12 #ifndef NETLINK_CACHE_H_ 13 #define NETLINK_CACHE_H_ 15 #include <netlink/netlink.h> 16 #include <netlink/msg.h> 17 #include <netlink/utils.h> 18 #include <netlink/object.h> 34 #define NL_ACT_MAX (__NL_ACT_MAX - 1) 37 typedef void (*change_func_t)(
struct nl_cache *,
struct nl_object *, int,
void *);
38 typedef void (*change_func_v2_t)(
struct nl_cache *,
struct nl_object *old_obj,
39 struct nl_object *new_obj, uint64_t, int,
void *);
45 #define NL_CACHE_AF_ITER 0x0001 69 extern void nl_cache_put(
struct nl_cache *cache);
85 extern int nl_cache_resync(
struct nl_sock *,
89 extern int nl_cache_include(
struct nl_cache *,
93 extern int nl_cache_include_v2(
struct nl_cache *,
118 void (*cb)(
struct nl_object *,
145 extern struct nl_cache * __nl_cache_mngt_require(
const char *);
147 struct nl_cache_mngr;
149 #define NL_AUTO_PROVIDE 1 150 #define NL_ALLOCATED_SOCK 2 154 struct nl_cache_mngr **);
161 struct nl_cache *cache,
162 change_func_t cb,
void *data);
164 struct nl_cache *cache,
165 change_func_v2_t cb,
void *data);
void nl_cache_mngt_provide(struct nl_cache *)
Provide a cache for global use.
void nl_cache_ops_put(struct nl_cache_ops *)
Decrement reference counter.
struct nl_object * nl_cache_get_prev(struct nl_object *)
Return the previous element in the cache.
int nl_cache_alloc_name(const char *, struct nl_cache **)
Allocate new cache based on type name.
struct nl_cache * nl_cache_subset(struct nl_cache *, struct nl_object *)
Allocate new cache containing a subset of an existing cache.
void nl_cache_ops_get(struct nl_cache_ops *)
Increment reference counter.
int nl_cache_mngr_alloc(struct nl_sock *, int, int, struct nl_cache_mngr **)
Allocate new cache manager.
int nl_cache_mngr_get_fd(struct nl_cache_mngr *)
Get socket file descriptor.
int nl_cache_mngt_unregister(struct nl_cache_ops *)
Unregister a set of cache operations.
struct nl_cache * nl_cache_mngt_require_safe(const char *)
Return cache previously provided via nl_cache_mngt_provide()
void nl_cache_get(struct nl_cache *)
Increase reference counter of cache.
struct nl_object * nl_cache_find(struct nl_cache *, struct nl_object *)
Find object in cache.
void nl_cache_dump_filter(struct nl_cache *, struct nl_dump_params *, struct nl_object *)
Dump all elements of a cache (filtered).
void nl_cache_mngr_info(struct nl_cache_mngr *, struct nl_dump_params *)
Print information about cache manager.
void nl_cache_foreach_filter(struct nl_cache *, struct nl_object *, void(*cb)(struct nl_object *, void *), void *arg)
Call a callback on each element of the cache (filtered).
struct nl_object * nl_cache_get_last(struct nl_cache *)
Return the last element in the cache.
int nl_cache_mngr_poll(struct nl_cache_mngr *, int)
Check for event notifications.
struct nl_cache_ops * nl_cache_ops_lookup(const char *)
Lookup cache operations by name.
int nl_cache_pickup_checkdup(struct nl_sock *, struct nl_cache *)
Pickup a netlink dump response and put it into a cache.
void nl_cache_free(struct nl_cache *)
Free a cache.
void nl_cache_set_arg1(struct nl_cache *, int)
Set synchronization arg1 of cache.
int nl_cache_mngt_register(struct nl_cache_ops *)
Register a set of cache operations.
struct nl_object * nl_cache_search(struct nl_cache *, struct nl_object *)
Search object in cache.
int nl_cache_mngr_add_cache_v2(struct nl_cache_mngr *mngr, struct nl_cache *cache, change_func_v2_t cb, void *data)
Add cache to cache manager.
void nl_cache_foreach(struct nl_cache *, void(*cb)(struct nl_object *, void *), void *arg)
Call a callback on each element of the cache.
void nl_cache_remove(struct nl_object *)
Remove object from cache.
struct nl_cache * nl_cache_mngt_require(const char *)
Return cache previously provided via nl_cache_mngt_provide()
int nl_cache_is_empty(struct nl_cache *)
Returns true if the cache is empty.
void nl_cache_clear(struct nl_cache *)
Remove all objects of a cache.
struct nl_cache_ops * nl_cache_ops_lookup_safe(const char *)
Lookup cache operations by name.
void nl_cache_set_arg2(struct nl_cache *, int)
Set synchronization arg2 of cache.
void nl_cache_dump(struct nl_cache *, struct nl_dump_params *)
Dump all elements of a cache.
void nl_cache_mngt_unprovide(struct nl_cache *)
Unprovide a cache for global use.
int nl_cache_parse_and_add(struct nl_cache *, struct nl_msg *)
Parse a netlink message and add it to the cache.
int nl_cache_nitems(struct nl_cache *)
Return the number of items in the cache.
void nl_cache_ops_set_flags(struct nl_cache_ops *, unsigned int)
Set default flags for caches of this type.
int nl_cache_mngr_add_cache(struct nl_cache_mngr *mngr, struct nl_cache *cache, change_func_t cb, void *data)
Add cache to cache manager.
struct nl_object * nl_cache_get_next(struct nl_object *)
Return the next element in the cache.
int nl_cache_refill(struct nl_sock *, struct nl_cache *)
(Re)fill a cache with the contents in the kernel.
void nl_cache_ops_foreach(void(*cb)(struct nl_cache_ops *, void *), void *)
Call a function for each registered cache operation.
void nl_cache_mark_all(struct nl_cache *)
Mark all objects of a cache.
int nl_cache_move(struct nl_cache *, struct nl_object *)
Move object from one cache to another.
int nl_cache_mngr_data_ready(struct nl_cache_mngr *)
Receive available event notifications.
int nl_cache_nitems_filter(struct nl_cache *, struct nl_object *)
Return the number of items matching a filter in the cache.
struct nl_cache_ops * nl_cache_ops_associate(int, int)
Associate protocol and message type to cache operations.
void nl_cache_mngr_free(struct nl_cache_mngr *)
Free cache manager and all caches.
void nl_cache_set_flags(struct nl_cache *, unsigned int)
Set cache flags.
struct nl_cache_ops * nl_cache_get_ops(struct nl_cache *)
Return the operations set of the cache.
int nl_cache_mngr_add(struct nl_cache_mngr *, const char *, change_func_t, void *, struct nl_cache **)
Add cache to cache manager.
struct nl_cache * nl_cache_clone(struct nl_cache *)
Allocate new cache and copy the contents of an existing cache.
int nl_cache_add(struct nl_cache *, struct nl_object *)
Add object to cache.
struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int)
Lookup message type cache association.
struct nl_cache_ops * nl_cache_ops_associate_safe(int, int)
Associate protocol and message type to cache operations.
struct nl_object * nl_cache_get_first(struct nl_cache *)
Return the first element in the cache.
int nl_cache_alloc_and_fill(struct nl_cache_ops *, struct nl_sock *, struct nl_cache **)
Allocate new cache and fill it.
struct nl_cache * nl_cache_alloc(struct nl_cache_ops *)
Allocate new cache.
int nl_cache_pickup(struct nl_sock *, struct nl_cache *)
Pickup a netlink dump response and put it into a cache.