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>
46 if (ops->
oo_size <
sizeof(*
new))
54 nl_init_list_head(&new->ce_list);
60 NL_DBG(4,
"Allocated new object %p\n",
new);
78 return -NLE_OPNOTSUPP;
111 new->ce_ops = obj->ce_ops;
112 new->ce_msgtype = obj->ce_msgtype;
113 new->ce_mask = obj->ce_mask;
116 memcpy((
void *)
new + doff, (
void *)obj + doff, size);
139 if (obj->ce_refcnt > 0)
140 NL_DBG(1,
"Warning: Freeing object in use...\n");
150 NL_DBG(4,
"Freed object %p\n", obj);
167 NL_DBG(4,
"New reference to object %p, total %d\n",
168 obj, obj->ce_refcnt);
181 NL_DBG(4,
"Returned object reference %p, %d remaining\n",
182 obj, obj->ce_refcnt);
184 if (obj->ce_refcnt < 0)
187 if (obj->ce_refcnt <= 0)
198 return obj->ce_refcnt > 1;
214 obj->ce_flags |= NL_OBJ_MARK;
223 obj->ce_flags &= ~NL_OBJ_MARK;
233 return (obj->ce_flags & NL_OBJ_MARK);
250 dump_from_ops(obj, params);
253 void nl_object_dump_buf(
struct nl_object *obj,
char *buf,
size_t len)
276 if (ops != obj_ops(b))
279 req_attrs = ops->oo_id_attrs;
281 req_attrs = a->ce_mask & b->ce_mask;
285 if ((a->ce_mask & req_attrs) != req_attrs ||
286 (b->ce_mask & req_attrs) != req_attrs)
293 return !(ops->
oo_compare(a, b, req_attrs, 0));
312 if (ops != obj_ops(b) || ops->
oo_compare == NULL)
331 if (ops != obj_ops(filter) || ops->
oo_compare == NULL)
334 return !(ops->
oo_compare(obj, filter, filter->ce_mask,
351 char *buf,
size_t len)
355 if (ops->oo_attrs2str != NULL)
356 return ops->oo_attrs2str(attrs, buf, len);
383 int nl_object_get_refcnt(
struct nl_object *obj)
385 return obj->ce_refcnt;
388 struct nl_cache *nl_object_get_cache(
struct nl_object *obj)
390 return obj->ce_cache;