Implementation of IPv4 specific link attributes. More...
Functions | |
const char * | rtnl_link_inet_devconf2str (int type, char *buf, size_t len) |
unsigned int | rtnl_link_inet_str2devconf (const char *name) |
int | rtnl_link_inet_get_conf (struct rtnl_link *link, const unsigned int cfgid, uint32_t *res) |
Get value of a ipv4 link configuration setting. | |
int | rtnl_link_inet_set_conf (struct rtnl_link *link, const unsigned int cfgid, uint32_t value) |
Change value of a ipv4 link configuration setting. |
Implementation of IPv4 specific link attributes.
struct nl_cache *cache; struct rtnl_link *link; uint32_t value; // Allocate a link cache rtnl_link_alloc_cache(sock, AF_UNSPEC, &cache); // Search for the link we wish to see the value from link = rtnl_link_get_by_name(cache, "eth0"); // Read the value of the setting IPV4_DEVCONF_FORWARDING if (rtnl_link_inet_get_conf(link, IPV4_DEVCONF_FORWARDING, &value) < 0) // Error: Unable to read config setting printf("forwarding is %s\n", value ? "enabled" : "disabled");
// // ... Continueing from the previous example ... // struct rtnl_link *new; // Allocate a new link to store the changes we wish to make. new = rtnl_link_alloc(); // Set IPV4_DEVCONF_FORWARDING to '1' rtnl_link_inet_set_conf(new, IPV4_DEVCONF_FORWARDING, 1); // Send the change request to the kernel. rtnl_link_change(sock, link, new, 0);
int rtnl_link_inet_get_conf | ( | struct rtnl_link * | link, | |
const unsigned int | cfgid, | |||
uint32_t * | res | |||
) |
Get value of a ipv4 link configuration setting.
link | Link object | |
cfgid | Configuration identifier | |
res | Result pointer |
Stores the value of the specified configuration setting in the provided result pointer.
Definition at line 224 of file inet.c.
References rtnl_link_af_alloc().
int rtnl_link_inet_set_conf | ( | struct rtnl_link * | link, | |
const unsigned int | cfgid, | |||
uint32_t | value | |||
) |
Change value of a ipv4 link configuration setting.
link | Link object | |
cfgid | Configuration identifier | |
value | New value |
Changes the value in the per link ipv4 configuration array.
Definition at line 252 of file inet.c.
References rtnl_link_af_alloc().