parse.c File Reference
#include "squid.h"
#include "asn1.h"
#include "cache_snmp.h"
#include "parse.h"
#include "snmp_debug.h"
#include "snmp_pdu.h"
#include "snmp_vars.h"
#include "util.h"
Include dependency graph for parse.c:

Go to the source code of this file.

Classes

struct  subid
 
struct  node
 
struct  tok
 

Macros

#define CONTINUE   -1
 
#define ENDOFFILE   0
 
#define LABEL   1
 
#define SUBTREE   2
 
#define SYNTAX   3
 
#define OBJID   4
 
#define OCTETSTR   5
 
#define INTEGER   6
 
#define NETADDR   7
 
#define IPADDR   8
 
#define COUNTER   9
 
#define GAUGE   10
 
#define TIMETICKS   11
 
#define SNMP_OPAQUE   12
 
#define NUL   13
 
#define SEQUENCE   14
 
#define OF   15 /* SEQUENCE OF */
 
#define OBJTYPE   16
 
#define ACCESS   17
 
#define READONLY   18
 
#define READWRITE   19
 
#define WRITEONLY   20
 
#define NOACCESS   21
 
#define SNMP_STATUS   22
 
#define MANDATORY   23
 
#define SNMP_OPTIONAL   24
 
#define OBSOLETE   25
 
#define RECOMMENDED   26
 
#define PUNCT   27
 
#define EQUALS   28
 
#define NUMBER   29
 
#define LEFTBRACKET   30
 
#define RIGHTBRACKET   31
 
#define LEFTPAREN   32
 
#define RIGHTPAREN   33
 
#define COMMA   34
 
#define DESCRIPTION   35
 
#define INDEX   36
 
#define QUOTE   37
 
#define HASHSIZE   32
 
#define BUCKET(x)   (x & 0x01F)
 
#define NHASHSIZE   128
 
#define NBUCKET(x)   (x & 0x7F)
 

Functions

static void hash_init (void)
 
static void init_node_hash (struct node *nodes)
 
static void print_error (const char *string, const char *token, int type)
 
static void build_translation_table (void)
 
static void do_subtree (struct snmp_mib_tree *root, struct node **nodes)
 
static struct snmp_mib_treebuild_tree (struct node *nodes)
 
static int get_token (register FILE *fp, register char *token)
 
static int getoid (register FILE *fp, register struct subid *SubOid, int length)
 
static void free_node (struct node *np)
 
static void free_node_list (struct node *nl)
 
static struct nodeparse_objectid (FILE *fp, char *name)
 
static int parse_asntype (FILE *fp)
 
static struct nodeparse_objecttype (register FILE *fp, char *name)
 
static struct nodeparse (FILE *fp)
 
struct snmp_mib_treeread_mib (char *filename)
 

Variables

int Line = 1
 
struct tok tokens []
 
static struct tokbuckets [HASHSIZE]
 
struct nodenbuckets [NHASHSIZE]
 
int translation_table [40]
 
static char last = ' '
 

Macro Definition Documentation

◆ ACCESS

#define ACCESS   17

Definition at line 136 of file parse.c.

◆ BUCKET

#define BUCKET (   x)    (x & 0x01F)

Definition at line 217 of file parse.c.

◆ COMMA

#define COMMA   34

Definition at line 154 of file parse.c.

◆ CONTINUE

#define CONTINUE   -1

Definition at line 116 of file parse.c.

◆ COUNTER

#define COUNTER   9

Definition at line 128 of file parse.c.

◆ DESCRIPTION

#define DESCRIPTION   35

Definition at line 156 of file parse.c.

◆ ENDOFFILE

#define ENDOFFILE   0

Definition at line 117 of file parse.c.

◆ EQUALS

#define EQUALS   28

Definition at line 148 of file parse.c.

◆ GAUGE

#define GAUGE   10

Definition at line 129 of file parse.c.

◆ HASHSIZE

#define HASHSIZE   32

Definition at line 216 of file parse.c.

◆ INDEX

#define INDEX   36

Definition at line 157 of file parse.c.

◆ INTEGER

#define INTEGER   6

Definition at line 125 of file parse.c.

◆ IPADDR

#define IPADDR   8

Definition at line 127 of file parse.c.

◆ LABEL

#define LABEL   1

Definition at line 118 of file parse.c.

◆ LEFTBRACKET

#define LEFTBRACKET   30

Definition at line 150 of file parse.c.

◆ LEFTPAREN

#define LEFTPAREN   32

Definition at line 152 of file parse.c.

◆ MANDATORY

#define MANDATORY   23

Definition at line 143 of file parse.c.

◆ NBUCKET

#define NBUCKET (   x)    (x & 0x7F)

Definition at line 242 of file parse.c.

◆ NETADDR

#define NETADDR   7

Definition at line 126 of file parse.c.

◆ NHASHSIZE

#define NHASHSIZE   128

Definition at line 241 of file parse.c.

◆ NOACCESS

#define NOACCESS   21

