summaryrefslogtreecommitdiffstats
path: root/conf/confbase.Y
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-05-15 13:48:23 +0200
committerMartin Mares <mj@ucw.cz>2000-05-15 13:48:23 +0200
commite3f2d5fce3e339bb34f14d7b2569c1bd43b741ba (patch)
tree931c697044b2b742862cd2105d96c4916f3c9ef6 /conf/confbase.Y
parent3b1c523d79763b22e0fe06862ff349fd94e816b1 (diff)
downloadbird-e3f2d5fce3e339bb34f14d7b2569c1bd43b741ba.tar
bird-e3f2d5fce3e339bb34f14d7b2569c1bd43b741ba.zip
Cleanup of configuration.
o Use `expr' instead of `NUM' and `ipa' instead of `IPA', so that defined symbols work everywhere. o `define' now accepts both numbers and IP addresses. o Renamed `ipa' in filters to `fipa'. Pavel, please update filters to accept define'd symbols as well.
Diffstat (limited to 'conf/confbase.Y')
-rw-r--r--conf/confbase.Y23
1 files changed, 18 insertions, 5 deletions
diff --git a/conf/confbase.Y b/conf/confbase.Y
index 4626d44..588f582 100644
--- a/conf/confbase.Y
+++ b/conf/confbase.Y
@@ -53,6 +53,7 @@ CF_DECLS
%type <i> expr bool pxlen
%type <time> datetime
+%type <a> ipa
%type <px> prefix prefix_or_ipa
%nonassoc '=' '<' '>' '~' '.' GEQ LEQ NEQ
@@ -96,6 +97,10 @@ definition:
cf_define_symbol($2, SYM_NUMBER, NULL);
$2->aux = $4;
}
+ | DEFINE SYM '=' IPA ';' {
+ cf_define_symbol($2, SYM_IPA, cfg_alloc(sizeof(ip_addr)));
+ *(ip_addr *)$2->def = $4;
+ }
;
/* Switches */
@@ -109,10 +114,18 @@ bool:
| /* Silence means agreement */ { $$ = 1; }
;
-/* Prefixes and netmasks */
+/* Addresses, prefixes and netmasks */
+
+ipa:
+ IPA
+ | SYM {
+ if ($1->class != SYM_IPA) cf_error("IP address expected");
+ $$ = *(ip_addr *)$1->def;
+ }
+ ;
prefix:
- IPA pxlen {
+ ipa pxlen {
if (!ip_is_prefix($1, $2)) cf_error("Invalid prefix");
$$.addr = $1; $$.len = $2;
}
@@ -120,15 +133,15 @@ prefix:
prefix_or_ipa:
prefix
- | IPA { $$.addr = $1; $$.len = BITS_PER_IP_ADDRESS; }
+ | ipa { $$.addr = $1; $$.len = BITS_PER_IP_ADDRESS; }
;
pxlen:
- '/' NUM {
+ '/' expr {
if ($2 < 0 || $2 > BITS_PER_IP_ADDRESS) cf_error("Invalid prefix length %d", $2);
$$ = $2;
}
- | ':' IPA {
+ | ':' ipa {
$$ = ipa_mklen($2);
if ($$ < 0) cf_error("Invalid netmask %I", $2);
}