parse.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. #ifndef PARSE_H
  2. #define PARSE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <net-snmp/mib_api.h>
  7. /*
  8. * parse.h
  9. */
  10. /***********************************************************
  11. Copyright 1989 by Carnegie Mellon University
  12. All Rights Reserved
  13. Permission to use, copy, modify, and distribute this software and its
  14. documentation for any purpose and without fee is hereby granted,
  15. provided that the above copyright notice appear in all copies and that
  16. both that copyright notice and this permission notice appear in
  17. supporting documentation, and that the name of CMU not be
  18. used in advertising or publicity pertaining to distribution of the
  19. software without specific, written prior permission.
  20. CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  21. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  22. CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  23. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  24. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  25. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  26. SOFTWARE.
  27. ******************************************************************/
  28. #define NETSNMP_MAXLABEL 64 /* maximum characters in a label */
  29. #define MAXTOKEN 128 /* maximum characters in a token */
  30. #define MAXQUOTESTR 4096 /* maximum characters in a quoted string */
  31. /*
  32. * MAXLABEL appears to be unused in code, and conflicts with
  33. * <arpa/nameser.h>. Only define it if requested. This will
  34. * cause problems if local DNSSEC validation is also enabled.
  35. */
  36. #ifdef UCD_COMPATIBLE
  37. #define MAXLABEL NETSNMP_MAXLABEL
  38. #endif
  39. struct variable_list;
  40. /*
  41. * A linked list of tag-value pairs for enumerated integers.
  42. */
  43. struct enum_list {
  44. struct enum_list *next;
  45. int value;
  46. char *label;
  47. };
  48. /*
  49. * A linked list of ranges
  50. */
  51. struct range_list {
  52. struct range_list *next;
  53. int low, high;
  54. };
  55. /*
  56. * A linked list of indexes
  57. */
  58. struct index_list {
  59. struct index_list *next;
  60. char *ilabel;
  61. char isimplied;
  62. };
  63. /*
  64. * A linked list of varbinds
  65. */
  66. struct varbind_list {
  67. struct varbind_list *next;
  68. char *vblabel;
  69. };
  70. /*
  71. * A tree in the format of the tree structure of the MIB.
  72. */
  73. struct tree {
  74. struct tree *child_list; /* list of children of this node */
  75. struct tree *next_peer; /* Next node in list of peers */
  76. struct tree *next; /* Next node in hashed list of names */
  77. struct tree *parent;
  78. char *label; /* This node's textual name */
  79. u_long subid; /* This node's integer subidentifier */
  80. int modid; /* The module containing this node */
  81. int number_modules;
  82. int *module_list; /* To handle multiple modules */
  83. int tc_index; /* index into tclist (-1 if NA) */
  84. int type; /* This node's object type */
  85. int access; /* This nodes access */
  86. int status; /* This nodes status */
  87. struct enum_list *enums; /* (optional) list of enumerated integers */
  88. struct range_list *ranges;
  89. struct index_list *indexes;
  90. char *augments;
  91. struct varbind_list *varbinds;
  92. char *hint;
  93. char *units;
  94. int (*printomat) (u_char **, size_t *, size_t *, int,
  95. const netsnmp_variable_list *,
  96. const struct enum_list *, const char *,
  97. const char *);
  98. void (*printer) (char *, const netsnmp_variable_list *, const struct enum_list *, const char *, const char *); /* Value printing function */
  99. char *description; /* description (a quoted string) */
  100. char *reference; /* references (a quoted string) */
  101. int reported; /* 1=report started in print_subtree... */
  102. char *defaultValue;
  103. char *parseErrorString; /* Contains the error string if there are errors in parsing MIBs */
  104. };
  105. /*
  106. * Information held about each MIB module
  107. */
  108. struct module_import {
  109. char *label; /* The descriptor being imported */
  110. int modid; /* The module imported from */
  111. };
  112. struct module {
  113. char *name; /* This module's name */
  114. char *file; /* The file containing the module */
  115. struct module_import *imports; /* List of descriptors being imported */
  116. int no_imports; /* The number of such import descriptors */
  117. /*
  118. * -1 implies the module hasn't been read in yet
  119. */
  120. int modid; /* The index number of this module */
  121. struct module *next; /* Linked list pointer */
  122. };
  123. struct module_compatability {
  124. const char *old_module;
  125. const char *new_module;
  126. const char *tag; /* NULL implies unconditional replacement,
  127. * otherwise node identifier or prefix */
  128. size_t tag_len; /* 0 implies exact match (or unconditional) */
  129. struct module_compatability *next; /* linked list */
  130. };
  131. /*
  132. * non-aggregate types for tree end nodes
  133. */
  134. #define TYPE_OTHER 0
  135. #define TYPE_OBJID 1
  136. #define TYPE_OCTETSTR 2
  137. #define TYPE_INTEGER 3
  138. #define TYPE_NETADDR 4
  139. #define TYPE_IPADDR 5
  140. #define TYPE_COUNTER 6
  141. #define TYPE_GAUGE 7
  142. #define TYPE_TIMETICKS 8
  143. #define TYPE_OPAQUE 9
  144. #define TYPE_NULL 10
  145. #define TYPE_COUNTER64 11
  146. #define TYPE_BITSTRING 12
  147. #define TYPE_NSAPADDRESS 13
  148. #define TYPE_UINTEGER 14
  149. #define TYPE_UNSIGNED32 15
  150. #define TYPE_INTEGER32 16
  151. #define TYPE_SIMPLE_LAST 16
  152. #define TYPE_TRAPTYPE 20
  153. #define TYPE_NOTIFTYPE 21
  154. #define TYPE_OBJGROUP 22
  155. #define TYPE_NOTIFGROUP 23
  156. #define TYPE_MODID 24
  157. #define TYPE_AGENTCAP 25
  158. #define TYPE_MODCOMP 26
  159. #define TYPE_OBJIDENTITY 27
  160. #define MIB_ACCESS_READONLY 18
  161. #define MIB_ACCESS_READWRITE 19
  162. #define MIB_ACCESS_WRITEONLY 20
  163. #define MIB_ACCESS_NOACCESS 21
  164. #define MIB_ACCESS_NOTIFY 67
  165. #define MIB_ACCESS_CREATE 48
  166. #define MIB_STATUS_MANDATORY 23
  167. #define MIB_STATUS_OPTIONAL 24
  168. #define MIB_STATUS_OBSOLETE 25
  169. #define MIB_STATUS_DEPRECATED 39
  170. #define MIB_STATUS_CURRENT 57
  171. #define ANON "anonymous#"
  172. #define ANON_LEN strlen(ANON)
  173. int netsnmp_unload_module(const char *name);
  174. #ifndef NETSNMP_NO_LEGACY_DEFINITIONS
  175. int unload_module(const char *name);
  176. #endif
  177. void netsnmp_init_mib_internals(void);
  178. void unload_all_mibs(void);
  179. int add_mibfile(const char*, const char*);
  180. int which_module(const char *);
  181. NETSNMP_IMPORT
  182. char *module_name(int, char *);
  183. NETSNMP_IMPORT
  184. void print_subtree(FILE *, struct tree *, int);
  185. NETSNMP_IMPORT
  186. void print_ascii_dump_tree(FILE *, struct tree *, int);
  187. NETSNMP_IMPORT
  188. struct tree *find_tree_node(const char *, int);
  189. NETSNMP_IMPORT
  190. const char *get_tc_descriptor(int);
  191. NETSNMP_IMPORT
  192. const char *get_tc_description(int);
  193. NETSNMP_IMPORT
  194. struct tree *find_best_tree_node(const char *, struct tree *,
  195. u_int *);
  196. /*
  197. * backwards compatability
  198. */
  199. NETSNMP_IMPORT
  200. struct tree *find_node(const char *, struct tree *);
  201. struct tree *find_node2(const char *, const char *);
  202. NETSNMP_IMPORT
  203. struct module *find_module(int);
  204. void adopt_orphans(void);
  205. NETSNMP_IMPORT
  206. char *snmp_mib_toggle_options(char *options);
  207. NETSNMP_IMPORT
  208. void snmp_mib_toggle_options_usage(const char *lead,
  209. FILE * outf);
  210. NETSNMP_IMPORT
  211. void print_mib(FILE *);
  212. NETSNMP_IMPORT
  213. void print_mib_tree(FILE *, struct tree *, int);
  214. int get_mib_parse_error_count(void);
  215. NETSNMP_IMPORT
  216. int snmp_get_token(FILE * fp, char *token, int maxtlen);
  217. NETSNMP_IMPORT
  218. struct tree *find_best_tree_node(const char *name,
  219. struct tree *tree_top,
  220. u_int * match);
  221. #ifdef __cplusplus
  222. }
  223. #endif
  224. #endif /* PARSE_H */