net-snmp
5.4.1
|
00001 #ifndef PARSE_H 00002 #define PARSE_H 00003 00004 #ifdef __cplusplus 00005 extern "C" { 00006 #endif 00007 /* 00008 * parse.h 00009 */ 00010 /*********************************************************** 00011 Copyright 1989 by Carnegie Mellon University 00012 00013 All Rights Reserved 00014 00015 Permission to use, copy, modify, and distribute this software and its 00016 documentation for any purpose and without fee is hereby granted, 00017 provided that the above copyright notice appear in all copies and that 00018 both that copyright notice and this permission notice appear in 00019 supporting documentation, and that the name of CMU not be 00020 used in advertising or publicity pertaining to distribution of the 00021 software without specific, written prior permission. 00022 00023 CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 00024 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 00025 CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 00026 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 00027 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 00028 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 00029 SOFTWARE. 00030 ******************************************************************/ 00031 00032 #define MAXLABEL 64 /* maximum characters in a label */ 00033 #define MAXTOKEN 128 /* maximum characters in a token */ 00034 #define MAXQUOTESTR 4096 /* maximum characters in a quoted string */ 00035 00036 struct variable_list; 00037 00038 /* 00039 * A linked list of tag-value pairs for enumerated integers. 00040 */ 00041 struct enum_list { 00042 struct enum_list *next; 00043 int value; 00044 char *label; 00045 }; 00046 00047 /* 00048 * A linked list of ranges 00049 */ 00050 struct range_list { 00051 struct range_list *next; 00052 int low, high; 00053 }; 00054 00055 /* 00056 * A linked list of indexes 00057 */ 00058 struct index_list { 00059 struct index_list *next; 00060 char *ilabel; 00061 char isimplied; 00062 }; 00063 00064 /* 00065 * A linked list of varbinds 00066 */ 00067 struct varbind_list { 00068 struct varbind_list *next; 00069 char *vblabel; 00070 }; 00071 00072 /* 00073 * A linked list of nodes. 00074 */ 00075 struct node { 00076 struct node *next; 00077 char *label; /* This node's (unique) textual name */ 00078 u_long subid; /* This node's integer subidentifier */ 00079 int modid; /* The module containing this node */ 00080 char *parent; /* The parent's textual name */ 00081 int tc_index; /* index into tclist (-1 if NA) */ 00082 int type; /* The type of object this represents */ 00083 int access; 00084 int status; 00085 struct enum_list *enums; /* (optional) list of enumerated integers */ 00086 struct range_list *ranges; 00087 struct index_list *indexes; 00088 char *augments; 00089 struct varbind_list *varbinds; 00090 char *hint; 00091 char *units; 00092 char *description; /* description (a quoted string) */ 00093 char *reference; /* references (a quoted string) */ 00094 char *defaultValue; 00095 char *filename; 00096 int lineno; 00097 }; 00098 00099 /* 00100 * A tree in the format of the tree structure of the MIB. 00101 */ 00102 struct tree { 00103 struct tree *child_list; /* list of children of this node */ 00104 struct tree *next_peer; /* Next node in list of peers */ 00105 struct tree *next; /* Next node in hashed list of names */ 00106 struct tree *parent; 00107 char *label; /* This node's textual name */ 00108 u_long subid; /* This node's integer subidentifier */ 00109 int modid; /* The module containing this node */ 00110 int number_modules; 00111 int *module_list; /* To handle multiple modules */ 00112 int tc_index; /* index into tclist (-1 if NA) */ 00113 int type; /* This node's object type */ 00114 int access; /* This nodes access */ 00115 int status; /* This nodes status */ 00116 struct enum_list *enums; /* (optional) list of enumerated integers */ 00117 struct range_list *ranges; 00118 struct index_list *indexes; 00119 char *augments; 00120 struct varbind_list *varbinds; 00121 char *hint; 00122 char *units; 00123 int (*printomat) (u_char **, size_t *, size_t *, int, 00124 const netsnmp_variable_list *, 00125 const struct enum_list *, const char *, 00126 const char *); 00127 void (*printer) (char *, const netsnmp_variable_list *, const struct enum_list *, const char *, const char *); /* Value printing function */ 00128 char *description; /* description (a quoted string) */ 00129 char *reference; /* references (a quoted string) */ 00130 int reported; /* 1=report started in print_subtree... */ 00131 char *defaultValue; 00132 }; 00133 00134 /* 00135 * Information held about each MIB module 00136 */ 00137 struct module_import { 00138 char *label; /* The descriptor being imported */ 00139 int modid; /* The module imported from */ 00140 }; 00141 00142 struct module { 00143 char *name; /* This module's name */ 00144 char *file; /* The file containing the module */ 00145 struct module_import *imports; /* List of descriptors being imported */ 00146 int no_imports; /* The number of such import descriptors */ 00147 /* 00148 * -1 implies the module hasn't been read in yet 00149 */ 00150 int modid; /* The index number of this module */ 00151 struct module *next; /* Linked list pointer */ 00152 }; 00153 00154 struct module_compatability { 00155 const char *old_module; 00156 const char *new_module; 00157 const char *tag; /* NULL implies unconditional replacement, 00158 * otherwise node identifier or prefix */ 00159 size_t tag_len; /* 0 implies exact match (or unconditional) */ 00160 struct module_compatability *next; /* linked list */ 00161 }; 00162 00163 00164 /* 00165 * non-aggregate types for tree end nodes 00166 */ 00167 #define TYPE_OTHER 0 00168 #define TYPE_OBJID 1 00169 #define TYPE_OCTETSTR 2 00170 #define TYPE_INTEGER 3 00171 #define TYPE_NETADDR 4 00172 #define TYPE_IPADDR 5 00173 #define TYPE_COUNTER 6 00174 #define TYPE_GAUGE 7 00175 #define TYPE_TIMETICKS 8 00176 #define TYPE_OPAQUE 9 00177 #define TYPE_NULL 10 00178 #define TYPE_COUNTER64 11 00179 #define TYPE_BITSTRING 12 00180 #define TYPE_NSAPADDRESS 13 00181 #define TYPE_UINTEGER 14 00182 #define TYPE_UNSIGNED32 15 00183 #define TYPE_INTEGER32 16 00184 00185 #define TYPE_SIMPLE_LAST 16 00186 00187 #define TYPE_TRAPTYPE 20 00188 #define TYPE_NOTIFTYPE 21 00189 #define TYPE_OBJGROUP 22 00190 #define TYPE_NOTIFGROUP 23 00191 #define TYPE_MODID 24 00192 #define TYPE_AGENTCAP 25 00193 #define TYPE_MODCOMP 26 00194 #define TYPE_OBJIDENTITY 27 00195 00196 #define MIB_ACCESS_READONLY 18 00197 #define MIB_ACCESS_READWRITE 19 00198 #define MIB_ACCESS_WRITEONLY 20 00199 #define MIB_ACCESS_NOACCESS 21 00200 #define MIB_ACCESS_NOTIFY 67 00201 #define MIB_ACCESS_CREATE 48 00202 00203 #define MIB_STATUS_MANDATORY 23 00204 #define MIB_STATUS_OPTIONAL 24 00205 #define MIB_STATUS_OBSOLETE 25 00206 #define MIB_STATUS_DEPRECATED 39 00207 #define MIB_STATUS_CURRENT 57 00208 00209 #define ANON "anonymous#" 00210 #define ANON_LEN strlen(ANON) 00211 00212 struct tree *netsnmp_read_module(const char *); 00213 #ifndef NETSNMP_CLEAN_NAMESPACE 00214 struct tree *read_module(const char *); 00215 #endif 00216 struct tree *read_mib(const char *); 00217 struct tree *read_all_mibs(void); 00218 int netsnmp_unload_module(const char *name); 00219 #ifndef NETSNMP_CLEAN_NAMESPACE 00220 int unload_module(const char *name); 00221 void init_mib_internals(void); 00222 #endif 00223 void netsnmp_init_mib_internals(void); 00224 void unload_all_mibs(void); 00225 int add_mibfile(const char*, const char*, FILE *); 00226 int add_mibdir(const char *); 00227 void add_module_replacement(const char *, const char *, 00228 const char *, int); 00229 int which_module(const char *); 00230 char *module_name(int, char *); 00231 void print_subtree(FILE *, struct tree *, int); 00232 void print_ascii_dump_tree(FILE *, struct tree *, int); 00233 struct tree *find_tree_node(const char *, int); 00234 const char *get_tc_descriptor(int); 00235 const char *get_tc_description(int); 00236 struct tree *find_best_tree_node(const char *, struct tree *, 00237 u_int *); 00238 /* 00239 * backwards compatability 00240 */ 00241 struct tree *find_node(const char *, struct tree *); 00242 struct tree *find_node2(const char *, const char *); 00243 struct module *find_module(int); 00244 void adopt_orphans(void); 00245 char *snmp_mib_toggle_options(char *options); 00246 void snmp_mib_toggle_options_usage(const char *lead, 00247 FILE * outf); 00248 void print_mib(FILE *); 00249 void print_mib_tree(FILE *, struct tree *, int); 00250 int get_mib_parse_error_count(void); 00251 int snmp_get_token(FILE * fp, char *token, int maxtlen); 00252 struct tree *find_best_tree_node(const char *name, 00253 struct tree *tree_top, 00254 u_int * match); 00255 00256 #ifdef __cplusplus 00257 } 00258 #endif 00259 #endif /* PARSE_H */