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>
19 #include <netlink/cache-api.h>
27 typedef void (*change_func_t)(
struct nl_cache *,
struct nl_object *, int);
40 #define nl_cache_alloc_from_ops(ptr) nl_cache_alloc(ptr)
54 #define nl_cache_delete(a, b) nl_cache_remove(b)
56 #define nl_cache_update(a, b) nl_cache_refill(a, b)
61 extern int nl_cache_resync(
struct nl_handle *,
64 extern int nl_cache_include(
struct nl_cache *,
81 void (*cb)(
struct nl_object *,
108 struct nl_cache_mngr;
110 #define NL_AUTO_PROVIDE 1
Message type to cache action association.
void nl_cache_mngt_provide(struct nl_cache *cache)
Provide a cache for global use.
struct nl_object * nl_cache_get_prev(struct nl_object *obj)
Return the previous element in the cache.
struct nl_cache * nl_cache_mngr_add(struct nl_cache_mngr *mngr, const char *name, change_func_t cb)
Add cache responsibility to cache manager.
struct nl_cache * nl_cache_subset(struct nl_cache *orig, struct nl_object *filter)
Allocate a new cache containing a subset of a cache.
int nl_cache_mngr_get_fd(struct nl_cache_mngr *mngr)
Get file descriptor.
int nl_cache_mngt_unregister(struct nl_cache_ops *ops)
Unregister a set of cache operations.
void nl_cache_get(struct nl_cache *cache)
Increase reference counter of cache.
int nl_cache_pickup(struct nl_handle *handle, struct nl_cache *cache)
Pickup a netlink dump response and put it into a cache.
void nl_cache_dump_filter(struct nl_cache *cache, struct nl_dump_params *params, struct nl_object *filter)
Dump all elements of a cache (filtered).
void nl_cache_foreach_filter(struct nl_cache *cache, struct nl_object *filter, 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 *cache)
Return the last element in the cache.
int nl_cache_mngr_poll(struct nl_cache_mngr *mngr, int timeout)
Check for event notifications.
struct nl_cache_ops * nl_cache_ops_lookup(const char *name)
Lookup cache operations by name.
void nl_cache_free(struct nl_cache *cache)
Free a cache.
int nl_cache_mngt_register(struct nl_cache_ops *ops)
Register a set of cache operations.
int nl_cache_refill(struct nl_handle *handle, struct nl_cache *cache)
(Re)fill a cache with the contents in the kernel.
struct nl_cache * nl_cache_alloc_name(const char *kind)
Allocate an empty cache based on type name.
void nl_cache_foreach(struct nl_cache *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 *obj)
Removes an object from a cache.
struct nl_cache * nl_cache_mngt_require(const char *name)
Demand the use of a global cache.
int nl_cache_is_empty(struct nl_cache *cache)
Returns true if the cache is empty.
void nl_cache_clear(struct nl_cache *cache)
Clear a cache.
struct nl_cache_ops * nl_cache_ops_lookup_safe(const char *name)
Lookup cache operations by name.
void nl_cache_dump(struct nl_cache *cache, struct nl_dump_params *params)
Dump all elements of a cache.
void nl_cache_mngt_unprovide(struct nl_cache *cache)
Unprovide a cache for global use.
int nl_cache_parse_and_add(struct nl_cache *cache, struct nl_msg *msg)
Parse a netlink message and add it to the cache.
int nl_cache_nitems(struct nl_cache *cache)
Return the number of items in the cache.
struct nl_object * nl_cache_get_next(struct nl_object *obj)
Return the next element in the cache.
void nl_cache_ops_foreach(void(*cb)(struct nl_cache_ops *, void *), void *arg)
Call a function for each registered cache operation.
void nl_cache_mark_all(struct nl_cache *cache)
Mark all objects in a cache.
int nl_cache_mngr_data_ready(struct nl_cache_mngr *mngr)
Receive available event notifications.
struct nl_cache_mngr * nl_cache_mngr_alloc(struct nl_handle *handle, int protocol, int flags)
Allocate new cache manager.
int nl_cache_nitems_filter(struct nl_cache *cache, struct nl_object *filter)
Return the number of items matching a filter in the cache.
struct nl_cache_ops * nl_cache_ops_associate(int protocol, int msgtype)
Associate protocol and message type to cache operations.
void nl_cache_mngr_free(struct nl_cache_mngr *mngr)
Free cache manager.
struct nl_cache_ops * nl_cache_get_ops(struct nl_cache *cache)
Return the operations set of the cache.
int nl_cache_add(struct nl_cache *cache, struct nl_object *obj)
Add object to a cache.
struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *ops, int msgtype)
Lookup message type cache association.
struct nl_cache_ops * nl_cache_ops_associate_safe(int protocol, int msgtype)
Associate protocol and message type to cache operations.
struct nl_object * nl_cache_get_first(struct nl_cache *cache)
Return the first element in the cache.
struct nl_cache * nl_cache_alloc(struct nl_cache_ops *ops)
Allocate an empty cache.