diff --git a/sys/include/net/gnrc/sixlowpan/frag/vrb.h b/sys/include/net/gnrc/sixlowpan/frag/vrb.h index e21347e729..3bb859195a 100644 --- a/sys/include/net/gnrc/sixlowpan/frag/vrb.h +++ b/sys/include/net/gnrc/sixlowpan/frag/vrb.h @@ -25,6 +25,7 @@ #include #include +#include "kernel_defines.h" #include "net/gnrc/netif.h" #include "net/gnrc/sixlowpan/config.h" #ifdef MODULE_GNRC_SIXLOWPAN_FRAG @@ -123,9 +124,9 @@ gnrc_sixlowpan_frag_vrb_t *gnrc_sixlowpan_frag_vrb_get( */ static inline void gnrc_sixlowpan_frag_vrb_rm(gnrc_sixlowpan_frag_vrb_t *vrb) { -#ifdef MODULE_GNRC_SIXLOWPAN_FRAG - gnrc_sixlowpan_frag_rb_base_rm(&vrb->super); -#endif /* MODULE_GNRC_SIXLOWPAN_FRAG */ + if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_RB)) { + gnrc_sixlowpan_frag_rb_base_rm(&vrb->super); + } vrb->super.src_len = 0; } diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c b/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c index f043ba6b7a..a2fe7c937a 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c @@ -302,6 +302,12 @@ static int _rbuf_add(gnrc_netif_hdr_t *netif_hdr, gnrc_pktsnip_t *pkt, memcpy(((uint8_t *)entry->pkt->data) + offset, data, frag_size); } + else { + /* no space left in rbuf interval buffer*/ + gnrc_pktbuf_release(entry->pkt); + gnrc_sixlowpan_frag_rb_remove(entry); + res = RBUF_ADD_ERROR; + } /* no errors and not consumed => release packet */ gnrc_pktbuf_release(pkt); return res; diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c b/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c index 6d42cc51ad..dac87c3984 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c @@ -83,6 +83,34 @@ gnrc_sixlowpan_frag_vrb_t *gnrc_sixlowpan_frag_vrb_add( vrbe->super.dst_len, addr_str), vrbe->out_tag); } + /* _equal_index() => append intervals of `base`, so they don't get + * lost. We use append, so we don't need to change base! */ + else if (base->ints != NULL) { + gnrc_sixlowpan_frag_rb_int_t *tmp = vrbe->super.ints; + + if (tmp != base->ints) { + /* base->ints is not already vrbe->super.ints */ + if (tmp != NULL) { + /* iterate before appending and check if `base->ints` is + * not already part of list */ + while (tmp->next != NULL) { + if (tmp == base->ints) { + tmp = NULL; + } + /* cppcheck-suppress nullPointer + * (reason: possible bug in cppcheck, tmp can't + * clearly be a NULL pointer here) */ + tmp = tmp->next; + } + if (tmp != NULL) { + tmp->next = base->ints; + } + } + else { + vrbe->super.ints = base->ints; + } + } + } break; } }