mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-08 12:18:42 +00:00
New syntax for bgp_path
This commit is contained in:
parent
f16ad72ed7
commit
cf18603491
@ -168,22 +168,28 @@ input_complete(int arg UNUSED, int key UNUSED)
|
|||||||
static int
|
static int
|
||||||
input_help(int arg, int key UNUSED)
|
input_help(int arg, int key UNUSED)
|
||||||
{
|
{
|
||||||
int i, in_string, in_path;
|
int i, in_string, in_bracket;
|
||||||
|
|
||||||
if (arg != 1)
|
if (arg != 1)
|
||||||
return rl_insert(arg, '?');
|
return rl_insert(arg, '?');
|
||||||
|
|
||||||
in_string = in_path = 0;
|
in_string = in_bracket = 0;
|
||||||
for (i = 0; i < rl_point; i++)
|
for (i = 0; i < rl_point; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (rl_line_buffer[i] == '"')
|
if (rl_line_buffer[i] == '"')
|
||||||
in_string = ! in_string;
|
in_string = ! in_string;
|
||||||
else if ((rl_line_buffer[i] == '|') && (! in_string))
|
else if (! in_string)
|
||||||
in_path = ! in_path;
|
{
|
||||||
|
if (rl_line_buffer[i] == '[')
|
||||||
|
in_bracket++;
|
||||||
|
else if (rl_line_buffer[i] == ']')
|
||||||
|
in_bracket--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* `?' inside string or path -> insert */
|
/* `?' inside string or path -> insert */
|
||||||
if (in_string || in_path)
|
if (in_string || in_bracket)
|
||||||
return rl_insert(1, '?');
|
return rl_insert(1, '?');
|
||||||
|
|
||||||
rl_begin_undo_group(); /* HACK: We want to display `?' at point position */
|
rl_begin_undo_group(); /* HACK: We want to display `?' at point position */
|
||||||
|
@ -200,6 +200,9 @@ WHITE [ \t]
|
|||||||
\&\& return AND;
|
\&\& return AND;
|
||||||
\|\| return OR;
|
\|\| return OR;
|
||||||
|
|
||||||
|
\[\= return PO;
|
||||||
|
\=\] return PC;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -45,6 +45,7 @@ CF_DECLS
|
|||||||
|
|
||||||
%token END CLI_MARKER INVALID_TOKEN
|
%token END CLI_MARKER INVALID_TOKEN
|
||||||
%token GEQ LEQ NEQ AND OR
|
%token GEQ LEQ NEQ AND OR
|
||||||
|
%token PO PC
|
||||||
%token <i> NUM ENUM
|
%token <i> NUM ENUM
|
||||||
%token <i32> RTRID
|
%token <i32> RTRID
|
||||||
%token <a> IPA
|
%token <a> IPA
|
||||||
@ -57,7 +58,7 @@ CF_DECLS
|
|||||||
%type <px> prefix prefix_or_ipa
|
%type <px> prefix prefix_or_ipa
|
||||||
|
|
||||||
%nonassoc PREFIX_DUMMY
|
%nonassoc PREFIX_DUMMY
|
||||||
%nonassoc '=' '<' '>' '~' '.' GEQ LEQ NEQ AND OR
|
%nonassoc '=' '<' '>' '~' '.' GEQ LEQ NEQ AND OR PO PC
|
||||||
%left '+' '-'
|
%left '+' '-'
|
||||||
%left '*' '/' '%'
|
%left '*' '/' '%'
|
||||||
%left '!'
|
%left '!'
|
||||||
|
@ -268,7 +268,7 @@ switch_body: /* EMPTY */ { $$ = NULL; }
|
|||||||
/* CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_INT; $$->a2.i = $3; } */
|
/* CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_INT; $$->a2.i = $3; } */
|
||||||
|
|
||||||
bgp_path:
|
bgp_path:
|
||||||
'|' bgp_path_tail1 '|' { $$ = $2; }
|
PO bgp_path_tail1 PC { $$ = $2; }
|
||||||
| '/' bgp_path_tail2 '/' { $$ = $2; }
|
| '/' bgp_path_tail2 '/' { $$ = $2; }
|
||||||
| OR { $$ = NULL; } /* special case because of || is a different token */
|
| OR { $$ = NULL; } /* special case because of || is a different token */
|
||||||
;
|
;
|
||||||
|
@ -83,9 +83,9 @@ pm_format(struct f_path_mask *p, byte *buf, unsigned int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p->any)
|
if (p->any)
|
||||||
buf += bsprintf(buf, "* ");
|
buf += bsprintf(buf, " *");
|
||||||
else
|
else
|
||||||
buf += bsprintf(buf, "%u ", p->val);
|
buf += bsprintf(buf, " %u", p->val);
|
||||||
|
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ val_print(struct f_val v)
|
|||||||
case T_ENUM: PRINTF( "(enum %x)%d", v.type, v.val.i ); break;
|
case T_ENUM: PRINTF( "(enum %x)%d", v.type, v.val.i ); break;
|
||||||
case T_PATH: as_path_format(v.val.ad, buf2, 1020); PRINTF( "(path %s)", buf2 ); break;
|
case T_PATH: as_path_format(v.val.ad, buf2, 1020); PRINTF( "(path %s)", buf2 ); break;
|
||||||
case T_CLIST: int_set_format(v.val.ad, 1, buf2, 1020); PRINTF( "(clist %s)", buf2 ); break;
|
case T_CLIST: int_set_format(v.val.ad, 1, buf2, 1020); PRINTF( "(clist %s)", buf2 ); break;
|
||||||
case T_PATH_MASK: pm_format(v.val.path_mask, buf2, 1020); PRINTF( "(pathmask %s)", buf2 ); break;
|
case T_PATH_MASK: pm_format(v.val.path_mask, buf2, 1020); PRINTF( "(pathmask%s)", buf2 ); break;
|
||||||
default: PRINTF( "[unknown type %x]", v.type );
|
default: PRINTF( "[unknown type %x]", v.type );
|
||||||
#undef PRINTF
|
#undef PRINTF
|
||||||
}
|
}
|
||||||
|
@ -31,25 +31,36 @@ function fifteen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
function paths()
|
function paths()
|
||||||
bgpmask p;
|
bgpmask pm1;
|
||||||
|
bgpmask pm2;
|
||||||
bgppath p2;
|
bgppath p2;
|
||||||
clist l;
|
clist l;
|
||||||
{
|
{
|
||||||
p = / 4 3 2 1 /;
|
pm1 = / 4 3 2 1 /;
|
||||||
print "Testing path masks: ", p;
|
pm2 = [= 4 3 2 1 =];
|
||||||
|
print "Testing path masks: ", pm1, " ", pm2;
|
||||||
p2 = prepend( + empty +, 1 );
|
p2 = prepend( + empty +, 1 );
|
||||||
p2 = prepend( p2, 2 );
|
p2 = prepend( p2, 2 );
|
||||||
p2 = prepend( p2, 3 );
|
p2 = prepend( p2, 3 );
|
||||||
p2 = prepend( p2, 4 );
|
p2 = prepend( p2, 4 );
|
||||||
print "Testing paths: ", p2;
|
print "Testing paths: ", p2;
|
||||||
print "Should be true: ", p2 ~ p;
|
print "Should be true: ", p2 ~ pm1, " ", p2 ~ pm2;
|
||||||
print "4 = ", p2.len;
|
print "4 = ", p2.len;
|
||||||
p2 = prepend( p2, 5 );
|
p2 = prepend( p2, 5 );
|
||||||
print "Should be false: ", p2 ~ p;
|
print "Should be false: ", p2 ~ pm1, " ", p2 ~ pm2;
|
||||||
print "Should be true: ", p2 ~ / ? 4 3 2 1 /, p2, / ? 4 3 2 1 /;
|
print "Should be true: ", p2 ~ / ? 4 3 2 1 /, " ", p2, " ", / ? 4 3 2 1 /;
|
||||||
print "Should be true: ", p2 ~ / ? 4 3 ? 1 /, p2, / ? 4 3 ? 1 /;
|
print "Should be true: ", p2 ~ [= * 4 3 * 1 =], " ", p2, " ", [= * 4 3 * 1 =];
|
||||||
print "5 = ", p2.len;
|
print "5 = ", p2.len;
|
||||||
|
|
||||||
|
pm1 = [= 1 2 * 3 4 5 =];
|
||||||
|
p2 = prepend( + empty +, 5 );
|
||||||
|
p2 = prepend( p2, 4 );
|
||||||
|
p2 = prepend( p2, 3 );
|
||||||
|
p2 = prepend( p2, 3 );
|
||||||
|
p2 = prepend( p2, 2 );
|
||||||
|
p2 = prepend( p2, 1 );
|
||||||
|
print "Should be true: ", p2 ~ pm1, " ", p2, " ", pm1;
|
||||||
|
|
||||||
l = - empty -;
|
l = - empty -;
|
||||||
l = add( l, (1,2) );
|
l = add( l, (1,2) );
|
||||||
l = add( l, (2,3) );
|
l = add( l, (2,3) );
|
||||||
|
Loading…
Reference in New Issue
Block a user