PktRadion/6LoWPAN: Fix more issues related to single byte radio addressing.
This commit is contained in:
parent
e4f3e32d7b
commit
678b63c887
@ -21,6 +21,8 @@ CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DISABLE_POLL=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_EXAMPLES_NETTEST_DAEMON_STACKSIZE=4096
|
||||
CONFIG_EXAMPLES_NETTEST_LOOPBACK=y
|
||||
CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO=61616
|
||||
CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_1=0xfe80
|
||||
CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_6=0x00ff
|
||||
|
@ -392,6 +392,9 @@ static void uncompress_addr(FAR const struct netdev_varaddr_s *addr,
|
||||
bool usemac = (prefpost & 0x0100) != 0;
|
||||
uint8_t prefcount = (prefpost >> 4) & 0xf;
|
||||
uint8_t postcount = prefpost & 0x0f;
|
||||
int destndx;
|
||||
int endndx;
|
||||
int i;
|
||||
|
||||
/* The value 16 is encoded as 0xf in the 4 bit-fields. */
|
||||
|
||||
@ -443,7 +446,7 @@ static void uncompress_addr(FAR const struct netdev_varaddr_s *addr,
|
||||
|
||||
if (postcount > 0)
|
||||
{
|
||||
if (postcount == 2 && prefcount < 11)
|
||||
if (postcount <= 2 && prefcount < 11)
|
||||
{
|
||||
/* 16 bits uncompression ipaddr=0000:00ff:fe00:XXXX */
|
||||
|
||||
@ -451,14 +454,13 @@ static void uncompress_addr(FAR const struct netdev_varaddr_s *addr,
|
||||
ipaddr[6] = HTONS(0xfe00);
|
||||
}
|
||||
|
||||
/* Handle the even bytes in the address */
|
||||
/* If the postcount is even then take extra care with endian-ness */
|
||||
|
||||
if ((postcount & 1) == 0)
|
||||
{
|
||||
int destndx = 8 - (postcount >> 1);
|
||||
int i;
|
||||
destndx = 8 - (postcount >> 1);
|
||||
endndx = 8 - (postcount & 1);
|
||||
|
||||
for (i = destndx; i < 8; i++)
|
||||
for (i = destndx; i < endndx; i++)
|
||||
{
|
||||
/* Big-endian, network order */
|
||||
|
||||
@ -466,22 +468,18 @@ static void uncompress_addr(FAR const struct netdev_varaddr_s *addr,
|
||||
srcptr += 2;
|
||||
}
|
||||
|
||||
/* Handle any remaining odd byte */
|
||||
|
||||
if ((postcount & 1) != 0)
|
||||
{
|
||||
ipaddr[7] = (uint16_t)(*srcptr) << 8;
|
||||
}
|
||||
|
||||
/* If the was a standard MAC based address then toggle */
|
||||
|
||||
if (fullmac)
|
||||
{
|
||||
ipaddr[destndx] ^= 0x0200;
|
||||
}
|
||||
}
|
||||
|
||||
/* postcount is odd... REVISIT: I am not sure about bye ordering. */
|
||||
|
||||
else
|
||||
{
|
||||
FAR uint8_t *destptr = (FAR uint8_t *)&ipaddr[0];
|
||||
int offset = 16 - postcount;
|
||||
|
||||
memcpy(&destptr[offset], srcptr, postcount);
|
||||
ipaddr[7] ^= 0x0200;
|
||||
}
|
||||
|
||||
/* If we took the data from packet, then update the packet pointer */
|
||||
|
Loading…
Reference in New Issue
Block a user