2 * BIRD -- Core Configuration
4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
11 #include "nest/rt-dev.h"
12 #include "nest/password.h"
13 #include "nest/cmds.h"
17 static struct proto_config *this_proto;
18 static struct iface_patt *this_ipatt;
22 CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
23 CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
24 CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
25 CF_KEYWORDS(PRIMARY, STATS)
27 CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
28 RIP, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE)
33 %type <p> password_list password_begin
36 %type <i> echo_mask echo_size debug_mask debug_list debug_flag import_or_proto
41 /* Setting of router ID */
45 rtrid: ROUTER ID idval ';' {
46 new_config->router_id = $3;
57 cf_error("Router IDs must be entered as hexadecimal numbers in IPv6 version");
62 /* Creation of routing tables */
64 CF_ADDTO(conf, newtab)
71 /* Definition of protocols */
79 struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter);
82 this_proto->name = s->name;
85 cf_define_symbol($1, SYM_PROTO, this_proto);
86 this_proto->name = $1->name;
93 if ($2 < 0 || $2 > 255) cf_error("Invalid preference");
94 this_proto->preference = $2;
96 | DISABLED { this_proto->disabled = 1; }
97 | DEBUG debug_mask { this_proto->debug = $2; }
98 | IMPORT imexport { this_proto->in_filter = $2; }
99 | EXPORT imexport { this_proto->out_filter = $2; }
100 | TABLE rtable { this_proto->table = $2; }
104 FILTER filter { $$ = $2; }
106 | ALL { $$ = FILTER_ACCEPT; }
107 | NONE { $$ = FILTER_REJECT; }
112 if ($1->class != SYM_TABLE) cf_error("Table name expected");
117 CF_ADDTO(conf, debug_default)
120 DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; }
123 /* Interface patterns */
126 TEXT { this_ipatt->pattern = $1; this_ipatt->prefix = IPA_NONE; this_ipatt->pxlen = 0; }
127 | IPA pxlen { this_ipatt->pattern = NULL; this_ipatt->prefix = $1; this_ipatt->pxlen = $2; }
128 | TEXT IPA pxlen { this_ipatt->pattern = $1; this_ipatt->prefix = $2; this_ipatt->pxlen = $3; }
131 /* Direct device route protocol */
133 CF_ADDTO(proto, dev_proto '}')
135 dev_proto_start: proto_start DIRECT {
136 struct rt_dev_config *p = proto_config_new(&proto_device, sizeof(struct rt_dev_config));
138 p->c.preference = DEF_PREF_DIRECT;
139 init_list(&p->iface_list);
144 dev_proto_start proto_name '{'
145 | dev_proto proto_item ';'
146 | dev_proto dev_iface_list ';'
149 dev_iface_entry_init:
151 struct rt_dev_config *p = (void *) this_proto;
152 struct iface_patt *k = cfg_allocz(sizeof(struct iface_patt));
153 add_tail(&p->iface_list, &k->n);
159 dev_iface_entry_init iface_patt
163 INTERFACE dev_iface_entry
164 | dev_iface_list ',' dev_iface_entry
172 | '{' debug_list '}' { $$ = $2; }
177 | debug_list ',' debug_flag { $$ = $1 | $3; }
181 STATES { $$ = D_STATES; }
182 | ROUTES { $$ = D_ROUTES; }
183 | FILTERS { $$ = D_FILTERS; }
184 | INTERFACES { $$ = D_IFACES; }
185 | EVENTS { $$ = D_EVENTS; }
186 | PACKETS { $$ = D_PACKETS; }
193 last_password_item = cfg_alloc(sizeof (struct password_item));
194 last_password_item->password = $2;
195 last_password_item->from = 0;
196 last_password_item->to = TIME_INFINITY;
197 last_password_item->id = 0;
198 last_password_item->next = NULL;
199 $$=last_password_item;
205 | FROM datetime password_items { last_password_item->from = $2; }
206 | TO datetime password_items { last_password_item->to = $2; }
207 | PASSIVE datetime password_items { last_password_item->passive = $2; }
208 | ID NUM password_items { last_password_item->id = $2; }
212 /* empty */ { $$ = NULL; }
213 | password_begin password_items ';' password_list {
221 CF_CLI_HELP(SHOW, ..., [[Show status information]])
223 CF_CLI(SHOW STATUS,,, [[Show router status]])
224 { cmd_show_status(); }
226 CF_CLI(SHOW PROTOCOLS, optsym, [<name>], [[Show routing protocols]])
227 { proto_show($3, 0); } ;
229 CF_CLI(SHOW PROTOCOLS ALL, optsym, [<name>], [[Show routing protocol details]])
230 { proto_show($4, 1); } ;
234 | /* empty */ { $$ = NULL; }
237 CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]])
240 CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
241 { if_show_summary(); } ;
243 CF_CLI(SHOW ROUTE, r_args, [<prefix>] [table <t>] [filter <f>] [all] [primary] [(import|protocol) <p>] [stats], [[Show routing table]])
248 $$ = cfg_allocz(sizeof(struct rt_show_data));
250 $$->filter = FILTER_ACCEPT;
251 $$->table = config->master_rtc->table;
255 if ($$->pxlen != 256) cf_error("Only one prefix expected");
256 if (!ip_is_prefix($2, $3)) cf_error("Invalid prefix");
262 if ($3->class != SYM_TABLE) cf_error("%s is not a table", $3->name);
263 $$->table = ((struct rtable_config *)$3->def)->table;
265 | r_args FILTER filter {
267 if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
270 | r_args where_filter {
272 if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice");
281 $$->primary_only = 1;
283 | r_args import_or_proto SYM {
284 struct proto_config *c = (struct proto_config *) $3->def;
286 if ($$->import_mode) cf_error("Protocol specified twice");
287 if ($3->class != SYM_PROTO || !c->proto) cf_error("%s is not a protocol", $3->name);
288 $$->import_mode = $2;
289 $$->primary_only = 1;
290 $$->import_protocol = c->proto;
291 $$->running_on_config = c->proto->cf->global;
301 | PROTOCOL { $$ = 2; }
304 CF_CLI(SHOW SYMBOLS, optsym, [<symbol>], [[Show all known symbolic names]])
305 { cmd_show_symbols($3); } ;
307 CF_CLI_HELP(DUMP, ..., [[Dump debugging information]])
308 CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]])
309 { rdump(&root_pool); cli_msg(0, ""); } ;
310 CF_CLI(DUMP SOCKETS,,, [[Dump open sockets]])
311 { sk_dump_all(); cli_msg(0, ""); } ;
312 CF_CLI(DUMP INTERFACES,,, [[Dump interface information]])
313 { if_dump_all(); cli_msg(0, ""); } ;
314 CF_CLI(DUMP NEIGHBORS,,, [[Dump neighbor cache]])
315 { neigh_dump_all(); cli_msg(0, ""); } ;
316 CF_CLI(DUMP ATTRIBUTES,,, [[Dump attribute cache]])
317 { rta_dump_all(); cli_msg(0, ""); } ;
318 CF_CLI(DUMP ROUTES,,, [[Dump routing table]])
319 { rt_dump_all(); cli_msg(0, ""); } ;
320 CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]])
321 { protos_dump_all(); cli_msg(0, ""); } ;
323 CF_CLI(ECHO, echo_mask echo_size, [all | off | <mask>] [<buffer-size>], [[Configure echoing of log messages]]) {
324 cli_set_log_echo(this_cli, $2, $3);
335 /* empty */ { $$ = 4096; }
337 if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size");
342 CF_CLI(DISABLE, proto_patt, <protocol> | <pattern> | all, [[Disable protocol]])
343 { proto_xxable($2, 0); } ;
344 CF_CLI(ENABLE, proto_patt, <protocol> | <pattern> | all, [[Enable protocol]])
345 { proto_xxable($2, 1); } ;
346 CF_CLI(RESTART, proto_patt, <protocol> | <pattern> | all, [[Restart protocol]])
347 { proto_xxable($2, 2); } ;
349 CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging]])
350 CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | <pattern> | all) (all | off | { states | routes | filters | events | packets }), [[Control protocol debugging]])
351 { proto_debug($2, $3); }
354 SYM { $$ = $1->name; }