6LoWPAN: Fix a misconception about HC06 16-bit IPv6 address compression.

This commit is contained in:
Gregory Nutt 2017-06-30 10:08:44 -06:00
parent af8c5c86f3
commit 76e6dba2e4

View File

@ -354,7 +354,6 @@ static void uncompress_addr(FAR const struct ieee802154_addr_s *addr,
FAR net_ipv6addr_t ipaddr)
{
FAR const uint8_t *srcptr;
bool fullmac = false;
bool usemac = (prefpost & 0x0100) != 0;
uint8_t prefcount = (prefpost >> 4) & 0xf;
uint8_t postcount = prefpost & 0x0f;
@ -384,12 +383,6 @@ static void uncompress_addr(FAR const struct ieee802154_addr_s *addr,
{
postcount = addrsize;
}
/* If we are converting the entire MAC address, then we need to some some
* special bit operations.
*/
fullmac = (postcount == addrsize);
}
/* Copy any prefix */
@ -412,6 +405,9 @@ static void uncompress_addr(FAR const struct ieee802154_addr_s *addr,
if (postcount > 0)
{
FAR uint8_t *destptr = (FAR uint8_t *)&ipaddr[0];
int offset = 16 - postcount;
if (postcount == 2 && prefcount < 11)
{
/* 16 bits uncompression ipaddr=0000:00ff:fe00:XXXX */
@ -420,36 +416,7 @@ static void uncompress_addr(FAR const struct ieee802154_addr_s *addr,
ipaddr[6] = HTONS(0xfe00);
}
/* If the postcount is even then take extra care with endian-ness */
if ((postcount & 1) == 0)
{
int destndx = 8 - (postcount >> 1);
int i;
for (i = destndx; i < 8; i++)
{
ipaddr[i] = (uint16_t)srcptr[0] << 8 | (uint16_t)srcptr[1];
srcptr += 2;
}
/* If the was a standard MAC based address then toggle */
if (fullmac)
{
ipaddr[destndx] ^= 0x200;
}
}
/* postcount is odd... */
else
{
FAR uint8_t *destptr = (FAR uint8_t *)&ipaddr[0];
int offset = 16 - postcount;
memcpy(&destptr[offset], srcptr, postcount);
}
/* If we took the data from packet, then update the packet pointer */