net-snmp
5.4.1
|
00001 #ifndef NETSNMP_CACHE_HANDLER_H 00002 #define NETSNMP_CACHE_HANDLER_H 00003 00004 /* 00005 * This caching helper provides a generalised (SNMP-manageable) caching 00006 * mechanism. Individual SNMP table and scalar/scalar group MIB 00007 * implementations can use data caching in a consistent manner, without 00008 * needing to handle the generic caching details themselves. 00009 */ 00010 00011 #include <net-snmp/library/tools.h> 00012 00013 #ifdef __cplusplus 00014 extern "C" { 00015 #endif 00016 00017 #define CACHE_NAME "cache_info" 00018 00019 typedef struct netsnmp_cache_s netsnmp_cache; 00020 00021 typedef int (NetsnmpCacheLoad)(netsnmp_cache *, void*); 00022 typedef void (NetsnmpCacheFree)(netsnmp_cache *, void*); 00023 00024 struct netsnmp_cache_s { 00025 /* 00026 * For operation of the data caches 00027 */ 00028 int flags; 00029 int enabled; 00030 int valid; 00031 char expired; 00032 int timeout; /* Length of time the cache is valid (in s) */ 00033 marker_t timestamp; /* When the cache was last loaded */ 00034 u_long timer_id; /* periodic timer id */ 00035 00036 NetsnmpCacheLoad *load_cache; 00037 NetsnmpCacheFree *free_cache; 00038 00039 /* 00040 * void pointer for the user that created the cache. 00041 * You never know when it might not come in useful .... 00042 */ 00043 void *magic; 00044 00045 /* 00046 * hint from the cache helper. contains the standard 00047 * handler arguments. 00048 */ 00049 netsnmp_handler_args *cache_hint; 00050 00051 /* 00052 * For SNMP-management of the data caches 00053 */ 00054 netsnmp_cache *next, *prev; 00055 oid *rootoid; 00056 int rootoid_len; 00057 00058 }; 00059 00060 00061 void netsnmp_cache_reqinfo_insert(netsnmp_cache* cache, 00062 netsnmp_agent_request_info * reqinfo, 00063 const char *name); 00064 netsnmp_cache * 00065 netsnmp_cache_reqinfo_extract(netsnmp_agent_request_info * reqinfo, 00066 const char *name); 00067 netsnmp_cache* netsnmp_extract_cache_info(netsnmp_agent_request_info *); 00068 00069 int netsnmp_cache_check_and_reload(netsnmp_cache * cache); 00070 int netsnmp_cache_check_expired(netsnmp_cache *cache); 00071 int netsnmp_cache_is_valid( netsnmp_agent_request_info *, 00072 const char *name); 00074 int netsnmp_is_cache_valid( netsnmp_agent_request_info *); 00075 netsnmp_mib_handler *netsnmp_get_cache_handler(int, NetsnmpCacheLoad *, 00076 NetsnmpCacheFree *, 00077 oid*, int); 00078 int netsnmp_register_cache_handler(netsnmp_handler_registration *reginfo, 00079 int, NetsnmpCacheLoad *, 00080 NetsnmpCacheFree *); 00081 00082 Netsnmp_Node_Handler netsnmp_cache_helper_handler; 00083 00084 netsnmp_cache * 00085 netsnmp_cache_create(int timeout, NetsnmpCacheLoad * load_hook, 00086 NetsnmpCacheFree * free_hook, 00087 oid * rootoid, int rootoid_len); 00088 netsnmp_mib_handler * 00089 netsnmp_cache_handler_get(netsnmp_cache* cache); 00090 00091 netsnmp_cache * netsnmp_cache_find_by_oid(oid * rootoid, 00092 int rootoid_len); 00093 00094 unsigned int netsnmp_cache_timer_start(netsnmp_cache *cache); 00095 void netsnmp_cache_timer_stop(netsnmp_cache *cache); 00096 00097 /* 00098 * Flags affecting cache handler operation 00099 */ 00100 #define NETSNMP_CACHE_DONT_INVALIDATE_ON_SET 0x0001 00101 #define NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD 0x0002 00102 #define NETSNMP_CACHE_DONT_FREE_EXPIRED 0x0004 00103 #define NETSNMP_CACHE_DONT_AUTO_RELEASE 0x0008 00104 #define NETSNMP_CACHE_PRELOAD 0x0010 00105 #define NETSNMP_CACHE_AUTO_RELOAD 0x0020 00106 00107 #define NETSNMP_CACHE_HINT_HANDLER_ARGS 0x1000 00108 00109 00110 #ifdef __cplusplus 00111 } 00112 #endif 00113 #endif /* NETSNMP_CACHE_HANDLER_H */