\doxysection{Tun}
\label{group__tun}\index{Tun@{Tun}}


tun network device (interface) convenience functions  


\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+tundev}
\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ TUN\+\_\+\+DEV\+\_\+\+PATH}~\char`\"{}/dev/\textbf{ net}/tun\char`\"{}
\item 
\#define \textbf{ TUN\+\_\+\+PACKET\+\_\+\+MAX}~8196
\item 
\#define \textbf{ LOGTUN}(tun,  lvl,  fmt,  args ...)
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static int \textbf{ tundev\+\_\+decaps} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\item 
static int \textbf{ tundev\+\_\+read\+\_\+cb} (struct \textbf{ osmo\+\_\+fd} $\ast$fd)
\item 
static int \textbf{ tundev\+\_\+write\+\_\+cb} (struct \textbf{ osmo\+\_\+fd} $\ast$fd, struct \textbf{ msgb} $\ast$\textbf{ msg})
\item 
static int \textbf{ tundev\+\_\+ifupdown\+\_\+ind\+\_\+cb} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, bool ifupdown)
\item 
static int \textbf{ tundev\+\_\+dev\+\_\+name\+\_\+chg\+\_\+cb} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, const char $\ast$new\+\_\+dev\+\_\+name)
\item 
static int \textbf{ tundev\+\_\+mtu\+\_\+chg\+\_\+cb} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, uint32\+\_\+t new\+\_\+mtu)
\item 
struct \textbf{ osmo\+\_\+tundev} $\ast$ \textbf{ osmo\+\_\+tundev\+\_\+alloc} (void $\ast$ctx, const char $\ast$\textbf{ name})
\begin{DoxyCompactList}\small\item\em Allocate a new tundev object. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+tundev\+\_\+free} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\begin{DoxyCompactList}\small\item\em Free an allocated tundev object. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tundev\+\_\+open} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\begin{DoxyCompactList}\small\item\em Open the tunnel device owned by the tundev object. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tundev\+\_\+close} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\begin{DoxyCompactList}\small\item\em Close the tunnel device owned by the tundev object. \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+tundev\+\_\+is\+\_\+open} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\begin{DoxyCompactList}\small\item\em Retrieve whether the tundev object is in \char`\"{}opened\char`\"{} state. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+tundev\+\_\+set\+\_\+priv\+\_\+data} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev, void $\ast$priv\+\_\+data)
\begin{DoxyCompactList}\small\item\em Set private user data pointer on the tundev object. \end{DoxyCompactList}\item 
void $\ast$ \textbf{ osmo\+\_\+tundev\+\_\+get\+\_\+priv\+\_\+data} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\begin{DoxyCompactList}\small\item\em Get private user data pointer from the tundev object. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+tundev\+\_\+set\+\_\+data\+\_\+ind\+\_\+cb} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev, \textbf{ osmo\+\_\+tundev\+\_\+data\+\_\+ind\+\_\+cb\+\_\+t} data\+\_\+ind\+\_\+cb)
\begin{DoxyCompactList}\small\item\em Set data\+\_\+ind\+\_\+cb callback, called when a new packet is received on the tun interface. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+tundev\+\_\+get\+\_\+name} (const struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\begin{DoxyCompactList}\small\item\em Get name used to identify the tundev object. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tundev\+\_\+get\+\_\+fd} (const struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\begin{DoxyCompactList}\small\item\em Get FD associated to the tundev object. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tundev\+\_\+set\+\_\+dev\+\_\+name} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev, const char $\ast$dev\+\_\+name)
\begin{DoxyCompactList}\small\item\em Set name used to name the tunnel interface created by the tundev object. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+tundev\+\_\+get\+\_\+dev\+\_\+name} (const struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\begin{DoxyCompactList}\small\item\em Get name used to name the tunnel interface created by the tundev object. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tundev\+\_\+set\+\_\+netns\+\_\+name} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev, const char $\ast$netns\+\_\+name)
\begin{DoxyCompactList}\small\item\em Set name of the network namespace to use when opening the tunnel interface. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+tundev\+\_\+get\+\_\+netns\+\_\+name} (const struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\begin{DoxyCompactList}\small\item\em Get name of network namespace used when opening the tunnel interface. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+netdev} $\ast$ \textbf{ osmo\+\_\+tundev\+\_\+get\+\_\+netdev} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev)
\begin{DoxyCompactList}\small\item\em Get netdev managing the tunnel interface of tundev. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tundev\+\_\+send} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev, struct \textbf{ msgb} $\ast$\textbf{ msg})
\begin{DoxyCompactList}\small\item\em Submit a packet to the tunnel device managed by the tundev object. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
tun network device (interface) convenience functions 



