libnl  3.2.3
/build/buildd/libnl3-3.2.3/include/netlink/cache.h
00001 /*
00002  * netlink/cache.h              Caching Module
00003  *
00004  *      This library is free software; you can redistribute it and/or
00005  *      modify it under the terms of the GNU Lesser General Public
00006  *      License as published by the Free Software Foundation version 2.1
00007  *      of the License.
00008  *
00009  * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
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 /* Access Functions */
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 /* Cache modification */
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 extern void                     nl_cache_set_arg1(struct nl_cache *, int);
00069 extern void                     nl_cache_set_arg2(struct nl_cache *, int);
00070 
00071 /* General */
00072 extern int                      nl_cache_is_empty(struct nl_cache *);
00073 extern struct nl_object *       nl_cache_search(struct nl_cache *,
00074                                                 struct nl_object *);
00075 extern void                     nl_cache_mark_all(struct nl_cache *);
00076 
00077 /* Dumping */
00078 extern void                     nl_cache_dump(struct nl_cache *,
00079                                               struct nl_dump_params *);
00080 extern void                     nl_cache_dump_filter(struct nl_cache *,
00081                                                      struct nl_dump_params *,
00082                                                      struct nl_object *);
00083 
00084 /* Iterators */
00085 extern void                     nl_cache_foreach(struct nl_cache *,
00086                                                  void (*cb)(struct nl_object *,
00087                                                             void *),
00088                                                  void *arg);
00089 extern void                     nl_cache_foreach_filter(struct nl_cache *,
00090                                                         struct nl_object *,
00091                                                         void (*cb)(struct
00092                                                                    nl_object *,
00093                                                                    void *),
00094                                                         void *arg);
00095 
00096 /* --- cache management --- */
00097 
00098 /* Cache type management */
00099 extern struct nl_cache_ops *    nl_cache_ops_lookup(const char *);
00100 extern struct nl_cache_ops *    nl_cache_ops_associate(int, int);
00101 extern struct nl_msgtype *      nl_msgtype_lookup(struct nl_cache_ops *, int);
00102 extern void                     nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *);
00103 extern int                      nl_cache_mngt_register(struct nl_cache_ops *);
00104 extern int                      nl_cache_mngt_unregister(struct nl_cache_ops *);
00105 
00106 /* Global cache provisioning/requiring */
00107 extern void                     nl_cache_mngt_provide(struct nl_cache *);
00108 extern void                     nl_cache_mngt_unprovide(struct nl_cache *);
00109 extern struct nl_cache *        nl_cache_mngt_require(const char *);
00110 extern struct nl_cache *        __nl_cache_mngt_require(const char *);
00111 
00112 struct nl_cache_mngr;
00113 
00114 #define NL_AUTO_PROVIDE         1
00115 
00116 extern int                      nl_cache_mngr_alloc(struct nl_sock *,
00117                                                     int, int,
00118                                                     struct nl_cache_mngr **);
00119 extern int                      nl_cache_mngr_add(struct nl_cache_mngr *,
00120                                                   const char *,
00121                                                   change_func_t,
00122                                                   void *,
00123                                                   struct nl_cache **);
00124 extern int                      nl_cache_mngr_get_fd(struct nl_cache_mngr *);
00125 extern int                      nl_cache_mngr_poll(struct nl_cache_mngr *,
00126                                                    int);
00127 extern int                      nl_cache_mngr_data_ready(struct nl_cache_mngr *);
00128 extern void                     nl_cache_mngr_free(struct nl_cache_mngr *);
00129 
00130 #ifdef __cplusplus
00131 }
00132 #endif
00133 
00134 #endif