\doxysection{ipa.\+h}
\label{ipa_8h_source}\index{include/osmocom/netif/ipa.h@{include/osmocom/netif/ipa.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#ifndef \_OSMO\_NETIF\_IPA\_H\_}}
\DoxyCodeLine{2 \textcolor{preprocessor}{\#define \_OSMO\_NETIF\_IPA\_H\_}}
\DoxyCodeLine{3 }
\DoxyCodeLine{4 \textcolor{preprocessor}{\#include <osmocom/gsm/protocol/ipaccess.h>}}
\DoxyCodeLine{5 \textcolor{preprocessor}{\#include <osmocom/gsm/ipa.h>}}
\DoxyCodeLine{6 }
\DoxyCodeLine{7 \textcolor{comment}{/* This is like 'struct ipaccess\_head' in libosmocore, but 'ipa\_head' is}}
\DoxyCodeLine{8 \textcolor{comment}{ * actually the more apropriate name, so rather than making more code}}
\DoxyCodeLine{9 \textcolor{comment}{ * use the wrong name, let's keep the duplicate header definitions below */}}
\DoxyCodeLine{10 \textcolor{keyword}{struct }ipa\_head \{}
\DoxyCodeLine{11         uint16\_t len;   \textcolor{comment}{/* network byte order */}}
\DoxyCodeLine{12         uint8\_t proto;}
\DoxyCodeLine{13         uint8\_t data[0];}
\DoxyCodeLine{14 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{15 }
\DoxyCodeLine{16 \textcolor{keyword}{struct }ipa\_head\_ext \{}
\DoxyCodeLine{17         uint8\_t proto;}
\DoxyCodeLine{18         uint8\_t data[0];}
\DoxyCodeLine{19 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{20 }
\DoxyCodeLine{21 \textcolor{keyword}{struct }osmo\_ipa\_msgb\_cb \{}
\DoxyCodeLine{22         uint8\_t proto;}
\DoxyCodeLine{23         uint8\_t proto\_ext;}
\DoxyCodeLine{24 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{25 }
\DoxyCodeLine{26 }
\DoxyCodeLine{27 \textcolor{comment}{/* We don't just cast to 'struct osmo\_ipa\_msgb\_cb *', because that would}}
\DoxyCodeLine{28 \textcolor{comment}{ * break the strict aliasing rule. Casting to a reference to a union with}}
\DoxyCodeLine{29 \textcolor{comment}{ * a compatible struct member seems to be allowed, though, see:}}
\DoxyCodeLine{30 \textcolor{comment}{ *      N1570 Committee Draft — April 12, 2011 ISO/IEC 9899:201x,}}
\DoxyCodeLine{31 \textcolor{comment}{ *      Section 6.5, §7 */}}
\DoxyCodeLine{32 \textcolor{preprocessor}{\#define OSMO\_IPA\_MSGB\_CB(\_\_msg) (\&((( \(\backslash\)}}
\DoxyCodeLine{33 \textcolor{preprocessor}{                                        union \{ \(\backslash\)}}
\DoxyCodeLine{34 \textcolor{preprocessor}{                                                unsigned long cb; \(\backslash\)}}
\DoxyCodeLine{35 \textcolor{preprocessor}{                                                struct osmo\_ipa\_msgb\_cb \_cb; \(\backslash\)}}
\DoxyCodeLine{36 \textcolor{preprocessor}{                                        \} \(\backslash\)}}
\DoxyCodeLine{37 \textcolor{preprocessor}{                                *)\&((\_\_msg)-\/>cb[0]))-\/>\_cb))}}
\DoxyCodeLine{38 }
\DoxyCodeLine{39 \textcolor{preprocessor}{\#define osmo\_ipa\_msgb\_cb\_proto(\_\_x)     OSMO\_IPA\_MSGB\_CB(\_\_x)-\/>proto}}
\DoxyCodeLine{40 \textcolor{preprocessor}{\#define osmo\_ipa\_msgb\_cb\_proto\_ext(\_\_x) OSMO\_IPA\_MSGB\_CB(\_\_x)-\/>proto\_ext}}
\DoxyCodeLine{41 }
\DoxyCodeLine{42 \textcolor{keyword}{struct }msgb *osmo\_ipa\_msg\_alloc(\textcolor{keywordtype}{int} headroom);}
\DoxyCodeLine{43 \textcolor{keyword}{struct }msgb *osmo\_ipa\_ext\_msg\_alloc(\textcolor{keywordtype}{size\_t} headroom);}
\DoxyCodeLine{44 }
\DoxyCodeLine{45 \textcolor{keywordtype}{void} osmo\_ipa\_msg\_push\_header(\textcolor{keyword}{struct} msgb *msg, uint8\_t proto);}
\DoxyCodeLine{46 }
\DoxyCodeLine{47 \textcolor{keywordtype}{int} osmo\_ipa\_process\_msg(\textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{48 }
\DoxyCodeLine{49 \textcolor{keyword}{struct }osmo\_fd;}
\DoxyCodeLine{50 \textcolor{keyword}{struct }tlv\_parsed;}
\DoxyCodeLine{51 }
\DoxyCodeLine{52 \textcolor{keywordtype}{int} osmo\_ipa\_rcvmsg\_base(\textcolor{keyword}{struct} msgb *msg, \textcolor{keyword}{struct} osmo\_fd *bfd, \textcolor{keywordtype}{int} server);}
\DoxyCodeLine{53 \textcolor{keywordtype}{int} osmo\_ipa\_parse\_unitid(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *str, \textcolor{keyword}{struct} ipaccess\_unit *unit\_data);}
\DoxyCodeLine{54 }
\DoxyCodeLine{55 \textcolor{keywordtype}{int} ipaccess\_send\_pong(\textcolor{keywordtype}{int} fd);}
\DoxyCodeLine{56 \textcolor{keywordtype}{int} ipaccess\_send\_id\_ack(\textcolor{keywordtype}{int} fd);}
\DoxyCodeLine{57 \textcolor{keywordtype}{int} ipaccess\_send\_id\_req(\textcolor{keywordtype}{int} fd);}
\DoxyCodeLine{58 }
\DoxyCodeLine{59 \textcolor{keyword}{struct }osmo\_ipa\_unit;}
\DoxyCodeLine{60 }
\DoxyCodeLine{61 \textcolor{keyword}{struct }msgb *ipa\_cli\_id\_resp(\textcolor{keyword}{struct} osmo\_ipa\_unit *dev, uint8\_t *data, \textcolor{keywordtype}{int} len);}
\DoxyCodeLine{62 \textcolor{keyword}{struct }msgb *ipa\_cli\_id\_ack(\textcolor{keywordtype}{void});}
\DoxyCodeLine{63 }
\DoxyCodeLine{64 \textcolor{keywordtype}{int} osmo\_ipa\_parse\_msg\_id\_resp(\textcolor{keyword}{struct} msgb *msg, \textcolor{keyword}{struct} ipaccess\_unit *unit\_data);}
\DoxyCodeLine{65 }
\DoxyCodeLine{66 \textcolor{keywordtype}{int} osmo\_ipa\_segmentation\_cb(\textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{67 }
\DoxyCodeLine{68 \textcolor{keywordtype}{void} osmo\_ipa\_msg\_push\_headers(\textcolor{keyword}{struct} msgb *msg, \textcolor{keyword}{enum} ipaccess\_proto p, \textcolor{keyword}{enum} ipaccess\_proto\_ext pe);}
\DoxyCodeLine{69 }
\DoxyCodeLine{70 \textcolor{comment}{/***********************************************************************}}
\DoxyCodeLine{71 \textcolor{comment}{ * IPA Keep-\/Alive FSM}}
\DoxyCodeLine{72 \textcolor{comment}{ ***********************************************************************/}}
\DoxyCodeLine{73 \textcolor{keyword}{struct }osmo\_ipa\_ka\_fsm\_inst;}
\DoxyCodeLine{74 \textcolor{keyword}{typedef} int (*osmo\_ipa\_ka\_fsm\_timeout\_cb\_t)(\textcolor{keyword}{struct }osmo\_ipa\_ka\_fsm\_inst *ka\_fi, \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{75 }
\DoxyCodeLine{76 \textcolor{keyword}{typedef} int (*osmo\_ipa\_ka\_fsm\_send\_cb\_t)(\textcolor{keyword}{struct }osmo\_ipa\_ka\_fsm\_inst *ka\_fi, \textcolor{keyword}{struct }msgb *msg, \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{77 }
\DoxyCodeLine{78 \textcolor{keyword}{struct }osmo\_ipa\_ka\_fsm\_inst *osmo\_ipa\_ka\_fsm\_alloc(\textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *\textcolor{keywordtype}{id});}
\DoxyCodeLine{79 \textcolor{keywordtype}{void} osmo\_ipa\_ka\_fsm\_free(\textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi);}
\DoxyCodeLine{80 }
\DoxyCodeLine{81 \textcolor{keywordtype}{int} osmo\_ipa\_ka\_fsm\_set\_id(\textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *\textcolor{keywordtype}{id});}
\DoxyCodeLine{82 \textcolor{keywordtype}{int} osmo\_ipa\_ka\_fsm\_set\_ping\_interval(\textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} interval);}
\DoxyCodeLine{83 \textcolor{keywordtype}{int} osmo\_ipa\_ka\_fsm\_set\_pong\_timeout(\textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} timeout);}
\DoxyCodeLine{84 \textcolor{keywordtype}{void} osmo\_ipa\_ka\_fsm\_set\_data(\textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi, \textcolor{keywordtype}{void} *cb\_data);}
\DoxyCodeLine{85 \textcolor{keywordtype}{void} *osmo\_ipa\_ka\_fsm\_get\_data(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi);}
\DoxyCodeLine{86 }
\DoxyCodeLine{87 \textcolor{keywordtype}{void} osmo\_ipa\_ka\_fsm\_set\_send\_cb(\textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi, osmo\_ipa\_ka\_fsm\_send\_cb\_t send\_cb);}
\DoxyCodeLine{88 \textcolor{keywordtype}{void} osmo\_ipa\_ka\_fsm\_set\_timeout\_cb(\textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi, osmo\_ipa\_ka\_fsm\_timeout\_cb\_t timeout\_cb);}
\DoxyCodeLine{89 }
\DoxyCodeLine{90 \textcolor{keywordtype}{void} osmo\_ipa\_ka\_fsm\_start(\textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi);}
\DoxyCodeLine{91 \textcolor{keywordtype}{void} osmo\_ipa\_ka\_fsm\_pong\_received(\textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi);}
\DoxyCodeLine{92 \textcolor{keywordtype}{void} osmo\_ipa\_ka\_fsm\_stop(\textcolor{keyword}{struct} osmo\_ipa\_ka\_fsm\_inst *ka\_fi);}
\DoxyCodeLine{93 }
\DoxyCodeLine{94 \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
