|
static struct netdev_netns_ctx * | netdev_netns_ctx_alloc (void *ctx, const char *netns_name) |
|
static void | netdev_netns_ctx_free (struct netdev_netns_ctx *netns_ctx) |
|
static int | netdev_netns_ctx_init (struct netdev_netns_ctx *netns_ctx) |
|
static struct netdev_netns_ctx * | netdev_netns_ctx_find_by_netns_name (const char *netns_name) |
|
static struct netdev_netns_ctx * | netdev_netns_ctx_get (const char *netns_name) |
|
static void | netdev_netns_ctx_put (struct netdev_netns_ctx *netns_ctx) |
|
struct osmo_netdev * | osmo_netdev_alloc (void *ctx, const char *name) |
| Allocate a new netdev object. More...
|
|
void | osmo_netdev_free (struct osmo_netdev *netdev) |
| Free an allocated netdev object. More...
|
|
int | osmo_netdev_register (struct osmo_netdev *netdev) |
| Start managing the network device referenced by the netdev object. More...
|
|
int | osmo_netdev_unregister (struct osmo_netdev *netdev) |
| Unregister the netdev object (stop managing /moniutoring the interface) More...
|
|
bool | osmo_netdev_is_registered (struct osmo_netdev *netdev) |
| Retrieve whether the netdev object is in "registered" state. More...
|
|
void | osmo_netdev_set_priv_data (struct osmo_netdev *netdev, void *priv_data) |
| Set private user data pointer on the netdev object. More...
|
|
void * | osmo_netdev_get_priv_data (struct osmo_netdev *netdev) |
| Get private user data pointer from the netdev object. More...
|
|
void | osmo_netdev_set_ifupdown_ind_cb (struct osmo_netdev *netdev, osmo_netdev_ifupdown_ind_cb_t ifupdown_ind_cb) |
| Set ifupdown_ind_cb callback, called when the link status (UP/DOWN) changes. More...
|
|
void | osmo_netdev_set_dev_name_chg_cb (struct osmo_netdev *netdev, osmo_netdev_dev_name_chg_cb_t dev_name_chg_cb) |
| Set dev_name_chg_cb callback, called when a change in the network name is detected. More...
|
|
void | osmo_netdev_set_mtu_chg_cb (struct osmo_netdev *netdev, osmo_netdev_mtu_chg_cb_t mtu_chg_cb) |
| Set mtu_chg_cb callback, called when a change in the network name is detected. More...
|
|
const char * | osmo_netdev_get_name (const struct osmo_netdev *netdev) |
| Get name used to identify the netdev object. More...
|
|
int | osmo_netdev_set_ifindex (struct osmo_netdev *netdev, unsigned int ifindex) |
| Set (specify) interface index identifying the network interface to manage. More...
|
|
unsigned int | osmo_netdev_get_ifindex (const struct osmo_netdev *netdev) |
| Get interface index identifying the interface managed by netdev. More...
|
|
int | osmo_netdev_set_netns_name (struct osmo_netdev *netdev, const char *netns_name) |
| Set (specify) name of the network namespace where the network interface to manage is located. More...
|
|
const char * | osmo_netdev_get_netns_name (const struct osmo_netdev *netdev) |
| Get name of network namespace used when opening the netdev interface. More...
|
|
const char * | osmo_netdev_get_dev_name (const struct osmo_netdev *netdev) |
| Get name used to name the network interface created by the netdev object. More...
|
|
int | osmo_netdev_set_mtu (struct osmo_netdev *netdev, uint32_t mtu) |
| Set the MTU of the network interface. More...
|
|
int | osmo_netdev_ifupdown (struct osmo_netdev *netdev, bool ifupdown) |
| Bring netdev interface UP or DOWN. More...
|
|
int | osmo_netdev_add_addr (struct osmo_netdev *netdev, const struct osmo_sockaddr *addr, uint8_t prefixlen) |
| Add IP address to netdev interface. More...
|
|
int | osmo_netdev_add_route (struct osmo_netdev *netdev, const struct osmo_sockaddr *dst_addr, uint8_t dst_prefixlen, const struct osmo_sockaddr *gw_addr) |
| Add IP route to netdev interface. More...
|
|
Example lifecycle use of the API:
struct osmo_sockaddr_str osa_str = {};
struct osmo_sockaddr osa = {};
// Allocate object:
struct osmo_netdev *netdev = osmo_netdev_alloc(parent_talloc_ctx, name);
OSMO_ASSERT(netdev);
// Configure object (before registration):
rc = osmo_netdev_set_netns_name(netdev, "some_netns_name_or_null");
rc = osmo_netdev_set_ifindex(netdev, if_nametoindex("eth0"));
// Register object:
rc = osmo_netdev_register(netdev);
// The network interface is now being monitored and the network interface
// can be operated (see below)
// Add a local IPv4 address:
rc = osmo_sockaddr_str_from_str2(&osa_str, "192.168.200.1");
rc = osmo_sockaddr_str_to_sockaddr(&osa_str, &osa.u.sas);
rc = osmo_netdev_add_addr(netdev, &osa, 24);
// Bring network interface up:
rc = osmo_netdev_ifupdown(netdev, true);
// Add default route (0.0.0.0/0):
rc = osmo_sockaddr_str_from_str2(&osa_str, "0.0.0.0");
rc = osmo_sockaddr_str_to_sockaddr(&osa_str, &osa.u.sas);
rc = osmo_netdev_add_route(netdev, &osa, 0, NULL);
// Unregister (can be freed directly too):
rc = osmo_netdev_unregister(netdev);
// Free the object:
osmo_netdev_free(netdev);