6LoWPAN: Remove the option to disable fragmentation support. Two reasons: (1) First fragementation is always required becaues IPv6 requires an MTU of 1280 bytes. The is no application use case that can work without fragmentation support. And (2) it greatly reduces the complexity of the code.

This commit is contained in:
Gregory Nutt 2017-09-10 10:49:27 -06:00
parent 334d1734dc
commit c217c663ae
9 changed files with 11 additions and 88 deletions

View File

@ -128,20 +128,10 @@
# endif
#endif
#ifndef CONFIG_NET_6LOWPAN_FRAG
# undef CONFIG_NET_6LOWPAN_MTU
# undef CONFIG_NET_6LOWPAN_TCP_RECVWNDO
#endif
#ifndef CONFIG_NET_6LOWPAN_MTU
# undef CONFIG_NET_6LOWPAN_TCP_RECVWNDO
# ifdef CONFIG_NET_6LOWPAN_FRAG
# define CONFIG_NET_6LOWPAN_MTU 1294
# define CONFIG_NET_6LOWPAN_TCP_RECVWNDO 1220
# else
# define CONFIG_NET_6LOWPAN_MTU CONFIG_NET_6LOWPAN_FRAMELEN
# define CONFIG_NET_6LOWPAN_TCP_RECVWNDO (CONFIG_NET_6LOWPAN_FRAMELEN - 25)
# endif
# define CONFIG_NET_6LOWPAN_MTU 1294
# undef CONFIG_NET_6LOWPAN_TCP_RECVWNDO
# define CONFIG_NET_6LOWPAN_TCP_RECVWNDO 1220
#endif
/* We are supporting multiple network devices using different link layer

View File

@ -382,7 +382,6 @@ struct sixlowpan_reassbuf_s
FAR struct sixlowpan_reassbuf_s *rb_flink;
#if CONFIG_NET_6LOWPAN_FRAG
/* Fragmentation is handled frame by frame and requires that certain
* state information be retained from frame to frame. That additional
* information follows the externally visible packet buffer.
@ -439,7 +438,6 @@ struct sixlowpan_reassbuf_s
*/
systime_t rb_time;
#endif /* CONFIG_NET_6LOWPAN_FRAG */
};
/****************************************************************************

View File

@ -5,17 +5,9 @@
if NET_6LOWPAN
config NET_6LOWPAN_FRAG
bool "6LoWPAN Fragmentation"
default y
---help---
CONFIG_NET_6LOWPAN_FRAG specifies if 6lowpan fragmentation should be
used or not. Fragmentation is on by default.
config NET_6LOWPAN_NREASSBUF
int "Number of preallocated reassembly buffers"
default 2
depends on NET_6LOWPAN_FRAG
---help---
Large IPv6 packets will be fragmented by 6LoWPAN into multiple
frames and reconstitued into a reassembly buffer on the receiving
@ -36,7 +28,6 @@ config NET_6LOWPAN_NREASSBUF
config NET_6LOWPAN_REASS_STATIC
bool "Static reassembly buffers"
default n
depends on NET_6LOWPAN_FRAG
---help---
By default, reassembly buffers may be allocated dynamically from the
stack when all of the statically allocation reassembly buffers are
@ -201,7 +192,6 @@ config NET_6LOWPAN_MTU
int "6LoWPAN packet buffer size"
default 1294
range 590 1518
depends on NET_6LOWPAN_FRAG
---help---
Packet buffer size. This size includes the TCP/UDP payload plus the
size of TCP/UDP header, the IP header, and the Ethernet header.
@ -215,8 +205,7 @@ config NET_6LOWPAN_MTU
config NET_6LOWPAN_TCP_RECVWNDO
int "6LoWPAN TCP receive window size"
default 1220 if NET_6LOWPAN_FRAG
default 102 if !NET_6LOWPAN_FRAG
default 1220
depends on NET_TCP
---help---
The size of the advertised receiver's window. Should be set low

View File

@ -41,6 +41,7 @@ ifeq ($(CONFIG_NET_6LOWPAN),y)
NET_CSRCS += sixlowpan_initialize.c sixlowpan_globals.c sixlowpan_utils.c
NET_CSRCS += sixlowpan_input.c sixlowpan_framer.c sixlowpan_framelist.c
NET_CSRCS += sixlowpan_reassbuf.c
ifeq ($(CONFIG_NET_TCP),y)
NET_CSRCS += sixlowpan_tcpsend.c
@ -68,10 +69,6 @@ ifeq ($(CONFIG_NET_6LOWPAN_COMPRESSION_HC06),y)
NET_CSRCS += sixlowpan_hc06.c
endif
ifeq ($(CONFIG_NET_6LOWPAN_FRAG),y)
NET_CSRCS += sixlowpan_reassbuf.c
endif
# Include the sixlowpan directory in the build
DEPPATH += --dep-path sixlowpan

View File

@ -385,11 +385,9 @@ int sixlowpan_queue_frames(FAR struct radio_driver_s *radio,
FAR uint8_t *fptr;
int framer_hdrlen;
struct netdev_varaddr_s bcastmac;
#ifdef CONFIG_NET_6LOWPAN_FRAG
uint16_t pktlen;
uint16_t paysize;
uint16_t outlen = 0;
#endif
uint8_t protosize;
int ret;
@ -501,7 +499,6 @@ int sixlowpan_queue_frames(FAR struct radio_driver_s *radio,
if (buflen > (SIXLOWPAN_FRAMELEN - g_frame_hdrlen - protosize))
{
#ifdef CONFIG_NET_6LOWPAN_FRAG
/* qhead will hold the generated frame list; frames will be
* added at qtail.
*/
@ -705,13 +702,6 @@ int sixlowpan_queue_frames(FAR struct radio_driver_s *radio,
/* Update the datagram TAG value */
reass->rb_dgramtag++;
#else
nerr("ERROR: Packet too large: %d\n", buflen);
nerr(" Cannot to be sent without fragmentation support\n");
nerr(" dropping packet\n");
return -E2BIG;
#endif
}
else
{

View File

@ -69,11 +69,9 @@
void sixlowpan_initialize(void)
{
#ifdef CONFIG_NET_6LOWPAN_FRAG
/* Initialize the reassembly buffer allocator */
sixlowpan_reass_initialize();
#endif
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC06
/* Initialize HC06 data data structures */

View File

@ -115,11 +115,9 @@
* Private Data
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN_FRAG
/* This big buffer could be avoided with a little more effort */
static uint8_t g_bitbucket[UNCOMP_MAXHDR];
#endif
/****************************************************************************
* Private Functions
@ -252,25 +250,22 @@ static void sixlowpan_uncompress_ipv6hdr(FAR uint8_t *fptr, FAR uint8_t *bptr)
static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
FAR const void *metadata, FAR struct iob_s *iob)
{
FAR struct sixlowpan_reassbuf_s *reass;
struct netdev_varaddr_s fragsrc;
FAR uint8_t *fptr; /* Convenience pointer to beginning of the frame */
FAR uint8_t *bptr; /* Used to redirect uncompressed header to the bitbucket */
FAR uint8_t *hc1; /* Convenience pointer to HC1 data */
FAR uint8_t *fragptr; /* Pointer to the fragmentation header */
uint16_t fragsize = 0; /* Size of the IP packet (read from fragment) */
uint16_t paysize; /* Size of the data payload */
uint16_t fragtag = 0; /* Tag of the fragment */
uint8_t fragoffset = 0; /* Offset of the fragment in the IP packet */
bool isfrag = false; /* true: Frame is a fragment */
bool isfirstfrag = false; /* true: Frame is the first fragement of the series */
int reqsize; /* Required buffer size */
int hdrsize; /* Size of the IEEE802.15.4 header */
int ret;
#ifdef CONFIG_NET_6LOWPAN_FRAG
FAR struct sixlowpan_reassbuf_s *reass;
struct netdev_varaddr_s fragsrc;
FAR uint8_t *fragptr; /* Pointer to the fragmentation header */
bool isfrag = false;
bool isfirstfrag = false;
uint16_t fragtag = 0; /* Tag of the fragment */
#endif /* CONFIG_NET_6LOWPAN_FRAG */
/* Get a pointer to the payload following the IEEE802.15.4 frame header(s).
* This size includes both fragmentation and FCF headers.
*/
@ -287,7 +282,6 @@ static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
g_uncomp_hdrlen = 0;
g_frame_hdrlen = hdrsize;
#ifdef CONFIG_NET_6LOWPAN_FRAG
/* Since we don't support the mesh and broadcast header, the first header
* we look for is the fragmentation header. NOTE that g_frame_hdrlen
* already includes the fragementation header, if presetn.
@ -420,9 +414,6 @@ static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
bptr = reass->rb_buf;
break;
}
#else
bptr = radio->r_dev.d_buf;
#endif /* CONFIG_NET_6LOWPAN_FRAG */
/* Process next dispatch and headers */
@ -460,7 +451,6 @@ static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
goto errout_with_reass;
}
#ifdef CONFIG_NET_6LOWPAN_FRAG
/* Is this the first fragment is a sequence? */
if (isfirstfrag)
@ -482,7 +472,6 @@ static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
g_uncomp_hdrlen = reass->rb_boffset;
}
#endif /* CONFIG_NET_6LOWPAN_FRAG */
/* Copy "payload" from the frame buffer to the IEEE802.15.4 MAC driver's
* packet buffer, d_buf. If this frame is a first fragment or not part of
@ -514,7 +503,6 @@ static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
memcpy(radio->r_dev.d_buf + g_uncomp_hdrlen + (fragoffset << 3),
fptr + g_frame_hdrlen, paysize);
#ifdef CONFIG_NET_6LOWPAN_FRAG
/* Update reass->rb_accumlen if the frame is a fragment, reass->rb_pktlen
* otherwise.
*/
@ -560,17 +548,6 @@ static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
errout_with_reass:
sixlowpan_reass_free(reass);
return ret;
#else
/* Deliver the packet to the IP stack */
radio->r_dev.d_len = paysize + g_uncomp_hdrlen;
return INPUT_COMPLETE;
errout_with_reass:
return ret;
#endif /* CONFIG_NET_6LOWPAN_FRAG */
}
/****************************************************************************
@ -589,9 +566,7 @@ errout_with_reass:
static int sixlowpan_dispatch(FAR struct radio_driver_s *radio)
{
#ifdef CONFIG_NET_6LOWPAN_FRAG
FAR struct sixlowpan_reassbuf_s *reass;
#endif
int ret;
sixlowpan_dumpbuffer("Incoming packet",
@ -617,13 +592,11 @@ static int sixlowpan_dispatch(FAR struct radio_driver_s *radio)
ret = ipv6_input(&radio->r_dev);
#ifdef CONFIG_NET_6LOWPAN_FRAG
/* Free the reassemby buffer */
reass = (FAR struct sixlowpan_reassbuf_s *)radio->r_dev.d_buf;
DEBUGASSERT(reass != NULL);
sixlowpan_reass_free(reass);
#endif
return ret;
}

