Skip to content

Commit

Permalink
gnrc_sixlowpan_iphc: forward received fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Dec 1, 2020
1 parent d9f3c08 commit e9d34e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,24 @@ static int _rbuf_get(const void *src, size_t src_len,
default:
reass_type = GNRC_NETTYPE_UNDEF;
}
#ifdef MODULE_GNRC_SIXLOWPAN_FRAG_VRB
res->pkt = gnrc_pktbuf_add(NULL, NULL, 0, reass_type);
#else /* MODULE_GNRC_SIXLOWPAN_FRAG_VRB */
res->pkt = gnrc_pktbuf_add(NULL, NULL, size, reass_type);
#endif /* MODULE_GNRC_SIXLOWPAN_FRAG_VRB */
if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_VRB)) {
if (IS_USED(MODULE_GNRC_SIXLOWPAN_IPHC)) {
/* only allocate enough space to decompress IPv6 header
* for forwarding information */
res->pkt = gnrc_pktbuf_add(NULL, NULL, sizeof(ipv6_hdr_t),
reass_type);
}
else {
/* try fragment forwarding without IPHC. Since `res->pkt == NULL`
* is not a valid value for a reassembly buffer entry, we need to
* set it to at least a packet snip for now */
res->pkt = gnrc_pktbuf_add(NULL, NULL, 0, reass_type);
}
}
else {
/* reassemble whole datagram without direct fragment forwarding */
res->pkt = gnrc_pktbuf_add(NULL, NULL, size, reass_type);
}
if (res->pkt == NULL) {
DEBUG("6lo rfrag: can not allocate reassembly buffer space.\n");
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ void gnrc_sixlowpan_iphc_recv(gnrc_pktsnip_t *sixlo, void *rbuf_ptr,
payload_offset - sizeof(ipv6_hdr_t));
}
if ((rbuf == NULL) &&
/* (rbuf == NULL) => forwarding is not affected by this */
(gnrc_pktbuf_realloc_data(ipv6, uncomp_hdr_len + payload_len) != 0)) {
DEBUG("6lo iphc: no space left to copy payload\n");
_recv_error_release(sixlo, ipv6, rbuf);
Expand Down Expand Up @@ -852,6 +853,7 @@ void gnrc_sixlowpan_iphc_recv(gnrc_pktsnip_t *sixlo, void *rbuf_ptr,
}
}
if ((ipv6 == NULL) || (res < 0)) {
/* TODO fall-back to reassembly in minfwd when ipv6 != NULL */
gnrc_sixlowpan_frag_vrb_rm(vrbe);
}
gnrc_pktbuf_release(sixlo);
Expand Down

0 comments on commit e9d34e2

Please sign in to comment.