6loWPAN: packet meta data does not need to be a global variable
This commit is contained in:
parent
b0b0c7ac49
commit
18eaf52e35
@ -211,6 +211,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
|||||||
FAR const void *buf, size_t buflen,
|
FAR const void *buf, size_t buflen,
|
||||||
FAR const struct sixlowpan_tagaddr_s *destmac)
|
FAR const struct sixlowpan_tagaddr_s *destmac)
|
||||||
{
|
{
|
||||||
|
struct packet_metadata_s pktmeta;
|
||||||
struct ieee802154_frame_meta_s meta;
|
struct ieee802154_frame_meta_s meta;
|
||||||
FAR struct iob_s *iob;
|
FAR struct iob_s *iob;
|
||||||
FAR uint8_t *fptr;
|
FAR uint8_t *fptr;
|
||||||
@ -232,8 +233,8 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
|||||||
|
|
||||||
/* Reset frame meta data */
|
/* Reset frame meta data */
|
||||||
|
|
||||||
memset(&g_packet_meta, 0, sizeof(struct packet_metadata_s));
|
memset(&pktmeta, 0, sizeof(struct packet_metadata_s));
|
||||||
g_packet_meta.xmits = CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS;
|
pktmeta.xmits = CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS;
|
||||||
|
|
||||||
/* Set stream mode for all TCP packets, except FIN packets. */
|
/* Set stream mode for all TCP packets, except FIN packets. */
|
||||||
|
|
||||||
@ -246,11 +247,11 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
|||||||
if ((tcp->flags & TCP_FIN) == 0 &&
|
if ((tcp->flags & TCP_FIN) == 0 &&
|
||||||
(tcp->flags & TCP_CTL) != TCP_ACK)
|
(tcp->flags & TCP_CTL) != TCP_ACK)
|
||||||
{
|
{
|
||||||
g_packet_meta.type = FRAME_ATTR_TYPE_STREAM;
|
pktmeta.type = FRAME_ATTR_TYPE_STREAM;
|
||||||
}
|
}
|
||||||
else if ((tcp->flags & TCP_FIN) == TCP_FIN)
|
else if ((tcp->flags & TCP_FIN) == TCP_FIN)
|
||||||
{
|
{
|
||||||
g_packet_meta.type = FRAME_ATTR_TYPE_STREAM_END;
|
pktmeta.type = FRAME_ATTR_TYPE_STREAM_END;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -288,22 +289,22 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||||
g_packet_meta.sextended = TRUE;
|
pktmeta.sextended = TRUE;
|
||||||
sixlowpan_eaddrcopy(g_packet_meta.source.eaddr.u8,
|
sixlowpan_eaddrcopy(pktmeta.source.eaddr.u8,
|
||||||
&ieee->i_dev.d_mac.ieee802154);
|
&ieee->i_dev.d_mac.ieee802154);
|
||||||
#else
|
#else
|
||||||
sixlowpan_saddrcopy(g_packet_meta.source.saddr.u8,
|
sixlowpan_saddrcopy(pktmeta.source.saddr.u8,
|
||||||
&ieee->i_dev.d_mac.ieee802154);
|
&ieee->i_dev.d_mac.ieee802154);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (destmac->extended)
|
if (destmac->extended)
|
||||||
{
|
{
|
||||||
g_packet_meta.dextended = TRUE;
|
pktmeta.dextended = TRUE;
|
||||||
sixlowpan_eaddrcopy(g_packet_meta.dest.eaddr.u8, destmac->u.eaddr.u8);
|
sixlowpan_eaddrcopy(pktmeta.dest.eaddr.u8, destmac->u.eaddr.u8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sixlowpan_saddrcopy(g_packet_meta.dest.saddr.u8, destmac->u.saddr.u8);
|
sixlowpan_saddrcopy(pktmeta.dest.saddr.u8, destmac->u.saddr.u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the destination PAN ID.
|
/* Get the destination PAN ID.
|
||||||
@ -312,15 +313,15 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
|||||||
* PAN IDs are the same.
|
* PAN IDs are the same.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
g_packet_meta.dpanid = 0xffff;
|
pktmeta.dpanid = 0xffff;
|
||||||
(void)sixlowpan_src_panid(ieee, &g_packet_meta.dpanid);
|
(void)sixlowpan_src_panid(ieee, &pktmeta.dpanid);
|
||||||
|
|
||||||
/* Based on the collected attributes and addresses, construct the MAC meta
|
/* Based on the collected attributes and addresses, construct the MAC meta
|
||||||
* data structure that we need to interface with the IEEE802.15.4 MAC (we
|
* data structure that we need to interface with the IEEE802.15.4 MAC (we
|
||||||
* will update the MSDU payload size when the IOB has been setup).
|
* will update the MSDU payload size when the IOB has been setup).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = sixlowpan_meta_data(ieee, &meta, 0);
|
ret = sixlowpan_meta_data(ieee, &pktmeta, &meta, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
nerr("ERROR: sixlowpan_meta_data() failed: %d\n", ret);
|
nerr("ERROR: sixlowpan_meta_data() failed: %d\n", ret);
|
||||||
|
@ -100,7 +100,7 @@ static bool sixlowpan_anyaddrnull(FAR uint8_t *addr, uint8_t addrlen)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static inline bool sixlowpan_saddrnull(FAR uint8_t *saddr)
|
static inline bool sixlowpan_saddrnull(FAR const uint8_t *saddr)
|
||||||
{
|
{
|
||||||
return sixlowpan_anyaddrnull(saddr, NET_6LOWPAN_SADDRSIZE);
|
return sixlowpan_anyaddrnull(saddr, NET_6LOWPAN_SADDRSIZE);
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ static inline bool sixlowpan_saddrnull(FAR uint8_t *saddr)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static inline bool sixlowpan_eaddrnull(FAR uint8_t *eaddr)
|
static inline bool sixlowpan_eaddrnull(FAR const uint8_t *eaddr)
|
||||||
{
|
{
|
||||||
return sixlowpan_anyaddrnull(eaddr, NET_6LOWPAN_EADDRSIZE);
|
return sixlowpan_anyaddrnull(eaddr, NET_6LOWPAN_EADDRSIZE);
|
||||||
}
|
}
|
||||||
@ -138,6 +138,7 @@ static inline bool sixlowpan_eaddrnull(FAR uint8_t *eaddr)
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* ieee - IEEE 802.15.4 MAC driver state reference.
|
* ieee - IEEE 802.15.4 MAC driver state reference.
|
||||||
|
* pktmeta - Meta-data specific to the current outgoing frame
|
||||||
* meta - Location to return the corresponding meta data.
|
* meta - Location to return the corresponding meta data.
|
||||||
* paylen - The size of the data payload to be sent.
|
* paylen - The size of the data payload to be sent.
|
||||||
*
|
*
|
||||||
@ -150,6 +151,7 @@ static inline bool sixlowpan_eaddrnull(FAR uint8_t *eaddr)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
|
int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
|
||||||
|
FAR const struct packet_metadata_s *pktmeta,
|
||||||
FAR struct ieee802154_frame_meta_s *meta,
|
FAR struct ieee802154_frame_meta_s *meta,
|
||||||
uint16_t paylen)
|
uint16_t paylen)
|
||||||
{
|
{
|
||||||
@ -161,23 +163,23 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
|
|||||||
|
|
||||||
/* Source address mode */
|
/* Source address mode */
|
||||||
|
|
||||||
meta->src_addr_mode = g_packet_meta.sextended != 0?
|
meta->src_addr_mode = pktmeta->sextended != 0?
|
||||||
IEEE802154_ADDRMODE_EXTENDED :
|
IEEE802154_ADDRMODE_EXTENDED :
|
||||||
IEEE802154_ADDRMODE_SHORT;
|
IEEE802154_ADDRMODE_SHORT;
|
||||||
|
|
||||||
/* Check for a broadcast destination address (all zero) */
|
/* Check for a broadcast destination address (all zero) */
|
||||||
|
|
||||||
if (g_packet_meta.dextended != 0)
|
if (pktmeta->dextended != 0)
|
||||||
{
|
{
|
||||||
/* Extended destination address mode */
|
/* Extended destination address mode */
|
||||||
|
|
||||||
rcvrnull = sixlowpan_eaddrnull(g_packet_meta.dest.eaddr.u8);
|
rcvrnull = sixlowpan_eaddrnull(pktmeta->dest.eaddr.u8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Short destination address mode */
|
/* Short destination address mode */
|
||||||
|
|
||||||
rcvrnull = sixlowpan_saddrnull(g_packet_meta.dest.saddr.u8);
|
rcvrnull = sixlowpan_saddrnull(pktmeta->dest.saddr.u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rcvrnull)
|
if (rcvrnull)
|
||||||
@ -198,22 +200,22 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
|
|||||||
meta->dest_addr.mode = IEEE802154_ADDRMODE_SHORT;
|
meta->dest_addr.mode = IEEE802154_ADDRMODE_SHORT;
|
||||||
meta->dest_addr.saddr = 0;
|
meta->dest_addr.saddr = 0;
|
||||||
}
|
}
|
||||||
else if (g_packet_meta.dextended != 0)
|
else if (pktmeta->dextended != 0)
|
||||||
{
|
{
|
||||||
/* Extended destination address mode */
|
/* Extended destination address mode */
|
||||||
|
|
||||||
meta->dest_addr.mode = IEEE802154_ADDRMODE_EXTENDED;
|
meta->dest_addr.mode = IEEE802154_ADDRMODE_EXTENDED;
|
||||||
sixlowpan_eaddrcopy(&meta->dest_addr.eaddr, g_packet_meta.dest.eaddr.u8);
|
sixlowpan_eaddrcopy(&meta->dest_addr.eaddr, pktmeta->dest.eaddr.u8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Short destination address mode */
|
/* Short destination address mode */
|
||||||
|
|
||||||
meta->dest_addr.mode = IEEE802154_ADDRMODE_SHORT;
|
meta->dest_addr.mode = IEEE802154_ADDRMODE_SHORT;
|
||||||
sixlowpan_saddrcopy(&meta->dest_addr.saddr, g_packet_meta.dest.saddr.u8);
|
sixlowpan_saddrcopy(&meta->dest_addr.saddr, pktmeta->dest.saddr.u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
meta->dest_addr.panid = g_packet_meta.dpanid;
|
meta->dest_addr.panid = pktmeta->dpanid;
|
||||||
|
|
||||||
/* Handle associated with MSDU. Will increment once per packet, not
|
/* Handle associated with MSDU. Will increment once per packet, not
|
||||||
* necesarily per frame: The same MSDU handle will be used for each
|
* necesarily per frame: The same MSDU handle will be used for each
|
||||||
|
@ -67,18 +67,4 @@ uint8_t g_uncomp_hdrlen;
|
|||||||
|
|
||||||
uint8_t g_frame_hdrlen;
|
uint8_t g_frame_hdrlen;
|
||||||
|
|
||||||
/* In order to provide a customizable IEEE 802.15.4 MAC header, a structure
|
|
||||||
* of meta data is passed to the MAC network driver, struct
|
|
||||||
* ieee802154_frame_meta_s. Many of the settings in this meta data are
|
|
||||||
* fixed, deterimined by the 6loWPAN configuration. Other settings depend
|
|
||||||
* on the protocol used in the current packet or on chacteristics of the
|
|
||||||
* destination node.
|
|
||||||
*
|
|
||||||
* The following structure is used to summarize those per-packet
|
|
||||||
* customizations and, along, with the fixed configuratin settings,
|
|
||||||
* determines the full form of that meta data.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct packet_metadata_s g_packet_meta;
|
|
||||||
|
|
||||||
#endif /* CONFIG_NET_6LOWPAN */
|
#endif /* CONFIG_NET_6LOWPAN */
|
||||||
|
@ -212,10 +212,6 @@ extern uint8_t g_uncomp_hdrlen;
|
|||||||
|
|
||||||
extern uint8_t g_frame_hdrlen;
|
extern uint8_t g_frame_hdrlen;
|
||||||
|
|
||||||
/* Packet buffer metadata: Attributes and addresses */
|
|
||||||
|
|
||||||
extern struct packet_metadata_s g_packet_meta;
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -279,6 +275,7 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* ieee - IEEE 802.15.4 MAC driver state reference.
|
* ieee - IEEE 802.15.4 MAC driver state reference.
|
||||||
|
* pktmeta - Meta-data specific to the current outgoing frame
|
||||||
* meta - Location to return the corresponding meta data.
|
* meta - Location to return the corresponding meta data.
|
||||||
* paylen - The size of the data payload to be sent.
|
* paylen - The size of the data payload to be sent.
|
||||||
*
|
*
|
||||||
@ -291,6 +288,7 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
|
int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
|
||||||
|
FAR const struct packet_metadata_s *pktmeta,
|
||||||
FAR struct ieee802154_frame_meta_s *meta,
|
FAR struct ieee802154_frame_meta_s *meta,
|
||||||
uint16_t paylen);
|
uint16_t paylen);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user