Root/package/libnl-tiny/src/include/netlink/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
22extern "C" {
23#endif
24
25struct nl_cache;
26
27typedef void (*change_func_t)(struct nl_cache *, struct nl_object *, int);
28
29/* Access Functions */
30extern int nl_cache_nitems(struct nl_cache *);
31extern int nl_cache_nitems_filter(struct nl_cache *,
32                               struct nl_object *);
33extern struct nl_cache_ops * nl_cache_get_ops(struct nl_cache *);
34extern struct nl_object * nl_cache_get_first(struct nl_cache *);
35extern struct nl_object * nl_cache_get_last(struct nl_cache *);
36extern struct nl_object * nl_cache_get_next(struct nl_object *);
37extern struct nl_object * nl_cache_get_prev(struct nl_object *);
38
39extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *);
40extern int nl_cache_alloc_and_fill(struct nl_cache_ops *,
41                            struct nl_sock *,
42                            struct nl_cache **);
43extern int nl_cache_alloc_name(const char *,
44                            struct nl_cache **);
45extern struct nl_cache * nl_cache_subset(struct nl_cache *,
46                        struct nl_object *);
47extern void nl_cache_clear(struct nl_cache *);
48extern void nl_cache_free(struct nl_cache *);
49
50/* Cache modification */
51extern int nl_cache_add(struct nl_cache *,
52                         struct nl_object *);
53extern int nl_cache_parse_and_add(struct nl_cache *,
54                               struct nl_msg *);
55extern void nl_cache_remove(struct nl_object *);
56extern int nl_cache_refill(struct nl_sock *,
57                        struct nl_cache *);
58extern int nl_cache_pickup(struct nl_sock *,
59                        struct nl_cache *);
60extern int nl_cache_resync(struct nl_sock *,
61                        struct nl_cache *,
62                        change_func_t);
63extern int nl_cache_include(struct nl_cache *,
64                         struct nl_object *,
65                         change_func_t);
66
67/* General */
68extern int nl_cache_is_empty(struct nl_cache *);
69extern void nl_cache_mark_all(struct nl_cache *);
70
71/* Dumping */
72extern void nl_cache_dump(struct nl_cache *,
73                          struct nl_dump_params *);
74extern void nl_cache_dump_filter(struct nl_cache *,
75                             struct nl_dump_params *,
76                             struct nl_object *);
77
78/* Iterators */
79#ifdef disabled
80extern void nl_cache_foreach(struct nl_cache *,
81                         void (*cb)(struct nl_object *,
82                                void *),
83                         void *arg);
84extern void nl_cache_foreach_filter(struct nl_cache *,
85                            struct nl_object *,
86                            void (*cb)(struct
87                                   nl_object *,
88                                   void *),
89                            void *arg);
90#endif
91
92/* --- cache management --- */
93
94/* Cache type management */
95extern struct nl_cache_ops * nl_cache_ops_lookup(const char *);
96extern struct nl_cache_ops * nl_cache_ops_associate(int, int);
97extern struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int);
98extern void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *);
99extern int nl_cache_mngt_register(struct nl_cache_ops *);
100extern int nl_cache_mngt_unregister(struct nl_cache_ops *);
101
102/* Global cache provisioning/requiring */
103extern void nl_cache_mngt_provide(struct nl_cache *);
104extern void nl_cache_mngt_unprovide(struct nl_cache *);
105extern struct nl_cache * nl_cache_mngt_require(const char *);
106
107struct nl_cache_mngr;
108
109#define NL_AUTO_PROVIDE 1
110
111extern int nl_cache_mngr_alloc(struct nl_sock *,
112                            int, int,
113                            struct nl_cache_mngr **);
114extern int nl_cache_mngr_add(struct nl_cache_mngr *,
115                          const char *,
116                          change_func_t,
117                          struct nl_cache **);
118extern int nl_cache_mngr_get_fd(struct nl_cache_mngr *);
119extern int nl_cache_mngr_poll(struct nl_cache_mngr *,
120                           int);
121extern int nl_cache_mngr_data_ready(struct nl_cache_mngr *);
122extern void nl_cache_mngr_free(struct nl_cache_mngr *);
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif
129

Archive Download this file



interactive