6loWPAN: Repartition device-specific vs. global data -- again.
This commit is contained in:
parent
cd3c9634c8
commit
44f1326046
@ -233,63 +233,6 @@
|
||||
|
||||
#define SIXLOWPAN_MAC_STDFRAME 127
|
||||
|
||||
/* Packet buffer Definitions */
|
||||
|
||||
#define PACKETBUF_HDR_SIZE 48
|
||||
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE_DATA 0
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE_ACK 1
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE_STREAM 2
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE_STREAM_END 3
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE_TIMESTAMP 4
|
||||
|
||||
/* Packet buffer attributes (indices into i_pktattr) */
|
||||
|
||||
#define PACKETBUF_ATTR_NONE 0
|
||||
|
||||
/* Scope 0 attributes: used only on the local node. */
|
||||
|
||||
#define PACKETBUF_ATTR_CHANNEL 1
|
||||
#define PACKETBUF_ATTR_NETWORK_ID 2
|
||||
#define PACKETBUF_ATTR_LINK_QUALITY 3
|
||||
#define PACKETBUF_ATTR_RSSI 4
|
||||
#define PACKETBUF_ATTR_TIMESTAMP 5
|
||||
#define PACKETBUF_ATTR_RADIO_TXPOWER 6
|
||||
#define PACKETBUF_ATTR_LISTEN_TIME 7
|
||||
#define PACKETBUF_ATTR_TRANSMIT_TIME 8
|
||||
#define PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS 9
|
||||
#define PACKETBUF_ATTR_MAC_SEQNO 10
|
||||
#define PACKETBUF_ATTR_MAC_ACK 11
|
||||
|
||||
/* Scope 1 attributes: used between two neighbors only. */
|
||||
|
||||
#define PACKETBUF_ATTR_RELIABLE 12
|
||||
#define PACKETBUF_ATTR_PACKET_ID 13
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE 14
|
||||
#define PACKETBUF_ATTR_REXMIT 15
|
||||
#define PACKETBUF_ATTR_MAX_REXMIT 16
|
||||
#define PACKETBUF_ATTR_NUM_REXMIT 17
|
||||
#define PACKETBUF_ATTR_PENDING 18
|
||||
|
||||
/* Scope 2 attributes: used between end-to-end nodes. */
|
||||
|
||||
#define PACKETBUF_ATTR_HOPS 11
|
||||
#define PACKETBUF_ATTR_TTL 20
|
||||
#define PACKETBUF_ATTR_EPACKET_ID 21
|
||||
#define PACKETBUF_ATTR_EPACKET_TYPE 22
|
||||
#define PACKETBUF_ATTR_ERELIABLE 23
|
||||
|
||||
#define PACKETBUF_NUM_ATTRS 24
|
||||
|
||||
/* Addresses (indices into i_pktaddr) */
|
||||
|
||||
#define PACKETBUF_ADDR_SENDER 0
|
||||
#define PACKETBUF_ADDR_RECEIVER 1
|
||||
#define PACKETBUF_ADDR_ESENDER 2
|
||||
#define PACKETBUF_ADDR_ERECEIVER 3
|
||||
|
||||
#define PACKETBUF_NUM_ADDRS 4
|
||||
|
||||
/* Frame buffer helper macros.
|
||||
*
|
||||
* The IEEE802.15.4 MAC driver structures includes a list of IOB
|
||||
@ -427,19 +370,6 @@ struct rimeaddr_s
|
||||
*
|
||||
* The MAC driver should then inform the network of the by calling
|
||||
* sixlowpan_input().
|
||||
*
|
||||
* Frame Organization. The IOB data is retained in the io_data[] field of the
|
||||
* IOB structure like:
|
||||
*
|
||||
* Content Offset
|
||||
* +------------------+ 0
|
||||
* | Frame Header |
|
||||
* +------------------+ i_dataoffset
|
||||
* | Procotol Headers |
|
||||
* | Data Payload |
|
||||
* +------------------+ io_len
|
||||
* | Unused |
|
||||
* +------------------+ CONFIG_NET_6LOWPAN_FRAMELEN
|
||||
*/
|
||||
|
||||
struct ieee802154_driver_s
|
||||
@ -492,40 +422,6 @@ struct ieee802154_driver_s
|
||||
*/
|
||||
|
||||
uint8_t i_dsn;
|
||||
|
||||
/* The following fields are device-specific metadata used by the 6loWPAN
|
||||
* stack and should not be modified by the IEEE802.15.4 MAC network drvier.
|
||||
*/
|
||||
|
||||
/* A pointer to the rime buffer.
|
||||
*
|
||||
* We initialize it to the beginning of the rime buffer, then access
|
||||
* different fields by updating the offset ieee->i_rime_hdrlen.
|
||||
*/
|
||||
|
||||
FAR uint8_t *i_rimeptr;
|
||||
|
||||
/* i_uncomp_hdrlen is the length of the headers before compression (if HC2
|
||||
* is used this includes the UDP header in addition to the IP header).
|
||||
*/
|
||||
|
||||
uint8_t i_uncomp_hdrlen;
|
||||
|
||||
/* i_rime_hdrlen is the total length of (the processed) 6lowpan headers
|
||||
* (fragment headers, IPV6 or HC1, HC2, and HC1 and HC2 non compressed
|
||||
* fields).
|
||||
*/
|
||||
|
||||
uint8_t i_rime_hdrlen;
|
||||
|
||||
/* Offset first available byte for the payload after header region. */
|
||||
|
||||
uint8_t i_dataoffset;
|
||||
|
||||
/* Packet buffer metadata: Attributes and addresses */
|
||||
|
||||
uint16_t i_pktattrs[PACKETBUF_NUM_ATTRS];
|
||||
struct rimeaddr_s i_pktaddrs[PACKETBUF_NUM_ADDRS];
|
||||
};
|
||||
|
||||
/* The structure of a next header compressor. This compressor is provided
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "nuttx/net/net.h"
|
||||
#include "nuttx/net/sixlowpan.h"
|
||||
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
|
@ -55,7 +55,6 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include "nuttx/net/net.h"
|
||||
#include "nuttx/net/sixlowpan.h"
|
||||
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
@ -299,21 +298,21 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Reset to an empty frame */
|
||||
|
||||
ieee->i_dataoffset = 0;
|
||||
FRAME_RESET();
|
||||
|
||||
/* Build the FCF (Only non-zero elements need to be initialized). */
|
||||
|
||||
params->fcf.frame_type = FRAME802154_DATAFRAME;
|
||||
params->fcf.frame_pending = ieee->i_pktattrs[PACKETBUF_ATTR_PENDING];
|
||||
params->fcf.frame_pending = g_pktattrs[PACKETBUF_ATTR_PENDING];
|
||||
|
||||
/* If the output address is NULL in the Rime buf, then it is broadcast
|
||||
* on the 802.15.4 network.
|
||||
*/
|
||||
|
||||
rcvrnull = sixlowpan_addrnull(ieee->i_pktaddrs[PACKETBUF_ADDR_RECEIVER].u8);
|
||||
rcvrnull = sixlowpan_addrnull(g_pktaddrs[PACKETBUF_ADDR_RECEIVER].u8);
|
||||
if (rcvrnull)
|
||||
{
|
||||
params->fcf.ack_required = ieee->i_pktattrs[PACKETBUF_ATTR_MAC_ACK];
|
||||
params->fcf.ack_required = g_pktattrs[PACKETBUF_ATTR_MAC_ACK];
|
||||
}
|
||||
|
||||
/* Insert IEEE 802.15.4 (2003) version bit. */
|
||||
@ -322,14 +321,14 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Increment and set the data sequence number. */
|
||||
|
||||
if (ieee->i_pktattrs[PACKETBUF_ATTR_MAC_SEQNO] != 0)
|
||||
if (g_pktattrs[PACKETBUF_ATTR_MAC_SEQNO] != 0)
|
||||
{
|
||||
params->seq = ieee->i_pktattrs[PACKETBUF_ATTR_MAC_SEQNO];
|
||||
params->seq = g_pktattrs[PACKETBUF_ATTR_MAC_SEQNO];
|
||||
}
|
||||
else
|
||||
{
|
||||
params->seq = ieee->i_dsn++;
|
||||
ieee->i_pktattrs[PACKETBUF_ATTR_MAC_SEQNO] = params->seq;
|
||||
g_pktattrs[PACKETBUF_ATTR_MAC_SEQNO] = params->seq;
|
||||
}
|
||||
|
||||
/* Complete the addressing fields. */
|
||||
@ -355,7 +354,7 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
/* Copy the destination address */
|
||||
|
||||
rimeaddr_copy((struct rimeaddr_s *)¶ms->dest_addr,
|
||||
ieee->i_pktaddrs[PACKETBUF_ADDR_RECEIVER].u8);
|
||||
g_pktaddrs[PACKETBUF_ADDR_RECEIVER].u8);
|
||||
|
||||
/* Use short address mode if so configured */
|
||||
|
||||
@ -374,8 +373,8 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
if (iob != NULL)
|
||||
{
|
||||
params->payload = FRAME_DATA_START(ieee, iob);
|
||||
params->payload_len = FRAME_DATA_SIZE(ieee, iob);
|
||||
params->payload = FRAME_DATA_START(iob);
|
||||
params->payload_len = FRAME_DATA_SIZE(iob);
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,7 +550,7 @@ int sixlowpan_framecreate(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Allocate space for the header in the frame buffer */
|
||||
|
||||
ret = sixlowpan_frame_hdralloc(ieee, iob, len);
|
||||
ret = sixlowpan_frame_hdralloc(iob, len);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Header too large: %u\n", len);
|
||||
@ -560,10 +559,10 @@ int sixlowpan_framecreate(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Then create the frame */
|
||||
|
||||
sixlowpan_802154_framecreate(¶ms, FRAME_HDR_START(ieee, iob), len);
|
||||
sixlowpan_802154_framecreate(¶ms, FRAME_HDR_START(iob), len);
|
||||
|
||||
wlinfo("Frame type: %02x Data len: %d %u (%u)\n",
|
||||
params.fcf.frame_type, len, FRAME_DATA_SIZE(ieee, iob),
|
||||
params.fcf.frame_type, len, FRAME_DATA_SIZE(iob),
|
||||
FRAME_SIZE(ieee, iob));
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
wlinfo("Dest address: %02x:%02x\n",
|
||||
|
@ -39,8 +39,6 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "nuttx/net/sixlowpan.h"
|
||||
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
@ -59,4 +57,41 @@ FAR struct sixlowpan_nhcompressor_s *g_sixlowpan_compressor;
|
||||
FAR struct sixlowpan_rime_sniffer_s *g_sixlowpan_sniffer;
|
||||
#endif
|
||||
|
||||
/* The following data values are used to hold intermediate settings while
|
||||
* processing IEEE802.15.4 frames. These globals are shared with incoming
|
||||
* and outgoing frame processing and possibly with mutliple IEEE802.15.4 MAC
|
||||
* devices. The network lock provides exclusive use of these globals
|
||||
* during that processing
|
||||
*/
|
||||
|
||||
/* A pointer to the rime buffer.
|
||||
*
|
||||
* We initialize it to the beginning of the rime buffer, then access
|
||||
* different fields by updating the offset ieee->g_rime_hdrlen.
|
||||
*/
|
||||
|
||||
FAR uint8_t *g_rimeptr;
|
||||
|
||||
/* g_uncomp_hdrlen is the length of the headers before compression (if HC2
|
||||
* is used this includes the UDP header in addition to the IP header).
|
||||
*/
|
||||
|
||||
uint8_t g_uncomp_hdrlen;
|
||||
|
||||
/* g_rime_hdrlen is the total length of (the processed) 6lowpan headers
|
||||
* (fragment headers, IPV6 or HC1, HC2, and HC1 and HC2 non compressed
|
||||
* fields).
|
||||
*/
|
||||
|
||||
uint8_t g_rime_hdrlen;
|
||||
|
||||
/* Offset first available byte for the payload after header region. */
|
||||
|
||||
uint8_t g_dataoffset;
|
||||
|
||||
/* Packet buffer metadata: Attributes and addresses */
|
||||
|
||||
uint16_t g_pktattrs[PACKETBUF_NUM_ATTRS];
|
||||
struct rimeaddr_s g_pktaddrs[PACKETBUF_NUM_ADDRS];
|
||||
|
||||
#endif /* CONFIG_NET_6LOWPAN */
|
||||
|
@ -59,7 +59,6 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
|
@ -63,6 +63,7 @@
|
||||
#include <nuttx/net/tcp.h>
|
||||
#include <nuttx/net/udp.h>
|
||||
#include <nuttx/net/icmpv6.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
|
||||
@ -83,25 +84,20 @@
|
||||
|
||||
/* Frame buffer helpers */
|
||||
|
||||
#define FRAME_RESET(ieee) \
|
||||
#define FRAME_RESET() \
|
||||
do \
|
||||
{ \
|
||||
(ieee)->i_dataoffset = 0; \
|
||||
g_dataoffset = 0; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define FRAME_HDR_START(ieee,iob) \
|
||||
((iob)->io_data)
|
||||
#define FRAME_HDR_SIZE(ieee,iob) \
|
||||
((ieee)->i_dataoffset)
|
||||
#define FRAME_HDR_START(iob) ((iob)->io_data)
|
||||
#define FRAME_HDR_SIZE(iob) g_dataoffset
|
||||
|
||||
#define FRAME_DATA_START(ieee,iob) \
|
||||
((FAR uint8_t *)((iob)->io_data) + (ieee)->i_dataoffset)
|
||||
#define FRAME_DATA_SIZE(ieee,iob) \
|
||||
((iob)->io_len - (ieee)->i_dataoffset)
|
||||
#define FRAME_DATA_START(iob) ((FAR uint8_t *)((iob)->io_data) + g_dataoffset)
|
||||
#define FRAME_DATA_SIZE(iob) ((iob)->io_len - g_dataoffset)
|
||||
|
||||
#define FRAME_REMAINING(ieee,iob) \
|
||||
(CONFIG_NET_6LOWPAN_FRAMELEN - (iob)->io_len)
|
||||
#define FRAME_REMAINING(iob) (CONFIG_NET_6LOWPAN_FRAMELEN - (iob)->io_len)
|
||||
#define FRAME_SIZE(ieee,iob) \
|
||||
((iob)->io_len)
|
||||
|
||||
@ -132,6 +128,63 @@
|
||||
#define FRAME802154_SECURITY_LEVEL_NONE 0
|
||||
#define FRAME802154_SECURITY_LEVEL_128 3
|
||||
|
||||
/* Packet buffer Definitions */
|
||||
|
||||
#define PACKETBUF_HDR_SIZE 48
|
||||
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE_DATA 0
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE_ACK 1
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE_STREAM 2
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE_STREAM_END 3
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE_TIMESTAMP 4
|
||||
|
||||
/* Packet buffer attributes (indices into i_pktattr) */
|
||||
|
||||
#define PACKETBUF_ATTR_NONE 0
|
||||
|
||||
/* Scope 0 attributes: used only on the local node. */
|
||||
|
||||
#define PACKETBUF_ATTR_CHANNEL 1
|
||||
#define PACKETBUF_ATTR_NETWORK_ID 2
|
||||
#define PACKETBUF_ATTR_LINK_QUALITY 3
|
||||
#define PACKETBUF_ATTR_RSSI 4
|
||||
#define PACKETBUF_ATTR_TIMESTAMP 5
|
||||
#define PACKETBUF_ATTR_RADIO_TXPOWER 6
|
||||
#define PACKETBUF_ATTR_LISTEN_TIME 7
|
||||
#define PACKETBUF_ATTR_TRANSMIT_TIME 8
|
||||
#define PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS 9
|
||||
#define PACKETBUF_ATTR_MAC_SEQNO 10
|
||||
#define PACKETBUF_ATTR_MAC_ACK 11
|
||||
|
||||
/* Scope 1 attributes: used between two neighbors only. */
|
||||
|
||||
#define PACKETBUF_ATTR_RELIABLE 12
|
||||
#define PACKETBUF_ATTR_PACKET_ID 13
|
||||
#define PACKETBUF_ATTR_PACKET_TYPE 14
|
||||
#define PACKETBUF_ATTR_REXMIT 15
|
||||
#define PACKETBUF_ATTR_MAX_REXMIT 16
|
||||
#define PACKETBUF_ATTR_NUM_REXMIT 17
|
||||
#define PACKETBUF_ATTR_PENDING 18
|
||||
|
||||
/* Scope 2 attributes: used between end-to-end nodes. */
|
||||
|
||||
#define PACKETBUF_ATTR_HOPS 11
|
||||
#define PACKETBUF_ATTR_TTL 20
|
||||
#define PACKETBUF_ATTR_EPACKET_ID 21
|
||||
#define PACKETBUF_ATTR_EPACKET_TYPE 22
|
||||
#define PACKETBUF_ATTR_ERELIABLE 23
|
||||
|
||||
#define PACKETBUF_NUM_ATTRS 24
|
||||
|
||||
/* Addresses (indices into i_pktaddr) */
|
||||
|
||||
#define PACKETBUF_ADDR_SENDER 0
|
||||
#define PACKETBUF_ADDR_RECEIVER 1
|
||||
#define PACKETBUF_ADDR_ESENDER 2
|
||||
#define PACKETBUF_ADDR_ERECEIVER 3
|
||||
|
||||
#define PACKETBUF_NUM_ADDRS 4
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@ -242,6 +295,43 @@ struct sixlowpan_rime_sniffer_s; /* Foward reference */
|
||||
extern FAR struct sixlowpan_rime_sniffer_s *g_sixlowpan_sniffer;
|
||||
#endif
|
||||
|
||||
/* The following data values are used to hold intermediate settings while
|
||||
* processing IEEE802.15.4 frames. These globals are shared with incoming
|
||||
* and outgoing frame processing and possibly with mutliple IEEE802.15.4 MAC
|
||||
* devices. The network lock provides exclusive use of these globals
|
||||
* during that processing
|
||||
*/
|
||||
|
||||
/* A pointer to the rime buffer.
|
||||
*
|
||||
* We initialize it to the beginning of the rime buffer, then access
|
||||
* different fields by updating the offset ieee->g_rime_hdrlen.
|
||||
*/
|
||||
|
||||
extern FAR uint8_t *g_rimeptr;
|
||||
|
||||
/* g_uncomp_hdrlen is the length of the headers before compression (if HC2
|
||||
* is used this includes the UDP header in addition to the IP header).
|
||||
*/
|
||||
|
||||
extern uint8_t g_uncomp_hdrlen;
|
||||
|
||||
/* g_rime_hdrlen is the total length of (the processed) 6lowpan headers
|
||||
* (fragment headers, IPV6 or HC1, HC2, and HC1 and HC2 non compressed
|
||||
* fields).
|
||||
*/
|
||||
|
||||
extern uint8_t g_rime_hdrlen;
|
||||
|
||||
/* Offset first available byte for the payload after header region. */
|
||||
|
||||
uint8_t g_dataoffset;
|
||||
|
||||
/* Packet buffer metadata: Attributes and addresses */
|
||||
|
||||
extern uint16_t g_pktattrs[PACKETBUF_NUM_ATTRS];
|
||||
extern struct rimeaddr_s g_pktaddrs[PACKETBUF_NUM_ADDRS];
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@ -478,8 +568,7 @@ void sixlowpan_uncompresshdr_hc1(FAR struct net_driver_s *dev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_frame_hdralloc(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR struct iob_s *iob, int size);
|
||||
int sixlowpan_frame_hdralloc(FAR struct iob_s *iob, int size);
|
||||
|
||||
#endif /* CONFIG_NET_6LOWPAN */
|
||||
#endif /* _NET_SIXLOWPAN_SIXLOWPAN_INTERNAL_H */
|
||||
|
@ -57,10 +57,6 @@
|
||||
#include "nuttx/net/iob.h"
|
||||
#include "nuttx/net/netdev.h"
|
||||
#include "nuttx/net/ip.h"
|
||||
#include "nuttx/net/tcp.h"
|
||||
#include "nuttx/net/udp.h"
|
||||
#include "nuttx/net/icmpv6.h"
|
||||
#include "nuttx/net/sixlowpan.h"
|
||||
|
||||
#include "iob/iob.h"
|
||||
#include "netdev/netdev.h"
|
||||
@ -117,7 +113,7 @@ static void sixlowpan_set_pktattrs(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Set protocol in NETWORK_ID */
|
||||
|
||||
ieee->i_pktattrs[PACKETBUF_ATTR_NETWORK_ID] = ipv6->proto;
|
||||
g_pktattrs[PACKETBUF_ATTR_NETWORK_ID] = ipv6->proto;
|
||||
|
||||
/* Assign values to the channel attribute (port or type + code) */
|
||||
|
||||
@ -148,7 +144,7 @@ static void sixlowpan_set_pktattrs(FAR struct ieee802154_driver_s *ieee,
|
||||
attr = icmp->type << 8 | icmp->code;
|
||||
}
|
||||
|
||||
ieee->i_pktattrs[PACKETBUF_ATTR_CHANNEL] = attr;
|
||||
g_pktattrs[PACKETBUF_ATTR_CHANNEL] = attr;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -181,14 +177,14 @@ static void sixlowpan_compress_ipv6hdr(FAR struct ieee802154_driver_s *ieee,
|
||||
{
|
||||
/* Indicate the IPv6 dispatch and length */
|
||||
|
||||
*ieee->i_rimeptr = SIXLOWPAN_DISPATCH_IPV6;
|
||||
ieee->i_rime_hdrlen += SIXLOWPAN_IPV6_HDR_LEN;
|
||||
*g_rimeptr = SIXLOWPAN_DISPATCH_IPV6;
|
||||
g_rime_hdrlen += SIXLOWPAN_IPV6_HDR_LEN;
|
||||
|
||||
/* Copy the IPv6 header and adjust pointers */
|
||||
|
||||
memcpy(ieee->i_rimeptr + ieee->i_rime_hdrlen, ipv6, IPv6_HDRLEN);
|
||||
ieee->i_rime_hdrlen += IPv6_HDRLEN;
|
||||
ieee->i_uncomp_hdrlen += IPv6_HDRLEN;
|
||||
memcpy(g_rimeptr + g_rime_hdrlen, ipv6, IPv6_HDRLEN);
|
||||
g_rime_hdrlen += IPv6_HDRLEN;
|
||||
g_uncomp_hdrlen += IPv6_HDRLEN;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -217,8 +213,8 @@ static int sixlowpan_send_frame(FAR struct ieee802154_driver_s *ieee,
|
||||
*/
|
||||
#if 0 /* Just some notes of what needs to be done in interrupt handler */
|
||||
framer_hdrlen = sixlowpan_createframe(ieee, ieee->i_panid);
|
||||
memcpy(ieee->i_rimeptr + ieee->i_rime_hdrlen, (uint8_t *)ipv6 + ieee->i_uncomp_hdrlen, len - ieee->i_uncomp_hdrlen);
|
||||
iob->io_len = len - ieee->i_uncomp_hdrlen + ieee->i_rime_hdrlen;
|
||||
memcpy(g_rimeptr + g_rime_hdrlen, (uint8_t *)ipv6 + g_uncomp_hdrlen, len - g_uncomp_hdrlen);
|
||||
iob->io_len = len - g_uncomp_hdrlen + g_rime_hdrlen;
|
||||
#endif
|
||||
#warning Missing logic
|
||||
/* Notify the IEEE802.14.5 MAC driver that we have data to be sent */
|
||||
@ -274,20 +270,22 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
||||
struct rimeaddr_s dest;
|
||||
uint16_t outlen = 0;
|
||||
|
||||
/* Initialize device-specific data */
|
||||
/* Initialize global data. Locking the network guarantees that we have
|
||||
* exclusive use of the global values for intermediate calculations.
|
||||
*/
|
||||
|
||||
FRAME_RESET(ieee);
|
||||
ieee->i_uncomp_hdrlen = 0;
|
||||
ieee->i_rime_hdrlen = 0;
|
||||
FRAME_RESET();
|
||||
g_uncomp_hdrlen = 0;
|
||||
g_rime_hdrlen = 0;
|
||||
/* REVISIT: Do I need this rimeptr? */
|
||||
ieee->i_rimeptr = &dev->d_buf[PACKETBUF_HDR_SIZE];
|
||||
g_rimeptr = &dev->d_buf[PACKETBUF_HDR_SIZE];
|
||||
|
||||
/* Reset rime buffer, packet buffer metatadata */
|
||||
|
||||
memset(ieee->i_pktattrs, 0, PACKETBUF_NUM_ATTRS * sizeof(uint16_t));
|
||||
memset(ieee->i_pktaddrs, 0, PACKETBUF_NUM_ADDRS * sizeof(struct rimeaddr_s));
|
||||
memset(g_pktattrs, 0, PACKETBUF_NUM_ATTRS * sizeof(uint16_t));
|
||||
memset(g_pktaddrs, 0, PACKETBUF_NUM_ADDRS * sizeof(struct rimeaddr_s));
|
||||
|
||||
ieee->i_pktattrs[PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS] =
|
||||
g_pktattrs[PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS] =
|
||||
CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS;
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_SNIFFER
|
||||
@ -295,10 +293,10 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
||||
{
|
||||
/* Reset rime buffer, packet buffer metatadata */
|
||||
|
||||
memset(ieee->i_pktattrs, 0, PACKETBUF_NUM_ATTRS * sizeof(uint16_t));
|
||||
memset(ieee->i_pktaddrs, 0, PACKETBUF_NUM_ADDRS * sizeof(struct rimeaddr_s));
|
||||
memset(g_pktattrs, 0, PACKETBUF_NUM_ATTRS * sizeof(uint16_t));
|
||||
memset(g_pktaddrs, 0, PACKETBUF_NUM_ADDRS * sizeof(struct rimeaddr_s));
|
||||
|
||||
ieee->i_pktattrs[PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS] =
|
||||
g_pktattrs[PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS] =
|
||||
CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS;
|
||||
|
||||
/* Call the attribution when the callback comes, but set attributes here */
|
||||
@ -309,10 +307,10 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Reset rime buffer, packet buffer metatadata */
|
||||
|
||||
memset(ieee->i_pktattrs, 0, PACKETBUF_NUM_ATTRS * sizeof(uint16_t));
|
||||
memset(ieee->i_pktaddrs, 0, PACKETBUF_NUM_ADDRS * sizeof(struct rimeaddr_s));
|
||||
memset(g_pktattrs, 0, PACKETBUF_NUM_ATTRS * sizeof(uint16_t));
|
||||
memset(g_pktaddrs, 0, PACKETBUF_NUM_ADDRS * sizeof(struct rimeaddr_s));
|
||||
|
||||
ieee->i_pktattrs[PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS] =
|
||||
g_pktattrs[PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS] =
|
||||
CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS;
|
||||
|
||||
/* Set stream mode for all TCP packets, except FIN packets. */
|
||||
@ -324,11 +322,11 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
||||
if ((tcp->flags & TCP_FIN) == 0 &&
|
||||
(tcp->flags & TCP_CTL) != TCP_ACK)
|
||||
{
|
||||
ieee->i_pktattrs[PACKETBUF_ATTR_PACKET_TYPE] = PACKETBUF_ATTR_PACKET_TYPE_STREAM;
|
||||
g_pktattrs[PACKETBUF_ATTR_PACKET_TYPE] = PACKETBUF_ATTR_PACKET_TYPE_STREAM;
|
||||
}
|
||||
else if ((tcp->flags & TCP_FIN) == TCP_FIN)
|
||||
{
|
||||
ieee->i_pktattrs[PACKETBUF_ATTR_PACKET_TYPE] = PACKETBUF_ATTR_PACKET_TYPE_STREAM_END;
|
||||
g_pktattrs[PACKETBUF_ATTR_PACKET_TYPE] = PACKETBUF_ATTR_PACKET_TYPE_STREAM_END;
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,9 +366,9 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
||||
sixlowpan_compress_ipv6hdr(ieee, ipv6);
|
||||
}
|
||||
|
||||
ninfo("Header of len %d\n", ieee->i_rime_hdrlen);
|
||||
ninfo("Header of len %d\n", g_rime_hdrlen);
|
||||
|
||||
rimeaddr_copy(&ieee->i_pktaddrs[PACKETBUF_ADDR_RECEIVER], &dest);
|
||||
rimeaddr_copy(&g_pktaddrs[PACKETBUF_ADDR_RECEIVER], &dest);
|
||||
|
||||
/* Pre-calculate frame header length. */
|
||||
|
||||
@ -385,9 +383,9 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Check if we need to fragment the packet into several frames */
|
||||
|
||||
if ((int)len - (int)ieee->i_uncomp_hdrlen >
|
||||
if ((int)len - (int)g_uncomp_hdrlen >
|
||||
(int)CONFIG_NET_6LOWPAN_MAXPAYLOAD - framer_hdrlen -
|
||||
(int)ieee->i_rime_hdrlen)
|
||||
(int)g_rime_hdrlen)
|
||||
{
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
/* ieee->i_framelist will hold the generated frames; frames will be
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "nuttx/net/net.h"
|
||||
#include "nuttx/net/sixlowpan.h"
|
||||
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
|
@ -44,8 +44,6 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include "nuttx/net/netdev.h"
|
||||
#include "nuttx/net/tcp.h"
|
||||
#include "nuttx/net/sixlowpan.h"
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
#include "socket/socket.h"
|
||||
|
@ -44,8 +44,6 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include "nuttx/net/netdev.h"
|
||||
#include "nuttx/net/udp.h"
|
||||
#include "nuttx/net/sixlowpan.h"
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
#include "socket/socket.h"
|
||||
|
@ -51,10 +51,10 @@
|
||||
* Content Offset
|
||||
* +------------------+ 0
|
||||
* | Frame Header |
|
||||
* +------------------+ i_dataoffset
|
||||
* +------------------+ g_dataoffset
|
||||
* | Procotol Headers |
|
||||
* | Data Payload |
|
||||
* +------------------+ io_len
|
||||
* +------------------+ iob->io_len
|
||||
* | Unused |
|
||||
* +------------------+ CONFIG_NET_6LOWPAN_FRAMELEN
|
||||
*/
|
||||
@ -68,8 +68,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "nuttx/net/sixlowpan.h"
|
||||
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
@ -86,13 +84,12 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_frame_hdralloc(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR struct iob_s *iob, int size)
|
||||
int sixlowpan_frame_hdralloc(FAR struct iob_s *iob, int size)
|
||||
{
|
||||
if (size <= FRAME_REMAINING(ieee, iob))
|
||||
if (size <= FRAME_REMAINING(iob))
|
||||
{
|
||||
ieee->i_dataoffset += size;
|
||||
iob->io_len += size;
|
||||
g_dataoffset += size;
|
||||
iob->io_len += size;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user