libnl: Packet Location Aliasing

libnl 3.10.0

Functions
Packet Location Aliasing
Routing Library (libnl-route) » Traffic Control

Packet Location Aliasing More...

## Functions
int | rtnl_pktloc_lookup (const char *name, struct rtnl_pktloc **result)
| Lookup packet location alias.
struct rtnl_pktloc * | rtnl_pktloc_alloc (void)
| Allocate packet location object.
void | rtnl_pktloc_put (struct rtnl_pktloc *loc)
| Return reference of a packet location.
int | rtnl_pktloc_add (struct rtnl_pktloc *loc)
| Add a packet location to the hash table.
void | rtnl_pktloc_foreach (void(*cb)(struct rtnl_pktloc *, void *), void *arg)

## Detailed Description

Packet Location Aliasing

The packet location aliasing interface eases the use of offset definitions inside packets by allowing them to be referenced by name. Known positions of protocol fields are stored in a configuration file and associated with a name for later reference. The configuration file is distributed with the library and provides a well defined set of definitions for most common protocol fields.

# Examples

Example 1.1 Looking up a packet location
  struct rtnl_pktloc *loc;
  rtnl_pktloc_lookup("ip.src", &loc);
  rtnl_pktloc_lookup
  int rtnl_pktloc_lookup(const char *name, struct rtnl_pktloc **result)
  Lookup packet location alias.
  Definition pktloc.c:171
  rtnl_pktloc
  Definition pktloc.h:20

## Function Documentation

## ◆ rtnl_pktloc_lookup()

int rtnl_pktloc_lookup | ( | const char * | name,
|  | struct rtnl_pktloc ** | result )

Lookup packet location alias.

Parameters

  name | Name of packet location.
  result | Result pointer

Tries to find a matching packet location alias for the supplied packet location name.

The file containing the packet location definitions is automatically re-read if its modification time has changed since the last call.

The returned packet location has to be returned after use by calling rtnl_pktloc_put() in order to allow freeing its memory after the last user has abandoned it.

Returns
  0 on success or a negative error code.

Return values

  NLE_PKTLOC_FILE | Unable to open packet location file.
  NLE_OBJ_NOTFOUND | No matching packet location alias found.

Definition at line 171 of file pktloc.c.

## ◆ rtnl_pktloc_alloc()

struct rtnl_pktloc * rtnl_pktloc_alloc | ( | void |  | ) |

Allocate packet location object.

Definition at line 184 of file pktloc.c.

## ◆ rtnl_pktloc_put()

void rtnl_pktloc_put | ( | struct rtnl_pktloc * | loc | ) |

Return reference of a packet location.

Parameters

  loc | packet location object.

Definition at line 201 of file pktloc.c.

Referenced by rtnl_pktloc_add().

Here is the caller graph for this function:

## ◆ rtnl_pktloc_add()

int rtnl_pktloc_add | ( | struct rtnl_pktloc * | loc | ) |

Add a packet location to the hash table.

Parameters

  loc | packet location object

Returns
  0 on success or a negative error code.

Definition at line 217 of file pktloc.c.

References rtnl_pktloc_put().

Here is the call graph for this function:

## ◆ rtnl_pktloc_foreach()

void rtnl_pktloc_foreach | ( | void(*)(struct rtnl_pktloc *, void *) | cb,
|  | void * | arg )

Definition at line 236 of file pktloc.c.