6loWPAN: Minor cleanup and re-verification of all compression modes after so menay recent changes.
This commit is contained in:
parent
88ec3d3aea
commit
c318072084
@ -220,7 +220,7 @@ static FAR struct sixlowpan_addrcontext_s *
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: compress_tagaddr and compress_laddr
|
* Name: comporess_ipaddr, compress_tagaddr, and compress_laddr
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Uncompress addresses based on a prefix and a postfix with zeroes in
|
* Uncompress addresses based on a prefix and a postfix with zeroes in
|
||||||
@ -230,20 +230,16 @@ static FAR struct sixlowpan_addrcontext_s *
|
|||||||
* prefpost takes a byte where the first nibble specify prefix count
|
* prefpost takes a byte where the first nibble specify prefix count
|
||||||
* and the second postfix count (NOTE: 15/0xf => 16 bytes copy).
|
* and the second postfix count (NOTE: 15/0xf => 16 bytes copy).
|
||||||
*
|
*
|
||||||
|
* compress_tagaddr() accepts a remote, variable length, taged MAC address;
|
||||||
|
* compress_laddr() accepts a local, fixed length MAC address.
|
||||||
|
* compress_ipaddr() is simply the common logic that does not depend on
|
||||||
|
* the size of the MAC address.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static uint8_t compress_tagaddr(FAR const net_ipv6addr_t ipaddr,
|
static uint8_t compress_ipaddr(FAR const net_ipv6addr_t ipaddr, uint8_t bitpos)
|
||||||
FAR const struct sixlowpan_tagaddr_s *macaddr,
|
|
||||||
uint8_t bitpos)
|
|
||||||
{
|
{
|
||||||
ninfo("ipaddr=%p macaddr=%p extended=%u bitpos=%u g_hc06ptr=%p\n",
|
if (SIXLOWPAN_IS_IID_16BIT_COMPRESSABLE(ipaddr))
|
||||||
ipaddr, macaddr, macaddr->extended, bitpos, g_hc06ptr);
|
|
||||||
|
|
||||||
if (sixlowpan_ismacbased(ipaddr, macaddr))
|
|
||||||
{
|
|
||||||
return 3 << bitpos; /* 0-bits */
|
|
||||||
}
|
|
||||||
else if (SIXLOWPAN_IS_IID_16BIT_COMPRESSABLE(ipaddr))
|
|
||||||
{
|
{
|
||||||
/* Compress IID to 16 bits: xxxx:xxxx:xxxx:xxxx:0000:00ff:fe00:XXXX */
|
/* Compress IID to 16 bits: xxxx:xxxx:xxxx:xxxx:0000:00ff:fe00:XXXX */
|
||||||
|
|
||||||
@ -261,21 +257,38 @@ static uint8_t compress_tagaddr(FAR const net_ipv6addr_t ipaddr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t compress_laddr(FAR const net_ipv6addr_t ipaddr,
|
static uint8_t compress_tagaddr(FAR const net_ipv6addr_t ipaddr,
|
||||||
FAR const struct sixlowpan_addr_s *macaddr,
|
FAR const struct sixlowpan_tagaddr_s *macaddr,
|
||||||
uint8_t bitpos)
|
uint8_t bitpos)
|
||||||
{
|
{
|
||||||
struct sixlowpan_tagaddr_s tagaddr;
|
ninfo("ipaddr=%p macaddr=%p extended=%u bitpos=%u g_hc06ptr=%p\n",
|
||||||
|
ipaddr, macaddr, macaddr->extended, bitpos, g_hc06ptr);
|
||||||
|
|
||||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
if (sixlowpan_ismacbased(ipaddr, macaddr))
|
||||||
tagaddr.extended = true;
|
{
|
||||||
sixlowpan_eaddrcopy(tagaddr.u.eaddr.u8, macaddr->u8);
|
return 3 << bitpos; /* 0-bits */
|
||||||
#else
|
}
|
||||||
tagaddr.extended = false;
|
else
|
||||||
sixlowpan_saddrcopy(tagaddr.u.saddr.u8, macaddr->u8);
|
{
|
||||||
#endif
|
return compress_ipaddr(ipaddr, bitpos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return compress_tagaddr(ipaddr, &tagaddr, bitpos);
|
static uint8_t compress_laddr(FAR const net_ipv6addr_t ipaddr,
|
||||||
|
FAR const struct sixlowpan_addr_s *macaddr,
|
||||||
|
uint8_t bitpos)
|
||||||
|
{
|
||||||
|
ninfo("ipaddr=%p macaddr=%p bitpos=%u g_hc06ptr=%p\n",
|
||||||
|
ipaddr, macaddr, bitpos, g_hc06ptr);
|
||||||
|
|
||||||
|
if (sixlowpan_isaddrbased(ipaddr, macaddr))
|
||||||
|
{
|
||||||
|
return 3 << bitpos; /* 0-bits */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return compress_ipaddr(ipaddr, bitpos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -642,9 +655,9 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
|
|||||||
ipv6->destipaddr[1] == 0 && ipv6->destipaddr[2] == 0 &&
|
ipv6->destipaddr[1] == 0 && ipv6->destipaddr[2] == 0 &&
|
||||||
ipv6->destipaddr[3] == 0)
|
ipv6->destipaddr[3] == 0)
|
||||||
{
|
{
|
||||||
iphc1 |= compress_laddr(ipv6->srcipaddr,
|
iphc1 |= compress_laddr(ipv6->srcipaddr,
|
||||||
&ieee->i_dev.d_mac.ieee802154,
|
&ieee->i_dev.d_mac.ieee802154,
|
||||||
SIXLOWPAN_IPHC_SAM_BIT);
|
SIXLOWPAN_IPHC_SAM_BIT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -129,7 +129,7 @@ void sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
|
|||||||
|
|
||||||
if (ipv6->vtc != 0x60 || ipv6->tcf != 0 || ipv6->flow != 0 ||
|
if (ipv6->vtc != 0x60 || ipv6->tcf != 0 || ipv6->flow != 0 ||
|
||||||
!sixlowpan_islinklocal(ipv6->srcipaddr) ||
|
!sixlowpan_islinklocal(ipv6->srcipaddr) ||
|
||||||
!sixlowpan_ismacbased(ipv6->srcipaddr, &ieee->i_dev.d_mac.ieee802154) ||
|
!sixlowpan_isaddrbased(ipv6->srcipaddr, &ieee->i_dev.d_mac.ieee802154) ||
|
||||||
!sixlowpan_islinklocal(ipv6->destipaddr) ||
|
!sixlowpan_islinklocal(ipv6->destipaddr) ||
|
||||||
!sixlowpan_ismacbased(ipv6->destipaddr, destmac) ||
|
!sixlowpan_ismacbased(ipv6->destipaddr, destmac) ||
|
||||||
(ipv6->proto != IP_PROTO_ICMP6 && ipv6->proto != IP_PROTO_UDP &&
|
(ipv6->proto != IP_PROTO_ICMP6 && ipv6->proto != IP_PROTO_UDP &&
|
||||||
|
@ -528,19 +528,27 @@ int sixlowpan_uncompresshdr_hc1(uint16_t iplen, FAR struct iob_s *iob,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sixlowpan_islinklocal, sixlowpan_addrfromip, and sixlowpan_ismacbased
|
* Name: sixlowpan_islinklocal, sixlowpan_addrfromip, and
|
||||||
|
* sixlowpan_ismacbased
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* sixlowpan_addrfromip: Extract the IEEE 802.15.14 address from a link
|
* sixlowpan_addrfromip(): Extract the IEEE 802.15.14 address from a MAC
|
||||||
* local IPv6 address.
|
* based IPv6 address. sixlowpan_addrfromip() is intended to handle a
|
||||||
|
* tagged address or any size; sixlowpan_saddrfromip() and
|
||||||
|
* sixlowpan_eaddrfromip() specifically handle short and extended
|
||||||
|
* addresses.
|
||||||
*
|
*
|
||||||
* sixlowpan_islinklocal and sixlowpan_ismacbased will return true for
|
* sixlowpan_islinklocal() and sixlowpan_ismacbased() will return true for
|
||||||
* address created in this fashion.
|
* address created in this fashion. sixlowpan_addrfromip() is intended to
|
||||||
|
* handle a tagged address or any size; sixlowpan_issaddrbased() and
|
||||||
|
* sixlowpan_iseaddrbased() specifically handle short and extended
|
||||||
|
* addresses. Local addresses are of a fixed but configurable size and
|
||||||
|
* sixlowpan_isaddrbased() is for use with such local addresses.
|
||||||
*
|
*
|
||||||
* 128 112 96 80 64 48 32 16
|
* 128 112 96 80 64 48 32 16
|
||||||
* ---- ---- ---- ---- ---- ---- ---- ----
|
* ---- ---- ---- ---- ---- ---- ---- ----
|
||||||
* fe80 0000 0000 0000 xxxx 0000 0000 0000 2-byte short address (VALID?)
|
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC
|
||||||
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address
|
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -553,6 +561,19 @@ void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr,
|
|||||||
void sixlowpan_addrfromip(const net_ipv6addr_t ipaddr,
|
void sixlowpan_addrfromip(const net_ipv6addr_t ipaddr,
|
||||||
FAR struct sixlowpan_tagaddr_s *addr);
|
FAR struct sixlowpan_tagaddr_s *addr);
|
||||||
|
|
||||||
|
bool sixlowpan_issaddrbased(const net_ipv6addr_t ipaddr,
|
||||||
|
FAR const struct sixlowpan_saddr_s *saddr);
|
||||||
|
bool sixlowpan_iseaddrbased(const net_ipv6addr_t ipaddr,
|
||||||
|
FAR const struct sixlowpan_eaddr_s *eaddr);
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||||
|
# define sixlowpan_isaddrbased(ipaddr,addr) \
|
||||||
|
sixlowpan_iseaddrbased(ipaddr,(FAR struct sixlowpan_eaddr_s *)addr)
|
||||||
|
#else
|
||||||
|
# define sixlowpan_isaddrbased(ipaddr,addr) \
|
||||||
|
sixlowpan_issaddrbased(ipaddr,(FAR struct sixlowpan_saddr_s *)addr)
|
||||||
|
#endif
|
||||||
|
|
||||||
bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
||||||
FAR const struct sixlowpan_tagaddr_s *addr);
|
FAR const struct sixlowpan_tagaddr_s *addr);
|
||||||
|
|
||||||
|
@ -71,12 +71,16 @@
|
|||||||
* Name: sixlowpan_addrfromip
|
* Name: sixlowpan_addrfromip
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Extract the IEEE 802.15.4 address from a link local IPv6 address:
|
* sixlowpan_addrfromip(): Extract the IEEE 802.15.14 address from a MAC
|
||||||
|
* based IPv6 address. sixlowpan_addrfromip() is intended to handle a
|
||||||
|
* tagged address or and size; sixlowpan_saddrfromip() and
|
||||||
|
* sixlowpan_eaddrfromip() specifically handler short and extended
|
||||||
|
* addresses.
|
||||||
*
|
*
|
||||||
* 128 112 96 80 64 48 32 16
|
* 128 112 96 80 64 48 32 16
|
||||||
* ---- ---- ---- ---- ---- ---- ---- ----
|
* ---- ---- ---- ---- ---- ---- ---- ----
|
||||||
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC
|
* xxxx 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC
|
||||||
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64
|
* xxxx 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -119,7 +123,13 @@ void sixlowpan_addrfromip(const net_ipv6addr_t ipaddr,
|
|||||||
* Name: sixlowpan_ismacbased
|
* Name: sixlowpan_ismacbased
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Check if the MAC address is encoded in the IP address:
|
* sixlowpan_ismacbased() will return true for IP addresses formed from
|
||||||
|
* IEEE802.15.4 MAC addresses. sixlowpan_addrfromip() is intended to
|
||||||
|
* handle a tagged address or any size; sixlowpan_issaddrbased() and
|
||||||
|
* sixlowpan_iseaddrbased() specifically handle short and extended
|
||||||
|
* addresses. Local addresses are of a fixed but configurable size and
|
||||||
|
* sixlowpan_isaddrbased() is for use with such local addresses.
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* 128 112 96 80 64 48 32 16
|
* 128 112 96 80 64 48 32 16
|
||||||
* ---- ---- ---- ---- ---- ---- ---- ----
|
* ---- ---- ---- ---- ---- ---- ---- ----
|
||||||
|
Loading…
x
Reference in New Issue
Block a user