Statistics
| Branch: | Revision:

iof-bird / bird-2.0.1 / sysdep / unix / config.Y @ 6b3f1a54

History | View | Annotate | Download (3.35 KB)

1
/*
2
 *	BIRD -- UNIX Configuration
3
 *
4
 *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
5
 *
6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

    
9
CF_HDR
10

    
11
#include "sysdep/unix/unix.h"
12
#include <stdio.h>
13

    
14
CF_DECLS
15

    
16
CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT)
17
CF_KEYWORDS(NAME, CONFIRM, UNDO, CHECK, TIMEOUT, DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING)
18

    
19
%type <i> log_mask log_mask_list log_cat cfg_timeout
20
%type <g> log_file
21
%type <t> cfg_name
22
%type <tf> timeformat_which
23
%type <t> syslog_name
24

    
25
CF_GRAMMAR
26

    
27
CF_ADDTO(conf, log_config)
28

    
29
log_config: LOG log_file log_mask ';' {
30
    struct log_config *c = cfg_allocz(sizeof(struct log_config));
31
    c->fh = $2;
32
    c->mask = $3;
33
    add_tail(&new_config->logfiles, &c->n);
34
  }
35
 ;
36

    
37
syslog_name:
38
   NAME text { $$ = $2; }
39
 | { $$ = bird_name; }
40
 ;
41

    
42
log_file:
43
   text {
44
     FILE *f = tracked_fopen(new_config->pool, $1, "a");
45
     if (!f) cf_error("Unable to open log file `%s': %m", $1);
46
     $$ = f;
47
   }
48
 | SYSLOG syslog_name { $$ = NULL; new_config->syslog_name = $2; }
49
 | STDERR { $$ = stderr; }
50
 ;
51

    
52
log_mask:
53
   ALL { $$ = ~0; }
54
 | '{' log_mask_list '}' { $$ = $2; }
55
 ;
56

    
57
log_mask_list:
58
   log_cat { $$ = 1 << $1; }
59
 | log_mask_list ',' log_cat { $$ = $1 | (1 << $3); }
60
 ;
61

    
62
log_cat:
63
   DEBUG { $$ = L_DEBUG[0]; }
64
 | TRACE { $$ = L_TRACE[0]; }
65
 | INFO { $$ = L_INFO[0]; }
66
 | REMOTE { $$ = L_REMOTE[0]; }
67
 | WARNING { $$ = L_WARN[0]; }
68
 | ERROR { $$ = L_ERR[0]; }
69
 | AUTH { $$ = L_AUTH[0]; }
70
 | FATAL { $$ = L_FATAL[0]; }
71
 | BUG { $$ = L_BUG[0]; }
72
 ;
73

    
74

    
75
CF_ADDTO(conf, mrtdump_base)
76

    
77
mrtdump_base:
78
   MRTDUMP PROTOCOLS mrtdump_mask ';' { new_config->proto_default_mrtdump = $3; }
79
 | MRTDUMP text ';' {
80
     FILE *f = tracked_fopen(new_config->pool, $2, "a");
81
     if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2);
82
     new_config->mrtdump_file = fileno(f);
83
   }
84
 ;
85

    
86

    
87
CF_ADDTO(conf, debug_unix)
88

    
89
debug_unix:
90
   DEBUG LATENCY bool { new_config->latency_debug = $3; }
91
 | DEBUG LATENCY LIMIT expr_us { new_config->latency_limit = $4; }
92
 | WATCHDOG WARNING expr_us { new_config->watchdog_warning = $3; }
93
 | WATCHDOG TIMEOUT expr_us { new_config->watchdog_timeout = ($3 + 999999) TO_S; }
94
 ;
95

    
96

    
97
/* Unix specific commands */
98

    
99
CF_CLI_HELP(CONFIGURE, ..., [[Reload configuration]])
100

    
101
CF_CLI(CONFIGURE, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration]])
102
{ cmd_reconfig($2, RECONFIG_HARD, $3); } ;
103

    
104
CF_CLI(CONFIGURE SOFT, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration and ignore changes in filters]])
105
{ cmd_reconfig($3, RECONFIG_SOFT, $4); } ;
106

    
107
/* Hack to get input completion for 'timeout' */
108
CF_CLI_CMD(CONFIGURE TIMEOUT, [<sec>], [[Reload configuration with undo timeout]])
109
CF_CLI_CMD(CONFIGURE SOFT TIMEOUT, [<sec>], [[Reload configuration with undo timeout]])
110

    
111
CF_CLI(CONFIGURE CONFIRM,,, [[Confirm last configuration change - deactivate undo timeout]])
112
{ cmd_reconfig_confirm(); } ;
113

    
114
CF_CLI(CONFIGURE UNDO,,, [[Undo last configuration change]])
115
{ cmd_reconfig_undo(); } ;
116

    
117
CF_CLI(CONFIGURE CHECK, cfg_name, [\"<file>\"], [[Parse configuration and check its validity]])
118
{ cmd_check_config($3); } ;
119

    
120
CF_CLI(DOWN,,, [[Shut the daemon down]])
121
{ cmd_shutdown(); } ;
122

    
123
cfg_name:
124
   /* empty */ { $$ = NULL; }
125
 | TEXT
126
 ;
127

    
128
cfg_timeout:
129
   /* empty */ { $$ = 0; }
130
 | TIMEOUT { $$ = UNIX_DEFAULT_CONFIGURE_TIMEOUT; }
131
 | TIMEOUT expr { $$ = $2; }
132
 ;
133

    
134
CF_CODE
135

    
136
CF_END