libosmocore 1.13.1.1-afb4 Osmocom core library

tun.h
Go to the documentation of this file.
1
4#pragma once
5
6#include <stddef.h>
7#include <stdint.h>
8
9#include <osmocom/core/msgb.h>
10#include <osmocom/core/socket.h>
11#include <osmocom/core/netdev.h>
12
13 struct osmo_tundev;
14
15/* callback user gets ownership of the msgb and is expected to free it. */
16 typedef int (*osmo_tundev_data_ind_cb_t)(struct osmo_tundev *tun, struct msgb *msg);
17
18 struct osmo_tundev *osmo_tundev_alloc(void *ctx, const char *name);
19 void osmo_tundev_free(struct osmo_tundev *tundev);
20 int osmo_tundev_open(struct osmo_tundev *tundev);
21 int osmo_tundev_close(struct osmo_tundev *tundev);
22 bool osmo_tundev_is_open(struct osmo_tundev *tundev);
23
24 void osmo_tundev_set_priv_data(struct osmo_tundev *tundev, void *priv_data);
25 void *osmo_tundev_get_priv_data(struct osmo_tundev *tundev);
26
27 void osmo_tundev_set_data_ind_cb(struct osmo_tundev *tundev, osmo_tundev_data_ind_cb_t data_ind_cb);
28
29 const char *osmo_tundev_get_name(const struct osmo_tundev *tundev);
30
31 int osmo_tundev_get_fd(const struct osmo_tundev *tundev);
32
33 int osmo_tundev_set_dev_name(struct osmo_tundev *tundev, const char *dev_name);
34 const char *osmo_tundev_get_dev_name(const struct osmo_tundev *tundev);
35
36 int osmo_tundev_set_netns_name(struct osmo_tundev *tundev, const char *netns);
37 const char *osmo_tundev_get_netns_name(const struct osmo_tundev *tundev);
38
39 struct osmo_netdev *osmo_tundev_get_netdev(struct osmo_tundev *tundev);
40
41 int osmo_tundev_send(struct osmo_tundev *tundev, struct msgb *msg);
name
const char * name
osmo_tundev_get_dev_name
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.
Definition: tun.c:529
osmo_tundev_set_priv_data
void osmo_tundev_set_priv_data(struct osmo_tundev *tundev, void *priv_data)
Set private user data pointer on the tundev object.
Definition: tun.c:464
osmo_tundev_alloc
struct osmo_tundev * osmo_tundev_alloc(void *ctx, const char *name)
Allocate a new tundev object.
Definition: tun.c:227
osmo_tundev_is_open
bool osmo_tundev_is_open(struct osmo_tundev *tundev)
Retrieve whether the tundev object is in "opened" state.
Definition: tun.c:456
osmo_tundev_set_dev_name
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.
Definition: tun.c:516
osmo_tundev_get_priv_data
void * osmo_tundev_get_priv_data(struct osmo_tundev *tundev)
Get private user data pointer from the tundev object.
Definition: tun.c:473
osmo_tundev_get_netdev
struct osmo_netdev * osmo_tundev_get_netdev(struct osmo_tundev *tundev)
Get netdev managing the tunnel interface of tundev.
Definition: tun.c:564
osmo_tundev_get_fd
int osmo_tundev_get_fd(const struct osmo_tundev *tundev)
Get FD associated to the tundev object.
Definition: tun.c:500
osmo_tundev_free
void osmo_tundev_free(struct osmo_tundev *tundev)
Free an allocated tundev object.
Definition: tun.c:257
osmo_tundev_get_netns_name
const char * osmo_tundev_get_netns_name(const struct osmo_tundev *tundev)
Get name of network namespace used when opening the tunnel interface.
Definition: tun.c:555
osmo_tundev_get_name
const char * osmo_tundev_get_name(const struct osmo_tundev *tundev)
Get name used to identify the tundev object.
Definition: tun.c:491
osmo_tundev_set_data_ind_cb
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.
Definition: tun.c:482
osmo_tundev_send
int osmo_tundev_send(struct osmo_tundev *tundev, struct msgb *msg)
Submit a packet to the tunnel device managed by the tundev object.
Definition: tun.c:576
osmo_tundev_close
int osmo_tundev_close(struct osmo_tundev *tundev)
Close the tunnel device owned by the tundev object.
Definition: tun.c:431
osmo_tundev_set_netns_name
int osmo_tundev_set_netns_name(struct osmo_tundev *tundev, const char *netns)
Set name of the network namespace to use when opening the tunnel interface.
Definition: tun.c:543
osmo_tundev_open
int osmo_tundev_open(struct osmo_tundev *tundev)
Open the tunnel device owned by the tundev object.
Definition: tun.c:345
msg
uint8_t msg[0]
msgb.h
netdev.h
network device (interface) convenience functions.
socket.h
Osmocom socket convenience functions.
msgb
Osmocom message buffer.
Definition: msgb.h:31
osmo_netdev
Definition: netdev.c:259
osmo_tundev
Definition: tun.c:109
osmo_tundev::priv_data
void * priv_data
Definition: tun.c:132
osmo_tundev::dev_name
char * dev_name
Definition: tun.c:121
osmo_tundev::data_ind_cb
osmo_tundev_data_ind_cb_t data_ind_cb
Definition: tun.c:135
osmo_tundev_data_ind_cb_t
int(* osmo_tundev_data_ind_cb_t)(struct osmo_tundev *tun, struct msgb *msg)
Definition: tun.h:16