2 * netlink/object.c Generic Cacheable Object
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
12 #ifndef NETLINK_OBJECT_H_
13 #define NETLINK_OBJECT_H_
15 #include <netlink/netlink.h>
16 #include <netlink/utils.h>
17 #include <netlink/object-api.h>
34 #define OBJ_CAST(ptr) ((struct nl_object *) (ptr))
37 extern struct nl_object
* nl_object_alloc(struct nl_object_ops
*);
38 extern void nl_object_free(struct nl_object
*);
39 extern struct nl_object
* nl_object_clone(struct nl_object
*obj
);
43 extern int nl_object_alloc_name(const char *,
45 extern void nl_object_dump(struct nl_object
*,
46 struct nl_dump_params
*);
48 extern uint32_t nl_object_diff(struct nl_object
*,
50 extern int nl_object_match_filter(struct nl_object
*,
52 extern int nl_object_identical(struct nl_object
*,
54 extern char * nl_object_attrs2str(struct nl_object
*,
55 uint32_t attrs
, char *buf
,
59 * Check whether this object is used by multiple users
60 * @arg obj object to check
61 * @return true or false
63 static inline int nl_object_shared(struct nl_object
*obj
)
65 return obj
->ce_refcnt
> 1;
69 static inline void nl_object_get(struct nl_object
*obj
)
74 static inline void nl_object_put(struct nl_object
*obj
)
81 if (obj
->ce_refcnt
<= 0)
93 * @arg obj Object to mark
95 static inline void nl_object_mark(struct nl_object
*obj
)
97 obj
->ce_flags
|= NL_OBJ_MARK
;
101 * Remove mark from object
102 * @arg obj Object to unmark
104 static inline void nl_object_unmark(struct nl_object
*obj
)
106 obj
->ce_flags
&= ~NL_OBJ_MARK
;
110 * Return true if object is marked
111 * @arg obj Object to check
112 * @return true if object is marked, otherwise false
114 static inline int nl_object_is_marked(struct nl_object
*obj
)
116 return (obj
->ce_flags
& NL_OBJ_MARK
);
123 * Return list of attributes present in an object
125 * @arg buf destination buffer
126 * @arg len length of destination buffer
128 * @return destination buffer.
130 static inline char *nl_object_attr_list(struct nl_object
*obj
, char *buf
, size_t len
)
132 return nl_object_attrs2str(obj
, obj
->ce_mask
, buf
, len
);
141 static inline int nl_object_get_refcnt(struct nl_object
*obj
)
143 return obj
->ce_refcnt
;
146 static inline struct nl_cache
*nl_object_get_cache(struct nl_object
*obj
)
148 return obj
->ce_cache
;
151 static inline void * nl_object_priv(struct nl_object
*obj
)
This page took 0.049351 seconds and 5 git commands to generate.