\doxysubsection{Macro Definition Documentation}
\mbox{\label{group__tun_ga8f4af10f5c20dcb47e517499d5c0c2b2}} 
\index{Tun@{Tun}!LOGTUN@{LOGTUN}}
\index{LOGTUN@{LOGTUN}!Tun@{Tun}}
\doxysubsubsection{LOGTUN}
{\footnotesize\ttfamily \#define LOGTUN(\begin{DoxyParamCaption}\item[{}]{tun,  }\item[{}]{lvl,  }\item[{}]{fmt,  }\item[{}]{args ... }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{        LOGP(DLGLOBAL, lvl, \textcolor{stringliteral}{"{}TUN(\%s,if=\%s/\%u,ns=\%s): "{}} fmt, \(\backslash\)}
\DoxyCodeLine{            (tun)-\/>name, (tun)-\/>dev\_name ? : \textcolor{stringliteral}{"{}"{}}, \(\backslash\)}
\DoxyCodeLine{             (tun)-\/>ifindex, (tun)-\/>netns\_name ? : \textcolor{stringliteral}{"{}"{}}, \#\# args)}

\end{DoxyCode}
\mbox{\label{group__tun_ga98bdc6d5a45d3b24e4b3a3ed19cafa0c}} 
\index{Tun@{Tun}!TUN\_DEV\_PATH@{TUN\_DEV\_PATH}}
\index{TUN\_DEV\_PATH@{TUN\_DEV\_PATH}!Tun@{Tun}}
\doxysubsubsection{TUN\_DEV\_PATH}
{\footnotesize\ttfamily \#define TUN\+\_\+\+DEV\+\_\+\+PATH~\char`\"{}/dev/\textbf{ net}/tun\char`\"{}}

\mbox{\label{group__tun_ga60304322931dd9d053a88072ca59c875}} 
\index{Tun@{Tun}!TUN\_PACKET\_MAX@{TUN\_PACKET\_MAX}}
\index{TUN\_PACKET\_MAX@{TUN\_PACKET\_MAX}!Tun@{Tun}}
\doxysubsubsection{TUN\_PACKET\_MAX}
{\footnotesize\ttfamily \#define TUN\+\_\+\+PACKET\+\_\+\+MAX~8196}



\doxysubsection{Function Documentation}
\mbox{\label{group__tun_ga36875a4a026aacc52bf5d45569d2e523}} 
\index{Tun@{Tun}!osmo\_tundev\_alloc@{osmo\_tundev\_alloc}}
\index{osmo\_tundev\_alloc@{osmo\_tundev\_alloc}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_alloc()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+tundev} $\ast$ osmo\+\_\+tundev\+\_\+alloc (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{const char $\ast$}]{name }\end{DoxyParamCaption})}



Allocate a new tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc context to use as a parent when allocating the tundev object \\
\hline
\mbox{\texttt{ in}}  & {\em name} & A name providen to identify the tundev object \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
newly allocated tundev object on success; NULL on error 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ name}, \textbf{ osmo\+\_\+tundev\+::name}, \textbf{ osmo\+\_\+tundev\+::netdev}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+READ}, \textbf{ osmo\+\_\+fd\+\_\+setup()}, \textbf{ osmo\+\_\+netdev\+\_\+alloc()}, \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+dev\+\_\+name\+\_\+chg\+\_\+cb()}, \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+ifupdown\+\_\+ind\+\_\+cb()}, \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+mtu\+\_\+chg\+\_\+cb()}, \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+priv\+\_\+data()}, \textbf{ osmo\+\_\+wqueue\+\_\+bfd\+\_\+cb()}, \textbf{ osmo\+\_\+wqueue\+\_\+init()}, \textbf{ osmo\+\_\+wqueue\+::read\+\_\+cb}, \textbf{ tundev\+\_\+dev\+\_\+name\+\_\+chg\+\_\+cb()}, \textbf{ tundev\+\_\+ifupdown\+\_\+ind\+\_\+cb()}, \textbf{ tundev\+\_\+mtu\+\_\+chg\+\_\+cb()}, \textbf{ tundev\+\_\+read\+\_\+cb()}, \textbf{ tundev\+\_\+write\+\_\+cb()}, \textbf{ osmo\+\_\+tundev\+::wqueue}, and \textbf{ osmo\+\_\+wqueue\+::write\+\_\+cb}.

