sixlowpan: Minor reorganization to removed some unused global varialbes and structure fields.
This commit is contained in:
parent
3e6b92d5fa
commit
3b21545480
@ -180,7 +180,6 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
* exclusive use of the global values for intermediate calculations.
|
||||
*/
|
||||
|
||||
FRAME_RESET();
|
||||
g_uncomp_hdrlen = 0;
|
||||
g_frame_hdrlen = 0;
|
||||
|
||||
|
@ -287,7 +287,7 @@ static int sixlowpan_802154_hdrlen(FAR struct frame802154_s *finfo)
|
||||
****************************************************************************/
|
||||
|
||||
static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR struct iob_s *iob, uint16_t dest_panid,
|
||||
uint16_t dest_panid,
|
||||
FAR struct frame802154_s *params)
|
||||
{
|
||||
bool rcvrnull;
|
||||
@ -296,10 +296,6 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
memset(params, 0, sizeof(params));
|
||||
|
||||
/* Reset to an empty frame */
|
||||
|
||||
FRAME_RESET();
|
||||
|
||||
/* Build the FCF (Only non-zero elements need to be initialized). */
|
||||
|
||||
params->fcf.frame_type = FRAME802154_DATAFRAME;
|
||||
@ -368,14 +364,6 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
/* Set the source address to the node address assigned to the device */
|
||||
|
||||
rimeaddr_copy((struct rimeaddr_s *)¶ms->src_addr, &ieee->i_nodeaddr.u8);
|
||||
|
||||
/* Configure the (optional) payload address and length */
|
||||
|
||||
if (iob != NULL)
|
||||
{
|
||||
params->payload = FRAME_DATA_START(iob);
|
||||
params->payload_len = FRAME_DATA_SIZE(iob);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -402,13 +390,13 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_send_hdrlen(FAR struct ieee802154_driver_s *ieee,
|
||||
uint16_t dest_panid)
|
||||
uint16_t dest_panid)
|
||||
{
|
||||
struct frame802154_s params;
|
||||
|
||||
/* Set up the frame parameters */
|
||||
|
||||
sixlowpan_setup_params(ieee, NULL, dest_panid, ¶ms);
|
||||
sixlowpan_setup_params(ieee, dest_panid, ¶ms);
|
||||
|
||||
/* Return the length of the header */
|
||||
|
||||
@ -427,7 +415,7 @@ int sixlowpan_send_hdrlen(FAR struct ieee802154_driver_s *ieee,
|
||||
* the frame to send.
|
||||
* buf - Pointer to the buffer to use for the frame.
|
||||
* buflen - The length of the buffer to use for the frame.
|
||||
* finfo - I that specifies the frame to send.
|
||||
* finfo - Specifies the frame to send.
|
||||
*
|
||||
* Returned Value:
|
||||
* The length of the frame header or 0 if there was insufficient space in
|
||||
@ -539,33 +527,22 @@ int sixlowpan_framecreate(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR struct iob_s *iob, uint16_t dest_panid)
|
||||
{
|
||||
struct frame802154_s params;
|
||||
int len;
|
||||
int ret;
|
||||
int hdrlen;
|
||||
|
||||
/* Set up the frame parameters */
|
||||
|
||||
sixlowpan_setup_params(ieee, iob, dest_panid, ¶ms);
|
||||
sixlowpan_setup_params(ieee, dest_panid, ¶ms);
|
||||
|
||||
/* Get the length of the header */
|
||||
|
||||
len = sixlowpan_802154_hdrlen(¶ms);
|
||||
|
||||
/* Allocate space for the header in the frame buffer */
|
||||
|
||||
ret = sixlowpan_frame_hdralloc(iob, len);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Header too large: %u\n", len);
|
||||
return ret;
|
||||
}
|
||||
hdrlen = sixlowpan_802154_hdrlen(¶ms);
|
||||
|
||||
/* Then create the frame */
|
||||
|
||||
sixlowpan_802154_framecreate(¶ms, FRAME_HDR_START(iob), len);
|
||||
sixlowpan_802154_framecreate(¶ms, iob->io_data, hdrlen);
|
||||
|
||||
wlinfo("Frame type: %02x Data len: %d %u (%u)\n",
|
||||
params.fcf.frame_type, len, FRAME_DATA_SIZE(iob),
|
||||
FRAME_SIZE(ieee, iob));
|
||||
wlinfo("Frame type: %02x hdrlen: %d\n",
|
||||
params.fcf.frame_type, hdrlen);
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
wlinfo("Dest address: %02x:%02x\n",
|
||||
params.dest_addr[0], params.dest_addr[1]);
|
||||
@ -576,7 +553,7 @@ int sixlowpan_framecreate(FAR struct ieee802154_driver_s *ieee,
|
||||
params.dest_addr[6], params.dest_addr[7]);
|
||||
#endif
|
||||
|
||||
return len;
|
||||
return hdrlen;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_6LOWPAN */
|
||||
|
@ -76,10 +76,6 @@ uint8_t g_uncomp_hdrlen;
|
||||
|
||||
uint8_t g_frame_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];
|
||||
|
@ -215,25 +215,6 @@
|
||||
|
||||
#define PACKETBUF_NUM_ADDRS 4
|
||||
|
||||
/* Frame buffer helpers *****************************************************/
|
||||
|
||||
#define FRAME_RESET() \
|
||||
do \
|
||||
{ \
|
||||
g_dataoffset = 0; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define FRAME_HDR_START(iob) ((iob)->io_data)
|
||||
#define FRAME_HDR_SIZE(iob) g_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(iob) (CONFIG_NET_6LOWPAN_FRAMELEN - (iob)->io_len)
|
||||
#define FRAME_SIZE(ieee,iob) \
|
||||
((iob)->io_len)
|
||||
|
||||
/* Address compressibility test macros **************************************/
|
||||
|
||||
/* Check whether we can compress the IID in address 'a' to 16 bits. This is
|
||||
@ -407,8 +388,6 @@ struct frame802154_s
|
||||
uint16_t src_pid; /* Source PAN ID */
|
||||
uint8_t src_addr[8]; /* Source address */
|
||||
struct frame802154_aux_hdr_s aux_hdr; /* Aux security header */
|
||||
uint8_t *payload; /* Pointer to 802.15.4 frame payload */
|
||||
uint8_t payload_len; /* Length of payload field */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -452,10 +431,6 @@ extern uint8_t g_uncomp_hdrlen;
|
||||
|
||||
extern uint8_t g_frame_hdrlen;
|
||||
|
||||
/* Offset first available byte for the payload after header region. */
|
||||
|
||||
extern uint8_t g_dataoffset;
|
||||
|
||||
/* Packet buffer metadata: Attributes and addresses */
|
||||
|
||||
extern uint16_t g_pktattrs[PACKETBUF_NUM_ATTRS];
|
||||
@ -745,16 +720,6 @@ int sixlowpan_uncompresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR uint8_t *payptr);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_frame_hdralloc
|
||||
*
|
||||
* Description:
|
||||
* Allocate space for a header within the frame buffer (IOB).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_frame_hdralloc(FAR struct iob_s *iob, int size);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_islinklocal, sixlowpan_ipfromrime, sixlowpan_rimefromip,
|
||||
* and sixlowpan_ismacbased
|
||||
|
@ -45,20 +45,6 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* Frame Organization. The IOB data is retained in the io_data[] field of the
|
||||
* IOB structure like:
|
||||
*
|
||||
* Content Offset
|
||||
* +------------------+ 0
|
||||
* | Frame Header |
|
||||
* +------------------+ g_dataoffset
|
||||
* | Procotol Headers |
|
||||
* | Data Payload |
|
||||
* +------------------+ iob->io_len
|
||||
* | Unused |
|
||||
* +------------------+ CONFIG_NET_6LOWPAN_FRAMELEN
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
@ -79,26 +65,6 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_frame_hdralloc
|
||||
*
|
||||
* Description:
|
||||
* Allocate space for a header within the packet buffer (dev->d_buf).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_frame_hdralloc(FAR struct iob_s *iob, int size)
|
||||
{
|
||||
if (size <= FRAME_REMAINING(iob))
|
||||
{
|
||||
g_dataoffset += size;
|
||||
iob->io_len += size;
|
||||
return OK;
|
||||
}
|
||||
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_ipfromrime
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user