\section{Osmocom Multiplex Protocol}
\label{group__osmux}\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsection*{Files}
\begin{DoxyCompactItemize}
\item 
file \textbf{ osmux.\+h}
\item 
file \textbf{ osmux.\+c}
\begin{DoxyCompactList}\small\item\em Osmocom multiplex protocol helpers. \end{DoxyCompactList}\item 
file \textbf{ osmux\+\_\+input.\+c}
\begin{DoxyCompactList}\small\item\em Osmocom multiplex protocol helpers (input) \end{DoxyCompactList}\item 
file \textbf{ osmux\+\_\+output.\+c}
\begin{DoxyCompactList}\small\item\em Osmocom multiplex protocol helpers (output) \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmux\+\_\+hdr}
\item 
struct \textbf{ osmux\+\_\+in\+\_\+handle}
\item 
struct \textbf{ osmux\+\_\+out\+\_\+handle}
\item 
struct \textbf{ osmux\+\_\+batch}
\item 
struct \textbf{ osmux\+\_\+circuit}
\item 
struct \textbf{ osmux\+\_\+input\+\_\+state}
\item 
struct \textbf{ osmux\+\_\+tx\+\_\+handle}
\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{group__osmux_ga3bad2ffab901ca5152e03cf7fd21780f}} 
\#define {\bfseries O\+S\+M\+U\+X\+\_\+\+D\+E\+F\+A\+U\+L\+T\+\_\+\+P\+O\+RT}~1984
\item 
\mbox{\label{group__osmux_ga56541848fbbf5c529d7983685cbe1222}} 
\#define {\bfseries O\+S\+M\+U\+X\+\_\+\+F\+T\+\_\+\+S\+I\+G\+N\+AL}~0
\item 
\mbox{\label{group__osmux_gae48ff00bdb503143c58d74c08e3ea4c6}} 
\#define {\bfseries O\+S\+M\+U\+X\+\_\+\+F\+T\+\_\+\+V\+O\+I\+C\+E\+\_\+\+A\+MR}~1
\item 
\mbox{\label{group__osmux_ga08d783f0644a0f44c9e39bb851a0d2a9}} 
\#define {\bfseries O\+S\+M\+U\+X\+\_\+\+F\+T\+\_\+\+D\+U\+M\+MY}~2
\item 
\mbox{\label{group__osmux_ga97865ddcdfb9cf8d39653cf704e154c4}} 
\#define {\bfseries O\+S\+M\+U\+X\+\_\+\+M\+A\+X\+\_\+\+C\+O\+N\+C\+U\+R\+R\+E\+N\+T\+\_\+\+C\+A\+L\+LS}~8
\item 
\mbox{\label{group__osmux_gafcc9ef25a29d641a31523dfeb627d20b}} 
\#define {\bfseries O\+S\+M\+U\+X\+\_\+\+B\+A\+T\+C\+H\+\_\+\+D\+E\+F\+A\+U\+L\+T\+\_\+\+M\+AX}~1472
\item 
\#define {\bfseries S\+N\+P\+R\+I\+N\+T\+F\+\_\+\+B\+U\+F\+F\+E\+R\+\_\+\+S\+I\+ZE}(ret,  remain,  offset)
\item 
\mbox{\label{group__osmux_gaf5909a93287ea334985b9d1735ad0b60}} 
\#define {\bfseries D\+E\+L\+T\+A\+\_\+\+R\+T\+P\+\_\+\+M\+SG}~20000
\item 
\mbox{\label{group__osmux_gaeac1d5817fbc8473765723ddad171dc5}} 
\#define {\bfseries D\+E\+L\+T\+A\+\_\+\+R\+T\+P\+\_\+\+T\+I\+M\+E\+S\+T\+A\+MP}~160
\item 
\mbox{\label{group__osmux_gaf5909a93287ea334985b9d1735ad0b60}} 
\#define {\bfseries D\+E\+L\+T\+A\+\_\+\+R\+T\+P\+\_\+\+M\+SG}~20000
\item 
\mbox{\label{group__osmux_gaeac1d5817fbc8473765723ddad171dc5}} 
\#define {\bfseries D\+E\+L\+T\+A\+\_\+\+R\+T\+P\+\_\+\+T\+I\+M\+E\+S\+T\+A\+MP}~160
\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{group__osmux_ga03cfb6ba0f9b627732b6d87ef04e0411}} 
typedef struct msgb $\ast$($\ast$ {\bfseries rtp\+\_\+msgb\+\_\+alloc\+\_\+cb\+\_\+t}) (void $\ast$rtp\+\_\+msgb\+\_\+alloc\+\_\+priv\+\_\+data, unsigned int msg\+\_\+len)
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{group__osmux_gab731e55b448e102a7f0937d575442929}} 
struct \textbf{ osmux\+\_\+hdr} {\bfseries \+\_\+\+\_\+attribute\+\_\+\+\_\+} ((packed))
\item 
\mbox{\label{group__osmux_ga6d16616cb76c2eb9db17a4cee638f80c}} 
static uint8\+\_\+t $\ast$ {\bfseries osmux\+\_\+get\+\_\+payload} (struct \textbf{ osmux\+\_\+hdr} $\ast$osmuxh)
\item 
int \textbf{ osmux\+\_\+snprintf} (char $\ast$buf, size\+\_\+t size, struct msgb $\ast$msg)
\item 
struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$ \textbf{ osmux\+\_\+xfrm\+\_\+input\+\_\+alloc} (void $\ast$ctx)
\begin{DoxyCompactList}\small\item\em Allocate a new osmux in handle (osmux source, tx side) \end{DoxyCompactList}\item 
\mbox{\label{group__osmux_ga96230b0431d5d4d91f2dd57a9c85c366}} 
void {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+init} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h) O\+S\+M\+O\+\_\+\+D\+E\+P\+R\+E\+C\+A\+T\+ED(\char`\"{}Use \textbf{ osmux\+\_\+xfrm\+\_\+input\+\_\+alloc}() instead\char`\"{})
\item 
\mbox{\label{group__osmux_ga13655a3bdc68f5e96ad1fe1c03dc235e}} 
void {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+fini} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h) O\+S\+M\+O\+\_\+\+D\+E\+P\+R\+E\+C\+A\+T\+ED(\char`\"{}Use talloc\+\_\+free() instead\char`\"{})
\item 
\mbox{\label{group__osmux_gaaa21b6e362e0355b9a307b61ad11041a}} 
int {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+set\+\_\+batch\+\_\+factor} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h, uint8\+\_\+t batch\+\_\+factor)
\item 
\mbox{\label{group__osmux_gaa3ffcf5b445c0c8671893d5b753d6ce1}} 
void {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+set\+\_\+batch\+\_\+size} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h, uint16\+\_\+t batch\+\_\+size)
\item 
\mbox{\label{group__osmux_gaff9d6b79f4839694991dcfacb4dac346}} 
void {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+set\+\_\+initial\+\_\+seqnum} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h, uint8\+\_\+t osmux\+\_\+seqnum)
\item 
\mbox{\label{group__osmux_gac51a84e71885e60a84f03b6e21a04492}} 
void {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+set\+\_\+deliver\+\_\+cb} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h, void($\ast$deliver\+\_\+cb)(struct msgb $\ast$msg, void $\ast$data), void $\ast$data)
\item 
\mbox{\label{group__osmux_gad93348881be4037fd67379f11d287f96}} 
void $\ast$ {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+get\+\_\+deliver\+\_\+cb\+\_\+data} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h)
\item 
\mbox{\label{group__osmux_ga8976891414ad18103efb8829b4b2844a}} 
int {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+open\+\_\+circuit} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h, int ccid, int dummy)
\item 
\mbox{\label{group__osmux_ga2c12c883c9dd7abd80b47802ef991b32}} 
void {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+close\+\_\+circuit} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h, int ccid)
\item 
int \textbf{ osmux\+\_\+xfrm\+\_\+input} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h, struct msgb $\ast$msg, int ccid)
\item 
\mbox{\label{group__osmux_gafad3a85e58f396db7544ac0138df7974}} 
void {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+deliver} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h)
\item 
struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$ \textbf{ osmux\+\_\+xfrm\+\_\+output\+\_\+alloc} (void $\ast$ctx)
\begin{DoxyCompactList}\small\item\em Allocate a new osmux out handle. \end{DoxyCompactList}\item 
\mbox{\label{group__osmux_ga90d58246bcd24a6126898cd6c47dddf4}} 
void {\bfseries osmux\+\_\+xfrm\+\_\+output\+\_\+init} (struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$h, uint32\+\_\+t rtp\+\_\+ssrc) O\+S\+M\+O\+\_\+\+D\+E\+P\+R\+E\+C\+A\+T\+ED(\char`\"{}Use \textbf{ osmux\+\_\+xfrm\+\_\+output\+\_\+alloc}() and osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+$\ast$() instead\char`\"{})
\item 
\mbox{\label{group__osmux_gaa076e54fa0d249721a4c7b174a8ed2d1}} 
void {\bfseries osmux\+\_\+xfrm\+\_\+output\+\_\+init2} (struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$h, uint32\+\_\+t rtp\+\_\+ssrc, uint8\+\_\+t rtp\+\_\+payload\+\_\+type) O\+S\+M\+O\+\_\+\+D\+E\+P\+R\+E\+C\+A\+T\+ED(\char`\"{}Use \textbf{ osmux\+\_\+xfrm\+\_\+output\+\_\+alloc}() and osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+$\ast$() instead\char`\"{})
\item 
void \textbf{ osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+ssrc} (struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$h, uint32\+\_\+t rtp\+\_\+ssrc)
\begin{DoxyCompactList}\small\item\em Set S\+S\+RC of generated R\+TP packets from Osmux frames. \end{DoxyCompactList}\item 
void \textbf{ osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+pl\+\_\+type} (struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$h, uint32\+\_\+t rtp\+\_\+payload\+\_\+type)
\begin{DoxyCompactList}\small\item\em Set Payload Type of generated R\+TP packets from Osmux frames. \end{DoxyCompactList}\item 
void \textbf{ osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+tx\+\_\+cb} (struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$h, void($\ast$tx\+\_\+cb)(struct msgb $\ast$msg, void $\ast$data), void $\ast$data)
\begin{DoxyCompactList}\small\item\em Set transmission callback to call when a generated R\+TP packet is to be transmitted. \end{DoxyCompactList}\item 
void \textbf{ osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+msgb\+\_\+alloc\+\_\+cb} (struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$h, rtp\+\_\+msgb\+\_\+alloc\+\_\+cb\+\_\+t cb, void $\ast$cb\+\_\+data)
\begin{DoxyCompactList}\small\item\em Set callback to call when an R\+TP packet to be generated is to be allocated. \end{DoxyCompactList}\item 
int \textbf{ osmux\+\_\+xfrm\+\_\+output\+\_\+sched} (struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$h, struct \textbf{ osmux\+\_\+hdr} $\ast$osmuxh)
\begin{DoxyCompactList}\small\item\em Generate R\+TP packets from osmux frame A\+MR payload set and schedule them for transmission at appropriate time. \end{DoxyCompactList}\item 
void \textbf{ osmux\+\_\+xfrm\+\_\+output\+\_\+flush} (struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$h)
\begin{DoxyCompactList}\small\item\em Flush all scheduled R\+TP packets still pending to be transmitted. \end{DoxyCompactList}\item 
\mbox{\label{group__osmux_ga613c43d4166a4985718f8e4f7216efcc}} 
struct \textbf{ osmux\+\_\+hdr} $\ast$ {\bfseries osmux\+\_\+xfrm\+\_\+output\+\_\+pull} (struct msgb $\ast$msg)
\item 
\mbox{\label{group__osmux_ga7173385a73a58d9e591c89c9ce6f2162}} 
static uint32\+\_\+t {\bfseries osmux\+\_\+get\+\_\+payload\+\_\+len} (struct \textbf{ osmux\+\_\+hdr} $\ast$osmuxh)
\item 
\mbox{\label{group__osmux_gad22fb7955b289918b8b16be80b07e957}} 
static int {\bfseries osmux\+\_\+snprintf\+\_\+header} (char $\ast$buf, size\+\_\+t size, struct \textbf{ osmux\+\_\+hdr} $\ast$osmuxh)
\item 
\mbox{\label{group__osmux_ga7e0da74da38893a8823b9247ba66e187}} 
static int {\bfseries osmux\+\_\+snprintf\+\_\+payload} (char $\ast$buf, size\+\_\+t size, const uint8\+\_\+t $\ast$payload, int payload\+\_\+len)
\item 
\mbox{\label{group__osmux_gaf756352e90aa8ab0e96c0f43f23c36d3}} 
static uint32\+\_\+t {\bfseries osmux\+\_\+ft\+\_\+dummy\+\_\+size} (uint8\+\_\+t amr\+\_\+ft, uint8\+\_\+t batch\+\_\+factor)
\item 
\mbox{\label{group__osmux_gac9a41c7caa16060666e7cf639e68e8a3}} 
static int {\bfseries osmux\+\_\+circuit\+\_\+enqueue} (struct \textbf{ osmux\+\_\+circuit} $\ast$circuit, struct msgb $\ast$msg, uint8\+\_\+t batch\+\_\+factor)
\item 
\mbox{\label{group__osmux_ga653eedeb61af21686961a758ae1ac1af}} 
static void {\bfseries osmux\+\_\+circuit\+\_\+dequeue} (struct \textbf{ osmux\+\_\+circuit} $\ast$circuit, struct msgb $\ast$msg)
\item 
\mbox{\label{group__osmux_gae8885fa2c6a40cf4cee4377dc46aeb94}} 
static void {\bfseries osmux\+\_\+circuit\+\_\+del\+\_\+msgs} (struct \textbf{ osmux\+\_\+batch} $\ast$batch, struct \textbf{ osmux\+\_\+circuit} $\ast$circuit)
\item 
\mbox{\label{group__osmux_ga817c50f0b3f136dc138e286325b85398}} 
static int {\bfseries osmux\+\_\+batch\+\_\+put} (struct \textbf{ osmux\+\_\+batch} $\ast$batch, struct \textbf{ osmux\+\_\+input\+\_\+state} $\ast$state)
\item 
\mbox{\label{group__osmux_ga323417cc06a5ed2e805264d462cd1a0b}} 
static void {\bfseries osmux\+\_\+encode\+\_\+dummy} (struct \textbf{ osmux\+\_\+batch} $\ast$batch, uint8\+\_\+t batch\+\_\+factor, struct \textbf{ osmux\+\_\+input\+\_\+state} $\ast$state)
\item 
\mbox{\label{group__osmux_ga63b5729acea7a10988b59c7980ab0fea}} 
static struct msgb $\ast$ {\bfseries osmux\+\_\+build\+\_\+batch} (struct \textbf{ osmux\+\_\+batch} $\ast$batch, uint32\+\_\+t batch\+\_\+size, uint8\+\_\+t batch\+\_\+factor)
\item 
\mbox{\label{group__osmux_ga0338c55965aa1658a42b7acf1d2e5d34}} 
static void {\bfseries osmux\+\_\+batch\+\_\+timer\+\_\+expired} (void $\ast$data)
\item 
\mbox{\label{group__osmux_ga102333c0e4201c9be9d953c0d284419c}} 
static int {\bfseries osmux\+\_\+rtp\+\_\+amr\+\_\+payload\+\_\+len} (struct \textbf{ amr\+\_\+hdr} $\ast$amrh, uint32\+\_\+t amr\+\_\+len)
\item 
\mbox{\label{group__osmux_gae6dc57a9803a56429f70f3210700c909}} 
static int {\bfseries osmux\+\_\+circuit\+\_\+get\+\_\+last\+\_\+stored\+\_\+amr\+\_\+ft} (struct \textbf{ osmux\+\_\+circuit} $\ast$circuit)
\item 
\mbox{\label{group__osmux_gacbbc3ea829bfc1f02e437c4180c04a4e}} 
static int {\bfseries osmux\+\_\+replay\+\_\+lost\+\_\+packets} (struct \textbf{ osmux\+\_\+circuit} $\ast$circuit, struct \textbf{ rtp\+\_\+hdr} $\ast$cur\+\_\+rtph, int batch\+\_\+factor)
\item 
\mbox{\label{group__osmux_ga9becda4685cfea6a8ee501fb93803092}} 
static struct \textbf{ osmux\+\_\+circuit} $\ast$ {\bfseries osmux\+\_\+batch\+\_\+find\+\_\+circuit} (struct \textbf{ osmux\+\_\+batch} $\ast$batch, int ccid)
\item 
\mbox{\label{group__osmux_ga4e06c9952928c96f893002794c24f7f1}} 
static void {\bfseries osmux\+\_\+batch\+\_\+del\+\_\+circuit} (struct \textbf{ osmux\+\_\+batch} $\ast$batch, struct \textbf{ osmux\+\_\+circuit} $\ast$circuit)
\item 
\mbox{\label{group__osmux_gaf11c2b30f84dcc858c4da254d2e6f3f9}} 
static int {\bfseries osmux\+\_\+batch\+\_\+add} (struct \textbf{ osmux\+\_\+batch} $\ast$batch, uint32\+\_\+t batch\+\_\+factor, struct msgb $\ast$msg, struct \textbf{ rtp\+\_\+hdr} $\ast$rtph, int ccid)
\item 
\mbox{\label{group__osmux_ga50fd802112c677bd2bd90dbad52c0454}} 
static int {\bfseries osmux\+\_\+xfrm\+\_\+input\+\_\+talloc\+\_\+destructor} (struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$h)
\item 
\mbox{\label{group__osmux_ga21f39732f8635545f2171af97297b639}} 
static struct msgb $\ast$ {\bfseries osmux\+\_\+rebuild\+\_\+rtp} (struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$h, struct \textbf{ osmux\+\_\+hdr} $\ast$osmuxh, void $\ast$payload, int payload\+\_\+len, bool first\+\_\+pkt)
\item 
\mbox{\label{group__osmux_gafad4414de98f24dcce1c5a7878e652c6}} 
static void {\bfseries osmux\+\_\+xfrm\+\_\+output\+\_\+trigger} (void $\ast$data)
\item 
\mbox{\label{group__osmux_ga9eefd8d88e9fe8b1d1d2ed4460720f36}} 
static int {\bfseries osmux\+\_\+xfrm\+\_\+output\+\_\+talloc\+\_\+destructor} (struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$h)
\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{group__osmux_ga9dd31e4f6a9ad599afbb4600bec665f2}} 
struct \textbf{ osmux\+\_\+in\+\_\+handle} {\bfseries \+\_\+\+\_\+attribute\+\_\+\+\_\+}
\item 
\mbox{\label{group__osmux_ga408d4648bd8b85223d46124c5157006d}} 
static void $\ast$ {\bfseries osmux\+\_\+ctx}
\end{DoxyCompactItemize}


\subsection{Detailed Description}
This code implements a variety of utility functions related to the O\+S\+M\+UX user-\/plane multiplexing protocol, an efficient alternative to plain U\+D\+P/\+R\+TP streams for voice transport in back-\/haul of cellular networks.

For information about the O\+S\+M\+UX protocol design, please see the O\+S\+M\+UX reference manual at {\tt http\+://ftp.\+osmocom.\+org/docs/latest/osmux-\/reference.\+pdf} 

\subsection{Macro Definition Documentation}
\mbox{\label{group__osmux_ga6aef25db0cf5336a997cae7c402e55be}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!S\+N\+P\+R\+I\+N\+T\+F\+\_\+\+B\+U\+F\+F\+E\+R\+\_\+\+S\+I\+ZE@{S\+N\+P\+R\+I\+N\+T\+F\+\_\+\+B\+U\+F\+F\+E\+R\+\_\+\+S\+I\+ZE}}
\index{S\+N\+P\+R\+I\+N\+T\+F\+\_\+\+B\+U\+F\+F\+E\+R\+\_\+\+S\+I\+ZE@{S\+N\+P\+R\+I\+N\+T\+F\+\_\+\+B\+U\+F\+F\+E\+R\+\_\+\+S\+I\+ZE}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{S\+N\+P\+R\+I\+N\+T\+F\+\_\+\+B\+U\+F\+F\+E\+R\+\_\+\+S\+I\+ZE}
{\footnotesize\ttfamily \#define S\+N\+P\+R\+I\+N\+T\+F\+\_\+\+B\+U\+F\+F\+E\+R\+\_\+\+S\+I\+ZE(\begin{DoxyParamCaption}\item[{}]{ret,  }\item[{}]{remain,  }\item[{}]{offset }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keywordflow}{if} (ret < 0)                                    \(\backslash\)
                ret = 0;                                \(\backslash\)
        offset += ret;                                  \(\backslash\)
        if (ret > remain)                               \(\backslash\)
                ret = remain;                           \(\backslash\)
        remain -= ret;
\end{DoxyCode}


\subsection{Function Documentation}
\mbox{\label{group__osmux_gaf654e092ca97dd764f59905a2ed21650}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!osmux\+\_\+snprintf@{osmux\+\_\+snprintf}}
\index{osmux\+\_\+snprintf@{osmux\+\_\+snprintf}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{osmux\+\_\+snprintf()}
{\footnotesize\ttfamily int osmux\+\_\+snprintf (\begin{DoxyParamCaption}\item[{char $\ast$}]{buf,  }\item[{size\+\_\+t}]{size,  }\item[{struct msgb $\ast$}]{msg }\end{DoxyParamCaption})}

Print osmux header fields and payload from msg into buffer buf. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt out}  & {\em buf} & buffer to store the output into \\
\hline
\mbox{\tt in}  & {\em len} & length of buf in bytes \\
\hline
\mbox{\tt in}  & {\em msgb} & message buffer containing one or more osmux frames \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of characters printed (excluding the null byte used to end output to strings).
\end{DoxyReturn}
If the output was truncated due to this limit, then the return value is the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available. \mbox{\label{group__osmux_ga9c7d30c0d7d9bc0caf744799d629d4cc}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!osmux\+\_\+xfrm\+\_\+input@{osmux\+\_\+xfrm\+\_\+input}}
\index{osmux\+\_\+xfrm\+\_\+input@{osmux\+\_\+xfrm\+\_\+input}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{osmux\+\_\+xfrm\+\_\+input()}
{\footnotesize\ttfamily int osmux\+\_\+xfrm\+\_\+input (\begin{DoxyParamCaption}\item[{struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$}]{h,  }\item[{struct msgb $\ast$}]{msg,  }\item[{int}]{ccid }\end{DoxyParamCaption})}

osmux\+\_\+xfrm\+\_\+input -\/ add R\+TP message to O\+Smux batch 
\begin{DoxyParams}{Parameters}
{\em msg} & R\+TP message that you want to batch into one O\+Smux message\\
\hline
\end{DoxyParams}
If 0 is returned, this indicates that the message has been batched and the msgb is now owned by the osmux layer. If negative value is returned, an error occurred and the message has been dropped (and freed). If 1 is returned, you have to invoke osmux\+\_\+xfrm\+\_\+input\+\_\+deliver and try again.

The function takes care of releasing the messages in case of error and when building the batch. \mbox{\label{group__osmux_gad61cdde332496df6d7350d147e50b8be}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!osmux\+\_\+xfrm\+\_\+input\+\_\+alloc@{osmux\+\_\+xfrm\+\_\+input\+\_\+alloc}}
\index{osmux\+\_\+xfrm\+\_\+input\+\_\+alloc@{osmux\+\_\+xfrm\+\_\+input\+\_\+alloc}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{osmux\+\_\+xfrm\+\_\+input\+\_\+alloc()}
{\footnotesize\ttfamily struct \textbf{ osmux\+\_\+in\+\_\+handle} $\ast$ osmux\+\_\+xfrm\+\_\+input\+\_\+alloc (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx }\end{DoxyParamCaption})}



Allocate a new osmux in handle (osmux source, tx side) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em ctx} & talloc context to use when allocating the returned struct \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Allocated osmux in handle
\end{DoxyReturn}
This object contains configuration and state to handle a group of circuits (trunk), receiving R\+TP packets from the upper layer (A\+PI user) and sending batched \& trunked Osmux messages containing all the data of those circuits down the stack outgoing network Osmux messages. Returned pointer can be freed with regular talloc\+\_\+free, all pending messages in queue and all internal data will be freed. \mbox{\label{group__osmux_ga41a217bffa1b0ac095c98ab0fab82c25}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!osmux\+\_\+xfrm\+\_\+output\+\_\+alloc@{osmux\+\_\+xfrm\+\_\+output\+\_\+alloc}}
\index{osmux\+\_\+xfrm\+\_\+output\+\_\+alloc@{osmux\+\_\+xfrm\+\_\+output\+\_\+alloc}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{osmux\+\_\+xfrm\+\_\+output\+\_\+alloc()}
{\footnotesize\ttfamily struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$ osmux\+\_\+xfrm\+\_\+output\+\_\+alloc (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx }\end{DoxyParamCaption})}



Allocate a new osmux out handle. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em ctx} & talloc context to use when allocating the returned struct \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Allocated osmux out handle
\end{DoxyReturn}
This object contains configuration and state to handle a specific C\+ID in incoming network Osmux messages, repackaging the frames for that C\+ID as R\+TP packets and pushing them up the protocol stack. Returned pointer can be freed with regular talloc\+\_\+free, queue will be flushed and all internal data will be freed. \mbox{\label{group__osmux_gaaac410425f6470396ae9db53ebb8dc44}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!osmux\+\_\+xfrm\+\_\+output\+\_\+flush@{osmux\+\_\+xfrm\+\_\+output\+\_\+flush}}
\index{osmux\+\_\+xfrm\+\_\+output\+\_\+flush@{osmux\+\_\+xfrm\+\_\+output\+\_\+flush}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{osmux\+\_\+xfrm\+\_\+output\+\_\+flush()}
{\footnotesize\ttfamily void osmux\+\_\+xfrm\+\_\+output\+\_\+flush (\begin{DoxyParamCaption}\item[{struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$}]{h }\end{DoxyParamCaption})}



Flush all scheduled R\+TP packets still pending to be transmitted. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em h} & the osmux out handle to flush\\
\hline
\end{DoxyParams}
This function will immediately call the transmit callback for all queued R\+TP packets, making sure the list ends up empty. It will also stop all internal timers to make sure the \doxyref{osmux\+\_\+out\+\_\+handle}{p.}{structosmux__out__handle} can be dropped or re-\/used by calling osmux\+\_\+xfrm\+\_\+output on it. \mbox{\label{group__osmux_gafee78ee4522a9caa238301d7b913dfd6}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!osmux\+\_\+xfrm\+\_\+output\+\_\+sched@{osmux\+\_\+xfrm\+\_\+output\+\_\+sched}}
\index{osmux\+\_\+xfrm\+\_\+output\+\_\+sched@{osmux\+\_\+xfrm\+\_\+output\+\_\+sched}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{osmux\+\_\+xfrm\+\_\+output\+\_\+sched()}
{\footnotesize\ttfamily int osmux\+\_\+xfrm\+\_\+output\+\_\+sched (\begin{DoxyParamCaption}\item[{struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$}]{h,  }\item[{struct \textbf{ osmux\+\_\+hdr} $\ast$}]{osmuxh }\end{DoxyParamCaption})}



Generate R\+TP packets from osmux frame A\+MR payload set and schedule them for transmission at appropriate time. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em h} & the osmux out handle handling a specific C\+ID \\
\hline
\mbox{\tt in}  & {\em osmuxh} & Buffer pointing to osmux frame header structure and A\+MR payload \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Number of generated R\+TP packets
\end{DoxyReturn}
The osmux frame passed to this function must be of the type O\+S\+M\+U\+X\+\_\+\+F\+T\+\_\+\+V\+O\+I\+C\+E\+\_\+\+A\+MR. The generated R\+TP packets are kept into h\textquotesingle{}s internal list and sent to the callback configured through osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+tx\+\_\+cb when are ready to be transmitted according to schedule. \mbox{\label{group__osmux_ga97187827e1f793f2392e54585343db32}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+msgb\+\_\+alloc\+\_\+cb@{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+msgb\+\_\+alloc\+\_\+cb}}
\index{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+msgb\+\_\+alloc\+\_\+cb@{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+msgb\+\_\+alloc\+\_\+cb}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+msgb\+\_\+alloc\+\_\+cb()}
{\footnotesize\ttfamily void osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+msgb\+\_\+alloc\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$}]{h,  }\item[{rtp\+\_\+msgb\+\_\+alloc\+\_\+cb\+\_\+t}]{cb,  }\item[{void $\ast$}]{cb\+\_\+data }\end{DoxyParamCaption})}



