diff --git a/conf/cf-lex.l b/conf/cf-lex.l index ccf5826a..3848718d 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -122,6 +122,38 @@ include ^{WHITE}*include{WHITE}*\".*\"{WHITE}*; cf_include(start, end-start); } +[02]:{DIGIT}+:{DIGIT}+ { + char *e; + unsigned long int l; + cf_lval.i64 = ((u64)(yytext[0] - '0')) << 48; + errno = 0; + l = strtoul(yytext+2, &e, 10); + if (e && (*e != ':') || errno == ERANGE || (yytext[0] == '0') && (l >= (1<<16))) + cf_error("ASN out of range"); + cf_lval.i64 |= (((u64) l) << 32); + errno = 0; + l = strtoul(e+1, &e, 10); + if (e && *e || errno == ERANGE || (yytext[0] == '2') && (l >= (1<<16))) + cf_error("Assigned number out of range"); + cf_lval.i64 |= l; + return VPN_RD; +} + +1:{DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+:{DIGIT}+ { + unsigned long int l; + char *e = strchr(yytext+2, ':'); + *e++ = '\0'; + ip4_addr ip4; + if (!ip4_pton(yytext+2, &ip4)) + cf_error("Invalid IPv4 address %s in Route Distinguisher", yytext+2); + errno = 0; + l = strtoul(e, &e, 10); + if (e && *e || errno == ERANGE || (l >= (1<<16))) + cf_error("Assigned number out of range"); + cf_lval.i64 = (1ULL<<48) | (((u64)ip4_to_u32(ip4)) << 16) | ((u64)l); + return VPN_RD; +} + {DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+ { if (!ip4_pton(yytext, &cf_lval.ip4)) cf_error("Invalid IPv4 address %s", yytext); diff --git a/conf/confbase.Y b/conf/confbase.Y index 22aee770..768e4c70 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -38,6 +38,7 @@ CF_DECLS %union { int i; u32 i32; + u64 i64; ip_addr a; ip4_addr ip4; ip6_addr ip6; @@ -72,6 +73,7 @@ CF_DECLS %token NUM ENUM %token IP4 %token IP6 +%token VPN_RD %token SYM %token TEXT %type ipa_scope @@ -81,7 +83,7 @@ CF_DECLS %type