10 /***********************************************************
11 Copyright 1989 by Carnegie Mellon University
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.
23 CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
24 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
25 CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
26 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
27 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
28 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
30 ******************************************************************/
32 #define MAXLABEL 64 /* maximum characters in a label */
33 #define MAXTOKEN 128 /* maximum characters in a token */
34 #define MAXQUOTESTR 4096 /* maximum characters in a quoted string */
39 * A linked list of tag-value pairs for enumerated integers.
42 struct enum_list *next;
48 * A linked list of ranges
51 struct range_list *next;
56 * A linked list of indexes
59 struct index_list *next;
65 * A linked list of varbinds
68 struct varbind_list *next;
73 * A linked list of nodes.
77 char *label; /* This node's (unique) textual name */
78 u_long subid; /* This node's integer subidentifier */
79 int modid; /* The module containing this node */
80 char *parent; /* The parent's textual name */
81 int tc_index; /* index into tclist (-1 if NA) */
82 int type; /* The type of object this represents */
85 struct enum_list *enums; /* (optional) list of enumerated integers */
86 struct range_list *ranges;
87 struct index_list *indexes;
89 struct varbind_list *varbinds;
92 char *description; /* description (a quoted string) */
99 * A tree in the format of the tree structure of the MIB.
102 struct tree *child_list; /* list of children of this node */
103 struct tree *next_peer; /* Next node in list of peers */
104 struct tree *next; /* Next node in hashed list of names */
106 char *label; /* This node's textual name */
107 u_long subid; /* This node's integer subidentifier */
108 int modid; /* The module containing this node */
110 int *module_list; /* To handle multiple modules */
111 int tc_index; /* index into tclist (-1 if NA) */
112 int type; /* This node's object type */
113 int access; /* This nodes access */
114 int status; /* This nodes status */
115 struct enum_list *enums; /* (optional) list of enumerated integers */
116 struct range_list *ranges;
117 struct index_list *indexes;
119 struct varbind_list *varbinds;
122 int (*printomat) (u_char **, size_t *, size_t *, int,
123 netsnmp_variable_list *,
124 struct enum_list *, const char *,
126 void (*printer) (char *, netsnmp_variable_list *, struct enum_list *, const char *, const char *); /* Value printing function */
127 char *description; /* description (a quoted string) */
128 int reported; /* 1=report started in print_subtree... */
133 * Information held about each MIB module
135 struct module_import {
136 char *label; /* The descriptor being imported */
137 int modid; /* The module imported from */
141 char *name; /* This module's name */
142 char *file; /* The file containing the module */
143 struct module_import *imports; /* List of descriptors being imported */
144 int no_imports; /* The number of such import descriptors */
146 * -1 implies the module hasn't been read in yet
148 int modid; /* The index number of this module */
149 struct module *next; /* Linked list pointer */
152 struct module_compatability {
153 const char *old_module;
154 const char *new_module;
155 const char *tag; /* NULL implies unconditional replacement,
156 * otherwise node identifier or prefix */
157 size_t tag_len; /* 0 implies exact match (or unconditional) */
158 struct module_compatability *next; /* linked list */
163 * non-aggregate types for tree end nodes
167 #define TYPE_OCTETSTR 2
168 #define TYPE_INTEGER 3
169 #define TYPE_NETADDR 4
170 #define TYPE_IPADDR 5
171 #define TYPE_COUNTER 6
173 #define TYPE_TIMETICKS 8
174 #define TYPE_OPAQUE 9
176 #define TYPE_COUNTER64 11
177 #define TYPE_BITSTRING 12
178 #define TYPE_NSAPADDRESS 13
179 #define TYPE_UINTEGER 14
180 #define TYPE_UNSIGNED32 15
181 #define TYPE_INTEGER32 16
183 #define TYPE_SIMPLE_LAST 16
185 #define TYPE_TRAPTYPE 20
186 #define TYPE_NOTIFTYPE 21
187 #define TYPE_OBJGROUP 22
188 #define TYPE_NOTIFGROUP 23
189 #define TYPE_MODID 24
190 #define TYPE_AGENTCAP 25
191 #define TYPE_MODCOMP 26
193 #define MIB_ACCESS_READONLY 18
194 #define MIB_ACCESS_READWRITE 19
195 #define MIB_ACCESS_WRITEONLY 20
196 #define MIB_ACCESS_NOACCESS 21
197 #define MIB_ACCESS_NOTIFY 67
198 #define MIB_ACCESS_CREATE 48
200 #define MIB_STATUS_MANDATORY 23
201 #define MIB_STATUS_OPTIONAL 24
202 #define MIB_STATUS_OBSOLETE 25
203 #define MIB_STATUS_DEPRECATED 39
204 #define MIB_STATUS_CURRENT 57
206 #define ANON "anonymous#"
207 #define ANON_LEN strlen(ANON)
209 struct tree *read_module(const char *);
210 struct tree *read_mib(const char *);
211 struct tree *read_all_mibs(void);
212 int unload_module(const char *name);
213 void unload_all_mibs(void);
214 void init_mib_internals(void);
215 int add_mibdir(const char *);
216 void add_module_replacement(const char *, const char *,
218 int which_module(const char *);
219 char *module_name(int, char *);
220 void print_subtree(FILE *, struct tree *, int);
221 void print_ascii_dump_tree(FILE *, struct tree *, int);
222 struct tree *find_tree_node(const char *, int);
223 const char *get_tc_descriptor(int);
224 struct tree *find_best_tree_node(const char *, struct tree *,
227 * backwards compatability
229 struct tree *find_node(const char *, struct tree *);
230 struct module *find_module(int);
231 void adopt_orphans(void);
232 char *snmp_mib_toggle_options(char *options);
233 void snmp_mib_toggle_options_usage(const char *lead,
235 void print_mib(FILE *);
236 void print_mib_tree(FILE *, struct tree *, int);
237 int get_mib_parse_error_count(void);
238 int snmp_get_token(FILE * fp, char *token, int maxtlen);
239 struct tree *find_best_tree_node(const char *name,
240 struct tree *tree_top,