summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
Diffstat (limited to 'conf')
-rw-r--r--conf/cf-lex.l54
-rw-r--r--conf/confbase.Y40
2 files changed, 92 insertions, 2 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l
index bd6dfff2..fb3d59e4 100644
--- a/conf/cf-lex.l
+++ b/conf/cf-lex.l
@@ -123,6 +123,60 @@ include ^{WHITE}*include{WHITE}*\".*\"{WHITE}*;
cf_include(start, end-start);
}
+[02]:{DIGIT}+:{DIGIT}+ {
+ unsigned long int l, len1, len2;
+ char *e;
+
+ if (yytext[0] == '0')
+ {
+ cf_lval.i64 = 0;
+ len1 = 16;
+ len2 = 32;
+ }
+ else
+ {
+ cf_lval.i64 = 2ULL << 48;
+ len1 = 32;
+ len2 = 16;
+ }
+
+ errno = 0;
+ l = strtoul(yytext+2, &e, 10);
+ if (e && (*e != ':') || (errno == ERANGE) || (l >> len1))
+ cf_error("ASN out of range");
+ cf_lval.i64 |= ((u64) l) << len2;
+
+ errno = 0;
+ l = strtoul(e+1, &e, 10);
+ if (e && *e || (errno == ERANGE) || (l >> len2))
+ cf_error("Number out of range");
+ cf_lval.i64 |= l;
+
+ return VPN_RD;
+}
+
+1:{DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+:{DIGIT}+ {
+ unsigned long int l;
+ ip4_addr ip4;
+ char *e;
+
+ cf_lval.i64 = 1ULL << 48;
+
+ e = strchr(yytext+2, ':');
+ *e++ = '\0';
+ if (!ip4_pton(yytext+2, &ip4))
+ cf_error("Invalid IPv4 address %s in Route Distinguisher", yytext+2);
+ cf_lval.i64 |= ((u64) ip4_to_u32(ip4)) << 16;
+
+ errno = 0;
+ l = strtoul(e, &e, 10);
+ if (e && *e || (errno == ERANGE) || (l >> 16))
+ cf_error("Number out of range");
+ cf_lval.i64 |= 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 aec4aeb4..d6a6951f 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;
@@ -64,6 +65,7 @@ CF_DECLS
struct proto_spec ps;
struct channel_limit cl;
struct timeformat *tf;
+ mpls_label_stack *mls;
}
%token END CLI_MARKER INVALID_TOKEN ELSECOL DDOT
@@ -72,6 +74,7 @@ CF_DECLS
%token <i> NUM ENUM
%token <ip4> IP4
%token <ip6> IP6
+%token <i64> VPN_RD
%token <s> SYM
%token <t> TEXT
%type <iface> ipa_scope
@@ -81,7 +84,8 @@ CF_DECLS
%type <time> datetime
%type <a> ipa
%type <net> net_ip4_ net_ip6_ net_ip6 net_ip_ net_ip net_or_ipa
-%type <net_ptr> net_ net_any net_roa4_ net_roa6_ net_roa_
+%type <net_ptr> net_ net_any net_vpn4_ net_vpn6_ net_vpn_ net_roa4_ net_roa6_ net_roa_
+%type <mls> label_stack_start label_stack
%type <t> text opttext
@@ -93,7 +97,7 @@ CF_DECLS
%left '!'
%nonassoc '.'
-CF_KEYWORDS(DEFINE, ON, OFF, YES, NO, S, MS, US, PORT)
+CF_KEYWORDS(DEFINE, ON, OFF, YES, NO, S, MS, US, PORT, VPN)
CF_GRAMMAR
@@ -196,6 +200,18 @@ net_ip6_: IP6 '/' NUM
cf_error("Invalid IPv6 prefix");
};
+net_vpn4_: VPN_RD net_ip4_
+{
+ $$ = cfg_alloc(sizeof(net_addr_vpn4));
+ net_fill_vpn4($$, net4_prefix(&$2), net4_pxlen(&$2), $1);
+}
+
+net_vpn6_: VPN_RD net_ip6_
+{
+ $$ = cfg_alloc(sizeof(net_addr_vpn6));
+ net_fill_vpn6($$, net6_prefix(&$2), net6_pxlen(&$2), $1);
+}
+
net_roa4_: net_ip4_ MAX NUM AS NUM
{
$$ = cfg_alloc(sizeof(net_addr_roa4));
@@ -213,10 +229,12 @@ net_roa6_: net_ip6_ MAX NUM AS NUM
};
net_ip_: net_ip4_ | net_ip6_ ;
+net_vpn_: net_vpn4_ | net_vpn6_ ;
net_roa_: net_roa4_ | net_roa6_ ;
net_:
net_ip_ { $$ = cfg_alloc($1.length); net_copy($$, &($1)); }
+ | net_vpn_
| net_roa_
| net_flow_
;
@@ -254,6 +272,8 @@ net_any:
net_or_ipa:
net_ip4_
| net_ip6_
+ | net_vpn4_ { $$ = *$1; }
+ | net_vpn6_ { $$ = *$1; }
| IP4 { net_fill_ip4(&($$), $1, IP4_MAX_PREFIX_LENGTH); }
| IP6 { net_fill_ip6(&($$), $1, IP6_MAX_PREFIX_LENGTH); }
| SYM {
@@ -266,6 +286,22 @@ net_or_ipa:
}
;
+label_stack_start: NUM
+{
+ $$ = cfg_allocz(sizeof(mpls_label_stack));
+ $$->len = 1;
+ $$->stack[0] = $1;
+};
+
+label_stack:
+ label_stack_start
+ | label_stack '/' NUM {
+ if ($1->len >= MPLS_MAX_LABEL_STACK)
+ cf_error("Too many labels in stack");
+ $1->stack[$1->len++] = $3;
+ $$ = $1;
+ }
+;
datetime:
TEXT {