libnl 3.11.0

Topics

 

Link Address Family Modules

struct rtnl_link_af_opsrtnl_link_af_ops_lookup (const unsigned int family)
 Return operations of a specific link address family.
 
void rtnl_link_af_ops_put (struct rtnl_link_af_ops *ops)
 Give back reference to a set of operations.
 
void * rtnl_link_af_alloc (struct rtnl_link *link, const struct rtnl_link_af_ops *ops)
 Allocate and return data buffer for link address family modules.
 
void * rtnl_link_af_data (const struct rtnl_link *link, const struct rtnl_link_af_ops *ops)
 Return data buffer for link address family modules.
 
int rtnl_link_af_register (struct rtnl_link_af_ops *ops)
 Register operations for a link address family.
 
int rtnl_link_af_unregister (struct rtnl_link_af_ops *ops)
 Unregister operations for a link address family.
 
int rtnl_link_af_data_compare (struct rtnl_link *a, struct rtnl_link *b, int family)
 Compare af data for a link address family.
 
int rtnl_link_info_data_compare (struct rtnl_link *a, struct rtnl_link *b, int flags)
 Compare link info data.
 

Link Info Modules

struct rtnl_link_info_opsrtnl_link_info_ops_lookup (const char *name)
 Return operations of a specific link info type.
 
void rtnl_link_info_ops_get (struct rtnl_link_info_ops *ops)
 Take reference to a set of operations.
 
void rtnl_link_info_ops_put (struct rtnl_link_info_ops *ops)
 Give back reference to a set of operations.
 
int rtnl_link_register_info (struct rtnl_link_info_ops *ops)
 Register operations for a link info type.
 
int rtnl_link_unregister_info (struct rtnl_link_info_ops *ops)
 Unregister operations for a link info type.
 

Detailed Description

API for modules implementing specific link types/semantics.

1) Registering/Unregistering a new link info type
static struct rtnl_link_info_ops vlan_info_ops = {
.io_name = "vlan",
.io_alloc = vlan_alloc,
.io_parse = vlan_parse,
.io_dump[NL_DUMP_BRIEF] = vlan_dump_brief,
.io_dump[NL_DUMP_FULL] = vlan_dump_full,
.io_free = vlan_free,
};
static void _nl_init vlan_init(void)
{
rtnl_link_register_info(&vlan_info_ops);
}
static void _nl_exit vlan_exit(void)
{
rtnl_link_unregister_info(&vlan_info_ops);
}

Function Documentation

◆ rtnl_link_info_ops_lookup()

struct rtnl_link_info_ops * rtnl_link_info_ops_lookup ( const char * name)

Return operations of a specific link info type.

Parameters
nameName of link info type.
Note
The returned pointer must be given back using rtnl_link_info_ops_put()
Returns
Pointer to operations or NULL if unavailable.

Definition at line 74 of file api.c.

References rtnl_link_info_ops::io_refcnt.

Referenced by rtnl_link_set_type().

+ Here is the caller graph for this function:

◆ rtnl_link_info_ops_get()

void rtnl_link_info_ops_get ( struct rtnl_link_info_ops * ops)

Take reference to a set of operations.

Parameters
opsLink info operations.

Definition at line 90 of file api.c.

References rtnl_link_info_ops::io_refcnt.

◆ rtnl_link_info_ops_put()

void rtnl_link_info_ops_put ( struct rtnl_link_info_ops * ops)

Give back reference to a set of operations.

Parameters
opsLink info operations.

Definition at line 104 of file api.c.

References rtnl_link_info_ops::io_refcnt.

◆ rtnl_link_register_info()

int rtnl_link_register_info ( struct rtnl_link_info_ops * ops)

Register operations for a link info type.

Parameters
opsLink info operations

This function must be called by modules implementing a specific link info type. It will make the operations implemented by the module available for everyone else.

Returns
0 on success or a negative error code.
-NLE_INVAL Link info name not specified.
-NLE_EXIST Operations for address family already registered.

Definition at line 127 of file api.c.

References rtnl_link_info_ops::io_name.

◆ rtnl_link_unregister_info()

int rtnl_link_unregister_info ( struct rtnl_link_info_ops * ops)

Unregister operations for a link info type.

Parameters
opsLink info operations

This function must be called if a module implementing a specific link info type is unloaded or becomes unavailable. It must provide a set of operations which have previously been registered using rtnl_link_register_info().

Returns
0 on success or a negative error code
_NLE_OPNOTSUPP Link info operations not registered.
-NLE_BUSY Link info operations still in use.

Definition at line 162 of file api.c.

References rtnl_link_info_ops::io_name, and rtnl_link_info_ops::io_refcnt.

