mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
Merged in antmerlino/nuttx/sixlowpan-ul-bit (pull request #787)
sixlowpan: Fixes logic surrounding the Universal/Local bit. This bit represents whether the IID is locally/globally administered. The U/L bit is bit 1 of the MSB of the EUI-64. It should only be inverted in cases where there is a full EUI-64. In cases whe
* sixlowpan: Fixes logic surrounding the Universal/Local bit. This bit represents whether the IID is locally/globally administered. The U/L bit is bit 1 of the MSB of the EUI-64. It should only be inverted in cases where there is a full EUI-64. In cases where the IID is derived from say, a short address, this bit should be forced to 0, indicating that it is locally administered.
See:
https://tools.ietf.org/html/rfc4291#section-2.5.1
https://tools.ietf.org/html/rfc4944#section-6
https://tools.ietf.org/html/rfc2464#section-4
* sixlowpan: Account for endianness with U/L bit.
Approved-by: GregoryN <gnutt@nuttx.org>
This commit is contained in:
committed by
GregoryN
parent
0d20c39250
commit
b48a62a7d4
@@ -229,7 +229,10 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[5] = (uint16_t)g_eaddr[2] << 8 | (uint16_t)g_eaddr[3];
|
||||
dev->d_ipv6addr[6] = (uint16_t)g_eaddr[4] << 8 | (uint16_t)g_eaddr[5];
|
||||
dev->d_ipv6addr[7] = (uint16_t)g_eaddr[6] << 8 | (uint16_t)g_eaddr[7];
|
||||
dev->d_ipv6addr[4] ^= 0x200;
|
||||
|
||||
/* Invert the U/L bit */
|
||||
|
||||
dev->d_ipv6addr[4] ^= HTONS(0x0200);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
@@ -251,7 +254,6 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[5] = HTONS(0x00ff);
|
||||
dev->d_ipv6addr[6] = HTONS(0xfe00);
|
||||
dev->d_ipv6addr[7] = (uint16_t)g_saddr[0] << 8 | (uint16_t)g_saddr[1];
|
||||
dev->d_ipv6addr[7] ^= 0x200;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -296,7 +296,10 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[5] = (uint16_t)eaddr[2] << 8 | (uint16_t)eaddr[3];
|
||||
dev->d_ipv6addr[6] = (uint16_t)eaddr[4] << 8 | (uint16_t)eaddr[5];
|
||||
dev->d_ipv6addr[7] = (uint16_t)eaddr[6] << 8 | (uint16_t)eaddr[7];
|
||||
dev->d_ipv6addr[4] ^= 0x200;
|
||||
|
||||
/* Invert the U/L bit */
|
||||
|
||||
dev->d_ipv6addr[4] ^= HTONS(0x0200);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -334,7 +337,6 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[5] = HTONS(0x00ff);
|
||||
dev->d_ipv6addr[6] = HTONS(0xfe00);
|
||||
dev->d_ipv6addr[7] = (uint16_t)saddr[0] << 8 | (uint16_t)saddr[1];
|
||||
dev->d_ipv6addr[7] ^= 0x200;
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -221,7 +221,7 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[4] = 0;
|
||||
dev->d_ipv6addr[5] = HTONS(0x00ff);
|
||||
dev->d_ipv6addr[6] = HTONS(0xfe00);
|
||||
dev->d_ipv6addr[7] = (uint16_t)g_mac_addr[0] << 8 ^ 0x0200;
|
||||
dev->d_ipv6addr[7] = (uint16_t)g_mac_addr[0] << 8;
|
||||
|
||||
#elif CONFIG_PKTRADIO_ADDRLEN == 2
|
||||
/* Set the IP address based on the 2 byte address */
|
||||
@@ -230,7 +230,6 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[5] = HTONS(0x00ff);
|
||||
dev->d_ipv6addr[6] = HTONS(0xfe00);
|
||||
dev->d_ipv6addr[7] = (uint16_t)g_mac_addr[0] << 8 | (uint16_t)g_mac_addr[1];
|
||||
dev->d_ipv6addr[7] ^= 0x0200;
|
||||
|
||||
#elif CONFIG_PKTRADIO_ADDRLEN == 8
|
||||
/* Set the IP address based on the 8-byte address */
|
||||
@@ -239,7 +238,6 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[5] = (uint16_t)g_mac_addr[2] << 8 | (uint16_t)g_mac_addr[3];
|
||||
dev->d_ipv6addr[6] = (uint16_t)g_mac_addr[4] << 8 | (uint16_t)g_mac_addr[5];
|
||||
dev->d_ipv6addr[7] = (uint16_t)g_mac_addr[6] << 8 | (uint16_t)g_mac_addr[7];
|
||||
dev->d_ipv6addr[4] ^= 0x0200;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user