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