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
e45020f7
Commit
e45020f7
authored
May 19, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use FOR_ALL_NEIGHBOURS throughout.
parent
8d3c6f0e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
46 deletions
+46
-46
babel.c
babel.c
+10
-9
message.c
message.c
+10
-11
neighbour.c
neighbour.c
+26
-26
No files found.
babel.c
View file @
e45020f7
...
...
@@ -902,23 +902,24 @@ init_signals(void)
static
void
dump_tables
(
FILE
*
out
)
{
struct
neighbour
*
neigh
;
int
i
;
fprintf
(
out
,
"
\n
"
);
fprintf
(
out
,
"My id %s seqno %d
\n
"
,
format_address
(
myid
),
myseqno
);
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
]
))
FOR_ALL_NEIGHBOURS
(
neigh
)
{
if
(
!
neighbour_valid
(
neigh
))
continue
;
fprintf
(
out
,
"Neighbour %s "
,
format_address
(
neigh
s
[
i
].
id
));
fprintf
(
out
,
"Neighbour %s "
,
format_address
(
neigh
->
id
));
fprintf
(
out
,
"at %s dev %s reach %04x rxcost %d txcost %d%s.
\n
"
,
format_address
(
neigh
s
[
i
].
address
),
neigh
s
[
i
].
network
->
ifname
,
neigh
s
[
i
].
reach
,
neighbour_rxcost
(
&
neighs
[
i
]
),
neigh
s
[
i
].
txcost
,
neigh
s
[
i
].
network
->
up
?
""
:
" (down)"
);
format_address
(
neigh
->
address
),
neigh
->
network
->
ifname
,
neigh
->
reach
,
neighbour_rxcost
(
neigh
),
neigh
->
txcost
,
neigh
->
network
->
up
?
""
:
" (down)"
);
}
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
fprintf
(
out
,
"%s metric %d (%s)
\n
"
,
...
...
message.c
View file @
e45020f7
...
...
@@ -1009,8 +1009,6 @@ send_self_update(struct network *net, int force_seqno)
void
send_ihu
(
struct
neighbour
*
neigh
,
struct
network
*
net
)
{
int
i
;
if
(
neigh
==
NULL
&&
net
==
NULL
)
{
struct
network
*
n
;
FOR_ALL_NETS
(
n
)
{
...
...
@@ -1022,11 +1020,12 @@ send_ihu(struct neighbour *neigh, struct network *net)
}
if
(
neigh
==
NULL
)
{
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
]))
struct
neighbour
*
ngh
;
FOR_ALL_NEIGHBOURS
(
ngh
)
{
if
(
!
neighbour_valid
(
ngh
))
continue
;
if
(
n
eighs
[
i
].
network
==
net
)
send_ihu
(
&
neighs
[
i
]
,
net
);
if
(
n
gh
->
network
==
net
)
send_ihu
(
ngh
,
net
);
}
}
else
{
int
rxcost
,
interval
;
...
...
@@ -1055,11 +1054,11 @@ send_ihu(struct neighbour *neigh, struct network *net)
void
send_marginal_ihu
(
struct
network
*
net
)
{
int
i
;
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
])
||
(
net
&&
neighs
[
i
].
network
!=
net
))
struct
neighbour
*
neigh
;
FOR_ALL_NEIGHBOURS
(
neigh
)
{
if
(
!
neighbour_valid
(
neigh
)
||
(
net
&&
neigh
->
network
!=
net
))
continue
;
if
(
neigh
s
[
i
].
txcost
>=
384
||
(
neighs
[
i
].
reach
&
0xF000
)
!=
0xF000
)
send_ihu
(
&
neighs
[
i
]
,
net
);
if
(
neigh
->
txcost
>=
384
||
(
neigh
->
reach
&
0xF000
)
!=
0xF000
)
send_ihu
(
neigh
,
net
);
}
}
neighbour.c
View file @
e45020f7
...
...
@@ -62,13 +62,13 @@ flush_neighbour(struct neighbour *neigh)
struct
neighbour
*
find_neighbour
(
const
unsigned
char
*
address
,
struct
network
*
net
)
{
int
i
;
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
]
))
struct
neighbour
*
neigh
;
FOR_ALL_NEIGHBOURS
(
neigh
)
{
if
(
!
neighbour_valid
(
neigh
))
continue
;
if
(
memcmp
(
address
,
neigh
s
[
i
].
address
,
16
)
==
0
&&
neigh
s
[
i
].
network
==
net
)
return
&
neighs
[
i
]
;
if
(
memcmp
(
address
,
neigh
->
address
,
16
)
==
0
&&
neigh
->
network
==
net
)
return
neigh
;
}
return
NULL
;
}
...
...
@@ -77,9 +77,8 @@ struct neighbour *
add_neighbour
(
const
unsigned
char
*
id
,
const
unsigned
char
*
address
,
struct
network
*
net
)
{
struct
neighbour
*
neigh
;
struct
neighbour
*
neigh
,
*
ngh
;
const
struct
timeval
zero
=
{
0
,
0
};
int
i
;
neigh
=
find_neighbour
(
address
,
net
);
if
(
neigh
)
{
...
...
@@ -94,9 +93,9 @@ add_neighbour(const unsigned char *id, const unsigned char *address,
}
debugf
(
"Creating neighbour %s (%s).
\n
"
,
format_address
(
id
),
format_address
(
address
));
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
]
))
neigh
=
&
neighs
[
i
]
;
FOR_ALL_NEIGHBOURS
(
ngh
)
{
if
(
!
neighbour_valid
(
ngh
))
neigh
=
ngh
;
}
if
(
!
neigh
)
{
if
(
numneighs
>=
MAXNEIGHBOURS
)
{
...
...
@@ -235,35 +234,36 @@ reset_txcost(struct neighbour *neigh)
int
check_neighbours
()
{
int
i
,
changed
,
delay
;
struct
neighbour
*
neigh
;
int
changed
,
delay
;
int
msecs
=
50000
;
debugf
(
"Checking neighbours.
\n
"
);
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
]
))
FOR_ALL_NEIGHBOURS
(
neigh
)
{
if
(
!
neighbour_valid
(
neigh
))
continue
;
changed
=
update_neighbour
(
&
neighs
[
i
]
,
-
1
,
0
);
changed
=
update_neighbour
(
neigh
,
-
1
,
0
);
if
(
neigh
s
[
i
].
reach
==
0
||
neigh
s
[
i
].
hello_time
.
tv_sec
>
now
.
tv_sec
||
/* clock stepped */
timeval_minus_msec
(
&
now
,
&
neigh
s
[
i
].
hello_time
)
>
300000
)
{
flush_neighbour
(
&
neighs
[
i
]
);
if
(
neigh
->
reach
==
0
||
neigh
->
hello_time
.
tv_sec
>
now
.
tv_sec
||
/* clock stepped */
timeval_minus_msec
(
&
now
,
&
neigh
->
hello_time
)
>
300000
)
{
flush_neighbour
(
neigh
);
continue
;
}
delay
=
timeval_minus_msec
(
&
now
,
&
neigh
s
[
i
].
ihu_time
);
delay
=
timeval_minus_msec
(
&
now
,
&
neigh
->
ihu_time
);
changed
=
changed
||
reset_txcost
(
&
neighs
[
i
]
);
changed
=
changed
||
reset_txcost
(
neigh
);
if
(
changed
)
update_neighbour_metric
(
&
neighs
[
i
]
);
update_neighbour_metric
(
neigh
);
if
(
neigh
s
[
i
].
hello_interval
>
0
)
msecs
=
MIN
(
msecs
,
neigh
s
[
i
].
hello_interval
*
10
);
if
(
neigh
s
[
i
].
ihu_interval
>
0
)
msecs
=
MIN
(
msecs
,
neigh
s
[
i
].
ihu_interval
*
10
);
if
(
neigh
->
hello_interval
>
0
)
msecs
=
MIN
(
msecs
,
neigh
->
hello_interval
*
10
);
if
(
neigh
->
ihu_interval
>
0
)
msecs
=
MIN
(
msecs
,
neigh
->
ihu_interval
*
10
);
}
return
msecs
;
...
...
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