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

SNMP编程

开发平台:

Unix_Linux

  1. #ifndef MIB_H
  2. #define MIB_H
  3. #ifdef __cplusplus
  4. extern          "C" {
  5. #endif
  6.     /*
  7.      * mib.h - Definitions for the variables as defined in the MIB
  8.      *
  9.      * Update: 1998-07-17 <jhy@gsu.edu>
  10.      * Added prototypes for print_oid_report* functions.
  11.      */
  12. /***********************************************************
  13. Copyright 1988, 1989 by Carnegie Mellon University
  14.                       All Rights Reserved
  15. Permission to use, copy, modify, and distribute this software and its 
  16. documentation for any purpose and without fee is hereby granted, 
  17. provided that the above copyright notice appear in all copies and that
  18. both that copyright notice and this permission notice appear in 
  19. supporting documentation, and that the name of CMU not be
  20. used in advertising or publicity pertaining to distribution of the
  21. software without specific, written prior permission.  
  22. CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  23. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  24. CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  25. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  26. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  27. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  28. SOFTWARE.
  29. ******************************************************************/
  30. #include <stdio.h>              /* for FILE */
  31. #define MIB 1, 3, 6, 1, 2, 1
  32. #define MIB_IFTYPE_OTHER     1
  33. #define MIB_IFTYPE_REGULAR1822     2
  34. #define MIB_IFTYPE_HDH1822     3
  35. #define MIB_IFTYPE_DDNX25     4
  36. #define MIB_IFTYPE_RFC877X25     5
  37. #define MIB_IFTYPE_ETHERNETCSMACD     6
  38. #define MIB_IFTYPE_ISO88023CSMACD     7
  39. #define MIB_IFTYPE_ISO88024TOKENBUS     8
  40. #define MIB_IFTYPE_ISO88025TOKENRING     9
  41. #define MIB_IFTYPE_ISO88026MAN     10
  42. #define MIB_IFTYPE_STARLAN     11
  43. #define MIB_IFTYPE_PROTEON10MBIT     12
  44. #define MIB_IFTYPE_PROTEON80MBIT     13
  45. #define MIB_IFTYPE_HYPERCHANNEL     14
  46. #define MIB_IFTYPE_FDDI     15
  47. #define MIB_IFTYPE_LAPB     16
  48. #define MIB_IFTYPE_SDLC     17
  49. #define MIB_IFTYPE_T1CARRIER     18
  50. #define MIB_IFTYPE_CEPT     19
  51. #define MIB_IFTYPE_BASICISDN     20
  52. #define MIB_IFTYPE_PRIMARYISDN     21
  53. #define MIB_IFTYPE_PROPPOINTTOPOINTSERIAL   22
  54. #define MIB_IFSTATUS_UP 1
  55. #define MIB_IFSTATUS_DOWN 2
  56. #define MIB_IFSTATUS_TESTING 3
  57. #define MIB_FORWARD_GATEWAY 1
  58. #define MIB_FORWARD_HOST 2
  59. #define MIB_IPROUTETYPE_OTHER 1
  60. #define MIB_IPROUTETYPE_INVALID 2
  61. #define MIB_IPROUTETYPE_DIRECT 3
  62. #define MIB_IPROUTETYPE_REMOTE 4
  63. #define MIB_IPROUTEPROTO_OTHER     1
  64. #define MIB_IPROUTEPROTO_LOCAL     2
  65. #define MIB_IPROUTEPROTO_NETMGMT    3
  66. #define MIB_IPROUTEPROTO_ICMP     4
  67. #define MIB_IPROUTEPROTO_EGP     5
  68. #define MIB_IPROUTEPROTO_GGP     6
  69. #define MIB_IPROUTEPROTO_HELLO     7
  70. #define MIB_IPROUTEPROTO_RIP     8
  71. #define MIB_IPROUTEPROTO_ISIS     9
  72. #define MIB_IPROUTEPROTO_ESIS     10
  73. #define MIB_IPROUTEPROTO_CISCOIGRP  11
  74. #define MIB_IPROUTEPROTO_BBNSPFIGP  12
  75. #define MIB_IPROUTEPROTO_OIGP     13
  76. #define MIB_TCPRTOALG_OTHER 1
  77. #define MIB_TCPRTOALG_CONSTANT 2
  78. #define MIB_TCPRTOALG_RSRE 3
  79. #define MIB_TCPRTOALG_VANJ 4
  80. #define MIB_TCPCONNSTATE_CLOSED 1
  81. #define MIB_TCPCONNSTATE_LISTEN 2
  82. #define MIB_TCPCONNSTATE_SYNSENT 3
  83. #define MIB_TCPCONNSTATE_SYNRECEIVED 4
  84. #define MIB_TCPCONNSTATE_ESTABLISHED 5
  85. #define MIB_TCPCONNSTATE_FINWAIT1 6
  86. #define MIB_TCPCONNSTATE_FINWAIT2 7
  87. #define MIB_TCPCONNSTATE_CLOSEWAIT 8
  88. #define MIB_TCPCONNSTATE_LASTACK 9
  89. #define MIB_TCPCONNSTATE_CLOSING 10
  90. #define MIB_TCPCONNSTATE_TIMEWAIT 11
  91. #define MIB_EGPNEIGHSTATE_IDLE 1
  92. #define MIB_EGPNEIGHSTATE_AQUISITION 2
  93. #define MIB_EGPNEIGHSTATE_DOWN 3
  94. #define MIB_EGPNEIGHSTATE_UP 4
  95. #define MIB_EGPNEIGHSTATE_CEASE 5
  96.     struct variable_list;
  97.     struct enum_list;
  98.     void            print_mib(FILE * fp);
  99.     void            print_ascii_dump(FILE *);
  100.     int             read_objid(const char *, oid *, size_t *);
  101.     void            register_mib_handlers(void);
  102.     void            netsnmp_set_mib_directory(const char *dir);
  103.     char            *netsnmp_get_mib_directory(void);
  104.     void            netsnmp_fixup_mib_directory(void);
  105.     void            init_mib(void);
  106.     void            shutdown_mib(void);
  107.     void            print_description(oid *, size_t, int);
  108.     void            fprint_description(FILE *, oid *, size_t, int);
  109.     int             snprint_description(char *, size_t, oid *, size_t, int);
  110.     int             sprint_realloc_description(u_char **, size_t *, size_t *,
  111.                                                int, oid *, size_t, int);
  112.     int             get_module_node(const char *, const char *, oid *,
  113.                                     size_t *);
  114.     int             get_wild_node(const char *, oid *, size_t *);
  115.     int             get_node(const char *, oid *, size_t *);
  116.     oid            *snmp_parse_oid(const char *, oid *, size_t *);
  117.     struct tree    *get_symbol(oid *, size_t, struct tree *, char *);
  118.     struct tree    *get_tree(const oid *, size_t, struct tree *);
  119.     struct tree    *get_tree_head(void);
  120.     void            set_function(struct tree *);
  121.     int             parse_one_oid_index(oid ** oidStart, size_t * oidLen,
  122.                                         netsnmp_variable_list * data,
  123.                                         int complete);
  124.     int             parse_oid_indexes(oid * oidIndex, size_t oidLen,
  125.                                       netsnmp_variable_list * data);
  126.     int             build_oid_noalloc(oid * in, size_t in_len,
  127.                                       size_t * out_len, oid * prefix,
  128.                                       size_t prefix_len,
  129.                                       netsnmp_variable_list * indexes);
  130.     int             build_oid(oid ** out, size_t * out_len, oid * prefix,
  131.                               size_t prefix_len,
  132.                               netsnmp_variable_list * indexes);
  133.     int             build_oid_segment(netsnmp_variable_list * var);
  134.     void            print_variable(const oid * objid, size_t objidlen,
  135.                                    const netsnmp_variable_list * variable);
  136.     void            fprint_variable(FILE * fp,
  137.                                     const oid * objid, size_t objidlen,
  138.                                     const netsnmp_variable_list * variable);
  139.     int             snprint_variable(char *buf, size_t buf_len,
  140.                                      const oid * objid, size_t objidlen,
  141.                                      const netsnmp_variable_list * variable);
  142.     int             sprint_realloc_variable(u_char ** buf,
  143.                                             size_t * buf_len,
  144.                                             size_t * out_len,
  145.                                             int allow_realloc,
  146.                                             const oid * objid,
  147.                                             size_t objidlen,
  148.                                             const netsnmp_variable_list *
  149.                                             variable);
  150. #ifndef DISABLE_MIB_LOADING
  151.     struct tree    *
  152. #else
  153.     void
  154. #endif
  155.                     netsnmp_sprint_realloc_objid_tree(u_char ** buf,
  156.                                                       size_t * buf_len,
  157.                                                       size_t * out_len,
  158.                                                       int allow_realloc,
  159.                                                       int *buf_overflow,
  160.                                                       const oid * objid,
  161.                                                       size_t objidlen);
  162.     void
  163.                     netsnmp_sprint_realloc_objid(u_char ** buf,
  164.                                                  size_t * buf_len,
  165.                                                  size_t * out_len,
  166.                                                  int allow_realloc,
  167.                                                  int *buf_overflow,
  168.                                                  const oid * objid,
  169.                                                  size_t objidlen);
  170.     void            print_value(const oid * objid, size_t objidlen,
  171.                                 const netsnmp_variable_list * variable);
  172.     void            fprint_value(FILE * fp,
  173.                                  const oid * objid, size_t objidlen,
  174.                                  const netsnmp_variable_list * variable);
  175.     int             snprint_value(char *buf, size_t buf_len,
  176.                                   const oid * objid, size_t objidlen,
  177.                                   const netsnmp_variable_list * variable);
  178.     int             sprint_realloc_value(u_char ** buf, size_t * buf_len,
  179.                                          size_t * out_len,
  180.                                          int allow_realloc,
  181.                                          const oid * objid,
  182.                                          size_t objidlen,
  183.                                          const netsnmp_variable_list * variable);
  184.     void            print_objid(const oid * objid, size_t objidlen);
  185.     void            fprint_objid(FILE * fp,
  186.                                  const oid * objid, size_t objidlen);
  187.     int             snprint_objid(char *buf, size_t buf_len,
  188.                                   const oid * objid, size_t objidlen);
  189.     int             sprint_realloc_objid(u_char ** buf, size_t * buf_len,
  190.                                          size_t * out_len,
  191.                                          int allow_realloc,
  192.                                          const oid * objid,
  193.                                          size_t objidlen);
  194.     int             sprint_realloc_by_type(u_char ** buf, size_t * buf_len,
  195.                                            size_t * out_len,
  196.                                            int allow_realloc,
  197.                                            const netsnmp_variable_list * var,
  198.                                            const struct enum_list *enums,
  199.                                            const char *hint,
  200.                                            const char *units);
  201.     int             sprint_realloc_hexstring(u_char ** buf,
  202.                                              size_t * buf_len,
  203.                                              size_t * out_len,
  204.                                              int allow_realloc,
  205.                                              const u_char *, size_t);
  206.     int             sprint_realloc_asciistring(u_char ** buf,
  207.                                                size_t * buf_len,
  208.                                                size_t * out_len,
  209.                                                int allow_realloc,
  210.                                                const u_char * cp,
  211.                                                size_t len);
  212.     int             sprint_realloc_octet_string(u_char ** buf,
  213.                                                 size_t * buf_len,
  214.                                                 size_t * out_len,
  215.                                                 int allow_realloc,
  216.                                                 const netsnmp_variable_list *,
  217.                                                 const struct enum_list *,
  218.                                                 const char *,
  219.                                                 const char *);
  220.     int             sprint_realloc_opaque(u_char ** buf, size_t * buf_len,
  221.                                           size_t * out_len,
  222.                                           int allow_realloc,
  223.                                           const netsnmp_variable_list *,
  224.                                           const struct enum_list *, const char *,
  225.                                           const char *);
  226.     int             sprint_realloc_object_identifier(u_char ** buf,
  227.                                                      size_t * buf_len,
  228.                                                      size_t * out_len,
  229.                                                      int allow_realloc,
  230.                                                      const netsnmp_variable_list
  231.                                                      *, const struct enum_list *,
  232.                                                      const char *,
  233.                                                      const char *);
  234.     int             sprint_realloc_timeticks(u_char ** buf,
  235.                                              size_t * buf_len,
  236.                                              size_t * out_len,
  237.                                              int allow_realloc,
  238.                                              const netsnmp_variable_list *,
  239.                                              const struct enum_list *,
  240.                                              const char *, const char *);
  241.     int             sprint_realloc_hinted_integer(u_char ** buf,
  242.                                                   size_t * buf_len,
  243.                                                   size_t * out_len,
  244.                                                   int allow_realloc, long,
  245.                                                   const char, const char *,
  246.                                                   const char *);
  247.     int             sprint_realloc_integer(u_char ** buf, size_t * buf_len,
  248.                                            size_t * out_len,
  249.                                            int allow_realloc,
  250.                                            const netsnmp_variable_list *,
  251.                                            const struct enum_list *,
  252.                                            const char *, const char *);
  253.     int             sprint_realloc_uinteger(u_char ** buf,
  254.                                             size_t * buf_len,
  255.                                             size_t * out_len,
  256.                                             int allow_realloc,
  257.                                             const netsnmp_variable_list *,
  258.                                             const struct enum_list *,
  259.                                             const char *, const char *);
  260.     int             sprint_realloc_gauge(u_char ** buf, size_t * buf_len,
  261.                                          size_t * out_len,
  262.                                          int allow_realloc,
  263.                                          const netsnmp_variable_list *,
  264.                                          const struct enum_list *, const char *,
  265.                                          const char *);
  266.     int             sprint_realloc_counter(u_char ** buf, size_t * buf_len,
  267.                                            size_t * out_len,
  268.                                            int allow_realloc,
  269.                                            const netsnmp_variable_list *,
  270.                                            const struct enum_list *,
  271.                                            const char *, const char *);
  272.     int             sprint_realloc_networkaddress(u_char ** buf,
  273.                                                   size_t * buf_len,
  274.                                                   size_t * out_len,
  275.                                                   int allow_realloc,
  276.                                                   const netsnmp_variable_list *,
  277.                                                   const struct enum_list *,
  278.                                                   const char *,
  279.                                                   const char *);
  280.     int             sprint_realloc_ipaddress(u_char ** buf,
  281.                                              size_t * buf_len,
  282.                                              size_t * out_len,
  283.                                              int allow_realloc,
  284.                                              const netsnmp_variable_list *,
  285.                                              const struct enum_list *,
  286.                                              const char *, const char *);
  287.     int             sprint_realloc_null(u_char ** buf, size_t * buf_len,
  288.                                         size_t * out_len,
  289.                                         int allow_realloc,
  290.                                         const netsnmp_variable_list *,
  291.                                         const struct enum_list *, const char *,
  292.                                         const char *);
  293.     int             sprint_realloc_bitstring(u_char ** buf,
  294.                                              size_t * buf_len,
  295.                                              size_t * out_len,
  296.                                              int allow_realloc,
  297.                                              const netsnmp_variable_list *,
  298.                                              const struct enum_list *,
  299.                                              const char *, const char *);
  300.     int             sprint_realloc_nsapaddress(u_char ** buf,
  301.                                                size_t * buf_len,
  302.                                                size_t * out_len,
  303.                                                int allow_realloc,
  304.                                                const netsnmp_variable_list *,
  305.                                                const struct enum_list *,
  306.                                                const char *, const char *);
  307.     int             sprint_realloc_counter64(u_char ** buf,
  308.                                              size_t * buf_len,
  309.                                              size_t * out_len,
  310.                                              int allow_realloc,
  311.                                              const netsnmp_variable_list *,
  312.                                              const struct enum_list *,
  313.                                              const char *, const char *);
  314.     int             sprint_realloc_badtype(u_char ** buf, size_t * buf_len,
  315.                                            size_t * out_len,
  316.                                            int allow_realloc,
  317.                                            const netsnmp_variable_list *,
  318.                                            const struct enum_list *,
  319.                                            const char *, const char *);
  320. #ifdef OPAQUE_SPECIAL_TYPES
  321.     int             sprint_realloc_float(u_char ** buf, size_t * buf_len,
  322.                                          size_t * out_len,
  323.                                          int allow_realloc,
  324.                                          const netsnmp_variable_list *,
  325.                                          const struct enum_list *, const char *,
  326.                                          const char *);
  327.     int             sprint_realloc_double(u_char ** buf, size_t * buf_len,
  328.                                           size_t * out_len,
  329.                                           int allow_realloc,
  330.                                           const netsnmp_variable_list *,
  331.                                           const struct enum_list *, const char *,
  332.                                           const char *);
  333. #endif
  334.     int             snprint_by_type(char *buf, size_t buf_len,
  335.                                     netsnmp_variable_list * var,
  336.                                     const struct enum_list *enums,
  337.                                     const char *hint, const char *units);
  338.     int             snprint_hexstring(char *buf, size_t buf_len,
  339.                                       const u_char *, size_t);
  340.     int             snprint_asciistring(char *buf, size_t buf_len,
  341.                                         const u_char * cp, size_t len);
  342.     int             snprint_octet_string(char *buf, size_t buf_len,
  343.                                          const netsnmp_variable_list *,
  344.                                          const struct enum_list *, const char *,
  345.                                          const char *);
  346.     int             snprint_opaque(char *buf, size_t buf_len,
  347.                                    const netsnmp_variable_list *,
  348.                                    const struct enum_list *, const char *,
  349.                                    const char *);
  350.     int             snprint_object_identifier(char *buf, size_t buf_len,
  351.                                               const netsnmp_variable_list *,
  352.                                               const struct enum_list *,
  353.                                               const char *, const char *);
  354.     int             snprint_timeticks(char *buf, size_t buf_len,
  355.                                       const netsnmp_variable_list *,
  356.                                       const struct enum_list *, const char *,
  357.                                       const char *);
  358.     int             snprint_hinted_integer(char *buf, size_t buf_len,
  359.                                            long, const char *,
  360.                                            const char *);
  361.     int             snprint_integer(char *buf, size_t buf_len,
  362.                                     const netsnmp_variable_list *,
  363.                                     const struct enum_list *, const char *,
  364.                                     const char *);
  365.     int             snprint_uinteger(char *buf, size_t buf_len,
  366.                                      const netsnmp_variable_list *,
  367.                                      const struct enum_list *, const char *,
  368.                                      const char *);
  369.     int             snprint_gauge(char *buf, size_t buf_len,
  370.                                   const netsnmp_variable_list *,
  371.                                   const struct enum_list *, const char *,
  372.                                   const char *);
  373.     int             snprint_counter(char *buf, size_t buf_len,
  374.                                     const netsnmp_variable_list *,
  375.                                     const struct enum_list *, const char *,
  376.                                     const char *);
  377.     int             snprint_networkaddress(char *buf, size_t buf_len,
  378.                                            const netsnmp_variable_list *,
  379.                                            const struct enum_list *,
  380.                                            const char *, const char *);
  381.     int             snprint_ipaddress(char *buf, size_t buf_len,
  382.                                       const netsnmp_variable_list *,
  383.                                       const struct enum_list *, const char *,
  384.                                       const char *);
  385.     int             snprint_null(char *buf, size_t buf_len,
  386.                                  const netsnmp_variable_list *,
  387.                                  const struct enum_list *, const char *,
  388.                                  const char *);
  389.     int             snprint_bitstring(char *buf, size_t buf_len,
  390.                                       const netsnmp_variable_list *,
  391.                                       const struct enum_list *, const char *,
  392.                                       const char *);
  393.     int             snprint_nsapaddress(char *buf, size_t buf_len,
  394.                                         const netsnmp_variable_list *,
  395.                                         const struct enum_list *, const char *,
  396.                                         const char *);
  397.     int             snprint_counter64(char *buf, size_t buf_len,
  398.                                       const netsnmp_variable_list *,
  399.                                       const struct enum_list *, const char *,
  400.                                       const char *);
  401.     int             snprint_badtype(char *buf, size_t buf_len,
  402.                                     const netsnmp_variable_list *,
  403.                                     const struct enum_list *, const char *,
  404.                                     const char *);
  405. #ifdef OPAQUE_SPECIAL_TYPES
  406.     int             snprint_float(char *buf, size_t buf_len,
  407.                                   const netsnmp_variable_list *,
  408.                                   const struct enum_list *, const char *,
  409.                                   const char *);
  410.     int             snprint_double(char *buf, size_t buf_len,
  411.                                    const netsnmp_variable_list *,
  412.                                    const struct enum_list *, const char *,
  413.                                    const char *);
  414. #endif
  415.     void            print_oid_report(FILE *);
  416.     void            print_oid_report_enable_labeledoid(void);
  417.     void            print_oid_report_enable_oid(void);
  418.     void            print_oid_report_enable_suffix(void);
  419.     void            print_oid_report_enable_symbolic(void);
  420.     const char     *parse_octet_hint(const char *hint, const char *value,
  421.                              unsigned char **new_val, int *new_val_len);
  422.     void            clear_tree_flags(register struct tree *tp);
  423.     char           *snmp_out_toggle_options(char *);
  424.     void            snmp_out_toggle_options_usage(const char *, FILE *);
  425.     char           *snmp_in_toggle_options(char *);
  426.     char           *snmp_in_options(char *, int, char * const *);
  427.     void            snmp_in_toggle_options_usage(const char *, FILE *);
  428.     u_char          mib_to_asn_type(int mib_type);
  429.     int             netsnmp_str2oid(const char *S, oid * O, int L);
  430. #define NETSNMP_STRING_OUTPUT_GUESS  1
  431. #define NETSNMP_STRING_OUTPUT_ASCII  2
  432. #define NETSNMP_STRING_OUTPUT_HEX    3
  433. #define NETSNMP_OID_OUTPUT_SUFFIX  1
  434. #define NETSNMP_OID_OUTPUT_MODULE  2
  435. #define NETSNMP_OID_OUTPUT_FULL    3
  436. #define NETSNMP_OID_OUTPUT_NUMERIC 4
  437. #define NETSNMP_OID_OUTPUT_UCD     5
  438. #define NETSNMP_OID_OUTPUT_NONE    6
  439. #ifdef __cplusplus
  440. }
  441. #endif
  442. #endif                          /* MIB_H */