Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
labs
BIRD Internet Routing Daemon
Commits
77de6882
Commit
77de6882
authored
Apr 12, 2000
by
Pavel Machek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BGP_PATH masks now actually work as data type.
parent
78c6217c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
3 deletions
+34
-3
filter/config.Y
filter/config.Y
+16
-3
filter/filter.c
filter/filter.c
+2
-0
filter/filter.h
filter/filter.h
+6
-0
filter/test.conf
filter/test.conf
+10
-0
No files found.
filter/config.Y
View file @
77de6882
...
...
@@ -24,7 +24,7 @@ mnozina cisel ASu. Na cestach nadefinuji nasledujici operace:
Filtry by mely podporovat:
- operator pridani AS k ceste [bgp
_
path_prepend]
- operator pridani AS k ceste [bgppath_prepend]
- matchovani na pritomnost podposloupnosti v ceste (pricemz vyskytne-li
se tam mnozina, tak si ji lze predstavit prerovnanou v libovolnem
poradi)
...
...
@@ -65,7 +65,7 @@ CF_DECLS
CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
ACCEPT, REJECT, ERROR, QUITBIRD,
INT, BOOL, IP, PREFIX, PAIR, SET, STRING,
INT, BOOL, IP, PREFIX, PAIR, SET, STRING,
BGP_PATH,
IF, THEN, ELSE, CASE,
TRUE, FALSE,
FROM, GW, NET, MASK, SOURCE,
...
...
@@ -84,6 +84,8 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
%type <e> set_item set_items switch_body
%type <v> set_atom prefix prefix_s ipa
%type <s> decls declsn one_decl function_params
%type <h> bgp_path
%type <i> bgp_one
CF_GRAMMAR
...
...
@@ -104,6 +106,7 @@ type:
| PREFIX { $$ = T_PREFIX; }
| PAIR { $$ = T_PAIR; }
| STRING { $$ = T_STRING; }
| BGP_PATH { $$ = T_PATH; }
| type SET {
switch ($1) {
default:
...
...
@@ -305,6 +308,15 @@ switch_body: /* EMPTY */ { $$ = NULL; }
/* CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_INT; $$->a2.i = $3; } */
bgp_one:
NUM { $$ = $1; }
;
bgp_path:
bgp_one { $$ = cfg_alloc(sizeof(struct f_path)); $$->next = NULL; $$->val = $1; }
| bgp_one bgp_path { $$ = cfg_alloc(sizeof(struct f_path)); $$->next = $2; $$->val = $1; }
;
constant:
NUM { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_INT; $$->a2.i = $1; }
| TRUE { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_BOOL; $$->a2.i = 1; }
...
...
@@ -315,6 +327,7 @@ constant:
| prefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
| '[' set_items ']' { DBG( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_SET; $$->a2.p = build_tree($2); DBG( "ook\n" ); }
| ENUM { $$ = f_new_inst(); $$->code = 'c'; $$->aux = $1 >> 16; $$->a2.i = $1 & 0xffff; }
| '/' bgp_path '/' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_PATH; $$->a2.p = $2; }
;
/*
...
...
@@ -371,6 +384,7 @@ term:
case SYM_VARIABLE | T_PAIR:
case SYM_VARIABLE | T_PREFIX:
case SYM_VARIABLE | T_IP:
case SYM_VARIABLE | T_PATH:
$$->code = 'C';
$$->a1.p = $1->aux2;
break;
...
...
@@ -401,7 +415,6 @@ term:
/* Paths */
| term '.' APPEND '(' term ')' { }
/* | term '.' LEN { } Hmm, this would colide with ip.len. What to do with that? */
| term '.' MATCH '(' term ')' { }
/* function_call is inlined here */
| SYM '(' var_list ')' {
...
...
filter/filter.c
View file @
77de6882
...
...
@@ -133,6 +133,7 @@ val_print(struct f_val v)
case
T_PAIR
:
PRINTF
(
"(%d,%d)"
,
v
.
val
.
i
>>
16
,
v
.
val
.
i
&
0xffff
);
break
;
case
T_SET
:
tree_print
(
v
.
val
.
t
);
PRINTF
(
"
\n
"
);
break
;
case
T_ENUM
:
PRINTF
(
"(enum %x)%d"
,
v
.
type
,
v
.
val
.
i
);
break
;
case
T_PATH
:
debug
(
"(path "
);
{
struct
f_path
*
p
=
v
.
val
.
s
;
while
(
p
)
{
debug
(
"%d "
,
p
->
val
);
p
=
p
->
next
;
}
debug
(
")"
);
}
break
;
default:
PRINTF
(
"[unknown type %x]"
,
v
.
type
);
#undef PRINTF
}
...
...
@@ -248,6 +249,7 @@ interpret(struct f_inst *what)
case
T_IP
:
case
T_PREFIX
:
case
T_PAIR
:
case
T_PATH
:
if
(
sym
->
class
!=
(
SYM_VARIABLE
|
v2
.
type
))
runtime
(
"Variable of bad type"
);
*
(
struct
f_val
*
)
sym
->
aux2
=
v2
;
...
...
filter/filter.h
View file @
77de6882
...
...
@@ -50,6 +50,11 @@ struct f_val {
}
val
;
};
struct
f_path
{
struct
f_path
*
next
;
int
val
;
};
struct
filter
{
char
*
name
;
struct
f_inst
*
root
;
...
...
@@ -110,6 +115,7 @@ void val_print(struct f_val v);
#define T_IP 0x20
#define T_PREFIX 0x21
#define T_STRING 0x22
#define T_PATH 0x23
/* BGP path */
#define T_RETURN 0x40
#define T_SET 0x80
...
...
filter/test.conf
View file @
77de6882
...
...
@@ -29,6 +29,14 @@ function fifteen()
return
15
;
}
function
paths
()
bgp_path
p
;
{
print
"Testing paths"
;
p
= /
1
2
3
4
/;
print
p
;
}
function
startup
()
int
i
;
prefix
px
;
...
...
@@ -73,6 +81,8 @@ ip p;
i
=
fifteen
();
print
"Testing function calls: 15 = "
,
i
;
paths
();
print
"done"
;
quitbird
;
# print "*** FAIL: this is unreachable";
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment