Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.85 KB)

1 a0c37b45 Martin Mares
/*
2
 *	BIRD -- UNIX Configuration
3
 *
4 50fe90ed Martin Mares
 *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
5 a0c37b45 Martin Mares
 *
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 a19cd811 Martin Mares
#include <stdio.h>
13 a0c37b45 Martin Mares
14
CF_DECLS
15
16 bf1aec97 Ondrej Zajicek
CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT)
17 44d4ab7a Ondrej Zajicek
CF_KEYWORDS(TIMEFORMAT, ISO, SHORT, LONG, BASE, NAME)
18 a0c37b45 Martin Mares
19
%type <i> log_mask log_mask_list log_cat
20 f78056fb Martin Mares
%type <g> log_file
21 50fe90ed Martin Mares
%type <t> cfg_name
22 c37e7851 Ondrej Zajicek
%type <tf> timeformat_which
23 44d4ab7a Ondrej Zajicek
%type <t> syslog_name
24 a0c37b45 Martin Mares
25
CF_GRAMMAR
26
27
CF_ADDTO(conf, log_config)
28
29 f78056fb Martin Mares
log_config: LOG log_file log_mask ';' {
30 a0c37b45 Martin Mares
    struct log_config *c = cfg_allocz(sizeof(struct log_config));
31 f78056fb Martin Mares
    c->fh = $2;
32 a0c37b45 Martin Mares
    c->mask = $3;
33
    add_tail(&new_config->logfiles, &c->n);
34
  }
35
 ;
36
37 44d4ab7a Ondrej Zajicek
syslog_name:
38
   NAME TEXT { $$ = $2; }
39
 | { $$ = bird_name; }
40
 ;
41
42 f78056fb Martin Mares
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 44d4ab7a Ondrej Zajicek
 | SYSLOG syslog_name { $$ = NULL; new_config->syslog_name = $2; }
49 f78056fb Martin Mares
 | STDERR { $$ = stderr; }
50
 ;
51
52 a0c37b45 Martin Mares
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 cf31112f Ondrej Zajicek
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 c37e7851 Ondrej Zajicek
CF_ADDTO(conf, timeformat_base)
87 cf31112f Ondrej Zajicek
88 c37e7851 Ondrej Zajicek
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 cf31112f Ondrej Zajicek
105 50fe90ed Martin Mares
/* Unix specific commands */
106
107 bf1aec97 Ondrej Zajicek
CF_CLI_HELP(CONFIGURE, [soft] [\"<file>\"], [[Reload configuration]])
108
109 c62d1c19 Martin Mares
CF_CLI(CONFIGURE, cfg_name, [\"<file>\"], [[Reload configuration]])
110 bf1aec97 Ondrej Zajicek
{ 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 50fe90ed Martin Mares
115 c801e1fb Martin Mares
CF_CLI(DOWN,,, [[Shut the daemon down]])
116 e0a45fb4 Ondrej Zajicek
{ cmd_shutdown(); } ;
117 bf8558bc Martin Mares
118 50fe90ed Martin Mares
cfg_name:
119
   /* empty */ { $$ = NULL; }
120
 | TEXT
121
 ;
122
123 a0c37b45 Martin Mares
CF_CODE
124
125
CF_END