libnl  3.2.3
Link Modules API

API for modules implementing specific link types/semantics. More...

Modules

 IPv4 Link Module
 

Implementation of IPv4 specific link attributes.


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_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.

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.

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 __init vlan_init(void)
 {
        rtnl_link_register_info(&vlan_info_ops);
 }

 static void __exit vlan_exit(void)
 {
        rtnl_link_unregister_info(&vlan_info_ops);
 }

Function Documentation

struct rtnl_link_info_ops* rtnl_link_info_ops_lookup ( const char *  name) [read]

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:

Give back reference to a set of operations.

Parameters:
opsLink info operations.

Definition at line 88 of file api.c.

References rtnl_link_info_ops::io_refcnt.

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 106 of file api.c.

References rtnl_link_info_ops::io_name.

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 134 of file api.c.

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

struct rtnl_link_af_ops* rtnl_link_af_ops_lookup ( const unsigned int  family) [read]

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 172 of file api.c.

References rtnl_link_af_ops::ao_refcnt.

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 187 of file api.c.

References rtnl_link_af_ops::ao_refcnt.

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 207 of file api.c.

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

Referenced by rtnl_link_inet_get_conf(), and rtnl_link_inet_set_conf().

+ Here is the caller graph for this function:

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 242 of file api.c.

References rtnl_link_af_ops::ao_family.

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 263 of file api.c.

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

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 294 of file api.c.

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