|
|
int | nl_object_get_refcnt (struct nl_object *obj) |
| |
|
struct nl_cache * | nl_object_get_cache (struct nl_object *obj) |
| |
◆ nl_object_alloc()
◆ nl_object_alloc_name()
| struct nl_object* nl_object_alloc_name |
( |
const char * |
kind | ) |
|
◆ nl_object_clone()
| struct nl_object* nl_object_clone |
( |
struct nl_object * |
obj | ) |
|
- Parameters
-
| obj | object to inherite data from |
- Returns
- The new object or NULL.
Definition at line 95 of file object.c.
97 struct nl_object *
new;
110 new->ce_ops = obj->ce_ops;
111 new->ce_msgtype = obj->ce_msgtype;
114 memcpy((
void *)
new + doff, (
void *)obj + doff, size);
Referenced by nl_cache_add().
◆ nl_object_free()
| void nl_object_free |
( |
struct nl_object * |
obj | ) |
|
- Parameters
-
- Returns
- 0 or a negative error code.
Definition at line 133 of file object.c.
142 if (obj->ce_refcnt > 0)
143 NL_DBG(1,
"Warning: Freeing object in use...\n");
153 NL_DBG(4,
"Freed object %p\n", obj);
Referenced by nl_object_put().
◆ nl_object_get()
| void nl_object_get |
( |
struct nl_object * |
obj | ) |
|
- Parameters
-
| obj | object to acquire reference from |
Definition at line 167 of file object.c.
170 NL_DBG(4,
"New reference to object %p, total %d\n",
171 obj, obj->ce_refcnt);
Referenced by genl_ctrl_search(), genl_ctrl_search_by_name(), nl_cache_add(), nl_cache_move(), nl_cache_search(), rtnl_neigh_get(), rtnl_qdisc_get(), and rtnl_qdisc_get_by_parent().
◆ nl_object_put()
| void nl_object_put |
( |
struct nl_object * |
obj | ) |
|
- Parameters
-
| obj | object to release reference from |
Definition at line 178 of file object.c.
184 NL_DBG(4,
"Returned object reference %p, %d remaining\n",
185 obj, obj->ce_refcnt);
187 if (obj->ce_refcnt < 0)
190 if (obj->ce_refcnt <= 0)
References nl_object_free().
Referenced by nl_cache_remove().
◆ nl_object_shared()
| int nl_object_shared |
( |
struct nl_object * |
obj | ) |
|
- Parameters
-
- Returns
- true or false
Definition at line 199 of file object.c.
201 return obj->ce_refcnt > 1;
◆ nl_object_mark()
| void nl_object_mark |
( |
struct nl_object * |
obj | ) |
|
◆ nl_object_unmark()
| void nl_object_unmark |
( |
struct nl_object * |
obj | ) |
|
- Parameters
-
Definition at line 224 of file object.c.
226 obj->ce_flags &= ~NL_OBJ_MARK;
◆ nl_object_is_marked()
| int nl_object_is_marked |
( |
struct nl_object * |
obj | ) |
|
- Parameters
-
- Returns
- true if object is marked, otherwise false
Definition at line 234 of file object.c.
236 return (obj->ce_flags & NL_OBJ_MARK);
◆ nl_object_dump()
| void nl_object_dump |
( |
struct nl_object * |
obj, |
|
|
struct nl_dump_params * |
params |
|
) |
| |
- Parameters
-
| obj | object to dump |
| params | dumping parameters |
Definition at line 251 of file object.c.
253 dump_from_ops(obj, params);
◆ nl_object_identical()
| int nl_object_identical |
( |
struct nl_object * |
a, |
|
|
struct nl_object * |
b |
|
) |
| |
- Parameters
-
| a | an object |
| b | another object of same type |
- Returns
- true if both objects have equal identifiers, otherwise false.
Definition at line 263 of file object.c.
269 if (ops != obj_ops(b))
272 req_attrs = ops->oo_id_attrs;
276 if ((a->ce_mask & req_attrs) != req_attrs ||
277 (b->ce_mask & req_attrs) != req_attrs)
284 return !(ops->
oo_compare(a, b, req_attrs, 0));
Referenced by nl_cache_search().
◆ nl_object_diff()
| uint32_t nl_object_diff |
( |
struct nl_object * |
a, |
|
|
struct nl_object * |
b |
|
) |
| |
- 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 299 of file object.c.
303 if (ops != obj_ops(b) || ops->
oo_compare == NULL)
◆ nl_object_match_filter()
| int nl_object_match_filter |
( |
struct nl_object * |
obj, |
|
|
struct nl_object * |
filter |
|
) |
| |
◆ nl_object_attrs2str()
| char* nl_object_attrs2str |
( |
struct nl_object * |
obj, |
|
|
uint32_t |
attrs, |
|
|
char * |
buf, |
|
|
size_t |
len |
|
) |
| |
- 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 341 of file object.c.
346 if (ops->oo_attrs2str != NULL)
347 return ops->oo_attrs2str(attrs, buf, len);
Referenced by nl_object_attr_list().
◆ nl_object_attr_list()
| char* nl_object_attr_list |
( |
struct nl_object * |
obj, |
|
|
char * |
buf, |
|
|
size_t |
len |
|
) |
| |
- Parameters
-
| obj | an object |
| buf | destination buffer |
| len | length of destination buffer |
- Returns
- destination buffer.
Definition at line 362 of file object.c.
References nl_object_attrs2str().
void nl_cache_remove(struct nl_object *obj)
Removes an object from a cache.
struct nl_cache_ops * nl_cache_ops_lookup(const char *name)
Lookup cache operations by name.
void nl_object_free(struct nl_object *obj)
Free a cacheable object.
size_t oo_size
Size of object including its header.
struct nl_object * nl_object_alloc(struct nl_object_ops *ops)
Allocate a new object of kind specified by the operations handle.
void(* oo_free_data)(struct nl_object *)
Destructor function.
int(* oo_clone)(struct nl_object *, struct nl_object *)
Cloning function.
void(* oo_constructor)(struct nl_object *)
Constructor function.
int(* oo_compare)(struct nl_object *, struct nl_object *, uint32_t, int)
Comparison 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.