2 * netlink/cache.h Caching Module
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
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);
29 /* Access Functions */
30 extern int nl_cache_nitems(struct nl_cache *);
31 extern int nl_cache_nitems_filter(struct nl_cache *,
33 extern struct nl_cache_ops * nl_cache_get_ops(struct nl_cache *);
34 extern struct nl_object * nl_cache_get_first(struct nl_cache *);
35 extern struct nl_object * nl_cache_get_last(struct nl_cache *);
36 extern struct nl_object * nl_cache_get_next(struct nl_object *);
37 extern struct nl_object * nl_cache_get_prev(struct nl_object *);
39 extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *);
40 extern int nl_cache_alloc_and_fill(struct nl_cache_ops *,
43 extern int nl_cache_alloc_name(const char *,
45 extern struct nl_cache * nl_cache_subset(struct nl_cache *,
47 extern void nl_cache_clear(struct nl_cache *);
48 extern void nl_cache_free(struct nl_cache *);
50 /* Cache modification */
51 extern int nl_cache_add(struct nl_cache *,
53 extern int nl_cache_parse_and_add(struct nl_cache *,
55 extern void nl_cache_remove(struct nl_object *);
56 extern int nl_cache_refill(struct nl_sock *,
58 extern int nl_cache_pickup(struct nl_sock *,
60 extern int nl_cache_resync(struct nl_sock *,
63 extern int nl_cache_include(struct nl_cache *,
68 extern int nl_cache_is_empty(struct nl_cache *);
69 extern void nl_cache_mark_all(struct nl_cache *);
72 extern void nl_cache_dump(struct nl_cache *,
73 struct nl_dump_params *);
74 extern void nl_cache_dump_filter(struct nl_cache *,
75 struct nl_dump_params *,
79 extern void nl_cache_foreach(struct nl_cache *,
80 void (*cb)(struct nl_object *,
83 extern void nl_cache_foreach_filter(struct nl_cache *,
90 /* --- cache management --- */
92 /* Cache type management */
93 extern struct nl_cache_ops * nl_cache_ops_lookup(const char *);
94 extern struct nl_cache_ops * nl_cache_ops_associate(int, int);
95 extern struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int);
96 extern void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *);
97 extern int nl_cache_mngt_register(struct nl_cache_ops *);
98 extern int nl_cache_mngt_unregister(struct nl_cache_ops *);
100 /* Global cache provisioning/requiring */
101 extern void nl_cache_mngt_provide(struct nl_cache *);
102 extern void nl_cache_mngt_unprovide(struct nl_cache *);
103 extern struct nl_cache * nl_cache_mngt_require(const char *);
105 struct nl_cache_mngr;
107 #define NL_AUTO_PROVIDE 1
109 extern int nl_cache_mngr_alloc(struct nl_sock *,
111 struct nl_cache_mngr **);
112 extern int nl_cache_mngr_add(struct nl_cache_mngr *,
116 extern int nl_cache_mngr_get_fd(struct nl_cache_mngr *);
117 extern int nl_cache_mngr_poll(struct nl_cache_mngr *,
119 extern int nl_cache_mngr_data_ready(struct nl_cache_mngr *);
120 extern void nl_cache_mngr_free(struct nl_cache_mngr *);