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
3551b45c
Commit
3551b45c
authored
Aug 20, 2020
by
Antonin Décimo
Committed by
Juliusz Chroboczek
May 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify and fix preparse phase.
parent
ba8f1168
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
27 deletions
+35
-27
message.c
message.c
+35
-27
No files found.
message.c
View file @
3551b45c
...
...
@@ -477,6 +477,10 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
}
if
(
type
==
MESSAGE_PC
)
{
unsigned
int
pcnat
;
if
(
index
!=
NULL
)
goto
done
;
if
(
len
<
4
)
{
fprintf
(
stderr
,
"Received truncated PC TLV.
\n
"
);
break
;
...
...
@@ -485,8 +489,7 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
fprintf
(
stderr
,
"Overlong PC TLV.
\n
"
);
break
;
}
if
(
index
!=
NULL
)
goto
done
;
pc
=
message
+
2
;
index
=
message
+
6
;
index_len
=
len
-
4
;
...
...
@@ -495,15 +498,25 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
debugf
(
"Received PC %u from %s.
\n
"
,
ntohl
(
pcnat
),
format_address
(
from
));
}
else
if
(
type
==
MESSAGE_CHALLENGE_REQUEST
)
{
debugf
(
"Received challenge request from %s.
\n
"
,
format_address
(
from
));
if
(
IN6_IS_ADDR_MULTICAST
(
to
))
goto
done
;
if
(
len
>
192
)
{
fprintf
(
stderr
,
"Overlong challenge request TLV.
\n
"
);
break
;
}
nonce
=
message
+
2
;
nonce_len
=
len
;
debugf
(
"Received challenge request from %s.
\n
"
,
format_address
(
from
));
}
else
if
(
type
==
MESSAGE_CHALLENGE_REPLY
)
{
if
(
len
>
192
)
{
fprintf
(
stderr
,
"Overlong challenge reply TLV.
\n
"
);
break
;
}
debugf
(
"Received challenge reply from %s.
\n
"
,
format_address
(
from
));
...
...
@@ -522,6 +535,7 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
const
struct
timeval
zero
=
{
0
,
0
};
challenge_success
=
1
;
neigh
->
challenge_deadline
=
zero
;
debugf
(
"Challenge succeeded!
\n
"
);
}
else
{
debugf
(
"Challenge failed.
\n
"
);
}
...
...
@@ -532,43 +546,37 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
if
(
index
==
NULL
)
{
debugf
(
"No PC in packet.
\n
"
);
goto
maybe_send_challenge_reply
;
}
if
(
challenge_success
)
{
}
else
if
(
challenge_success
)
{
neigh
->
index_len
=
index_len
;
memcpy
(
neigh
->
index
,
index
,
index_len
);
memcpy
(
neigh
->
pc
,
pc
,
4
);
accept_packet
=
1
;
goto
maybe_send_challenge_reply
;
}
if
(
neigh
==
NULL
||
neigh
->
index_len
!=
index_len
||
memcmp
(
index
,
neigh
->
index
,
index_len
)
!=
0
)
{
}
else
{
neigh
=
neigh
!=
NULL
?
neigh
:
find_neighbour
(
from
,
ifp
);
if
(
neigh
==
NULL
)
return
NULL
;
rc
=
send_challenge_request
(
neigh
);
if
(
rc
<
-
1
)
fputs
(
"Could not send challenge request.
\n
"
,
stderr
);
goto
maybe_send_challenge_reply
;
}
if
(
memcmp
(
pc
,
neigh
->
pc
,
4
)
<=
0
)
{
debugf
(
"Out of order PC.
\n
"
);
return
NULL
;
if
(
neigh
->
index_len
==
-
1
||
neigh
->
index_len
!=
index_len
||
memcmp
(
index
,
neigh
->
index
,
index_len
)
!=
0
)
{
rc
=
send_challenge_request
(
neigh
);
if
(
rc
<
-
1
)
fputs
(
"Could not send challenge request.
\n
"
,
stderr
);
}
else
if
(
memcmp
(
pc
,
neigh
->
pc
,
4
)
<=
0
)
{
debugf
(
"Out of order PC.
\n
"
);
nonce
=
NULL
;
}
else
{
memcpy
(
neigh
->
pc
,
pc
,
4
);
accept_packet
=
1
;
}
}
memcpy
(
neigh
->
pc
,
pc
,
4
);
return
neigh
;
maybe_send_challenge_reply:
if
(
nonce
!=
NULL
)
{
/* a challenge request was received */
neigh
=
neigh
!=
NULL
?
neigh
:
find_neighbour
(
from
,
ifp
);
if
(
neigh
==
NULL
)
return
NULL
;
send_challenge_reply
(
neigh
,
nonce
,
nonce_len
);
}
debugf
(
"accept_packet: %d, neigh: %p.
\n
"
,
accept_packet
,
(
void
*
)
neigh
);
return
accept_packet
?
neigh
:
NULL
;
}
...
...
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