Loading tools/rootcanal/model/controller/link_layer_controller.cc +5 −1 Original line number Original line Diff line number Diff line Loading @@ -682,7 +682,7 @@ ErrorCode LinkLayerController::LeAddDeviceToResolvingList( for (auto const& entry : le_resolving_list_) { for (auto const& entry : le_resolving_list_) { if ((entry.peer_identity_address_type == peer_identity_address_type && if ((entry.peer_identity_address_type == peer_identity_address_type && entry.peer_identity_address == peer_identity_address) || entry.peer_identity_address == peer_identity_address) || entry.peer_irk == peer_irk) { (entry.peer_irk == peer_irk && !irk_is_zero(peer_irk))) { INFO(id_, "device is already present in the resolving list"); INFO(id_, "device is already present in the resolving list"); return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS; return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS; } } Loading Loading @@ -2837,6 +2837,10 @@ Address LinkLayerController::generate_rpa( return rpa; return rpa; } } bool LinkLayerController::irk_is_zero(std::array<uint8_t, LinkLayerController::kIrkSize> irk) { return std::all_of(irk.begin(), irk.end(), [](uint8_t b) { return b == 0; }); } // Handle legacy advertising PDUs while in the Scanning state. // Handle legacy advertising PDUs while in the Scanning state. void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu( void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu( model::packets::LeLegacyAdvertisingPduView& pdu, uint8_t rssi) { model::packets::LeLegacyAdvertisingPduView& pdu, uint8_t rssi) { Loading tools/rootcanal/model/controller/link_layer_controller.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -63,6 +63,9 @@ class LinkLayerController { static Address generate_rpa( static Address generate_rpa( std::array<uint8_t, LinkLayerController::kIrkSize> irk); std::array<uint8_t, LinkLayerController::kIrkSize> irk); // Return true if the input IRK is all 0s. static bool irk_is_zero(std::array<uint8_t, LinkLayerController::kIrkSize> irk); LinkLayerController(const Address& address, LinkLayerController(const Address& address, const ControllerProperties& properties, int id = 0); const ControllerProperties& properties, int id = 0); ~LinkLayerController(); ~LinkLayerController(); Loading tools/rootcanal/test/controller/le/le_add_device_to_resolving_list_test.cc +12 −0 Original line number Original line Diff line number Diff line Loading @@ -130,4 +130,16 @@ TEST_F(LeAddDeviceToResolvingListTest, PeerIrkDuplicate) { ErrorCode::INVALID_HCI_COMMAND_PARAMETERS); ErrorCode::INVALID_HCI_COMMAND_PARAMETERS); } } TEST_F(LeAddDeviceToResolvingListTest, EmptyPeerIrkDuplicate) { ASSERT_EQ(controller_.LeAddDeviceToResolvingList( PeerAddressType::PUBLIC_DEVICE_OR_IDENTITY_ADDRESS, Address{1}, std::array<uint8_t, 16>{0}, std::array<uint8_t, 16>{1}), ErrorCode::SUCCESS); ASSERT_EQ(controller_.LeAddDeviceToResolvingList( PeerAddressType::RANDOM_DEVICE_OR_IDENTITY_ADDRESS, Address{1}, std::array<uint8_t, 16>{0}, std::array<uint8_t, 16>{1}), ErrorCode::SUCCESS); } } // namespace rootcanal } // namespace rootcanal Loading
tools/rootcanal/model/controller/link_layer_controller.cc +5 −1 Original line number Original line Diff line number Diff line Loading @@ -682,7 +682,7 @@ ErrorCode LinkLayerController::LeAddDeviceToResolvingList( for (auto const& entry : le_resolving_list_) { for (auto const& entry : le_resolving_list_) { if ((entry.peer_identity_address_type == peer_identity_address_type && if ((entry.peer_identity_address_type == peer_identity_address_type && entry.peer_identity_address == peer_identity_address) || entry.peer_identity_address == peer_identity_address) || entry.peer_irk == peer_irk) { (entry.peer_irk == peer_irk && !irk_is_zero(peer_irk))) { INFO(id_, "device is already present in the resolving list"); INFO(id_, "device is already present in the resolving list"); return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS; return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS; } } Loading Loading @@ -2837,6 +2837,10 @@ Address LinkLayerController::generate_rpa( return rpa; return rpa; } } bool LinkLayerController::irk_is_zero(std::array<uint8_t, LinkLayerController::kIrkSize> irk) { return std::all_of(irk.begin(), irk.end(), [](uint8_t b) { return b == 0; }); } // Handle legacy advertising PDUs while in the Scanning state. // Handle legacy advertising PDUs while in the Scanning state. void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu( void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu( model::packets::LeLegacyAdvertisingPduView& pdu, uint8_t rssi) { model::packets::LeLegacyAdvertisingPduView& pdu, uint8_t rssi) { Loading
tools/rootcanal/model/controller/link_layer_controller.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -63,6 +63,9 @@ class LinkLayerController { static Address generate_rpa( static Address generate_rpa( std::array<uint8_t, LinkLayerController::kIrkSize> irk); std::array<uint8_t, LinkLayerController::kIrkSize> irk); // Return true if the input IRK is all 0s. static bool irk_is_zero(std::array<uint8_t, LinkLayerController::kIrkSize> irk); LinkLayerController(const Address& address, LinkLayerController(const Address& address, const ControllerProperties& properties, int id = 0); const ControllerProperties& properties, int id = 0); ~LinkLayerController(); ~LinkLayerController(); Loading
tools/rootcanal/test/controller/le/le_add_device_to_resolving_list_test.cc +12 −0 Original line number Original line Diff line number Diff line Loading @@ -130,4 +130,16 @@ TEST_F(LeAddDeviceToResolvingListTest, PeerIrkDuplicate) { ErrorCode::INVALID_HCI_COMMAND_PARAMETERS); ErrorCode::INVALID_HCI_COMMAND_PARAMETERS); } } TEST_F(LeAddDeviceToResolvingListTest, EmptyPeerIrkDuplicate) { ASSERT_EQ(controller_.LeAddDeviceToResolvingList( PeerAddressType::PUBLIC_DEVICE_OR_IDENTITY_ADDRESS, Address{1}, std::array<uint8_t, 16>{0}, std::array<uint8_t, 16>{1}), ErrorCode::SUCCESS); ASSERT_EQ(controller_.LeAddDeviceToResolvingList( PeerAddressType::RANDOM_DEVICE_OR_IDENTITY_ADDRESS, Address{1}, std::array<uint8_t, 16>{0}, std::array<uint8_t, 16>{1}), ErrorCode::SUCCESS); } } // namespace rootcanal } // namespace rootcanal