From 38eed0a847ddf9c85ebc6e4b8163de338fc76871 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 4 Apr 2017 17:06:17 -0600 Subject: [PATCH] 6loWPAN: Various fixes for building with different configurations; Some minimal testing of HC06 --- include/nuttx/net/sixlowpan.h | 12 ++++++------ net/sixlowpan/sixlowpan_framelist.c | 5 ++++- net/sixlowpan/sixlowpan_hc06.c | 8 ++++---- net/sixlowpan/sixlowpan_input.c | 14 +++++++------- net/sixlowpan/sixlowpan_internal.h | 2 +- 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/include/nuttx/net/sixlowpan.h b/include/nuttx/net/sixlowpan.h index 43a1a9660e..5f73d9cdb1 100644 --- a/include/nuttx/net/sixlowpan.h +++ b/include/nuttx/net/sixlowpan.h @@ -364,6 +364,12 @@ struct ieee802154_driver_s uint8_t i_dsn; +#if CONFIG_NET_6LOWPAN_FRAG + /* Fragmentation Support *************************************************/ + /* Fragmentation is handled frame by frame and requires that certain + * state information be retained from frame to frame. + */ + /* i_dgramtag. Datagram tag to be put in the header of the set of * fragments. It is used by the recipient to match fragments of the * same payload. @@ -371,12 +377,6 @@ struct ieee802154_driver_s uint16_t i_dgramtag; -#if CONFIG_NET_6LOWPAN_FRAG - /* Fragmentation Support *************************************************/ - /* Fragementation is handled frame by frame and requires that certain - * state information be retained from frame to frame. - */ - /* i_pktlen. The total length of the IPv6 packet to be re-assembled in * d_buf. */ diff --git a/net/sixlowpan/sixlowpan_framelist.c b/net/sixlowpan/sixlowpan_framelist.c index 58f4ba624e..11a98274ad 100644 --- a/net/sixlowpan/sixlowpan_framelist.c +++ b/net/sixlowpan/sixlowpan_framelist.c @@ -51,6 +51,7 @@ #include #include +#include #include #include @@ -171,7 +172,9 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, FAR uint8_t *fptr; int framer_hdrlen; struct rimeaddr_s bcastmac; +#ifdef CONFIG_NET_6LOWPAN_FRAG uint16_t outlen = 0; +#endif /* Initialize global data. Locking the network guarantees that we have * exclusive use of the global values for intermediate calculations. @@ -278,7 +281,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, (int)CONFIG_NET_6LOWPAN_MAXPAYLOAD - framer_hdrlen - (int)g_frame_hdrlen) { -#if CONFIG_NET_6LOWPAN_FRAG +#ifdef CONFIG_NET_6LOWPAN_FRAG /* ieee->i_framelist will hold the generated frames; frames will be * added at qtail. */ diff --git a/net/sixlowpan/sixlowpan_hc06.c b/net/sixlowpan/sixlowpan_hc06.c index f5d8396e91..98df1c1bd3 100644 --- a/net/sixlowpan/sixlowpan_hc06.c +++ b/net/sixlowpan/sixlowpan_hc06.c @@ -18,7 +18,7 @@ * Joel Hoglund * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * modification, are permitted provided that the following c/onditions * are met: * * 1. Redistributions of source code must retain the above copyright @@ -74,9 +74,9 @@ ****************************************************************************/ #define IPv6BUF(ieee) \ - ((FAR struct ipv6_hdr_s *)&(ieee)->i_dev.d_buf) + ((FAR struct ipv6_hdr_s *)((ieee)->i_dev.d_buf)) #define UDPIPv6BUF(ieee) \ - ((FAR struct udp_hdr_s *)&(ieee)->i_dev.d_buf[IPv6_HDRLEN]) + ((FAR struct udp_hdr_s *)&((ieee)->i_dev.d_buf[IPv6_HDRLEN])) /**************************************************************************** * Private Types @@ -841,7 +841,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee, void sixlowpan_uncompresshdr_hc06(FAR struct ieee802154_driver_s *ieee, uint16_t iplen, FAR struct iob_s *iob, - FAR char *payptr) + FAR uint8_t *payptr) { FAR struct ipv6_hdr_s *ipv6 = IPv6BUF(ieee); FAR uint8_t *iphc = payptr + g_frame_hdrlen; diff --git a/net/sixlowpan/sixlowpan_input.c b/net/sixlowpan/sixlowpan_input.c index 2018cc1376..c279920e41 100644 --- a/net/sixlowpan/sixlowpan_input.c +++ b/net/sixlowpan/sixlowpan_input.c @@ -54,7 +54,7 @@ #include #include -#if CONFIG_NET_6LOWPAN_FRAG +#ifdef CONFIG_NET_6LOWPAN_FRAG # include "nuttx/clock.h" #endif @@ -214,11 +214,11 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee, uint16_t fragsize = 0; /* Size of the IP packet (read from fragment) */ uint8_t fragoffset = 0; /* Offset of the fragment in the IP packet */ - bool isfrag = false; int reqsize; /* Required buffer size */ int hdrsize; /* Size of the IEEE802.15.4 header */ -#if CONFIG_NET_6LOWPAN_FRAG +#ifdef CONFIG_NET_6LOWPAN_FRAG + bool isfrag = false; bool isfirstfrag = false; bool islastfrag = false; uint16_t fragtag = 0; /* Tag of the fragment */ @@ -243,7 +243,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee, payptr = &iob->io_data[hdrsize]; -#if CONFIG_NET_6LOWPAN_FRAG +#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 */ @@ -285,7 +285,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee, g_frame_hdrlen += SIXLOWPAN_FRAGN_HDR_LEN; - ninfo("islastfrag?: i_accumlen %d g_rime_payloadlen %d fragsize %d\n", + ninfo("FRAGN: i_accumlen %d g_rime_payloadlen %d fragsize %d\n", ieee->i_accumlen, iob->io_len - g_frame_hdrlen, fragsize); /* Indicate that this frame is a another fragment for reassembly */ @@ -480,7 +480,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee, return OK; } -#if CONFIG_NET_6LOWPAN_FRAG +#ifdef CONFIG_NET_6LOWPAN_FRAG copypayload: #endif /* CONFIG_NET_6LOWPAN_FRAG */ @@ -514,7 +514,7 @@ copypayload: (int)(fragoffset << 3), payptr + g_frame_hdrlen, g_rime_payloadlen); -#if CONFIG_NET_6LOWPAN_FRAG +#ifdef CONFIG_NET_6LOWPAN_FRAG /* Update ieee->i_accumlen if the frame is a fragment, ieee->i_pktlen * otherwise. */ diff --git a/net/sixlowpan/sixlowpan_internal.h b/net/sixlowpan/sixlowpan_internal.h index 1a4f28056e..4a221f4fa9 100644 --- a/net/sixlowpan/sixlowpan_internal.h +++ b/net/sixlowpan/sixlowpan_internal.h @@ -454,7 +454,7 @@ extern uint8_t g_frame_hdrlen; /* Offset first available byte for the payload after header region. */ -uint8_t g_dataoffset; +extern uint8_t g_dataoffset; /* Packet buffer metadata: Attributes and addresses */