oid_stash.h
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:3k
源码类别:

SNMP编程

开发平台:

Unix_Linux

  1. #ifndef OID_STASH_H
  2. #define OID_STASH_H
  3. /*
  4.  * designed to store/retrieve information associated with a given oid.
  5.  * Storage is done in an efficient tree manner for fast lookups.
  6.  */
  7. #define OID_STASH_CHILDREN_SIZE 31
  8. #ifdef __cplusplus
  9. extern          "C" {
  10. #endif
  11.     struct netsnmp_oid_stash_node_s;
  12.     /* args: buffer, sizeof(buffer), yourdata, stashnode */
  13.     typedef int     (NetSNMPStashDump) (char *, size_t,
  14.                                         void *,
  15.                                         struct netsnmp_oid_stash_node_s *);
  16.     typedef void    (NetSNMPStashFreeNode) (void *);
  17.     
  18.     typedef struct netsnmp_oid_stash_node_s {
  19.         oid             value;
  20.         struct netsnmp_oid_stash_node_s **children;     /* array of children */
  21.         size_t          children_size;
  22.         struct netsnmp_oid_stash_node_s *next_sibling;  /* cache too small links */
  23.         struct netsnmp_oid_stash_node_s *prev_sibling;
  24.         struct netsnmp_oid_stash_node_s *parent; 
  25.         void           *thedata;
  26.     } netsnmp_oid_stash_node;
  27.     typedef struct netsnmp_oid_stash_save_info_s {
  28.        const char *token;
  29.        netsnmp_oid_stash_node **root;
  30.        NetSNMPStashDump *dumpfn;
  31.     } netsnmp_oid_stash_save_info;
  32.     int             netsnmp_oid_stash_add_data(netsnmp_oid_stash_node
  33.                                                **root, oid * lookup,
  34.                                                size_t lookup_len,
  35.                                                void *mydata);
  36.     SNMPCallback netsnmp_oid_stash_store_all;
  37.     netsnmp_oid_stash_node
  38.         *netsnmp_oid_stash_get_node(netsnmp_oid_stash_node *root,
  39.                                     oid * lookup, size_t lookup_len);
  40.     void           *netsnmp_oid_stash_get_data(netsnmp_oid_stash_node
  41.                                                *root, oid * lookup,
  42.                                                size_t lookup_len);
  43.     netsnmp_oid_stash_node *
  44.     netsnmp_oid_stash_getnext_node(netsnmp_oid_stash_node *root,
  45.                                    oid * lookup, size_t lookup_len);
  46.     netsnmp_oid_stash_node *netsnmp_oid_stash_create_sized_node(size_t
  47.                                                                 mysize);
  48.     netsnmp_oid_stash_node *netsnmp_oid_stash_create_node(void);        /* returns a malloced node */
  49.     void netsnmp_oid_stash_store(netsnmp_oid_stash_node *root,
  50.                                  const char *tokenname,
  51.                                  NetSNMPStashDump *dumpfn,
  52.                                  oid *curoid, size_t curoid_len);
  53.     /* frees all data in the stash and cleans it out.  Sets root = NULL */
  54.     void netsnmp_oid_stash_free(netsnmp_oid_stash_node **root,
  55.                                 NetSNMPStashFreeNode *freefn);
  56.                                 
  57.     /* a noop function that can be passed to netsnmp_oid_stash_node to
  58.        NOT free the data */
  59.     NetSNMPStashFreeNode netsnmp_oid_stash_no_free;
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif                          /* OID_STASH_H */