From fe9f1a6dedda6bab23cbb605d1cd5db6cd3e2468 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Thu, 5 Nov 2015 12:48:52 +0100 Subject: 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. --- conf/cf-lex.l | 22 +++++----------------- conf/conf.c | 6 +++--- conf/confbase.Y | 22 ++++++++++++++++++---- 3 files changed, 26 insertions(+), 24 deletions(-) (limited to 'conf') 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 NUM ENUM -%token RTRID -%token IPA +%token IP4 +%token IP6 %token SYM %token TEXT %type ipa_scope @@ -75,10 +77,11 @@ CF_DECLS %type expr bool pxlen %type expr_us %type ipa +%type ipa ipa_raw %type prefix prefix_or_ipa %type text %type text_or_none +%type 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 -- cgit v1.2.3