Set callback to call when an R\+TP packet to be generated is to be allocated. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em h} & the osmux out handle handling a specific C\+ID \\
\hline
\mbox{\tt in}  & {\em cb} & User defined msgb alloc function for generated R\+TP pkts \\
\hline
\mbox{\tt in}  & {\em cb\+\_\+data} & Opaque data pointer set by user and passed in cb \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
msgb structure to be used to fill in generated R\+TP pkt content 
\end{DoxyReturn}
\mbox{\label{group__osmux_ga0d96c8a544e0ff56576615e0b2ac7774}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+pl\+\_\+type@{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+pl\+\_\+type}}
\index{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+pl\+\_\+type@{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+pl\+\_\+type}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+pl\+\_\+type()}
{\footnotesize\ttfamily void osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+pl\+\_\+type (\begin{DoxyParamCaption}\item[{struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$}]{h,  }\item[{uint32\+\_\+t}]{rtp\+\_\+payload\+\_\+type }\end{DoxyParamCaption})}



Set Payload Type of generated R\+TP packets from Osmux frames. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em h} & the osmux out handle handling a specific C\+ID \\
\hline
\mbox{\tt in}  & {\em rtp\+\_\+payload\+\_\+type} & the R\+TP Payload Type to set \\
\hline
\end{DoxyParams}
\mbox{\label{group__osmux_ga08151bad3c12df245d4c0e4f9c4ca966}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+ssrc@{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+ssrc}}
\index{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+ssrc@{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+ssrc}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+ssrc()}
{\footnotesize\ttfamily void osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+rtp\+\_\+ssrc (\begin{DoxyParamCaption}\item[{struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$}]{h,  }\item[{uint32\+\_\+t}]{rtp\+\_\+ssrc }\end{DoxyParamCaption})}



