libnl 3.5.0

Data Structures
Object (Cacheable)
Core Library (libnl) » Data Types

Generic object data type, for inheritance purposes to implement cacheable data types. More...

## Data Structures
struct | nl_derived_object

## Object Creation/Deletion
struct nl_object * | nl_object_alloc (struct nl_object_ops *ops)
| Allocate a new object of kind specified by the operations handle. More...
int | nl_object_alloc_name (const char *kind, struct nl_object **result)
| Allocate new object of kind specified by the name. More...
struct nl_object * | nl_object_clone (struct nl_object *obj)
| Allocate a new object and copy all data from an existing object. More...
int | nl_object_update (struct nl_object *dst, struct nl_object *src)
| Merge a cacheable object. More...
void | nl_object_free (struct nl_object *obj)
| Free a cacheable object. More...

## Reference Management
void | nl_object_get (struct nl_object *obj)
| Acquire a reference on a object. More...
void | nl_object_put (struct nl_object *obj)
| Release a reference from an object. More...
int | nl_object_shared (struct nl_object *obj)
| Check whether this object is used by multiple users. More...

## Marks
void | nl_object_mark (struct nl_object *obj)
| Add mark to object. More...
void | nl_object_unmark (struct nl_object *obj)
| Remove mark from object. More...
int | nl_object_is_marked (struct nl_object *obj)
| Return true if object is marked. More...

## Utillities
void | nl_object_dump (struct nl_object *obj, struct nl_dump_params *params)
| Dump this object according to the specified parameters. More...
void | nl_object_dump_buf (struct nl_object *obj, char *buf, size_t len)
int | nl_object_identical (struct nl_object *a, struct nl_object *b)
| Check if the identifiers of two objects are identical. More...
uint64_t | nl_object_diff64 (struct nl_object *a, struct nl_object *b)
| Compute bitmask representing difference in attribute values. More...
uint32_t | nl_object_diff (struct nl_object *a, struct nl_object *b)
| Compute 32-bit bitmask representing difference in attribute values. More...
int | nl_object_match_filter (struct nl_object *obj, struct nl_object *filter)
| Match a filter against an object. More...
char * | nl_object_attrs2str (struct nl_object *obj, uint32_t attrs, char *buf, size_t len)
| Convert bitmask of attributes to a character string. More...
char * | nl_object_attr_list (struct nl_object *obj, char *buf, size_t len)
| Return list of attributes present in an object. More...
void | nl_object_keygen (struct nl_object *obj, uint32_t *hashkey, uint32_t hashtbl_sz)
| Generate object hash key. More...

## Attributes
int | nl_object_get_refcnt (struct nl_object *obj)
| Return number of references held. More...
struct nl_cache * | nl_object_get_cache (struct nl_object *obj)
| Return cache the object is associated with. More...
const char * | nl_object_get_type (const struct nl_object *obj)
| Return the object's type. More...
int | nl_object_get_msgtype (const struct nl_object *obj)
| Return the netlink message type the object was derived from. More...
struct nl_object_ops * | nl_object_get_ops (const struct nl_object *obj)
| Return object operations structure. More...
uint32_t | nl_object_get_id_attrs (struct nl_object *obj)
| Return object id attribute mask. More...

## Detailed Description

Generic object data type, for inheritance purposes to implement cacheable data types.

Related sections in the development guide:

## Header

#include <netlink/object.h>

## Function Documentation

## ◆ nl_object_alloc()

struct nl_object* nl_object_alloc | ( | struct nl_object_ops * | ops | ) |

Allocate a new object of kind specified by the operations handle.

Parameters

  ops | cache operations handle

Returns
  The new object or NULL

Definition at line 55 of file object.c.

Referenced by genl_family_alloc(), nl_object_alloc_name(), and rtnl_link_alloc().

Here is the caller graph for this function:

## ◆ nl_object_alloc_name()

int nl_object_alloc_name | ( | const char * | kind,
|  | struct nl_object ** | result
| ) |  |

Allocate new object of kind specified by the name.

Parameters

  kind | name of object type
  result | Result pointer

Returns
  0 on success or a negative error code.

Definition at line 85 of file object.c.

References nl_cache_ops_lookup_safe(), nl_cache_ops_put(), and nl_object_alloc().

Here is the call graph for this function:

## ◆ nl_object_clone()

struct nl_object* nl_object_clone | ( | struct nl_object * | obj | ) |

