diff options
author | Jan Moskyto Matejka <mq@ucw.cz> | 2016-02-09 14:53:29 +0100 |
---|---|---|
committer | Jan Moskyto Matejka <mq@ucw.cz> | 2016-12-22 21:38:33 +0100 |
commit | d311368bc58842552e25744a0aae9a09c42cda9f (patch) | |
tree | 7bdacfbca47c86148193f5438d9bb2ae89fa4342 /conf/cf-lex.l | |
parent | d47c3d64b2733baea756f1bb37ef09f10d7f9644 (diff) |
VPN4 and VPN6 literals
From now on, protocol static accepts VPN4 and VPN6 addressess.
With some concerns about VPN6 Route Distinguishers, I finally chose
to have the same format as for VPN4 (where it is defined by RFC 4364).
Diffstat (limited to 'conf/cf-lex.l')
-rw-r--r-- | conf/cf-lex.l | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l index bd6dfff2..8e1f60a6 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -123,6 +123,43 @@ include ^{WHITE}*include{WHITE}*\".*\"{WHITE}*; cf_include(start, end-start); } +[02]:{DIGIT}+:{DIGIT}+ { + char *e; + unsigned long int l; + + if (yytext[0] == '0') + cf_lval.i64 = 0; + else + cf_lval.i64 = 0x2000000000000ULL; + + 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); |