net-snmp 5.7
|
00001 #ifndef OID_STASH_H 00002 #define OID_STASH_H 00003 00004 /* 00005 * designed to store/retrieve information associated with a given oid. 00006 * Storage is done in an efficient tree manner for fast lookups. 00007 */ 00008 00009 #define OID_STASH_CHILDREN_SIZE 31 00010 00011 #ifdef __cplusplus 00012 extern "C" { 00013 #endif 00014 00015 struct netsnmp_oid_stash_node_s; 00016 00017 /* args: buffer, sizeof(buffer), yourdata, stashnode */ 00018 typedef int (NetSNMPStashDump) (char *, size_t, 00019 void *, 00020 struct netsnmp_oid_stash_node_s *); 00021 00022 typedef void (NetSNMPStashFreeNode) (void *); 00023 00024 typedef struct netsnmp_oid_stash_node_s { 00025 oid value; 00026 struct netsnmp_oid_stash_node_s **children; /* array of children */ 00027 size_t children_size; 00028 struct netsnmp_oid_stash_node_s *next_sibling; /* cache too small links */ 00029 struct netsnmp_oid_stash_node_s *prev_sibling; 00030 struct netsnmp_oid_stash_node_s *parent; 00031 00032 void *thedata; 00033 } netsnmp_oid_stash_node; 00034 00035 typedef struct netsnmp_oid_stash_save_info_s { 00036 const char *token; 00037 netsnmp_oid_stash_node **root; 00038 NetSNMPStashDump *dumpfn; 00039 } netsnmp_oid_stash_save_info; 00040 00041 NETSNMP_IMPORT 00042 int netsnmp_oid_stash_add_data(netsnmp_oid_stash_node **root, 00043 const oid * lookup, 00044 size_t lookup_len, 00045 void *mydata); 00046 SNMPCallback netsnmp_oid_stash_store_all; 00047 00048 00049 netsnmp_oid_stash_node 00050 *netsnmp_oid_stash_get_node(netsnmp_oid_stash_node *root, 00051 const oid * lookup, size_t lookup_len); 00052 NETSNMP_IMPORT 00053 void *netsnmp_oid_stash_get_data(netsnmp_oid_stash_node *root, 00054 const oid * lookup, 00055 size_t lookup_len); 00056 NETSNMP_IMPORT 00057 netsnmp_oid_stash_node * 00058 netsnmp_oid_stash_getnext_node(netsnmp_oid_stash_node *root, 00059 oid * lookup, size_t lookup_len); 00060 00061 netsnmp_oid_stash_node *netsnmp_oid_stash_create_sized_node(size_t 00062 mysize); 00063 netsnmp_oid_stash_node *netsnmp_oid_stash_create_node(void); /* returns a malloced node */ 00064 00065 void netsnmp_oid_stash_store(netsnmp_oid_stash_node *root, 00066 const char *tokenname, 00067 NetSNMPStashDump *dumpfn, 00068 oid *curoid, size_t curoid_len); 00069 00070 /* frees all data in the stash and cleans it out. Sets root = NULL */ 00071 NETSNMP_IMPORT 00072 void netsnmp_oid_stash_free(netsnmp_oid_stash_node **root, 00073 NetSNMPStashFreeNode *freefn); 00074 00075 00076 /* a noop function that can be passed to netsnmp_oid_stash_node to 00077 NOT free the data */ 00078 NetSNMPStashFreeNode netsnmp_oid_stash_no_free; 00079 #ifdef __cplusplus 00080 } 00081 #endif 00082 #endif /* OID_STASH_H */