\doxysection{include/osmocom/core/netdev.h File Reference}
\label{netdev_8h}\index{include/osmocom/core/netdev.h@{include/osmocom/core/netdev.h}}


network device (interface) convenience functions.  


{\ttfamily \#include $<$stddef.\+h$>$}\newline
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/msgb.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/socket.\+h$>$}\newline
\doxysubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef int($\ast$ \textbf{ osmo\+\_\+netdev\+\_\+ifupdown\+\_\+ind\+\_\+cb\+\_\+t}) (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, bool ifupdown)
\item 
typedef int($\ast$ \textbf{ osmo\+\_\+netdev\+\_\+dev\+\_\+name\+\_\+chg\+\_\+cb\+\_\+t}) (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, const char $\ast$new\+\_\+dev\+\_\+name)
\item 
typedef int($\ast$ \textbf{ osmo\+\_\+netdev\+\_\+mtu\+\_\+chg\+\_\+cb\+\_\+t}) (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, unsigned int new\+\_\+mtu)
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+netdev} $\ast$ \textbf{ osmo\+\_\+netdev\+\_\+alloc} (void $\ast$ctx, const char $\ast$\textbf{ name})
\begin{DoxyCompactList}\small\item\em Allocate a new netdev object. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+netdev\+\_\+free} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev)
\begin{DoxyCompactList}\small\item\em Free an allocated netdev object. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+netdev\+\_\+register} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev)
\begin{DoxyCompactList}\small\item\em Start managing the network device referenced by the netdev object. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+netdev\+\_\+unregister} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev)
\begin{DoxyCompactList}\small\item\em Unregister the netdev object (stop managing /moniutoring the interface) \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+netdev\+\_\+is\+\_\+registered} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev)
\begin{DoxyCompactList}\small\item\em Retrieve whether the netdev object is in \char`\"{}registered\char`\"{} state. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+netdev\+\_\+get\+\_\+name} (const struct \textbf{ osmo\+\_\+netdev} $\ast$netdev)
\begin{DoxyCompactList}\small\item\em Get name used to identify the netdev object. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+priv\+\_\+data} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, void $\ast$priv\+\_\+data)
\begin{DoxyCompactList}\small\item\em Set private user data pointer on the netdev object. \end{DoxyCompactList}\item 
void $\ast$ \textbf{ osmo\+\_\+netdev\+\_\+get\+\_\+priv\+\_\+data} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev)
\begin{DoxyCompactList}\small\item\em Get private user data pointer from the netdev object. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+ifindex} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, unsigned int ifindex)
\begin{DoxyCompactList}\small\item\em Set (specify) interface index identifying the network interface to manage. \end{DoxyCompactList}\item 
unsigned int \textbf{ osmo\+\_\+netdev\+\_\+get\+\_\+ifindex} (const struct \textbf{ osmo\+\_\+netdev} $\ast$netdev)
\begin{DoxyCompactList}\small\item\em Get interface index identifying the interface managed by netdev. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+netdev\+\_\+get\+\_\+dev\+\_\+name} (const struct \textbf{ osmo\+\_\+netdev} $\ast$netdev)
\begin{DoxyCompactList}\small\item\em Get name used to name the network interface created by the netdev object. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+netns\+\_\+name} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, const char $\ast$netns)
\begin{DoxyCompactList}\small\item\em Set (specify) name of the network namespace where the network interface to manage is located. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+netdev\+\_\+get\+\_\+netns\+\_\+name} (const struct \textbf{ osmo\+\_\+netdev} $\ast$netdev)
\begin{DoxyCompactList}\small\item\em Get name of network namespace used when opening the netdev interface. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+mtu} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, uint32\+\_\+t mtu)
\begin{DoxyCompactList}\small\item\em Set the MTU of the network interface. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+ifupdown\+\_\+ind\+\_\+cb} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, \textbf{ osmo\+\_\+netdev\+\_\+ifupdown\+\_\+ind\+\_\+cb\+\_\+t} ifupdown\+\_\+ind\+\_\+cb)
\begin{DoxyCompactList}\small\item\em Set ifupdown\+\_\+ind\+\_\+cb callback, called when the link status (UP/\+DOWN) changes. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+dev\+\_\+name\+\_\+chg\+\_\+cb} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, \textbf{ osmo\+\_\+netdev\+\_\+dev\+\_\+name\+\_\+chg\+\_\+cb\+\_\+t} dev\+\_\+name\+\_\+chg\+\_\+cb)
\begin{DoxyCompactList}\small\item\em Set dev\+\_\+name\+\_\+chg\+\_\+cb callback, called when a change in the network name is detected. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+netdev\+\_\+set\+\_\+mtu\+\_\+chg\+\_\+cb} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, \textbf{ osmo\+\_\+netdev\+\_\+mtu\+\_\+chg\+\_\+cb\+\_\+t} mtu\+\_\+chg\+\_\+cb)
\begin{DoxyCompactList}\small\item\em Set mtu\+\_\+chg\+\_\+cb callback, called when a change in the network name is detected. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+netdev\+\_\+add\+\_\+addr} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, const struct \textbf{ osmo\+\_\+sockaddr} $\ast$addr, uint8\+\_\+t prefixlen)
\begin{DoxyCompactList}\small\item\em Add IP address to netdev interface. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+netdev\+\_\+add\+\_\+route} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, const struct \textbf{ osmo\+\_\+sockaddr} $\ast$dst\+\_\+addr, uint8\+\_\+t dst\+\_\+prefixlen, const struct \textbf{ osmo\+\_\+sockaddr} $\ast$gw\+\_\+addr)
\begin{DoxyCompactList}\small\item\em Add IP route to netdev interface. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+netdev\+\_\+ifupdown} (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, bool ifupdown)
\begin{DoxyCompactList}\small\item\em Bring netdev interface UP or DOWN. \end{DoxyCompactList}\end{DoxyCompactItemize}


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



