-/* $OpenBSD: parse.y,v 1.350 2018/09/10 11:09:25 benno Exp $ */
+/* $OpenBSD: parse.y,v 1.351 2018/09/13 11:16:21 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
%token IPSEC ESP AH SPI IKE
%token IPV4 IPV6
%token QUALIFY VIA
-%token NE LE GE XRANGE LONGER
+%token NE LE GE XRANGE LONGER MAXLEN
%token <v.string> STRING
%token <v.number> NUMBER
%type <v.number> asnumber as4number as4number_any optnumber
$$.len_min = -1;
$$.len_max = -1;
}
+ | MAXLEN NUMBER {
+ bzero(&$$, sizeof($$));
+ if ($2 < 0 || $2 > 128) {
+ yyerror("prefixlen must be >= 0 and <= 128");
+ YYERROR;
+ }
+
+ $$.op = OP_RANGE;
+ $$.len_min = -1;
+ $$.len_max = $2;
+ }
| PREFIXLEN unaryop NUMBER {
int min, max;
$$.op = OP_RANGE;
switch ($2) {
- case OP_EQ:
case OP_NE:
- min = max = $3;
$$.op = $2;
+ case OP_EQ:
+ min = max = $3;
break;
case OP_LT:
if ($3 == 0) {
{ "max-as-len", MAXASLEN},
{ "max-as-seq", MAXASSEQ},
{ "max-prefix", MAXPREFIX},
+ { "maxlen", MAXLEN},
{ "md5sig", MD5SIG},
{ "med", MED},
{ "metric", METRIC},
-/* $OpenBSD: printconf.c,v 1.117 2018/09/10 11:01:15 benno Exp $ */
+/* $OpenBSD: printconf.c,v 1.118 2018/09/13 11:16:21 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
switch (p->op) {
case OP_NONE:
break;
- case OP_EQ:
- printf(" prefixlen = %u", p->len_min);
- break;
case OP_NE:
printf(" prefixlen != %u", p->len_min);
break;
printf(" prefixlen %u >< %u ", p->len_min, p->len_max);
break;
case OP_RANGE:
- if (p->len == p->len_min && p->len_max == max_len)
+ if (p->len == p->len_min && p->len == p->len_max)
+ printf(" prefixlen = %u", p->len);
+ else if (p->len == p->len_min && p->len_max == max_len)
printf(" or-longer");
+ else if (p->len == p->len_min)
+ printf(" maxlen %u", p->len_max);
else if (p->len_max == max_len)
printf(" prefixlen >= %u", p->len_min);
else