18 #include <netlink-local.h>
19 #include <netlink/netlink.h>
20 #include <netlink/cache.h>
21 #include <netlink/object.h>
22 #include <netlink/utils.h>
24 static inline struct nl_object_ops *obj_ops(
struct nl_object *obj)
44 struct nl_object *
new;
46 if (ops->
oo_size <
sizeof(*
new))
56 nl_init_list_head(&new->ce_list);
62 NL_DBG(4,
"Allocated new object %p\n",
new);
78 nl_error(ENOENT,
"Unable to lookup cache kind \"%s\"", kind);
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);
137 if (obj->ce_refcnt > 0)
138 NL_DBG(1,
"Warning: Freeing object in use...\n");
148 NL_DBG(4,
"Freed object %p\n", obj);
165 NL_DBG(4,
"New reference to object %p, total %d\n",
166 obj, obj->ce_refcnt);
179 NL_DBG(4,
"Returned object reference %p, %d remaining\n",
180 obj, obj->ce_refcnt);
182 if (obj->ce_refcnt < 0)
185 if (obj->ce_refcnt <= 0)
196 return obj->ce_refcnt > 1;
212 obj->ce_flags |= NL_OBJ_MARK;
221 obj->ce_flags &= ~NL_OBJ_MARK;
231 return (obj->ce_flags & NL_OBJ_MARK);
248 dump_from_ops(obj, params);
264 if (ops != obj_ops(b))
267 req_attrs = ops->oo_id_attrs;
271 if ((a->ce_mask & req_attrs) != req_attrs ||
272 (b->ce_mask & req_attrs) != req_attrs)
279 return !(ops->
oo_compare(a, b, req_attrs, 0));
298 if (ops != obj_ops(b) || ops->
oo_compare == NULL)
317 if (ops != obj_ops(filter) || ops->
oo_compare == NULL)
320 return !(ops->
oo_compare(obj, filter, filter->ce_mask,
321 LOOSE_FLAG_COMPARISON));
337 char *buf,
size_t len)
341 if (ops->oo_attrs2str != NULL)
342 return ops->oo_attrs2str(attrs, buf, len);
369 int nl_object_get_refcnt(
struct nl_object *obj)
371 return obj->ce_refcnt;
374 struct nl_cache *nl_object_get_cache(
struct nl_object *obj)
376 return obj->ce_cache;
379 void *nl_object_priv(
struct nl_object *obj)