libnl  3.2.14
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-2012 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 /* Access Functions */
28 extern int nl_cache_nitems(struct nl_cache *);
29 extern int nl_cache_nitems_filter(struct nl_cache *,
30  struct nl_object *);
31 extern struct nl_cache_ops * nl_cache_get_ops(struct nl_cache *);
32 extern struct nl_object * nl_cache_get_first(struct nl_cache *);
33 extern struct nl_object * nl_cache_get_last(struct nl_cache *);
34 extern struct nl_object * nl_cache_get_next(struct nl_object *);
35 extern struct nl_object * nl_cache_get_prev(struct nl_object *);
36 
37 extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *);
38 extern int nl_cache_alloc_and_fill(struct nl_cache_ops *,
39  struct nl_sock *,
40  struct nl_cache **);
41 extern int nl_cache_alloc_name(const char *,
42  struct nl_cache **);
43 extern struct nl_cache * nl_cache_subset(struct nl_cache *,
44  struct nl_object *);
45 extern struct nl_cache * nl_cache_clone(struct nl_cache *);
46 extern void nl_cache_clear(struct nl_cache *);
47 extern void nl_cache_free(struct nl_cache *);
48 
49 /* Cache modification */
50 extern int nl_cache_add(struct nl_cache *,
51  struct nl_object *);
52 extern int nl_cache_parse_and_add(struct nl_cache *,
53  struct nl_msg *);
54 extern void nl_cache_remove(struct nl_object *);
55 extern int nl_cache_refill(struct nl_sock *,
56  struct nl_cache *);
57 extern int nl_cache_pickup(struct nl_sock *,
58  struct nl_cache *);
59 extern int nl_cache_resync(struct nl_sock *,
60  struct nl_cache *,
61  change_func_t,
62  void *);
63 extern int nl_cache_include(struct nl_cache *,
64  struct nl_object *,
65  change_func_t,
66  void *);
67 extern void nl_cache_set_arg1(struct nl_cache *, int);
68 extern void nl_cache_set_arg2(struct nl_cache *, int);
69 
70 /* General */
71 extern int nl_cache_is_empty(struct nl_cache *);
72 extern struct nl_object * nl_cache_search(struct nl_cache *,
73  struct nl_object *);
74 extern void nl_cache_mark_all(struct nl_cache *);
75 
76 /* Dumping */
77 extern void nl_cache_dump(struct nl_cache *,
78  struct nl_dump_params *);
79 extern void nl_cache_dump_filter(struct nl_cache *,
80  struct nl_dump_params *,
81  struct nl_object *);
82 
83 /* Iterators */
84 extern void nl_cache_foreach(struct nl_cache *,
85  void (*cb)(struct nl_object *,
86  void *),
87  void *arg);
88 extern void nl_cache_foreach_filter(struct nl_cache *,
89  struct nl_object *,
90  void (*cb)(struct
91  nl_object *,
92  void *),
93  void *arg);
94 
95 /* --- cache management --- */
96 
97 /* Cache type management */
98 extern struct nl_cache_ops * nl_cache_ops_lookup(const char *);
99 extern struct nl_cache_ops * nl_cache_ops_associate(int, int);
100 extern struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int);
101 extern void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *);
102 extern int nl_cache_mngt_register(struct nl_cache_ops *);
103 extern int nl_cache_mngt_unregister(struct nl_cache_ops *);
104 
105 /* Global cache provisioning/requiring */
106 extern void nl_cache_mngt_provide(struct nl_cache *);
107 extern void nl_cache_mngt_unprovide(struct nl_cache *);
108 extern struct nl_cache * nl_cache_mngt_require(const char *);
109 extern struct nl_cache * __nl_cache_mngt_require(const char *);
110 
111 struct nl_cache_mngr;
112 
113 #define NL_AUTO_PROVIDE 1
114 #define NL_ALLOCATED_SOCK 2 /* For internal use only, do not use */
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_info(struct nl_cache_mngr *,
129  struct nl_dump_params *);
130 extern void nl_cache_mngr_free(struct nl_cache_mngr *);
131 
132 #ifdef __cplusplus
133 }
134 #endif
135 
136 #endif