]>
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; |
8edf2361 | 12 | static struct iface_patt *this_ipatt; |
c74c0e3c | 13 | |
50d8424a | 14 | #include "nest/rt-dev.h" |
1a2ded45 | 15 | #include "nest/password.h" |
50d8424a | 16 | |
da877822 MM |
17 | CF_DECLS |
18 | ||
7e5f5ffd | 19 | CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT) |
0e02abfd | 20 | CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE) |
900d5470 | 21 | CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID) |
da877822 | 22 | |
7d509304 MM |
23 | CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT, |
24 | RIP, RIP_EXT, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE) | |
25 | ||
dce26783 | 26 | %type <i32> idval |
5056c559 | 27 | %type <f> imexport |
0e02abfd | 28 | %type <r> rtable |
1a2ded45 | 29 | %type <p> password_list password_begin |
ae97b946 | 30 | %type <s> optsym |
730f2e2c | 31 | %type <ra> r_args |
34350a52 | 32 | %type <i> echo_mask echo_size |
f14a4bec | 33 | %type <t> proto_patt |
da877822 MM |
34 | |
35 | CF_GRAMMAR | |
36 | ||
c74c0e3c MM |
37 | /* Setting of router ID */ |
38 | ||
da877822 | 39 | CF_ADDTO(conf, rtrid) |
0e02abfd | 40 | |
7f400d1c | 41 | rtrid: ROUTER ID idval ';' { |
31b3e1bb | 42 | new_config->router_id = $3; |
c74c0e3c | 43 | } |
da877822 MM |
44 | ; |
45 | ||
46 | idval: | |
dce26783 MM |
47 | NUM { $$ = $1; } |
48 | | RTRID | |
49 | | IPA { | |
50 | #ifndef IPV6 | |
51 | $$ = ipa_to_u32($1); | |
52 | #else | |
53 | cf_error("Router IDs must be entered as hexadecimal numbers in IPv6 version"); | |
54 | #endif | |
55 | } | |
da877822 MM |
56 | ; |
57 | ||
0e02abfd MM |
58 | /* Creation of routing tables */ |
59 | ||
60 | CF_ADDTO(conf, newtab) | |
61 | ||
62 | newtab: TABLE SYM { | |
63 | struct rtable_config *c = cfg_allocz(sizeof(struct rtable_config)); | |
64 | struct symbol *s = $2; | |
65 | cf_define_symbol(s, SYM_TABLE, c); | |
66 | c->name = s->name; | |
67 | add_tail(&new_config->tables, &c->n); | |
68 | } | |
69 | ; | |
70 | ||
c74c0e3c MM |
71 | /* Definition of protocols */ |
72 | ||
73 | CF_ADDTO(conf, proto) | |
74 | ||
75 | proto_start: PROTOCOL | |
76 | ||
77 | proto_name: | |
78 | /* EMPTY */ { | |
f0474f20 | 79 | struct symbol *s = cf_default_name(this_proto->protocol->name, &this_proto->protocol->name_counter); |
c74c0e3c MM |
80 | s->class = SYM_PROTO; |
81 | s->def = this_proto; | |
82 | this_proto->name = s->name; | |
83 | } | |
84 | | SYM { | |
0e02abfd | 85 | cf_define_symbol($1, SYM_PROTO, this_proto); |
c74c0e3c MM |
86 | this_proto->name = $1->name; |
87 | } | |
88 | ; | |
89 | ||
90 | proto_item: | |
91 | /* EMPTY */ | |
0b62c3a7 | 92 | | PREFERENCE expr { |
c74c0e3c MM |
93 | if ($2 < 0 || $2 > 255) cf_error("Invalid preference"); |
94 | this_proto->preference = $2; | |
95 | } | |
bd5d0d62 MM |
96 | | DISABLED { this_proto->disabled = 1; } |
97 | | DEBUG expr { this_proto->debug = $2; } | |
98 | | DEBUG ALL { this_proto->debug = ~0; } | |
99 | | DEBUG OFF { this_proto->debug = 0; } | |
5056c559 MM |
100 | | IMPORT imexport { this_proto->in_filter = $2; } |
101 | | EXPORT imexport { this_proto->out_filter = $2; } | |
0e02abfd | 102 | | TABLE rtable { this_proto->table = $2; } |
5056c559 MM |
103 | ; |
104 | ||
105 | imexport: | |
106 | FILTER filter { $$ = $2; } | |
107 | | ALL { $$ = FILTER_ACCEPT; } | |
108 | | NONE { $$ = FILTER_REJECT; } | |
c74c0e3c MM |
109 | ; |
110 | ||
0e02abfd MM |
111 | rtable: |
112 | SYM { | |
113 | if ($1->class != SYM_TABLE) cf_error("Table name expected"); | |
114 | $$ = $1->def; | |
115 | } | |
116 | ; | |
117 | ||
8edf2361 MM |
118 | /* Interface patterns */ |
119 | ||
120 | iface_patt: | |
121 | TEXT { this_ipatt->pattern = $1; this_ipatt->prefix = IPA_NONE; this_ipatt->pxlen = 0; } | |
122 | | IPA pxlen { this_ipatt->pattern = NULL; this_ipatt->prefix = $1; this_ipatt->pxlen = $2; } | |
123 | | TEXT IPA pxlen { this_ipatt->pattern = $1; this_ipatt->prefix = $2; this_ipatt->pxlen = $3; } | |
124 | ; | |
125 | ||
7e5f5ffd | 126 | /* Direct device route protocol */ |
50d8424a MM |
127 | |
128 | CF_ADDTO(proto, dev_proto '}') | |
129 | ||
7e5f5ffd MM |
130 | dev_proto_start: proto_start DIRECT { |
131 | struct rt_dev_config *p = proto_config_new(&proto_device, sizeof(struct rt_dev_config)); | |
7e5f5ffd MM |
132 | this_proto = &p->c; |
133 | p->c.preference = DEF_PREF_DIRECT; | |
134 | init_list(&p->iface_list); | |
50d8424a MM |
135 | } |
136 | ; | |
137 | ||
138 | dev_proto: | |
7e5f5ffd | 139 | dev_proto_start proto_name '{' |
50d8424a MM |
140 | | dev_proto proto_item ';' |
141 | | dev_proto dev_iface_list ';' | |
142 | ; | |
143 | ||
8edf2361 MM |
144 | dev_iface_entry_init: |
145 | /* EMPTY */ { | |
146 | struct rt_dev_config *p = (void *) this_proto; | |
147 | struct iface_patt *k = cfg_allocz(sizeof(struct iface_patt)); | |
148 | add_tail(&p->iface_list, &k->n); | |
149 | this_ipatt = k; | |
50d8424a | 150 | } |
50d8424a MM |
151 | ; |
152 | ||
8edf2361 MM |
153 | dev_iface_entry: |
154 | dev_iface_entry_init iface_patt | |
155 | ; | |
156 | ||
157 | dev_iface_list: | |
158 | INTERFACE dev_iface_entry | |
159 | | dev_iface_list ',' dev_iface_entry | |
160 | ; | |
161 | ||
162 | /* Password lists */ | |
163 | ||
1a2ded45 PM |
164 | password_begin: |
165 | PASSWORD TEXT { | |
166 | last_password_item = cfg_alloc(sizeof (struct password_item)); | |
167 | last_password_item->password = $2; | |
168 | last_password_item->from = 0; | |
f0474f20 | 169 | last_password_item->to = TIME_INFINITY; |
1a2ded45 PM |
170 | last_password_item->id = 0; |
171 | last_password_item->next = NULL; | |
172 | $$=last_password_item; | |
173 | } | |
174 | ; | |
175 | ||
176 | password_items: | |
177 | /* empty */ { } | |
858a7177 PM |
178 | | FROM datetime password_items { last_password_item->from = $2; } |
179 | | TO datetime password_items { last_password_item->to = $2; } | |
900d5470 | 180 | | PASSIVE datetime password_items { last_password_item->passive = $2; } |
858a7177 | 181 | | ID NUM password_items { last_password_item->id = $2; } |
1a2ded45 PM |
182 | ; |
183 | ||
184 | password_list: | |
185 | /* empty */ { $$ = NULL; } | |
858a7177 | 186 | | password_begin password_items ';' password_list { |
ac40c888 PM |
187 | $1->next = $4; |
188 | $$ = $1; | |
1a2ded45 PM |
189 | } |
190 | ; | |
191 | ||
bc2fb680 MM |
192 | /* Core commands */ |
193 | ||
ae97b946 MM |
194 | CF_CLI_HELP(SHOW,,[[Show status information]]) |
195 | ||
196 | CF_CLI(SHOW STATUS,,, [[Show router status]]) { | |
0d3e6bce | 197 | cli_msg(1000, "BIRD " BIRD_VERSION); |
ae97b946 MM |
198 | /* FIXME: Should include uptime, shutdown flag et cetera */ |
199 | } ; | |
200 | ||
201 | CF_CLI(SHOW PROTOCOLS, optsym, [<name>], [[Show routing protocols]]) | |
0d3e6bce MM |
202 | { proto_show($3, 0); } ; |
203 | ||
28e01f85 | 204 | CF_CLI(SHOW PROTOCOLS ALL, optsym, [<name>], [[Show routing protocol details]]) |
0d3e6bce | 205 | { proto_show($4, 1); } ; |
ae97b946 | 206 | |
730f2e2c MM |
207 | optsym: |
208 | SYM | |
209 | | /* empty */ { $$ = NULL; } | |
210 | ; | |
211 | ||
ae97b946 MM |
212 | CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]]) |
213 | { if_show(); } ; | |
214 | ||
215 | CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]]) | |
216 | { if_show_summary(); } ; | |
217 | ||
730f2e2c MM |
218 | CF_CLI(SHOW ROUTE, r_args, [<prefix>] [table <t>] [filter <f>] [all], [[Show routing table]]) |
219 | { rt_show($3); } ; | |
220 | ||
221 | r_args: | |
222 | /* empty */ { | |
223 | $$ = cfg_allocz(sizeof(struct rt_show_data)); | |
224 | $$->pxlen = 256; | |
225 | $$->filter = FILTER_ACCEPT; | |
226 | $$->table = config->master_rtc->table; | |
227 | } | |
228 | | r_args IPA pxlen { | |
229 | $$ = $1; | |
230 | if ($$->pxlen != 256) cf_error("Only one prefix expected"); | |
231 | if (!ip_is_prefix($2, $3)) cf_error("Invalid prefix"); | |
232 | $$->prefix = $2; | |
233 | $$->pxlen = $3; | |
234 | } | |
235 | | r_args TABLE SYM { | |
236 | $$ = $1; | |
237 | if ($3->class != SYM_TABLE) cf_error("%s is not a table", $3->name); | |
238 | $$->table = ((struct rtable_config *)$3->def)->table; | |
239 | } | |
240 | | r_args FILTER filter { | |
241 | $$ = $1; | |
430da60f | 242 | if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice"); |
730f2e2c MM |
243 | $$->filter = $3; |
244 | } | |
430da60f MM |
245 | | r_args where_filter { |
246 | $$ = $1; | |
247 | if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice"); | |
248 | $$->filter = $2; | |
249 | } | |
730f2e2c MM |
250 | | r_args ALL { |
251 | $$ = $1; | |
252 | $$->verbose = 1; | |
253 | } | |
254 | ; | |
255 | ||
305a01f5 MM |
256 | CF_CLI_HELP(DEBUG, <subsystem>, [[Show debugging information]]) |
257 | CF_CLI(DEBUG RESOURCES,,, [[Show all allocated resource]]) | |
34350a52 | 258 | { rdump(&root_pool); cli_msg(0, ""); } ; |
305a01f5 | 259 | CF_CLI(DEBUG SOCKETS,,, [[Show open sockets]]) |
34350a52 | 260 | { sk_dump_all(); cli_msg(0, ""); } ; |
305a01f5 | 261 | CF_CLI(DEBUG INTERFACES,,, [[Show interface information]]) |
34350a52 | 262 | { if_dump_all(); cli_msg(0, ""); } ; |
305a01f5 | 263 | CF_CLI(DEBUG NEIGHBORS,,, [[Show neighbor cache]]) |
34350a52 | 264 | { neigh_dump_all(); cli_msg(0, ""); } ; |
305a01f5 | 265 | CF_CLI(DEBUG ATTRIBUTES,,, [[Show attribute cache]]) |
34350a52 | 266 | { rta_dump_all(); cli_msg(0, ""); } ; |
305a01f5 | 267 | CF_CLI(DEBUG ROUTES,,, [[Show routing table]]) |
34350a52 | 268 | { rt_dump_all(); cli_msg(0, ""); } ; |
305a01f5 | 269 | CF_CLI(DEBUG PROTOCOLS,,, [[Show protocol information]]) |
34350a52 MM |
270 | { protos_dump_all(); cli_msg(0, ""); } ; |
271 | ||
272 | CF_CLI(ECHO, echo_mask echo_size, [all | off | <mask>] [<buffer-size>], [[Configure echoing of log messages]]) { | |
273 | cli_set_log_echo(this_cli, $2, $3); | |
274 | cli_msg(0, ""); | |
275 | } ; | |
276 | ||
277 | echo_mask: | |
278 | ALL { $$ = ~0; } | |
279 | | OFF { $$ = 0; } | |
280 | | NUM | |
281 | ; | |
282 | ||
283 | echo_size: | |
284 | /* empty */ { $$ = 4096; } | |
285 | | NUM { | |
286 | if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size"); | |
287 | $$ = $1; | |
288 | } | |
289 | ; | |
bc2fb680 | 290 | |
f14a4bec MM |
291 | CF_CLI(DISABLE, proto_patt, <protocol> | <pattern> | all, [[Disable protocol]]) |
292 | { proto_xxable($2, 0); } ; | |
293 | CF_CLI(ENABLE, proto_patt, <protocol> | <pattern> | all, [[Enable protocol]]) | |
294 | { proto_xxable($2, 1); } ; | |
295 | CF_CLI(RESTART, proto_patt, <protocol> | <pattern> | all, [[Restart protocol]]) | |
296 | { proto_xxable($2, 2); } ; | |
297 | ||
298 | proto_patt: | |
299 | SYM { $$ = $1->name; } | |
300 | | ALL { $$ = "*"; } | |
301 | | TEXT | |
302 | ; | |
303 | ||
da877822 MM |
304 | CF_CODE |
305 | ||
306 | CF_END |