00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef NETLINK_CACHE_H_
00013 #define NETLINK_CACHE_H_
00014
00015 #include <netlink/netlink.h>
00016 #include <netlink/msg.h>
00017 #include <netlink/utils.h>
00018 #include <netlink/object.h>
00019 #include <netlink/cache-api.h>
00020
00021 #ifdef __cplusplus
00022 extern "C" {
00023 #endif
00024
00025 struct nl_cache;
00026
00027 typedef void (*change_func_t)(struct nl_cache *, struct nl_object *, int, void *);
00028
00029
00030 extern int nl_cache_nitems(struct nl_cache *);
00031 extern int nl_cache_nitems_filter(struct nl_cache *,
00032 struct nl_object *);
00033 extern struct nl_cache_ops * nl_cache_get_ops(struct nl_cache *);
00034 extern struct nl_object * nl_cache_get_first(struct nl_cache *);
00035 extern struct nl_object * nl_cache_get_last(struct nl_cache *);
00036 extern struct nl_object * nl_cache_get_next(struct nl_object *);
00037 extern struct nl_object * nl_cache_get_prev(struct nl_object *);
00038
00039 extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *);
00040 extern int nl_cache_alloc_and_fill(struct nl_cache_ops *,
00041 struct nl_sock *,
00042 struct nl_cache **);
00043 extern int nl_cache_alloc_name(const char *,
00044 struct nl_cache **);
00045 extern struct nl_cache * nl_cache_subset(struct nl_cache *,
00046 struct nl_object *);
00047 extern void nl_cache_clear(struct nl_cache *);
00048 extern void nl_cache_free(struct nl_cache *);
00049
00050
00051 extern int nl_cache_add(struct nl_cache *,
00052 struct nl_object *);
00053 extern int nl_cache_parse_and_add(struct nl_cache *,
00054 struct nl_msg *);
00055 extern void nl_cache_remove(struct nl_object *);
00056 extern int nl_cache_refill(struct nl_sock *,
00057 struct nl_cache *);
00058 extern int nl_cache_pickup(struct nl_sock *,
00059 struct nl_cache *);
00060 extern int nl_cache_resync(struct nl_sock *,
00061 struct nl_cache *,
00062 change_func_t,
00063 void *);
00064 extern int nl_cache_include(struct nl_cache *,
00065 struct nl_object *,
00066 change_func_t,
00067 void *);
00068
00069
00070 extern int nl_cache_is_empty(struct nl_cache *);
00071 extern void nl_cache_mark_all(struct nl_cache *);
00072
00073
00074 extern void nl_cache_dump(struct nl_cache *,
00075 struct nl_dump_params *);
00076 extern void nl_cache_dump_filter(struct nl_cache *,
00077 struct nl_dump_params *,
00078 struct nl_object *);
00079
00080
00081 extern void nl_cache_foreach(struct nl_cache *,
00082 void (*cb)(struct nl_object *,
00083 void *),
00084 void *arg);
00085 extern void nl_cache_foreach_filter(struct nl_cache *,
00086 struct nl_object *,
00087 void (*cb)(struct
00088 nl_object *,
00089 void *),
00090 void *arg);
00091
00092
00093
00094
00095 extern struct nl_cache_ops * nl_cache_ops_lookup(const char *);
00096 extern struct nl_cache_ops * nl_cache_ops_associate(int, int);
00097 extern struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int);
00098 extern void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *);
00099 extern int nl_cache_mngt_register(struct nl_cache_ops *);
00100 extern int nl_cache_mngt_unregister(struct nl_cache_ops *);
00101
00102
00103 extern void nl_cache_mngt_provide(struct nl_cache *);
00104 extern void nl_cache_mngt_unprovide(struct nl_cache *);
00105 extern struct nl_cache * nl_cache_mngt_require(const char *);
00106
00107 struct nl_cache_mngr;
00108
00109 #define NL_AUTO_PROVIDE 1
00110
00111 extern int nl_cache_mngr_alloc(struct nl_sock *,
00112 int, int,
00113 struct nl_cache_mngr **);
00114 extern int nl_cache_mngr_add(struct nl_cache_mngr *,
00115 const char *,
00116 change_func_t,
00117 void *,
00118 struct nl_cache **);
00119 extern int nl_cache_mngr_get_fd(struct nl_cache_mngr *);
00120 extern int nl_cache_mngr_poll(struct nl_cache_mngr *,
00121 int);
00122 extern int nl_cache_mngr_data_ready(struct nl_cache_mngr *);
00123 extern void nl_cache_mngr_free(struct nl_cache_mngr *);
00124
00125 #ifdef __cplusplus
00126 }
00127 #endif
00128
00129 #endif