sixlowpan: Can't reuse same header on each fragment. DSN needs to increment.

This commit is contained in:
Gregory Nutt 2017-04-29 08:23:59 -06:00
parent 5f5c82aa11
commit 8262c05713
4 changed files with 21 additions and 9 deletions

View File

@ -49,7 +49,7 @@ 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
41 88 01 cefa 3412 cdab ### 9-byte MAC header
41 88 2a cefa 3412 cdab ### 9-byte MAC header
c50e 000b ### 4-byte FRAG1 header
42 ### SIXLOWPAN_DISPATCH_HC1
fb ### RIME_HC1_HC_UDP_HC1_ENCODING
@ -66,7 +66,7 @@ this is a HC1 compressed first frame of a packet
This is the second frame of the same transfer:
41 88 01 cefa 3412 cdab ### 9-byte MAC header
41 88 2b cefa 3412 cdab ### 9-byte MAC header
e50e 000b 0d ### 5 byte FRAGN header
42 ### SIXLOWPAN_DISPATCH_HC1
fb ### RIME_HC1_HC_UDP_HC1_ENCODING

View File

@ -281,7 +281,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
ninfo("Sending packet length %d\n", buflen);
/* Set the source and destinatino address */
/* Set the source and destination address */
rimeaddr_copy(&g_pktaddrs[PACKETBUF_ADDR_SENDER],
&ieee->i_dev.d_mac.ieee802154);
@ -348,7 +348,9 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
ninfo("Sending fragmented packet length %d\n", buflen);
/* Create 1st Fragment */
/* Add the frame header using the pre-allocated IOB. */
/* Add the frame header using the pre-allocated IOB using the DSN
* selected by sixlowpan_send_hdrlen().
*/
verify = sixlowpan_framecreate(ieee, iob, ieee->i_panid);
DEBUGASSERT(verify == framer_hdrlen);
@ -434,11 +436,17 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
iob->io_pktlen = 0;
fptr = iob->io_data;
/* Copy the frame header at the beginning of the frame. */
/* Add a new frame header to the IOB (same as the first but with a
* different DSN).
*/
memcpy(fptr, frame1, framer_hdrlen);
g_pktattrs[PACKETBUF_ATTR_MAC_SEQNO] = 0;
/* Move HC1/HC06/IPv6 header the frame header from first
verify = sixlowpan_framecreate(ieee, iob, ieee->i_panid);
DEBUGASSERT(verify == framer_hdrlen);
UNUSED(verify);
/* Copy the HC1/HC06/IPv6 header the frame header from first
* frame, into the correct location after the FRAGN header
* of subsequent frames.
*/

View File

@ -322,12 +322,12 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
if (g_pktattrs[PACKETBUF_ATTR_MAC_SEQNO] != 0)
{
params->seq = g_pktattrs[PACKETBUF_ATTR_MAC_SEQNO];
params->seq = g_pktattrs[PACKETBUF_ATTR_MAC_SEQNO] & 0xff;
}
else
{
params->seq = ieee->i_dsn++;
g_pktattrs[PACKETBUF_ATTR_MAC_SEQNO] = params->seq;
g_pktattrs[PACKETBUF_ATTR_MAC_SEQNO] = params->seq | 0x100;
}
/* Complete the addressing fields. */

View File

@ -618,6 +618,10 @@ int ieee8021514_loopback(void)
priv->lo_polldog = wd_create(); /* Create periodic poll timer */
/* Initialize the DSN to a "random" value */
priv->lo_ieee.i_dsn = 42;
/* Register the loopabck device with the OS so that socket IOCTLs can b
* performed.
*/