1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// ./lib/current/include/parse.h
|
4 |
|
|
//
|
5 |
|
|
//
|
6 |
|
|
//==========================================================================
|
7 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
8 |
|
|
// -------------------------------------------
|
9 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
10 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
11 |
|
|
//
|
12 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
13 |
|
|
// the terms of the GNU General Public License as published by the Free
|
14 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
15 |
|
|
//
|
16 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
17 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
18 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
19 |
|
|
// for more details.
|
20 |
|
|
//
|
21 |
|
|
// You should have received a copy of the GNU General Public License along
|
22 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
23 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
24 |
|
|
//
|
25 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
26 |
|
|
// or inline functions from this file, or you compile this file and link it
|
27 |
|
|
// with other works to produce a work based on this file, this file does not
|
28 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
29 |
|
|
// License. However the source code for this file must still be made available
|
30 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
31 |
|
|
//
|
32 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
33 |
|
|
// this file might be covered by the GNU General Public License.
|
34 |
|
|
//
|
35 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
36 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//####UCDSNMPCOPYRIGHTBEGIN####
|
40 |
|
|
//
|
41 |
|
|
// -------------------------------------------
|
42 |
|
|
//
|
43 |
|
|
// Portions of this software may have been derived from the UCD-SNMP
|
44 |
|
|
// project, <http://ucd-snmp.ucdavis.edu/> from the University of
|
45 |
|
|
// California at Davis, which was originally based on the Carnegie Mellon
|
46 |
|
|
// University SNMP implementation. Portions of this software are therefore
|
47 |
|
|
// covered by the appropriate copyright disclaimers included herein.
|
48 |
|
|
//
|
49 |
|
|
// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
|
50 |
|
|
// -------------------------------------------
|
51 |
|
|
//
|
52 |
|
|
//####UCDSNMPCOPYRIGHTEND####
|
53 |
|
|
//==========================================================================
|
54 |
|
|
//#####DESCRIPTIONBEGIN####
|
55 |
|
|
//
|
56 |
|
|
// Author(s): hmt
|
57 |
|
|
// Contributors: hmt
|
58 |
|
|
// Date: 2000-05-30
|
59 |
|
|
// Purpose: Port of UCD-SNMP distribution to eCos.
|
60 |
|
|
// Description:
|
61 |
|
|
//
|
62 |
|
|
//
|
63 |
|
|
//####DESCRIPTIONEND####
|
64 |
|
|
//
|
65 |
|
|
//==========================================================================
|
66 |
|
|
/********************************************************************
|
67 |
|
|
Copyright 1989, 1991, 1992 by Carnegie Mellon University
|
68 |
|
|
|
69 |
|
|
Derivative Work -
|
70 |
|
|
Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
|
71 |
|
|
|
72 |
|
|
All Rights Reserved
|
73 |
|
|
|
74 |
|
|
Permission to use, copy, modify and distribute this software and its
|
75 |
|
|
documentation for any purpose and without fee is hereby granted,
|
76 |
|
|
provided that the above copyright notice appears in all copies and
|
77 |
|
|
that both that copyright notice and this permission notice appear in
|
78 |
|
|
supporting documentation, and that the name of CMU and The Regents of
|
79 |
|
|
the University of California not be used in advertising or publicity
|
80 |
|
|
pertaining to distribution of the software without specific written
|
81 |
|
|
permission.
|
82 |
|
|
|
83 |
|
|
CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
|
84 |
|
|
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
|
85 |
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
|
86 |
|
|
THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
|
87 |
|
|
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
88 |
|
|
FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
89 |
|
|
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
90 |
|
|
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
91 |
|
|
*********************************************************************/
|
92 |
|
|
#ifndef PARSE_H
|
93 |
|
|
#define PARSE_H
|
94 |
|
|
|
95 |
|
|
#ifdef __cplusplus
|
96 |
|
|
extern "C" {
|
97 |
|
|
#endif
|
98 |
|
|
/*
|
99 |
|
|
* parse.h
|
100 |
|
|
*/
|
101 |
|
|
/***********************************************************
|
102 |
|
|
Copyright 1989 by Carnegie Mellon University
|
103 |
|
|
|
104 |
|
|
All Rights Reserved
|
105 |
|
|
|
106 |
|
|
Permission to use, copy, modify, and distribute this software and its
|
107 |
|
|
documentation for any purpose and without fee is hereby granted,
|
108 |
|
|
provided that the above copyright notice appear in all copies and that
|
109 |
|
|
both that copyright notice and this permission notice appear in
|
110 |
|
|
supporting documentation, and that the name of CMU not be
|
111 |
|
|
used in advertising or publicity pertaining to distribution of the
|
112 |
|
|
software without specific, written prior permission.
|
113 |
|
|
|
114 |
|
|
CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
115 |
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
116 |
|
|
CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
117 |
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
118 |
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
119 |
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
120 |
|
|
SOFTWARE.
|
121 |
|
|
******************************************************************/
|
122 |
|
|
|
123 |
|
|
#define MAXLABEL 64 /* maximum characters in a label */
|
124 |
|
|
#define MAXTOKEN 128 /* maximum characters in a token */
|
125 |
|
|
#define MAXQUOTESTR 4096 /* maximum characters in a quoted string */
|
126 |
|
|
|
127 |
|
|
struct variable_list;
|
128 |
|
|
|
129 |
|
|
/*
|
130 |
|
|
* A linked list of tag-value pairs for enumerated integers.
|
131 |
|
|
*/
|
132 |
|
|
struct enum_list {
|
133 |
|
|
struct enum_list *next;
|
134 |
|
|
int value;
|
135 |
|
|
char *label;
|
136 |
|
|
};
|
137 |
|
|
|
138 |
|
|
/*
|
139 |
|
|
* A linked list of ranges
|
140 |
|
|
*/
|
141 |
|
|
struct range_list {
|
142 |
|
|
struct range_list *next;
|
143 |
|
|
int low, high;
|
144 |
|
|
};
|
145 |
|
|
|
146 |
|
|
/*
|
147 |
|
|
* A linked list of indexes
|
148 |
|
|
*/
|
149 |
|
|
struct index_list {
|
150 |
|
|
struct index_list *next;
|
151 |
|
|
char *ilabel;
|
152 |
|
|
char isimplied;
|
153 |
|
|
};
|
154 |
|
|
|
155 |
|
|
/*
|
156 |
|
|
* A linked list of nodes.
|
157 |
|
|
*/
|
158 |
|
|
struct node {
|
159 |
|
|
struct node *next;
|
160 |
|
|
char *label; /* This node's (unique) textual name */
|
161 |
|
|
u_long subid; /* This node's integer subidentifier */
|
162 |
|
|
int modid; /* The module containing this node */
|
163 |
|
|
char *parent; /* The parent's textual name */
|
164 |
|
|
int tc_index; /* index into tclist (-1 if NA) */
|
165 |
|
|
int type; /* The type of object this represents */
|
166 |
|
|
int access;
|
167 |
|
|
int status;
|
168 |
|
|
struct enum_list *enums; /* (optional) list of enumerated integers */
|
169 |
|
|
struct range_list *ranges;
|
170 |
|
|
struct index_list *indexes;
|
171 |
|
|
char *hint;
|
172 |
|
|
char *units;
|
173 |
|
|
char *description; /* description (a quoted string) */
|
174 |
|
|
};
|
175 |
|
|
|
176 |
|
|
/*
|
177 |
|
|
* A tree in the format of the tree structure of the MIB.
|
178 |
|
|
*/
|
179 |
|
|
struct tree {
|
180 |
|
|
struct tree *child_list; /* list of children of this node */
|
181 |
|
|
struct tree *next_peer; /* Next node in list of peers */
|
182 |
|
|
struct tree *next; /* Next node in hashed list of names */
|
183 |
|
|
struct tree *parent;
|
184 |
|
|
char *label; /* This node's textual name */
|
185 |
|
|
u_long subid; /* This node's integer subidentifier */
|
186 |
|
|
int modid; /* The module containing this node */
|
187 |
|
|
int number_modules;
|
188 |
|
|
int *module_list; /* To handle multiple modules */
|
189 |
|
|
int tc_index; /* index into tclist (-1 if NA) */
|
190 |
|
|
int type; /* This node's object type */
|
191 |
|
|
int access; /* This nodes access */
|
192 |
|
|
int status; /* This nodes status */
|
193 |
|
|
struct enum_list *enums; /* (optional) list of enumerated integers */
|
194 |
|
|
struct range_list *ranges;
|
195 |
|
|
struct index_list *indexes;
|
196 |
|
|
char *hint;
|
197 |
|
|
char *units;
|
198 |
|
|
void (*printer) (char *, struct variable_list *, struct enum_list *,
|
199 |
|
|
const char *, const char *); /* Value printing function */
|
200 |
|
|
char *description; /* description (a quoted string) */
|
201 |
|
|
int reported; /* 1=report started in print_subtree... */
|
202 |
|
|
};
|
203 |
|
|
|
204 |
|
|
/*
|
205 |
|
|
* Information held about each MIB module
|
206 |
|
|
*/
|
207 |
|
|
struct module_import {
|
208 |
|
|
char *label; /* The descriptor being imported */
|
209 |
|
|
int modid; /* The module imported from */
|
210 |
|
|
};
|
211 |
|
|
|
212 |
|
|
struct module {
|
213 |
|
|
char *name; /* This module's name */
|
214 |
|
|
char *file; /* The file containing the module */
|
215 |
|
|
struct module_import *imports; /* List of descriptors being imported */
|
216 |
|
|
int no_imports; /* The number of such import descriptors */
|
217 |
|
|
/* -1 implies the module hasn't been read in yet */
|
218 |
|
|
int modid; /* The index number of this module */
|
219 |
|
|
struct module *next; /* Linked list pointer */
|
220 |
|
|
};
|
221 |
|
|
|
222 |
|
|
struct module_compatability {
|
223 |
|
|
const char *old_module;
|
224 |
|
|
const char *new_module;
|
225 |
|
|
const char *tag; /* NULL implies unconditional replacement,
|
226 |
|
|
otherwise node identifier or prefix */
|
227 |
|
|
size_t tag_len; /* 0 implies exact match (or unconditional) */
|
228 |
|
|
struct module_compatability *next; /* linked list */
|
229 |
|
|
};
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
/* non-aggregate types for tree end nodes */
|
233 |
|
|
#define TYPE_OTHER 0
|
234 |
|
|
#define TYPE_OBJID 1
|
235 |
|
|
#define TYPE_OCTETSTR 2
|
236 |
|
|
#define TYPE_INTEGER 3
|
237 |
|
|
#define TYPE_NETADDR 4
|
238 |
|
|
#define TYPE_IPADDR 5
|
239 |
|
|
#define TYPE_COUNTER 6
|
240 |
|
|
#define TYPE_GAUGE 7
|
241 |
|
|
#define TYPE_TIMETICKS 8
|
242 |
|
|
#define TYPE_OPAQUE 9
|
243 |
|
|
#define TYPE_NULL 10
|
244 |
|
|
#define TYPE_COUNTER64 11
|
245 |
|
|
#define TYPE_BITSTRING 12
|
246 |
|
|
#define TYPE_NSAPADDRESS 13
|
247 |
|
|
#define TYPE_UINTEGER 14
|
248 |
|
|
|
249 |
|
|
#define MIB_ACCESS_READONLY 18
|
250 |
|
|
#define MIB_ACCESS_READWRITE 19
|
251 |
|
|
#define MIB_ACCESS_WRITEONLY 20
|
252 |
|
|
#define MIB_ACCESS_NOACCESS 21
|
253 |
|
|
#define MIB_ACCESS_NOTIFY 67
|
254 |
|
|
#define MIB_ACCESS_CREATE 48
|
255 |
|
|
|
256 |
|
|
#define MIB_STATUS_MANDATORY 23
|
257 |
|
|
#define MIB_STATUS_OPTIONAL 24
|
258 |
|
|
#define MIB_STATUS_OBSOLETE 25
|
259 |
|
|
#define MIB_STATUS_DEPRECATED 39
|
260 |
|
|
#define MIB_STATUS_CURRENT 57
|
261 |
|
|
|
262 |
|
|
#ifdef CMU_COMPATIBLE
|
263 |
|
|
#define ACCESS_READONLY MIB_ACCESS_READONLY
|
264 |
|
|
#define ACCESS_READWRITE MIB_ACCESS_READWRITE
|
265 |
|
|
#define ACCESS_WRITEONLY MIB_ACCESS_WRITEONLY
|
266 |
|
|
#define ACCESS_NOACCESS MIB_ACCESS_NOACCESS
|
267 |
|
|
#define ACCESS_NOTIFY MIB_ACCESS_NOTIFY
|
268 |
|
|
#define ACCESS_CREATE MIB_ACCESS_CREATE
|
269 |
|
|
#define STATUS_MANDATORY MIB_STATUS_MANDATORY
|
270 |
|
|
#define STATUS_OPTIONAL MIB_STATUS_OPTIONAL
|
271 |
|
|
#define STATUS_OBSOLETE MIB_STATUS_OBSOLETE
|
272 |
|
|
#define STATUS_DEPRECATED MIB_STATUS_DEPRECATED
|
273 |
|
|
#define STATUS_CURRENT MIB_STATUS_CURRENT
|
274 |
|
|
#endif /* CMU_COMPATIBLE */
|
275 |
|
|
|
276 |
|
|
#define ANON "anonymous#"
|
277 |
|
|
#define ANON_LEN strlen(ANON)
|
278 |
|
|
|
279 |
|
|
struct tree *read_module (const char *);
|
280 |
|
|
struct tree *read_mib (const char *);
|
281 |
|
|
struct tree *read_all_mibs (void);
|
282 |
|
|
int unload_module(const char *name);
|
283 |
|
|
void init_mib_internals (void);
|
284 |
|
|
int add_mibdir (const char *);
|
285 |
|
|
void add_module_replacement (const char *, const char *, const char *, int);
|
286 |
|
|
int which_module (const char *);
|
287 |
|
|
char *module_name (int, char *);
|
288 |
|
|
void print_subtree (FILE *, struct tree *, int);
|
289 |
|
|
void print_ascii_dump_tree (FILE *, struct tree *, int);
|
290 |
|
|
struct tree *find_tree_node (const char *, int);
|
291 |
|
|
const char *get_tc_descriptor (int);
|
292 |
|
|
struct tree *find_best_tree_node(const char *, struct tree *, u_int *);
|
293 |
|
|
/* backwards compatability */
|
294 |
|
|
struct tree *find_node (const char *, struct tree*);
|
295 |
|
|
struct module *find_module (int);
|
296 |
|
|
void adopt_orphans (void);
|
297 |
|
|
void snmp_set_mib_warnings (int);
|
298 |
|
|
void snmp_set_mib_errors (int);
|
299 |
|
|
void snmp_set_save_descriptions (int);
|
300 |
|
|
void snmp_set_mib_comment_term (int);
|
301 |
|
|
void snmp_set_mib_parse_label (int);
|
302 |
|
|
char *snmp_mib_toggle_options(char *options);
|
303 |
|
|
void snmp_mib_toggle_options_usage(const char *lead, FILE *outf);
|
304 |
|
|
void print_mib(FILE *);
|
305 |
|
|
void print_mib_tree(FILE *, struct tree *, int);
|
306 |
|
|
int get_mib_parse_error_count(void);
|
307 |
|
|
int snmp_get_token(FILE *fp, char *token, int maxtlen);
|
308 |
|
|
struct tree *
|
309 |
|
|
find_best_tree_node(const char *name, struct tree *tree_top, u_int *match);
|
310 |
|
|
|
311 |
|
|
#ifdef __cplusplus
|
312 |
|
|
}
|
313 |
|
|
#endif
|
314 |
|
|
|
315 |
|
|
#endif /* PARSE_H */
|