1999-12-06 13:45:56 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- UNIX Configuration
|
|
|
|
*
|
2000-01-16 16:44:50 +00:00
|
|
|
* (c) 1999--2000 Martin Mares <mj@ucw.cz>
|
1999-12-06 13:45:56 +00:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CF_HDR
|
|
|
|
|
2016-04-12 09:14:54 +00:00
|
|
|
#include "sysdep/unix/unix.h"
|
2002-11-13 08:30:56 +00:00
|
|
|
#include <stdio.h>
|
1999-12-06 13:45:56 +00:00
|
|
|
|
2018-11-14 16:16:05 +00:00
|
|
|
CF_DEFINES
|
|
|
|
|
|
|
|
static struct log_config *this_log;
|
2024-06-24 11:46:12 +00:00
|
|
|
static struct cli_config *this_cli_config;
|
2018-11-14 16:16:05 +00:00
|
|
|
|
1999-12-06 13:45:56 +00:00
|
|
|
CF_DECLS
|
|
|
|
|
2024-06-24 09:09:46 +00:00
|
|
|
CF_KEYWORDS(LOG, SYSLOG, NAME, STDERR, UDP, PORT, CLI)
|
2023-12-13 02:48:12 +00:00
|
|
|
CF_KEYWORDS(ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG)
|
|
|
|
CF_KEYWORDS(DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, TIMEOUT, THREADS)
|
1999-12-06 13:45:56 +00:00
|
|
|
|
2012-12-26 11:40:48 +00:00
|
|
|
%type <i> log_mask log_mask_list log_cat cfg_timeout
|
2000-01-16 16:44:50 +00:00
|
|
|
%type <t> cfg_name
|
2010-04-07 09:00:36 +00:00
|
|
|
%type <t> syslog_name
|
1999-12-06 13:45:56 +00:00
|
|
|
|
|
|
|
CF_GRAMMAR
|
|
|
|
|
2023-06-09 11:49:17 +00:00
|
|
|
/* Dummy threads setting for forward compatibility */
|
|
|
|
conf: THREADS expr ';' ;
|
|
|
|
|
2018-06-26 12:29:03 +00:00
|
|
|
conf: log_config ;
|
1999-12-06 13:45:56 +00:00
|
|
|
|
2018-11-14 16:16:05 +00:00
|
|
|
log_begin: { this_log = cfg_allocz(sizeof(struct log_config)); };
|
|
|
|
|
|
|
|
log_config: LOG log_begin log_file log_mask ';' {
|
|
|
|
this_log->mask = $4;
|
|
|
|
add_tail(&new_config->logfiles, &this_log->n);
|
1999-12-06 13:45:56 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2010-04-07 09:00:36 +00:00
|
|
|
syslog_name:
|
2014-05-29 21:05:03 +00:00
|
|
|
NAME text { $$ = $2; }
|
2010-04-07 09:00:36 +00:00
|
|
|
| { $$ = bird_name; }
|
|
|
|
;
|
|
|
|
|
2018-11-14 16:16:05 +00:00
|
|
|
log_limit:
|
|
|
|
/* empty */
|
|
|
|
| expr text { this_log->limit = $1; this_log->backup = $2; }
|
|
|
|
;
|
|
|
|
|
1999-12-06 13:51:04 +00:00
|
|
|
log_file:
|
2018-11-14 16:16:05 +00:00
|
|
|
text log_limit {
|
2020-05-31 11:21:55 +00:00
|
|
|
if (!parse_and_exit)
|
|
|
|
{
|
|
|
|
this_log->rf = rf_open(new_config->pool, $1, "a");
|
|
|
|
if (!this_log->rf) cf_error("Unable to open log file '%s': %m", $1);
|
|
|
|
this_log->fh = rf_file(this_log->rf);
|
|
|
|
}
|
2018-11-14 16:16:05 +00:00
|
|
|
this_log->pos = -1;
|
|
|
|
this_log->filename = $1;
|
1999-12-06 13:51:04 +00:00
|
|
|
}
|
2018-11-14 16:16:05 +00:00
|
|
|
| SYSLOG syslog_name { this_log->fh = NULL; new_config->syslog_name = $2; }
|
|
|
|
| STDERR { this_log->fh = stderr; }
|
2023-12-13 02:48:12 +00:00
|
|
|
| UDP log_udp_host log_udp_port {
|
|
|
|
this_log->udp_flag = 1;
|
|
|
|
|
|
|
|
if (!parse_and_exit)
|
|
|
|
log_open_udp(this_log, new_config->pool);
|
|
|
|
}
|
1999-12-06 13:51:04 +00:00
|
|
|
;
|
|
|
|
|
2023-12-13 02:48:12 +00:00
|
|
|
log_udp_host: text_or_ipa
|
|
|
|
{
|
|
|
|
if ($1.type == T_STRING)
|
|
|
|
this_log->host = $1.val.s;
|
|
|
|
else if ($1.type == T_IP)
|
|
|
|
this_log->ip = $1.val.ip;
|
|
|
|
else bug("Bad text_or_ipa");
|
|
|
|
};
|
|
|
|
|
|
|
|
log_udp_port:
|
|
|
|
/* empty */ { this_log->port = 514; }
|
|
|
|
| PORT NUM { check_u16($2); this_log->port = $2; }
|
|
|
|
;
|
|
|
|
|
1999-12-06 13:45:56 +00: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 11:17:52 +00:00
|
|
|
|
2018-06-26 12:29:03 +00:00
|
|
|
conf: mrtdump_base ;
|
2010-01-03 11:17:52 +00:00
|
|
|
|
|
|
|
mrtdump_base:
|
|
|
|
MRTDUMP PROTOCOLS mrtdump_mask ';' { new_config->proto_default_mrtdump = $3; }
|
2014-05-29 21:05:03 +00:00
|
|
|
| MRTDUMP text ';' {
|
2020-05-31 11:21:55 +00:00
|
|
|
if (!parse_and_exit)
|
|
|
|
{
|
|
|
|
struct rfile *f = rf_open(new_config->pool, $2, "a");
|
|
|
|
if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2);
|
|
|
|
new_config->mrtdump_file = rf_fileno(f);
|
|
|
|
}
|
2010-01-03 11:17:52 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2024-06-24 09:10:07 +00:00
|
|
|
conf: cli ;
|
|
|
|
|
|
|
|
cli: CLI text cli_opts {
|
2024-06-24 11:46:12 +00:00
|
|
|
this_cli_config->name = $2;
|
|
|
|
cli_config_add_tail(&new_config->cli, this_cli_config);
|
|
|
|
this_cli_config = NULL;
|
2024-06-24 09:10:07 +00:00
|
|
|
} ;
|
|
|
|
|
2024-06-24 11:46:12 +00:00
|
|
|
cli_opts: cli_opts_begin '{' cli_opts_block '}' ';' | cli_opts_begin ';' ;
|
|
|
|
|
|
|
|
cli_opts_begin: {
|
|
|
|
this_cli_config = cfg_alloc(sizeof *this_cli_config);
|
|
|
|
*this_cli_config = (typeof (*this_cli_config)) {
|
2024-06-24 09:10:07 +00:00
|
|
|
.config = new_config,
|
|
|
|
.mode = 0660,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-06-24 11:46:12 +00:00
|
|
|
cli_opts_block:
|
|
|
|
/* EMPTY */ |
|
|
|
|
cli_opts_block RESTRICT { this_cli_config->restricted = 1; }
|
|
|
|
;
|
|
|
|
|
2018-06-26 12:29:03 +00:00
|
|
|
conf: debug_unix ;
|
2015-03-02 08:41:14 +00:00
|
|
|
|
|
|
|
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-16 16:44:50 +00:00
|
|
|
/* Unix specific commands */
|
|
|
|
|
2012-12-26 11:40:48 +00:00
|
|
|
CF_CLI_HELP(CONFIGURE, ..., [[Reload configuration]])
|
2009-06-19 21:49:34 +00:00
|
|
|
|
2012-12-26 11:40:48 +00:00
|
|
|
CF_CLI(CONFIGURE, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration]])
|
|
|
|
{ cmd_reconfig($2, RECONFIG_HARD, $3); } ;
|
2009-06-19 21:49:34 +00:00
|
|
|
|
2012-12-26 11:40:48 +00: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(); } ;
|
|
|
|
|
2019-06-12 14:13:21 +00:00
|
|
|
CF_CLI(CONFIGURE STATUS,,, [[Show configuration status]])
|
|
|
|
{ cmd_reconfig_status(); } ;
|
|
|
|
|
2012-12-26 11:40:48 +00:00
|
|
|
CF_CLI(CONFIGURE CHECK, cfg_name, [\"<file>\"], [[Parse configuration and check its validity]])
|
|
|
|
{ cmd_check_config($3); } ;
|
2000-01-16 16:44:50 +00:00
|
|
|
|
2000-03-07 20:09:35 +00:00
|
|
|
CF_CLI(DOWN,,, [[Shut the daemon down]])
|
2010-02-21 08:57:26 +00:00
|
|
|
{ cmd_shutdown(); } ;
|
2000-01-16 17:40:26 +00:00
|
|
|
|
2019-09-22 21:32:22 +00:00
|
|
|
CF_CLI_HELP(GRACEFUL, restart, [[Shut the daemon down for graceful restart]])
|
|
|
|
|
2019-07-31 17:45:29 +00:00
|
|
|
CF_CLI(GRACEFUL RESTART,,, [[Shut the daemon down for graceful restart]])
|
2019-06-18 14:27:21 +00:00
|
|
|
{ cmd_graceful_restart(); } ;
|
|
|
|
|
|
|
|
|
2000-01-16 16:44:50 +00:00
|
|
|
cfg_name:
|
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| TEXT
|
|
|
|
;
|
|
|
|
|
2012-12-26 11:40:48 +00:00
|
|
|
cfg_timeout:
|
|
|
|
/* empty */ { $$ = 0; }
|
|
|
|
| TIMEOUT { $$ = UNIX_DEFAULT_CONFIGURE_TIMEOUT; }
|
|
|
|
| TIMEOUT expr { $$ = $2; }
|
|
|
|
;
|
|
|
|
|
1999-12-06 13:45:56 +00:00
|
|
|
CF_CODE
|
|
|
|
|
|
|
|
CF_END
|