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
1c3b2bb8
Commit
1c3b2bb8
authored
Sep 09, 2011
by
Matthieu Boutier
Committed by
Juliusz Chroboczek
Sep 09, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename struct network to interface and associated changes.
parent
5f40b621
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
700 additions
and
701 deletions
+700
-701
babeld.c
babeld.c
+64
-64
configuration.c
configuration.c
+46
-46
kernel_netlink.c
kernel_netlink.c
+3
-3
local.c
local.c
+2
-2
message.c
message.c
+303
-303
message.h
message.h
+13
-13
neighbour.c
neighbour.c
+16
-16
neighbour.h
neighbour.h
+2
-2
network.c
network.c
+185
-185
network.h
network.h
+28
-29
resend.c
resend.c
+12
-12
resend.h
resend.h
+4
-4
route.c
route.c
+19
-19
route.h
route.h
+3
-3
No files found.
babeld.c
View file @
1c3b2bb8
...
...
@@ -108,7 +108,7 @@ main(int argc, char **argv)
char
*
config_file
=
NULL
;
void
*
vrc
;
unsigned
int
seed
;
struct
network
*
net
;
struct
interface
*
ifp
;
gettime
(
&
now
);
...
...
@@ -362,22 +362,22 @@ main(int argc, char **argv)
}
for
(
i
=
optind
;
i
<
argc
;
i
++
)
{
vrc
=
add_
network
(
argv
[
i
],
NULL
);
vrc
=
add_
interface
(
argv
[
i
],
NULL
);
if
(
vrc
==
NULL
)
goto
fail
;
}
if
(
network
s
==
NULL
)
{
if
(
interface
s
==
NULL
)
{
fprintf
(
stderr
,
"Eek... asked to run on no interfaces!
\n
"
);
goto
fail
;
}
FOR_ALL_
NETS
(
net
)
{
/*
net
->ifindex is not necessarily valid at this point */
int
ifindex
=
if_nametoindex
(
net
->
if
name
);
FOR_ALL_
INTERFACES
(
ifp
)
{
/*
ifp
->ifindex is not necessarily valid at this point */
int
ifindex
=
if_nametoindex
(
ifp
->
name
);
if
(
ifindex
>
0
)
{
unsigned
char
eui
[
8
];
rc
=
if_eui64
(
net
->
if
name
,
ifindex
,
eui
);
rc
=
if_eui64
(
ifp
->
name
,
ifindex
,
eui
);
if
(
rc
<
0
)
continue
;
memcpy
(
myid
,
eui
,
8
);
...
...
@@ -482,7 +482,7 @@ main(int argc, char **argv)
rc
=
resize_receive_buffer
(
1500
);
if
(
rc
<
0
)
goto
fail
;
check_
network
s
();
check_
interface
s
();
if
(
receive_buffer
==
NULL
)
goto
fail
;
...
...
@@ -499,27 +499,27 @@ main(int argc, char **argv)
/* Make some noise so that others notice us, and send retractions in
case we were restarted recently */
FOR_ALL_
NETS
(
net
)
{
if
(
!
net_up
(
net
))
FOR_ALL_
INTERFACES
(
ifp
)
{
if
(
!
if_up
(
ifp
))
continue
;
/* Apply jitter before we send the first message. */
usleep
(
roughly
(
10000
));
gettime
(
&
now
);
send_hello
(
net
);
send_wildcard_retraction
(
net
);
send_hello
(
ifp
);
send_wildcard_retraction
(
ifp
);
}
FOR_ALL_
NETS
(
net
)
{
if
(
!
net_up
(
net
))
FOR_ALL_
INTERFACES
(
ifp
)
{
if
(
!
if_up
(
ifp
))
continue
;
usleep
(
roughly
(
10000
));
gettime
(
&
now
);
send_hello
(
net
);
send_wildcard_retraction
(
net
);
send_self_update
(
net
);
send_request
(
net
,
NULL
,
0
);
flushupdates
(
net
);
flushbuf
(
net
);
send_hello
(
ifp
);
send_wildcard_retraction
(
ifp
);
send_self_update
(
ifp
);
send_request
(
ifp
,
NULL
,
0
);
flushupdates
(
ifp
);
flushbuf
(
ifp
);
}
debugf
(
"Entering main loop.
\n
"
);
...
...
@@ -535,13 +535,13 @@ main(int argc, char **argv)
timeval_min_sec
(
&
tv
,
source_expiry_time
);
timeval_min_sec
(
&
tv
,
kernel_dump_time
);
timeval_min
(
&
tv
,
&
resend_time
);
FOR_ALL_
NETS
(
net
)
{
if
(
!
net_up
(
net
))
FOR_ALL_
INTERFACES
(
ifp
)
{
if
(
!
if_up
(
ifp
))
continue
;
timeval_min
(
&
tv
,
&
net
->
flush_timeout
);
timeval_min
(
&
tv
,
&
net
->
hello_timeout
);
timeval_min
(
&
tv
,
&
net
->
update_timeout
);
timeval_min
(
&
tv
,
&
net
->
update_flush_timeout
);
timeval_min
(
&
tv
,
&
ifp
->
flush_timeout
);
timeval_min
(
&
tv
,
&
ifp
->
hello_timeout
);
timeval_min
(
&
tv
,
&
ifp
->
update_timeout
);
timeval_min
(
&
tv
,
&
ifp
->
update_flush_timeout
);
}
timeval_min
(
&
tv
,
&
unicast_flush_timeout
);
FD_ZERO
(
&
readfds
);
...
...
@@ -593,11 +593,11 @@ main(int argc, char **argv)
sleep
(
1
);
}
}
else
{
FOR_ALL_
NETS
(
net
)
{
if
(
!
net_up
(
net
))
FOR_ALL_
INTERFACES
(
ifp
)
{
if
(
!
if_up
(
ifp
))
continue
;
if
(
net
->
ifindex
==
sin6
.
sin6_scope_id
)
{
parse_packet
((
unsigned
char
*
)
&
sin6
.
sin6_addr
,
net
,
if
(
ifp
->
ifindex
==
sin6
.
sin6_scope_id
)
{
parse_packet
((
unsigned
char
*
)
&
sin6
.
sin6_addr
,
ifp
,
receive_buffer
,
rc
);
VALGRIND_MAKE_MEM_UNDEFINED
(
receive_buffer
,
receive_buffer_size
);
...
...
@@ -647,7 +647,7 @@ main(int argc, char **argv)
}
if
(
kernel_link_changed
||
kernel_addr_changed
)
{
check_
network
s
();
check_
interface
s
();
kernel_link_changed
=
0
;
}
...
...
@@ -671,7 +671,7 @@ main(int argc, char **argv)
}
if
(
now
.
tv_sec
>=
expiry_time
)
{
check_
network
s
();
check_
interface
s
();
expire_routes
();
expire_resend
();
expiry_time
=
now
.
tv_sec
+
roughly
(
30
);
...
...
@@ -682,15 +682,15 @@ main(int argc, char **argv)
source_expiry_time
=
now
.
tv_sec
+
roughly
(
300
);
}
FOR_ALL_
NETS
(
net
)
{
if
(
!
net_up
(
net
))
FOR_ALL_
INTERFACES
(
ifp
)
{
if
(
!
if_up
(
ifp
))
continue
;
if
(
timeval_compare
(
&
now
,
&
net
->
hello_timeout
)
>=
0
)
send_hello
(
net
);
if
(
timeval_compare
(
&
now
,
&
net
->
update_timeout
)
>=
0
)
send_update
(
net
,
0
,
NULL
,
0
);
if
(
timeval_compare
(
&
now
,
&
net
->
update_flush_timeout
)
>=
0
)
flushupdates
(
net
);
if
(
timeval_compare
(
&
now
,
&
ifp
->
hello_timeout
)
>=
0
)
send_hello
(
ifp
);
if
(
timeval_compare
(
&
now
,
&
ifp
->
update_timeout
)
>=
0
)
send_update
(
ifp
,
0
,
NULL
,
0
);
if
(
timeval_compare
(
&
now
,
&
ifp
->
update_flush_timeout
)
>=
0
)
flushupdates
(
ifp
);
}
if
(
resend_time
.
tv_sec
!=
0
)
{
...
...
@@ -703,12 +703,12 @@ main(int argc, char **argv)
flush_unicast
(
1
);
}
FOR_ALL_
NETS
(
net
)
{
if
(
!
net_up
(
net
))
FOR_ALL_
INTERFACES
(
ifp
)
{
if
(
!
if_up
(
ifp
))
continue
;
if
(
net
->
flush_timeout
.
tv_sec
!=
0
)
{
if
(
timeval_compare
(
&
now
,
&
net
->
flush_timeout
)
>=
0
)
flushbuf
(
net
);
if
(
ifp
->
flush_timeout
.
tv_sec
!=
0
)
{
if
(
timeval_compare
(
&
now
,
&
ifp
->
flush_timeout
)
>=
0
)
flushbuf
(
ifp
);
}
}
...
...
@@ -726,31 +726,31 @@ main(int argc, char **argv)
while
(
numroutes
>
0
)
{
if
(
routes
[
0
].
installed
)
uninstall_route
(
&
routes
[
0
]);
/* We need to flush the route so
network
_up won't reinstall it */
/* We need to flush the route so
interface
_up won't reinstall it */
flush_route
(
&
routes
[
0
]);
}
FOR_ALL_
NETS
(
net
)
{
if
(
!
net_up
(
net
))
FOR_ALL_
INTERFACES
(
ifp
)
{
if
(
!
if_up
(
ifp
))
continue
;
send_wildcard_retraction
(
net
);
send_wildcard_retraction
(
ifp
);
/* Make sure that we expire quickly from our neighbours'
association caches. */
send_hello_noupdate
(
net
,
10
);
flushbuf
(
net
);
send_hello_noupdate
(
ifp
,
10
);
flushbuf
(
ifp
);
usleep
(
roughly
(
1000
));
gettime
(
&
now
);
}
FOR_ALL_
NETS
(
net
)
{
if
(
!
net_up
(
net
))
FOR_ALL_
INTERFACES
(
ifp
)
{
if
(
!
if_up
(
ifp
))
continue
;
/* Make sure they got it. */
send_wildcard_retraction
(
net
);
send_hello_noupdate
(
net
,
1
);
flushbuf
(
net
);
send_wildcard_retraction
(
ifp
);
send_hello_noupdate
(
ifp
,
1
);
flushbuf
(
ifp
);
usleep
(
roughly
(
10000
));
gettime
(
&
now
);
network_up
(
net
,
0
);
interface_up
(
ifp
,
0
);
}
kernel_setup_socket
(
0
);
kernel_setup
(
0
);
...
...
@@ -802,10 +802,10 @@ main(int argc, char **argv)
exit
(
1
);
fail:
FOR_ALL_
NETS
(
net
)
{
if
(
!
net_up
(
net
))
FOR_ALL_
INTERFACES
(
ifp
)
{
if
(
!
if_up
(
ifp
))
continue
;
network_up
(
net
,
0
);
interface_up
(
ifp
,
0
);
}
kernel_setup_socket
(
0
);
kernel_setup
(
0
);
...
...
@@ -936,12 +936,12 @@ dump_tables(FILE *out)
FOR_ALL_NEIGHBOURS
(
neigh
)
{
fprintf
(
out
,
"Neighbour %s dev %s reach %04x rxcost %d txcost %d chan %d%s.
\n
"
,
format_address
(
neigh
->
address
),
neigh
->
network
->
if
name
,
neigh
->
ifp
->
name
,
neigh
->
reach
,
neighbour_rxcost
(
neigh
),
neigh
->
txcost
,
neigh
->
network
->
channel
,
net_up
(
neigh
->
network
)
?
""
:
" (down)"
);
neigh
->
ifp
->
channel
,
if_up
(
neigh
->
ifp
)
?
""
:
" (down)"
);
}
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
fprintf
(
out
,
"%s metric %d (exported)
\n
"
,
...
...
@@ -980,7 +980,7 @@ dump_tables(FILE *out)
(
int
)
routes
[
i
].
seqno
,
channels
,
(
int
)(
now
.
tv_sec
-
routes
[
i
].
time
),
routes
[
i
].
neigh
->
network
->
if
name
,
routes
[
i
].
neigh
->
ifp
->
name
,
format_address
(
routes
[
i
].
neigh
->
address
),
nexthop
?
" nexthop "
:
""
,
nexthop
?
format_address
(
nexthop
)
:
""
,
...
...
configuration.c
View file @
1c3b2bb8
...
...
@@ -40,7 +40,7 @@ THE SOFTWARE.
struct
filter
*
input_filters
=
NULL
;
struct
filter
*
output_filters
=
NULL
;
struct
filter
*
redistribute_filters
=
NULL
;
struct
network_conf
*
network
_confs
=
NULL
;
struct
interface_conf
*
interface
_confs
=
NULL
;
/* get_next_char callback */
typedef
int
(
*
gnc_t
)(
void
*
);
...
...
@@ -370,15 +370,15 @@ parse_filter(gnc_t gnc, void *closure)
return
NULL
;
}
static
struct
network
_conf
*
parse_
n
conf
(
gnc_t
gnc
,
void
*
closure
)
static
struct
interface
_conf
*
parse_
if
conf
(
gnc_t
gnc
,
void
*
closure
)
{
int
c
;
char
*
token
;
struct
network_conf
*
n
conf
;
struct
interface_conf
*
if_
conf
;
nconf
=
calloc
(
1
,
sizeof
(
struct
network
_conf
));
if
(
n
conf
==
NULL
)
if_conf
=
calloc
(
1
,
sizeof
(
struct
interface
_conf
));
if
(
if_
conf
==
NULL
)
goto
error
;
c
=
gnc
(
closure
);
...
...
@@ -393,7 +393,7 @@ parse_nconf(gnc_t gnc, void *closure)
if
(
c
<
-
1
||
token
==
NULL
)
goto
error
;
n
conf
->
ifname
=
token
;
if_
conf
->
ifname
=
token
;
while
(
c
>=
0
&&
c
!=
'\n'
)
{
c
=
skip_whitespace
(
c
,
gnc
,
closure
);
...
...
@@ -410,43 +410,43 @@ parse_nconf(gnc_t gnc, void *closure)
c
=
getint
(
c
,
&
cost
,
gnc
,
closure
);
if
(
c
<
-
1
||
cost
<=
0
||
cost
>
0xFFFF
)
goto
error
;
n
conf
->
cost
=
cost
;
if_
conf
->
cost
=
cost
;
}
else
if
(
strcmp
(
token
,
"hello-interval"
)
==
0
)
{
int
interval
;
c
=
getmsec
(
c
,
&
interval
,
gnc
,
closure
);
if
(
c
<
-
1
||
interval
<=
0
||
interval
>
10
*
0xFFFF
)
goto
error
;
n
conf
->
hello_interval
=
interval
;
if_
conf
->
hello_interval
=
interval
;
}
else
if
(
strcmp
(
token
,
"update-interval"
)
==
0
)
{
int
interval
;
c
=
getmsec
(
c
,
&
interval
,
gnc
,
closure
);
if
(
c
<
-
1
||
interval
<=
0
||
interval
>
10
*
0xFFFF
)
goto
error
;
n
conf
->
update_interval
=
interval
;
if_
conf
->
update_interval
=
interval
;
}
else
if
(
strcmp
(
token
,
"wired"
)
==
0
)
{
int
v
;
c
=
getbool
(
c
,
&
v
,
gnc
,
closure
);
if
(
c
<
-
1
)
goto
error
;
n
conf
->
wired
=
v
;
if_
conf
->
wired
=
v
;
}
else
if
(
strcmp
(
token
,
"faraway"
)
==
0
)
{
int
v
;
c
=
getbool
(
c
,
&
v
,
gnc
,
closure
);
if
(
c
<
-
1
)
goto
error
;
n
conf
->
faraway
=
v
;
if_
conf
->
faraway
=
v
;
}
else
if
(
strcmp
(
token
,
"link-quality"
)
==
0
)
{
int
v
;
c
=
getbool
(
c
,
&
v
,
gnc
,
closure
);
if
(
c
<
-
1
)
goto
error
;
n
conf
->
lq
=
v
;
if_
conf
->
lq
=
v
;
}
else
if
(
strcmp
(
token
,
"split-horizon"
)
==
0
)
{
int
v
;
c
=
getbool
(
c
,
&
v
,
gnc
,
closure
);
if
(
c
<
-
1
)
goto
error
;
n
conf
->
split_horizon
=
v
;
if_
conf
->
split_horizon
=
v
;
}
else
if
(
strcmp
(
token
,
"channel"
)
==
0
)
{
char
*
t
,
*
end
;
...
...
@@ -455,19 +455,19 @@ parse_nconf(gnc_t gnc, void *closure)
goto
error
;
if
(
strcmp
(
t
,
"noninterfering"
)
==
0
)
nconf
->
channel
=
NET
_CHANNEL_NONINTERFERING
;
if_conf
->
channel
=
IF
_CHANNEL_NONINTERFERING
;
else
if
(
strcmp
(
t
,
"interfering"
)
==
0
)
nconf
->
channel
=
NET
_CHANNEL_INTERFERING
;
if_conf
->
channel
=
IF
_CHANNEL_INTERFERING
;
else
{
n
conf
->
channel
=
strtol
(
t
,
&
end
,
0
);
if_
conf
->
channel
=
strtol
(
t
,
&
end
,
0
);
if
(
*
end
!=
'\0'
)
goto
error
;
}
free
(
t
);
if
((
nconf
->
channel
<
1
||
n
conf
->
channel
>
254
)
&&
nconf
->
channel
!=
NET
_CHANNEL_NONINTERFERING
)
if
((
if_conf
->
channel
<
1
||
if_
conf
->
channel
>
254
)
&&
if_conf
->
channel
!=
IF
_CHANNEL_NONINTERFERING
)
goto
error
;
}
else
{
goto
error
;
...
...
@@ -475,10 +475,10 @@ parse_nconf(gnc_t gnc, void *closure)
free
(
token
);
}
return
n
conf
;
return
if_
conf
;
error:
free
(
n
conf
);
free
(
if_
conf
);
return
NULL
;
}
...
...
@@ -499,7 +499,7 @@ add_filter(struct filter *filter, struct filter **filters)
}
static
void
merge_
nconf
(
struct
network_conf
*
dest
,
struct
network
_conf
*
src
)
merge_
ifconf
(
struct
interface_conf
*
dest
,
struct
interface
_conf
*
src
)
{
assert
(
strcmp
(
dest
->
ifname
,
src
->
ifname
)
==
0
);
...
...
@@ -520,24 +520,24 @@ merge_nconf(struct network_conf *dest, struct network_conf *src)
}
static
void
add_
nconf
(
struct
network_conf
*
nconf
,
struct
network_conf
**
n
confs
)
add_
ifconf
(
struct
interface_conf
*
if_conf
,
struct
interface_conf
**
if_
confs
)
{
if
(
*
n
confs
==
NULL
)
{
n
conf
->
next
=
NULL
;
*
nconfs
=
n
conf
;
if
(
*
if_
confs
==
NULL
)
{
if_
conf
->
next
=
NULL
;
*
if_confs
=
if_
conf
;
}
else
{
struct
network_conf
*
n
;
n
=
*
n
confs
;
while
(
n
->
next
)
{
if
(
strcmp
(
n
->
ifname
,
n
conf
->
ifname
)
==
0
)
{
merge_
nconf
(
n
,
n
conf
);
free
(
n
conf
);
struct
interface_conf
*
if_c
;
if_c
=
*
if_
confs
;
while
(
if_c
->
next
)
{
if
(
strcmp
(
if_c
->
ifname
,
if_
conf
->
ifname
)
==
0
)
{
merge_
ifconf
(
if_c
,
if_
conf
);
free
(
if_
conf
);
return
;
}
n
=
n
->
next
;
if_c
=
if_c
->
next
;
}
n
conf
->
next
=
NULL
;
n
->
next
=
n
conf
;
if_
conf
->
next
=
NULL
;
if_c
->
next
=
if_
conf
;
}
}
...
...
@@ -582,11 +582,11 @@ parse_config(gnc_t gnc, void *closure)
return
-
1
;
add_filter
(
filter
,
&
redistribute_filters
);
}
else
if
(
strcmp
(
token
,
"interface"
)
==
0
)
{
struct
network_conf
*
n
conf
;
nconf
=
parse_n
conf
(
gnc
,
closure
);
if
(
n
conf
==
NULL
)
struct
interface_conf
*
if_
conf
;
if_conf
=
parse_if
conf
(
gnc
,
closure
);
if
(
if_
conf
==
NULL
)
return
-
1
;
add_
nconf
(
nconf
,
&
network
_confs
);
add_
ifconf
(
if_conf
,
&
interface
_confs
);
}
else
{
return
-
1
;
}
...
...
@@ -759,15 +759,15 @@ finalise_config()
filter
->
plen_le
=
128
;
add_filter
(
filter
,
&
redistribute_filters
);
while
(
network
_confs
)
{
struct
network_conf
*
n
;
while
(
interface
_confs
)
{
struct
interface_conf
*
if_conf
;
void
*
vrc
;
n
=
network
_confs
;
network_confs
=
network
_confs
->
next
;
n
->
next
=
NULL
;
vrc
=
add_
network
(
n
->
ifname
,
n
);
if_conf
=
interface
_confs
;
interface_confs
=
interface
_confs
->
next
;
if_conf
->
next
=
NULL
;
vrc
=
add_
interface
(
if_conf
->
ifname
,
if_conf
);
if
(
vrc
==
NULL
)
{
fprintf
(
stderr
,
"Couldn't add interface %s.
\n
"
,
n
->
ifname
);
fprintf
(
stderr
,
"Couldn't add interface %s.
\n
"
,
if_conf
->
ifname
);
return
-
1
;
}
}
...
...
kernel_netlink.c
View file @
1c3b2bb8
...
...
@@ -1239,7 +1239,7 @@ filter_link(struct nlmsghdr *nh, void *data)
int
ifindex
;
char
*
ifname
;
unsigned
int
ifflags
;
struct
network
*
net
;
struct
interface
*
ifp
;
len
=
nh
->
nlmsg_len
;
...
...
@@ -1257,8 +1257,8 @@ filter_link(struct nlmsghdr *nh, void *data)
return
0
;
kdebugf
(
"filter_interfaces: link change on if %s(%d): 0x%x
\n
"
,
ifname
,
ifindex
,
(
unsigned
)
ifflags
);
FOR_ALL_
NETS
(
net
)
{
if
(
strcmp
(
net
->
if
name
,
ifname
)
==
0
)
FOR_ALL_
INTERFACES
(
ifp
)
{
if
(
strcmp
(
ifp
->
name
,
ifname
)
==
0
)
return
1
;
}
return
0
;
...
...
local.c
View file @
1c3b2bb8
...
...
@@ -140,7 +140,7 @@ local_notify_neighbour(struct neighbour *neigh, int kind)
address as a unique identifier. */
(
unsigned
long
int
)
neigh
,
format_address
(
neigh
->
address
),
neigh
->
network
->
if
name
,
neigh
->
ifp
->
name
,
neigh
->
reach
,
neighbour_rxcost
(
neigh
),
neighbour_txcost
(
neigh
),
...
...
@@ -207,7 +207,7 @@ local_notify_route(struct route *route, int kind)
format_eui64
(
route
->
src
->
id
),
route_metric
(
route
),
route
->
refmetric
,
format_address
(
route
->
neigh
->
address
),
route
->
neigh
->
network
->
if
name
);
route
->
neigh
->
ifp
->
name
);
if
(
rc
<
0
||
rc
>=
512
)
goto
fail
;
...
...
message.c
View file @
1c3b2bb8
This diff is collapsed.
Click to expand it.
message.h
View file @
1c3b2bb8
...
...
@@ -50,29 +50,29 @@ extern unsigned char packet_header[4];
extern
struct
neighbour
*
unicast_neighbour
;
extern
struct
timeval
unicast_flush_timeout
;
void
parse_packet
(
const
unsigned
char
*
from
,
struct
network
*
net
,
void
parse_packet
(
const
unsigned
char
*
from
,
struct
interface
*
ifp
,
const
unsigned
char
*
packet
,
int
packetlen
);
void
flushbuf
(
struct
network
*
net
);
void
flushupdates
(
struct
network
*
net
);
void
flushbuf
(
struct
interface
*
ifp
);
void
flushupdates
(
struct
interface
*
ifp
);
void
send_ack
(
struct
neighbour
*
neigh
,
unsigned
short
nonce
,
unsigned
short
interval
);
void
send_hello_noupdate
(
struct
network
*
net
,
unsigned
interval
);
void
send_hello
(
struct
network
*
net
);
void
send_hello_noupdate
(
struct
interface
*
ifp
,
unsigned
interval
);
void
send_hello
(
struct
interface
*
ifp
);
void
flush_unicast
(
int
dofree
);
void
send_update
(
struct
network
*
net
,
int
urgent
,
void
send_update
(
struct
interface
*
ifp
,
int
urgent
,
const
unsigned
char
*
prefix
,
unsigned
char
plen
);
void
send_update_resend
(
struct
network
*
net
,
void
send_update_resend
(
struct
interface
*
ifp
,
const
unsigned
char
*
prefix
,
unsigned
char
plen
);
void
send_wildcard_retraction
(
struct
network
*
net
);
void
send_wildcard_retraction
(
struct
interface
*
ifp
);
void
update_myseqno
(
void
);
void
send_self_update
(
struct
network
*
net
);
void
send_ihu
(
struct
neighbour
*
neigh
,
struct
network
*
net
);
void
send_marginal_ihu
(
struct
network
*
net
);
void
send_request
(
struct
network
*
net
,
void
send_self_update
(
struct
interface
*
ifp
);
void
send_ihu
(
struct
neighbour
*
neigh
,
struct
interface
*
ifp
);
void
send_marginal_ihu
(
struct
interface
*
ifp
);
void
send_request
(
struct
interface
*
ifp
,
const
unsigned
char
*
prefix
,
unsigned
char
plen
);
void
send_unicast_request
(
struct
neighbour
*
neigh
,
const
unsigned
char
*
prefix
,
unsigned
char
plen
);
void
send_multihop_request
(
struct
network
*
net
,
void
send_multihop_request
(
struct
interface
*
ifp
,
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
const
unsigned
char
*
id
,
unsigned
short
hop_count
);
...
...
neighbour.c
View file @
1c3b2bb8
...
...
@@ -39,12 +39,12 @@ THE SOFTWARE.
struct
neighbour
*
neighs
=
NULL
;
static
struct
neighbour
*
find_neighbour_nocreate
(
const
unsigned
char
*
address
,
struct
network
*
net
)
find_neighbour_nocreate
(
const
unsigned
char
*
address
,
struct
interface
*
ifp
)
{
struct
neighbour
*
neigh
;
FOR_ALL_NEIGHBOURS
(
neigh
)
{
if
(
memcmp
(
address
,
neigh
->
address
,
16
)
==
0
&&
neigh
->
network
==
net
)
neigh
->
ifp
==
ifp
)
return
neigh
;
}
return
NULL
;
...
...
@@ -71,17 +71,17 @@ flush_neighbour(struct neighbour *neigh)
}
struct
neighbour
*
find_neighbour
(
const
unsigned
char
*
address
,
struct
network
*
net
)
find_neighbour
(
const
unsigned
char
*
address
,
struct
interface
*
ifp
)
{
struct
neighbour
*
neigh
;
const
struct
timeval
zero
=
{
0
,
0
};
neigh
=
find_neighbour_nocreate
(
address
,
net
);
neigh
=
find_neighbour_nocreate
(
address
,
ifp
);
if
(
neigh
)
return
neigh
;
debugf
(
"Creating neighbour %s on %s.
\n
"
,
format_address
(
address
),
net
->
if
name
);
format_address
(
address
),
ifp
->
name
);
neigh
=
malloc
(
sizeof
(
struct
neighbour
));
if
(
neigh
==
NULL
)
{
...
...
@@ -97,11 +97,11 @@ find_neighbour(const unsigned char *address, struct network *net)
neigh
->
hello_time
=
zero
;
neigh
->
hello_interval
=
0
;
neigh
->
ihu_interval
=
0
;
neigh
->
network
=
net
;
neigh
->
ifp
=
ifp
;
neigh
->
next
=
neighs
;
neighs
=
neigh
;
local_notify_neighbour
(
neigh
,
LOCAL_ADD
);
send_hello
(
net
);
send_hello
(
ifp
);
return
neigh
;
}
...
...
@@ -174,14 +174,14 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
/* Make sure to give neighbours some feedback early after association */
if
((
neigh
->
reach
&
0xBF00
)
==
0x8000
)
{
/* A new neighbour */
send_hello
(
neigh
->
network
);
send_hello
(
neigh
->
ifp
);
}
else
{
/* Don't send hellos, in order to avoid a positive feedback loop. */
int
a
=
(
neigh
->
reach
&
0xC000
);
int
b
=
(
neigh
->
reach
&
0x3000
);
if
((
a
==
0xC000
&&
b
==
0
)
||
(
a
==
0
&&
b
==
0x3000
))
{
/* Reachability is either 1100 or 0011 */
send_self_update
(
neigh
->
network
);
send_self_update
(
neigh
->
ifp
);
}
}
...
...
@@ -269,25 +269,25 @@ neighbour_rxcost(struct neighbour *neigh)
if
((
reach
&
0xFFF0
)
==
0
||
delay
>=
180000
)
{
return
INFINITY
;
}
else
if
((
neigh
->
network
->
flags
&
NET
_LQ
))
{
}
else
if
((
neigh
->
ifp
->
flags
&
IF
_LQ
))
{
int
sreach
=
((
reach
&
0x8000
)
>>
2
)
+
((
reach
&
0x4000
)
>>
1
)
+
(
reach
&
0x3FFF
);
/* 0 <= sreach <= 0x7FFF */
int
cost
=
(
0x8000
*
neigh
->
network
->
cost
)
/
(
sreach
+
1
);
/* cost >=
network
->cost */
int
cost
=
(
0x8000
*
neigh
->
ifp
->
cost
)
/
(
sreach
+
1
);
/* cost >=
interface
->cost */
if
(
delay
>=
40000
)
cost
=
(
cost
*
(
delay
-
20000
)
+
10000
)
/
20000
;
return
MIN
(
cost
,
INFINITY
);
}
else
{
/* To lose one hello is a misfortune, to lose two is carelessness. */
if
((
reach
&
0xC000
)
==
0xC000
)
return
neigh
->
network
->
cost
;
return
neigh
->
ifp
->
cost
;
else
if
((
reach
&
0xC000
)
==
0
)
return
INFINITY
;
else
if
((
reach
&
0x2000
))
return
neigh
->
network
->
cost
;
return
neigh
->
ifp
->
cost
;
else
return
INFINITY
;
}
...
...
@@ -298,7 +298,7 @@ neighbour_cost(struct neighbour *neigh)
{
unsigned
a
,
b
;
if
(
!
net_up
(
neigh
->
network
))
if
(
!
if_up
(
neigh
->
ifp
))
return
INFINITY
;
a
=
neighbour_txcost
(
neigh
);
...
...
@@ -310,7 +310,7 @@ neighbour_cost(struct neighbour *neigh)
if
(
b
>=
INFINITY
)
return
INFINITY
;
if
(
!
(
neigh
->
network
->
flags
&
NET
_LQ
)
||
(
a
<=
256
&&
b
<=
256
))
{
if
(
!
(
neigh
->
ifp
->
flags
&
IF
_LQ
)
||
(
a
<=
256
&&
b
<=
256
))
{
return
a
;
}
else
{
/* a = 256/alpha, b = 256/beta, where alpha and beta are the expected
...
...
neighbour.h
View file @
1c3b2bb8
...
...
@@ -31,7 +31,7 @@ struct neighbour {
struct
timeval
ihu_time
;
unsigned
short
hello_interval
;
/* in centiseconds */
unsigned
short
ihu_interval
;
/* in centiseconds */
struct
network
*
network
;
struct
interface
*
ifp
;
};
extern
struct
neighbour
*
neighs
;
...
...
@@ -42,7 +42,7 @@ extern struct neighbour *neighs;
int
neighbour_valid
(
struct
neighbour
*
neigh
);
void
flush_neighbour
(
struct
neighbour
*
neigh
);
struct
neighbour
*
find_neighbour
(
const
unsigned
char
*
address
,
struct
network
*
net
);
struct
interface
*
ifp
);
int
update_neighbour
(
struct
neighbour
*
neigh
,
int
hello
,
int
hello_interval
);
unsigned
check_neighbours
(
void
);
unsigned
neighbour_txcost
(
struct
neighbour
*
neigh
);
...
...
network.c
View file @
1c3b2bb8
This diff is collapsed.
Click to expand it.
network.h
View file @
1c3b2bb8
...
...
@@ -27,7 +27,7 @@ struct buffered_update {
unsigned
char
pad
[
3
];
};
struct
network
_conf
{
struct
interface
_conf
{
char
*
ifname
;
unsigned
hello_interval
;
unsigned
update_interval
;
...
...
@@ -37,27 +37,27 @@ struct network_conf {
char
lq
;
char
faraway
;
int
channel
;
struct
network
_conf
*
next
;
struct
interface
_conf
*
next
;
};
#define CONFIG_DEFAULT 0
#define CONFIG_NO 1
#define CONFIG_YES 2
#define
NET
_UP (1 << 0)
#define
NET
_WIRED (1<<1)
#define
NET
_SPLIT_HORIZON (1 << 2)
#define
NET
_LQ (1 << 3)
#define
NET
_FARAWAY (1 << 4)
#define
IF
_UP (1 << 0)
#define
IF
_WIRED (1<<1)
#define
IF
_SPLIT_HORIZON (1 << 2)
#define
IF
_LQ (1 << 3)
#define
IF
_FARAWAY (1 << 4)
/* Only INTERFERING can appear on the wire. */
#define
NET
_CHANNEL_UNKNOWN 0
#define
NET
_CHANNEL_INTERFERING 255
#define
NET
_CHANNEL_NONINTERFERING -2
#define
IF
_CHANNEL_UNKNOWN 0
#define
IF
_CHANNEL_INTERFERING 255
#define
IF
_CHANNEL_NONINTERFERING -2
struct
network
{
struct
network
*
next
;
struct
network
_conf
*
conf
;
struct
interface
{
struct
interface
*
next
;
struct
interface
_conf
*
conf
;
unsigned
int
ifindex
;
unsigned
short
flags
;
unsigned
short
cost
;
...
...
@@ -66,7 +66,7 @@ struct network {
struct
timeval
update_timeout
;
struct
timeval
flush_timeout
;
struct
timeval
update_flush_timeout
;
char
if
name
[
IF_NAMESIZE
];
char
name
[
IF_NAMESIZE
];
unsigned
char
*
ipv4
;
int
numll
;
unsigned
char
(
*
ll
)[
16
];
...
...
@@ -91,26 +91,25 @@ struct network {
unsigned
update_interval
;
};
#define
NET_CONF(_net
, _field) \
((_
net)->conf ? (_net
)->conf->_field : 0)
#define
IF_CONF(_ifp
, _field) \
((_
ifp)->conf ? (_ifp
)->conf->_field : 0)
extern
struct
network
*
networks
;
extern
int
numnets
;
extern
struct
interface
*
interfaces
;
#define FOR_ALL_
NETS(_net) for(_net = networks; _net; _net = _net
->next)
#define FOR_ALL_
INTERFACES(_ifp) for(_ifp = interfaces; _ifp; _ifp = _ifp
->next)
static
inline
int
net_up
(
struct
network
*
net
)
if_up
(
struct
interface
*
ifp
)
{
return
!!
(
net
->
flags
&
NET
_UP
);
return
!!
(
ifp
->
flags
&
IF
_UP
);
}
struct
network
*
add_network
(
char
*
ifname
,
struct
network_conf
*
conf
);
int
network_idle
(
struct
network
*
net
);
int
update_hello_interval
(
struct
network
*
net
);
unsigned
jitter
(
struct
network
*
net
,
int
urgent
);
unsigned
update_jitter
(
struct
network
*
net
,
int
urgent
);
struct
interface
*
add_interface
(
char
*
ifname
,
struct
interface_conf
*
if_
conf
);
int
interface_idle
(
struct
interface
*
ifp
);
int
update_hello_interval
(
struct
interface
*
ifp
);
unsigned
jitter
(
struct
interface
*
ifp
,
int
urgent
);
unsigned
update_jitter
(
struct
interface
*
ifp
,
int
urgent
);
void
set_timeout
(
struct
timeval
*
timeout
,
int
msecs
);
int
network_up
(
struct
network
*
net
,
int
up
);
int
network_ll_address
(
struct
network
*
net
,
const
unsigned
char
*
address
);
void
check_
network
s
(
void
);
int
interface_up
(
struct
interface
*
ifp
,
int
up
);
int
interface_ll_address
(
struct
interface
*
ifp
,
const
unsigned
char
*
address
);
void
check_
interface
s
(
void
);
resend.c
View file @
1c3b2bb8
...
...
@@ -83,10 +83,10 @@ find_request(const unsigned char *prefix, unsigned char plen,
int
record_resend
(
int
kind
,
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
const
unsigned
char
*
id
,
struct
network
*
network
,
int
delay
)
struct
interface
*
ifp
,
int
delay
)
{
struct
resend
*
resend
;
unsigned
int
ifindex
=
network
?
network
->
ifindex
:
0
;
unsigned
int
ifindex
=
ifp
?
ifp
->
ifindex
:
0
;
if
((
kind
==
RESEND_REQUEST
&&
input_filter
(
NULL
,
prefix
,
plen
,
NULL
,
ifindex
)
>=
INFINITY
)
||
...
...
@@ -114,8 +114,8 @@ record_resend(int kind, const unsigned char *prefix, unsigned char plen,
else
memset
(
resend
->
id
,
0
,
8
);
resend
->
seqno
=
seqno
;
if
(
resend
->
network
!=
network
)
resend
->
network
=
NULL
;
if
(
resend
->
ifp
!=
ifp
)
resend
->
ifp
=
NULL
;
}
else
{
resend
=
malloc
(
sizeof
(
struct
resend
));
if
(
resend
==
NULL
)
...
...
@@ -130,7 +130,7 @@ record_resend(int kind, const unsigned char *prefix, unsigned char plen,
memcpy
(
resend
->
id
,
id
,
8
);
else
memset
(
resend
->
id
,
0
,
8
);
resend
->
network
=
network
;
resend
->
ifp
=
ifp
;
resend
->
time
=
now
;
resend
->
next
=
to_resend
;
to_resend
=
resend
;
...
...
@@ -174,7 +174,7 @@ unsatisfied_request(const unsigned char *prefix, unsigned char plen,
/* Determine whether a given request should be forwarded. */
int
request_redundant
(
struct
network
*
net
,
request_redundant
(
struct
interface
*
ifp
,
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
const
unsigned
char
*
id
)
{
...
...
@@ -188,7 +188,7 @@ request_redundant(struct network *net,
seqno_compare
(
request
->
seqno
,
seqno
)
>
0
)
return
0
;
if
(
request
->
network
!=
NULL
&&
request
->
network
!=
net
)
if
(
request
->
ifp
!=
NULL
&&
request
->
ifp
!=
ifp
)
return
0
;
if
(
request
->
max
>
0
)
...
...
@@ -196,7 +196,7 @@ request_redundant(struct network *net,
return
1
;
if
(
timeval_minus_msec
(
&
now
,
&
request
->
time
)
<
(
net
?
MIN
(
net
->
hello_interval
,
1000
)
:
1000
))
(
ifp
?
MIN
(
ifp
->
hello_interval
,
1000
)
:
1000
))
/* Fairly recent. */
return
1
;
...
...
@@ -206,7 +206,7 @@ request_redundant(struct network *net,
int
satisfy_request
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
const
unsigned
char
*
id
,
struct
network
*
network
)
struct
interface
*
ifp
)
{
struct
resend
*
request
,
*
previous
;
...
...
@@ -214,7 +214,7 @@ satisfy_request(const unsigned char *prefix, unsigned char plen,
if
(
request
==
NULL
)
return
0
;
if
(
network
!=
NULL
&&
request
->
network
!=
network
)
if
(
ifp
!=
NULL
&&
request
->
ifp
!=
ifp
)
return
0
;
if
(
memcmp
(
request
->
id
,
id
,
8
)
!=
0
||
...
...
@@ -291,12 +291,12 @@ do_resend()
if
(
timeval_compare
(
&
now
,
&
timeout
)
>=
0
)
{
switch
(
resend
->
kind
)
{
case
RESEND_REQUEST
:
send_multihop_request
(
resend
->
network
,
send_multihop_request
(
resend
->
ifp
,
resend
->
prefix
,
resend
->
plen
,
resend
->
seqno
,
resend
->
id
,
127
);
break
;
case
RESEND_UPDATE
:
send_update
(
resend
->
network
,
1
,
send_update
(
resend
->
ifp
,
1
,
resend
->
prefix
,
resend
->
plen
);
break
;
default:
abort
();
...
...
resend.h
View file @
1c3b2bb8
...
...
@@ -35,7 +35,7 @@ struct resend {
unsigned
char
plen
;
unsigned
short
seqno
;
unsigned
char
id
[
8
];
struct
network
*
network
;
struct
interface
*
ifp
;
struct
resend
*
next
;
};
...
...
@@ -46,15 +46,15 @@ struct resend *find_request(const unsigned char *prefix, unsigned char plen,
void
flush_resends
(
struct
neighbour
*
neigh
);
int
record_resend
(
int
kind
,
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
const
unsigned
char
*
id
,
struct
network
*
net
,
int
delay
);
struct
interface
*
ifp
,
int
delay
);
int
unsatisfied_request
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
const
unsigned
char
*
id
);
int
request_redundant
(
struct
network
*
net
,
int
request_redundant
(
struct
interface
*
ifp
,
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
const
unsigned
char
*
id
);
int
satisfy_request
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
unsigned
short
seqno
,
const
unsigned
char
*
id
,
struct
network
*
net
);
struct
interface
*
ifp
);
void
expire_resend
(
void
);
void
recompute_resend_time
(
void
);
...
...
route.c
View file @
1c3b2bb8
...
...
@@ -134,13 +134,13 @@ flush_neighbour_routes(struct neighbour *neigh)
}
void
flush_
network_routes
(
struct
network
*
net
,
int
v4only
)
flush_
interface_routes
(
struct
interface
*
ifp
,
int
v4only
)
{
int
i
;
i
=
0
;
while
(
i
<
numroutes
)
{
if
(
routes
[
i
].
neigh
->
network
==
net
&&
if
(
routes
[
i
].
neigh
->
ifp
==
ifp
&&
(
!
v4only
||
v4mapped
(
routes
[
i
].
nexthop
)))
{
flush_route
(
&
routes
[
i
]);
continue
;
...
...
@@ -169,7 +169,7 @@ install_route(struct route *route)
rc
=
kernel_route
(
ROUTE_ADD
,
route
->
src
->
prefix
,
route
->
src
->
plen
,
route
->
nexthop
,
route
->
neigh
->
network
->
ifindex
,
route
->
neigh
->
ifp
->
ifindex
,
metric_to_kernel
(
route_metric
(
route
)),
NULL
,
0
,
0
);
if
(
rc
<
0
)
{
int
save
=
errno
;
...
...
@@ -191,7 +191,7 @@ uninstall_route(struct route *route)
rc
=
kernel_route
(
ROUTE_FLUSH
,
route
->
src
->
prefix
,
route
->
src
->
plen
,
route
->
nexthop
,
route
->
neigh
->
network
->
ifindex
,
route
->
neigh
->
ifp
->
ifindex
,
metric_to_kernel
(
route_metric
(
route
)),
NULL
,
0
,
0
);
if
(
rc
<
0
)
perror
(
"kernel_route(FLUSH)"
);
...
...
@@ -222,9 +222,9 @@ switch_routes(struct route *old, struct route *new)
"(this shouldn't happen)."
);
rc
=
kernel_route
(
ROUTE_MODIFY
,
old
->
src
->
prefix
,
old
->
src
->
plen
,
old
->
nexthop
,
old
->
neigh
->
network
->
ifindex
,
old
->
nexthop
,
old
->
neigh
->
ifp
->
ifindex
,
metric_to_kernel
(
route_metric
(
old
)),
new
->
nexthop
,
new
->
neigh
->
network
->
ifindex
,
new
->
nexthop
,
new
->
neigh
->
ifp
->
ifindex
,
metric_to_kernel
(
route_metric
(
new
)));
if
(
rc
<
0
)
{
perror
(
"kernel_route(MODIFY)"
);
...
...
@@ -251,9 +251,9 @@ change_route_metric(struct route *route,
if
(
route
->
installed
&&
old
!=
new
)
{
int
rc
;
rc
=
kernel_route
(
ROUTE_MODIFY
,
route
->
src
->
prefix
,
route
->
src
->
plen
,
route
->
nexthop
,
route
->
neigh
->
network
->
ifindex
,
route
->
nexthop
,
route
->
neigh
->
ifp
->
ifindex
,
old
,
route
->
nexthop
,
route
->
neigh
->
network
->
ifindex
,
route
->
nexthop
,
route
->
neigh
->
ifp
->
ifindex
,
new
);
if
(
rc
<
0
)
{
perror
(
"kernel_route(MODIFY metric)"
);
...
...
@@ -294,33 +294,33 @@ route_expired(struct route *route)
static
int
channels_interfere
(
int
ch1
,
int
ch2
)
{
if
(
ch1
==
NET_CHANNEL_NONINTERFERING
||
ch2
==
NET
_CHANNEL_NONINTERFERING
)
if
(
ch1
==
IF_CHANNEL_NONINTERFERING
||
ch2
==
IF
_CHANNEL_NONINTERFERING
)
return
0
;
if
(
ch1
==
NET_CHANNEL_INTERFERING
||
ch2
==
NET
_CHANNEL_INTERFERING
)
if
(
ch1
==
IF_CHANNEL_INTERFERING
||
ch2
==
IF
_CHANNEL_INTERFERING
)
return
1
;
return
ch1
==
ch2
;
}
int
route_interferes
(
struct
route
*
route
,
struct
network
*
net
)
route_interferes
(
struct
route
*
route
,
struct
interface
*
ifp
)
{
switch
(
diversity_kind
)
{
case
DIVERSITY_NONE
:
return
1
;
case
DIVERSITY_INTERFACE_1
:
return
route
->
neigh
->
network
==
net
;
return
route
->
neigh
->
ifp
==
ifp
;
case
DIVERSITY_CHANNEL_1
:
case
DIVERSITY_CHANNEL
:
if
(
route
->
neigh
->
network
==
net
)
if
(
route
->
neigh
->
ifp
==
ifp
)
return
1
;
if
(
channels_interfere
(
net
->
channel
,
route
->
neigh
->
network
->
channel
))
if
(
channels_interfere
(
ifp
->
channel
,
route
->
neigh
->
ifp
->
channel
))
return
1
;
if
(
diversity_kind
==
DIVERSITY_CHANNEL
)
{
int
i
;
for
(
i
=
0
;
i
<
DIVERSITY_HOPS
;
i
++
)
{
if
(
route
->
channels
[
i
]
==
0
)
break
;
if
(
channels_interfere
(
net
->
channel
,
route
->
channels
[
i
]))
if
(
channels_interfere
(
ifp
->
channel
,
route
->
channels
[
i
]))
return
1
;
}
}
...
...
@@ -391,7 +391,7 @@ update_route_metric(struct route *route)
int
add_metric
=
input_filter
(
route
->
src
->
id
,
route
->
src
->
prefix
,
route
->
src
->
plen
,
neigh
->
address
,
neigh
->
network
->
ifindex
);
neigh
->
ifp
->
ifindex
);
change_route_metric
(
route
,
route
->
refmetric
,
neighbour_cost
(
route
->
neigh
),
add_metric
);
if
(
route_metric
(
route
)
!=
oldmetric
)
...
...
@@ -420,13 +420,13 @@ update_neighbour_metric(struct neighbour *neigh, int changed)
}
void
update_
network_metric
(
struct
network
*
net
)
update_
interface_metric
(
struct
interface
*
ifp
)
{
int
i
;
i
=
0
;
while
(
i
<
numroutes
)
{
if
(
routes
[
i
].
neigh
->
network
==
net
)
if
(
routes
[
i
].
neigh
->
ifp
==
ifp
)
update_route_metric
(
&
routes
[
i
]);
i
++
;
}
...
...
@@ -456,7 +456,7 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen,
}
add_metric
=
input_filter
(
a
,
p
,
plen
,
neigh
->
address
,
neigh
->
network
->
ifindex
);
neigh
->
address
,
neigh
->
ifp
->
ifindex
);
if
(
add_metric
>=
INFINITY
)
return
NULL
;
...
...
route.h
View file @
1c3b2bb8
...
...
@@ -71,14 +71,14 @@ struct route *find_installed_route(const unsigned char *prefix,
unsigned
char
plen
);
void
flush_route
(
struct
route
*
route
);
void
flush_neighbour_routes
(
struct
neighbour
*
neigh
);
void
flush_
network_routes
(
struct
network
*
net
,
int
v4only
);
void
flush_
interface_routes
(
struct
interface
*
ifp
,
int
v4only
);
void
install_route
(
struct
route
*
route
);
void
uninstall_route
(
struct
route
*
route
);
void
switch_route
(
struct
route
*
old
,
struct
route
*
new
);
int
route_feasible
(
struct
route
*
route
);
int
route_old
(
struct
route
*
route
);
int
route_expired
(
struct
route
*
route
);
int
route_interferes
(
struct
route
*
route
,
struct
network
*
net
);
int
route_interferes
(
struct
route
*
route
,
struct
interface
*
ifp
);
int
update_feasible
(
struct
source
*
src
,
unsigned
short
seqno
,
unsigned
short
refmetric
);
struct
route
*
find_best_route
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
...
...
@@ -86,7 +86,7 @@ struct route *find_best_route(const unsigned char *prefix, unsigned char plen,
struct
route
*
install_best_route
(
const
unsigned
char
prefix
[
16
],
unsigned
char
plen
);
void
update_neighbour_metric
(
struct
neighbour
*
neigh
,
int
changed
);
void
update_
network_metric
(
struct
network
*
net
);
void
update_
interface_metric
(
struct
interface
*
ifp
);
void
update_route_metric
(
struct
route
*
route
);
struct
route
*
update_route
(
const
unsigned
char
*
a
,
const
unsigned
char
*
p
,
unsigned
char
plen
,
...
...
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