\doxysection{src/core/tun.c File Reference}
\label{tun_8c}\index{src/core/tun.c@{src/core/tun.c}}
{\ttfamily \#include \char`\"{}config.\+h\char`\"{}}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$fcntl.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$ifaddrs.\+h$>$}\newline
{\ttfamily \#include $<$sys/types.\+h$>$}\newline
{\ttfamily \#include $<$sys/time.\+h$>$}\newline
{\ttfamily \#include $<$sys/ioctl.\+h$>$}\newline
{\ttfamily \#include $<$sys/socket.\+h$>$}\newline
{\ttfamily \#include $<$sys/stat.\+h$>$}\newline
{\ttfamily \#include $<$net/if.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/select.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/linuxlist.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/logging.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/write\+\_\+queue.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/socket.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/netns.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/netdev.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/tun.\+h$>$}\newline
\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 
static int \textbf{ tundev\+\_\+open\+\_\+fd} (struct \textbf{ osmo\+\_\+tundev} $\ast$tundev, int \textbf{ flags})
\begin{DoxyCompactList}\small\item\em Open and configure fd of the tunnel device. \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}
