diff --git a/Documentation/README.html b/Documentation/README.html
index 01a27ce644..8cc093715d 100644
--- a/Documentation/README.html
+++ b/Documentation/README.html
@@ -8,7 +8,7 @@
NuttX README Files
- Last Updated: March 23, 2017
+ Last Updated: April 8, 2017
|
@@ -362,6 +362,8 @@ nuttx/
| | `- README.txt
| `- README.txt
|- net/
+ | |- sixlowpan/
+ | | `- README.txt
| `- README.txt
|- syscall/
| `- README.txt
diff --git a/README.txt b/README.txt
index 5d3721f4c5..af17a2334d 100644
--- a/README.txt
+++ b/README.txt
@@ -1750,6 +1750,8 @@ nuttx/
| | `- README.txt
| `- README.txt
|- net/
+ | |- sixlowpan
+ | | `- README.txt
| `- README.txt
|- syscall/
| `- README.txt
diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c
index fa8468196e..5b3f1c0e9f 100644
--- a/arch/sim/src/up_initialize.c
+++ b/arch/sim/src/up_initialize.c
@@ -187,7 +187,7 @@ void up_initialize(void)
* separately.
*/
- syslog(LOG_INFO, "SIM: Initializing");
+ syslog(LOG_INFO, "SIM: Initializing\n");
#endif
#ifdef CONFIG_PM
diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h
index 9bbd0e9929..99f00e3856 100644
--- a/include/nuttx/net/netconfig.h
+++ b/include/nuttx/net/netconfig.h
@@ -295,16 +295,13 @@
#endif
/* The UDP maximum packet size. This is should not be to set to more
- * than NET_DEV_MTU(d) - NET_LL_HDRLEN(dev) - IPv*_HDRLEN.
- *
- * REVISIT: It is unclear to me if the UDP_HDRLEN should subtracted
- * or not.
+ * than NET_DEV_MTU(d) - NET_LL_HDRLEN(dev) - UDP_HDRLEN - IPv*_HDRLEN.
*/
-#define UDP_MSS(d,h) (NET_DEV_MTU(d) - NET_LL_HDRLEN(d) (h))
+#define UDP_MSS(d,h) (NET_DEV_MTU(d) - NET_LL_HDRLEN(d) - UDP_HDRLEN (h))
#ifdef CONFIG_NET_ETHERNET
-# define ETH_UDP_MSS(h) (CONFIG_NET_ETH_MTU - ETH_HDRLEN - (h))
+# define ETH_UDP_MSS(h) (CONFIG_NET_ETH_MTU - ETH_HDRLEN - UDP_HDRLEN - (h))
# ifndef CONFIG_NET_MULTILINK
# define __MIN_UDP_MSS(h) ETH_UDP_MSS(h)
# define __MAX_UDP_MSS(h) ETH_UDP_MSS(h)
@@ -312,7 +309,7 @@
#endif
#ifdef CONFIG_NET_6LOWPAN
-# define IEEE802154_UDP_MSS(h) (CONFIG_NET_6LOWPAN_MAXPAYLOAD - (h))
+# define IEEE802154_UDP_MSS(h) (CONFIG_NET_6LOWPAN_MAXPAYLOAD - UDP_HDRLEN - (h))
# ifndef CONFIG_NET_MULTILINK
# define __MIN_UDP_MSS(h) IEEE802154_UDP_MSS(h)
# define __MAX_UDP_MSS(h) IEEE802154_UDP_MSS(h)
@@ -320,7 +317,7 @@
#endif
#ifdef CONFIG_NET_LOOPBACK
-# define LO_UDP_MSS(h) (NET_LO_MTU - (h))
+# define LO_UDP_MSS(h) (NET_LO_MTU - UDP_HDRLEN - (h))
# ifndef CONFIG_NET_MULTILINK
# define __MIN_UDP_MSS(h) LO_UDP_MSS(h)
# define __MAX_UDP_MSS(h) LO_UDP_MSS(h)
@@ -328,7 +325,7 @@
#endif
#ifdef CONFIG_NET_SLIP
-# define SLIP_UDP_MSS(h) (CONFIG_NET_SLIP_MTU - (h))
+# define SLIP_UDP_MSS(h) (CONFIG_NET_SLIP_MTU - UDP_HDRLEN - (h))
# ifndef CONFIG_NET_MULTILINK
# define __MIN_UDP_MSS(h) SLIP_UDP_MSS(h)
# define __MAX_UDP_MSS(h) SLIP_UDP_MSS(h)
@@ -383,27 +380,25 @@
# endif
#endif
-/* NOTE: MSS calcuation excludes the UDP_HDRLEN. */
-
#ifdef CONFIG_NET_IPv4
-# define UDP_IPv4_MSS(d) UDP_MSS(d,IPv4_HDRLEN)
-# define ETH_IPv4_UDP_MSS ETH_UDP_MSS(IPv4_HDRLEN)
-# define SLIP_IPv4_UDP_MSS SLIP_UDP_MSS(IPv4_HDRLEN)
+# define UDP_IPv4_MSS(d) UDP_MSS(d,IPv4_HDRLEN)
+# define ETH_IPv4_UDP_MSS ETH_UDP_MSS(IPv4_HDRLEN)
+# define SLIP_IPv4_UDP_MSS SLIP_UDP_MSS(IPv4_HDRLEN)
-# define MIN_IPv4_UDP_MSS __MIN_UDP_MSS(IPv4_HDRLEN)
-# define MIN_UDP_MSS __MIN_UDP_MSS(IPv4_HDRLEN)
+# define MIN_IPv4_UDP_MSS __MIN_UDP_MSS(IPv4_HDRLEN)
+# define MIN_UDP_MSS __MIN_UDP_MSS(IPv4_HDRLEN)
# undef MAX_UDP_MSS
-# define MAX_IPv4_UDP_MSS __MAX_UDP_MSS(IPv4_HDRLEN)
-# define MAX_UDP_MSS __MAX_UDP_MSS(IPv4_HDRLEN)
+# define MAX_IPv4_UDP_MSS __MAX_UDP_MSS(IPv4_HDRLEN)
+# define MAX_UDP_MSS __MAX_UDP_MSS(IPv4_HDRLEN)
#endif
/* If IPv6 is support, it will have the smaller MSS */
#ifdef CONFIG_NET_IPv6
# undef MIN_UDP_MSS
-# define MIN_IPv6_UDP_MSS __MIN_UDP_MSS(IPv6_HDRLEN)
-# define MIN_UDP_MSS __MIN_UDP_MSS(IPv6_HDRLEN)
+# define MIN_IPv6_UDP_MSS __MIN_UDP_MSS(IPv6_HDRLEN)
+# define MIN_UDP_MSS __MIN_UDP_MSS(IPv6_HDRLEN)
#endif
/* TCP configuration options */
@@ -473,17 +468,15 @@
* may support a different UDP MSS value. Here we arbitrarily select
* the minimum MSS for that case.
*
- * REVISIT: It is unclear to me if the TCP_HDRLEN should subtracted
- * or not.
+ * REVISIT: TCP_HDRLEN is not really a constant!
*/
-#define TCP_MSS(d,h) (NET_DEV_MTU(d) - NET_LL_HDRLEN(d) - (h))
-#define LO_TCP_MSS(h) (NET_LO_MTU - (h))
+#define TCP_MSS(d,h) (NET_DEV_MTU(d) - NET_LL_HDRLEN(d) - TCP_HDRLEN - (h))
/* Get the smallest and largest MSS */
#ifdef CONFIG_NET_ETHERNET
-# define ETH_TCP_MSS(h) (CONFIG_NET_ETH_MTU - ETH_HDRLEN - (h))
+# define ETH_TCP_MSS(h) (CONFIG_NET_ETH_MTU - ETH_HDRLEN - TCP_HDRLEN - (h))
# ifndef CONFIG_NET_MULTILINK
# define __MIN_TCP_MSS(h) ETH_TCP_MSS(h)
# define __MAX_TCP_MSS(h) ETH_TCP_MSS(h)
@@ -491,7 +484,7 @@
#endif
#ifdef CONFIG_NET_6LOWPAN
-# define IEEE802154_TCP_MSS(h) CONFIG_NET_6LOWPAN_MAXPAYLOAD
+# define IEEE802154_TCP_MSS(h) (CONFIG_NET_6LOWPAN_MAXPAYLOAD - TCP_HDRLEN - (h))
# ifndef CONFIG_NET_MULTILINK
# define __MIN_TCP_MSS(h) IEEE802154_TCP_MSS(h)
# define __MAX_TCP_MSS(h) IEEE802154_TCP_MSS(h)
@@ -499,7 +492,7 @@
#endif
#ifdef CONFIG_NET_LOOPBACK
-# define LO_TCP_MSS(h) (NET_LO_MTU - (h))
+# define LO_TCP_MSS(h) (NET_LO_MTU - TCP_HDRLEN - (h))
# ifndef CONFIG_NET_MULTILINK
# define __MIN_TCP_MSS(h) LO_TCP_MSS(h)
# define __MAX_TCP_MSS(h) LO_TCP_MSS(h)
@@ -507,7 +500,7 @@
#endif
#ifdef CONFIG_NET_SLIP
-# define SLIP_TCP_MSS(h) (CONFIG_NET_SLIP_MTU - (h))
+# define SLIP_TCP_MSS(h) (CONFIG_NET_SLIP_MTU - TCP_HDRLEN - (h))
# ifndef CONFIG_NET_MULTILINK
# define __MIN_TCP_MSS(h) SLIP_TCP_MSS(h)
# define __MAX_TCP_MSS(h) SLIP_TCP_MSS(h)
@@ -568,26 +561,26 @@
*/
#ifdef CONFIG_NET_IPv6
-# define TCP_IPv6_MSS(d) TCP_MSS(d,IPv6_HDRLEN)
-# define ETH_IPv6_TCP_MSS ETH_TCP_MSS(IPv6_HDRLEN)
-# define SLIP_IPv6_TCP_MSS SLIP_TCP_MSS(IPv6_HDRLEN)
-# define MAX_TCP_MSS __MAX_TCP_MSS(IPv6_HDRLEN)
+# define TCP_IPv6_MSS(d) TCP_MSS(d,IPv6_HDRLEN)
+# define ETH_IPv6_TCP_MSS ETH_TCP_MSS(IPv6_HDRLEN)
+# define SLIP_IPv6_TCP_MSS SLIP_TCP_MSS(IPv6_HDRLEN)
+# define MAX_TCP_MSS __MAX_TCP_MSS(IPv6_HDRLEN)
#endif
#ifdef CONFIG_NET_IPv4
-# define TCP_IPv4_MSS(d) TCP_MSS(d,IPv4_HDRLEN)
-# define ETH_IPv4_TCP_MSS ETH_TCP_MSS(IPv4_HDRLEN)
-# define SLIP_IPv4_TCP_MSS SLIP_TCP_MSS(IPv4_HDRLEN)
-# define MIN_TCP_MSS __MIN_TCP_MSS(IPv4_HDRLEN)
+# define TCP_IPv4_MSS(d) TCP_MSS(d,IPv4_HDRLEN)
+# define ETH_IPv4_TCP_MSS ETH_TCP_MSS(IPv4_HDRLEN)
+# define SLIP_IPv4_TCP_MSS SLIP_TCP_MSS(IPv4_HDRLEN)
+# define MIN_TCP_MSS __MIN_TCP_MSS(IPv4_HDRLEN)
# undef MAX_TCP_MSS
-# define MAX_TCP_MSS __MAX_TCP_MSS(IPv4_HDRLEN)
+# define MAX_TCP_MSS __MAX_TCP_MSS(IPv4_HDRLEN)
#endif
/* If IPv6 is supported, it will have the smaller MSS */
#ifdef CONFIG_NET_IPv6
# undef MIN_TCP_MSS
-# define MIN_TCP_MSS __MIN_TCP_MSS(IPv6_HDRLEN)
+# define MIN_TCP_MSS __MIN_TCP_MSS(IPv6_HDRLEN)
#endif
/* The size of the advertised receiver's window.
@@ -614,22 +607,28 @@
#endif
#if defined(CONFIG_NET_MULTILINK)
- /* We are supporting multiple network devices using different link layer
- * protocols. Get the size of the receive window from the device structure.
- */
+ /* We are supporting multiple network devices using different link layer
+ * protocols. Get the size of the receive window from the device
+ * structure.
+ */
# define NET_DEV_RCVWNDO(d) ((d)->d_recvwndo)
-#elif defined(CONFIG_NET_SLIP)
- /* Only SLIP.. use the configured SLIP receive window size */
-
-# define NET_DEV_RCVWNDO(d) CONFIG_NET_SLIP_TCP_RECVWNDO
-
#elif defined(CONFIG_NET_ETHERNET)
/* Only Ethernet.. use the configured SLIP receive window size */
# define NET_DEV_RCVWNDO(d) CONFIG_NET_ETH_TCP_RECVWNDO
+#elif defined(CONFIG_NET_6LOWPAN)
+ /* Only 6loWPAN.. use the configured 6loWPAN receive window size */
+
+# define NET_DEV_RCVWNDO(d) CONFIG_NET_6LOWPAN_TCP_RECVWNDO
+
+#elif defined(CONFIG_NET_SLIP)
+ /* Only SLIP.. use the configured SLIP receive window size */
+
+# define NET_DEV_RCVWNDO(d) CONFIG_NET_SLIP_TCP_RECVWNDO
+
#else /* if defined(CONFIG_NET_LOOPBACK) */
/* Only loal loopback.. use the fixed loopback receive window size */
diff --git a/include/nuttx/net/sixlowpan.h b/include/nuttx/net/sixlowpan.h
index 04b69da604..a98cfa457c 100644
--- a/include/nuttx/net/sixlowpan.h
+++ b/include/nuttx/net/sixlowpan.h
@@ -63,6 +63,83 @@
* Pre-processor Definitions
****************************************************************************/
+/* Frame format definitions *************************************************/
+/* Fragment header.
+ *
+ * The fragment header is used when the payload is too large to fit in a
+ * single IEEE 802.15.4 frame. The fragment header contains three fields:
+ * Datagram size, datagram tag and datagram offset.
+ *
+ * 1. Datagram size describes the total (un-fragmented) payload.
+ * 2. Datagram tag identifies the set of fragments and is used to match
+ * fragments of the same payload.
+ * 3. Datagram offset identifies the fragment’s offset within the un-
+ * fragmented payload.
+ *
+ * The fragment header length is 4 bytes for the first header and 5
+ * bytes for all subsequent headers.
+ */
+
+#define RIME_FRAG_DISPATCH_SIZE 0 /* 16 bit */
+#define RIME_FRAG_TAG 2 /* 16 bit */
+#define RIME_FRAG_OFFSET 4 /* 8 bit */
+
+/* Define the Rime buffer as a byte array */
+
+#define RIME_HC1_DISPATCH 0 /* 8 bit */
+#define RIME_HC1_ENCODING 1 /* 8 bit */
+#define RIME_HC1_TTL 2 /* 8 bit */
+
+#define RIME_HC1_HC_UDP_DISPATCH 0 /* 8 bit */
+#define RIME_HC1_HC_UDP_HC1_ENCODING 1 /* 8 bit */
+#define RIME_HC1_HC_UDP_UDP_ENCODING 2 /* 8 bit */
+#define RIME_HC1_HC_UDP_TTL 3 /* 8 bit */
+#define RIME_HC1_HC_UDP_PORTS 4 /* 8 bit */
+#define RIME_HC1_HC_UDP_CHKSUM 5 /* 16 bit */
+
+/* These are some definitions of element values used in the FCF. See the
+ * IEEE802.15.4 spec for details.
+ */
+
+#define FRAME802154_FRAMETYPE_SHIFT (0) /* Bits 0-2: Frame type */
+#define FRAME802154_FRAMETYPE_MASK (7 << FRAME802154_FRAMETYPE_SHIFT)
+#define FRAME802154_SECENABLED_SHIFT (3) /* Bit 3: Security enabled */
+#define FRAME802154_FRAMEPENDING_SHIFT (4) /* Bit 4: Frame pending */
+#define FRAME802154_ACKREQUEST_SHIFT (5) /* Bit 5: ACK request */
+#define FRAME802154_PANIDCOMP_SHIFT (6) /* Bit 6: PANID compression */
+ /* Bits 7-9: Reserved */
+#define FRAME802154_DSTADDR_SHIFT (2) /* Bits 10-11: Dest address mode */
+#define FRAME802154_DSTADDR_MASK (3 << FRAME802154_DSTADDR_SHIFT)
+#define FRAME802154_VERSION_SHIFT (4) /* Bit 12-13: Frame version */
+#define FRAME802154_VERSION_MASK (3 << FRAME802154_VERSION_SHIFT)
+#define FRAME802154_SRCADDR_SHIFT (6) /* Bits 14-15: Source address mode */
+#define FRAME802154_SRCADDR_MASK (3 << FRAME802154_SRCADDR_SHIFT)
+
+/* Unshifted values for use in struct frame802154_fcf_s */
+
+#define FRAME802154_BEACONFRAME (0)
+#define FRAME802154_DATAFRAME (1)
+#define FRAME802154_ACKFRAME (2)
+#define FRAME802154_CMDFRAME (3)
+
+#define FRAME802154_BEACONREQ (7)
+
+#define FRAME802154_IEEERESERVED (0)
+#define FRAME802154_NOADDR (0) /* Only valid for ACK or Beacon frames */
+#define FRAME802154_SHORTADDRMODE (2)
+#define FRAME802154_LONGADDRMODE (3)
+
+#define FRAME802154_NOBEACONS 0x0f
+
+#define FRAME802154_BROADCASTADDR 0xffff
+#define FRAME802154_BROADCASTPANDID 0xffff
+
+#define FRAME802154_IEEE802154_2003 (0)
+#define FRAME802154_IEEE802154_2006 (1)
+
+#define FRAME802154_SECURITY_LEVEL_NONE (0)
+#define FRAME802154_SECURITY_LEVEL_128 (3)
+
/* Min and Max compressible UDP ports - HC06 */
#define SIXLOWPAN_UDP_4_BIT_PORT_MIN 0xf0b0
@@ -171,9 +248,71 @@
#define SIXLOWPAN_MAC_STDFRAME 127
-/* Frame buffer helper macros.
+/* Address compressibility test macros **************************************/
+
+/* Check whether we can compress the IID in address 'a' to 16 bits. This is
+ * used for unicast addresses only, and is true if the address is on the
+ * format ::0000:00ff:fe00:XXXX
*
- * The IEEE802.15.4 MAC driver structures includes a list of IOB
+ * NOTE: we currently assume 64-bits prefixes
+ */
+
+/* Check whether we can compress the IID in address 'a' to 16 bits. This is
+ * used for unicast addresses only, and is true if the address is on the
+ * format ::0000:00ff:fe00:XXXX.
+ *
+ * NOTE: we currently assume 64-bits prefixes. Big-endian, network order is
+ * assumed.
+ */
+
+#define SIXLOWPAN_IS_IID_16BIT_COMPRESSABLE(a) \
+ ((((a)[4]) == 0x0000) && (((a)[5]) == HTONS(0x00ff)) && \
+ (((a)[6]) == 0xfe00))
+
+/* Check whether the 9-bit group-id of the compressed multicast address is
+ * known. It is true if the 9-bit group is the all nodes or all routers
+ * group. Parameter 'a' is typed uint8_t *
+ */
+
+#define SIXLOWPAN_IS_MCASTADDR_DECOMPRESSABLE(a) \
+ (((*a & 0x01) == 0) && \
+ ((*(a + 1) == 0x01) || (*(a + 1) == 0x02)))
+
+/* Check whether the 112-bit group-id of the multicast address is mappable
+ * to a 9-bit group-id. It is true if the group is the all nodes or all
+ * routers group:
+ *
+ * XXXX:0000:0000:0000:0000:0000:0000:0001 All nodes address
+ * XXXX:0000:0000:0000:0000:0000:0000:0002 All routers address
+ */
+
+#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE(a) \
+ ((a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
+ (a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && \
+ ((a)[7] == HTONS(0x0001) || (a)[7] == HTONS(0x0002)))
+
+/* FFXX:0000:0000:0000:0000:00XX:XXXX:XXXX */
+
+#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE48(a) \
+ ((a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
+ (a)[4] == 0 && (((a)[5] & HTONS(0xff00)) == 0))
+
+/* FFXX:0000:0000:0000:0000:0000:00XX:XXXX */
+
+#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE32(a) \
+ ((a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
+ (a)[4] == 0 && (a)[5] == 0 && ((a)[6] & HTONS(0xff00)) == 0)
+
+/* FF02:0000:0000:0000:0000:0000:0000:00XX */
+
+#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE8(a) \
+ ((((a)[0] & HTONS(0x00ff)) == HTONS(0x0002)) && \
+ (a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
+ (a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && \
+ (((a)[7] & HTONS(0xff00)) == 0x0000))
+
+/* Frame buffer helper macros ***********************************************/
+/* The IEEE802.15.4 MAC driver structures includes a list of IOB
* structures, i_framelist, containing frames to be sent by the driver or
* that were received by the driver. The IOB structure is defined in
* include/nuttx/net/iob.h. The length of data in the IOB is provided by
@@ -376,28 +515,38 @@ struct ieee802154_driver_s
/* 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.
+ *
+ * This is the sender's copy of the tag. It is incremented after each
+ * fragmented packet is sent so that it will be unique to that
+ * sequence fragmentation. Its value is then persistent, the values of
+ * other fragmentatin variables are valid on during a single
+ * fragmentation sequence (while i_accumlen > 0)
*/
uint16_t i_dgramtag;
+ /* i_reasstag. Each frame in the reassembly has a tag. That tag must
+ * match the reassembly tag in the fragments being merged.
+ *
+ * This is the same tag as i_dgramtag but is saved on the receiving
+ * side to match all of the fragments of the packet.
+ */
+
+ uint16_t i_reasstag;
+
/* i_pktlen. The total length of the IPv6 packet to be re-assembled in
- * d_buf.
+ * d_buf. Used to determine when the re-assembly is complete.
*/
uint16_t i_pktlen;
/* The current accumulated length of the packet being received in d_buf.
- * Included IPv6 and protocol headers.
+ * Included IPv6 and protocol headers. Currently used only to determine
+ * there is a fragmentation sequence in progress.
*/
uint16_t i_accumlen;
- /* i_reasstag. Each frame in the reassembly has a tag. That tag must
- * match the reassembly tag in the fragments being merged.
- */
-
- uint16_t i_reasstag;
-
/* i_boffset. Offset to the beginning of data in d_buf. As each fragment
* is received, data is placed at an appriate offset added to this.
*/
diff --git a/include/pthread.h b/include/pthread.h
index a75cd9e901..225a7ef8b0 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -354,10 +354,6 @@ typedef int pthread_rwlockattr_t;
PTHREAD_COND_INITIALIZER, \
0, 0}
-#define PTHREAD_MUTEX_INITIALIZER {NULL, SEM_INITIALIZER(1), -1, \
- __PTHREAD_MUTEX_DEFAULT_FLAGS, \
- PTHREAD_MUTEX_DEFAULT, 0}
-
#ifdef CONFIG_PTHREAD_CLEANUP
/* This type describes the pthread cleanup callback (non-standard) */
diff --git a/net/sixlowpan/README.txt b/net/sixlowpan/README.txt
new file mode 100644
index 0000000000..643735dd86
--- /dev/null
+++ b/net/sixlowpan/README.txt
@@ -0,0 +1,73 @@
+Optimal 6loWPAN Configuration
+-----------------------------
+
+1. Link local IP addresses:
+
+ 128 112 96 80 64 48 32 16
+ fe80 0000 0000 0000 xxxx xxxx xxxx xxxx
+
+2. MAC-based IP addresses:
+
+ 128 112 96 80 64 48 32 16
+ ---- ---- ---- ---- ---- ---- ---- ----
+ xxxx xxxx xxxx xxxx xxxx 00ff fe00 MMMM 2-byte Rime address IEEE 48-bit MAC
+ fe80 0000 0000 0000 NNNN NNNN NNNN NNNN 8-byte Rime address IEEE EUI-64
+
+ Where MMM is the 2-byte rime address XOR 0x0200. For example, the MAC
+ address of 0xabcd would be 0xa9cd. And NNNN NNNN NNNN NNNN is the 8-byte
+ rime address address XOR 02000 0000 0000 0000
+
+3. MAC based link-local addresses
+
+ 128 112 96 80 64 48 32 16
+ ---- ---- ---- ---- ---- ---- ---- ----
+ fe80 0000 0000 0000 0000 00ff fe00 MMMM 2-byte Rime address IEEE 48-bit MAC
+ fe80 0000 0000 0000 NNNN NNNN NNNN NNNN 8-byte Rime address IEEE EUI-64
+
+4. Compressable port numbers in the rangs 0xf0b0-0xf0bf
+
+5. IOBs: Must be big enough to hold one IEEE802.15.4 frame (CONFIG_NET_6LOWPAN_FRAMELEN,
+ typically 127). There must be enough IOBs to decompose the largest IPv6
+ packet (CONFIG_NET_6LOWPAN_MTU, default 1294, plus per frame overhead).
+
+Fragmentation Headers
+---------------------
+A fragment header is placed at the beginning of the outgoing packet when the
+payload is too large to fit in a single IEEE 802.15.4 frame. The fragment
+header contains three fields: Datagram size, datagram tag and datagram
+offset.
+
+1. Datagram size describes the total (un-fragmented) payload.
+2. Datagram tag identifies the set of fragments and is used to match
+ fragments of the same payload.
+3. Datagram offset identifies the fragment’s offset within the un-
+ fragmented payload (in units of 8 bytes).
+
+The length of the fragment header length is four bytes for the first header
+(FRAG1) and five bytes for all subsequent headers (FRAGN). For example,
+this is a HC1 compressed first frame of a packet
+
+ c50e 000b ### 4-byte FRAG1 header
+ 01 08 01 0000 3412 ### 7-byte FCF header
+ 42 ### SIXLOWPAN_DISPATCH_HC1
+ fb ### RIME_HC1_HC_UDP_HC1_ENCODING
+ e0 ### RIME_HC1_HC_UDP_UDP_ENCODING
+ 00 ### RIME_HC1_HC_UDP_TTL
+ 10 ### RIME_HC1_HC_UDP_PORTS
+ 0000 ### RIME_HC1_HC_UDP_CHKSUM
+ 4f4e452064617920 48656e6e792d7065 6e6e792077617320 7069636b696e6720 ### 80 byte payload
+ 757020636f726e20 696e207468652063 6f726e7961726420 7768656e2d2d7768
+ 61636b212d2d736f 6d657468696e6720 g
+
+This is the second frame of the same transfer:
+
+ e50e 000b 0a ### 5 byte FRAGN header
+ 01 08 01 0000 3412 ### 7-byte FCF header
+ 6869742068657220 75706f6e20746865 20686561642e2027 476f6f646e657373 ### 88 byte payload
+ 2067726163696f75 73206d6521272073 6169642048656e6e 792d70656e6e793b
+ 202774686520736b 79277320612d676f 696e6720746f2066
+
+The payload length is encoded in the LS 11-bits of the first 16-bit value:
+In this example the payload size is 0x050e or 1,294. The tag is 0x000b. In
+the second frame, the fifth byte contains the offset 0x0a which is 10 << 3 =
+80 bytes, the size of the payload on the first packet.
diff --git a/net/sixlowpan/sixlowpan_framelist.c b/net/sixlowpan/sixlowpan_framelist.c
index 552f394b78..d8b751e8a7 100644
--- a/net/sixlowpan/sixlowpan_framelist.c
+++ b/net/sixlowpan/sixlowpan_framelist.c
@@ -112,6 +112,8 @@
static void sixlowpan_compress_ipv6hdr(FAR const struct ipv6_hdr_s *ipv6hdr,
FAR uint8_t *fptr)
{
+ uint16_t protosize;
+
/* Indicate the IPv6 dispatch and length */
fptr[g_frame_hdrlen] = SIXLOWPAN_DISPATCH_IPV6;
@@ -122,33 +124,8 @@ static void sixlowpan_compress_ipv6hdr(FAR const struct ipv6_hdr_s *ipv6hdr,
memcpy(&fptr[g_frame_hdrlen] , ipv6hdr, IPv6_HDRLEN);
g_frame_hdrlen += IPv6_HDRLEN;
g_uncomp_hdrlen += IPv6_HDRLEN;
-}
-/****************************************************************************
- * Name: sixlowpan_copy_protohdr
- *
- * Description:
- * The IPv6 header should have already been processed (as reflected in the
- * g_uncomphdrlen). But we probably still need to copy the following
- * protocol header.
- *
- * Input Parameters:
- * ipv6hdr - Pointer to the IPv6 header to "compress"
- * fptr - Pointer to the beginning of the frame under construction
- *
- * Returned Value:
- * None. But g_frame_hdrlen and g_uncomp_hdrlen updated.
- *
- ****************************************************************************/
-
-static void sixlowpan_copy_protohdr(FAR const struct ipv6_hdr_s *ipv6hdr,
- FAR uint8_t *fptr)
-{
- uint16_t combined;
- uint16_t protosize;
- uint16_t copysize;
-
- /* What is the total size of the IPv6 + protocol header? */
+ /* Copy the following protocol header, */
switch (ipv6hdr->proto)
{
@@ -162,7 +139,6 @@ static void sixlowpan_copy_protohdr(FAR const struct ipv6_hdr_s *ipv6hdr,
*/
protosize = ((uint16_t)tcp->tcpoffset >> 4) << 2;
- combined = sizeof(struct ipv6_hdr_s) + protosize;
}
break;
#endif
@@ -170,48 +146,27 @@ static void sixlowpan_copy_protohdr(FAR const struct ipv6_hdr_s *ipv6hdr,
#ifdef CONFIG_NET_UDP
case IP_PROTO_UDP:
protosize = sizeof(struct udp_hdr_s);
- combined = sizeof(struct ipv6udp_hdr_s);
break;
#endif
#ifdef CONFIG_NET_ICMPv6
case IP_PROTO_ICMP6:
protosize = sizeof(struct icmpv6_hdr_s);
- combined = sizeof(struct ipv6icmp_hdr_s);
break;
#endif
default:
nwarn("WARNING: Unrecognized proto: %u\n", ipv6hdr->proto);
- protosize = 0;
- combined = sizeof(struct ipv6_hdr_s);
- break;
+ return;
}
- /* Copy the remaining protocol header. */
-
- if (g_uncomp_hdrlen > IPv6_HDRLEN)
- {
- nwarn("WARNING: Protocol header not copied: "
- "g_uncomp_hdren=%u IPv6_HDRLEN=%u\n",
- g_uncomp_hdrlen, IPv6_HDRLEN);
- return;
- }
-
- copysize = combined - g_uncomp_hdrlen;
- if (copysize != protosize)
- {
- nwarn("WARNING: Protocol header size mismatch: "
- "g_uncomp_hdren=%u copysize=%u protosize=%u\n",
- g_uncomp_hdrlen, copysize, protosize);
- return;
- }
+ /* Copy the protocol header. */
memcpy(fptr + g_frame_hdrlen, (FAR uint8_t *)ipv6hdr + g_uncomp_hdrlen,
- copysize);
+ protosize);
- g_frame_hdrlen += copysize;
- g_uncomp_hdrlen += copysize;
+ g_frame_hdrlen += protosize;
+ g_uncomp_hdrlen += protosize;
}
/****************************************************************************
@@ -421,10 +376,6 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
g_frame_hdrlen += SIXLOWPAN_FRAG1_HDR_LEN;
- /* Copy protocol header that follows the IPv6 header */
-
- sixlowpan_copy_protohdr(destip, fptr);
-
/* Copy payload and enqueue. NOTE that the size is a multiple of eight
* bytes.
*/
@@ -551,10 +502,6 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
DEBUGASSERT(verify == framer_hdrlen);
UNUSED(verify);
- /* Copy protocol header that follows the IPv6 header */
-
- sixlowpan_copy_protohdr(destip, fptr);
-
/* Copy the payload and queue */
memcpy(fptr + g_frame_hdrlen, buf, buflen);
diff --git a/net/sixlowpan/sixlowpan_hc06.c b/net/sixlowpan/sixlowpan_hc06.c
index 9e51f88c17..d449f82936 100644
--- a/net/sixlowpan/sixlowpan_hc06.c
+++ b/net/sixlowpan/sixlowpan_hc06.c
@@ -440,7 +440,7 @@ void sixlowpan_hc06_initialize(void)
* ipv6 - The IPv6 header to be compressed
* destmac - L2 destination address, needed to compress the IP
* destination field
- * fptr - Pointer to frame data payload.
+ * fptr - Pointer to frame to be compressed.
*
* Returned Value:
* None
@@ -840,7 +840,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
* inferred from the L2 length), non 0 if the packet is a first
* fragment.
* iob - Pointer to the IOB containing the received frame.
- * payptr - Pointer to the frame data payload.
+ * fptr - Pointer to frame to be compressed.
*
* Returned Value:
* None
@@ -849,7 +849,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 uint8_t *payptr)
+ FAR uint8_t *fptr)
{
FAR struct ipv6_hdr_s *ipv6 = IPv6BUF(ieee);
FAR uint8_t *iphc;
@@ -857,18 +857,18 @@ void sixlowpan_uncompresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
uint8_t iphc1;
uint8_t tmp;
- /* payptr points to IPHC. At least two byte will be used for the encoding. */
+ /* iphc points to IPHC. At least two byte will be used for the encoding. */
- iphc = payptr;
+ iphc = fptr + g_frame_hdrlen;
iphc0 = iphc[0];
iphc1 = iphc[1];
/* g_hc96ptr points to just after the 2-byte minimum IPHC */
- g_hc06ptr = payptr + 2;
+ g_hc06ptr = iphc + 2;
- ninfo("payptr=%p g_frame_hdrlen=%u iphc=%02x:%02x:%02x g_hc06ptr=%p\n",
- payptr, g_frame_hdrlen, iphc[0], iphc[1], iphc[2], g_hc06ptr);
+ ninfo("fptr=%p g_frame_hdrlen=%u iphc=%02x:%02x:%02x g_hc06ptr=%p\n",
+ fptr, g_frame_hdrlen, iphc[0], iphc[1], iphc[2], g_hc06ptr);
/* Another if the CID flag is set */
@@ -1171,7 +1171,7 @@ void sixlowpan_uncompresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
}
}
- g_frame_hdrlen = g_hc06ptr - payptr;
+ g_frame_hdrlen = g_hc06ptr - fptr;
/* IP length field. */
diff --git a/net/sixlowpan/sixlowpan_hc1.c b/net/sixlowpan/sixlowpan_hc1.c
index 6626501363..9f657a12dc 100644
--- a/net/sixlowpan/sixlowpan_hc1.c
+++ b/net/sixlowpan/sixlowpan_hc1.c
@@ -258,7 +258,7 @@ void sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
* inferred from the L2 length), non 0 if the packet is a 1st
* fragment.
* iob - Pointer to the IOB containing the received frame.
- * payptr - Pointer to the frame data payload.
+ * fptr - Pointer to frame to be uncompressed.
*
* Returned Value:
* Zero (OK) is returned on success, on failure a negater errno value is
@@ -268,10 +268,10 @@ void sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_uncompresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
uint16_t iplen, FAR struct iob_s *iob,
- FAR uint8_t *payptr)
+ FAR uint8_t *fptr)
{
FAR struct ipv6_hdr_s *ipv6 = IPv6BUF(&ieee->i_dev);
- FAR uint8_t *hc1 = payptr + g_frame_hdrlen;
+ FAR uint8_t *hc1 = fptr + g_frame_hdrlen;
/* Format the IPv6 header in the device d_buf */
/* Set version, traffic clase, and flow label */
@@ -312,7 +312,7 @@ int sixlowpan_uncompresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
case SIXLOWPAN_HC1_NH_UDP:
{
FAR struct udp_hdr_s *udp = UDPIPv6BUF(&ieee->i_dev);
- FAR uint8_t *hcudp = payptr + g_frame_hdrlen;
+ FAR uint8_t *hcudp = fptr + g_frame_hdrlen;
ipv6->proto = IP_PROTO_UDP;
if ((hcudp[RIME_HC1_HC_UDP_HC1_ENCODING] & 0x01) != 0)
diff --git a/net/sixlowpan/sixlowpan_input.c b/net/sixlowpan/sixlowpan_input.c
index 6098a58251..b19fa8ffba 100644
--- a/net/sixlowpan/sixlowpan_input.c
+++ b/net/sixlowpan/sixlowpan_input.c
@@ -190,6 +190,91 @@ int sixlowpan_recv_hdrlen(FAR const uint8_t *fptr)
return 0;
}
+/****************************************************************************
+ * Name: sixlowpan_compress_ipv6hdr
+ *
+ * Description:
+ * IPv6 dispatch "compression" function. Packets "Compression" when only
+ * IPv6 dispatch is used
+ *
+ * There is no compression in this case, all fields are sent
+ * inline. We just add the IPv6 dispatch byte before the packet.
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | IPv6 Dsp | IPv6 header and payload ...
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * Input Parameters:
+ * ieee - The IEEE802.15.4 MAC network driver interface.
+ * fptr - Pointer to the beginning of the frame under construction
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void sixlowpan_uncompress_ipv6hdr(FAR struct ieee802154_driver_s *ieee,
+ FAR uint8_t *fptr)
+{
+ FAR struct ipv6_hdr_s *ipv6 = IPv6BUF(&ieee->i_dev);
+ uint16_t protosize;
+
+ /* Put uncompressed IPv6 header in d_buf. */
+
+ g_frame_hdrlen += SIXLOWPAN_IPV6_HDR_LEN;
+ memcpy(ipv6, fptr + g_frame_hdrlen, IPv6_HDRLEN);
+
+ /* Update g_uncomp_hdrlen and g_frame_hdrlen. */
+
+ g_frame_hdrlen += IPv6_HDRLEN;
+ g_uncomp_hdrlen += IPv6_HDRLEN;
+
+ /* Copy the following protocol header, */
+
+ switch (ipv6->proto)
+ {
+#ifdef CONFIG_NET_TCP
+ case IP_PROTO_TCP:
+ {
+ FAR struct tcp_hdr_s *tcp = &((FAR struct ipv6tcp_hdr_s *)ipv6)->tcp;
+
+ /* The TCP header length is encoded in the top 4 bits of the
+ * tcpoffset field (in units of 32-bit words).
+ */
+
+ protosize = ((uint16_t)tcp->tcpoffset >> 4) << 2;
+ }
+ break;
+#endif
+
+#ifdef CONFIG_NET_UDP
+ case IP_PROTO_UDP:
+ protosize = sizeof(struct udp_hdr_s);
+ break;
+#endif
+
+#ifdef CONFIG_NET_ICMPv6
+ case IP_PROTO_ICMP6:
+ protosize = sizeof(struct icmpv6_hdr_s);
+ break;
+#endif
+
+ default:
+ nwarn("WARNING: Unrecognized proto: %u\n", ipv6->proto);
+ return;
+ }
+
+ /* Copy the protocol header. */
+
+ memcpy((FAR uint8_t *)ipv6 + g_uncomp_hdrlen, fptr + g_frame_hdrlen,
+ protosize);
+
+ g_frame_hdrlen += protosize;
+ g_uncomp_hdrlen += protosize;
+}
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -224,6 +309,7 @@ int sixlowpan_recv_hdrlen(FAR const uint8_t *fptr)
static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
FAR struct iob_s *iob)
{
+ FAR uint8_t *fptr; /* Convenience pointer to beginning of the frame */
FAR uint8_t *hc1; /* Convenience pointer to HC1 data */
uint16_t fragsize = 0; /* Size of the IP packet (read from fragment) */
uint16_t paysize; /* Size of the data payload */
@@ -242,7 +328,8 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
* This size includes both fragmentation and FCF headers.
*/
- hdrsize = sixlowpan_recv_hdrlen(iob->io_data);
+ fptr = iob->io_data;
+ hdrsize = sixlowpan_recv_hdrlen(fptr);
if (hdrsize < 0)
{
nwarn("Invalid IEEE802.15.2 header: %d\n", hdrsize);
@@ -262,7 +349,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
* already includes the fragementation header, if presetn.
*/
- switch ((GETINT16(iob->io_data, RIME_FRAG_DISPATCH_SIZE) & 0xf800) >> 8)
+ switch ((GETINT16(fptr, RIME_FRAG_DISPATCH_SIZE) & 0xf800) >> 8)
{
/* First fragment of new reassembly */
@@ -270,8 +357,8 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
{
/* Set up for the reassembly */
- fragsize = GETINT16(iob->io_data, RIME_FRAG_DISPATCH_SIZE) & 0x07ff;
- fragtag = GETINT16(iob->io_data, RIME_FRAG_TAG);
+ fragsize = GETINT16(fptr, RIME_FRAG_DISPATCH_SIZE) & 0x07ff;
+ fragtag = GETINT16(fptr, RIME_FRAG_TAG);
ninfo("FRAG1: fragsize=%d fragtag=%d fragoffset=%d\n",
fragsize, fragtag, fragoffset);
@@ -287,9 +374,9 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
{
/* Set offset, tag, size. Offset is in units of 8 bytes. */
- fragoffset = iob->io_data[RIME_FRAG_OFFSET];
- fragtag = GETINT16(iob->io_data, RIME_FRAG_TAG);
- fragsize = GETINT16(iob->io_data, RIME_FRAG_DISPATCH_SIZE) & 0x07ff;
+ fragoffset = fptr[RIME_FRAG_OFFSET];
+ fragtag = GETINT16(fptr, RIME_FRAG_TAG);
+ fragsize = GETINT16(fptr, RIME_FRAG_DISPATCH_SIZE) & 0x07ff;
ninfo("FRAGN: fragsize=%d fragtag=%d fragoffset=%d\n",
fragsize, fragtag, fragoffset);
@@ -429,19 +516,13 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
/* Process next dispatch and headers */
- hc1 = &iob->io_data[g_frame_hdrlen];
+ hc1 = fptr + g_frame_hdrlen;
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC06
if ((hc1[RIME_HC1_DISPATCH] & SIXLOWPAN_DISPATCH_IPHC_MASK) == SIXLOWPAN_DISPATCH_IPHC)
{
- FAR uint8_t *payptr;
-
ninfo("IPHC Dispatch\n");
-
- /* Payload starts after the IEEE802.15.4 header(s) */
-
- payptr = &iob->io_data[g_frame_hdrlen];
- sixlowpan_uncompresshdr_hc06(ieee, fragsize, iob, payptr);
+ sixlowpan_uncompresshdr_hc06(ieee, fragsize, iob, fptr);
}
else
#endif /* CONFIG_NET_6LOWPAN_COMPRESSION_HC06 */
@@ -449,33 +530,16 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC1
if (hc1[RIME_HC1_DISPATCH] == SIXLOWPAN_DISPATCH_HC1)
{
- FAR uint8_t *payptr;
-
ninfo("HC1 Dispatch\n");
-
- /* Payload starts after the IEEE802.15.4 header(s) */
-
- payptr = &iob->io_data[g_frame_hdrlen];
- sixlowpan_uncompresshdr_hc1(ieee, fragsize, iob, payptr);
+ sixlowpan_uncompresshdr_hc1(ieee, fragsize, iob, fptr);
}
else
#endif /* CONFIG_NET_6LOWPAN_COMPRESSION_HC1 */
if (hc1[RIME_HC1_DISPATCH] == SIXLOWPAN_DISPATCH_IPV6)
{
- FAR struct ipv6_hdr_s *ipv6 = IPv6BUF(&ieee->i_dev);
-
ninfo("IPv6 Dispatch\n");
- g_frame_hdrlen += SIXLOWPAN_IPV6_HDR_LEN;
-
- /* Put uncompressed IP header in d_buf. */
-
- memcpy(ipv6, iob->io_data + g_frame_hdrlen, IPv6_HDRLEN);
-
- /* Update g_uncomp_hdrlen and g_frame_hdrlen. */
-
- g_frame_hdrlen += IPv6_HDRLEN;
- g_uncomp_hdrlen += IPv6_HDRLEN;
+ sixlowpan_uncompress_ipv6hdr(ieee, fptr);
}
else
{
@@ -527,8 +591,7 @@ copypayload:
}
memcpy(ieee->i_dev.d_buf + g_uncomp_hdrlen + (fragoffset << 3),
- iob->io_data + g_frame_hdrlen,
- paysize);
+ fptr + g_frame_hdrlen, paysize);
#ifdef CONFIG_NET_6LOWPAN_FRAG
/* Update ieee->i_accumlen if the frame is a fragment, ieee->i_pktlen
@@ -690,8 +753,7 @@ int sixlowpan_input(FAR struct ieee802154_driver_s *ieee)
FRAME_IOB_REMOVE(ieee, iob);
DEBUGASSERT(iob != NULL);
- sixlowpan_dumpbuffer("Incoming frame",
- (FAR const uint8_t *)iob->io_data, iob->io_len);
+ sixlowpan_dumpbuffer("Incoming frame", iob->io_data, iob->io_len);
/* Process the frame, decompressing it into the packet buffer */
diff --git a/net/sixlowpan/sixlowpan_internal.h b/net/sixlowpan/sixlowpan_internal.h
index bd366c884e..5445686373 100644
--- a/net/sixlowpan/sixlowpan_internal.h
+++ b/net/sixlowpan/sixlowpan_internal.h
@@ -84,82 +84,6 @@
/* Pointers in the Rime buffer */
-/* Fragment header.
- *
- * The fragment header is used when the payload is too large to fit in a
- * single IEEE 802.15.4 frame. The fragment header contains three fields:
- * Datagram size, datagram tag and datagram offset.
- *
- * 1. Datagram size describes the total (un-fragmented) payload.
- * 2. Datagram tag identifies the set of fragments and is used to match
- * fragments of the same payload.
- * 3. Datagram offset identifies the fragment’s offset within the un-
- * fragmented payload.
- *
- * The fragment header length is 4 bytes for the first header and 5
- * bytes for all subsequent headers.
- */
-
-#define RIME_FRAG_DISPATCH_SIZE 0 /* 16 bit */
-#define RIME_FRAG_TAG 2 /* 16 bit */
-#define RIME_FRAG_OFFSET 4 /* 8 bit */
-
-/* Define the Rime buffer as a byte array */
-
-#define RIME_HC1_DISPATCH 0 /* 8 bit */
-#define RIME_HC1_ENCODING 1 /* 8 bit */
-#define RIME_HC1_TTL 2 /* 8 bit */
-
-#define RIME_HC1_HC_UDP_DISPATCH 0 /* 8 bit */
-#define RIME_HC1_HC_UDP_HC1_ENCODING 1 /* 8 bit */
-#define RIME_HC1_HC_UDP_UDP_ENCODING 2 /* 8 bit */
-#define RIME_HC1_HC_UDP_TTL 3 /* 8 bit */
-#define RIME_HC1_HC_UDP_PORTS 4 /* 8 bit */
-#define RIME_HC1_HC_UDP_CHKSUM 5 /* 16 bit */
-
-/* These are some definitions of element values used in the FCF. See the
- * IEEE802.15.4 spec for details.
- */
-
-#define FRAME802154_FRAMETYPE_SHIFT (0) /* Bits 0-2: Frame type */
-#define FRAME802154_FRAMETYPE_MASK (7 << FRAME802154_FRAMETYPE_SHIFT)
-#define FRAME802154_SECENABLED_SHIFT (3) /* Bit 3: Security enabled */
-#define FRAME802154_FRAMEPENDING_SHIFT (4) /* Bit 4: Frame pending */
-#define FRAME802154_ACKREQUEST_SHIFT (5) /* Bit 5: ACK request */
-#define FRAME802154_PANIDCOMP_SHIFT (6) /* Bit 6: PANID compression */
- /* Bits 7-9: Reserved */
-#define FRAME802154_DSTADDR_SHIFT (2) /* Bits 10-11: Dest address mode */
-#define FRAME802154_DSTADDR_MASK (3 << FRAME802154_DSTADDR_SHIFT)
-#define FRAME802154_VERSION_SHIFT (4) /* Bit 12-13: Frame version */
-#define FRAME802154_VERSION_MASK (3 << FRAME802154_VERSION_SHIFT)
-#define FRAME802154_SRCADDR_SHIFT (6) /* Bits 14-15: Source address mode */
-#define FRAME802154_SRCADDR_MASK (3 << FRAME802154_SRCADDR_SHIFT)
-
-/* Unshifted values for use in struct frame802154_fcf_s */
-
-#define FRAME802154_BEACONFRAME (0)
-#define FRAME802154_DATAFRAME (1)
-#define FRAME802154_ACKFRAME (2)
-#define FRAME802154_CMDFRAME (3)
-
-#define FRAME802154_BEACONREQ (7)
-
-#define FRAME802154_IEEERESERVED (0)
-#define FRAME802154_NOADDR (0) /* Only valid for ACK or Beacon frames */
-#define FRAME802154_SHORTADDRMODE (2)
-#define FRAME802154_LONGADDRMODE (3)
-
-#define FRAME802154_NOBEACONS 0x0f
-
-#define FRAME802154_BROADCASTADDR 0xffff
-#define FRAME802154_BROADCASTPANDID 0xffff
-
-#define FRAME802154_IEEE802154_2003 (0)
-#define FRAME802154_IEEE802154_2006 (1)
-
-#define FRAME802154_SECURITY_LEVEL_NONE (0)
-#define FRAME802154_SECURITY_LEVEL_128 (3)
-
/* Packet buffer Definitions */
#define PACKETBUF_ATTR_PACKET_TYPE_DATA 0
@@ -215,69 +139,6 @@
#define PACKETBUF_NUM_ADDRS 4
-/* Address compressibility test macros **************************************/
-
-/* Check whether we can compress the IID in address 'a' to 16 bits. This is
- * used for unicast addresses only, and is true if the address is on the
- * format ::0000:00ff:fe00:XXXX
- *
- * NOTE: we currently assume 64-bits prefixes
- */
-
-/* Check whether we can compress the IID in address 'a' to 16 bits. This is
- * used for unicast addresses only, and is true if the address is on the
- * format ::0000:00ff:fe00:XXXX.
- *
- * NOTE: we currently assume 64-bits prefixes. Big-endian, network order is
- * assumed.
- */
-
-#define SIXLOWPAN_IS_IID_16BIT_COMPRESSABLE(a) \
- ((((a)[4]) == 0x0000) && (((a)[5]) == HTONS(0x00ff)) && \
- (((a)[6]) == 0xfe00))
-
-/* Check whether the 9-bit group-id of the compressed multicast address is
- * known. It is true if the 9-bit group is the all nodes or all routers
- * group. Parameter 'a' is typed uint8_t *
- */
-
-#define SIXLOWPAN_IS_MCASTADDR_DECOMPRESSABLE(a) \
- (((*a & 0x01) == 0) && \
- ((*(a + 1) == 0x01) || (*(a + 1) == 0x02)))
-
-/* Check whether the 112-bit group-id of the multicast address is mappable
- * to a 9-bit group-id. It is true if the group is the all nodes or all
- * routers group:
- *
- * XXXX:0000:0000:0000:0000:0000:0000:0001 All nodes address
- * XXXX:0000:0000:0000:0000:0000:0000:0002 All routers address
- */
-
-#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE(a) \
- ((a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
- (a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && \
- ((a)[7] == HTONS(0x0001) || (a)[7] == HTONS(0x0002)))
-
-/* FFXX:0000:0000:0000:0000:00XX:XXXX:XXXX */
-
-#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE48(a) \
- ((a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
- (a)[4] == 0 && (((a)[5] & HTONS(0xff00)) == 0))
-
-/* FFXX:0000:0000:0000:0000:0000:00XX:XXXX */
-
-#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE32(a) \
- ((a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
- (a)[4] == 0 && (a)[5] == 0 && ((a)[6] & HTONS(0xff00)) == 0)
-
-/* FF02:0000:0000:0000:0000:0000:0000:00XX */
-
-#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE8(a) \
- ((((a)[0] & HTONS(0x00ff)) == HTONS(0x0002)) && \
- (a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
- (a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && \
- (((a)[7] & HTONS(0xff00)) == 0x0000))
-
/* General helper macros ****************************************************/
#define GETINT16(ptr,index) \
@@ -641,7 +502,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
* inferred from the L2 length), non 0 if the packet is a first
* fragment.
* iob - Pointer to the IOB containing the received frame.
- * payptr - Pointer to the frame data payload.
+ * fptr - Pointer to frame to be uncompressed.
*
* Returned Value:
* None
@@ -651,7 +512,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC06
void sixlowpan_uncompresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
uint16_t iplen, FAR struct iob_s *iob,
- FAR uint8_t *payptr);
+ FAR uint8_t *fptr);
#endif
/****************************************************************************
@@ -701,7 +562,7 @@ void sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
* inferred from the L2 length), non 0 if the packet is a first
* fragment.
* iob - Pointer to the IOB containing the received frame.
- * payptr - Pointer to the frame data payload.
+ * fptr - Pointer to frame to be uncompressed.
*
* Returned Value:
* None
@@ -711,7 +572,7 @@ void sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC1
int sixlowpan_uncompresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
uint16_t ip_len, FAR struct iob_s *iob,
- FAR uint8_t *payptr);
+ FAR uint8_t *fptr);
#endif
/****************************************************************************