libnl 3.7.0
|
Manager keeping caches up to date automatically. More...
Functions | |
int | nl_cache_mngr_alloc (struct nl_sock *sk, int protocol, int flags, struct nl_cache_mngr **result) |
Allocate new cache manager. More... | |
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. More... | |
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. More... | |
int | nl_cache_mngr_add (struct nl_cache_mngr *mngr, const char *name, change_func_t cb, void *data, struct nl_cache **result) |
Add cache to cache manager. More... | |
int | nl_cache_mngr_get_fd (struct nl_cache_mngr *mngr) |
Get socket file descriptor. More... | |
int | nl_cache_mngr_poll (struct nl_cache_mngr *mngr, int timeout) |
Check for event notifications. More... | |
int | nl_cache_mngr_data_ready (struct nl_cache_mngr *mngr) |
Receive available event notifications. More... | |
void | nl_cache_mngr_info (struct nl_cache_mngr *mngr, struct nl_dump_params *p) |
Print information about cache manager. More... | |
void | nl_cache_mngr_free (struct nl_cache_mngr *mngr) |
Free cache manager and all caches. More... | |
Manager keeping caches up to date automatically.
The cache manager keeps caches up to date automatically by listening to netlink notifications and integrating the received information into the existing cache.
Related sections in the development guide:
int nl_cache_mngr_alloc | ( | struct nl_sock * | sk, |
int | protocol, | ||
int | flags, | ||
struct nl_cache_mngr ** | result | ||
) |
Allocate new cache manager.
sk | Netlink socket or NULL to auto allocate |
protocol | Netlink protocol this manager is used for |
flags | Flags (NL_AUTO_PROVIDE ) |
result | Result pointer |
Allocates a new cache manager for the specified netlink protocol.
NULL
) a netlink socket matching the specified protocol will be automatically allocated.If the flag NL_AUTO_PROVIDE
is specified, any cache added to the manager will automatically be made available to other users using nl_cache_mngt_provide().
Definition at line 136 of file cache_mngr.c.
References nl_cache_mngr_free(), nl_connect(), nl_socket_alloc(), nl_socket_disable_seq_check(), nl_socket_free(), and nl_socket_set_nonblocking().
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.
mngr | Cache manager. |
cache | Cache to be added to cache manager |
cb | Function to be called upon changes. |
data | Argument passed on to change callback |
Adds cache to the manager. The operation will trigger a full dump request from the kernel to initially fill the contents of the cache. The manager will subscribe to the notification group of the cache and keep track of any further changes.
The user is responsible for calling nl_cache_mngr_poll() or monitor the socket and call nl_cache_mngr_data_ready() to allow the library to process netlink notification events.
Definition at line 286 of file cache_mngr.c.
References nl_cache_mngt_provide(), and nl_cache_refill().
Referenced by nl_cache_mngr_add(), and nl_cache_mngr_add_cache_v2().
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.
mngr | Cache manager. |
cache | Cache to be added to cache manager |
cb | V2 function to be called upon changes. |
data | Argument passed on to change callback |
Adds cache to the manager. The operation will trigger a full dump request from the kernel to initially fill the contents of the cache. The manager will subscribe to the notification group of the cache and keep track of any further changes.
The user is responsible for calling nl_cache_mngr_poll() or monitor the socket and call nl_cache_mngr_data_ready() to allow the library to process netlink notification events.
Definition at line 384 of file cache_mngr.c.
References nl_cache_mngr_add_cache().
int nl_cache_mngr_add | ( | struct nl_cache_mngr * | mngr, |
const char * | name, | ||
change_func_t | cb, | ||
void * | data, | ||
struct nl_cache ** | result | ||
) |
Add cache to cache manager.
mngr | Cache manager. |
name | Name of cache to keep track of |
cb | Function to be called upon changes. |
data | Argument passed on to change callback |
result | Pointer to store added cache (optional) |
Allocates a new cache of the specified type and adds it to the manager. The operation will trigger a full dump request from the kernel to initially fill the contents of the cache. The manager will subscribe to the notification group of the cache and keep track of any further changes.
The user is responsible for calling nl_cache_mngr_poll() or monitor the socket and call nl_cache_mngr_data_ready() to allow the library to process netlink notification events.
Definition at line 425 of file cache_mngr.c.
References nl_cache_alloc(), nl_cache_free(), nl_cache_mngr_add_cache(), nl_cache_ops_lookup_safe(), and nl_cache_ops_put().
int nl_cache_mngr_get_fd | ( | struct nl_cache_mngr * | mngr | ) |
Get socket file descriptor.
mngr | Cache Manager |
Get the file descriptor of the socket associated with the manager.
Definition at line 464 of file cache_mngr.c.
References nl_socket_get_fd().
int nl_cache_mngr_poll | ( | struct nl_cache_mngr * | mngr, |
int | timeout | ||
) |
Check for event notifications.
mngr | Cache Manager |
timeout | Upper limit poll() will block, in milliseconds. |
Causes poll() to be called to check for new event notifications being available. Calls nl_cache_mngr_data_ready() to process available data.
This functionally is ideally called regularly during an idle period.
A timeout can be specified in milliseconds to limit the time the function will wait for updates.
Definition at line 488 of file cache_mngr.c.
References nl_cache_mngr_data_ready(), and nl_socket_get_fd().
int nl_cache_mngr_data_ready | ( | struct nl_cache_mngr * | mngr | ) |
Receive available event notifications.
mngr | Cache manager |
This function can be called if the socket associated to the manager contains updates to be received. This function should only be used if nl_cache_mngr_poll() is not used.
The function will process messages until there is no more data to be read from the socket.
Definition at line 527 of file cache_mngr.c.
References nl_cb_clone(), NL_CB_CUSTOM, nl_cb_set(), NL_CB_VALID, nl_recvmsgs_report(), and nl_socket_get_fd().
Referenced by nl_cache_mngr_poll().
void nl_cache_mngr_info | ( | struct nl_cache_mngr * | mngr, |
struct nl_dump_params * | p | ||
) |
Print information about cache manager.
mngr | Cache manager |
p | Dumping parameters |
Prints information about the cache manager including all managed caches.
Definition at line 563 of file cache_mngr.c.
References nl_dump_params::dp_prefix, nl_cache_dump(), and nl_cache_nitems().
void nl_cache_mngr_free | ( | struct nl_cache_mngr * | mngr | ) |
Free cache manager and all caches.
mngr | Cache manager. |
Release all resources held by a cache manager.
Definition at line 602 of file cache_mngr.c.
References nl_cache_free(), nl_cache_mngt_unprovide(), nl_close(), and nl_socket_free().
Referenced by nl_cache_mngr_alloc().