Set S\+S\+RC of generated R\+TP packets from Osmux frames. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em h} & the osmux out handle handling a specific C\+ID \\
\hline
\mbox{\tt in}  & {\em rtp\+\_\+ssrc} & the R\+TP S\+S\+RC to set \\
\hline
\end{DoxyParams}
\mbox{\label{group__osmux_ga3936e43e881d0992648937417969ead1}} 
\index{Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}!osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+tx\+\_\+cb@{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+tx\+\_\+cb}}
\index{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+tx\+\_\+cb@{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+tx\+\_\+cb}!Osmocom Multiplex Protocol@{Osmocom Multiplex Protocol}}
\subsubsection{osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+tx\+\_\+cb()}
{\footnotesize\ttfamily void osmux\+\_\+xfrm\+\_\+output\+\_\+set\+\_\+tx\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmux\+\_\+out\+\_\+handle} $\ast$}]{h,  }\item[{void($\ast$)(struct msgb $\ast$msg, void $\ast$data)}]{tx\+\_\+cb,  }\item[{void $\ast$}]{data }\end{DoxyParamCaption})}



Set transmission callback to call when a generated R\+TP packet is to be transmitted. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em h} & the osmux out handle handling a specific C\+ID \\
\hline
\mbox{\tt in}  & {\em osmuxh} & Buffer pointing to osmux frame header structure and A\+MR payload \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Number of generated R\+TP packets
\end{DoxyReturn}
This Function sets the callback called by the interal timer set by osmux\+\_\+xfrm\+\_\+out\+\_\+sched function. 