summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2015-11-05 12:48:52 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2015-11-05 12:48:52 +0100
commitfe9f1a6dedda6bab23cbb605d1cd5db6cd3e2468 (patch)
treed6ea417b7ed16c90b29634fe075e51508dec87d9 /conf
parent8eb8e546dc8cc647fcfa4a3a17dfa8ab36b00958 (diff)
Initial commit on integrated BIRD
New data types net_addr and variants (in lib/net.h) describing network addresses (prefix/pxlen). Modifications of FIB structures to handle these data types and changing everything to use these data types instead of prefix/pxlen pairs where possible. The commit is WiP, some protocols are not yet updated (BGP, Kernel), and the code contains some temporary scaffolding. Comments are welcome.
Diffstat (limited to 'conf')
-rw-r--r--conf/cf-lex.l22
-rw-r--r--conf/conf.c6
-rw-r--r--conf/confbase.Y22
3 files changed, 26 insertions, 24 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l
index 61e04075..8baa1ee7 100644
--- a/conf/cf-lex.l
+++ b/conf/cf-lex.l
@@ -123,27 +123,15 @@ include ^{WHITE}*include{WHITE}*\".*\"{WHITE}*;
}
{DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+ {
- ip4_addr a;
- if (!ip4_pton(yytext, &a))
+ if (!ip4_pton(yytext, &cf_lval.ip4))
cf_error("Invalid IPv4 address %s", yytext);
-
-#ifdef IPV6
- cf_lval.i32 = ip4_to_u32(a);
- return RTRID;
-#else
- cf_lval.a = ipa_from_ip4(a);
- return IPA;
-#endif
+ return IP4;
}
({XIGIT}*::|({XIGIT}*:){3,})({XIGIT}*|{DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+) {
-#ifdef IPV6
- if (ipa_pton(yytext, &cf_lval.a))
- return IPA;
- cf_error("Invalid IPv6 address %s", yytext);
-#else
- cf_error("This is an IPv4 router, therefore IPv6 addresses are not supported");
-#endif
+ if (!ip6_pton(yytext, &cf_lval.ip6))
+ cf_error("Invalid IPv6 address %s", yytext);
+ return IP6;
}
0x{XIGIT}+ {
diff --git a/conf/conf.c b/conf/conf.c
index a907402d..cc5d5115 100644
--- a/conf/conf.c
+++ b/conf/conf.c
@@ -133,10 +133,10 @@ config_parse(struct config *c)
protos_postconfig(c);
if (EMPTY_LIST(c->protos))
cf_error("No protocol is specified in the config file");
-#ifdef IPV6
+ /* XXXX */
if (!c->router_id)
- cf_error("Router ID must be configured manually on IPv6 routers");
-#endif
+ cf_error("Router ID must be configured manually");
+
return 1;
}
diff --git a/conf/confbase.Y b/conf/confbase.Y
index 5f487c1d..64a636cf 100644
--- a/conf/confbase.Y
+++ b/conf/confbase.Y
@@ -39,6 +39,8 @@ CF_DECLS
int i;
u32 i32;
ip_addr a;
+ ip4_addr ip4;
+ ip6_addr ip6;
struct symbol *s;
char *t;
struct rtable_config *r;
@@ -66,8 +68,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 +77,11 @@ CF_DECLS
%type <i> expr bool pxlen
%type <i32> expr_us
%type <time> datetime
-%type <a> ipa
+%type <a> ipa ipa_raw
%type <px> prefix prefix_or_ipa
%type <t> text
%type <t> text_or_none
+%type <t> opttext
%nonassoc PREFIX_DUMMY
%left AND OR
@@ -148,8 +151,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;
@@ -205,6 +213,12 @@ text_or_none:
| { $$ = NULL; }
;
+opttext:
+ TEXT
+ | /* empty */ { $$ = NULL; }
+ ;
+
+
CF_CODE
CF_END