6loWPAN: Design simplications; also remove unused utility function.

This commit is contained in:
Gregory Nutt
2017-05-04 17:16:45 -06:00
parent d385f46130
commit 128936d9a6
4 changed files with 10 additions and 71 deletions
+8 -27
View File
@@ -317,7 +317,8 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
(void)sixlowpan_src_panid(ieee, &g_packet_meta.dpanid); (void)sixlowpan_src_panid(ieee, &g_packet_meta.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. * 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, &meta, 0);
@@ -533,32 +534,18 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
* frame which is not a fragment from this sequence from intervening. * frame which is not a fragment from this sequence from intervening.
*/ */
paysize = 0;
for (iob = qhead; iob != NULL; iob = qhead) for (iob = qhead; iob != NULL; iob = qhead)
{ {
uint16_t newsize;
/* Remove the IOB from the list */ /* Remove the IOB from the list */
qhead = iob->io_flink; qhead = iob->io_flink;
iob->io_flink = NULL; iob->io_flink = NULL;
/* Re-construct the MAC meta data structure using the correct /* Update the MSDU length in the metadata */
* payload size for this frame (if it is different than the
* payload size of the previous frame).
*/
newsize = iob->io_len - iob->io_offset; meta.msdu_length = iob->io_len - iob->io_offset;
if (newsize != paysize)
{
ret = sixlowpan_meta_data(ieee, &meta, newsize);
if (ret < 0)
{
nerr("ERROR: sixlowpan_meta_data() failed: %d\n", ret);
}
paysize = newsize; /* And submit the frame to the MAC */
}
ret = sixlowpan_frame_submit(ieee, &meta, iob); ret = sixlowpan_frame_submit(ieee, &meta, iob);
if (ret < 0) if (ret < 0)
@@ -594,17 +581,11 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
sixlowpan_dumpbuffer("Outgoing frame", sixlowpan_dumpbuffer("Outgoing frame",
(FAR const uint8_t *)iob->io_data, iob->io_len); (FAR const uint8_t *)iob->io_data, iob->io_len);
/* Re-construct the MAC meta data structure using the correct payload /* Update the MSDU length in the metadata */
* size for this frame.
*/
ret = sixlowpan_meta_data(ieee, &meta, iob->io_len - iob->io_offset); meta.msdu_length = iob->io_len - iob->io_offset;
if (ret < 0)
{
nerr("ERROR: sixlowpan_meta_data() failed: %d\n", ret);
}
/* Submit the frame to the MAC */ /* And submit the frame to the MAC */
ret = sixlowpan_frame_submit(ieee, &meta, iob); ret = sixlowpan_frame_submit(ieee, &meta, iob);
if (ret < 0) if (ret < 0)
+1 -1
View File
@@ -316,7 +316,7 @@ static void uncompress_addr(FAR net_ipv6addr_t ipaddr, uint8_t const prefix[],
{ {
/* No IID based configuration if no prefix and no data => unspec */ /* No IID based configuration if no prefix and no data => unspec */
nwarn("WARNING: No IID based configuration\n") nwarn("WARNING: No IID based configuration\n");
} }
ninfo("Uncompressing %d + %d => %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", ninfo("Uncompressing %d + %d => %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
+1 -7
View File
@@ -511,13 +511,9 @@ int sixlowpan_uncompresshdr_hc1(uint16_t iplen, FAR struct iob_s *iob,
#endif #endif
/**************************************************************************** /****************************************************************************
* Name: sixlowpan_islinklocal, sixlowpan_ipfromaddr, sixlowpan_addrfromip, * Name: sixlowpan_islinklocal, sixlowpan_addrfromip, and sixlowpan_ismacbased
* and sixlowpan_ismacbased
* *
* Description: * Description:
* sixlowpan_ipfromaddr: Create a link local IPv6 address from an IEEE
* 802.15.4 address.
*
* sixlowpan_addrfromip: Extract the IEEE 802.15.14 address from a link * sixlowpan_addrfromip: Extract the IEEE 802.15.14 address from a link
* local IPv6 address. * local IPv6 address.
* *
@@ -533,8 +529,6 @@ int sixlowpan_uncompresshdr_hc1(uint16_t iplen, FAR struct iob_s *iob,
#define sixlowpan_islinklocal(ipaddr) ((ipaddr)[0] == NTOHS(0xfe80)) #define sixlowpan_islinklocal(ipaddr) ((ipaddr)[0] == NTOHS(0xfe80))
void sixlowpan_ipfromaddr(FAR const struct sixlowpan_addr_s *addr,
net_ipv6addr_t ipaddr);
void sixlowpan_addrfromip(const net_ipv6addr_t ipaddr, void sixlowpan_addrfromip(const net_ipv6addr_t ipaddr,
FAR struct sixlowpan_addr_s *addr); FAR struct sixlowpan_addr_s *addr);
bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr, bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
-36
View File
@@ -67,40 +67,6 @@
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Name: sixlowpan_ipfromaddr
*
* Description:
* Create a link local IPv6 address from an IEEE 802.15.4 address:
*
* 128 112 96 80 64 48 32 16
* ---- ---- ---- ---- ---- ---- ---- ----
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte address IEEE 48-bit MAC
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte address IEEE EUI-64
*
****************************************************************************/
void sixlowpan_ipfromaddr(FAR const struct sixlowpan_addr_s *addr,
net_ipv6addr_t ipaddr)
{
/* We consider only links with IEEE EUI-64 identifier or IEEE 48-bit MAC
* addresses.
*/
memset(ipaddr, 0, sizeof(net_ipv6addr_t));
ipaddr[0] = HTONS(0xfe80);
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
memcpy(&ipaddr[4], addr, NET_6LOWPAN_ADDRSIZE);
ipaddr[4] ^= HTONS(0x0200);
#else
ipaddr[5] = HTONS(0x00ff);
ipaddr[6] = HTONS(0xfe00);
memcpy(&ipaddr[7], addr, NET_6LOWPAN_ADDRSIZE);
ipaddr[7] ^= HTONS(0x0200);
#endif
}
/**************************************************************************** /****************************************************************************
* Name: sixlowpan_addrfromip * Name: sixlowpan_addrfromip
* *
@@ -117,8 +83,6 @@ void sixlowpan_ipfromaddr(FAR const struct sixlowpan_addr_s *addr,
void sixlowpan_addrfromip(const net_ipv6addr_t ipaddr, void sixlowpan_addrfromip(const net_ipv6addr_t ipaddr,
FAR struct sixlowpan_addr_s *addr) FAR struct sixlowpan_addr_s *addr)
{ {
/* REVISIT: See notes about 2 byte addresses in sixlowpan_ipfromaddr() */
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80)); DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR #ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR