libnl 1.1
|
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-2006 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); 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 /* Cache creation/deletion */ 00040 #define nl_cache_alloc_from_ops(ptr) nl_cache_alloc(ptr) 00041 extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *); 00042 extern struct nl_cache * nl_cache_alloc_name(const char *); 00043 extern struct nl_cache * nl_cache_subset(struct nl_cache *, 00044 struct nl_object *); 00045 extern void nl_cache_clear(struct nl_cache *); 00046 extern void nl_cache_free(struct nl_cache *); 00047 00048 /* Cache modification */ 00049 extern int nl_cache_add(struct nl_cache *, 00050 struct nl_object *); 00051 extern int nl_cache_parse_and_add(struct nl_cache *, 00052 struct nl_msg *); 00053 #define nl_cache_delete(a, b) nl_cache_remove(b) 00054 extern void nl_cache_remove(struct nl_object *); 00055 #define nl_cache_update(a, b) nl_cache_refill(a, b) 00056 extern int nl_cache_refill(struct nl_handle *, 00057 struct nl_cache *); 00058 extern int nl_cache_pickup(struct nl_handle *, 00059 struct nl_cache *); 00060 extern int nl_cache_resync(struct nl_handle *, 00061 struct nl_cache *, 00062 change_func_t); 00063 extern int nl_cache_include(struct nl_cache *, 00064 struct nl_object *, 00065 change_func_t); 00066 00067 /* General */ 00068 extern int nl_cache_is_empty(struct nl_cache *); 00069 extern void nl_cache_mark_all(struct nl_cache *); 00070 00071 /* Dumping */ 00072 extern void nl_cache_dump(struct nl_cache *, 00073 struct nl_dump_params *); 00074 extern void nl_cache_dump_filter(struct nl_cache *, 00075 struct nl_dump_params *, 00076 struct nl_object *); 00077 00078 /* Iterators */ 00079 extern void nl_cache_foreach(struct nl_cache *, 00080 void (*cb)(struct nl_object *, 00081 void *), 00082 void *arg); 00083 extern void nl_cache_foreach_filter(struct nl_cache *, 00084 struct nl_object *, 00085 void (*cb)(struct 00086 nl_object *, 00087 void *), 00088 void *arg); 00089 00090 /* --- cache management --- */ 00091 00092 /* Cache type management */ 00093 extern struct nl_cache_ops * nl_cache_ops_lookup(const char *); 00094 extern struct nl_cache_ops * nl_cache_ops_associate(int, int); 00095 extern struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int); 00096 extern void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *); 00097 extern int nl_cache_mngt_register(struct nl_cache_ops *); 00098 extern int nl_cache_mngt_unregister(struct nl_cache_ops *); 00099 00100 /* Global cache provisioning/requiring */ 00101 extern void nl_cache_mngt_provide(struct nl_cache *); 00102 extern void nl_cache_mngt_unprovide(struct nl_cache *); 00103 extern struct nl_cache * nl_cache_mngt_require(const char *); 00104 00105 struct nl_cache_mngr; 00106 00107 #define NL_AUTO_PROVIDE 1 00108 00109 extern struct nl_cache_mngr * nl_cache_mngr_alloc(struct nl_handle *, 00110 int, int); 00111 extern struct nl_cache * nl_cache_mngr_add(struct nl_cache_mngr *, 00112 const char *, 00113 change_func_t); 00114 extern int nl_cache_mngr_get_fd(struct nl_cache_mngr *); 00115 extern int nl_cache_mngr_poll(struct nl_cache_mngr *, 00116 int); 00117 extern int nl_cache_mngr_data_ready(struct nl_cache_mngr *); 00118 extern void nl_cache_mngr_free(struct nl_cache_mngr *); 00119 00120 #ifdef __cplusplus 00121 } 00122 #endif 00123 00124 #endif