Definition at line 141 of file parse.c.

◆ NUL

#define NUL   13

Definition at line 132 of file parse.c.

◆ NUMBER

#define NUMBER   29

Definition at line 149 of file parse.c.

◆ OBJID

#define OBJID   4

Definition at line 122 of file parse.c.

◆ OBJTYPE

#define OBJTYPE   16

Definition at line 135 of file parse.c.

◆ OBSOLETE

#define OBSOLETE   25

Definition at line 145 of file parse.c.

◆ OCTETSTR

#define OCTETSTR   5

Definition at line 123 of file parse.c.

◆ OF

#define OF   15 /* SEQUENCE OF */

Definition at line 134 of file parse.c.

◆ PUNCT

#define PUNCT   27

Definition at line 147 of file parse.c.

◆ QUOTE

#define QUOTE   37

Definition at line 158 of file parse.c.

◆ READONLY

#define READONLY   18

Definition at line 137 of file parse.c.

◆ READWRITE

#define READWRITE   19

Definition at line 138 of file parse.c.

◆ RECOMMENDED

#define RECOMMENDED   26

Definition at line 146 of file parse.c.

◆ RIGHTBRACKET

#define RIGHTBRACKET   31

Definition at line 151 of file parse.c.

◆ RIGHTPAREN

#define RIGHTPAREN   33

Definition at line 153 of file parse.c.

◆ SEQUENCE

#define SEQUENCE   14

Definition at line 133 of file parse.c.

◆ SNMP_OPAQUE

#define SNMP_OPAQUE   12

Definition at line 131 of file parse.c.

◆ SNMP_OPTIONAL

#define SNMP_OPTIONAL   24

Definition at line 144 of file parse.c.

◆ SNMP_STATUS

#define SNMP_STATUS   22

Definition at line 142 of file parse.c.

◆ SUBTREE

#define SUBTREE   2

Definition at line 119 of file parse.c.

◆ SYNTAX

#define SYNTAX   3

Definition at line 120 of file parse.c.

◆ TIMETICKS

#define TIMETICKS   11

Definition at line 130 of file parse.c.

◆ WRITEONLY

#define WRITEONLY   20

Definition at line 139 of file parse.c.

Function Documentation

◆ build_translation_table()

static void build_translation_table ( void  )
static

◆ build_tree()

◆ do_subtree()

◆ free_node()

static void free_node ( struct node np)
static

Definition at line 590 of file parse.c.

References node::enums, enum_list::next, and xfree.

Referenced by free_node_list(), parse_objectid(), and parse_objecttype().

◆ free_node_list()

static void free_node_list ( struct node nl)
static

Definition at line 604 of file parse.c.

References free_node(), and node::next.

Referenced by parse(), and parse_objectid().

◆ get_token()

static int get_token ( register FILE *  fp,
register char *  token 
)
static

◆ getoid()

static int getoid ( register FILE *  fp,
register struct subid SubOid,
int  length 
)
static

◆ hash_init()

static void hash_init ( void  )
static

Definition at line 222 of file parse.c.

References BUCKET, buckets, tok::hash, tok::name, tok::next, and tokens.

Referenced by parse().

◆ init_node_hash()

static void init_node_hash ( struct node nodes)
static

Definition at line 246 of file parse.c.

References hash, NBUCKET, nbuckets, node::next, and node::parent.

Referenced by build_tree().

◆ parse()

static struct node * parse ( FILE *  fp)
static

◆ parse_asntype()

static int parse_asntype ( FILE *  fp)
static

Definition at line 708 of file parse.c.

References ENDOFFILE, get_token(), print_error(), RIGHTBRACKET, SEQUENCE, and node::type.

Referenced by parse().

◆ parse_objectid()

static struct node * parse_objectid ( FILE *  fp,
char *  name 
)
static

◆ parse_objecttype()

◆ print_error()

static void print_error ( const char *  string,
const char *  token,
int  type 
)
static

Definition at line 265 of file parse.c.

References assert, ENDOFFILE, Line, NULL, snmplib_debug(), and node::type.

Referenced by getoid(), parse(), parse_asntype(), parse_objectid(), and parse_objecttype().

◆ read_mib()

struct snmp_mib_tree * read_mib ( char *  filename)

Definition at line 1038 of file parse.c.

References build_tree(), NULL, parse(), snmplib_debug(), and xstrerr().

Referenced by init_mib().

Variable Documentation

◆ buckets

struct tok* buckets[HASHSIZE]
static

◆ last

◆ Line

int Line = 1

Definition at line 113 of file parse.c.

Referenced by get_token(), parse_objecttype(), and print_error().

◆ nbuckets

struct node* nbuckets[NHASHSIZE]

Definition at line 243 of file parse.c.

Referenced by build_tree(), do_subtree(), init_node_hash(), and storeKeyHashBuckets().

◆ tokens

struct tok tokens[]

◆ translation_table

int translation_table[40]

Definition at line 276 of file parse.c.

Referenced by build_translation_table(), and do_subtree().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors