Access Functions |
int | nl_cache_nitems (struct nl_cache *cache) |
| Return the number of items in the cache.
|
int | nl_cache_nitems_filter (struct nl_cache *cache, struct nl_object *filter) |
| Return the number of items matching a filter in the cache.
|
int | nl_cache_is_empty (struct nl_cache *cache) |
| Returns true if the cache is empty.
|
struct nl_cache_ops * | nl_cache_get_ops (struct nl_cache *cache) |
| Return the operations set of the cache.
|
struct nl_object * | nl_cache_get_first (struct nl_cache *cache) |
| Return the first element in the cache.
|
struct nl_object * | nl_cache_get_last (struct nl_cache *cache) |
| Return the last element in the cache.
|
struct nl_object * | nl_cache_get_next (struct nl_object *obj) |
| Return the next element in the cache.
|
struct nl_object * | nl_cache_get_prev (struct nl_object *obj) |
| Return the previous element in the cache.
|
Cache Creation/Deletion |
struct nl_cache * | nl_cache_alloc (struct nl_cache_ops *ops) |
| Allocate an empty cache.
|
struct nl_cache * | nl_cache_alloc_name (const char *kind) |
| Allocate an empty cache based on type name.
|
struct nl_cache * | nl_cache_subset (struct nl_cache *orig, struct nl_object *filter) |
| Allocate a new cache containing a subset of a cache.
|
void | nl_cache_clear (struct nl_cache *cache) |
| Clear a cache.
|
void | nl_cache_free (struct nl_cache *cache) |
| Free a cache.
|
Cache Modifications |
int | nl_cache_add (struct nl_cache *cache, struct nl_object *obj) |
| Add object to a cache.
|
int | nl_cache_move (struct nl_cache *cache, struct nl_object *obj) |
| Move object from one cache to another.
|
void | nl_cache_remove (struct nl_object *obj) |
| Removes an object from a cache.
|
struct nl_object * | nl_cache_search (struct nl_cache *cache, struct nl_object *needle) |
| Search for an object in a cache.
|
Synchronization |
int | nl_cache_request_full_dump (struct nl_handle *handle, struct nl_cache *cache) |
| Request a full dump from the kernel to fill a cache.
|
int | __cache_pickup (struct nl_handle *handle, struct nl_cache *cache, struct nl_parser_param *param) |
int | nl_cache_pickup (struct nl_handle *handle, struct nl_cache *cache) |
| Pickup a netlink dump response and put it into a cache.
|
int | nl_cache_include (struct nl_cache *cache, struct nl_object *obj, change_func_t change_cb) |
int | nl_cache_resync (struct nl_handle *handle, struct nl_cache *cache, change_func_t change_cb) |
Parsing |
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_refill (struct nl_handle *handle, struct nl_cache *cache) |
| (Re)fill a cache with the contents in the kernel.
|
Utillities |
void | nl_cache_mark_all (struct nl_cache *cache) |
| Mark all objects in a cache.
|
Iterators |
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_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).
|
Detailed Description
Cache Management | | Type Specific Cache Operations
| | +----------------+ +------------+
| request update | | msg_parser |
| | +----------------+ +------------+
+- - - - -^- - - - - - - -^- -|- - - -
nl_cache_update: | | | |
1) --------- co_request_update ------+ | |
| | |
2) destroy old cache +----------- pp_cb ---------|---+
| | |
+--------------+ | | | |
+--------------+ | | +-------------+
| | +-----|-^-----+
+---v-|---+
+---------+
| | Core Netlink
Function Documentation
int nl_cache_nitems |
( |
struct nl_cache * |
cache | ) |
|
- Parameters
-
Definition at line 58 of file cache.c.
int nl_cache_nitems_filter |
( |
struct nl_cache * |
cache, |
|
|
struct nl_object * |
filter |
|
) |
| |
int nl_cache_is_empty |
( |
struct nl_cache * |
cache | ) |
|
- Parameters
-
- Returns
- true if the cache is empty, otherwise false is returned.
Definition at line 94 of file cache.c.
struct nl_cache_ops* nl_cache_get_ops |
( |
struct nl_cache * |
cache | ) |
|
|
read |
- Parameters
-
Definition at line 103 of file cache.c.
struct nl_object* nl_cache_get_first |
( |
struct nl_cache * |
cache | ) |
|
|
read |
- Parameters
-
Definition at line 112 of file cache.c.
struct nl_object* nl_cache_get_last |
( |
struct nl_cache * |
cache | ) |
|
|
read |
- Parameters
-
Definition at line 125 of file cache.c.
struct nl_object* nl_cache_get_next |
( |
struct nl_object * |
obj | ) |
|
|
read |
- Parameters
-
Definition at line 138 of file cache.c.
struct nl_object* nl_cache_get_prev |
( |
struct nl_object * |
obj | ) |
|
|
read |
- Parameters
-
Definition at line 151 of file cache.c.
struct nl_cache* nl_cache_alloc |
( |
struct nl_cache_ops * |
ops | ) |
|
|
read |
- Parameters
-
ops | cache operations to base the cache on |
- Returns
- A newly allocated and initialized cache.
Definition at line 173 of file cache.c.
Referenced by flnl_result_alloc_cache(), nfnl_ct_alloc_cache(), nl_cache_alloc_name(), nl_cache_mngr_add(), nl_cache_subset(), rtnl_class_alloc_cache(), rtnl_cls_alloc_cache(), rtnl_link_alloc_cache(), rtnl_neigh_alloc_cache(), rtnl_neightbl_alloc_cache(), rtnl_qdisc_alloc_cache(), rtnl_route_alloc_cache(), and rtnl_rule_alloc_cache_by_family().
struct nl_cache* nl_cache_alloc_name |
( |
const char * |
kind | ) |
|
|
read |
struct nl_cache* nl_cache_subset |
( |
struct nl_cache * |
orig, |
|
|
struct nl_object * |
filter |
|
) |
| |
|
read |
void nl_cache_clear |
( |
struct nl_cache * |
cache | ) |
|
void nl_cache_free |
( |
struct nl_cache * |
cache | ) |
|
int nl_cache_add |
( |
struct nl_cache * |
cache, |
|
|
struct nl_object * |
obj |
|
) |
| |
- Parameters
-
cache | Cache to add object to |
obj | Object to be added to the cache |
Adds the given object to the specified cache. The object is cloned if it has been added to another cache already.
- Returns
- 0 or a negative error code.
Definition at line 302 of file cache.c.
References nl_object_clone(), and nl_object_get().
Referenced by nl_cache_subset().
int nl_cache_move |
( |
struct nl_cache * |
cache, |
|
|
struct nl_object * |
obj |
|
) |
| |
- Parameters
-
cache | Cache to move object to. |
obj | Object subject to be moved |
Removes the given object from its associated cache if needed and adds it to the new cache.
- Returns
- 0 on success or a negative error code.
Definition at line 331 of file cache.c.
References nl_cache_remove(), and nl_object_get().
void nl_cache_remove |
( |
struct nl_object * |
obj | ) |
|
struct nl_object* nl_cache_search |
( |
struct nl_cache * |
cache, |
|
|
struct nl_object * |
needle |
|
) |
| |
|
read |
- Parameters
-
cache | Cache to search in. |
needle | Object to look for. |
Iterates over the cache and looks for an object with identical identifiers as the needle.
- Returns
- Reference to object or NULL if not found.
- Note
- The returned object must be returned via nl_object_put().
Definition at line 383 of file cache.c.
References nl_object_get(), and nl_object_identical().
int nl_cache_request_full_dump |
( |
struct nl_handle * |
handle, |
|
|
struct nl_cache * |
cache |
|
) |
| |
- Parameters
-
handle | Netlink handle |
cache | Cache subjected to be filled. |
Send a dumping request to the kernel causing it to dump all objects related to the specified cache to the netlink socket.
Use nl_cache_pickup() to read the objects from the socket and fill them into a cache.
Definition at line 417 of file cache.c.
Referenced by nl_cache_refill().
int nl_cache_pickup |
( |
struct nl_handle * |
handle, |
|
|
struct nl_cache * |
cache |
|
) |
| |
- Parameters
-
handle | Netlink handle. |
cache | Cache to put items into. |
Waits for netlink messages to arrive, parses them and puts them into the specified cache.
- Returns
- 0 on success or a negative error code.
Definition at line 487 of file cache.c.
Referenced by flnl_lookup(), and nl_cache_refill().
int nl_cache_parse_and_add |
( |
struct nl_cache * |
cache, |
|
|
struct nl_msg * |
msg |
|
) |
| |
- Parameters
-
cache | cache to add element to |
msg | netlink message |
Parses a netlink message by calling the cache specific message parser and adds the new element to the cache.
- Returns
- 0 or a negative error code.
Definition at line 642 of file cache.c.
References nlmsg_hdr().
int nl_cache_refill |
( |
struct nl_handle * |
handle, |
|
|
struct nl_cache * |
cache |
|
) |
| |
- Parameters
-
handle | netlink handle |
cache | cache to update |
Clears the specified cache and fills it with the current state in the kernel.
- Returns
- 0 or a negative error code.
Definition at line 662 of file cache.c.
References nl_cache_clear(), nl_cache_pickup(), and nl_cache_request_full_dump().
Referenced by nfnl_ct_alloc_cache(), nl_cache_mngr_add(), rtnl_class_alloc_cache(), rtnl_cls_alloc_cache(), rtnl_link_alloc_cache(), rtnl_neigh_alloc_cache(), rtnl_neightbl_alloc_cache(), rtnl_qdisc_alloc_cache(), rtnl_route_alloc_cache(), and rtnl_rule_alloc_cache_by_family().
void nl_cache_mark_all |
( |
struct nl_cache * |
cache | ) |
|
void nl_cache_dump |
( |
struct nl_cache * |
cache, |
|
|
struct nl_dump_params * |
params |
|
) |
| |
- Parameters
-
cache | cache to dump |
params | dumping parameters |
Dumps all elements of the cache to the file descriptor fd.
Definition at line 713 of file cache.c.
References nl_cache_dump_filter().
void nl_cache_dump_filter |
( |
struct nl_cache * |
cache, |
|
|
struct nl_dump_params * |
params, |
|
|
struct nl_object * |
filter |
|
) |
| |
void nl_cache_foreach |
( |
struct nl_cache * |
cache, |
|
|
void(*)(struct nl_object *, void *) |
cb, |
|
|
void * |
arg |
|
) |
| |
- Parameters
-
cache | cache to iterate on |
cb | callback function |
arg | argument passed to callback function |
Calls a callback function cb on each element of the cache. The argument arg is passed on the callback function.
Definition at line 773 of file cache.c.
References nl_cache_foreach_filter().
void nl_cache_foreach_filter |
( |
struct nl_cache * |
cache, |
|
|
struct nl_object * |
filter, |
|
|
void(*)(struct nl_object *, void *) |
cb, |
|
|
void * |
arg |
|
) |
| |