net-snmp
5.4.1
|
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 int netsnmp_oid_stash_add_data(netsnmp_oid_stash_node 00042 **root, oid * lookup, 00043 size_t lookup_len, 00044 void *mydata); 00045 SNMPCallback netsnmp_oid_stash_store_all; 00046 00047 00048 netsnmp_oid_stash_node 00049 *netsnmp_oid_stash_get_node(netsnmp_oid_stash_node *root, 00050 oid * lookup, size_t lookup_len); 00051 void *netsnmp_oid_stash_get_data(netsnmp_oid_stash_node 00052 *root, oid * lookup, 00053 size_t lookup_len); 00054 netsnmp_oid_stash_node * 00055 netsnmp_oid_stash_getnext_node(netsnmp_oid_stash_node *root, 00056 oid * lookup, size_t lookup_len); 00057 00058 netsnmp_oid_stash_node *netsnmp_oid_stash_create_sized_node(size_t 00059 mysize); 00060 netsnmp_oid_stash_node *netsnmp_oid_stash_create_node(void); /* returns a malloced node */ 00061 00062 void netsnmp_oid_stash_store(netsnmp_oid_stash_node *root, 00063 const char *tokenname, 00064 NetSNMPStashDump *dumpfn, 00065 oid *curoid, size_t curoid_len); 00066 00067 /* frees all data in the stash and cleans it out. Sets root = NULL */ 00068 void netsnmp_oid_stash_free(netsnmp_oid_stash_node **root, 00069 NetSNMPStashFreeNode *freefn); 00070 00071 00072 /* a noop function that can be passed to netsnmp_oid_stash_node to 00073 NOT free the data */ 00074 NetSNMPStashFreeNode netsnmp_oid_stash_no_free; 00075 #ifdef __cplusplus 00076 } 00077 #endif 00078 #endif /* OID_STASH_H */