\mbox{\label{group__tun_gad321860ec0c2be297c48d580918c811c}} 
\index{Tun@{Tun}!osmo\_tundev\_close@{osmo\_tundev\_close}}
\index{osmo\_tundev\_close@{osmo\_tundev\_close}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_close()}
{\footnotesize\ttfamily int osmo\+\_\+tundev\+\_\+close (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})}



Close the tunnel device owned by the tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object to close \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ osmo\+\_\+tundev\+::dev\+\_\+name}, \textbf{ osmo\+\_\+tundev\+::dev\+\_\+name\+\_\+dynamic}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ osmo\+\_\+tundev\+::netdev}, \textbf{ osmo\+\_\+tundev\+::opened}, \textbf{ osmo\+\_\+fd\+\_\+unregister()}, \textbf{ osmo\+\_\+netdev\+\_\+unregister()}, \textbf{ osmo\+\_\+wqueue\+\_\+clear()}, and \textbf{ osmo\+\_\+tundev\+::wqueue}.



Referenced by \textbf{ osmo\+\_\+tundev\+\_\+free()}.

\mbox{\label{group__tun_gaa5a54e97b016d59ed2b03a16491eda76}} 
\index{Tun@{Tun}!osmo\_tundev\_free@{osmo\_tundev\_free}}
\index{osmo\_tundev\_free@{osmo\_tundev\_free}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_free()}
{\footnotesize\ttfamily void osmo\+\_\+tundev\+\_\+free (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})}



Free an allocated tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object to free \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+tundev\+::netdev}, \textbf{ osmo\+\_\+netdev\+\_\+free()}, and \textbf{ osmo\+\_\+tundev\+\_\+close()}.

\mbox{\label{group__tun_ga22ef1c28ec0c985e742950ef331270bc}} 
\index{Tun@{Tun}!osmo\_tundev\_get\_dev\_name@{osmo\_tundev\_get\_dev\_name}}
\index{osmo\_tundev\_get\_dev\_name@{osmo\_tundev\_get\_dev\_name}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_get\_dev\_name()}
{\footnotesize\ttfamily const char $\ast$ osmo\+\_\+tundev\+\_\+get\+\_\+dev\+\_\+name (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})}



Get name used to name the tunnel interface created by the tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object from where to retrieve the field \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The current value of the configured tunnel interface name to use 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tundev\+::dev\+\_\+name}.

\mbox{\label{group__tun_ga841211492d9aeed4f1b0fbe451b42584}} 
\index{Tun@{Tun}!osmo\_tundev\_get\_fd@{osmo\_tundev\_get\_fd}}
\index{osmo\_tundev\_get\_fd@{osmo\_tundev\_get\_fd}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_get\_fd()}
{\footnotesize\ttfamily int osmo\+\_\+tundev\+\_\+get\+\_\+fd (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})}



Get FD associated to the tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object from where to retrieve the field \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The fd of the currently open tundev, negative otherwise 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ osmo\+\_\+fd\+::fd}, and \textbf{ osmo\+\_\+tundev\+::wqueue}.

\mbox{\label{group__tun_gaae3e8b0fe9f1bc8b6dbfd5b26ef0df2b}} 
\index{Tun@{Tun}!osmo\_tundev\_get\_name@{osmo\_tundev\_get\_name}}
\index{osmo\_tundev\_get\_name@{osmo\_tundev\_get\_name}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_get\_name()}
{\footnotesize\ttfamily const char $\ast$ osmo\+\_\+tundev\+\_\+get\+\_\+name (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})}



