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
Show 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,
...
@@ -477,6 +477,10 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
}
}
if
(
type
==
MESSAGE_PC
)
{
if
(
type
==
MESSAGE_PC
)
{
unsigned
int
pcnat
;
unsigned
int
pcnat
;
if
(
index
!=
NULL
)
goto
done
;
if
(
len
<
4
)
{
if
(
len
<
4
)
{
fprintf
(
stderr
,
"Received truncated PC TLV.
\n
"
);
fprintf
(
stderr
,
"Received truncated PC TLV.
\n
"
);
break
;
break
;
...
@@ -485,8 +489,7 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
...
@@ -485,8 +489,7 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
fprintf
(
stderr
,
"Overlong PC TLV.
\n
"
);
fprintf
(
stderr
,
"Overlong PC TLV.
\n
"
);
break
;
break
;
}
}
if
(
index
!=
NULL
)
goto
done
;
pc
=
message
+
2
;
pc
=
message
+
2
;
index
=
message
+
6
;
index
=
message
+
6
;
index_len
=
len
-
4
;
index_len
=
len
-
4
;
...
@@ -495,15 +498,25 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
...
@@ -495,15 +498,25 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
debugf
(
"Received PC %u from %s.
\n
"
,
debugf
(
"Received PC %u from %s.
\n
"
,
ntohl
(
pcnat
),
format_address
(
from
));
ntohl
(
pcnat
),
format_address
(
from
));
}
else
if
(
type
==
MESSAGE_CHALLENGE_REQUEST
)
{
}
else
if
(
type
==
MESSAGE_CHALLENGE_REQUEST
)
{
debugf
(
"Received challenge request from %s.
\n
"
,
format_address
(
from
));
if
(
IN6_IS_ADDR_MULTICAST
(
to
))
if
(
IN6_IS_ADDR_MULTICAST
(
to
))
goto
done
;
goto
done
;
if
(
len
>
192
)
{
fprintf
(
stderr
,
"Overlong challenge request TLV.
\n
"
);
break
;
}
nonce
=
message
+
2
;
nonce
=
message
+
2
;
nonce_len
=
len
;
nonce_len
=
len
;
debugf
(
"Received challenge request from %s.
\n
"
,
format_address
(
from
));
}
else
if
(
type
==
MESSAGE_CHALLENGE_REPLY
)
{
}
else
if
(
type
==
MESSAGE_CHALLENGE_REPLY
)
{
if
(
len
>
192
)
{
fprintf
(
stderr
,
"Overlong challenge reply TLV.
\n
"
);
break
;
}
debugf
(
"Received challenge reply from %s.
\n
"
,
debugf
(
"Received challenge reply from %s.
\n
"
,
format_address
(
from
));
format_address
(
from
));
...
@@ -522,6 +535,7 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
...
@@ -522,6 +535,7 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
const
struct
timeval
zero
=
{
0
,
0
};
const
struct
timeval
zero
=
{
0
,
0
};
challenge_success
=
1
;
challenge_success
=
1
;
neigh
->
challenge_deadline
=
zero
;
neigh
->
challenge_deadline
=
zero
;
debugf
(
"Challenge succeeded!
\n
"
);
}
else
{
}
else
{
debugf
(
"Challenge failed.
\n
"
);
debugf
(
"Challenge failed.
\n
"
);
}
}
...
@@ -532,43 +546,37 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
...
@@ -532,43 +546,37 @@ preparse_packet(const unsigned char *from, struct interface *ifp,
if
(
index
==
NULL
)
{
if
(
index
==
NULL
)
{
debugf
(
"No PC in packet.
\n
"
);
debugf
(
"No PC in packet.
\n
"
);
goto
maybe_send_challenge_reply
;
}
else
if
(
challenge_success
)
{
}
if
(
challenge_success
)
{
neigh
->
index_len
=
index_len
;
neigh
->
index_len
=
index_len
;
memcpy
(
neigh
->
index
,
index
,
index_len
);
memcpy
(
neigh
->
index
,
index
,
index_len
);
memcpy
(
neigh
->
pc
,
pc
,
4
);
memcpy
(
neigh
->
pc
,
pc
,
4
);
accept_packet
=
1
;
accept_packet
=
1
;
goto
maybe_send_challenge_reply
;
}
else
{
}
if
(
neigh
==
NULL
||
neigh
->
index_len
!=
index_len
||
memcmp
(
index
,
neigh
->
index
,
index_len
)
!=
0
)
{
neigh
=
neigh
!=
NULL
?
neigh
:
find_neighbour
(
from
,
ifp
);
neigh
=
neigh
!=
NULL
?
neigh
:
find_neighbour
(
from
,
ifp
);
if
(
neigh
==
NULL
)
if
(
neigh
==
NULL
)
return
NULL
;
return
NULL
;
if
(
neigh
->
index_len
==
-
1
||
neigh
->
index_len
!=
index_len
||
memcmp
(
index
,
neigh
->
index
,
index_len
)
!=
0
)
{
rc
=
send_challenge_request
(
neigh
);
rc
=
send_challenge_request
(
neigh
);
if
(
rc
<
-
1
)
if
(
rc
<
-
1
)
fputs
(
"Could not send challenge request.
\n
"
,
stderr
);
fputs
(
"Could not send challenge request.
\n
"
,
stderr
);
goto
maybe_send_challenge_reply
;
}
else
if
(
memcmp
(
pc
,
neigh
->
pc
,
4
)
<=
0
)
{
}
if
(
memcmp
(
pc
,
neigh
->
pc
,
4
)
<=
0
)
{
debugf
(
"Out of order PC.
\n
"
);
debugf
(
"Out of order PC.
\n
"
);
return
NULL
;
nonce
=
NULL
;
}
}
else
{
memcpy
(
neigh
->
pc
,
pc
,
4
);
memcpy
(
neigh
->
pc
,
pc
,
4
);
return
neigh
;
accept_packet
=
1
;
}
}
maybe_send_challenge_reply:
if
(
nonce
!=
NULL
)
{
/* a challenge request was received */
if
(
nonce
!=
NULL
)
{
/* a challenge request was received */
neigh
=
neigh
!=
NULL
?
neigh
:
find_neighbour
(
from
,
ifp
);
neigh
=
neigh
!=
NULL
?
neigh
:
find_neighbour
(
from
,
ifp
);
if
(
neigh
==
NULL
)
if
(
neigh
==
NULL
)
return
NULL
;
return
NULL
;
send_challenge_reply
(
neigh
,
nonce
,
nonce_len
);
send_challenge_reply
(
neigh
,
nonce
,
nonce_len
);
}
}
debugf
(
"accept_packet: %d, neigh: %p.
\n
"
,
accept_packet
,
(
void
*
)
neigh
);
return
accept_packet
?
neigh
:
NULL
;
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