libnl  3.2.13
Object (Cacheable)

Generic object data type, for inheritance purposes to implement cacheable data types. 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>

Modules

 Object API

Data Structures

struct  nl_derived_object

Object Creation/Deletion

struct nl_objectnl_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_objectnl_object_clone (struct nl_object *obj)
 Allocate a new object and copy all data from an existing 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.
uint32_t nl_object_diff (struct nl_object *a, struct nl_object *b)
 Compute 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.

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_opsnl_object_get_ops (const struct nl_object *obj)
 Return object operations structure.

Function Documentation

struct nl_object* nl_object_alloc ( struct nl_object_ops ops)
read

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

Parameters:
opscache operations handle
Returns:
The new object or NULL

Definition at line 54 of file object.c.

References nl_object_ops::oo_constructor, and nl_object_ops::oo_size.

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

+ Here is the caller graph for this function:

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 84 of file object.c.

References nl_cache_ops::co_obj_ops, nl_cache_ops_lookup(), and nl_object_alloc().

+ Here is the call graph for this function:

struct nl_object* nl_object_clone ( struct nl_object obj)
read

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 108 of file object.c.

References nl_object_alloc(), nl_object_free(), nl_object_ops::oo_clone, nl_object_ops::oo_free_data, and nl_object_ops::oo_size.

Referenced by nl_cache_add().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 147 of file object.c.

References nl_cache_remove(), and nl_object_ops::oo_free_data.

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:

void nl_object_get ( struct nl_object obj)

Acquire a reference on a object.

Parameters:
objobject to acquire reference from

Definition at line 176 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_cache_search(), rtnl_addr_get(), rtnl_class_get(), rtnl_link_get(), rtnl_link_get_by_name(), rtnl_neigh_get(), rtnl_neightbl_get(), rtnl_qdisc_get(), rtnl_qdisc_get_by_parent(), rtnl_tc_get_link(), and rtnl_tc_set_link().

+ Here is the caller graph for this function:

void nl_object_put ( struct nl_object obj)

Release a reference from an object.

Parameters:
objobject to release reference from

Definition at line 187 of file object.c.

References nl_object_free().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 208 of file object.c.

void nl_object_mark ( struct nl_object obj)

Add mark to object.

Parameters:
objObject to mark

Definition at line 224 of file object.c.

Referenced by nl_cache_mark_all().

+ Here is the caller graph for this function:

void nl_object_unmark ( struct nl_object obj)

Remove mark from object.

Parameters:
objObject to unmark

Definition at line 233 of file object.c.

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 243 of file object.c.

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 260 of file object.c.

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

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 285 of file object.c.

References nl_object_ops::oo_compare.

Referenced by nl_cache_search().

+ Here is the caller graph for this function:

uint32_t nl_object_diff ( 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 323 of file object.c.

References nl_object_ops::oo_compare.

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 342 of file object.c.

References nl_object_ops::oo_compare.

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:

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 365 of file object.c.

Referenced by nl_object_attr_list().

+ Here is the caller graph for this function:

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 386 of file object.c.

References nl_object_attrs2str().

+ Here is the call graph for this function:

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 404 of file object.c.

struct nl_cache* nl_object_get_cache ( struct nl_object obj)
read

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 418 of file object.c.

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 431 of file object.c.

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 445 of file object.c.

struct nl_object_ops* nl_object_get_ops ( const struct nl_object obj)
read

Return object operations structure.

Parameters:
objobject
Returns:
Pointer to the object operations structure

Definition at line 456 of file object.c.