libnl: Object (Cacheable)

libnl 3.10.0

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

## 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.
int | nl_object_alloc_name (const char *kind, struct nl_object **result)
| Allocate new object of kind specified by the name.
struct nl_object * | nl_object_clone (struct nl_object *obj)
| Allocate a new object and copy all data from an existing object.
int | nl_object_update (struct nl_object *dst, struct nl_object *src)
| Merge a cacheable object.
void | nl_object_free (struct nl_object *obj)
| Free a cacheable object.

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

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

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

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

## 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(), nl_object_clone(), 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.

References nl_object_alloc(), and nl_object_free().

Referenced by nl_cache_add().

Here is the call graph for this function:
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 160 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 176 of file object.c.

References nl_cache_remove().

Referenced by nl_object_clone(), and nl_object_put().

Here is the call graph for this function:
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 210 of file object.c.

Referenced by genl_ctrl_search(), genl_ctrl_search_by_name(), nl_cache_add(), nl_cache_find(), nl_cache_foreach_filter(), nl_cache_move(), nl_cache_search(), nl_hash_table_add(), rtnl_addr_get(), rtnl_class_get(), rtnl_class_get_by_parent(), rtnl_cls_find_by_handle(), rtnl_cls_find_by_prio(), rtnl_link_get(), rtnl_link_get_by_name(), rtnl_link_veth_get_peer(), rtnl_neigh_get(), rtnl_neigh_get_by_vlan(), rtnl_neightbl_get(), rtnl_netconf_get_by_idx(), rtnl_qdisc_get(), rtnl_qdisc_get_by_kind(), rtnl_qdisc_get_by_parent(), 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 221 of file object.c.

References nl_object_free().

Referenced by genl_family_put(), nl_cache_add(), 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 242 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 258 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 267 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 277 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 294 of file object.c.

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

## ◆ nl_object_dump_buf()

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

Definition at line 302 of file object.c.

## ◆ 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 319 of file object.c.

Referenced by nl_cache_search(), 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 371 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 395 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 415 of file object.c.

Referenced by nl_cache_dump_filter(), nl_cache_find(), 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 438 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 459 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 472 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 498 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 512 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 525 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 539 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 550 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 561 of file object.c.

Referenced by nl_cache_find().

Here is the caller graph for this function: