libnl-tiny: Fix for c++ compatibility
[openwrt.git] / package / libnl-tiny / src / include / netlink / object.h
1 /*
2 * netlink/object.c Generic Cacheable Object
3 *
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
7 * of the License.
8 *
9 * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
10 */
11
12 #ifndef NETLINK_OBJECT_H_
13 #define NETLINK_OBJECT_H_
14
15 #include <netlink/netlink.h>
16 #include <netlink/utils.h>
17 #include <netlink/object-api.h>
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 #define NL_OBJ_MARK 1
24
25 struct nl_cache;
26 struct nl_object;
27 struct nl_object_ops;
28
29 struct nl_object
30 {
31 NLHDR_COMMON
32 };
33
34 #define OBJ_CAST(ptr) ((struct nl_object *) (ptr))
35
36 /* General */
37 extern struct nl_object * nl_object_alloc(struct nl_object_ops *);
38 extern int nl_object_alloc_name(const char *,
39 struct nl_object **);
40 extern void nl_object_free(struct nl_object *);
41 extern struct nl_object * nl_object_clone(struct nl_object *obj);
42 extern void nl_object_get(struct nl_object *);
43 extern void nl_object_put(struct nl_object *);
44 extern void nl_object_dump(struct nl_object *,
45 struct nl_dump_params *);
46 extern int nl_object_identical(struct nl_object *,
47 struct nl_object *);
48 extern uint32_t nl_object_diff(struct nl_object *,
49 struct nl_object *);
50 extern int nl_object_match_filter(struct nl_object *,
51 struct nl_object *);
52 extern char * nl_object_attrs2str(struct nl_object *,
53 uint32_t attrs, char *buf,
54 size_t);
55 /**
56 * Check whether this object is used by multiple users
57 * @arg obj object to check
58 * @return true or false
59 */
60 static inline int nl_object_shared(struct nl_object *obj)
61 {
62 return obj->ce_refcnt > 1;
63 }
64
65
66
67 /**
68 * @name Marks
69 * @{
70 */
71
72 /**
73 * Add mark to object
74 * @arg obj Object to mark
75 */
76 static inline void nl_object_mark(struct nl_object *obj)
77 {
78 obj->ce_flags |= NL_OBJ_MARK;
79 }
80
81 /**
82 * Remove mark from object
83 * @arg obj Object to unmark
84 */
85 static inline void nl_object_unmark(struct nl_object *obj)
86 {
87 obj->ce_flags &= ~NL_OBJ_MARK;
88 }
89
90 /**
91 * Return true if object is marked
92 * @arg obj Object to check
93 * @return true if object is marked, otherwise false
94 */
95 static inline int nl_object_is_marked(struct nl_object *obj)
96 {
97 return (obj->ce_flags & NL_OBJ_MARK);
98 }
99
100 /** @} */
101
102 /**
103 * Return list of attributes present in an object
104 * @arg obj an object
105 * @arg buf destination buffer
106 * @arg len length of destination buffer
107 *
108 * @return destination buffer.
109 */
110 static inline char *nl_object_attr_list(struct nl_object *obj, char *buf, size_t len)
111 {
112 return nl_object_attrs2str(obj, obj->ce_mask, buf, len);
113 }
114
115
116 /**
117 * @name Attributes
118 * @{
119 */
120
121 static inline int nl_object_get_refcnt(struct nl_object *obj)
122 {
123 return obj->ce_refcnt;
124 }
125
126 static inline struct nl_cache *nl_object_get_cache(struct nl_object *obj)
127 {
128 return obj->ce_cache;
129 }
130
131 static inline void * nl_object_priv(struct nl_object *obj)
132 {
133 return obj;
134 }
135
136
137 /** @} */
138
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif
This page took 0.048913 seconds and 5 git commands to generate.