◆ rtnl_link_af_ops_lookup()

struct rtnl_link_af_ops * rtnl_link_af_ops_lookup ( const unsigned int family)

Return operations of a specific link address family.

Parameters
familyAddress family
Note
The returned pointer must be given back using rtnl_link_af_ops_put()
Returns
Pointer to operations or NULL if unavailable.

Definition at line 209 of file api.c.

References rtnl_link_af_ops::ao_refcnt.

Referenced by rtnl_link_af_data_compare().

+ Here is the caller graph for this function:

◆ rtnl_link_af_ops_put()

void rtnl_link_af_ops_put ( struct rtnl_link_af_ops * ops)

Give back reference to a set of operations.

Parameters
opsAddress family operations.

Definition at line 226 of file api.c.

References rtnl_link_af_ops::ao_refcnt.

Referenced by rtnl_link_af_data_compare().

+ Here is the caller graph for this function:

◆ rtnl_link_af_alloc()

void * rtnl_link_af_alloc ( struct rtnl_link * link,
const struct rtnl_link_af_ops * ops )

Allocate and return data buffer for link address family modules.

Parameters
linkLink object
opsAddress family operations

This function must be called by link address family modules in all cases where the API does not provide the data buffer as argument already. This typically includes set functions the module provides. Calling this function is strictly required to ensure proper allocation of the buffer upon first use. Link objects will NOT proactively allocate a data buffer for each registered link address family.

Returns
Pointer to data buffer or NULL on error.

Definition at line 249 of file api.c.

References rtnl_link_af_ops::ao_alloc, and rtnl_link_af_ops::ao_family.

Referenced by rtnl_link_inet_set_conf().

+ Here is the caller graph for this function:

◆ rtnl_link_af_data()

void * rtnl_link_af_data ( const struct rtnl_link * link,
const struct rtnl_link_af_ops * ops )

Return data buffer for link address family modules.

Parameters
linkLink object
opsAddress family operations

This function returns a pointer to the data buffer for the specified link address family module or NULL if the buffer was not allocated yet. This function is typically used by get functions of modules which are not interested in having the data buffer allocated if no values have been set yet.

Returns
Pointer to data buffer or NULL on error.

Definition at line 284 of file api.c.

References rtnl_link_af_ops::ao_family.

Referenced by rtnl_link_inet_get_conf().

+ Here is the caller graph for this function:

◆ rtnl_link_af_register()

int rtnl_link_af_register ( struct rtnl_link_af_ops * ops)

Register operations for a link address family.

Parameters
opsAddress family operations

This function must be called by modules implementing a specific link address family. It will make the operations implemented by the module available for everyone else.

Returns
0 on success or a negative error code.
-NLE_INVAL Address family is out of range (0..AF_MAX)
-NLE_EXIST Operations for address family already registered.

Definition at line 305 of file api.c.

References rtnl_link_af_ops::ao_family, and rtnl_link_af_ops::ao_refcnt.

◆ rtnl_link_af_unregister()

int rtnl_link_af_unregister ( struct rtnl_link_af_ops * ops)

Unregister operations for a link address family.

Parameters
opsAddress family operations

This function must be called if a module implementing a specific link address family is unloaded or becomes unavailable. It must provide a set of operations which have previously been registered using rtnl_link_af_register().

Returns
0 on success or a negative error code
-NLE_INVAL ops is NULL
-NLE_OBJ_NOTFOUND Address family operations not registered.
-NLE_BUSY Address family operations still in use.

Definition at line 344 of file api.c.

References rtnl_link_af_ops::ao_family, and rtnl_link_af_ops::ao_refcnt.

◆ rtnl_link_af_data_compare()

int rtnl_link_af_data_compare ( struct rtnl_link * a,
struct rtnl_link * b,
int family )

Compare af data for a link address family.

Parameters
aLink object a
bLink object b
familyaf data family

This function will compare af_data between two links a and b of family given by arg family

Returns
0 if address family specific data matches or is not present or != 0 if it mismatches.

Definition at line 385 of file api.c.

References rtnl_link_af_ops::ao_compare, rtnl_link_af_ops_lookup(), and rtnl_link_af_ops_put().

+ Here is the call graph for this function:

◆ rtnl_link_info_data_compare()

int rtnl_link_info_data_compare ( struct rtnl_link * a,
struct rtnl_link * b,
int flags )

Compare link info data.

Parameters
aLink object a
bLink object b

This function will compare link_info data between two links a and b

Returns
0 if link_info data matches or is not present or != 0 if it mismatches.

Definition at line 425 of file api.c.

References rtnl_link_info_ops::io_compare.