libnl 3.5.0

Modules
Link Modules API
Routing Library (libnl-route) » Links (Interfaces)

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_ops * | rtnl_link_info_ops_lookup (const char *name)
| Return operations of a specific link info type. More...
void | rtnl_link_info_ops_put (struct rtnl_link_info_ops *ops)
| Give back reference to a set of operations. More...
int | rtnl_link_register_info (struct rtnl_link_info_ops *ops)
| Register operations for a link info type. More...
int | rtnl_link_unregister_info (struct rtnl_link_info_ops *ops)
| Unregister operations for a link info type. More...

## Link Address Family Modules
struct rtnl_link_af_ops * | rtnl_link_af_ops_lookup (const unsigned int family)
| Return operations of a specific link address family. More...
void | rtnl_link_af_ops_put (struct rtnl_link_af_ops *ops)
| Give back reference to a set of operations. More...
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. More...
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. More...
int | rtnl_link_af_register (struct rtnl_link_af_ops *ops)
| Register operations for a link address family. More...
int | rtnl_link_af_unregister (struct rtnl_link_af_ops *ops)
| Unregister operations for a link address family. More...
int | rtnl_link_af_data_compare (struct rtnl_link *a, struct rtnl_link *b, int family)
| Compare af data for a link address family. More...
int | rtnl_link_info_data_compare (struct rtnl_link *a, struct rtnl_link *b, int flags)
| Compare link info data. More...

## 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

## ◆ 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

  name | Name 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 77 of file api.c.

## ◆ 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

  ops | Link info operations.

Definition at line 93 of file api.c.

## ◆ rtnl_link_register_info()

int rtnl_link_register_info | ( | struct rtnl_link_info_ops * | ops | ) |

Register operations for a link info type.

Parameters

  ops | Link 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 111 of file api.c.

## ◆ rtnl_link_unregister_info()

int rtnl_link_unregister_info | ( | struct rtnl_link_info_ops * | ops | ) |

Unregister operations for a link info type.

Parameters

  ops | Link 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 146 of file api.c.

## ◆ 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

  family | Address 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 192 of file api.c.

## ◆ 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

  ops | Address family operations.

Definition at line 209 of file api.c.

## ◆ 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

  link | Link object
  ops | Address 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 229 of file api.c.

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

  link | Link object
  ops | Address 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 264 of file api.c.

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

  ops | Address 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 285 of file api.c.

## ◆ rtnl_link_af_unregister()

int rtnl_link_af_unregister | ( | struct rtnl_link_af_ops * | ops | ) |

Unregister operations for a link address family.

Parameters

  ops | Address 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 324 of file api.c.

## ◆ 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

  a | Link object a
  b | Link object b
  family | af 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 365 of file api.c.

## ◆ 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

  a | Link object a
  b | Link 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 405 of file api.c.