1999-12-06 21:45:56 +08:00
|
|
|
/*
|
|
|
|
* BIRD -- UNIX Configuration
|
|
|
|
*
|
2000-01-17 00:44:50 +08:00
|
|
|
* (c) 1999--2000 Martin Mares <mj@ucw.cz>
|
1999-12-06 21:45:56 +08:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CF_HDR
|
|
|
|
|
2016-04-12 17:14:54 +08:00
|
|
|
#include "sysdep/unix/unix.h"
|
2002-11-13 16:30:56 +08:00
|
|
|
#include <stdio.h>
|
1999-12-06 21:45:56 +08:00
|
|
|
|
|
|
|
CF_DECLS
|
|
|
|
|
2009-06-20 05:49:34 +08:00
|
|
|
CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT)
|
2013-11-25 20:44:07 +08:00
|
|
|
CF_KEYWORDS(TIMEFORMAT, ISO, OLD, SHORT, LONG, BASE, NAME, CONFIRM, UNDO, CHECK, TIMEOUT)
|
2015-03-02 16:41:14 +08:00
|
|
|
CF_KEYWORDS(DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, TIMEOUT)
|
1999-12-06 21:45:56 +08:00
|
|
|
|
2012-12-26 19:40:48 +08:00
|
|
|
%type <i> log_mask log_mask_list log_cat cfg_timeout
|
1999-12-06 21:51:04 +08:00
|
|
|
%type <g> log_file
|
2000-01-17 00:44:50 +08:00
|
|
|
%type <t> cfg_name
|
2010-02-03 07:19:24 +08:00
|
|
|
%type <tf> timeformat_which
|
2010-04-07 17:00:36 +08:00
|
|
|
%type <t> syslog_name
|
1999-12-06 21:45:56 +08:00
|
|
|
|
|
|
|
CF_GRAMMAR
|
|
|
|
|
|
|
|
CF_ADDTO(conf, log_config)
|
|
|
|
|
1999-12-06 21:51:04 +08:00
|
|
|
log_config: LOG log_file log_mask ';' {
|
1999-12-06 21:45:56 +08:00
|
|
|
struct log_config *c = cfg_allocz(sizeof(struct log_config));
|
1999-12-06 21:51:04 +08:00
|
|
|
c->fh = $2;
|
1999-12-06 21:45:56 +08:00
|
|
|
c->mask = $3;
|
|
|
|
add_tail(&new_config->logfiles, &c->n);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2010-04-07 17:00:36 +08:00
|
|
|
syslog_name:
|
2014-05-30 05:05:03 +08:00
|
|
|
NAME text { $$ = $2; }
|
2010-04-07 17:00:36 +08:00
|
|
|
| { $$ = bird_name; }
|
|
|
|
;
|
|
|
|
|
1999-12-06 21:51:04 +08:00
|
|
|
log_file:
|
2014-05-30 05:05:03 +08:00
|
|
|
text {
|
1999-12-06 21:51:04 +08:00
|
|
|
FILE *f = tracked_fopen(new_config->pool, $1, "a");
|
|
|
|
if (!f) cf_error("Unable to open log file `%s': %m", $1);
|
|
|
|
$$ = f;
|
|
|
|
}
|
2010-04-07 17:00:36 +08:00
|
|
|
| SYSLOG syslog_name { $$ = NULL; new_config->syslog_name = $2; }
|
1999-12-06 21:51:04 +08:00
|
|
|
| STDERR { $$ = stderr; }
|
|
|
|
;
|
|
|
|
|
1999-12-06 21:45:56 +08:00
|
|
|
log_mask:
|
|
|
|
ALL { $$ = ~0; }
|
|
|
|
| '{' log_mask_list '}' { $$ = $2; }
|
|
|
|
;
|
|
|
|
|
|
|
|
log_mask_list:
|
|
|
|
log_cat { $$ = 1 << $1; }
|
|
|
|
| log_mask_list ',' log_cat { $$ = $1 | (1 << $3); }
|
|
|
|
;
|
|
|
|
|
|
|
|
log_cat:
|
|
|
|
DEBUG { $$ = L_DEBUG[0]; }
|
|
|
|
| TRACE { $$ = L_TRACE[0]; }
|
|
|
|
| INFO { $$ = L_INFO[0]; }
|
|
|
|
| REMOTE { $$ = L_REMOTE[0]; }
|
|
|
|
| WARNING { $$ = L_WARN[0]; }
|
|
|
|
| ERROR { $$ = L_ERR[0]; }
|
|
|
|
| AUTH { $$ = L_AUTH[0]; }
|
|
|
|
| FATAL { $$ = L_FATAL[0]; }
|
|
|
|
| BUG { $$ = L_BUG[0]; }
|
|
|
|
;
|
|
|
|
|
2010-01-03 19:17:52 +08:00
|
|
|
|
|
|
|
CF_ADDTO(conf, mrtdump_base)
|
|
|
|
|
|
|
|
mrtdump_base:
|
|
|
|
MRTDUMP PROTOCOLS mrtdump_mask ';' { new_config->proto_default_mrtdump = $3; }
|
2014-05-30 05:05:03 +08:00
|
|
|
| MRTDUMP text ';' {
|
2010-01-03 19:17:52 +08:00
|
|
|
FILE *f = tracked_fopen(new_config->pool, $2, "a");
|
|
|
|
if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2);
|
|
|
|
new_config->mrtdump_file = fileno(f);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2015-03-02 16:41:14 +08:00
|
|
|
|
2010-02-03 07:19:24 +08:00
|
|
|
CF_ADDTO(conf, timeformat_base)
|
2010-01-03 19:17:52 +08:00
|
|
|
|
2010-02-03 07:19:24 +08:00
|
|
|
timeformat_which:
|
|
|
|
ROUTE { $$ = &new_config->tf_route; }
|
|
|
|
| PROTOCOL { $$ = &new_config->tf_proto; }
|
|
|
|
| BASE { $$ = &new_config->tf_base; }
|
|
|
|
| LOG { $$ = &new_config->tf_log; }
|
2016-01-20 22:41:15 +08:00
|
|
|
;
|
2010-02-03 07:19:24 +08:00
|
|
|
|
|
|
|
timeformat_spec:
|
|
|
|
timeformat_which TEXT { *$1 = (struct timeformat){$2, NULL, 0}; }
|
|
|
|
| timeformat_which TEXT expr TEXT { *$1 = (struct timeformat){$2, $4, $3}; }
|
|
|
|
| timeformat_which ISO SHORT { *$1 = (struct timeformat){"%T", "%F", 20*3600}; }
|
|
|
|
| timeformat_which ISO LONG { *$1 = (struct timeformat){"%F %T", NULL, 0}; }
|
2013-11-25 20:44:07 +08:00
|
|
|
| timeformat_which OLD SHORT { *$1 = (struct timeformat){NULL, NULL, 0}; }
|
|
|
|
| timeformat_which OLD LONG { *$1 = (struct timeformat){"%d-%m-%Y %T", NULL, 0}; }
|
2010-02-03 07:19:24 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
timeformat_base:
|
|
|
|
TIMEFORMAT timeformat_spec ';'
|
|
|
|
;
|
2010-01-03 19:17:52 +08:00
|
|
|
|
2015-03-02 16:41:14 +08:00
|
|
|
|
|
|
|
CF_ADDTO(conf, debug_unix)
|
|
|
|
|
|
|
|
debug_unix:
|
|
|
|
DEBUG LATENCY bool { new_config->latency_debug = $3; }
|
|
|
|
| DEBUG LATENCY LIMIT expr_us { new_config->latency_limit = $4; }
|
|
|
|
| WATCHDOG WARNING expr_us { new_config->watchdog_warning = $3; }
|
|
|
|
| WATCHDOG TIMEOUT expr_us { new_config->watchdog_timeout = ($3 + 999999) TO_S; }
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2000-01-17 00:44:50 +08:00
|
|
|
/* Unix specific commands */
|
|
|
|
|
2012-12-26 19:40:48 +08:00
|
|
|
CF_CLI_HELP(CONFIGURE, ..., [[Reload configuration]])
|
2009-06-20 05:49:34 +08:00
|
|
|
|
2012-12-26 19:40:48 +08:00
|
|
|
CF_CLI(CONFIGURE, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration]])
|
|
|
|
{ cmd_reconfig($2, RECONFIG_HARD, $3); } ;
|
2009-06-20 05:49:34 +08:00
|
|
|
|
2012-12-26 19:40:48 +08:00
|
|
|
CF_CLI(CONFIGURE SOFT, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration and ignore changes in filters]])
|
|
|
|
{ cmd_reconfig($3, RECONFIG_SOFT, $4); } ;
|
|
|
|
|
|
|
|
/* Hack to get input completion for 'timeout' */
|
|
|
|
CF_CLI_CMD(CONFIGURE TIMEOUT, [<sec>], [[Reload configuration with undo timeout]])
|
|
|
|
CF_CLI_CMD(CONFIGURE SOFT TIMEOUT, [<sec>], [[Reload configuration with undo timeout]])
|
|
|
|
|
|
|
|
CF_CLI(CONFIGURE CONFIRM,,, [[Confirm last configuration change - deactivate undo timeout]])
|
|
|
|
{ cmd_reconfig_confirm(); } ;
|
|
|
|
|
|
|
|
CF_CLI(CONFIGURE UNDO,,, [[Undo last configuration change]])
|
|
|
|
{ cmd_reconfig_undo(); } ;
|
|
|
|
|
|
|
|
CF_CLI(CONFIGURE CHECK, cfg_name, [\"<file>\"], [[Parse configuration and check its validity]])
|
|
|
|
{ cmd_check_config($3); } ;
|
2000-01-17 00:44:50 +08:00
|
|
|
|
2000-03-08 04:09:35 +08:00
|
|
|
CF_CLI(DOWN,,, [[Shut the daemon down]])
|
2010-02-21 16:57:26 +08:00
|
|
|
{ cmd_shutdown(); } ;
|
2000-01-17 01:40:26 +08:00
|
|
|
|
2000-01-17 00:44:50 +08:00
|
|
|
cfg_name:
|
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| TEXT
|
|
|
|
;
|
|
|
|
|
2012-12-26 19:40:48 +08:00
|
|
|
cfg_timeout:
|
|
|
|
/* empty */ { $$ = 0; }
|
|
|
|
| TIMEOUT { $$ = UNIX_DEFAULT_CONFIGURE_TIMEOUT; }
|
|
|
|
| TIMEOUT expr { $$ = $2; }
|
|
|
|
;
|
|
|
|
|
1999-12-06 21:45:56 +08:00
|
|
|
CF_CODE
|
|
|
|
|
|
|
|
CF_END
|