Merged in antmerlino/nuttx/avoid-double-context-lookup (pull request #788)
sixlowpan: Address comment regarding avoiding double lookup of address context. Approved-by: GregoryN <gnutt@nuttx.org>
This commit is contained in:
parent
4c601faf6f
commit
33a4ec969a
@ -131,7 +131,7 @@ static FAR uint8_t *g_hc06ptr;
|
|||||||
* 2 -> 2 bytes from prefix - 0000::00ff:fe00:XXXX and 2 bytes from packet
|
* 2 -> 2 bytes from prefix - 0000::00ff:fe00:XXXX and 2 bytes from packet
|
||||||
* 3 -> 2 bytes from prefix - Infer 2 or 8 bytes from MAC address
|
* 3 -> 2 bytes from prefix - Infer 2 or 8 bytes from MAC address
|
||||||
*
|
*
|
||||||
* NOTE: ipaddr=the uncompress function does change 0xf to 0x10
|
* NOTE: ipaddr=the uncompress function does change 0xf to 0x100
|
||||||
* NOTE: 0x00 ipaddr=no-autoconfig ipaddr=unspecified
|
* NOTE: 0x00 ipaddr=no-autoconfig ipaddr=unspecified
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -238,6 +238,11 @@ static FAR struct sixlowpan_addrcontext_s *
|
|||||||
if ((g_hc06_addrcontexts[i].used == 1) &&
|
if ((g_hc06_addrcontexts[i].used == 1) &&
|
||||||
net_ipv6addr_prefixcmp(&g_hc06_addrcontexts[i].prefix, ipaddr, 64))
|
net_ipv6addr_prefixcmp(&g_hc06_addrcontexts[i].prefix, ipaddr, 64))
|
||||||
{
|
{
|
||||||
|
ninfo("Context found for ipaddr=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x Context: %d\n",
|
||||||
|
ntohs(ipaddr[0]), ntohs(ipaddr[1]), ntohs(ipaddr[2]), ntohs(ipaddr[3]),
|
||||||
|
ntohs(ipaddr[4]), ntohs(ipaddr[5]), ntohs(ipaddr[6]), ntohs(ipaddr[7]),
|
||||||
|
g_hc06_addrcontexts[i].number);
|
||||||
|
|
||||||
return &g_hc06_addrcontexts[i];
|
return &g_hc06_addrcontexts[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -700,7 +705,8 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
|
|||||||
FAR uint8_t *fptr)
|
FAR uint8_t *fptr)
|
||||||
{
|
{
|
||||||
FAR uint8_t *iphc = fptr + g_frame_hdrlen;
|
FAR uint8_t *iphc = fptr + g_frame_hdrlen;
|
||||||
FAR struct sixlowpan_addrcontext_s *addrcontext;
|
FAR struct sixlowpan_addrcontext_s *saddrcontext;
|
||||||
|
FAR struct sixlowpan_addrcontext_s *daddrcontext;
|
||||||
uint8_t iphc0;
|
uint8_t iphc0;
|
||||||
uint8_t iphc1;
|
uint8_t iphc1;
|
||||||
uint8_t tmp;
|
uint8_t tmp;
|
||||||
@ -726,18 +732,16 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
|
|||||||
* byte with [ SCI | DCI ]
|
* byte with [ SCI | DCI ]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Check if dest address context exists (for allocating third byte)
|
/* Check if dest address context exists (for allocating third byte) */
|
||||||
*
|
|
||||||
* TODO: fix this so that it remembers the looked up values for avoiding two
|
|
||||||
* lookups - or set the lookup values immediately
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (find_addrcontext_byprefix(ipv6->destipaddr) != NULL ||
|
daddrcontext = find_addrcontext_byprefix(ipv6->destipaddr);
|
||||||
find_addrcontext_byprefix(ipv6->srcipaddr) != NULL)
|
saddrcontext = find_addrcontext_byprefix(ipv6->srcipaddr);
|
||||||
|
|
||||||
|
if (daddrcontext != NULL || saddrcontext != NULL)
|
||||||
{
|
{
|
||||||
/* set address context flag and increase g_hc06ptr */
|
/* set address context flag and increase g_hc06ptr */
|
||||||
|
|
||||||
ninfo("Decompressing dest or src ipaddr. Setting CID\n");
|
ninfo("Compressing dest or src ipaddr. Setting CID\n");
|
||||||
iphc1 |= SIXLOWPAN_IPHC_CID;
|
iphc1 |= SIXLOWPAN_IPHC_CID;
|
||||||
g_hc06ptr++;
|
g_hc06ptr++;
|
||||||
}
|
}
|
||||||
@ -852,15 +856,15 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
|
|||||||
iphc1 |= SIXLOWPAN_IPHC_SAC;
|
iphc1 |= SIXLOWPAN_IPHC_SAC;
|
||||||
iphc1 |= SIXLOWPAN_IPHC_SAM_128;
|
iphc1 |= SIXLOWPAN_IPHC_SAM_128;
|
||||||
}
|
}
|
||||||
else if ((addrcontext = find_addrcontext_byprefix(ipv6->srcipaddr)) != NULL)
|
else if (saddrcontext != NULL)
|
||||||
{
|
{
|
||||||
/* Elide the prefix - indicate by CID and set address context + SAC */
|
/* Elide the prefix - indicate by CID and set address context + SAC */
|
||||||
|
|
||||||
ninfo("Compressing src with address context. Setting CID and SAC context: %d\n",
|
ninfo("Compressing src with address context. Setting SAC. Context: %d\n",
|
||||||
addrcontext->number);
|
saddrcontext->number);
|
||||||
|
|
||||||
iphc1 |= SIXLOWPAN_IPHC_CID | SIXLOWPAN_IPHC_SAC;
|
iphc1 |= SIXLOWPAN_IPHC_SAC;
|
||||||
iphc[2] |= addrcontext->number << 4;
|
iphc[2] |= saddrcontext->number << 4;
|
||||||
|
|
||||||
/* Compression compare with this nodes address (source) */
|
/* Compression compare with this nodes address (source) */
|
||||||
|
|
||||||
@ -954,12 +958,15 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
|
|||||||
{
|
{
|
||||||
/* Address is unicast, try to compress */
|
/* Address is unicast, try to compress */
|
||||||
|
|
||||||
if ((addrcontext = find_addrcontext_byprefix(ipv6->destipaddr)) != NULL)
|
if (daddrcontext != NULL)
|
||||||
{
|
{
|
||||||
/* Elide the prefix */
|
/* Elide the prefix */
|
||||||
|
|
||||||
|
ninfo("Compressing dest with address context. Setting DAC. Context: %d\n",
|
||||||
|
daddrcontext->number);
|
||||||
|
|
||||||
iphc1 |= SIXLOWPAN_IPHC_DAC;
|
iphc1 |= SIXLOWPAN_IPHC_DAC;
|
||||||
iphc[2] |= addrcontext->number;
|
iphc[2] |= daddrcontext->number;
|
||||||
|
|
||||||
/* Compession compare with link adress (destination) */
|
/* Compession compare with link adress (destination) */
|
||||||
|
|
||||||
|
@ -127,12 +127,12 @@ int mac802154_req_data(MACHANDLE mac,
|
|||||||
if (meta->destaddr.mode != IEEE802154_ADDRMODE_NONE)
|
if (meta->destaddr.mode != IEEE802154_ADDRMODE_NONE)
|
||||||
{
|
{
|
||||||
IEEE802154_PANIDCOPY(&frame->io_data[mhr_len], meta->destaddr.panid);
|
IEEE802154_PANIDCOPY(&frame->io_data[mhr_len], meta->destaddr.panid);
|
||||||
mhr_len += 2;
|
mhr_len += IEEE802154_PANIDSIZE;
|
||||||
|
|
||||||
if (meta->destaddr.mode == IEEE802154_ADDRMODE_SHORT)
|
if (meta->destaddr.mode == IEEE802154_ADDRMODE_SHORT)
|
||||||
{
|
{
|
||||||
IEEE802154_SADDRCOPY(&frame->io_data[mhr_len], meta->destaddr.saddr);
|
IEEE802154_SADDRCOPY(&frame->io_data[mhr_len], meta->destaddr.saddr);
|
||||||
mhr_len += 2;
|
mhr_len += IEEE802154_SADDRSIZE;
|
||||||
}
|
}
|
||||||
else if (meta->destaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
|
else if (meta->destaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
|
||||||
{
|
{
|
||||||
@ -185,13 +185,13 @@ int mac802154_req_data(MACHANDLE mac,
|
|||||||
(!(*frame_ctrl & IEEE802154_FRAMECTRL_PANIDCOMP)))
|
(!(*frame_ctrl & IEEE802154_FRAMECTRL_PANIDCOMP)))
|
||||||
{
|
{
|
||||||
IEEE802154_PANIDCOPY(&frame->io_data[mhr_len], priv->addr.panid);
|
IEEE802154_PANIDCOPY(&frame->io_data[mhr_len], priv->addr.panid);
|
||||||
mhr_len += 2;
|
mhr_len += IEEE802154_PANIDSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta->srcmode == IEEE802154_ADDRMODE_SHORT)
|
if (meta->srcmode == IEEE802154_ADDRMODE_SHORT)
|
||||||
{
|
{
|
||||||
IEEE802154_SADDRCOPY(&frame->io_data[mhr_len], priv->addr.saddr);
|
IEEE802154_SADDRCOPY(&frame->io_data[mhr_len], priv->addr.saddr);
|
||||||
mhr_len += 2;
|
mhr_len += IEEE802154_SADDRSIZE;
|
||||||
}
|
}
|
||||||
else if (meta->srcmode == IEEE802154_ADDRMODE_EXTENDED)
|
else if (meta->srcmode == IEEE802154_ADDRMODE_EXTENDED)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user