View File

@ -704,9 +704,7 @@ int sixlowpan_extract_destaddr(FAR struct radio_driver_s *radio,
*
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN_FRAG
void sixlowpan_reass_initialize(void);
#endif /* CONFIG_NET_6LOWPAN_FRAG */
/****************************************************************************
* Name: sixlowpan_reass_allocate
@ -733,11 +731,9 @@ void sixlowpan_reass_initialize(void);
*
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN_FRAG
FAR struct sixlowpan_reassbuf_s *
sixlowpan_reass_allocate(uint16_t reasstag,
FAR const struct netdev_varaddr_s *fragsrc);
#endif /* CONFIG_NET_6LOWPAN_FRAG */
/****************************************************************************
* Name: sixlowpan_reass_find
@ -758,11 +754,9 @@ FAR struct sixlowpan_reassbuf_s *
*
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN_FRAG
FAR struct sixlowpan_reassbuf_s *
sixlowpan_reass_find(uint16_t reasstag,
FAR const struct netdev_varaddr_s *fragsrc);
#endif /* CONFIG_NET_6LOWPAN_FRAG */
/****************************************************************************
* Name: sixlowpan_reass_free
@ -784,9 +778,7 @@ FAR struct sixlowpan_reassbuf_s *
*
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN_FRAG
void sixlowpan_reass_free(FAR struct sixlowpan_reassbuf_s *reass);
#endif /* CONFIG_NET_6LOWPAN_FRAG */
#endif /* CONFIG_NET_6LOWPAN */
#endif /* _NET_SIXLOWPAN_SIXLOWPAN_INTERNAL_H */

View File

@ -52,8 +52,6 @@
#include "sixlowpan_internal.h"
#ifdef CONFIG_NET_6LOWPAN_FRAG
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -454,5 +452,3 @@ void sixlowpan_reass_free(FAR struct sixlowpan_reassbuf_s *reass)
#endif
}
}
#endif /* CONFIG_NET_6LOWPAN_FRAG */