libnl 3.7.0
Object (Cacheable)

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
opscache operations handle
Returns
The new object or NULL

Definition at line 48 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
kindname of object type
resultResult pointer
Returns
0 on success or a negative error code.

Definition at line 78 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
objobject to inherite data from
Returns
The new object or NULL.

Definition at line 104 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
dstobject to be merged into
srcnew object to be merged into dst
Returns
0 or a negative error code.

Definition at line 153 of file object.c.

◆ nl_object_free()

void nl_object_free ( struct nl_object *  obj)

Free a cacheable object.

Parameters
objobject to free
Returns
0 or a negative error code.

Definition at line 169 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()

◆ nl_object_put()

void nl_object_put ( struct nl_object *  obj)

Release a reference from an object.

Parameters
objobject to release reference from

Definition at line 214 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
objobject to check
Returns
true or false

Definition at line 235 of file object.c.

◆ nl_object_mark()

void nl_object_mark ( struct nl_object *  obj)

Add mark to object.

Parameters
objObject to mark

Definition at line 251 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
objObject to unmark

Definition at line 260 of file object.c.

◆ nl_object_is_marked()

int nl_object_is_marked ( struct nl_object *  obj)

Return true if object is marked.

Parameters
objObject to check
Returns
true if object is marked, otherwise false

Definition at line 270 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
objobject to dump
paramsdumping parameters

Definition at line 287 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 295 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
aan object
banother object of same type
Returns
true if both objects have equal identifiers, otherwise false.

Definition at line 312 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
aan object
banother 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 364 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
aan object
banother 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 388 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
objobject to check
filterobject 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 408 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
objobject of same type as attribute bitmask
attrsbitmask of attribute types
bufdestination buffer
lenlength of destination buffer

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

Returns
destination buffer.

Definition at line 431 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
objan object
bufdestination buffer
lenlength of destination buffer
Returns
destination buffer.

Definition at line 452 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
objthe object
hashkeydestination buffer to be used for key stream
hashtbl_szhash table size
Returns
hash key in destination buffer

Definition at line 465 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
objobject
Returns
The number of references held to this object

Definition at line 491 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
objobject
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 505 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
objobject

FIXME: link to list of object types

Returns
Name of the object type

Definition at line 518 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
objobject
Returns
Netlink message type or 0.

Definition at line 532 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
objobject
Returns
Pointer to the object operations structure

Definition at line 543 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
objobject
Returns
object id attribute mask

Definition at line 554 of file object.c.

Referenced by nl_cache_find().

+ Here is the caller graph for this function: