Added missing masks and fixed bit ordering in is_random_xx_address() functions

pull/6932/head
Donatien Garnier 2018-05-14 13:59:32 +01:00
parent d8b63fc03d
commit 6c6af1b0d5
1 changed files with 6 additions and 6 deletions

View File

@ -229,8 +229,8 @@ static bool is_prand_24_bits_valid(const BLEProtocol::AddressBytes_t address)
*/ */
static bool is_random_static_address(const BLEProtocol::AddressBytes_t address) static bool is_random_static_address(const BLEProtocol::AddressBytes_t address)
{ {
// top two msb bits shall be equal to 1. // top two msb bits shall be equal to 0b11.
if ((address[5] >> 6) != 0x03) { if (((address[5] >> 6) & 0xC0) != 0xC0) {
return false; return false;
} }
@ -243,8 +243,8 @@ static bool is_random_static_address(const BLEProtocol::AddressBytes_t address)
static bool is_random_private_non_resolvable_address( static bool is_random_private_non_resolvable_address(
const BLEProtocol::AddressBytes_t address const BLEProtocol::AddressBytes_t address
) { ) {
// top two msb bits shall be equal to 0. // top two msb bits shall be equal to 0b00.
if ((address[5] >> 6) != 0x00) { if (((address[5] >> 6) & 0xC0) != 0x00) {
return false; return false;
} }
@ -257,8 +257,8 @@ static bool is_random_private_non_resolvable_address(
static bool is_random_private_resolvable_address( static bool is_random_private_resolvable_address(
const BLEProtocol::AddressBytes_t address const BLEProtocol::AddressBytes_t address
) { ) {
// top two msb bits shall be equal to 01. // top two msb bits shall be equal to 0b01.
if ((address[5] >> 6) != 0x01) { if (((address[5] >> 6) & 0xC0) != 0x40) {
return false; return false;
} }