libnl  3.2.7
cache.h
1 /*
2  * netlink/cache.h Caching Module
3  *
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
7  * of the License.
8  *
9  * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
10  */
11 
12 #ifndef NETLINK_CACHE_H_
13 #define NETLINK_CACHE_H_
14 
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>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 struct nl_cache;
26 
27 typedef void (*change_func_t)(struct nl_cache *, struct nl_object *, int, void *);
28 
29 /* Access Functions */
30 extern int nl_cache_nitems(struct nl_cache *);
31 extern int nl_cache_nitems_filter(struct nl_cache *,
32  struct nl_object *);
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 *);
38 
39 extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *);
40 extern int nl_cache_alloc_and_fill(struct nl_cache_ops *,
41  struct nl_sock *,
42  struct nl_cache **);
43 extern int nl_cache_alloc_name(const char *,
44  struct nl_cache **);
45 extern struct nl_cache * nl_cache_subset(struct nl_cache *,
46  struct nl_object *);
47 extern void nl_cache_clear(struct nl_cache *);
48 extern void nl_cache_free(struct nl_cache *);
49 
50 /* Cache modification */
51 extern int nl_cache_add(struct nl_cache *,
52  struct nl_object *);
53 extern int nl_cache_parse_and_add(struct nl_cache *,
54  struct nl_msg *);
55 extern void nl_cache_remove(struct nl_object *);
56 extern int nl_cache_refill(struct nl_sock *,
57  struct nl_cache *);
58 extern int nl_cache_pickup(struct nl_sock *,
59  struct nl_cache *);
60 extern int nl_cache_resync(struct nl_sock *,
61  struct nl_cache *,
62  change_func_t,
63  void *);
64 extern int nl_cache_include(struct nl_cache *,
65  struct nl_object *,
66  change_func_t,
67  void *);
68 extern void nl_cache_set_arg1(struct nl_cache *, int);
69 extern void nl_cache_set_arg2(struct nl_cache *, int);
70 
71 /* General */
72 extern int nl_cache_is_empty(struct nl_cache *);
73 extern struct nl_object * nl_cache_search(struct nl_cache *,
74  struct nl_object *);
75 extern void nl_cache_mark_all(struct nl_cache *);
76 
77 /* Dumping */
78 extern void nl_cache_dump(struct nl_cache *,
79  struct nl_dump_params *);
80 extern void nl_cache_dump_filter(struct nl_cache *,
81  struct nl_dump_params *,
82  struct nl_object *);
83 
84 /* Iterators */
85 extern void nl_cache_foreach(struct nl_cache *,
86  void (*cb)(struct nl_object *,
87  void *),
88  void *arg);
89 extern void nl_cache_foreach_filter(struct nl_cache *,
90  struct nl_object *,
91  void (*cb)(struct
92  nl_object *,
93  void *),
94  void *arg);
95 
96 /* --- cache management --- */
97 
98 /* Cache type management */
99 extern struct nl_cache_ops * nl_cache_ops_lookup(const char *);
100 extern struct nl_cache_ops * nl_cache_ops_associate(int, int);
101 extern struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int);
102 extern void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *);
103 extern int nl_cache_mngt_register(struct nl_cache_ops *);
104 extern int nl_cache_mngt_unregister(struct nl_cache_ops *);
105 
106 /* Global cache provisioning/requiring */
107 extern void nl_cache_mngt_provide(struct nl_cache *);
108 extern void nl_cache_mngt_unprovide(struct nl_cache *);
109 extern struct nl_cache * nl_cache_mngt_require(const char *);
110 extern struct nl_cache * __nl_cache_mngt_require(const char *);
111 
112 struct nl_cache_mngr;
113 
114 #define NL_AUTO_PROVIDE 1
115 
116 extern int nl_cache_mngr_alloc(struct nl_sock *,
117  int, int,
118  struct nl_cache_mngr **);
119 extern int nl_cache_mngr_add(struct nl_cache_mngr *,
120  const char *,
121  change_func_t,
122  void *,
123  struct nl_cache **);
124 extern int nl_cache_mngr_get_fd(struct nl_cache_mngr *);
125 extern int nl_cache_mngr_poll(struct nl_cache_mngr *,
126  int);
127 extern int nl_cache_mngr_data_ready(struct nl_cache_mngr *);
128 extern void nl_cache_mngr_free(struct nl_cache_mngr *);
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif