and added files
[bcm963xx.git] / userapps / opensource / net-snmp / include / net-snmp / library / parse.h
1 #ifndef PARSE_H
2 #define PARSE_H
3
4 #ifdef __cplusplus
5 extern          "C" {
6 #endif
7     /*
8      * parse.h
9      */
10 /***********************************************************
11         Copyright 1989 by Carnegie Mellon University
12
13                       All Rights Reserved
14
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.
22
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
29 SOFTWARE.
30 ******************************************************************/
31
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 */
35
36     struct variable_list;
37
38     /*
39      * A linked list of tag-value pairs for enumerated integers.
40      */
41     struct enum_list {
42         struct enum_list *next;
43         int             value;
44         char           *label;
45     };
46
47     /*
48      * A linked list of ranges
49      */
50     struct range_list {
51         struct range_list *next;
52         int             low, high;
53     };
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     /*
65      * A linked list of varbinds
66      */
67     struct varbind_list {
68         struct varbind_list *next;
69         char           *vblabel;
70     };
71
72     /*
73      * A linked list of nodes.
74      */
75     struct node {
76         struct node    *next;
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 */
83         int             access;
84         int             status;
85         struct enum_list *enums;        /* (optional) list of enumerated integers */
86         struct range_list *ranges;
87         struct index_list *indexes;
88         char           *augments;
89         struct varbind_list *varbinds;
90         char           *hint;
91         char           *units;
92         char           *description;    /* description (a quoted string) */
93         char           *defaultValue;
94         char           *filename;
95         int             lineno;
96     };
97
98     /*
99      * A tree in the format of the tree structure of the MIB.
100      */
101     struct tree {
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 */
105         struct tree    *parent;
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 */
109         int             number_modules;
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;
118         char           *augments;
119         struct varbind_list *varbinds;
120         char           *hint;
121         char           *units;
122         int             (*printomat) (u_char **, size_t *, size_t *, int,
123                                       netsnmp_variable_list *,
124                                       struct enum_list *, const char *,
125                                       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... */
129         char           *defaultValue;
130     };
131
132     /*
133      * Information held about each MIB module
134      */
135     struct module_import {
136         char           *label;  /* The descriptor being imported */
137         int             modid;  /* The module imported from */
138     };
139
140     struct module {
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 */
145         /*
146          * -1 implies the module hasn't been read in yet 
147          */
148         int             modid;  /* The index number of this module */
149         struct module  *next;   /* Linked list pointer */
150     };
151
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 */
159     };
160
161
162     /*
163      * non-aggregate types for tree end nodes 
164      */
165 #define TYPE_OTHER          0
166 #define TYPE_OBJID          1
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
172 #define TYPE_GAUGE          7
173 #define TYPE_TIMETICKS      8
174 #define TYPE_OPAQUE         9
175 #define TYPE_NULL           10
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
182
183 #define TYPE_SIMPLE_LAST    16
184
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
192
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
199
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
205
206 #define ANON    "anonymous#"
207 #define ANON_LEN  strlen(ANON)
208
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 *,
217                                            const char *, int);
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 *,
225                                         u_int *);
226     /*
227      * backwards compatability 
228      */
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,
234                                                   FILE * outf);
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,
241                                         u_int * match);
242
243 #ifdef __cplusplus
244 }
245 #endif
246 #endif                          /* PARSE_H */