Statistics
| Branch: | Revision:

iof-bird-daemon / sysdep / unix / config.Y @ e0a45fb4

History | View | Annotate | Download (2.72 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)
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

    
24
CF_GRAMMAR
25

    
26
CF_ADDTO(conf, log_config)
27

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

    
36
log_file:
37
   TEXT {
38
     FILE *f = tracked_fopen(new_config->pool, $1, "a");
39
     if (!f) cf_error("Unable to open log file `%s': %m", $1);
40
     $$ = f;
41
   }
42
 | SYSLOG { $$ = NULL; }
43
 | STDERR { $$ = stderr; }
44
 ;
45

    
46
log_mask:
47
   ALL { $$ = ~0; }
48
 | '{' log_mask_list '}' { $$ = $2; }
49
 ;
50

    
51
log_mask_list:
52
   log_cat { $$ = 1 << $1; }
53
 | log_mask_list ',' log_cat { $$ = $1 | (1 << $3); }
54
 ;
55

    
56
log_cat:
57
   DEBUG { $$ = L_DEBUG[0]; }
58
 | TRACE { $$ = L_TRACE[0]; }
59
 | INFO { $$ = L_INFO[0]; }
60
 | REMOTE { $$ = L_REMOTE[0]; }
61
 | WARNING { $$ = L_WARN[0]; }
62
 | ERROR { $$ = L_ERR[0]; }
63
 | AUTH { $$ = L_AUTH[0]; }
64
 | FATAL { $$ = L_FATAL[0]; }
65
 | BUG { $$ = L_BUG[0]; }
66
 ;
67

    
68

    
69
CF_ADDTO(conf, mrtdump_base)
70

    
71
mrtdump_base:
72
   MRTDUMP PROTOCOLS mrtdump_mask ';' { new_config->proto_default_mrtdump = $3; }
73
 | MRTDUMP TEXT ';' {
74
     FILE *f = tracked_fopen(new_config->pool, $2, "a");
75
     if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2);
76
     new_config->mrtdump_file = fileno(f);
77
   }
78
 ;
79

    
80
CF_ADDTO(conf, timeformat_base)
81

    
82
timeformat_which:
83
   ROUTE { $$ = &new_config->tf_route; }
84
 | PROTOCOL { $$ = &new_config->tf_proto; }
85
 | BASE { $$ = &new_config->tf_base; }
86
 | LOG { $$ = &new_config->tf_log; }
87

    
88
timeformat_spec:
89
   timeformat_which TEXT { *$1 = (struct timeformat){$2, NULL, 0}; }
90
 | timeformat_which TEXT expr TEXT { *$1 = (struct timeformat){$2, $4, $3}; }
91
 | timeformat_which ISO SHORT { *$1 = (struct timeformat){"%T", "%F", 20*3600}; }
92
 | timeformat_which ISO LONG  { *$1 = (struct timeformat){"%F %T", NULL, 0}; }
93
 ;
94

    
95
timeformat_base:
96
   TIMEFORMAT timeformat_spec ';'
97
 ;
98

    
99
/* Unix specific commands */
100

    
101
CF_CLI_HELP(CONFIGURE, [soft] [\"<file>\"], [[Reload configuration]])
102

    
103
CF_CLI(CONFIGURE, cfg_name, [\"<file>\"], [[Reload configuration]])
104
{ cmd_reconfig($2, RECONFIG_HARD); } ;
105

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

    
109
CF_CLI(DOWN,,, [[Shut the daemon down]])
110
{ cmd_shutdown(); } ;
111

    
112
cfg_name:
113
   /* empty */ { $$ = NULL; }
114
 | TEXT
115
 ;
116

    
117
CF_CODE
118

    
119
CF_END