Get name used to identify the tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object from where to retrieve the field \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The current value of the name used to identify the tundev object 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tundev\+::name}.

\mbox{\label{group__tun_ga7787e7fe210d9c7ea62a49042412ac20}} 
\index{Tun@{Tun}!osmo\_tundev\_get\_netdev@{osmo\_tundev\_get\_netdev}}
\index{osmo\_tundev\_get\_netdev@{osmo\_tundev\_get\_netdev}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_get\_netdev()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+netdev} $\ast$ osmo\+\_\+tundev\+\_\+get\+\_\+netdev (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})}



Get netdev managing the tunnel interface of tundev. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object from where to retrieve the field \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The netdev objet managing the tun interface 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tundev\+::netdev}.

\mbox{\label{group__tun_gaa71cfeea8d70f6527a5c9f8e59c2d790}} 
\index{Tun@{Tun}!osmo\_tundev\_get\_netns\_name@{osmo\_tundev\_get\_netns\_name}}
\index{osmo\_tundev\_get\_netns\_name@{osmo\_tundev\_get\_netns\_name}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_get\_netns\_name()}
{\footnotesize\ttfamily const char $\ast$ osmo\+\_\+tundev\+\_\+get\+\_\+netns\+\_\+name (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})}



Get name of network namespace used when opening the tunnel interface. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object from where to retrieve the field \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The current value of the configured network namespace 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tundev\+::netns\+\_\+name}.

\mbox{\label{group__tun_ga73eeb43489a75e38c495a1aabebdf7bf}} 
\index{Tun@{Tun}!osmo\_tundev\_get\_priv\_data@{osmo\_tundev\_get\_priv\_data}}
\index{osmo\_tundev\_get\_priv\_data@{osmo\_tundev\_get\_priv\_data}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_get\_priv\_data()}
{\footnotesize\ttfamily void $\ast$ osmo\+\_\+tundev\+\_\+get\+\_\+priv\+\_\+data (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})}



Get private user data pointer from the tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object from where to retrieve the field \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The current value of the priv\+\_\+data field. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tundev\+::priv\+\_\+data}.

\mbox{\label{group__tun_ga384c5bfc84a2fd78a8730adacd6061d1}} 
\index{Tun@{Tun}!osmo\_tundev\_is\_open@{osmo\_tundev\_is\_open}}
\index{osmo\_tundev\_is\_open@{osmo\_tundev\_is\_open}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_is\_open()}
{\footnotesize\ttfamily bool osmo\+\_\+tundev\+\_\+is\+\_\+open (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})}



Retrieve whether the tundev object is in \char`\"{}opened\char`\"{} state. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object to check \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if in state \char`\"{}opened\char`\"{}; false otherwise 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tundev\+::opened}.

\mbox{\label{group__tun_gae6ce16c4c73663ae523b4e3a2638d644}} 
\index{Tun@{Tun}!osmo\_tundev\_open@{osmo\_tundev\_open}}
\index{osmo\_tundev\_open@{osmo\_tundev\_open}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_open()}
{\footnotesize\ttfamily int osmo\+\_\+tundev\+\_\+open (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})}



Open the tunnel device owned by the tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object to open \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ DLGLOBAL}, \textbf{ ENOTSUP}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ osmo\+\_\+tundev\+::ifindex}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGL\+\_\+\+INFO}, \textbf{ LOGP}, \textbf{ LOGTUN}, \textbf{ osmo\+\_\+tundev\+::netdev}, \textbf{ osmo\+\_\+tundev\+::netns\+\_\+name}, \textbf{ osmo\+\_\+tundev\+::opened}, \textbf{ osmo\+\_\+fd\+\_\+register()}, \textbf{ osmo\+\_\+netdev\+\_\+register()}, \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+ifindex()}, \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+netns\+\_\+name()}, \textbf{ osmo\+\_\+netdev\+\_\+unregister()}, \textbf{ osmo\+\_\+netns\+\_\+open\+\_\+fd()}, \textbf{ osmo\+\_\+netns\+\_\+switch\+\_\+enter()}, \textbf{ osmo\+\_\+netns\+\_\+switch\+\_\+exit()}, and \textbf{ osmo\+\_\+tundev\+::wqueue}.