Allocate a new object and copy all data from an existing object.

Parameters

  obj | object to inherite data from

Returns
  The new object or NULL.

Definition at line 111 of file object.c.

Referenced by nl_cache_add().

Here is the caller graph for this function:

## ◆ nl_object_update()

int nl_object_update | ( | struct nl_object * | dst,
|  | struct nl_object * | src
| ) |  |

Merge a cacheable object.

Parameters

  dst | object to be merged into
  src | new object to be merged into dst

Returns
  0 or a negative error code.

Definition at line 155 of file object.c.

## ◆ nl_object_free()

void nl_object_free | ( | struct nl_object * | obj | ) |

Free a cacheable object.

Parameters

  obj | object to free

Returns
  0 or a negative error code.

Definition at line 171 of file object.c.

Referenced by nl_object_put().

Here is the caller graph for this function:

## ◆ nl_object_get()

void nl_object_get | ( | struct nl_object * | obj | ) |

Acquire a reference on a object.

Parameters

  obj | object to acquire reference from

Definition at line 205 of file object.c.

Referenced by genl_ctrl_search(), genl_ctrl_search_by_name(), nl_cache_add(), nl_cache_foreach_filter(), nl_cache_move(), nl_hash_table_add(), rtnl_link_veth_get_peer(), rtnl_neigh_get(), rtnl_neigh_get_by_vlan(), rtnl_tc_get_link(), and rtnl_tc_set_link().

Here is the caller graph for this function:

## ◆ nl_object_put()

void nl_object_put | ( | struct nl_object * | obj | ) |

Release a reference from an object.

Parameters

  obj | object to release reference from

Definition at line 216 of file object.c.

References nl_object_free().

Referenced by genl_family_put(), nl_cache_foreach_filter(), nl_cache_remove(), nl_hash_table_del(), nl_hash_table_free(), and rtnl_link_put().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ nl_object_shared()

int nl_object_shared | ( | struct nl_object * | obj | ) |

Check whether this object is used by multiple users.

Parameters

  obj | object to check

Returns
  true or false

Definition at line 237 of file object.c.

## ◆ nl_object_mark()

void nl_object_mark | ( | struct nl_object * | obj | ) |

Add mark to object.

Parameters

  obj | Object to mark

Definition at line 253 of file object.c.

Referenced by nl_cache_mark_all().

Here is the caller graph for this function:

## ◆ nl_object_unmark()

void nl_object_unmark | ( | struct nl_object * | obj | ) |

Remove mark from object.

Parameters

  obj | Object to unmark

Definition at line 262 of file object.c.

## ◆ nl_object_is_marked()

int nl_object_is_marked | ( | struct nl_object * | obj | ) |

Return true if object is marked.

Parameters

  obj | Object to check

Returns
  true if object is marked, otherwise false

Definition at line 272 of file object.c.

## ◆ nl_object_dump()

void nl_object_dump | ( | struct nl_object * | obj,
|  | struct nl_dump_params * | params
| ) |  |

Dump this object according to the specified parameters.

Parameters

  obj | object to dump
  params | dumping parameters

Definition at line 289 of file object.c.

References nl_dump_params::dp_buf, and nl_dump_params::dp_buflen.

## ◆ nl_object_identical()

int nl_object_identical | ( | struct nl_object * | a,
|  | struct nl_object * | b
| ) |  |

Check if the identifiers of two objects are identical.

Parameters

  a | an object
  b | another object of same type

Returns
  true if both objects have equal identifiers, otherwise false.

Definition at line 314 of file object.c.

Referenced by nl_hash_table_add(), nl_hash_table_del(), and nl_hash_table_lookup().

Here is the caller graph for this function:

## ◆ nl_object_diff64()

uint64_t nl_object_diff64 | ( | struct nl_object * | a,
|  | struct nl_object * | b
| ) |  |

Compute bitmask representing difference in attribute values.

Parameters

  a | an object
  b | another object of same type

The bitmask returned is specific to an object type, each bit set represents an attribute which mismatches in either of the two objects. Unavailability of an attribute in one object and presence in the other is regarded a mismatch as well.

Returns
  Bitmask describing differences or 0 if they are completely identical.

Definition at line 362 of file object.c.

Referenced by nl_object_diff().

Here is the caller graph for this function:

## ◆ nl_object_diff()

uint32_t nl_object_diff | ( | struct nl_object * | a,
|  | struct nl_object * | b
| ) |  |

