From 3b21545480b53ca401491ac19ffd197f5258b659 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 5 Apr 2017 08:40:30 -0600 Subject: [PATCH] sixlowpan: Minor reorganization to removed some unused global varialbes and structure fields. --- net/sixlowpan/sixlowpan_framelist.c | 1 - net/sixlowpan/sixlowpan_framer.c | 45 +++++++---------------------- net/sixlowpan/sixlowpan_globals.c | 4 --- net/sixlowpan/sixlowpan_internal.h | 35 ---------------------- net/sixlowpan/sixlowpan_utils.c | 34 ---------------------- 5 files changed, 11 insertions(+), 108 deletions(-) diff --git a/net/sixlowpan/sixlowpan_framelist.c b/net/sixlowpan/sixlowpan_framelist.c index 11a98274ad..bd4dd2e8eb 100644 --- a/net/sixlowpan/sixlowpan_framelist.c +++ b/net/sixlowpan/sixlowpan_framelist.c @@ -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; diff --git a/net/sixlowpan/sixlowpan_framer.c b/net/sixlowpan/sixlowpan_framer.c index 1adad943ab..b0953db648 100644 --- a/net/sixlowpan/sixlowpan_framer.c +++ b/net/sixlowpan/sixlowpan_framer.c @@ -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 */ diff --git a/net/sixlowpan/sixlowpan_globals.c b/net/sixlowpan/sixlowpan_globals.c index 274ef47fa7..8f48ade9f2 100644 --- a/net/sixlowpan/sixlowpan_globals.c +++ b/net/sixlowpan/sixlowpan_globals.c @@ -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]; diff --git a/net/sixlowpan/sixlowpan_internal.h b/net/sixlowpan/sixlowpan_internal.h index 4a221f4fa9..8f3e52dfd3 100644 --- a/net/sixlowpan/sixlowpan_internal.h +++ b/net/sixlowpan/sixlowpan_internal.h @@ -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 diff --git a/net/sixlowpan/sixlowpan_utils.c b/net/sixlowpan/sixlowpan_utils.c index 1ec8eec2b6..3dcf757bfa 100644 --- a/net/sixlowpan/sixlowpan_utils.c +++ b/net/sixlowpan/sixlowpan_utils.c @@ -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 *