Loading...
Searching...
No Matches
tun.c File Reference
`#include "config.h"`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <fcntl.h>`
`#include <unistd.h>`
`#include <errno.h>`
`#include <ifaddrs.h>`
`#include <sys/types.h>`
`#include <sys/time.h>`
`#include <sys/ioctl.h>`
`#include <sys/socket.h>`
`#include <sys/stat.h>`
`#include <net/if.h>`
`#include <osmocom/core/utils.h>`
`#include <osmocom/core/select.h>`
`#include <osmocom/core/linuxlist.h>`
`#include <osmocom/core/logging.h>`
`#include <osmocom/core/write_queue.h>`
`#include <osmocom/core/socket.h>`
`#include <osmocom/core/netns.h>`
`#include <osmocom/core/netdev.h>`
`#include <osmocom/core/tun.h>`

## Data Structures

struct | osmo_tundev

## Macros

#define | TUN_DEV_PATH "/dev/net/tun"
#define | TUN_PACKET_MAX 8196
#define | LOGTUN(tun, lvl, fmt, args ...)

## Functions

static int | tundev_decaps (struct osmo_tundev *tundev)
static int | tundev_read_cb (struct osmo_fd *fd)
static int | tundev_write_cb (struct osmo_fd *fd, struct msgb *msg)
static int | tundev_ifupdown_ind_cb (struct osmo_netdev *netdev, bool ifupdown)
static int | tundev_dev_name_chg_cb (struct osmo_netdev *netdev, const char *new_dev_name)
static int | tundev_mtu_chg_cb (struct osmo_netdev *netdev, uint32_t new_mtu)
struct osmo_tundev * | osmo_tundev_alloc (void *ctx, const char *name)
| Allocate a new tundev object.
void | osmo_tundev_free (struct osmo_tundev *tundev)
| Free an allocated tundev object.
int | osmo_tundev_open (struct osmo_tundev *tundev)
| Open the tunnel device owned by the tundev object.
int | osmo_tundev_close (struct osmo_tundev *tundev)
| Close the tunnel device owned by the tundev object.
bool | osmo_tundev_is_open (struct osmo_tundev *tundev)
| Retrieve whether the tundev object is in "opened" state.
void | osmo_tundev_set_priv_data (struct osmo_tundev *tundev, void *priv_data)
| Set private user data pointer on the tundev object.
void * | osmo_tundev_get_priv_data (struct osmo_tundev *tundev)
| Get private user data pointer from the tundev object.
void | osmo_tundev_set_data_ind_cb (struct osmo_tundev *tundev, osmo_tundev_data_ind_cb_t data_ind_cb)
| Set data_ind_cb callback, called when a new packet is received on the tun interface.
const char * | osmo_tundev_get_name (const struct osmo_tundev *tundev)
| Get name used to identify the tundev object.
int | osmo_tundev_get_fd (const struct osmo_tundev *tundev)
| Get FD associated to the tundev object.
int | osmo_tundev_set_dev_name (struct osmo_tundev *tundev, const char *dev_name)
| Set name used to name the tunnel interface created by the tundev object.
const char * | osmo_tundev_get_dev_name (const struct osmo_tundev *tundev)
| Get name used to name the tunnel interface created by the tundev object.
int | osmo_tundev_set_netns_name (struct osmo_tundev *tundev, const char *netns_name)
| Set name of the network namespace to use when opening the tunnel interface.
const char * | osmo_tundev_get_netns_name (const struct osmo_tundev *tundev)
| Get name of network namespace used when opening the tunnel interface.
struct osmo_netdev * | osmo_tundev_get_netdev (struct osmo_tundev *tundev)
| Get netdev managing the tunnel interface of tundev.
int | osmo_tundev_send (struct osmo_tundev *tundev, struct msgb *msg)
| Submit a packet to the tunnel device managed by the tundev object.