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 struct sixlowpan_tagaddr_s *destmac)
|
||||
{
|
||||
struct packet_metadata_s pktmeta;
|
||||
struct ieee802154_frame_meta_s meta;
|
||||
FAR struct iob_s *iob;
|
||||
FAR uint8_t *fptr;
|
||||
@ -232,8 +233,8 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Reset frame meta data */
|
||||
|
||||
memset(&g_packet_meta, 0, sizeof(struct packet_metadata_s));
|
||||
g_packet_meta.xmits = CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS;
|
||||
memset(&pktmeta, 0, sizeof(struct packet_metadata_s));
|
||||
pktmeta.xmits = CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS;
|
||||
|
||||
/* 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 &&
|
||||
(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)
|
||||
{
|
||||
g_packet_meta.type = FRAME_ATTR_TYPE_STREAM_END;
|
||||
pktmeta.type = FRAME_ATTR_TYPE_STREAM_END;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -288,22 +289,22 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
g_packet_meta.sextended = TRUE;
|
||||
sixlowpan_eaddrcopy(g_packet_meta.source.eaddr.u8,
|
||||
pktmeta.sextended = TRUE;
|
||||
sixlowpan_eaddrcopy(pktmeta.source.eaddr.u8,
|
||||
&ieee->i_dev.d_mac.ieee802154);
|
||||
#else
|
||||
sixlowpan_saddrcopy(g_packet_meta.source.saddr.u8,
|
||||
sixlowpan_saddrcopy(pktmeta.source.saddr.u8,
|
||||
&ieee->i_dev.d_mac.ieee802154);
|
||||
#endif
|
||||
|
||||
if (destmac->extended)
|
||||
{
|
||||
g_packet_meta.dextended = TRUE;
|
||||
sixlowpan_eaddrcopy(g_packet_meta.dest.eaddr.u8, destmac->u.eaddr.u8);
|
||||
pktmeta.dextended = TRUE;
|
||||
sixlowpan_eaddrcopy(pktmeta.dest.eaddr.u8, destmac->u.eaddr.u8);
|
||||
}
|
||||
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.
|
||||
@ -312,15 +313,15 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
* PAN IDs are the same.
|
||||
*/
|
||||
|
||||
g_packet_meta.dpanid = 0xffff;
|
||||
(void)sixlowpan_src_panid(ieee, &g_packet_meta.dpanid);
|
||||
pktmeta.dpanid = 0xffff;
|
||||
(void)sixlowpan_src_panid(ieee, &pktmeta.dpanid);
|
||||
|
||||
/* 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
|
||||
* 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -137,9 +137,10 @@ static inline bool sixlowpan_eaddrnull(FAR uint8_t *eaddr)
|
||||
* data structure that we need to interface with the IEEE802.15.4 MAC.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ieee - IEEE 802.15.4 MAC driver state reference.
|
||||
* meta - Location to return the corresponding meta data.
|
||||
* paylen - The size of the data payload to be sent.
|
||||
* 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.
|
||||
* paylen - The size of the data payload to be sent.
|
||||
*
|
||||
* Returned Value:
|
||||
* Ok is returned on success; Othewise a negated errno value is returned.
|
||||
@ -150,6 +151,7 @@ static inline bool sixlowpan_eaddrnull(FAR uint8_t *eaddr)
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR const struct packet_metadata_s *pktmeta,
|
||||
FAR struct ieee802154_frame_meta_s *meta,
|
||||
uint16_t paylen)
|
||||
{
|
||||
@ -161,23 +163,23 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Source address mode */
|
||||
|
||||
meta->src_addr_mode = g_packet_meta.sextended != 0?
|
||||
meta->src_addr_mode = pktmeta->sextended != 0?
|
||||
IEEE802154_ADDRMODE_EXTENDED :
|
||||
IEEE802154_ADDRMODE_SHORT;
|
||||
|
||||
/* Check for a broadcast destination address (all zero) */
|
||||
|
||||
if (g_packet_meta.dextended != 0)
|
||||
if (pktmeta->dextended != 0)
|
||||
{
|
||||
/* Extended destination address mode */
|
||||
|
||||
rcvrnull = sixlowpan_eaddrnull(g_packet_meta.dest.eaddr.u8);
|
||||
rcvrnull = sixlowpan_eaddrnull(pktmeta->dest.eaddr.u8);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Short destination address mode */
|
||||
|
||||
rcvrnull = sixlowpan_saddrnull(g_packet_meta.dest.saddr.u8);
|
||||
rcvrnull = sixlowpan_saddrnull(pktmeta->dest.saddr.u8);
|
||||
}
|
||||
|
||||
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.saddr = 0;
|
||||
}
|
||||
else if (g_packet_meta.dextended != 0)
|
||||
else if (pktmeta->dextended != 0)
|
||||
{
|
||||
/* Extended destination address mode */
|
||||
|
||||
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
|
||||
{
|
||||
/* Short destination address mode */
|
||||
|
||||
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
|
||||
* 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;
|
||||
|
||||
/* 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 */
|
||||
|
@ -212,10 +212,6 @@ extern uint8_t g_uncomp_hdrlen;
|
||||
|
||||
extern uint8_t g_frame_hdrlen;
|
||||
|
||||
/* Packet buffer metadata: Attributes and addresses */
|
||||
|
||||
extern struct packet_metadata_s g_packet_meta;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@ -278,9 +274,10 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
||||
* data structure that we need to interface with the IEEE802.15.4 MAC.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ieee - IEEE 802.15.4 MAC driver state reference.
|
||||
* meta - Location to return the corresponding meta data.
|
||||
* paylen - The size of the data payload to be sent.
|
||||
* 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.
|
||||
* paylen - The size of the data payload to be sent.
|
||||
*
|
||||
* Returned Value:
|
||||
* Ok is returned on success; Othewise a negated errno value is returned.
|
||||
@ -291,6 +288,7 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR const struct packet_metadata_s *pktmeta,
|
||||
FAR struct ieee802154_frame_meta_s *meta,
|
||||
uint16_t paylen);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user