00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef NETSNMP_CACHE_HANDLER_H
00012 #define NETSNMP_CACHE_HANDLER_H
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <net-snmp/library/tools.h>
00022
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026
00027 #define CACHE_NAME "cache_info"
00028
00029 typedef struct netsnmp_cache_s netsnmp_cache;
00030
00031 typedef int (NetsnmpCacheLoad)(netsnmp_cache *, void*);
00032 typedef void (NetsnmpCacheFree)(netsnmp_cache *, void*);
00033
00034 struct netsnmp_cache_s {
00035
00036
00037
00038 int flags;
00039 int enabled;
00040 int valid;
00041 char expired;
00042 int timeout;
00043 marker_t timestamp;
00044 u_long timer_id;
00045
00046 NetsnmpCacheLoad *load_cache;
00047 NetsnmpCacheFree *free_cache;
00048
00049
00050
00051
00052
00053 void *magic;
00054
00055
00056
00057
00058
00059 netsnmp_handler_args *cache_hint;
00060
00061
00062
00063
00064 netsnmp_cache *next, *prev;
00065 oid *rootoid;
00066 int rootoid_len;
00067
00068 };
00069
00070
00071 void netsnmp_cache_reqinfo_insert(netsnmp_cache* cache,
00072 netsnmp_agent_request_info * reqinfo,
00073 const char *name);
00074 netsnmp_cache *
00075 netsnmp_cache_reqinfo_extract(netsnmp_agent_request_info * reqinfo,
00076 const char *name);
00077 netsnmp_cache* netsnmp_extract_cache_info(netsnmp_agent_request_info *);
00078
00079 int netsnmp_cache_check_and_reload(netsnmp_cache * cache);
00080 int netsnmp_cache_check_expired(netsnmp_cache *cache);
00081 int netsnmp_cache_is_valid( netsnmp_agent_request_info *,
00082 const char *name);
00084 int netsnmp_is_cache_valid( netsnmp_agent_request_info *);
00085 netsnmp_mib_handler *netsnmp_get_cache_handler(int, NetsnmpCacheLoad *,
00086 NetsnmpCacheFree *,
00087 const oid*, int);
00088 int netsnmp_register_cache_handler(netsnmp_handler_registration *reginfo,
00089 int, NetsnmpCacheLoad *,
00090 NetsnmpCacheFree *);
00091
00092 Netsnmp_Node_Handler netsnmp_cache_helper_handler;
00093
00094 netsnmp_cache *
00095 netsnmp_cache_create(int timeout, NetsnmpCacheLoad * load_hook,
00096 NetsnmpCacheFree * free_hook,
00097 const oid * rootoid, int rootoid_len);
00098 int netsnmp_cache_free(netsnmp_cache *cache);
00099
00100 netsnmp_mib_handler *
00101 netsnmp_cache_handler_get(netsnmp_cache* cache);
00102
00103 netsnmp_cache * netsnmp_cache_find_by_oid(const oid * rootoid,
00104 int rootoid_len);
00105
00106 unsigned int netsnmp_cache_timer_start(netsnmp_cache *cache);
00107 void netsnmp_cache_timer_stop(netsnmp_cache *cache);
00108
00109
00110
00111
00112 #define NETSNMP_CACHE_DONT_INVALIDATE_ON_SET 0x0001
00113 #define NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD 0x0002
00114 #define NETSNMP_CACHE_DONT_FREE_EXPIRED 0x0004
00115 #define NETSNMP_CACHE_DONT_AUTO_RELEASE 0x0008
00116 #define NETSNMP_CACHE_PRELOAD 0x0010
00117 #define NETSNMP_CACHE_AUTO_RELOAD 0x0020
00118
00119 #define NETSNMP_CACHE_HINT_HANDLER_ARGS 0x1000
00120
00121
00122 #ifdef __cplusplus
00123 }
00124 #endif
00125 #endif