libnl  3.2.20
nl_object_ops Struct Reference

Object Operations. More...

#include <object-api.h>

Data Fields

char * oo_name
 Unique name of object type.
size_t oo_size
 Size of object including its header.
uint32_t oo_id_attrs
void(* oo_constructor )(struct nl_object *)
 Constructor function.
void(* oo_free_data )(struct nl_object *)
 Destructor function.
int(* oo_clone )(struct nl_object *, struct nl_object *)
 Cloning function.
void(* oo_dump [NL_DUMP_MAX+1])(struct nl_object *, struct nl_dump_params *)
 Dumping functions.
int(* oo_compare )(struct nl_object *, struct nl_object *, uint32_t, int)
 Comparison function.
int(* oo_update )(struct nl_object *, struct nl_object *)
 update function
void(* oo_keygen )(struct nl_object *, uint32_t *, uint32_t)
 Hash Key generator function.
char *(* oo_attrs2str )(int, char *, size_t)
uint32_t(* oo_id_attrs_get )(struct nl_object *)
 Get key attributes by family function.

Detailed Description

Object Operations.

Definition at line 268 of file object-api.h.


Field Documentation

char* nl_object_ops::oo_name

Unique name of object type.

Must be in the form family/name, e.g. "route/addr"

Definition at line 275 of file object-api.h.

void(* nl_object_ops::oo_constructor)(struct nl_object *)

Constructor function.

Will be called when a new object of this type is allocated. Can be used to initialize members such as lists etc.

Definition at line 289 of file object-api.h.

Referenced by nl_object_alloc().

void(* nl_object_ops::oo_free_data)(struct nl_object *)

Destructor function.

Will be called when an object is freed. Must free all resources which may have been allocated as part of this object.

Definition at line 298 of file object-api.h.

Referenced by nl_object_clone(), and nl_object_free().

int(* nl_object_ops::oo_clone)(struct nl_object *, struct nl_object *)

Cloning function.

Will be called when an object needs to be cloned. Please note that the generic object code will make an exact copy of the object first, therefore you only need to take care of members which require reference counting etc.

May return a negative error code to abort cloning.

Definition at line 310 of file object-api.h.

Referenced by nl_object_clone().

void(* nl_object_ops::oo_dump[NL_DUMP_MAX+1])(struct nl_object *, struct nl_dump_params *)

Dumping functions.

Will be called when an object is dumped. The implementations have to use nl_dump(), nl_dump_line(), and nl_new_line() to dump objects.

The functions must return the number of lines printed.

Definition at line 321 of file object-api.h.

Referenced by nl_cache_dump_filter().

int(* nl_object_ops::oo_compare)(struct nl_object *, struct nl_object *, uint32_t, int)

Comparison function.

Will be called when two objects of the same type are compared. It takes the two objects in question, an object specific bitmask defining which attributes should be compared and flags to control the behaviour.

The function must return a bitmask with the relevant bit set for each attribute that mismatches.

Definition at line 335 of file object-api.h.

Referenced by nl_object_diff(), nl_object_identical(), and nl_object_match_filter().

int(* nl_object_ops::oo_update)(struct nl_object *, struct nl_object *)

update function

Will be called when the object given by first argument needs to be updated with the contents of the second object

The function must return 0 for success and error for failure to update. In case of failure its assumed that the original object is not touched

Definition at line 349 of file object-api.h.

Referenced by nl_object_update().

void(* nl_object_ops::oo_keygen)(struct nl_object *, uint32_t *, uint32_t)

Hash Key generator function.

When called returns a hash key for the object being referenced. This key will be used by higher level hash functions to build association lists. Each object type gets to specify it's own key formulation

Definition at line 359 of file object-api.h.

Referenced by nl_cache_alloc(), and nl_object_keygen().