Statistics
| Branch: | Revision:

iof-bird-daemon / sysdep / unix / config.Y @ 1bc26957

History | View | Annotate | Download (2.85 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 "lib/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(TIMEFORMAT, ISO, SHORT, LONG, BASE, NAME)
18

    
19
%type <i> log_mask log_mask_list log_cat
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
CF_ADDTO(conf, timeformat_base)
87

    
88
timeformat_which:
89
   ROUTE { $$ = &new_config->tf_route; }
90
 | PROTOCOL { $$ = &new_config->tf_proto; }
91
 | BASE { $$ = &new_config->tf_base; }
92
 | LOG { $$ = &new_config->tf_log; }
93

    
94
timeformat_spec:
95
   timeformat_which TEXT { *$1 = (struct timeformat){$2, NULL, 0}; }
96
 | timeformat_which TEXT expr TEXT { *$1 = (struct timeformat){$2, $4, $3}; }
97
 | timeformat_which ISO SHORT { *$1 = (struct timeformat){"%T", "%F", 20*3600}; }
98
 | timeformat_which ISO LONG  { *$1 = (struct timeformat){"%F %T", NULL, 0}; }
99
 ;
100

    
101
timeformat_base:
102
   TIMEFORMAT timeformat_spec ';'
103
 ;
104

    
105
/* Unix specific commands */
106

    
107
CF_CLI_HELP(CONFIGURE, [soft] [\"<file>\"], [[Reload configuration]])
108

    
109
CF_CLI(CONFIGURE, cfg_name, [\"<file>\"], [[Reload configuration]])
110
{ cmd_reconfig($2, RECONFIG_HARD); } ;
111

    
112
CF_CLI(CONFIGURE SOFT, cfg_name, [\"<file>\"], [[Reload configuration and ignore changes in filters]])
113
{ cmd_reconfig($3, RECONFIG_SOFT); } ;
114

    
115
CF_CLI(DOWN,,, [[Shut the daemon down]])
116
{ cmd_shutdown(); } ;
117

    
118
cfg_name:
119
   /* empty */ { $$ = NULL; }
120
 | TEXT
121
 ;
122

    
123
CF_CODE
124

    
125
CF_END