\doxysection{osmux.\+h}
\label{osmux_8h_source}\index{include/osmocom/netif/osmux.h@{include/osmocom/netif/osmux.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#ifndef\ \_OSMUX\_H\_}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#define\ \_OSMUX\_H\_}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ <osmocom/core/endian.h>}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ <osmocom/core/timer.h>}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ <osmocom/core/msgb.h>}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00016\ \textcolor{preprocessor}{\#define\ OSMUX\_DEFAULT\_PORT\ 1984}}
\DoxyCodeLine{00017\ }
\DoxyCodeLine{00032\ \textcolor{preprocessor}{\#define\ OSMUX\_FT\_SIGNAL\ \ \ \ \ \ \ \ \ 0}}
\DoxyCodeLine{00033\ \textcolor{preprocessor}{\#define\ OSMUX\_FT\_VOICE\_AMR\ \ \ \ \ \ 1}}
\DoxyCodeLine{00034\ \textcolor{preprocessor}{\#define\ OSMUX\_FT\_DUMMY\ \ \ \ \ \ \ \ \ \ 2}}
\DoxyCodeLine{00035\ }
\DoxyCodeLine{00037\ \textcolor{keyword}{struct\ }osmux\_hdr\ \{}
\DoxyCodeLine{00038\ \textcolor{preprocessor}{\#if\ OSMO\_IS\_LITTLE\_ENDIAN}}
\DoxyCodeLine{00039\ \ \ \ \ \ \ \ \ uint8\_t\ amr\_q:1,}
\DoxyCodeLine{00040\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ amr\_f:1,}
\DoxyCodeLine{00041\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ctr:3,}
\DoxyCodeLine{00042\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ft:2,}
\DoxyCodeLine{00043\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rtp\_m:1;}
\DoxyCodeLine{00044\ \textcolor{preprocessor}{\#elif\ OSMO\_IS\_BIG\_ENDIAN}}
\DoxyCodeLine{00045\ \textcolor{comment}{/*\ auto-\/generated\ from\ the\ little\ endian\ part\ above\ (libosmocore/contrib/struct\_endianness.py)\ */}}
\DoxyCodeLine{00046\ \ \ \ \ \ \ \ \ uint8\_t\ rtp\_m:1,\ ft:2,\ ctr:3,\ amr\_f:1,\ amr\_q:1;}
\DoxyCodeLine{00047\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00048\ \ \ \ \ \ \ \ \ uint8\_t\ seq;}
\DoxyCodeLine{00049\ \textcolor{preprocessor}{\#define\ OSMUX\_CID\_MAX\ \ \ \ \ \ \ \ \ \ \ 255\ \ \ \ \ }\textcolor{comment}{/*\ determined\ by\ circuit\_id\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00050\ \ \ \ \ \ \ \ \ uint8\_t\ circuit\_id;}
\DoxyCodeLine{00051\ \textcolor{preprocessor}{\#if\ OSMO\_IS\_LITTLE\_ENDIAN}}
\DoxyCodeLine{00052\ \ \ \ \ \ \ \ \ uint8\_t\ amr\_cmr:4,}
\DoxyCodeLine{00053\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ amr\_ft:4;}
\DoxyCodeLine{00054\ \textcolor{preprocessor}{\#elif\ OSMO\_IS\_BIG\_ENDIAN}}
\DoxyCodeLine{00055\ \textcolor{comment}{/*\ auto-\/generated\ from\ the\ little\ endian\ part\ above\ (libosmocore/contrib/struct\_endianness.py)\ */}}
\DoxyCodeLine{00056\ \ \ \ \ \ \ \ \ uint8\_t\ amr\_ft:4,\ amr\_cmr:4;}
\DoxyCodeLine{00057\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00058\ \ \ \ \ \ \ \ \ uint8\_t\ data[0];}
\DoxyCodeLine{00059\ \}\ \_\_attribute\_\_((packed));}
\DoxyCodeLine{00060\ }
\DoxyCodeLine{00062\ \textcolor{keyword}{struct\ }osmux\_in\_handle\ \{}
\DoxyCodeLine{00064\ \ \ \ \ \ \ \ \ uint8\_t\ osmux\_seq;}
\DoxyCodeLine{00065\ \ \ \ \ \ \ \ \ uint8\_t\ batch\_factor;}
\DoxyCodeLine{00066\ \ \ \ \ \ \ \ \ uint16\_t\ batch\_size;}
\DoxyCodeLine{00067\ }
\DoxyCodeLine{00068\ \ \ \ \ \ \ \ \ \textcolor{keyword}{struct\ }\{}
\DoxyCodeLine{00069\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint32\_t\ input\_rtp\_msgs;}
\DoxyCodeLine{00070\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint32\_t\ output\_osmux\_msgs;}
\DoxyCodeLine{00071\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint64\_t\ input\_rtp\_bytes;}
\DoxyCodeLine{00072\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uint64\_t\ output\_osmux\_bytes;}
\DoxyCodeLine{00073\ \ \ \ \ \ \ \ \ \}\ stats;}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00075\ \ \ \ \ \ \ \ \ void\ (*deliver)(\textcolor{keyword}{struct\ }msgb\ *msg,\ \textcolor{keywordtype}{void}\ *data);}
\DoxyCodeLine{00076\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ *data;}
\DoxyCodeLine{00077\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ *internal\_data;\ \ \ \ \textcolor{comment}{/*\ internal\ data\ to\ store\ batch\ */}}
\DoxyCodeLine{00078\ \};}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00080\ \textcolor{preprocessor}{\#define\ OSMUX\_MAX\_CONCURRENT\_CALLS\ \ \ \ \ \ 8}}
\DoxyCodeLine{00081\ }
\DoxyCodeLine{00082\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }msgb\ *(*rtp\_msgb\_alloc\_cb\_t)(\textcolor{keywordtype}{void}\ *rtp\_msgb\_alloc\_priv\_data,}
\DoxyCodeLine{00083\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{int}\ msg\_len);}
\DoxyCodeLine{00085\ \textcolor{keyword}{struct\ }osmux\_out\_handle\ \{}
\DoxyCodeLine{00086\ \ \ \ \ \ \ \ \ uint16\_t\ rtp\_seq;}
\DoxyCodeLine{00087\ \ \ \ \ \ \ \ \ uint32\_t\ rtp\_timestamp;}
\DoxyCodeLine{00088\ \ \ \ \ \ \ \ \ uint32\_t\ rtp\_ssrc;}
\DoxyCodeLine{00089\ \ \ \ \ \ \ \ \ uint8\_t\ rtp\_payload\_type;}
\DoxyCodeLine{00090\ \ \ \ \ \ \ \ \ uint8\_t\ osmux\_seq\_ack;\ \textcolor{comment}{/*\ Latest\ received\ seq\ num\ */}}
\DoxyCodeLine{00091\ \ \ \ \ \ \ \ \ \textcolor{keyword}{struct\ }osmo\_timer\_list\ \ timer;}
\DoxyCodeLine{00092\ \ \ \ \ \ \ \ \ \textcolor{keyword}{struct\ }llist\_head\ list;}
\DoxyCodeLine{00093\ \ \ \ \ \ \ \ \ void\ (*tx\_cb)(\textcolor{keyword}{struct\ }msgb\ *msg,\ \textcolor{keywordtype}{void}\ *data);\ \textcolor{comment}{/*\ Used\ defined\ rtp\ tx\ callback\ */}}
\DoxyCodeLine{00094\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ *data;\ \textcolor{comment}{/*\ User\ defined\ opaque\ data\ structure\ */}}
\DoxyCodeLine{00095\ \ \ \ \ \ \ \ \ rtp\_msgb\_alloc\_cb\_t\ rtp\_msgb\_alloc\_cb;\ \textcolor{comment}{/*\ User\ defined\ msgb\ alloc\ function\ for\ generated\ RTP\ pkts\ */}}
\DoxyCodeLine{00096\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{void}\ *rtp\_msgb\_alloc\_cb\_data;\ \textcolor{comment}{/*\ Opaque\ data\ pointer\ set\ by\ user\ and\ passed\ in\ rtp\_msgb\_alloc\_cb()\ */}}
\DoxyCodeLine{00097\ \};}
\DoxyCodeLine{00098\ }
\DoxyCodeLine{00100\ \textcolor{keyword}{static}\ \textcolor{keyword}{inline}\ uint8\_t\ *osmux\_get\_payload(\textcolor{keyword}{struct}\ osmux\_hdr\ *osmuxh)}
\DoxyCodeLine{00101\ \{}
\DoxyCodeLine{00102\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ (uint8\_t\ *)osmuxh\ +\ \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct\ }osmux\_hdr);}
\DoxyCodeLine{00103\ \}}
\DoxyCodeLine{00104\ }
\DoxyCodeLine{00105\ \textcolor{keywordtype}{int}\ osmux\_snprintf(\textcolor{keywordtype}{char}\ *buf,\ \textcolor{keywordtype}{size\_t}\ size,\ \textcolor{keyword}{struct}\ msgb\ *msg);}
\DoxyCodeLine{00106\ }
\DoxyCodeLine{00107\ \textcolor{comment}{/*\ 1500\ -\/\ sizeof(iphdr)\ =\ 20\ bytes\ -\/\ sizeof(udphdr)\ =\ 8\ bytes.\ */}}
\DoxyCodeLine{00108\ \textcolor{preprocessor}{\#define\ OSMUX\_BATCH\_DEFAULT\_MAX\ \ \ \ \ \ \ \ \ 1472}}
\DoxyCodeLine{00109\ }
\DoxyCodeLine{00110\ \textcolor{keyword}{struct\ }osmux\_in\_handle\ *osmux\_xfrm\_input\_alloc(\textcolor{keywordtype}{void}\ *ctx);}
\DoxyCodeLine{00111\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_input\_init(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h)\ OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Use\ osmux\_xfrm\_input\_alloc()\ instead"{}});}
\DoxyCodeLine{00112\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_input\_fini(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h)\ OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Use\ talloc\_free()\ instead"{}});}
\DoxyCodeLine{00113\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_input\_set\_name(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *name);}
\DoxyCodeLine{00114\ \textcolor{keywordtype}{int}\ osmux\_xfrm\_input\_set\_batch\_factor(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h,\ uint8\_t\ batch\_factor);}
\DoxyCodeLine{00115\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_input\_set\_batch\_size(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h,\ uint16\_t\ batch\_size);}
\DoxyCodeLine{00116\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_input\_set\_initial\_seqnum(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h,\ uint8\_t\ osmux\_seqnum);}
\DoxyCodeLine{00117\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_input\_set\_deliver\_cb(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h,\ \textcolor{keywordtype}{void}\ (*deliver\_cb)(\textcolor{keyword}{struct}\ msgb\ *msg,\ \textcolor{keywordtype}{void}\ *data),\ \textcolor{keywordtype}{void}\ *data);}
\DoxyCodeLine{00118\ \textcolor{keywordtype}{void}\ *osmux\_xfrm\_input\_get\_deliver\_cb\_data(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h);}
\DoxyCodeLine{00119\ }
\DoxyCodeLine{00120\ \textcolor{keywordtype}{int}\ osmux\_xfrm\_input\_open\_circuit(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h,\ \textcolor{keywordtype}{int}\ ccid,\ \textcolor{keywordtype}{int}\ dummy);}
\DoxyCodeLine{00121\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_input\_close\_circuit(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h,\ \textcolor{keywordtype}{int}\ ccid);}
\DoxyCodeLine{00122\ }
\DoxyCodeLine{00123\ \textcolor{keywordtype}{int}\ osmux\_xfrm\_input(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h,\ \textcolor{keyword}{struct}\ msgb\ *msg,\ \textcolor{keywordtype}{int}\ ccid);}
\DoxyCodeLine{00124\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_input\_deliver(\textcolor{keyword}{struct}\ osmux\_in\_handle\ *h);}
\DoxyCodeLine{00125\ }
\DoxyCodeLine{00126\ \textcolor{keyword}{struct\ }osmux\_out\_handle\ *osmux\_xfrm\_output\_alloc(\textcolor{keywordtype}{void}\ *ctx);}
\DoxyCodeLine{00127\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_output\_init(\textcolor{keyword}{struct}\ osmux\_out\_handle\ *h,\ uint32\_t\ rtp\_ssrc)\ OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Use\ osmux\_xfrm\_output\_alloc()\ and\ osmux\_xfrm\_output\_set\_rtp\_*()\ instead"{}});}
\DoxyCodeLine{00128\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_output\_init2(\textcolor{keyword}{struct}\ osmux\_out\_handle\ *h,\ uint32\_t\ rtp\_ssrc,\ uint8\_t\ rtp\_payload\_type)\ OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Use\ osmux\_xfrm\_output\_alloc()\ and\ osmux\_xfrm\_output\_set\_rtp\_*()\ instead"{}});}
\DoxyCodeLine{00129\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_output\_set\_rtp\_ssrc(\textcolor{keyword}{struct}\ osmux\_out\_handle\ *h,\ uint32\_t\ rtp\_ssrc);}
\DoxyCodeLine{00130\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_output\_set\_rtp\_pl\_type(\textcolor{keyword}{struct}\ osmux\_out\_handle\ *h,\ uint32\_t\ rtp\_payload\_type);}
\DoxyCodeLine{00131\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_output\_set\_tx\_cb(\textcolor{keyword}{struct}\ osmux\_out\_handle\ *h,\ \textcolor{keywordtype}{void}\ (*tx\_cb)(\textcolor{keyword}{struct}\ msgb\ *msg,\ \textcolor{keywordtype}{void}\ *data),\ \textcolor{keywordtype}{void}\ *data);}
\DoxyCodeLine{00132\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_output\_set\_rtp\_msgb\_alloc\_cb(\textcolor{keyword}{struct}\ osmux\_out\_handle\ *h,\ rtp\_msgb\_alloc\_cb\_t\ cb,\ \textcolor{keywordtype}{void}\ *cb\_data);}
\DoxyCodeLine{00133\ \textcolor{keywordtype}{int}\ osmux\_xfrm\_output\_sched(\textcolor{keyword}{struct}\ osmux\_out\_handle\ *h,\ \textcolor{keyword}{struct}\ osmux\_hdr\ *osmuxh);}
\DoxyCodeLine{00134\ \textcolor{keywordtype}{void}\ osmux\_xfrm\_output\_flush(\textcolor{keyword}{struct}\ osmux\_out\_handle\ *h);}
\DoxyCodeLine{00135\ \textcolor{keyword}{struct\ }osmux\_hdr\ *osmux\_xfrm\_output\_pull(\textcolor{keyword}{struct}\ msgb\ *msg);}
\DoxyCodeLine{00138\ \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
