From b27f12bc1f58e0f8f425ca0b31d794a55dd79c11 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 14 Feb 2019 16:41:39 +0100 Subject: [PATCH 1/2] gnrc_sixlowpan_frag: remove redundant PID member The interface ID is actually also provided in `pkt` so providing it in the `gnrc_sixlowpan_msg_frag_t` struct is redundant. --- sys/include/net/gnrc/sixlowpan/frag.h | 1 - .../network_layer/sixlowpan/frag/gnrc_sixlowpan_frag.c | 7 +++---- sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/sys/include/net/gnrc/sixlowpan/frag.h b/sys/include/net/gnrc/sixlowpan/frag.h index 1e5a81ab0de2..790df66e41f7 100644 --- a/sys/include/net/gnrc/sixlowpan/frag.h +++ b/sys/include/net/gnrc/sixlowpan/frag.h @@ -92,7 +92,6 @@ typedef struct { size_t datagram_size; /**< Length of just the (uncompressed) IPv6 packet to be fragmented */ uint16_t offset; /**< Offset of the Nth fragment from the beginning of the * payload datagram */ - kernel_pid_t pid; /**< PID of the interface */ } gnrc_sixlowpan_msg_frag_t; /** diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/gnrc_sixlowpan_frag.c b/sys/net/gnrc/network_layer/sixlowpan/frag/gnrc_sixlowpan_frag.c index 8b94a263113f..7f5cd220b2c9 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/gnrc_sixlowpan_frag.c +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/gnrc_sixlowpan_frag.c @@ -31,9 +31,7 @@ #define ENABLE_DEBUG (0) #include "debug.h" -static gnrc_sixlowpan_msg_frag_t _fragment_msg = { - NULL, 0, 0, KERNEL_PID_UNDEF - }; +static gnrc_sixlowpan_msg_frag_t _fragment_msg; #if ENABLE_DEBUG /* For PRIu16 etc. */ @@ -238,7 +236,7 @@ void gnrc_sixlowpan_frag_send(gnrc_pktsnip_t *pkt, void *ctx, unsigned page) { assert(ctx != NULL); gnrc_sixlowpan_msg_frag_t *fragment_msg = ctx; - gnrc_netif_t *iface = gnrc_netif_get_by_pid(fragment_msg->pid); + gnrc_netif_t *iface; uint16_t res; /* payload_len: actual size of the packet vs * datagram_size: size of the uncompressed IPv6 packet */ @@ -248,6 +246,7 @@ void gnrc_sixlowpan_frag_send(gnrc_pktsnip_t *pkt, void *ctx, unsigned page) assert((fragment_msg->pkt == pkt) || (pkt == NULL)); (void)page; (void)pkt; + iface = gnrc_netif_hdr_get_netif(fragment_msg->pkt->data); #if defined(DEVELHELP) && ENABLE_DEBUG if (iface == NULL) { DEBUG("6lo frag: iface == NULL, expect segmentation fault.\n"); diff --git a/sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c b/sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c index f19f8441c359..339cbda80531 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c +++ b/sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c @@ -129,7 +129,6 @@ void gnrc_sixlowpan_multiplex_by_size(gnrc_pktsnip_t *pkt, gnrc_pktbuf_release_error(pkt, ENOMEM); return; } - fragment_msg->pid = netif->pid; fragment_msg->pkt = pkt; fragment_msg->datagram_size = orig_datagram_size; /* Sending the first fragment has an offset==0 */ From 0954fabdc776da6c5a6ce87dc9404aeb7bfcd5e1 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 15 Feb 2019 11:23:46 +0100 Subject: [PATCH 2/2] gnrc_sixlowpan_frag: make datagram size uint16_t for send It can't get bigger, so it doesn't make sense to waste another 2 byte on it. --- sys/include/net/gnrc/sixlowpan/frag.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/include/net/gnrc/sixlowpan/frag.h b/sys/include/net/gnrc/sixlowpan/frag.h index 790df66e41f7..ff6a7c4987a3 100644 --- a/sys/include/net/gnrc/sixlowpan/frag.h +++ b/sys/include/net/gnrc/sixlowpan/frag.h @@ -89,7 +89,7 @@ typedef struct { */ typedef struct { gnrc_pktsnip_t *pkt; /**< Pointer to the IPv6 packet to be fragmented */ - size_t datagram_size; /**< Length of just the (uncompressed) IPv6 packet to be fragmented */ + uint16_t datagram_size; /**< Length of just the (uncompressed) IPv6 packet to be fragmented */ uint16_t offset; /**< Offset of the Nth fragment from the beginning of the * payload datagram */ } gnrc_sixlowpan_msg_frag_t;