Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
0b4230e5
Commit
0b4230e5
authored
6 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
gnrc_icmpv6_error: fix and optimize pointer search in _param_prob_build
parent
335342a4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sys/include/net/gnrc/icmpv6/error.h
+2
-0
2 additions, 0 deletions
sys/include/net/gnrc/icmpv6/error.h
sys/net/gnrc/network_layer/icmpv6/error/gnrc_icmpv6_error.c
+10
-22
10 additions, 22 deletions
sys/net/gnrc/network_layer/icmpv6/error/gnrc_icmpv6_error.c
with
12 additions
and
22 deletions
sys/include/net/gnrc/icmpv6/error.h
+
2
−
0
View file @
0b4230e5
...
...
@@ -62,6 +62,8 @@ void gnrc_icmpv6_error_time_exc_send(uint8_t code,
/**
* @brief Sends an ICMPv6 parameter problem message for sending.
*
* @pre @p orig_pkt is in receive order.
*
* @param[in] code The code for the message @see net/icmpv6.h.
* @param[in] ptr Pointer to the errorneous octet in @p orig_pkt.
* @param[in] orig_pkt The invoking packet.
...
...
This diff is collapsed.
Click to expand it.
sys/net/gnrc/network_layer/icmpv6/error/gnrc_icmpv6_error.c
+
10
−
22
View file @
0b4230e5
...
...
@@ -168,36 +168,24 @@ static gnrc_pktsnip_t *_param_prob_build(uint8_t code, void *ptr,
/* copy as much of the originating packet into error message and
* determine relative *ptr* offset */
if
(
pkt
!=
NULL
)
{
size_t
offset
=
sizeof
(
icmpv6_error_param_prob_t
);
uint8_t
*
data
=
pkt
->
data
;
icmpv6_error_param_prob_t
*
hdr
=
pkt
->
data
;
uint32_t
ptr_offset
=
0U
;
bool
found_offset
=
false
;
while
(
orig_pkt
!=
NULL
)
{
/* copy as long as it fits into packet */
if
(
offset
<
pkt
->
size
)
{
memcpy
(
data
+
offset
,
orig_pkt
->
data
,
MIN
(
pkt
->
size
-
offset
,
orig_pkt
->
size
));
offset
+=
MIN
(
pkt
->
size
-
offset
,
orig_pkt
->
size
);
}
while
(
_in_orig_pkt
(
orig_pkt
))
{
/* copy as long as it fits into packet; parameter problem can only
* come from received packets */
size_t
offset
=
_copy_rcv_snip
(
pkt
,
orig_pkt
);
if
(
_in_range
(
ptr
,
orig_pkt
->
data
,
orig_pkt
->
size
))
{
ptr_offset
+=
(
uint32_t
)(((
uint8_t
*
)
ptr
)
-
((
uint8_t
*
)
orig_pkt
->
data
));
found_offset
=
true
;
}
else
if
(
!
found_offset
)
{
ptr_offset
+=
(
uint32_t
)
orig_pkt
->
size
;
ptr_offset
=
(
uint32_t
)(((
uint8_t
*
)
ptr
)
-
((
uint8_t
*
)
orig_pkt
->
data
)
+
(
offset
-
ICMPV6_ERROR_SZ
));
}
orig_pkt
=
orig_pkt
->
next
;
if
((
offset
<
pkt
->
size
)
&&
found_offset
)
{
break
;
}
}
/* set "pointer" field to relative pointer offset */
((
icmpv6_error_param_prob_t
*
)
data
)
->
ptr
=
byteorder_htonl
(
ptr_offset
);
hdr
->
ptr
=
byteorder_htonl
(
ptr_offset
);
}
return
pkt
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment