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
2a40efa5
Commit
2a40efa5
authored
Apr 17, 2000
by
Pavel Machek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
as_path_match moved to a-path.c
parent
684c6f5a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
67 deletions
+76
-67
filter/filter.c
filter/filter.c
+1
-67
nest/a-path.c
nest/a-path.c
+67
-0
nest/attrs.h
nest/attrs.h
+8
-0
No files found.
filter/filter.c
View file @
2a40efa5
...
...
@@ -61,7 +61,7 @@ int
val_simple_in_range
(
struct
f_val
v1
,
struct
f_val
v2
)
{
if
((
v1
.
type
==
T_PATH
)
&&
(
v2
.
type
==
T_PATH_MASK
))
return
path_match
(
v1
.
val
.
ad
->
data
,
v1
.
val
.
ad
->
length
,
v2
.
val
.
path_mask
);
return
as_
path_match
(
v1
.
val
.
ad
,
v2
.
val
.
path_mask
);
if
((
v1
.
type
==
T_IP
)
&&
(
v2
.
type
==
T_PREFIX
))
return
!
(
ipa_compare
(
ipa_and
(
v2
.
val
.
px
.
ip
,
ipa_mkmask
(
v2
.
val
.
px
.
len
)),
ipa_and
(
v1
.
val
.
px
.
ip
,
ipa_mkmask
(
v2
.
val
.
px
.
len
))));
...
...
@@ -620,72 +620,6 @@ filter_same(struct filter *new, struct filter *old)
* FIXME: It should take struct adata *, not u8 * + length; but that makes it a little more difficult to test.
* Or maybe both versions are usefull?
*/
#define MASK_PLUS do { mask = mask->next; if (!mask) return next == q; \
asterix = (mask->val == PM_ANY); \
if (asterix) { mask = mask->next; if (!mask) { return 1; } } \
} while(0)
int
path_match
(
u8
*
p
,
int
len
,
struct
f_path_mask
*
mask
)
{
int
i
;
int
asterix
=
0
;
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 */
len
=
*
p
++
;
{
u8
*
p_save
=
p
;
next
=
p_save
+
2
*
len
;
retry:
p
=
p_save
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
asterix
&&
(
get_u16
(
p
)
==
mask
->
val
))
{
MASK_PLUS
;
goto
retry
;
}
if
(
!
asterix
&&
(
get_u16
(
p
)
==
mask
->
val
))
{
p
=
next
;
MASK_PLUS
;
goto
okay
;
}
p
+=
2
;
}
if
(
!
asterix
)
return
0
;
okay:
}
break
;
case
2
:
/* This is a sequence */
len
=
*
p
++
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
next
=
p
+
2
;
if
(
asterix
&&
(
get_u16
(
p
)
==
mask
->
val
))
MASK_PLUS
;
else
if
(
!
asterix
)
{
if
(
get_u16
(
p
)
!=
mask
->
val
)
return
0
;
MASK_PLUS
;
}
p
+=
2
;
}
break
;
default:
bug
(
"This should not be in path"
);
}
}
return
0
;
}
struct
adata
*
comlist_add
(
struct
linpool
*
pool
,
struct
adata
*
list
,
u32
val
)
{
...
...
nest/a-path.c
View file @
2a40efa5
...
...
@@ -99,3 +99,70 @@ as_path_getlen(struct adata *path)
}
return
res
;
}
#define MASK_PLUS do { mask = mask->next; if (!mask) return next == q; \
asterix = (mask->val == PM_ANY); \
if (asterix) { mask = mask->next; if (!mask) { return 1; } } \
} while(0)
int
as_path_match
(
struct
adata
*
path
,
struct
f_path_mask
*
mask
)
{
int
i
;
int
asterix
=
0
;
u8
*
p
=
path
->
data
;
u8
*
q
=
p
+
path
->
length
;
int
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 */
len
=
*
p
++
;
{
u8
*
p_save
=
p
;
next
=
p_save
+
2
*
len
;
retry:
p
=
p_save
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
asterix
&&
(
get_u16
(
p
)
==
mask
->
val
))
{
MASK_PLUS
;
goto
retry
;
}
if
(
!
asterix
&&
(
get_u16
(
p
)
==
mask
->
val
))
{
p
=
next
;
MASK_PLUS
;
goto
okay
;
}
p
+=
2
;
}
if
(
!
asterix
)
return
0
;
okay:
}
break
;
case
2
:
/* This is a sequence */
len
=
*
p
++
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
next
=
p
+
2
;
if
(
asterix
&&
(
get_u16
(
p
)
==
mask
->
val
))
MASK_PLUS
;
else
if
(
!
asterix
)
{
if
(
get_u16
(
p
)
!=
mask
->
val
)
return
0
;
MASK_PLUS
;
}
p
+=
2
;
}
break
;
default:
bug
(
"This should not be in path"
);
}
}
return
0
;
}
nest/attrs.h
View file @
2a40efa5
...
...
@@ -18,6 +18,14 @@ struct adata *as_path_prepend(struct linpool *pool, struct adata *olda, int as);
void
as_path_format
(
struct
adata
*
path
,
byte
*
buf
,
unsigned
int
size
);
int
as_path_getlen
(
struct
adata
*
path
);
struct
f_path_mask
{
struct
f_path_mask
*
next
;
int
val
;
};
#define PM_ANY -1
int
as_path_match
(
struct
adata
*
path
,
struct
f_path_mask
*
mask
);
/* a-set.c */
void
int_set_format
(
struct
adata
*
set
,
byte
*
buf
,
unsigned
int
size
);
...
...
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