\mbox{\label{group__tun_gabd21998a822758c2de51a029d4378f65}} 
\index{Tun@{Tun}!osmo\_tundev\_send@{osmo\_tundev\_send}}
\index{osmo\_tundev\_send@{osmo\_tundev\_send}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_send()}
{\footnotesize\ttfamily int osmo\+\_\+tundev\+\_\+send (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev,  }\item[{struct \textbf{ msgb} $\ast$}]{msg }\end{DoxyParamCaption})}



Submit a packet to the tunnel device managed by the tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object owning the tunnel device where to inject the packet \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & The msgb containg the packet to transfer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error
\end{DoxyReturn}
This function takes the ownership of msg in all cases. 

References \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGTUN}, \textbf{ msg}, \textbf{ msgb\+\_\+free()}, \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ osmo\+\_\+wqueue\+\_\+enqueue()}, and \textbf{ osmo\+\_\+tundev\+::wqueue}.

\mbox{\label{group__tun_gab4cc44199ac0b7ab25cd0b3444d76c7d}} 
\index{Tun@{Tun}!osmo\_tundev\_set\_data\_ind\_cb@{osmo\_tundev\_set\_data\_ind\_cb}}
\index{osmo\_tundev\_set\_data\_ind\_cb@{osmo\_tundev\_set\_data\_ind\_cb}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_set\_data\_ind\_cb()}
{\footnotesize\ttfamily void osmo\+\_\+tundev\+\_\+set\+\_\+data\+\_\+ind\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev,  }\item[{\textbf{ osmo\+\_\+tundev\+\_\+data\+\_\+ind\+\_\+cb\+\_\+t}}]{data\+\_\+ind\+\_\+cb }\end{DoxyParamCaption})}



Set data\+\_\+ind\+\_\+cb callback, called when a new packet is received on the tun interface. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object where the field is set \\
\hline
\mbox{\texttt{ in}}  & {\em data\+\_\+ind\+\_\+cb} & the user provided function to be called when a new packet is received \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+tundev\+::data\+\_\+ind\+\_\+cb}.

\mbox{\label{group__tun_ga58fa0f32b02698e91cdbfff89e44307d}} 
\index{Tun@{Tun}!osmo\_tundev\_set\_dev\_name@{osmo\_tundev\_set\_dev\_name}}
\index{osmo\_tundev\_set\_dev\_name@{osmo\_tundev\_set\_dev\_name}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_set\_dev\_name()}
{\footnotesize\ttfamily int osmo\+\_\+tundev\+\_\+set\+\_\+dev\+\_\+name (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev,  }\item[{const char $\ast$}]{dev\+\_\+name }\end{DoxyParamCaption})}



Set name used to name the tunnel interface created by the tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object where the field is set \\
\hline
\mbox{\texttt{ in}}  & {\em dev\+\_\+name} & The tunnel interface name to use \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error
\end{DoxyReturn}
This is used during \doxyref{osmo\+\_\+tundev\+\_\+open()}{p.}{group__tun_gae6ce16c4c73663ae523b4e3a2638d644} time, and hence shouldn\textquotesingle{}t be changed when the tundev object is in \char`\"{}opened\char`\"{} state. If left as NULL (default), the system will pick a suitable name during \doxyref{osmo\+\_\+tundev\+\_\+open()}{p.}{group__tun_gae6ce16c4c73663ae523b4e3a2638d644}, and the field will be updated to the system-\/selected name, which can be retrieved later with \doxyref{osmo\+\_\+tundev\+\_\+get\+\_\+dev\+\_\+name()}{p.}{group__tun_ga22ef1c28ec0c985e742950ef331270bc}. 

References \textbf{ osmo\+\_\+tundev\+::dev\+\_\+name}, \textbf{ osmo\+\_\+tundev\+::dev\+\_\+name\+\_\+dynamic}, \textbf{ osmo\+\_\+tundev\+::opened}, and \textbf{ osmo\+\_\+talloc\+\_\+replace\+\_\+string()}.

