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