libosmocore 1.9.0.196-9975
Osmocom core library
tun.h
Go to the documentation of this file.
1
4#pragma once
5#if (!EMBEDDED)
6
7#include <stddef.h>
8#include <stdint.h>
9
10#include <osmocom/core/msgb.h>
11#include <osmocom/core/socket.h>
12#include <osmocom/core/netdev.h>
13
14struct osmo_tundev;
15
16/* callback user gets ownership of the msgb and is expected to free it. */
17typedef int (*osmo_tundev_data_ind_cb_t)(struct osmo_tundev *tun, struct msgb *msg);
18
19struct osmo_tundev *osmo_tundev_alloc(void *ctx, const char *name);
20void osmo_tundev_free(struct osmo_tundev *tundev);
21int osmo_tundev_open(struct osmo_tundev *tundev);
22int osmo_tundev_close(struct osmo_tundev *tundev);
23bool osmo_tundev_is_open(struct osmo_tundev *tundev);
24
25void osmo_tundev_set_priv_data(struct osmo_tundev *tundev, void *priv_data);
26void *osmo_tundev_get_priv_data(struct osmo_tundev *tundev);
27
29
30const char *osmo_tundev_get_name(const struct osmo_tundev *tundev);
31
32int osmo_tundev_set_dev_name(struct osmo_tundev *tundev, const char *dev_name);
33const char *osmo_tundev_get_dev_name(const struct osmo_tundev *tundev);
34
35int osmo_tundev_set_netns_name(struct osmo_tundev *tundev, const char *netns);
36const char *osmo_tundev_get_netns_name(const struct osmo_tundev *tundev);
37
38struct osmo_netdev *osmo_tundev_get_netdev(struct osmo_tundev *tundev);
39
40int osmo_tundev_send(struct osmo_tundev *tundev, struct msgb *msg);
41
42#endif /* (!EMBEDDED) */
const char * 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:516
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:460
struct osmo_tundev * osmo_tundev_alloc(void *ctx, const char *name)
Allocate a new tundev object.
Definition: tun.c:229
bool osmo_tundev_is_open(struct osmo_tundev *tundev)
Retrieve whether the tundev object is in "opened" state.
Definition: tun.c:452
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:503
void * osmo_tundev_get_priv_data(struct osmo_tundev *tundev)
Get private user data pointer from the tundev object.
Definition: tun.c:469
struct osmo_netdev * osmo_tundev_get_netdev(struct osmo_tundev *tundev)
Get netdev managing the tunnel interface of tundev.
Definition: tun.c:551
void osmo_tundev_free(struct osmo_tundev *tundev)
Free an allocated tundev object.
Definition: tun.c:259
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:542
const char * osmo_tundev_get_name(const struct osmo_tundev *tundev)
Get name used to identify the tundev object.
Definition: tun.c:487
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:478
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:563
int osmo_tundev_close(struct osmo_tundev *tundev)
Close the tunnel device owned by the tundev object.
Definition: tun.c:427
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:530
int osmo_tundev_open(struct osmo_tundev *tundev)
Open the tunnel device owned by the tundev object.
Definition: tun.c:345
uint8_t msg[0]
network device (interface) convenience functions.
Osmocom socket convenience functions.
Osmocom message buffer.
Definition: msgb.h:31
Definition: netdev.c:255
Definition: tun.c:111
void * priv_data
Definition: tun.c:134
char * dev_name
Definition: tun.c:123
osmo_tundev_data_ind_cb_t data_ind_cb
Definition: tun.c:137
int(* osmo_tundev_data_ind_cb_t)(struct osmo_tundev *tun, struct msgb *msg)
Definition: tun.h:17