\mbox{\label{group__tun_gae31a6b8fa612faaf21aaa0c339e23e0b}} 
\index{Tun@{Tun}!osmo\_tundev\_set\_netns\_name@{osmo\_tundev\_set\_netns\_name}}
\index{osmo\_tundev\_set\_netns\_name@{osmo\_tundev\_set\_netns\_name}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_set\_netns\_name()}
{\footnotesize\ttfamily int osmo\+\_\+tundev\+\_\+set\+\_\+netns\+\_\+name (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev,  }\item[{const char $\ast$}]{netns\+\_\+name }\end{DoxyParamCaption})}



Set name of the network namespace to use when opening the tunnel interface. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object where the field is set \\
\hline
\mbox{\texttt{ in}}  & {\em netns\+\_\+name} & The network namespace to use during tunnel interface creation \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error
\end{DoxyReturn}
This is used during \doxyref{osmo\+\_\+tundev\+\_\+open()}{p.}{group__tun_gae6ce16c4c73663ae523b4e3a2638d644} time, and hence shouldn\textquotesingle{}t be changed when the tundev object is in \char`\"{}opened\char`\"{} state. If left as NULL (default), the system will stay in the current network namespace. 

References \textbf{ osmo\+\_\+tundev\+::netns\+\_\+name}, \textbf{ osmo\+\_\+tundev\+::opened}, and \textbf{ osmo\+\_\+talloc\+\_\+replace\+\_\+string()}.

\mbox{\label{group__tun_ga35fdce0913f5c26802ef2350cd0531ef}} 
\index{Tun@{Tun}!osmo\_tundev\_set\_priv\_data@{osmo\_tundev\_set\_priv\_data}}
\index{osmo\_tundev\_set\_priv\_data@{osmo\_tundev\_set\_priv\_data}!Tun@{Tun}}
\doxysubsubsection{osmo\_tundev\_set\_priv\_data()}
{\footnotesize\ttfamily void osmo\+\_\+tundev\+\_\+set\+\_\+priv\+\_\+data (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev,  }\item[{void $\ast$}]{priv\+\_\+data }\end{DoxyParamCaption})}



Set private user data pointer on the tundev object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tundev} & The tundev object where the field is set \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+tundev\+::priv\+\_\+data}.

\mbox{\label{group__tun_gab7bb4ad4360d0d0bdb5ccb4659276a1d}} 
\index{Tun@{Tun}!tundev\_decaps@{tundev\_decaps}}
\index{tundev\_decaps@{tundev\_decaps}!Tun@{Tun}}
\doxysubsubsection{tundev\_decaps()}
{\footnotesize\ttfamily static int tundev\+\_\+decaps (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tundev} $\ast$}]{tundev }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ osmo\+\_\+tundev\+::data\+\_\+ind\+\_\+cb}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGTUN}, \textbf{ msg}, \textbf{ msgb\+\_\+alloc()}, \textbf{ msgb\+\_\+data()}, \textbf{ msgb\+\_\+free()}, \textbf{ msgb\+\_\+put()}, \textbf{ TUN\+\_\+\+PACKET\+\_\+\+MAX}, and \textbf{ osmo\+\_\+tundev\+::wqueue}.



Referenced by \textbf{ tundev\+\_\+read\+\_\+cb()}.

\mbox{\label{group__tun_ga1b714e0b4e6a3d45e965fc97fc6fd09d}} 
\index{Tun@{Tun}!tundev\_dev\_name\_chg\_cb@{tundev\_dev\_name\_chg\_cb}}
\index{tundev\_dev\_name\_chg\_cb@{tundev\_dev\_name\_chg\_cb}!Tun@{Tun}}
\doxysubsubsection{tundev\_dev\_name\_chg\_cb()}
{\footnotesize\ttfamily static int tundev\+\_\+dev\+\_\+name\+\_\+chg\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+netdev} $\ast$}]{netdev,  }\item[{const char $\ast$}]{new\+\_\+dev\+\_\+name }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+tundev\+::dev\+\_\+name}, \textbf{ osmo\+\_\+tundev\+::dev\+\_\+name\+\_\+dynamic}, \textbf{ LOGL\+\_\+\+NOTICE}, \textbf{ LOGTUN}, \textbf{ osmo\+\_\+tundev\+::netdev}, \textbf{ osmo\+\_\+netdev\+\_\+get\+\_\+dev\+\_\+name()}, \textbf{ osmo\+\_\+netdev\+\_\+get\+\_\+priv\+\_\+data()}, and \textbf{ osmo\+\_\+talloc\+\_\+replace\+\_\+string()}.



Referenced by \textbf{ osmo\+\_\+tundev\+\_\+alloc()}.

\mbox{\label{group__tun_ga5d311ac51f718729e227b76e0f9dd474}} 
\index{Tun@{Tun}!tundev\_ifupdown\_ind\_cb@{tundev\_ifupdown\_ind\_cb}}
\index{tundev\_ifupdown\_ind\_cb@{tundev\_ifupdown\_ind\_cb}!Tun@{Tun}}
\doxysubsubsection{tundev\_ifupdown\_ind\_cb()}
{\footnotesize\ttfamily static int tundev\+\_\+ifupdown\+\_\+ind\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+netdev} $\ast$}]{netdev,  }\item[{bool}]{ifupdown }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ LOGL\+\_\+\+NOTICE}, \textbf{ LOGTUN}, \textbf{ osmo\+\_\+tundev\+::netdev}, \textbf{ osmo\+\_\+netdev\+\_\+get\+\_\+priv\+\_\+data()}, \textbf{ osmo\+\_\+wqueue\+\_\+clear()}, and \textbf{ osmo\+\_\+tundev\+::wqueue}.



Referenced by \textbf{ osmo\+\_\+tundev\+\_\+alloc()}.

\mbox{\label{group__tun_gae9508aad437383431d53b14e07286d3b}} 
\index{Tun@{Tun}!tundev\_mtu\_chg\_cb@{tundev\_mtu\_chg\_cb}}
\index{tundev\_mtu\_chg\_cb@{tundev\_mtu\_chg\_cb}!Tun@{Tun}}
\doxysubsubsection{tundev\_mtu\_chg\_cb()}
{\footnotesize\ttfamily static int tundev\+\_\+mtu\+\_\+chg\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+netdev} $\ast$}]{netdev,  }\item[{uint32\+\_\+t}]{new\+\_\+mtu }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ LOGL\+\_\+\+NOTICE}, \textbf{ LOGTUN}, \textbf{ osmo\+\_\+tundev\+::netdev}, and \textbf{ osmo\+\_\+netdev\+\_\+get\+\_\+priv\+\_\+data()}.



Referenced by \textbf{ osmo\+\_\+tundev\+\_\+alloc()}.

\mbox{\label{group__tun_gab4b9fc3bfbaa99ea7aaa4b6630656674}} 
\index{Tun@{Tun}!tundev\_read\_cb@{tundev\_read\_cb}}
\index{tundev\_read\_cb@{tundev\_read\_cb}!Tun@{Tun}}
\doxysubsubsection{tundev\_read\_cb()}
{\footnotesize\ttfamily static int tundev\+\_\+read\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{fd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+fd\+::data}, and \textbf{ tundev\+\_\+decaps()}.



Referenced by \textbf{ osmo\+\_\+tundev\+\_\+alloc()}.

\mbox{\label{group__tun_ga7bb8d07849ef9d7bc1a6d413fecc41d1}} 
\index{Tun@{Tun}!tundev\_write\_cb@{tundev\_write\_cb}}
\index{tundev\_write\_cb@{tundev\_write\_cb}!Tun@{Tun}}
\doxysubsubsection{tundev\_write\_cb()}
{\footnotesize\ttfamily static int tundev\+\_\+write\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{fd,  }\item[{struct \textbf{ msgb} $\ast$}]{msg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ osmo\+\_\+fd\+::data}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGTUN}, \textbf{ msg}, \textbf{ msgb\+\_\+data()}, \textbf{ msgb\+\_\+length()}, and \textbf{ osmo\+\_\+tundev\+::wqueue}.



Referenced by \textbf{ osmo\+\_\+tundev\+\_\+alloc()}.