\doxysubsection{Typedef Documentation}
\mbox{\label{netdev_8h_ad83cc7272a57cb8eaddd1f886c46fc46}} 
\index{netdev.h@{netdev.h}!osmo\_netdev\_dev\_name\_chg\_cb\_t@{osmo\_netdev\_dev\_name\_chg\_cb\_t}}
\index{osmo\_netdev\_dev\_name\_chg\_cb\_t@{osmo\_netdev\_dev\_name\_chg\_cb\_t}!netdev.h@{netdev.h}}
\doxysubsubsection{osmo\_netdev\_dev\_name\_chg\_cb\_t}
{\footnotesize\ttfamily typedef int($\ast$ osmo\+\_\+netdev\+\_\+dev\+\_\+name\+\_\+chg\+\_\+cb\+\_\+t) (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, const char $\ast$new\+\_\+dev\+\_\+name)}

\mbox{\label{netdev_8h_a08ac9b015802c5e54ad10ab577094f68}} 
\index{netdev.h@{netdev.h}!osmo\_netdev\_ifupdown\_ind\_cb\_t@{osmo\_netdev\_ifupdown\_ind\_cb\_t}}
\index{osmo\_netdev\_ifupdown\_ind\_cb\_t@{osmo\_netdev\_ifupdown\_ind\_cb\_t}!netdev.h@{netdev.h}}
\doxysubsubsection{osmo\_netdev\_ifupdown\_ind\_cb\_t}
{\footnotesize\ttfamily typedef int($\ast$ osmo\+\_\+netdev\+\_\+ifupdown\+\_\+ind\+\_\+cb\+\_\+t) (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, bool ifupdown)}

\mbox{\label{netdev_8h_a51661be016d90f7bb3a4134ad4ee3ed6}} 
\index{netdev.h@{netdev.h}!osmo\_netdev\_mtu\_chg\_cb\_t@{osmo\_netdev\_mtu\_chg\_cb\_t}}
\index{osmo\_netdev\_mtu\_chg\_cb\_t@{osmo\_netdev\_mtu\_chg\_cb\_t}!netdev.h@{netdev.h}}
\doxysubsubsection{osmo\_netdev\_mtu\_chg\_cb\_t}
{\footnotesize\ttfamily typedef int($\ast$ osmo\+\_\+netdev\+\_\+mtu\+\_\+chg\+\_\+cb\+\_\+t) (struct \textbf{ osmo\+\_\+netdev} $\ast$netdev, unsigned int new\+\_\+mtu)}

