]> git.ipfire.org Git - thirdparty/bird.git/blame - sysdep/unix/config.Y
Add CLI command to test reconfiguration status
[thirdparty/bird.git] / sysdep / unix / config.Y
CommitLineData
a0c37b45
MM
1/*
2 * BIRD -- UNIX Configuration
3 *
50fe90ed 4 * (c) 1999--2000 Martin Mares <mj@ucw.cz>
a0c37b45
MM
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9CF_HDR
10
7152e5ef 11#include "sysdep/unix/unix.h"
a19cd811 12#include <stdio.h>
a0c37b45 13
6712e772
OZ
14CF_DEFINES
15
16static struct log_config *this_log;
17
a0c37b45
MM
18CF_DECLS
19
bf1aec97 20CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT)
9106a750 21CF_KEYWORDS(NAME, CONFIRM, UNDO, CHECK, TIMEOUT, DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, STATUS)
a0c37b45 22
a92cf57d 23%type <i> log_mask log_mask_list log_cat cfg_timeout
50fe90ed 24%type <t> cfg_name
c37e7851 25%type <tf> timeformat_which
44d4ab7a 26%type <t> syslog_name
a0c37b45
MM
27
28CF_GRAMMAR
29
f851f0d7 30conf: log_config ;
a0c37b45 31
6712e772
OZ
32log_begin: { this_log = cfg_allocz(sizeof(struct log_config)); };
33
34log_config: LOG log_begin log_file log_mask ';' {
35 this_log->mask = $4;
36 add_tail(&new_config->logfiles, &this_log->n);
a0c37b45
MM
37 }
38 ;
39
44d4ab7a 40syslog_name:
9eceab33 41 NAME text { $$ = $2; }
44d4ab7a
OZ
42 | { $$ = bird_name; }
43 ;
44
6712e772
OZ
45log_limit:
46 /* empty */
47 | expr text { this_log->limit = $1; this_log->backup = $2; }
48 ;
49
f78056fb 50log_file:
6712e772
OZ
51 text log_limit {
52 this_log->rf = rf_open(new_config->pool, $1, "a");
53 if (!this_log->rf) cf_error("Unable to open log file '%s': %m", $1);
54 this_log->fh = rf_file(this_log->rf);
55 this_log->pos = -1;
56 this_log->filename = $1;
f78056fb 57 }
6712e772
OZ
58 | SYSLOG syslog_name { this_log->fh = NULL; new_config->syslog_name = $2; }
59 | STDERR { this_log->fh = stderr; }
f78056fb
MM
60 ;
61
a0c37b45
MM
62log_mask:
63 ALL { $$ = ~0; }
64 | '{' log_mask_list '}' { $$ = $2; }
65 ;
66
67log_mask_list:
68 log_cat { $$ = 1 << $1; }
69 | log_mask_list ',' log_cat { $$ = $1 | (1 << $3); }
70 ;
71
72log_cat:
73 DEBUG { $$ = L_DEBUG[0]; }
74 | TRACE { $$ = L_TRACE[0]; }
75 | INFO { $$ = L_INFO[0]; }
76 | REMOTE { $$ = L_REMOTE[0]; }
77 | WARNING { $$ = L_WARN[0]; }
78 | ERROR { $$ = L_ERR[0]; }
79 | AUTH { $$ = L_AUTH[0]; }
80 | FATAL { $$ = L_FATAL[0]; }
81 | BUG { $$ = L_BUG[0]; }
82 ;
83
cf31112f 84
f851f0d7 85conf: mrtdump_base ;
cf31112f
OZ
86
87mrtdump_base:
88 MRTDUMP PROTOCOLS mrtdump_mask ';' { new_config->proto_default_mrtdump = $3; }
9eceab33 89 | MRTDUMP text ';' {
c68ba7d0 90 struct rfile *f = rf_open(new_config->pool, $2, "a");
cf31112f 91 if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2);
c68ba7d0 92 new_config->mrtdump_file = rf_fileno(f);
cf31112f
OZ
93 }
94 ;
95
8bcb5fb1 96
f851f0d7 97conf: debug_unix ;
8bcb5fb1
OZ
98
99debug_unix:
100 DEBUG LATENCY bool { new_config->latency_debug = $3; }
101 | DEBUG LATENCY LIMIT expr_us { new_config->latency_limit = $4; }
102 | WATCHDOG WARNING expr_us { new_config->watchdog_warning = $3; }
103 | WATCHDOG TIMEOUT expr_us { new_config->watchdog_timeout = ($3 + 999999) TO_S; }
104 ;
105
106
50fe90ed
MM
107/* Unix specific commands */
108
a92cf57d 109CF_CLI_HELP(CONFIGURE, ..., [[Reload configuration]])
bf1aec97 110
a92cf57d
OZ
111CF_CLI(CONFIGURE, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration]])
112{ cmd_reconfig($2, RECONFIG_HARD, $3); } ;
bf1aec97 113
a92cf57d
OZ
114CF_CLI(CONFIGURE SOFT, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration and ignore changes in filters]])
115{ cmd_reconfig($3, RECONFIG_SOFT, $4); } ;
116
117/* Hack to get input completion for 'timeout' */
118CF_CLI_CMD(CONFIGURE TIMEOUT, [<sec>], [[Reload configuration with undo timeout]])
119CF_CLI_CMD(CONFIGURE SOFT TIMEOUT, [<sec>], [[Reload configuration with undo timeout]])
120
121CF_CLI(CONFIGURE CONFIRM,,, [[Confirm last configuration change - deactivate undo timeout]])
122{ cmd_reconfig_confirm(); } ;
123
124CF_CLI(CONFIGURE UNDO,,, [[Undo last configuration change]])
125{ cmd_reconfig_undo(); } ;
126
9106a750
OZ
127CF_CLI(CONFIGURE STATUS,,, [[Show configuration status]])
128{ cmd_reconfig_status(); } ;
129
a92cf57d
OZ
130CF_CLI(CONFIGURE CHECK, cfg_name, [\"<file>\"], [[Parse configuration and check its validity]])
131{ cmd_check_config($3); } ;
50fe90ed 132
c801e1fb 133CF_CLI(DOWN,,, [[Shut the daemon down]])
e0a45fb4 134{ cmd_shutdown(); } ;
bf8558bc 135
50fe90ed
MM
136cfg_name:
137 /* empty */ { $$ = NULL; }
138 | TEXT
139 ;
140
a92cf57d
OZ
141cfg_timeout:
142 /* empty */ { $$ = 0; }
143 | TIMEOUT { $$ = UNIX_DEFAULT_CONFIGURE_TIMEOUT; }
144 | TIMEOUT expr { $$ = $2; }
145 ;
146
a0c37b45
MM
147CF_CODE
148
149CF_END