Skip to content
Snippets Groups Projects
Commit e0164660 authored by Alexandre Abadie's avatar Alexandre Abadie Committed by GitHub
Browse files

Merge pull request #6064 from miri64/gnrc_sixlowpan_nhc/fix/forwarding

gnrc_sixlowpan_nhc: fix forwarding case
parents 6d80df1a 1605b506
No related branches found
No related tags found
No related merge requests found
......@@ -568,20 +568,14 @@ inline static size_t iphc_nhc_udp_encode(gnrc_pktsnip_t *udp, ipv6_hdr_t *ipv6_h
/* Set UDP header ID (rfc6282#section-5). */
ipv6_hdr->nh |= NHC_UDP_ID;
if (udp->type == GNRC_NETTYPE_IPV6) {
/* forwarded ipv6 packet */
size_t diff = sizeof(udp_hdr_t) - nhc_len;
for (size_t i = nhc_len; i < (udp->size - diff); i++) {
udp_data[i] = udp_data[i + diff];
}
/* NOTE: gnrc_pktbuf_realloc_data overflow if (udp->size - diff) < 4 */
gnrc_pktbuf_realloc_data(udp, (udp->size - diff));
}
else {
/* shrink udp allocation to final size */
gnrc_pktbuf_realloc_data(udp, nhc_len);
DEBUG("6lo iphc nhc: set udp len to %d\n", (int) nhc_len);
}
/* In case payload is in this snip (e.g. a forwarded packet):
* move data to right place */
size_t diff = sizeof(udp_hdr_t) - nhc_len;
for (size_t i = nhc_len; i < (udp->size - diff); i++) {
udp_data[i] = udp_data[i + diff];
}
/* NOTE: gnrc_pktbuf_realloc_data overflow if (udp->size - diff) < 4 */
gnrc_pktbuf_realloc_data(udp, (udp->size - diff));
return nhc_len;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment