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
Hide 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)
...
@@ -902,23 +902,24 @@ init_signals(void)
static
void
static
void
dump_tables
(
FILE
*
out
)
dump_tables
(
FILE
*
out
)
{
{
struct
neighbour
*
neigh
;
int
i
;
int
i
;
fprintf
(
out
,
"
\n
"
);
fprintf
(
out
,
"
\n
"
);
fprintf
(
out
,
"My id %s seqno %d
\n
"
,
format_address
(
myid
),
myseqno
);
fprintf
(
out
,
"My id %s seqno %d
\n
"
,
format_address
(
myid
),
myseqno
);
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
FOR_ALL_NEIGHBOURS
(
neigh
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
]
))
if
(
!
neighbour_valid
(
neigh
))
continue
;
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
"
,
fprintf
(
out
,
"at %s dev %s reach %04x rxcost %d txcost %d%s.
\n
"
,
format_address
(
neigh
s
[
i
].
address
),
format_address
(
neigh
->
address
),
neigh
s
[
i
].
network
->
ifname
,
neigh
->
network
->
ifname
,
neigh
s
[
i
].
reach
,
neigh
->
reach
,
neighbour_rxcost
(
&
neighs
[
i
]
),
neighbour_rxcost
(
neigh
),
neigh
s
[
i
].
txcost
,
neigh
->
txcost
,
neigh
s
[
i
].
network
->
up
?
""
:
" (down)"
);
neigh
->
network
->
up
?
""
:
" (down)"
);
}
}
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
fprintf
(
out
,
"%s metric %d (%s)
\n
"
,
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)
...
@@ -1009,8 +1009,6 @@ send_self_update(struct network *net, int force_seqno)
void
void
send_ihu
(
struct
neighbour
*
neigh
,
struct
network
*
net
)
send_ihu
(
struct
neighbour
*
neigh
,
struct
network
*
net
)
{
{
int
i
;
if
(
neigh
==
NULL
&&
net
==
NULL
)
{
if
(
neigh
==
NULL
&&
net
==
NULL
)
{
struct
network
*
n
;
struct
network
*
n
;
FOR_ALL_NETS
(
n
)
{
FOR_ALL_NETS
(
n
)
{
...
@@ -1022,11 +1020,12 @@ send_ihu(struct neighbour *neigh, struct network *net)
...
@@ -1022,11 +1020,12 @@ send_ihu(struct neighbour *neigh, struct network *net)
}
}
if
(
neigh
==
NULL
)
{
if
(
neigh
==
NULL
)
{
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
struct
neighbour
*
ngh
;
if
(
!
neighbour_valid
(
&
neighs
[
i
]))
FOR_ALL_NEIGHBOURS
(
ngh
)
{
if
(
!
neighbour_valid
(
ngh
))
continue
;
continue
;
if
(
n
eighs
[
i
].
network
==
net
)
if
(
n
gh
->
network
==
net
)
send_ihu
(
&
neighs
[
i
]
,
net
);
send_ihu
(
ngh
,
net
);
}
}
}
else
{
}
else
{
int
rxcost
,
interval
;
int
rxcost
,
interval
;
...
@@ -1055,11 +1054,11 @@ send_ihu(struct neighbour *neigh, struct network *net)
...
@@ -1055,11 +1054,11 @@ send_ihu(struct neighbour *neigh, struct network *net)
void
void
send_marginal_ihu
(
struct
network
*
net
)
send_marginal_ihu
(
struct
network
*
net
)
{
{
int
i
;
struct
neighbour
*
neigh
;
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
FOR_ALL_NEIGHBOURS
(
neigh
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
])
||
(
net
&&
neighs
[
i
].
network
!=
net
))
if
(
!
neighbour_valid
(
neigh
)
||
(
net
&&
neigh
->
network
!=
net
))
continue
;
continue
;
if
(
neigh
s
[
i
].
txcost
>=
384
||
(
neighs
[
i
].
reach
&
0xF000
)
!=
0xF000
)
if
(
neigh
->
txcost
>=
384
||
(
neigh
->
reach
&
0xF000
)
!=
0xF000
)
send_ihu
(
&
neighs
[
i
]
,
net
);
send_ihu
(
neigh
,
net
);
}
}
}
}
neighbour.c
View file @
e45020f7
...
@@ -62,13 +62,13 @@ flush_neighbour(struct neighbour *neigh)
...
@@ -62,13 +62,13 @@ flush_neighbour(struct neighbour *neigh)
struct
neighbour
*
struct
neighbour
*
find_neighbour
(
const
unsigned
char
*
address
,
struct
network
*
net
)
find_neighbour
(
const
unsigned
char
*
address
,
struct
network
*
net
)
{
{
int
i
;
struct
neighbour
*
neigh
;
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
FOR_ALL_NEIGHBOURS
(
neigh
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
]
))
if
(
!
neighbour_valid
(
neigh
))
continue
;
continue
;
if
(
memcmp
(
address
,
neigh
s
[
i
].
address
,
16
)
==
0
&&
if
(
memcmp
(
address
,
neigh
->
address
,
16
)
==
0
&&
neigh
s
[
i
].
network
==
net
)
neigh
->
network
==
net
)
return
&
neighs
[
i
]
;
return
neigh
;
}
}
return
NULL
;
return
NULL
;
}
}
...
@@ -77,9 +77,8 @@ struct neighbour *
...
@@ -77,9 +77,8 @@ struct neighbour *
add_neighbour
(
const
unsigned
char
*
id
,
const
unsigned
char
*
address
,
add_neighbour
(
const
unsigned
char
*
id
,
const
unsigned
char
*
address
,
struct
network
*
net
)
struct
network
*
net
)
{
{
struct
neighbour
*
neigh
;
struct
neighbour
*
neigh
,
*
ngh
;
const
struct
timeval
zero
=
{
0
,
0
};
const
struct
timeval
zero
=
{
0
,
0
};
int
i
;
neigh
=
find_neighbour
(
address
,
net
);
neigh
=
find_neighbour
(
address
,
net
);
if
(
neigh
)
{
if
(
neigh
)
{
...
@@ -94,9 +93,9 @@ add_neighbour(const unsigned char *id, const unsigned char *address,
...
@@ -94,9 +93,9 @@ add_neighbour(const unsigned char *id, const unsigned char *address,
}
}
debugf
(
"Creating neighbour %s (%s).
\n
"
,
debugf
(
"Creating neighbour %s (%s).
\n
"
,
format_address
(
id
),
format_address
(
address
));
format_address
(
id
),
format_address
(
address
));
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
FOR_ALL_NEIGHBOURS
(
ngh
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
]
))
if
(
!
neighbour_valid
(
ngh
))
neigh
=
&
neighs
[
i
]
;
neigh
=
ngh
;
}
}
if
(
!
neigh
)
{
if
(
!
neigh
)
{
if
(
numneighs
>=
MAXNEIGHBOURS
)
{
if
(
numneighs
>=
MAXNEIGHBOURS
)
{
...
@@ -235,35 +234,36 @@ reset_txcost(struct neighbour *neigh)
...
@@ -235,35 +234,36 @@ reset_txcost(struct neighbour *neigh)
int
int
check_neighbours
()
check_neighbours
()
{
{
int
i
,
changed
,
delay
;
struct
neighbour
*
neigh
;
int
changed
,
delay
;
int
msecs
=
50000
;
int
msecs
=
50000
;
debugf
(
"Checking neighbours.
\n
"
);
debugf
(
"Checking neighbours.
\n
"
);
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
FOR_ALL_NEIGHBOURS
(
neigh
)
{
if
(
!
neighbour_valid
(
&
neighs
[
i
]
))
if
(
!
neighbour_valid
(
neigh
))
continue
;
continue
;
changed
=
update_neighbour
(
&
neighs
[
i
]
,
-
1
,
0
);
changed
=
update_neighbour
(
neigh
,
-
1
,
0
);
if
(
neigh
s
[
i
].
reach
==
0
||
if
(
neigh
->
reach
==
0
||
neigh
s
[
i
].
hello_time
.
tv_sec
>
now
.
tv_sec
||
/* clock stepped */
neigh
->
hello_time
.
tv_sec
>
now
.
tv_sec
||
/* clock stepped */
timeval_minus_msec
(
&
now
,
&
neigh
s
[
i
].
hello_time
)
>
300000
)
{
timeval_minus_msec
(
&
now
,
&
neigh
->
hello_time
)
>
300000
)
{
flush_neighbour
(
&
neighs
[
i
]
);
flush_neighbour
(
neigh
);
continue
;
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
)
if
(
changed
)
update_neighbour_metric
(
&
neighs
[
i
]
);
update_neighbour_metric
(
neigh
);
if
(
neigh
s
[
i
].
hello_interval
>
0
)
if
(
neigh
->
hello_interval
>
0
)
msecs
=
MIN
(
msecs
,
neigh
s
[
i
].
hello_interval
*
10
);
msecs
=
MIN
(
msecs
,
neigh
->
hello_interval
*
10
);
if
(
neigh
s
[
i
].
ihu_interval
>
0
)
if
(
neigh
->
ihu_interval
>
0
)
msecs
=
MIN
(
msecs
,
neigh
s
[
i
].
ihu_interval
*
10
);
msecs
=
MIN
(
msecs
,
neigh
->
ihu_interval
*
10
);
}
}
return
msecs
;
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