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 int nl_object_alloc_name(const char *,
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
*,
48 extern uint32_t nl_object_diff(struct nl_object
*,
50 extern int nl_object_match_filter(struct nl_object
*,
52 extern char * nl_object_attrs2str(struct nl_object
*,
53 uint32_t attrs
, char *buf
,
56 * Check whether this object is used by multiple users
57 * @arg obj object to check
58 * @return true or false
60 static inline int nl_object_shared(struct nl_object
*obj
)
62 return obj
->ce_refcnt
> 1;
74 * @arg obj Object to mark
76 static inline void nl_object_mark(struct nl_object
*obj
)
78 obj
->ce_flags
|= NL_OBJ_MARK
;
82 * Remove mark from object
83 * @arg obj Object to unmark
85 static inline void nl_object_unmark(struct nl_object
*obj
)
87 obj
->ce_flags
&= ~NL_OBJ_MARK
;
91 * Return true if object is marked
92 * @arg obj Object to check
93 * @return true if object is marked, otherwise false
95 static inline int nl_object_is_marked(struct nl_object
*obj
)
97 return (obj
->ce_flags
& NL_OBJ_MARK
);
103 * Return list of attributes present in an object
105 * @arg buf destination buffer
106 * @arg len length of destination buffer
108 * @return destination buffer.
110 static inline char *nl_object_attr_list(struct nl_object
*obj
, char *buf
, size_t len
)
112 return nl_object_attrs2str(obj
, obj
->ce_mask
, buf
, len
);
121 static inline int nl_object_get_refcnt(struct nl_object
*obj
)
123 return obj
->ce_refcnt
;
126 static inline struct nl_cache
*nl_object_get_cache(struct nl_object
*obj
)
128 return obj
->ce_cache
;
131 static inline void * nl_object_priv(struct nl_object
*obj
)
This page took 0.051928 seconds and 5 git commands to generate.