Functions | |
struct nl_cache_mngr * | nl_cache_mngr_alloc (struct nl_handle *handle, int protocol, int flags) |
Allocate new cache manager. | |
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. | |
int | nl_cache_mngr_get_fd (struct nl_cache_mngr *mngr) |
Get file descriptor. | |
int | nl_cache_mngr_poll (struct nl_cache_mngr *mngr, int timeout) |
Check for event notifications. | |
int | nl_cache_mngr_data_ready (struct nl_cache_mngr *mngr) |
Receive available event notifications. | |
void | nl_cache_mngr_free (struct nl_cache_mngr *mngr) |
Free cache manager. |
App libnl Kernel
| |
+-----------------+ [ notification, link change ]
| | Cache Manager | | [ (IFF_UP | IFF_RUNNING) ]
| | |
| | +------------+| | | [ notification, new addr ]
<-------|---| route/link |<-------(async)--+ [ 10.0.1.1/32 dev eth1 ]
| | +------------+| | |
| +------------+| |
<---|---|---| route/addr |<------|-(async)--------------+
| +------------+|
| | +------------+| |
<-------|---| ... ||
| | +------------+| |
+-----------------+
| |
struct nl_cache_mngr *mngr; // Allocate a new cache manager for RTNETLINK and automatically // provide the caches added to the manager. mngr = nl_cache_mngr_alloc(NETLINK_ROUTE, NL_AUTO_PROVIDE);
struct nl_cache *cache; // Create a new cache for links/interfaces and ask the manager to // keep it up to date for us. This will trigger a full dump request // to initially fill the cache. cache = nl_cache_mngr_add(mngr, "route/link");
// Give the manager the ability to receive updates, will call poll() // with a timeout of 5 seconds. if (nl_cache_mngr_poll(mngr, 5000) > 0) { // Manager received at least one update, dump cache? nl_cache_dump(cache, ...); }
nl_cache_mngr_free(mngr);
struct nl_cache_mngr* nl_cache_mngr_alloc | ( | struct nl_handle * | handle, | |
int | protocol, | |||
int | flags | |||
) | [read] |
handle | Netlink socket/handle to be used | |
protocol | Netlink Protocol this manager is used for | |
flags | Flags |
Definition at line 149 of file cache_mngr.c.
References nl_cache_mngr_free(), NL_CB_CUSTOM, NL_CB_VALID, nl_connect(), nl_disable_sequence_check(), nl_socket_modify_cb(), and nl_socket_set_nonblocking().
struct nl_cache* nl_cache_mngr_add | ( | struct nl_cache_mngr * | mngr, | |
const char * | name, | |||
change_func_t | cb | |||
) | [read] |
mngr | Cache manager. | |
name | Name of cache to keep track of | |
cb | Function to be called upon changes. |
Definition at line 209 of file cache_mngr.c.
References nl_af_group::ag_group, nl_cache_ops::co_groups, nl_cache_ops::co_protocol, nl_cache_alloc(), nl_cache_free(), nl_cache_mngt_provide(), nl_cache_ops_lookup(), nl_cache_refill(), nl_socket_add_membership(), and nl_socket_drop_membership().
int nl_cache_mngr_get_fd | ( | struct nl_cache_mngr * | mngr | ) |
mngr | Cache Manager |
Definition at line 305 of file cache_mngr.c.
int nl_cache_mngr_poll | ( | struct nl_cache_mngr * | mngr, | |
int | timeout | |||
) |
mngr | Cache Manager | |
timeout | Upper limit poll() will block, in milliseconds. |
This functionally is ideally called regularly during an idle period.
Definition at line 325 of file cache_mngr.c.
References nl_cache_mngr_data_ready().
int nl_cache_mngr_data_ready | ( | struct nl_cache_mngr * | mngr | ) |
mngr | Cache manager |
Definition at line 356 of file cache_mngr.c.
References nl_recvmsgs_default().
Referenced by nl_cache_mngr_poll().
void nl_cache_mngr_free | ( | struct nl_cache_mngr * | mngr | ) |
mngr | Cache manager |
Definition at line 373 of file cache_mngr.c.
References nl_close(), and nl_handle_destroy().
Referenced by nl_cache_mngr_alloc().