Compute 32-bit bitmask representing difference in attribute values.

Parameters

  a | an object
  b | another object of same type

The bitmask returned is specific to an object type, each bit set represents an attribute which mismatches in either of the two objects. Unavailability of an attribute in one object and presence in the other is regarded a mismatch as well.

Returns
  Bitmask describing differences or 0 if they are completely identical. 32nd bit indicates if higher bits from the 64-bit compare were different.

Definition at line 386 of file object.c.

References nl_object_diff64().

Here is the call graph for this function:

## ◆ nl_object_match_filter()

int nl_object_match_filter | ( | struct nl_object * | obj,
|  | struct nl_object * | filter
| ) |  |

Match a filter against an object.

Parameters

  obj | object to check
  filter | object of same type acting as filter

Returns
  1 if the object matches the filter or 0 if no filter procedure is available or if the filter does not match.

Definition at line 406 of file object.c.

Referenced by nl_cache_dump_filter(), nl_cache_foreach_filter(), nl_cache_nitems_filter(), and nl_cache_subset().

Here is the caller graph for this function:

## ◆ nl_object_attrs2str()

char* nl_object_attrs2str | ( | struct nl_object * | obj,
|  | uint32_t | attrs,
|  | char * | buf,
|  | size_t | len
| ) |  |

Convert bitmask of attributes to a character string.

Parameters

  obj | object of same type as attribute bitmask
  attrs | bitmask of attribute types
  buf | destination buffer
  len | length of destination buffer

Converts the bitmask of attribute types into a list of attribute names separated by comas.

Returns
  destination buffer.

Definition at line 429 of file object.c.

Referenced by nl_object_attr_list().

Here is the caller graph for this function:

## ◆ nl_object_attr_list()

char* nl_object_attr_list | ( | struct nl_object * | obj,
|  | char * | buf,
|  | size_t | len
| ) |  |

Return list of attributes present in an object.

Parameters

  obj | an object
  buf | destination buffer
  len | length of destination buffer

Returns
  destination buffer.

Definition at line 450 of file object.c.

References nl_object_attrs2str().

Here is the call graph for this function:

## ◆ nl_object_keygen()

void nl_object_keygen | ( | struct nl_object * | obj,
|  | uint32_t * | hashkey,
|  | uint32_t | hashtbl_sz
| ) |  |

Generate object hash key.

Parameters

  obj | the object
  hashkey | destination buffer to be used for key stream
  hashtbl_sz | hash table size

Returns
  hash key in destination buffer

Definition at line 463 of file object.c.

Referenced by nl_hash_table_add(), nl_hash_table_del(), and nl_hash_table_lookup().

Here is the caller graph for this function:

## ◆ nl_object_get_refcnt()

int nl_object_get_refcnt | ( | struct nl_object * | obj | ) |

Return number of references held.

Parameters

  obj | object

Returns
  The number of references held to this object

Definition at line 489 of file object.c.

## ◆ nl_object_get_cache()

struct nl_cache* nl_object_get_cache | ( | struct nl_object * | obj | ) |

Return cache the object is associated with.

Parameters

  obj | object

Note
  The returned pointer is not protected with a reference counter, it is your responsibility.

Returns
  Pointer to cache or NULL if not associated with a cache.

Definition at line 503 of file object.c.

## ◆ nl_object_get_type()

const char* nl_object_get_type | ( | const struct nl_object * | obj | ) |

Return the object's type.

Parameters

  obj | object

FIXME: link to list of object types

Returns
  Name of the object type

Definition at line 516 of file object.c.

## ◆ nl_object_get_msgtype()

int nl_object_get_msgtype | ( | const struct nl_object * | obj | ) |

Return the netlink message type the object was derived from.

Parameters

  obj | object

Returns
  Netlink message type or 0.

Definition at line 530 of file object.c.

## ◆ nl_object_get_ops()

struct nl_object_ops* nl_object_get_ops | ( | const struct nl_object * | obj | ) |

Return object operations structure.

Parameters

  obj | object

Returns
  Pointer to the object operations structure

Definition at line 541 of file object.c.

## ◆ nl_object_get_id_attrs()

uint32_t nl_object_get_id_attrs | ( | struct nl_object * | obj | ) |

Return object id attribute mask.

Parameters

  obj | object

Returns
  object id attribute mask

Definition at line 552 of file object.c.

Referenced by nl_cache_find().

Here is the caller graph for this function: