Home | History | Annotate | Download | only in parser
      1 /*
      2  * Copyright (c) 1998 by Sun Microsystems, Inc.
      3  * All rights reserved.
      4  */
      5 
      6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
      7 
      8 #ifndef _PARSE_H_
      9 #define _PARSE_H_
     10 
     11 /***********************************************************
     12 	Copyright 1989 by Carnegie Mellon University
     13 
     14                       All Rights Reserved
     15 
     16 Permission to use, copy, modify, and distribute this software and its
     17 documentation for any purpose and without fee is hereby granted,
     18 provided that the above copyright notice appear in all copies and that
     19 both that copyright notice and this permission notice appear in
     20 supporting documentation, and that the name of CMU not be
     21 used in advertising or publicity pertaining to distribution of the
     22 software without specific, written prior permission.
     23 
     24 CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
     25 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
     26 CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
     27 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
     28 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
     29 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     30 SOFTWARE.
     31 ******************************************************************/
     32 /*
     33  * parse.h
     34  */
     35 
     36 #include <sys/types.h>
     37 #include "asn1.h"
     38 
     39 #define MAXLABEL	64	/* maximum characters in a label */
     40 #define MAXTOKEN	64	/* maximum characters in a token */
     41 #define MAXQUOTESTR	512	/* maximum characters in a quoted string */
     42 
     43 #define READ_FLAG	0x1
     44 #define WRITE_FLAG	0x2
     45 #define CREATE_FLAG	0x4
     46 
     47 
     48 struct index_list {
     49     struct index_list *next;
     50     struct tree *tp;
     51     char *label;
     52     int mark;
     53 };
     54 
     55 
     56 
     57 /*
     58  * A linked list of tag-value pairs for enumerated integers.
     59  */
     60 struct enum_list {
     61     struct enum_list *next;
     62     int	value;
     63     char *label;
     64 };
     65 
     66 struct trap_item {
     67 	struct trap_item *next;
     68 	char label[MAXLABEL];
     69 	char enterprise_label[MAXLABEL];
     70 	/* For arbitrary length enterprise OID in traps - bug 4133978 */
     71 	/* There is an extra -1 to indicate end of the oid sequence */
     72 	uint32_t enterprise_subids[MAX_OID_LEN+1];
     73 	struct index_list *var_list;
     74 	int n_variables;
     75         char *description;
     76 	int value;	/* trap-value */
     77 };
     78 
     79 extern struct trap_item *trap_list;
     80 
     81 
     82 /*
     83  * A linked list of nodes.
     84  */
     85 struct node {
     86     struct node *next;
     87     char label[MAXLABEL]; /* This node's (unique) textual name */
     88     uint32_t  subid;  /* This node's integer subidentifier */
     89     char parent[MAXLABEL];/* The parent's textual name */
     90     int type;	    /* The type of object this represents */
     91     int oct_str_len; /* if octet string, SIZE len*/
     92     struct enum_list *enums;	/* (optional) list of enumerated integers
     93 (otherwise NULL) */
     94     char *description;	/* description (a quoted string) */
     95 /*
     96 -- Olivier Reisacher 95/2/14
     97 */
     98 	int access;
     99 	struct index_list *indexs;
    100 	int n_indexs;
    101 };
    102 
    103 /*
    104  * A tree in the format of the tree structure of the MIB.
    105  */
    106 struct tree {
    107     struct tree *child_list;	/* list of children of this node */
    108     struct tree *next_peer;	/* Next node in list of peers */
    109     struct tree *parent;
    110     char label[MAXLABEL];		/* This node's textual name */
    111     uint32_t subid;		/* This node's integer subidentifier */
    112     int type;			/* This node's object type */
    113     struct enum_list *enums;	/* (optional) list of enumerated integers
    114 (otherwise NULL) */
    115     void (*printer)();     /* Value printing function */
    116     char *description;	/* description (a quoted string) */
    117 /*
    118  -- Olivier Reisacher 95/2/14
    119 */
    120 	int access;
    121 	struct index_list *indexs;
    122 	int n_indexs;
    123 	struct tree *next;
    124 	int node_index;
    125 	int node_type;
    126         int oct_str_len;
    127 	int object_index;
    128 	int column_index;
    129 	int entry_index;
    130 };
    131 
    132 /* non-aggregate types for tree end nodes */
    133 #define TYPE_OTHER	    0
    134 #define TYPE_OBJID	    1
    135 #define TYPE_OCTETSTR	    2
    136 #define TYPE_INTEGER	    3
    137 #define TYPE_NETADDR	    4
    138 #define	TYPE_IPADDR	    5
    139 #define TYPE_COUNTER	    6
    140 #define TYPE_GAUGE	    7
    141 #define TYPE_TIMETICKS	    8
    142 #define TYPE_OPAQUE	    9
    143 #define TYPE_NULL	    10
    144 #define TYPE_COUNTER64      11
    145 #define TYPE_BITSTRING      12
    146 #define TYPE_NSAPADDRESS    13
    147 #define TYPE_UINTEGER	    14
    148 /*
    149 -- Olivier Reisacher 95/2/14
    150 */
    151 #define TYPE_TABLE	20
    152 #define TYPE_ENTRY	21
    153 
    154 struct tree *read_mib();
    155 
    156 /*
    157 -- Olivier Reisacher 95/2/14
    158 */
    159 void parse_init();
    160 struct node *parse(FILE *fp);
    161 struct tree *build_tree(struct node *nodes);
    162 void print_subtree(struct tree *subtree, int count);
    163 
    164 #endif
    165