diff options
Diffstat (limited to 'conf')
-rw-r--r-- | conf/cf-lex.l | 22 | ||||
-rw-r--r-- | conf/conf.c | 6 | ||||
-rw-r--r-- | conf/confbase.Y | 56 |
3 files changed, 49 insertions, 35 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l index 5a2a4d6b..f90e983b 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 825a8e9f..1bb744c3 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -140,10 +140,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"); + done = 1; cleanup: 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 |