\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{1 \textcolor{preprocessor}{\#ifndef \_OSMUX\_H\_}}
\DoxyCodeLine{2 \textcolor{preprocessor}{\#define \_OSMUX\_H\_}}
\DoxyCodeLine{3 }
\DoxyCodeLine{4 \textcolor{preprocessor}{\#include <osmocom/core/endian.h>}}
\DoxyCodeLine{5 \textcolor{preprocessor}{\#include <osmocom/core/timer.h>}}
\DoxyCodeLine{6 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{7 }
\DoxyCodeLine{16 \textcolor{preprocessor}{\#define OSMUX\_DEFAULT\_PORT 1984}}
\DoxyCodeLine{17 }
\DoxyCodeLine{32 \textcolor{preprocessor}{\#define OSMUX\_FT\_SIGNAL         0}}
\DoxyCodeLine{33 \textcolor{preprocessor}{\#define OSMUX\_FT\_VOICE\_AMR      1}}
\DoxyCodeLine{34 \textcolor{preprocessor}{\#define OSMUX\_FT\_DUMMY          2}}
\DoxyCodeLine{35 }
\DoxyCodeLine{37 \textcolor{keyword}{struct }osmux\_hdr \{}
\DoxyCodeLine{38 \textcolor{preprocessor}{\#if OSMO\_IS\_LITTLE\_ENDIAN}}
\DoxyCodeLine{39         uint8\_t amr\_q:1,}
\DoxyCodeLine{40                 amr\_f:1,}
\DoxyCodeLine{41                 ctr:3,}
\DoxyCodeLine{42                 ft:2,}
\DoxyCodeLine{43                 rtp\_m:1;}
\DoxyCodeLine{44 \textcolor{preprocessor}{\#elif OSMO\_IS\_BIG\_ENDIAN}}
\DoxyCodeLine{45 \textcolor{comment}{/* auto-\/generated from the little endian part above (libosmocore/contrib/struct\_endianness.py) */}}
\DoxyCodeLine{46         uint8\_t rtp\_m:1, ft:2, ctr:3, amr\_f:1, amr\_q:1;}
\DoxyCodeLine{47 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{48         uint8\_t seq;}
\DoxyCodeLine{49 \textcolor{preprocessor}{\#define OSMUX\_CID\_MAX           255     }\textcolor{comment}{/* determined by circuit\_id */}\textcolor{preprocessor}{}}
\DoxyCodeLine{50         uint8\_t circuit\_id;}
\DoxyCodeLine{51 \textcolor{preprocessor}{\#if OSMO\_IS\_LITTLE\_ENDIAN}}
\DoxyCodeLine{52         uint8\_t amr\_cmr:4,}
\DoxyCodeLine{53                 amr\_ft:4;}
\DoxyCodeLine{54 \textcolor{preprocessor}{\#elif OSMO\_IS\_BIG\_ENDIAN}}
\DoxyCodeLine{55 \textcolor{comment}{/* auto-\/generated from the little endian part above (libosmocore/contrib/struct\_endianness.py) */}}
\DoxyCodeLine{56         uint8\_t amr\_ft:4, amr\_cmr:4;}
\DoxyCodeLine{57 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{58         uint8\_t data[0];}
\DoxyCodeLine{59 \} \_\_attribute\_\_((packed));}
\DoxyCodeLine{60 }
\DoxyCodeLine{62 \textcolor{keyword}{struct }osmux\_in\_handle \{}
\DoxyCodeLine{64         uint8\_t osmux\_seq;}
\DoxyCodeLine{65         uint8\_t batch\_factor;}
\DoxyCodeLine{66         uint16\_t batch\_size;}
\DoxyCodeLine{67 }
\DoxyCodeLine{68         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{69                 uint32\_t input\_rtp\_msgs;}
\DoxyCodeLine{70                 uint32\_t output\_osmux\_msgs;}
\DoxyCodeLine{71                 uint64\_t input\_rtp\_bytes;}
\DoxyCodeLine{72                 uint64\_t output\_osmux\_bytes;}
\DoxyCodeLine{73         \} stats;}
\DoxyCodeLine{74 }
\DoxyCodeLine{75         void (*deliver)(\textcolor{keyword}{struct }msgb *msg, \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{76         \textcolor{keywordtype}{void} *data;}
\DoxyCodeLine{77         \textcolor{keywordtype}{char} *internal\_data;    \textcolor{comment}{/* internal data to store batch */}}
\DoxyCodeLine{78 \};}
\DoxyCodeLine{79 }
\DoxyCodeLine{80 \textcolor{preprocessor}{\#define OSMUX\_MAX\_CONCURRENT\_CALLS      8}}
\DoxyCodeLine{81 }
\DoxyCodeLine{82 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }msgb *(*rtp\_msgb\_alloc\_cb\_t)(\textcolor{keywordtype}{void} *rtp\_msgb\_alloc\_priv\_data,}
\DoxyCodeLine{83                                             \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} msg\_len);}
\DoxyCodeLine{85 \textcolor{keyword}{struct }osmux\_out\_handle \{}
\DoxyCodeLine{86         uint16\_t rtp\_seq;}
\DoxyCodeLine{87         uint32\_t rtp\_timestamp;}
\DoxyCodeLine{88         uint32\_t rtp\_ssrc;}
\DoxyCodeLine{89         uint8\_t rtp\_payload\_type;}
\DoxyCodeLine{90         uint8\_t osmux\_seq\_ack; \textcolor{comment}{/* Latest received seq num */}}
\DoxyCodeLine{91         \textcolor{keyword}{struct }osmo\_timer\_list  timer;}
\DoxyCodeLine{92         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{93         void (*tx\_cb)(\textcolor{keyword}{struct }msgb *msg, \textcolor{keywordtype}{void} *data); \textcolor{comment}{/* Used defined rtp tx callback */}}
\DoxyCodeLine{94         \textcolor{keywordtype}{void} *data; \textcolor{comment}{/* User defined opaque data structure */}}
\DoxyCodeLine{95         rtp\_msgb\_alloc\_cb\_t rtp\_msgb\_alloc\_cb; \textcolor{comment}{/* User defined msgb alloc function for generated RTP pkts */}}
\DoxyCodeLine{96         \textcolor{keywordtype}{void} *rtp\_msgb\_alloc\_cb\_data; \textcolor{comment}{/* Opaque data pointer set by user and passed in rtp\_msgb\_alloc\_cb() */}}
\DoxyCodeLine{97 \};}
\DoxyCodeLine{98 }
\DoxyCodeLine{100 \textcolor{keyword}{static} \textcolor{keyword}{inline} uint8\_t *osmux\_get\_payload(\textcolor{keyword}{struct} osmux\_hdr *osmuxh)}
\DoxyCodeLine{101 \{}
\DoxyCodeLine{102         \textcolor{keywordflow}{return} (uint8\_t *)osmuxh + \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct }osmux\_hdr);}
\DoxyCodeLine{103 \}}
\DoxyCodeLine{104 }
\DoxyCodeLine{105 \textcolor{keywordtype}{int} osmux\_snprintf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} size, \textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{106 }
\DoxyCodeLine{107 \textcolor{comment}{/* 1500 -\/ sizeof(iphdr) = 20 bytes -\/ sizeof(udphdr) = 8 bytes. */}}
\DoxyCodeLine{108 \textcolor{preprocessor}{\#define OSMUX\_BATCH\_DEFAULT\_MAX         1472}}
\DoxyCodeLine{109 }
\DoxyCodeLine{110 \textcolor{keyword}{struct }osmux\_in\_handle *osmux\_xfrm\_input\_alloc(\textcolor{keywordtype}{void} *ctx);}
\DoxyCodeLine{111 \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{112 \textcolor{keywordtype}{void} osmux\_xfrm\_input\_fini(\textcolor{keyword}{struct} osmux\_in\_handle *h) OSMO\_DEPRECATED(\textcolor{stringliteral}{"{}Use talloc\_free() instead"{}});}
\DoxyCodeLine{113 \textcolor{keywordtype}{void} osmux\_xfrm\_input\_set\_name(\textcolor{keyword}{struct} osmux\_in\_handle *h, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{114 \textcolor{keywordtype}{int} osmux\_xfrm\_input\_set\_batch\_factor(\textcolor{keyword}{struct} osmux\_in\_handle *h, uint8\_t batch\_factor);}
\DoxyCodeLine{115 \textcolor{keywordtype}{void} osmux\_xfrm\_input\_set\_batch\_size(\textcolor{keyword}{struct} osmux\_in\_handle *h, uint16\_t batch\_size);}
\DoxyCodeLine{116 \textcolor{keywordtype}{void} osmux\_xfrm\_input\_set\_initial\_seqnum(\textcolor{keyword}{struct} osmux\_in\_handle *h, uint8\_t osmux\_seqnum);}
\DoxyCodeLine{117 \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{118 \textcolor{keywordtype}{void} *osmux\_xfrm\_input\_get\_deliver\_cb\_data(\textcolor{keyword}{struct} osmux\_in\_handle *h);}
\DoxyCodeLine{119 }
\DoxyCodeLine{120 \textcolor{keywordtype}{int} osmux\_xfrm\_input\_open\_circuit(\textcolor{keyword}{struct} osmux\_in\_handle *h, \textcolor{keywordtype}{int} ccid, \textcolor{keywordtype}{int} dummy);}
\DoxyCodeLine{121 \textcolor{keywordtype}{void} osmux\_xfrm\_input\_close\_circuit(\textcolor{keyword}{struct} osmux\_in\_handle *h, \textcolor{keywordtype}{int} ccid);}
\DoxyCodeLine{122 }
\DoxyCodeLine{123 \textcolor{keywordtype}{int} osmux\_xfrm\_input(\textcolor{keyword}{struct} osmux\_in\_handle *h, \textcolor{keyword}{struct} msgb *msg, \textcolor{keywordtype}{int} ccid);}
\DoxyCodeLine{124 \textcolor{keywordtype}{void} osmux\_xfrm\_input\_deliver(\textcolor{keyword}{struct} osmux\_in\_handle *h);}
\DoxyCodeLine{125 }
\DoxyCodeLine{126 \textcolor{keyword}{struct }osmux\_out\_handle *osmux\_xfrm\_output\_alloc(\textcolor{keywordtype}{void} *ctx);}
\DoxyCodeLine{127 \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{128 \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{129 \textcolor{keywordtype}{void} osmux\_xfrm\_output\_set\_rtp\_ssrc(\textcolor{keyword}{struct} osmux\_out\_handle *h, uint32\_t rtp\_ssrc);}
\DoxyCodeLine{130 \textcolor{keywordtype}{void} osmux\_xfrm\_output\_set\_rtp\_pl\_type(\textcolor{keyword}{struct} osmux\_out\_handle *h, uint32\_t rtp\_payload\_type);}
\DoxyCodeLine{131 \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{132 \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{133 \textcolor{keywordtype}{int} osmux\_xfrm\_output\_sched(\textcolor{keyword}{struct} osmux\_out\_handle *h, \textcolor{keyword}{struct} osmux\_hdr *osmuxh);}
\DoxyCodeLine{134 \textcolor{keywordtype}{void} osmux\_xfrm\_output\_flush(\textcolor{keyword}{struct} osmux\_out\_handle *h);}
\DoxyCodeLine{135 \textcolor{keyword}{struct }osmux\_hdr *osmux\_xfrm\_output\_pull(\textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{138 \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
