Statistics
| Branch: | Revision:

iof-bird-daemon / nest / config.Y @ 31b3e1bb

History | View | Annotate | Download (2 KB)

1
/*
2
 *	BIRD -- Core Configuration
3
 *
4
 *	(c) 1998--1999 Martin Mares <mj@ucw.cz>
5
 *
6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

    
9
CF_HDR
10

    
11
static struct proto_config *this_proto;
12

    
13
#include "nest/rt-dev.h"
14

    
15
void rt_dev_add_iface(char *);
16

    
17
CF_DECLS
18

    
19
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DEVICE)
20
CF_KEYWORDS(INTERFACE)
21

    
22
%type <i> idval
23

    
24
CF_GRAMMAR
25

    
26
/* Setting of router ID */
27

    
28
CF_ADDTO(conf, rtrid)
29
rtrid: ROUTER ID idval {
30
   new_config->router_id = $3;
31
   }
32
 ;
33

    
34
idval:
35
   NUM
36
 | IPA { $$ = ipa_to_u32($1); }
37
 ;
38

    
39
/* Definition of protocols */
40

    
41
CF_ADDTO(conf, proto)
42

    
43
proto_start: PROTOCOL
44

    
45
proto_name:
46
   /* EMPTY */ {
47
     struct symbol *s = cf_default_name(this_proto->proto->name);
48
     s->class = SYM_PROTO;
49
     s->def = this_proto;
50
     this_proto->name = s->name;
51
     }
52
 | SYM {
53
     if ($1->class) cf_error("Symbol already defined");
54
     $1->class = SYM_PROTO;
55
     $1->def = this_proto;
56
     this_proto->name = $1->name;
57
   }
58
 ;
59

    
60
proto_item:
61
   /* EMPTY */
62
 | PREFERENCE expr {
63
     if ($2 < 0 || $2 > 255) cf_error("Invalid preference");
64
     this_proto->preference = $2;
65
   }
66
 | DISABLED { this_proto->disabled = 1; }
67
 | DEBUG expr { this_proto->debug = $2; }
68
 | DEBUG ALL { this_proto->debug = ~0; }
69
 | DEBUG OFF { this_proto->debug = 0; }
70
 ;
71

    
72
/* Device protocol */
73

    
74
CF_ADDTO(proto, dev_proto '}')
75

    
76
dev_proto_start: proto_start DEVICE {
77
     if (!(this_proto = cf_dev_proto)) cf_error("Device protocol already defined");
78
     cf_dev_proto = NULL;
79
   }
80
 ;
81

    
82
dev_proto:
83
   dev_proto_start '{'
84
 | dev_proto proto_item ';'
85
 | dev_proto dev_iface_list ';'
86
 ;
87

    
88
dev_iface_list:
89
   INTERFACE TEXT {
90
     init_list(&((struct rt_dev_config *) this_proto)->iface_list);
91
     rt_dev_add_iface($2);
92
   }
93
 | dev_iface_list ',' TEXT { rt_dev_add_iface($3); }
94
 ;
95

    
96
CF_CODE
97

    
98
void
99
rt_dev_add_iface(char *n)
100
{
101
  struct rt_dev_config *p = (void *) this_proto;
102
  struct iface_patt *k = cfg_alloc(sizeof(struct iface_patt));
103

    
104
  k->pattern = cfg_strdup(n);
105
  add_tail(&p->iface_list, &k->n);
106
}
107

    
108
CF_END