]>
Commit | Line | Data |
---|---|---|
da877822 MM |
1 | /* |
2 | * BIRD -- Core Configuration | |
3 | * | |
31b3e1bb | 4 | * (c) 1998--1999 Martin Mares <mj@ucw.cz> |
da877822 MM |
5 | * |
6 | * Can be freely distributed and used under the terms of the GNU GPL. | |
7 | */ | |
8 | ||
9 | CF_HDR | |
10 | ||
31b3e1bb | 11 | static struct proto_config *this_proto; |
c74c0e3c | 12 | |
50d8424a | 13 | #include "nest/rt-dev.h" |
1a2ded45 | 14 | #include "nest/password.h" |
50d8424a MM |
15 | |
16 | void rt_dev_add_iface(char *); | |
17 | ||
da877822 MM |
18 | CF_DECLS |
19 | ||
7e5f5ffd | 20 | CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT) |
0e02abfd | 21 | CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE) |
900d5470 | 22 | CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID) |
da877822 MM |
23 | |
24 | %type <i> idval | |
5056c559 | 25 | %type <f> imexport |
0e02abfd | 26 | %type <r> rtable |
1a2ded45 | 27 | %type <p> password_list password_begin |
da877822 MM |
28 | |
29 | CF_GRAMMAR | |
30 | ||
c74c0e3c MM |
31 | /* Setting of router ID */ |
32 | ||
da877822 | 33 | CF_ADDTO(conf, rtrid) |
0e02abfd | 34 | |
7f400d1c | 35 | rtrid: ROUTER ID idval ';' { |
31b3e1bb | 36 | new_config->router_id = $3; |
c74c0e3c | 37 | } |
da877822 MM |
38 | ; |
39 | ||
40 | idval: | |
41 | NUM | |
42 | | IPA { $$ = ipa_to_u32($1); } | |
43 | ; | |
44 | ||
0e02abfd MM |
45 | /* Creation of routing tables */ |
46 | ||
47 | CF_ADDTO(conf, newtab) | |
48 | ||
49 | newtab: TABLE SYM { | |
50 | struct rtable_config *c = cfg_allocz(sizeof(struct rtable_config)); | |
51 | struct symbol *s = $2; | |
52 | cf_define_symbol(s, SYM_TABLE, c); | |
53 | c->name = s->name; | |
54 | add_tail(&new_config->tables, &c->n); | |
55 | } | |
56 | ; | |
57 | ||
c74c0e3c MM |
58 | /* Definition of protocols */ |
59 | ||
60 | CF_ADDTO(conf, proto) | |
61 | ||
62 | proto_start: PROTOCOL | |
63 | ||
64 | proto_name: | |
65 | /* EMPTY */ { | |
7e5f5ffd | 66 | struct symbol *s = cf_default_name(this_proto->proto->name, &this_proto->proto->name_counter); |
c74c0e3c MM |
67 | s->class = SYM_PROTO; |
68 | s->def = this_proto; | |
69 | this_proto->name = s->name; | |
70 | } | |
71 | | SYM { | |
0e02abfd | 72 | cf_define_symbol($1, SYM_PROTO, this_proto); |
c74c0e3c MM |
73 | this_proto->name = $1->name; |
74 | } | |
75 | ; | |
76 | ||
77 | proto_item: | |
78 | /* EMPTY */ | |
0b62c3a7 | 79 | | PREFERENCE expr { |
c74c0e3c MM |
80 | if ($2 < 0 || $2 > 255) cf_error("Invalid preference"); |
81 | this_proto->preference = $2; | |
82 | } | |
bd5d0d62 MM |
83 | | DISABLED { this_proto->disabled = 1; } |
84 | | DEBUG expr { this_proto->debug = $2; } | |
85 | | DEBUG ALL { this_proto->debug = ~0; } | |
86 | | DEBUG OFF { this_proto->debug = 0; } | |
5056c559 MM |
87 | | IMPORT imexport { this_proto->in_filter = $2; } |
88 | | EXPORT imexport { this_proto->out_filter = $2; } | |
0e02abfd | 89 | | TABLE rtable { this_proto->table = $2; } |
5056c559 MM |
90 | ; |
91 | ||
92 | imexport: | |
93 | FILTER filter { $$ = $2; } | |
94 | | ALL { $$ = FILTER_ACCEPT; } | |
95 | | NONE { $$ = FILTER_REJECT; } | |
c74c0e3c MM |
96 | ; |
97 | ||
0e02abfd MM |
98 | rtable: |
99 | SYM { | |
100 | if ($1->class != SYM_TABLE) cf_error("Table name expected"); | |
101 | $$ = $1->def; | |
102 | } | |
103 | ; | |
104 | ||
7e5f5ffd | 105 | /* Direct device route protocol */ |
50d8424a MM |
106 | |
107 | CF_ADDTO(proto, dev_proto '}') | |
108 | ||
7e5f5ffd MM |
109 | dev_proto_start: proto_start DIRECT { |
110 | struct rt_dev_config *p = proto_config_new(&proto_device, sizeof(struct rt_dev_config)); | |
111 | struct iface_patt *k = cfg_alloc(sizeof(struct iface_patt)); | |
112 | this_proto = &p->c; | |
113 | p->c.preference = DEF_PREF_DIRECT; | |
114 | init_list(&p->iface_list); | |
115 | k->pattern = "*"; | |
116 | add_tail(&p->iface_list, &k->n); | |
50d8424a MM |
117 | } |
118 | ; | |
119 | ||
120 | dev_proto: | |
7e5f5ffd | 121 | dev_proto_start proto_name '{' |
50d8424a MM |
122 | | dev_proto proto_item ';' |
123 | | dev_proto dev_iface_list ';' | |
124 | ; | |
125 | ||
126 | dev_iface_list: | |
127 | INTERFACE TEXT { | |
7e5f5ffd | 128 | /* FIXME: Beware of obscure semantics. */ |
31b3e1bb | 129 | init_list(&((struct rt_dev_config *) this_proto)->iface_list); |
50d8424a MM |
130 | rt_dev_add_iface($2); |
131 | } | |
132 | | dev_iface_list ',' TEXT { rt_dev_add_iface($3); } | |
133 | ; | |
134 | ||
1a2ded45 PM |
135 | password_begin: |
136 | PASSWORD TEXT { | |
137 | last_password_item = cfg_alloc(sizeof (struct password_item)); | |
138 | last_password_item->password = $2; | |
139 | last_password_item->from = 0; | |
140 | last_password_item->to = ~0; | |
141 | last_password_item->id = 0; | |
142 | last_password_item->next = NULL; | |
143 | $$=last_password_item; | |
144 | } | |
145 | ; | |
146 | ||
147 | password_items: | |
148 | /* empty */ { } | |
858a7177 PM |
149 | | FROM datetime password_items { last_password_item->from = $2; } |
150 | | TO datetime password_items { last_password_item->to = $2; } | |
900d5470 | 151 | | PASSIVE datetime password_items { last_password_item->passive = $2; } |
858a7177 | 152 | | ID NUM password_items { last_password_item->id = $2; } |
1a2ded45 PM |
153 | ; |
154 | ||
155 | password_list: | |
156 | /* empty */ { $$ = NULL; } | |
858a7177 PM |
157 | | password_begin password_items ';' password_list { |
158 | last_password_item->next = $4; | |
159 | $$ = last_password_item; | |
1a2ded45 PM |
160 | } |
161 | ; | |
162 | ||
da877822 MM |
163 | CF_CODE |
164 | ||
50d8424a MM |
165 | void |
166 | rt_dev_add_iface(char *n) | |
167 | { | |
31b3e1bb | 168 | struct rt_dev_config *p = (void *) this_proto; |
50d8424a MM |
169 | struct iface_patt *k = cfg_alloc(sizeof(struct iface_patt)); |
170 | ||
b35d72ac | 171 | k->pattern = cfg_strdup(n); |
50d8424a MM |
172 | add_tail(&p->iface_list, &k->n); |
173 | } | |
174 | ||
da877822 | 175 | CF_END |