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
c2704e82
Commit
c2704e82
authored
Mar 16, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use hello_seqno to indicate invalid entries in the neighbour table.
Instead of neigh->id[0] = 0xFF.
parent
ebaa1afd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
neighbour.c
neighbour.c
+12
-11
neighbour.h
neighbour.h
+3
-2
No files found.
neighbour.c
View file @
c2704e82
...
...
@@ -37,14 +37,20 @@ THE SOFTWARE.
struct
neighbour
neighs
[
MAXNEIGHBOURS
];
int
numneighs
=
0
;
static
int
neighbour_valid
(
struct
neighbour
*
neigh
)
{
return
neigh
->
hello_seqno
!=
-
2
;
}
void
flush_neighbour
(
struct
neighbour
*
neigh
)
{
flush_neighbour_routes
(
neigh
);
memset
(
neigh
,
0
,
sizeof
(
*
neigh
));
VALGRIND_MAKE_MEM_UNDEFINED
(
neigh
,
sizeof
(
*
neigh
));
neigh
->
id
[
0
]
=
0xFF
;
while
(
numneighs
>
0
&&
neighs
[
numneighs
-
1
].
id
[
0
]
==
0xFF
)
{
neigh
->
hello_seqno
=
-
2
;
while
(
numneighs
>
0
&&
!
neighbour_valid
(
&
neighs
[
numneighs
-
1
])
)
{
numneighs
--
;
VALGRIND_MAKE_MEM_UNDEFINED
(
&
neighs
[
numneighs
],
sizeof
(
neighs
[
numneighs
]));
...
...
@@ -56,7 +62,7 @@ find_neighbour(const unsigned char *address, struct network *net)
{
int
i
;
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
if
(
neighs
[
i
].
id
[
0
]
==
0xFF
)
if
(
!
neighbour_valid
(
&
neighs
[
i
])
)
continue
;
if
(
memcmp
(
address
,
neighs
[
i
].
address
,
16
)
==
0
&&
neighs
[
i
].
network
==
net
)
...
...
@@ -73,11 +79,6 @@ add_neighbour(const unsigned char *id, const unsigned char *address,
const
struct
timeval
zero
=
{
0
,
0
};
int
i
;
if
(
id
[
0
]
==
0xFF
)
{
fprintf
(
stderr
,
"Received neighbour announcement with id[0] = FF.
\n
"
);
return
NULL
;
}
neigh
=
find_neighbour
(
address
,
net
);
if
(
neigh
)
{
if
(
memcmp
(
neigh
->
id
,
id
,
16
)
==
0
)
{
...
...
@@ -92,7 +93,7 @@ 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
(
neighs
[
i
].
id
[
0
]
==
0xFF
)
if
(
!
neighbour_valid
(
&
neighs
[
i
])
)
neigh
=
&
neighs
[
i
];
}
if
(
!
neigh
)
{
...
...
@@ -102,6 +103,7 @@ add_neighbour(const unsigned char *id, const unsigned char *address,
}
neigh
=
&
neighs
[
numneighs
++
];
}
neigh
->
hello_seqno
=
-
1
;
memcpy
(
neigh
->
id
,
id
,
16
);
memcpy
(
neigh
->
address
,
address
,
16
);
neigh
->
reach
=
0
;
...
...
@@ -110,7 +112,6 @@ add_neighbour(const unsigned char *id, const unsigned char *address,
neigh
->
hello_time
=
zero
;
neigh
->
hello_interval
=
0
;
neigh
->
ihu_interval
=
0
;
neigh
->
hello_seqno
=
-
1
;
neigh
->
network
=
net
;
send_hello
(
net
);
return
neigh
;
...
...
@@ -220,7 +221,7 @@ check_neighbours()
debugf
(
"Checking neighbours.
\n
"
);
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
if
(
neighs
[
i
].
id
[
0
]
==
0xFF
)
if
(
!
neighbour_valid
(
&
neighs
[
i
])
)
continue
;
changed
=
update_neighbour
(
&
neighs
[
i
],
-
1
,
0
);
...
...
neighbour.h
View file @
c2704e82
...
...
@@ -21,12 +21,13 @@ THE SOFTWARE.
*/
struct
neighbour
{
/* This is -1 when unknown, and -2 for an invalid neighbour,
so don't make it unsigned */
int
hello_seqno
;
unsigned
char
id
[
16
];
unsigned
char
address
[
16
];
unsigned
short
reach
;
unsigned
short
txcost
;
/* This is -1 when unknown, so don't make it unsigned */
int
hello_seqno
;
struct
timeval
hello_time
;
struct
timeval
ihu_time
;
unsigned
short
hello_interval
;
/* in centiseconds */
...
...
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