Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
b48ed3e3
Commit
b48ed3e3
authored
Jul 10, 2007
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorise xroute destination comparison into a separate function.
parent
cbd0670a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
xroute.c
xroute.c
+14
-15
No files found.
xroute.c
View file @
b48ed3e3
...
@@ -42,16 +42,20 @@ int nummyxroutes = 0;
...
@@ -42,16 +42,20 @@ int nummyxroutes = 0;
int
xroute_gc_delay
=
180
;
int
xroute_gc_delay
=
180
;
int
xroute_hold_delay
=
45
;
int
xroute_hold_delay
=
45
;
static
int
xroute_prefix
(
struct
xroute
*
xroute
,
const
unsigned
char
*
prefix
,
int
plen
)
{
return
(
xroute
->
plen
==
plen
&&
memcmp
(
xroute
->
prefix
,
prefix
,
16
)
==
0
);
}
static
struct
xroute
*
static
struct
xroute
*
find_installed_xroute
(
unsigned
char
*
prefix
,
unsigned
short
plen
)
find_installed_xroute
(
unsigned
char
*
prefix
,
unsigned
short
plen
)
{
{
int
i
;
int
i
;
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
if
(
xroutes
[
i
].
installed
&&
if
(
xroutes
[
i
].
installed
&&
xroute_prefix
(
&
xroutes
[
i
],
prefix
,
plen
))
xroutes
[
i
].
plen
==
plen
&&
memcmp
(
xroutes
[
i
].
prefix
,
prefix
,
16
)
==
0
)
{
return
&
xroutes
[
i
];
return
&
xroutes
[
i
];
}
}
}
return
NULL
;
return
NULL
;
}
}
...
@@ -61,11 +65,8 @@ find_installed_myxroute(unsigned char *prefix, unsigned short plen)
...
@@ -61,11 +65,8 @@ find_installed_myxroute(unsigned char *prefix, unsigned short plen)
{
{
int
i
;
int
i
;
for
(
i
=
0
;
i
<
nummyxroutes
;
i
++
)
{
for
(
i
=
0
;
i
<
nummyxroutes
;
i
++
)
{
if
(
myxroutes
[
i
].
installed
&&
if
(
myxroutes
[
i
].
installed
&&
xroute_prefix
(
&
myxroutes
[
i
],
prefix
,
plen
))
myxroutes
[
i
].
plen
==
plen
&&
memcmp
(
myxroutes
[
i
].
prefix
,
prefix
,
16
)
==
0
)
{
return
&
myxroutes
[
i
];
return
&
myxroutes
[
i
];
}
}
}
return
NULL
;
return
NULL
;
}
}
...
@@ -80,8 +81,7 @@ find_best_xroute(unsigned char *prefix, unsigned short plen)
...
@@ -80,8 +81,7 @@ find_best_xroute(unsigned char *prefix, unsigned short plen)
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
if
(
xroutes
[
i
].
metric
>=
INFINITY
&&
xroutes
[
i
].
cost
<
INFINITY
)
if
(
xroutes
[
i
].
metric
>=
INFINITY
&&
xroutes
[
i
].
cost
<
INFINITY
)
continue
;
continue
;
if
(
xroutes
[
i
].
plen
!=
plen
||
if
(
!
xroute_prefix
(
&
xroutes
[
i
],
prefix
,
plen
))
memcmp
(
xroutes
[
i
].
prefix
,
prefix
,
16
)
!=
0
)
continue
;
continue
;
route
=
find_installed_route
(
xroutes
[
i
].
gateway
);
route
=
find_installed_route
(
xroutes
[
i
].
gateway
);
if
(
route
->
nexthop
!=
xroutes
[
i
].
nexthop
)
if
(
route
->
nexthop
!=
xroutes
[
i
].
nexthop
)
...
@@ -251,8 +251,7 @@ retract_xroutes(struct destination *gateway, struct neighbour *nexthop,
...
@@ -251,8 +251,7 @@ retract_xroutes(struct destination *gateway, struct neighbour *nexthop,
if
(
xroutes
[
i
].
cost
<
INFINITY
&&
xroutes
[
i
].
gateway
==
gateway
&&
if
(
xroutes
[
i
].
cost
<
INFINITY
&&
xroutes
[
i
].
gateway
==
gateway
&&
xroutes
[
i
].
nexthop
==
nexthop
)
{
xroutes
[
i
].
nexthop
==
nexthop
)
{
for
(
j
=
0
;
j
<
numexcept
;
j
++
)
{
for
(
j
=
0
;
j
<
numexcept
;
j
++
)
{
if
(
memcmp
(
xroutes
[
i
].
prefix
,
except
[
j
].
prefix
,
16
)
==
0
&&
if
(
xroute_prefix
(
&
xroutes
[
i
],
except
[
j
].
prefix
,
except
[
j
].
plen
))
xroutes
[
i
].
plen
==
except
[
j
].
plen
)
goto
skip
;
goto
skip
;
}
}
update_xroute_metric
(
&
xroutes
[
i
],
INFINITY
);
update_xroute_metric
(
&
xroutes
[
i
],
INFINITY
);
...
@@ -282,7 +281,7 @@ update_xroute(const unsigned char *prefix, unsigned short plen,
...
@@ -282,7 +281,7 @@ update_xroute(const unsigned char *prefix, unsigned short plen,
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
xroute
=
&
xroutes
[
i
];
xroute
=
&
xroutes
[
i
];
if
(
xroute
->
gateway
==
gateway
&&
xroute
->
nexthop
==
nexthop
&&
if
(
xroute
->
gateway
==
gateway
&&
xroute
->
nexthop
==
nexthop
&&
memcmp
(
xroute
->
prefix
,
prefix
,
16
)
==
0
&&
xroute
->
plen
==
plen
)
{
xroute_prefix
(
xroute
,
prefix
,
plen
)
)
{
update_xroute_metric
(
xroute
,
cost
);
update_xroute_metric
(
xroute
,
cost
);
xroute
->
time
=
now
.
tv_sec
;
xroute
->
time
=
now
.
tv_sec
;
return
xroute
;
return
xroute
;
...
@@ -378,8 +377,8 @@ check_myxroutes()
...
@@ -378,8 +377,8 @@ check_myxroutes()
continue
;
continue
;
installed
=
0
;
installed
=
0
;
for
(
j
=
0
;
j
<
n
;
j
++
)
{
for
(
j
=
0
;
j
<
n
;
j
++
)
{
if
(
routes
[
j
].
plen
==
myxroutes
[
i
].
plen
&&
if
(
xroute_prefix
(
&
myxroutes
[
i
],
memcmp
(
routes
[
j
].
prefix
,
myxroutes
[
i
].
prefix
,
16
)
==
0
)
{
routes
[
j
].
prefix
,
routes
[
j
].
plen
)
)
{
installed
=
1
;
installed
=
1
;
break
;
break
;
}
}
...
...
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