Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
labs
BIRD Internet Routing Daemon
Commits
4b641bab
Commit
4b641bab
authored
Apr 17, 2000
by
Pavel Machek
Browse files
Path matching now actually works, including / * 1 2 3 * /.
parent
e399b6f6
Changes
4
Hide whitespace changes
Inline
Side-by-side
filter/config.Y
View file @
4b641bab
...
...
@@ -313,6 +313,7 @@ switch_body: /* EMPTY */ { $$ = NULL; }
bgp_one:
NUM { $$ = $1; }
| '*' { $$ = PM_ANY; }
;
bgp_path:
...
...
filter/filter.c
View file @
4b641bab
...
...
@@ -592,7 +592,6 @@ filters_postconfig(void)
die
(
"Startup function resulted in error."
);
debug
(
"done
\n
"
);
}
self_test
();
}
int
...
...
@@ -674,11 +673,8 @@ path_format(u8 *p, int len)
#undef PRINTF
#undef COMMA
#define PM_END -1
#define PM_ASTERIX -2
#define MASK_PLUS do { mask = mask->next; if (!mask) return next == q; \
asterix = (mask->val == PM_A
STERIX
); \
asterix = (mask->val == PM_A
NY
); \
if (asterix) { mask = mask->next; if (!mask) { return 1; } } \
} while(0)
...
...
@@ -690,6 +686,9 @@ path_match(u8 *p, int len, struct f_path_mask *mask)
u8
*
q
=
p
+
len
;
u8
*
next
;
asterix
=
(
mask
->
val
==
PM_ANY
);
if
(
asterix
)
{
mask
=
mask
->
next
;
if
(
!
mask
)
{
return
1
;
}
}
while
(
p
<
q
)
{
switch
(
*
p
++
)
{
case
1
:
/* This is a set */
...
...
@@ -789,19 +788,3 @@ adata_empty(struct linpool *pool)
res
->
length
=
0
;
return
res
;
}
void
self_test
(
void
)
{
char
path1
[]
=
{
2
,
5
,
0
,
5
,
0
,
4
,
0
,
3
,
0
,
2
,
0
,
1
};
char
path2
[]
=
{
2
,
5
,
0
,
5
,
0
,
4
,
0
,
3
,
0
,
2
,
0
,
1
,
1
,
5
,
0
,
5
,
0
,
4
,
0
,
3
,
0
,
2
,
0
,
1
};
s32
match
[]
=
{
5
,
PM_ASTERIX
,
2
,
PM_ASTERIX
,
1
,
3
,
PM_END
};
DBG
(
"Filters self-testing:
\n
"
);
DBG
(
"%s
\n
"
,
path_format
(
path1
,
sizeof
(
path1
))
);
DBG
(
"%s
\n
"
,
path_format
(
path2
,
sizeof
(
path2
))
);
DBG
(
"5, 6 = %d, %d
\n
"
,
path_getlen
(
path1
,
sizeof
(
path1
)),
path_getlen
(
path2
,
sizeof
(
path2
))
);
// DBG( "%d\n", path_match(path1, sizeof(path1), match));
// DBG( "%d\n", path_match(path2, sizeof(path2), match));
// die( "okay" );
}
filter/filter.h
View file @
4b641bab
...
...
@@ -43,6 +43,7 @@ struct f_path_mask {
struct
f_path_mask
*
next
;
int
val
;
};
#define PM_ANY -1
struct
f_val
{
int
type
;
...
...
filter/test.conf
View file @
4b641bab
...
...
@@ -43,6 +43,7 @@ bgppath p2;
print
"Should be true: "
,
p2
~
p
;
p2
=
prepend
(
p2
,
5
);
print
"Should be false: "
,
p2
~
p
;
print
"Should be true: "
,
p2
~ / *
4
3
2
1
/,
p2
, / *
4
3
2
1
/;
}
function
startup
()
...
...
Write
Preview
Supports
Markdown
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