summaryrefslogtreecommitdiff
path: root/conf/confbase.Y
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2015-11-12 02:03:59 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2015-11-12 02:03:59 +0100
commitd44e686e9bcae5850115c0e1adfe24523dce61ee (patch)
tree88feb4c9e43fe547db954496ec5d9eb66b307f52 /conf/confbase.Y
parentfe9f1a6dedda6bab23cbb605d1cd5db6cd3e2468 (diff)
Follow-up commit on integrated BIRD
Use net_addr for interface address prefixes, support net_addr in configuration parser.
Diffstat (limited to 'conf/confbase.Y')
-rw-r--r--conf/confbase.Y40
1 files changed, 26 insertions, 14 deletions
diff --git a/conf/confbase.Y b/conf/confbase.Y
index 64a636cf..3ad0c5f0 100644
--- a/conf/confbase.Y
+++ b/conf/confbase.Y
@@ -41,6 +41,8 @@ CF_DECLS
ip_addr a;
ip4_addr ip4;
ip6_addr ip6;
+ net_addr_union net;
+ net_addr *net_ptr;
struct symbol *s;
char *t;
struct rtable_config *r;
@@ -78,10 +80,11 @@ CF_DECLS
%type <i32> expr_us
%type <time> datetime
%type <a> ipa ipa_raw
-%type <px> prefix prefix_or_ipa
-%type <t> text
-%type <t> text_or_none
-%type <t> opttext
+%type <px> prefix
+%type <net> net_ip4 net_ip6 net_ip net_or_ipa
+%type <net_ptr> net_any
+
+%type <t> text opttext
%nonassoc PREFIX_DUMMY
%left AND OR
@@ -169,6 +172,25 @@ ipa_scope:
| '%' SYM { $$ = if_get_by_name($2->name); }
;
+
+/* XXXX - symbols and tests */
+
+net_ip4: IP4 pxlen { $$.ip4 = NET_ADDR_IP4($1, $2); }
+
+net_ip6: IP6 pxlen { $$.ip6 = NET_ADDR_IP6($1, $2); }
+
+net_ip: net_ip4 | net_ip6 ;
+
+net_any: net_ip { $$ = cfg_alloc($1.n.length); net_copy($$, &($1.n)); }
+
+net_or_ipa:
+ net_ip4
+ | net_ip6
+ | IP4 { $$.ip4 = NET_ADDR_IP4($1, IP4_MAX_PREFIX_LENGTH); }
+ | IP6 { $$.ip6 = NET_ADDR_IP6($1, IP6_MAX_PREFIX_LENGTH); }
+ ;
+
+
prefix:
ipa pxlen {
if (!ip_is_prefix($1, $2)) cf_error("Invalid prefix");
@@ -176,11 +198,6 @@ prefix:
}
;
-prefix_or_ipa:
- prefix
- | ipa { $$.addr = $1; $$.len = BITS_PER_IP_ADDRESS; }
- ;
-
pxlen:
'/' expr {
if ($2 < 0 || $2 > BITS_PER_IP_ADDRESS) cf_error("Invalid prefix length %d", $2);
@@ -208,11 +225,6 @@ text:
}
;
-text_or_none:
- TEXT { $$ = $1; }
- | { $$ = NULL; }
- ;
-
opttext:
TEXT
| /* empty */ { $$ = NULL; }