Functions

IPv4 Link Module
[Link Modules API]

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.

Detailed Description

Implementation of IPv4 specific link attributes.

Example: Reading the value of IPV4_DEVCONF_FORWARDING
 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");
Example: Changing the value of IPV4_DEVCONF_FOWARDING
 //
 // ... 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);

Function Documentation

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.

Parameters:
link Link object
cfgid Configuration identifier
res Result pointer

Stores the value of the specified configuration setting in the provided result pointer.

Returns:
0 on success or a negative error code.
-NLE_RANGE cfgid is out of range, 1..IPV4_DEVCONF_MAX
-NLE_NOATTR configuration setting not available

Definition at line 224 of file inet.c.

References rtnl_link_af_alloc().

Here is the call graph for this function:

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.

Parameters:
link Link object
cfgid Configuration identifier
value New value

Changes the value in the per link ipv4 configuration array.

Returns:
0 on success or a negative error code.
-NLE_RANGE cfgid is out of range, 1..IPV4_DEVCONF_MAX
-NLE_NOMEM memory allocation failed

Definition at line 252 of file inet.c.

References rtnl_link_af_alloc().

Here is the call graph for this function: