summaryrefslogtreecommitdiff
path: root/conf/confbase.Y
diff options
context:
space:
mode:
Diffstat (limited to 'conf/confbase.Y')
-rw-r--r--conf/confbase.Y56
1 files changed, 41 insertions, 15 deletions
diff --git a/conf/confbase.Y b/conf/confbase.Y
index 5f487c1d..3ad0c5f0 100644
--- a/conf/confbase.Y
+++ b/conf/confbase.Y
@@ -39,6 +39,10 @@ CF_DECLS
int i;
u32 i32;
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;
@@ -66,8 +70,8 @@ CF_DECLS
%token GEQ LEQ NEQ AND OR
%token PO PC
%token <i> NUM ENUM
-%token <i32> RTRID
-%token <a> IPA
+%token <ip4> IP4
+%token <ip6> IP6
%token <s> SYM
%token <t> TEXT
%type <iface> ipa_scope
@@ -75,10 +79,12 @@ CF_DECLS
%type <i> expr bool pxlen
%type <i32> expr_us
%type <time> datetime
-%type <a> ipa
-%type <px> prefix prefix_or_ipa
-%type <t> text
-%type <t> text_or_none
+%type <a> ipa ipa_raw
+%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
@@ -148,8 +154,13 @@ bool:
/* Addresses, prefixes and netmasks */
+ipa_raw:
+ IP4 { $$ = ipa_from_ip4($1); }
+ | IP6 { $$ = ipa_from_ip6($1); }
+ ;
+
ipa:
- IPA
+ ipa_raw
| SYM {
if ($1->class != (SYM_CONSTANT | T_IP)) cf_error("IP address expected");
$$ = SYM_VAL($1).px.ip;
@@ -161,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");
@@ -168,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);
@@ -200,11 +225,12 @@ text:
}
;
-text_or_none:
- TEXT { $$ = $1; }
- | { $$ = NULL; }
+opttext:
+ TEXT
+ | /* empty */ { $$ = NULL; }
;
+
CF_CODE
CF_END