diff options
| author | 2023-05-25 23:45:13 +0000 | |
|---|---|---|
| committer | 2023-05-25 23:45:13 +0000 | |
| commit | 63b5f9b1b0533a8b785762754eb6947f37d57bb2 (patch) | |
| tree | 28a0c891142a7caf030f7c26de76f3039ddc7ece | |
| parent | 18da67124b3a70e4422bd2f04e9ee093baf96f15 (diff) | |
Revert "RootCanal: Implement all Role Change configurations"
This reverts commit 18da67124b3a70e4422bd2f04e9ee093baf96f15.
Reason for revert: Potential culprit for b/284368992
Change-Id: I5636315eb26fa7de37b76f2f9cf1f6804e237dd0
| -rw-r--r-- | tools/rootcanal/Android.bp | 1 | ||||
| -rw-r--r-- | tools/rootcanal/config.proto | 5 | ||||
| -rw-r--r-- | tools/rootcanal/model/controller/acl_connection.cc | 4 | ||||
| -rw-r--r-- | tools/rootcanal/model/controller/acl_connection.h | 16 | ||||
| -rw-r--r-- | tools/rootcanal/model/controller/controller_properties.cc | 1 | ||||
| -rw-r--r-- | tools/rootcanal/model/controller/link_layer_controller.cc | 217 | ||||
| -rw-r--r-- | tools/rootcanal/packets/link_layer_packets.pdl | 2 | ||||
| -rw-r--r-- | tools/rootcanal/py/bluetooth.py | 11 | ||||
| -rw-r--r-- | tools/rootcanal/test/LMP/LIH/BV_01_C.py | 63 | ||||
| -rw-r--r-- | tools/rootcanal/test/LMP/LIH/BV_02_C.py | 66 | ||||
| -rw-r--r-- | tools/rootcanal/test/LMP/LIH/BV_142_C.py | 53 | ||||
| -rw-r--r-- | tools/rootcanal/test/LMP/LIH/BV_143_C.py | 72 | ||||
| -rw-r--r-- | tools/rootcanal/test/LMP/LIH/BV_144_C.py | 41 | ||||
| -rw-r--r-- | tools/rootcanal/test/LMP/LIH/BV_149_C.py | 62 | ||||
| -rw-r--r-- | tools/rootcanal/test/LMP/LIH/BV_78_C.py | 41 | ||||
| -rw-r--r-- | tools/rootcanal/test/LMP/LIH/BV_79_C.py | 43 | ||||
| -rw-r--r-- | tools/rootcanal/test/main.py | 8 |
17 files changed, 88 insertions, 618 deletions
diff --git a/tools/rootcanal/Android.bp b/tools/rootcanal/Android.bp index d3a2cfb2e9..0b5e9d4cce 100644 --- a/tools/rootcanal/Android.bp +++ b/tools/rootcanal/Android.bp @@ -294,7 +294,6 @@ python_test_host { "test/LL/CON_/PER/*.py", "test/LL/DDI/ADV/*.py", "test/LL/DDI/SCN/*.py", - "test/LMP/LIH/*.py", "test/main.py", ], data: [ diff --git a/tools/rootcanal/config.proto b/tools/rootcanal/config.proto index 3fdea960d5..11a447dc8b 100644 --- a/tools/rootcanal/config.proto +++ b/tools/rootcanal/config.proto @@ -22,8 +22,11 @@ message ControllerQuirks { optional bool send_acl_data_before_connection_complete = 1; // Configure a default value for the LE random address. optional bool has_default_random_address = 2; + // Send the Role Change event before the Connection Complete event + // in the case where a role switch is initiated at connection establishment. + optional bool send_role_change_before_connection_complete = 3; // Send an Hardware Error event if any command is called before HCI Reset. - optional bool hardware_error_before_reset = 3; + optional bool hardware_error_before_reset = 4; } message Controller { diff --git a/tools/rootcanal/model/controller/acl_connection.cc b/tools/rootcanal/model/controller/acl_connection.cc index 926e373aa1..2c47ad191d 100644 --- a/tools/rootcanal/model/controller/acl_connection.cc +++ b/tools/rootcanal/model/controller/acl_connection.cc @@ -33,6 +33,10 @@ void AclConnection::Encrypt() { encrypted_ = true; }; bool AclConnection::IsEncrypted() const { return encrypted_; }; +uint16_t AclConnection::GetLinkPolicySettings() const { + return link_policy_settings_; +}; + void AclConnection::SetLinkPolicySettings(uint16_t settings) { link_policy_settings_ = settings; } diff --git a/tools/rootcanal/model/controller/acl_connection.h b/tools/rootcanal/model/controller/acl_connection.h index 7945ef0ece..74bc9a700a 100644 --- a/tools/rootcanal/model/controller/acl_connection.h +++ b/tools/rootcanal/model/controller/acl_connection.h @@ -26,12 +26,6 @@ namespace rootcanal { using ::bluetooth::hci::AddressWithType; -enum AclConnectionState { - kActiveMode, - kHoldMode, - kSniffMode, -}; - // Model the connection of a device to the controller. class AclConnection { public: @@ -50,15 +44,8 @@ class AclConnection { void Encrypt(); bool IsEncrypted() const; + uint16_t GetLinkPolicySettings() const; void SetLinkPolicySettings(uint16_t settings); - uint16_t GetLinkPolicySettings() const { return link_policy_settings_; } - bool IsRoleSwitchEnabled() const { - return (link_policy_settings_ & 0x1) != 0; - } - bool IsHoldModeEnabled() const { return (link_policy_settings_ & 0x2) != 0; } - bool IsSniffModeEnabled() const { return (link_policy_settings_ & 0x4) != 0; } - - AclConnectionState GetMode() const { return state_; } bluetooth::hci::Role GetRole() const; void SetRole(bluetooth::hci::Role role); @@ -94,7 +81,6 @@ class AclConnection { // State variables bool encrypted_{false}; uint16_t link_policy_settings_{0}; - AclConnectionState state_{kActiveMode}; bluetooth::hci::Role role_{bluetooth::hci::Role::CENTRAL}; std::chrono::steady_clock::time_point last_packet_timestamp_; std::chrono::steady_clock::duration timeout_; diff --git a/tools/rootcanal/model/controller/controller_properties.cc b/tools/rootcanal/model/controller/controller_properties.cc index 9c691debd1..cd230b7147 100644 --- a/tools/rootcanal/model/controller/controller_properties.cc +++ b/tools/rootcanal/model/controller/controller_properties.cc @@ -1880,6 +1880,7 @@ ControllerProperties::ControllerProperties( config.quirks().hardware_error_before_reset(); } // TODO(b/270606199): support send_acl_data_before_connection_complete + // TODO(b/274476773): support send_role_change_before_connection_complete } if (!CheckSupportedFeatures()) { diff --git a/tools/rootcanal/model/controller/link_layer_controller.cc b/tools/rootcanal/model/controller/link_layer_controller.cc index 8b5ee4c30d..6fc81c8c9b 100644 --- a/tools/rootcanal/model/controller/link_layer_controller.cc +++ b/tools/rootcanal/model/controller/link_layer_controller.cc @@ -5181,39 +5181,32 @@ void LinkLayerController::IncomingPageResponsePacket( LOG_WARN("No free handles"); return; } - CancelScheduledTask(page_timeout_task_id_); ASSERT(link_manager_add_link( lm_.get(), reinterpret_cast<const uint8_t(*)[6]>(peer.data()))); CheckExpiringConnection(handle); - AclConnection& connection = connections_.GetAclConnection(handle); - auto bd_addr = incoming.GetSourceAddress(); + auto addr = incoming.GetSourceAddress(); auto response = model::packets::PageResponseView::Create(incoming); ASSERT(response.IsValid()); - - bluetooth::hci::Role role = - connections_.IsRoleSwitchAllowedForPendingConnection() && - response.GetTryRoleSwitch() - ? bluetooth::hci::Role::PERIPHERAL - : bluetooth::hci::Role::CENTRAL; - - connection.SetLinkPolicySettings(default_link_policy_settings_); - connection.SetRole(role); - - // Role change event before connection complete generates an HCI Role Change - // event on the initiator side if accepted; the event is sent before the - // HCI Connection Complete event. - if (role == bluetooth::hci::Role::PERIPHERAL && - IsEventUnmasked(EventCode::ROLE_CHANGE)) { - send_event_(bluetooth::hci::RoleChangeBuilder::Create(ErrorCode::SUCCESS, - bd_addr, role)); + /* Role change event before connection complete is a quirk commonly exists in + * Android-capatable Bluetooth controllers. + * On the initiator side, only connection in peripheral role should be + * accompanied with a role change event */ + // TODO(b/274476773): Add a config option for this quirk + if (connections_.IsRoleSwitchAllowedForPendingConnection() && + response.GetTryRoleSwitch()) { + auto role = bluetooth::hci::Role::PERIPHERAL; + connections_.SetAclRole(handle, role); + if (IsEventUnmasked(EventCode::ROLE_CHANGE)) { + send_event_(bluetooth::hci::RoleChangeBuilder::Create(ErrorCode::SUCCESS, + addr, role)); + } } - if (IsEventUnmasked(EventCode::CONNECTION_COMPLETE)) { send_event_(bluetooth::hci::ConnectionCompleteBuilder::Create( - ErrorCode::SUCCESS, handle, bd_addr, bluetooth::hci::LinkType::ACL, + ErrorCode::SUCCESS, handle, addr, bluetooth::hci::LinkType::ACL, bluetooth::hci::Enable::DISABLED)); } } @@ -5342,50 +5335,43 @@ ErrorCode LinkLayerController::AcceptConnectionRequest(const Address& bd_addr, return ErrorCode::UNKNOWN_CONNECTION; } -void LinkLayerController::MakePeripheralConnection(const Address& bd_addr, +void LinkLayerController::MakePeripheralConnection(const Address& addr, bool try_role_switch) { - LOG_INFO("Sending page response to %s", bd_addr.ToString().c_str()); + LOG_INFO("Sending page response to %s", addr.ToString().c_str()); + SendLinkLayerPacket(model::packets::PageResponseBuilder::Create( + GetAddress(), addr, try_role_switch)); - uint16_t connection_handle = - connections_.CreateConnection(bd_addr, GetAddress()); - if (connection_handle == kReservedHandle) { + uint16_t handle = connections_.CreateConnection(addr, GetAddress()); + if (handle == kReservedHandle) { LOG_INFO("CreateConnection failed"); return; } - ASSERT(link_manager_add_link( - lm_.get(), reinterpret_cast<const uint8_t(*)[6]>(bd_addr.data()))); + lm_.get(), reinterpret_cast<const uint8_t(*)[6]>(addr.data()))); - CheckExpiringConnection(connection_handle); + CheckExpiringConnection(handle); - bluetooth::hci::Role role = + /* Role change event before connection complete is a quirk commonly exists in + * Android-capatable Bluetooth controllers. + * On the responder side, any connection should be accompanied with a role + * change event */ + // TODO(b/274476773): Add a config option for this quirk + auto role = try_role_switch && connections_.IsRoleSwitchAllowedForPendingConnection() ? bluetooth::hci::Role::CENTRAL : bluetooth::hci::Role::PERIPHERAL; - - AclConnection& connection = connections_.GetAclConnection(connection_handle); - connection.SetRole(role); - connection.SetLinkPolicySettings(default_link_policy_settings_); - - // Role change event before connection complete generates an HCI Role Change - // event on the acceptor side if accepted; the event is sent before the - // HCI Connection Complete event. - if (role == bluetooth::hci::Role::CENTRAL && - IsEventUnmasked(EventCode::ROLE_CHANGE)) { - LOG_INFO("Role at connection setup accepted"); + connections_.SetAclRole(handle, role); + if (IsEventUnmasked(EventCode::ROLE_CHANGE)) { send_event_(bluetooth::hci::RoleChangeBuilder::Create(ErrorCode::SUCCESS, - bd_addr, role)); + addr, role)); } - LOG_INFO("CreateConnection returned handle 0x%x", connection_handle); + LOG_INFO("CreateConnection returned handle 0x%x", handle); if (IsEventUnmasked(EventCode::CONNECTION_COMPLETE)) { send_event_(bluetooth::hci::ConnectionCompleteBuilder::Create( - ErrorCode::SUCCESS, connection_handle, bd_addr, - bluetooth::hci::LinkType::ACL, bluetooth::hci::Enable::DISABLED)); + ErrorCode::SUCCESS, handle, addr, bluetooth::hci::LinkType::ACL, + bluetooth::hci::Enable::DISABLED)); } - - SendLinkLayerPacket(model::packets::PageResponseBuilder::Create( - GetAddress(), bd_addr, try_role_switch)); } ErrorCode LinkLayerController::RejectConnectionRequest(const Address& addr, @@ -5614,124 +5600,67 @@ ErrorCode LinkLayerController::RoleDiscovery(uint16_t handle, if (!connections_.HasHandle(handle)) { return ErrorCode::UNKNOWN_CONNECTION; } - *role = connections_.GetAclRole(handle); return ErrorCode::SUCCESS; } -ErrorCode LinkLayerController::SwitchRole(Address bd_addr, +ErrorCode LinkLayerController::SwitchRole(Address addr, bluetooth::hci::Role role) { - // The BD_ADDR command parameter indicates for which connection - // the role switch is to be performed and shall specify a BR/EDR Controller - // for which a connection already exists. - uint16_t connection_handle = connections_.GetHandleOnlyAddress(bd_addr); - if (connection_handle == kReservedHandle) { - LOG_INFO("unknown connection address %s", bd_addr.ToString().c_str()); + auto handle = connections_.GetHandleOnlyAddress(addr); + if (handle == rootcanal::kReservedHandle) { return ErrorCode::UNKNOWN_CONNECTION; } - - AclConnection& connection = connections_.GetAclConnection(connection_handle); - - // If there is an (e)SCO connection between the local device and the device - // identified by the BD_ADDR parameter, an attempt to perform a role switch - // shall be rejected by the local device. - if (connections_.GetScoHandle(bd_addr) != kReservedHandle) { - LOG_INFO( - "role switch rejected because an Sco link is opened with" - " the target device"); - return ErrorCode::COMMAND_DISALLOWED; - } - - // If the connection between the local device and the device identified by the - // BD_ADDR parameter is placed in Sniff mode, an attempt to perform a role - // switch shall be rejected by the local device. - if (connection.GetMode() == AclConnectionState::kSniffMode) { - LOG_INFO( - "role switch rejected because the acl connection is in sniff mode"); - return ErrorCode::COMMAND_DISALLOWED; - } - - if (role != connection.GetRole()) { - SendLinkLayerPacket(model::packets::RoleSwitchRequestBuilder::Create( - GetAddress(), bd_addr)); - } else if (IsEventUnmasked(EventCode::ROLE_CHANGE)) { - // Note: the status is Success only if the role change procedure was - // actually performed, otherwise the status is >0. - ScheduleTask(kNoDelayMs, [this, bd_addr, role]() { - send_event_(bluetooth::hci::RoleChangeBuilder::Create( - ErrorCode::ROLE_SWITCH_FAILED, bd_addr, role)); - }); - } - + // TODO(b/274248798): Reject role switch if disabled in link policy + SendLinkLayerPacket(model::packets::RoleSwitchRequestBuilder::Create( + GetAddress(), addr, static_cast<uint8_t>(role))); return ErrorCode::SUCCESS; } void LinkLayerController::IncomingRoleSwitchRequest( model::packets::LinkLayerPacketView incoming) { - auto bd_addr = incoming.GetSourceAddress(); - auto connection_handle = connections_.GetHandleOnlyAddress(bd_addr); - auto switch_req = model::packets::RoleSwitchRequestView::Create(incoming); - ASSERT(switch_req.IsValid()); + auto addr = incoming.GetSourceAddress(); + auto handle = connections_.GetHandleOnlyAddress(addr); + auto request = model::packets::RoleSwitchRequestView::Create(incoming); + ASSERT(request.IsValid()); - if (connection_handle == kReservedHandle) { - LOG_INFO("ignoring Switch Request received on unknown connection"); - return; + // TODO(b/274248798): Reject role switch if disabled in link policy + Role remote_role = static_cast<Role>(request.GetInitiatorNewRole()); + Role local_role = + remote_role == Role::CENTRAL ? Role::PERIPHERAL : Role::CENTRAL; + connections_.SetAclRole(handle, local_role); + if (IsEventUnmasked(EventCode::ROLE_CHANGE)) { + ScheduleTask(kNoDelayMs, [this, addr, local_role]() { + send_event_(bluetooth::hci::RoleChangeBuilder::Create(ErrorCode::SUCCESS, + addr, local_role)); + }); } - - AclConnection& connection = connections_.GetAclConnection(connection_handle); - - if (!connection.IsRoleSwitchEnabled()) { - LOG_INFO("role switch disabled by local link policy settings"); - SendLinkLayerPacket(model::packets::RoleSwitchResponseBuilder::Create( - GetAddress(), bd_addr, - static_cast<uint8_t>(ErrorCode::ROLE_CHANGE_NOT_ALLOWED))); - } else { - LOG_INFO("role switch request accepted by local device"); + ScheduleTask(kNoDelayMs, [this, addr, remote_role]() { SendLinkLayerPacket(model::packets::RoleSwitchResponseBuilder::Create( - GetAddress(), bd_addr, static_cast<uint8_t>(ErrorCode::SUCCESS))); - - bluetooth::hci::Role new_role = - connection.GetRole() == bluetooth::hci::Role::CENTRAL - ? bluetooth::hci::Role::PERIPHERAL - : bluetooth::hci::Role::CENTRAL; - - connection.SetRole(new_role); - - if (IsEventUnmasked(EventCode::ROLE_CHANGE)) { - ScheduleTask(kNoDelayMs, [this, bd_addr, new_role]() { - send_event_(bluetooth::hci::RoleChangeBuilder::Create( - ErrorCode::SUCCESS, bd_addr, new_role)); - }); - } - } + GetAddress(), addr, static_cast<uint8_t>(ErrorCode::SUCCESS), + static_cast<uint8_t>(remote_role))); + }); } void LinkLayerController::IncomingRoleSwitchResponse( model::packets::LinkLayerPacketView incoming) { - auto bd_addr = incoming.GetSourceAddress(); - auto connection_handle = connections_.GetHandleOnlyAddress(bd_addr); - auto switch_rsp = model::packets::RoleSwitchResponseView::Create(incoming); - ASSERT(switch_rsp.IsValid()); + auto addr = incoming.GetSourceAddress(); + auto handle = connections_.GetHandleOnlyAddress(addr); + auto response = model::packets::RoleSwitchResponseView::Create(incoming); + ASSERT(response.IsValid()); - if (connection_handle == kReservedHandle) { - LOG_INFO("ignoring Switch Response received on unknown connection"); - return; + // TODO(b/274248798): Reject role switch if disabled in link policy + ErrorCode status = ErrorCode::SUCCESS; + Role role = static_cast<Role>(response.GetInitiatorNewRole()); + if (response.GetStatus() == static_cast<uint8_t>(ErrorCode::SUCCESS)) { + connections_.SetAclRole(handle, role); + } else { + status = static_cast<ErrorCode>(response.GetStatus()); } - AclConnection& connection = connections_.GetAclConnection(connection_handle); - ErrorCode status = ErrorCode(switch_rsp.GetStatus()); - bluetooth::hci::Role new_role = - status != ErrorCode::SUCCESS ? connection.GetRole() - : connection.GetRole() == bluetooth::hci::Role::CENTRAL - ? bluetooth::hci::Role::PERIPHERAL - : bluetooth::hci::Role::CENTRAL; - - connection.SetRole(new_role); - if (IsEventUnmasked(EventCode::ROLE_CHANGE)) { - ScheduleTask(kNoDelayMs, [this, status, bd_addr, new_role]() { + ScheduleTask(kNoDelayMs, [this, status, addr, role]() { send_event_( - bluetooth::hci::RoleChangeBuilder::Create(status, bd_addr, new_role)); + bluetooth::hci::RoleChangeBuilder::Create(status, addr, role)); }); } } @@ -5741,7 +5670,6 @@ ErrorCode LinkLayerController::ReadLinkPolicySettings(uint16_t handle, if (!connections_.HasHandle(handle)) { return ErrorCode::UNKNOWN_CONNECTION; } - *settings = connections_.GetAclLinkPolicySettings(handle); return ErrorCode::SUCCESS; } @@ -5763,7 +5691,6 @@ ErrorCode LinkLayerController::WriteDefaultLinkPolicySettings( if (settings > 7 /* Sniff + Hold + Role switch */) { return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS; } - default_link_policy_settings_ = settings; return ErrorCode::SUCCESS; } diff --git a/tools/rootcanal/packets/link_layer_packets.pdl b/tools/rootcanal/packets/link_layer_packets.pdl index 5cd6767328..3a92e39f08 100644 --- a/tools/rootcanal/packets/link_layer_packets.pdl +++ b/tools/rootcanal/packets/link_layer_packets.pdl @@ -401,10 +401,12 @@ packet PingResponse : LinkLayerPacket (type = PING_RESPONSE) { } packet RoleSwitchRequest : LinkLayerPacket (type = ROLE_SWITCH_REQUEST) { + initiator_new_role: 8, } packet RoleSwitchResponse : LinkLayerPacket (type = ROLE_SWITCH_RESPONSE) { status: 8, + initiator_new_role: 8, } packet LlPhyReq : LinkLayerPacket (type = LL_PHY_REQ) { diff --git a/tools/rootcanal/py/bluetooth.py b/tools/rootcanal/py/bluetooth.py index a8a18c53ae..0244333722 100644 --- a/tools/rootcanal/py/bluetooth.py +++ b/tools/rootcanal/py/bluetooth.py @@ -51,19 +51,16 @@ class Address: @dataclass class ClassOfDevice: - class_of_device: int = 0 def parse(span: bytes) -> Tuple['Address', bytes]: - assert len(span) >= 3 - return (ClassOfDevice(int.from_bytes(span[:3], byteorder='little')), span[3:]) + assert False def parse_all(span: bytes) -> 'Address': - assert len(span) == 3 - return ClassOfDevice(int.from_bytes(span, byteorder='little')) + assert False def serialize(self) -> bytes: - return int.to_bytes(self.class_of_device, length=3, byteorder='little') + assert False @property def size(self) -> int: - return 3 + assert False diff --git a/tools/rootcanal/test/LMP/LIH/BV_01_C.py b/tools/rootcanal/test/LMP/LIH/BV_01_C.py deleted file mode 100644 index ca92e44e30..0000000000 --- a/tools/rootcanal/test/LMP/LIH/BV_01_C.py +++ /dev/null @@ -1,63 +0,0 @@ -from dataclasses import dataclass -import hci_packets as hci -import link_layer_packets as ll -import unittest -from hci_packets import ErrorCode -from py.bluetooth import Address -from py.controller import ControllerTest - - -class Test(ControllerTest): - - # LMP/LIH/BV-01-C [Initiate Role Switch] - async def test(self): - # Test parameters. - controller = self.controller - acl_connection_handle = 0xefe - peer_address = Address('11:22:33:44:55:66') - - controller.send_cmd(hci.WriteScanEnable(scan_enable=hci.ScanEnable.PAGE_SCAN_ONLY)) - - await self.expect_evt(hci.WriteScanEnableComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - controller.send_ll( - ll.Page(source_address=peer_address, destination_address=controller.address, allow_role_switch=False)) - - await self.expect_evt(hci.ConnectionRequest(bd_addr=peer_address, link_type=hci.ConnectionRequestLinkType.ACL)) - - controller.send_cmd( - hci.AcceptConnectionRequest(bd_addr=peer_address, role=hci.AcceptConnectionRequestRole.REMAIN_PERIPHERAL)) - - await self.expect_evt(hci.AcceptConnectionRequestStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll( - ll.PageResponse(source_address=controller.address, destination_address=peer_address, try_role_switch=False)) - - await self.expect_evt( - hci.ConnectionComplete(status=ErrorCode.SUCCESS, - connection_handle=acl_connection_handle, - bd_addr=peer_address, - link_type=hci.LinkType.ACL, - encryption_enabled=hci.Enable.DISABLED)) - - controller.send_cmd( - hci.WriteLinkPolicySettings(connection_handle=acl_connection_handle, - link_policy_settings=hci.LinkPolicy.ENABLE_ROLE_SWITCH)) - - await self.expect_evt( - hci.WriteLinkPolicySettingsComplete(status=ErrorCode.SUCCESS, - num_hci_command_packets=1, - connection_handle=acl_connection_handle)) - - controller.send_cmd(hci.SwitchRole(bd_addr=peer_address, role=hci.Role.CENTRAL)) - - await self.expect_evt(hci.SwitchRoleStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll(ll.RoleSwitchRequest(source_address=controller.address, destination_address=peer_address)) - - controller.send_ll( - ll.RoleSwitchResponse(source_address=peer_address, - destination_address=controller.address, - status=ErrorCode.SUCCESS)) - - await self.expect_evt(hci.RoleChange(status=ErrorCode.SUCCESS, bd_addr=peer_address, new_role=hci.Role.CENTRAL)) diff --git a/tools/rootcanal/test/LMP/LIH/BV_02_C.py b/tools/rootcanal/test/LMP/LIH/BV_02_C.py deleted file mode 100644 index 375acdc1f6..0000000000 --- a/tools/rootcanal/test/LMP/LIH/BV_02_C.py +++ /dev/null @@ -1,66 +0,0 @@ -from dataclasses import dataclass -import hci_packets as hci -import link_layer_packets as ll -import unittest -from hci_packets import ErrorCode -from py.bluetooth import Address -from py.controller import ControllerTest - - -class Test(ControllerTest): - - # LMP/LIH/BV-02-C [Accept Role Switch] - async def test(self): - # Test parameters. - controller = self.controller - acl_connection_handle = 0xefe - peer_address = Address('11:22:33:44:55:66') - - controller.send_cmd( - hci.CreateConnection(bd_addr=peer_address, - packet_type=0x7fff, - page_scan_repetition_mode=hci.PageScanRepetitionMode.R0, - allow_role_switch=hci.CreateConnectionRoleSwitch.REMAIN_CENTRAL)) - - await self.expect_evt(hci.CreateConnectionStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll( - ll.Page(source_address=controller.address, destination_address=peer_address, allow_role_switch=False)) - - controller.send_ll( - ll.PageResponse(source_address=peer_address, destination_address=controller.address, try_role_switch=False)) - - await self.expect_evt( - hci.ConnectionComplete(status=ErrorCode.SUCCESS, - connection_handle=acl_connection_handle, - bd_addr=peer_address, - link_type=hci.LinkType.ACL, - encryption_enabled=hci.Enable.DISABLED)) - - controller.send_cmd( - hci.WriteLinkPolicySettings(connection_handle=acl_connection_handle, - link_policy_settings=hci.LinkPolicy.ENABLE_ROLE_SWITCH)) - - await self.expect_evt( - hci.WriteLinkPolicySettingsComplete(status=ErrorCode.SUCCESS, - num_hci_command_packets=1, - connection_handle=acl_connection_handle)) - - controller.send_ll(ll.RoleSwitchRequest(source_address=peer_address, destination_address=controller.address)) - - await self.expect_ll( - ll.RoleSwitchResponse(source_address=controller.address, - destination_address=peer_address, - status=ErrorCode.SUCCESS)) - - await self.expect_evt( - hci.RoleChange(status=ErrorCode.SUCCESS, bd_addr=peer_address, new_role=hci.Role.PERIPHERAL)) - - controller.send_ll(ll.RoleSwitchRequest(source_address=peer_address, destination_address=controller.address)) - - await self.expect_ll( - ll.RoleSwitchResponse(source_address=controller.address, - destination_address=peer_address, - status=ErrorCode.SUCCESS)) - - await self.expect_evt(hci.RoleChange(status=ErrorCode.SUCCESS, bd_addr=peer_address, new_role=hci.Role.CENTRAL)) diff --git a/tools/rootcanal/test/LMP/LIH/BV_142_C.py b/tools/rootcanal/test/LMP/LIH/BV_142_C.py deleted file mode 100644 index 605f1d717d..0000000000 --- a/tools/rootcanal/test/LMP/LIH/BV_142_C.py +++ /dev/null @@ -1,53 +0,0 @@ -from dataclasses import dataclass -import hci_packets as hci -import link_layer_packets as ll -import unittest -from hci_packets import ErrorCode -from py.bluetooth import Address -from py.controller import ControllerTest - - -class Test(ControllerTest): - - # LMP/LIH/BV-142-C [Reject Role Switch Request] - async def test(self): - # Test parameters. - controller = self.controller - acl_connection_handle = 0xefe - peer_address = Address('11:22:33:44:55:66') - - controller.send_cmd( - hci.CreateConnection(bd_addr=peer_address, - packet_type=0x7fff, - page_scan_repetition_mode=hci.PageScanRepetitionMode.R0, - allow_role_switch=hci.CreateConnectionRoleSwitch.REMAIN_CENTRAL)) - - await self.expect_evt(hci.CreateConnectionStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll( - ll.Page(source_address=controller.address, destination_address=peer_address, allow_role_switch=False)) - - controller.send_ll( - ll.PageResponse(source_address=peer_address, destination_address=controller.address, try_role_switch=False)) - - await self.expect_evt( - hci.ConnectionComplete(status=ErrorCode.SUCCESS, - connection_handle=acl_connection_handle, - bd_addr=peer_address, - link_type=hci.LinkType.ACL, - encryption_enabled=hci.Enable.DISABLED)) - - controller.send_cmd(hci.WriteLinkPolicySettings(connection_handle=acl_connection_handle, - link_policy_settings=0)) - - await self.expect_evt( - hci.WriteLinkPolicySettingsComplete(status=ErrorCode.SUCCESS, - num_hci_command_packets=1, - connection_handle=acl_connection_handle)) - - controller.send_ll(ll.RoleSwitchRequest(source_address=peer_address, destination_address=controller.address)) - - await self.expect_ll( - ll.RoleSwitchResponse(source_address=controller.address, - destination_address=peer_address, - status=ErrorCode.ROLE_CHANGE_NOT_ALLOWED)) diff --git a/tools/rootcanal/test/LMP/LIH/BV_143_C.py b/tools/rootcanal/test/LMP/LIH/BV_143_C.py deleted file mode 100644 index 0e6b38af9c..0000000000 --- a/tools/rootcanal/test/LMP/LIH/BV_143_C.py +++ /dev/null @@ -1,72 +0,0 @@ -from dataclasses import dataclass -import hci_packets as hci -import link_layer_packets as ll -import unittest -from hci_packets import ErrorCode -from py.bluetooth import Address -from py.controller import ControllerTest - - -class Test(ControllerTest): - - # LMP/LIH/BV-143-C [Rejected Role Switch Request] - async def test(self): - # Test parameters. - controller = self.controller - acl_connection_handle = 0xefe - peer_address = Address('11:22:33:44:55:66') - - controller.send_cmd(hci.WriteScanEnable(scan_enable=hci.ScanEnable.PAGE_SCAN_ONLY)) - - await self.expect_evt(hci.WriteScanEnableComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - controller.send_ll( - ll.Page(source_address=peer_address, destination_address=controller.address, allow_role_switch=False)) - - await self.expect_evt(hci.ConnectionRequest(bd_addr=peer_address, link_type=hci.ConnectionRequestLinkType.ACL)) - - controller.send_cmd( - hci.AcceptConnectionRequest(bd_addr=peer_address, role=hci.AcceptConnectionRequestRole.REMAIN_PERIPHERAL)) - - await self.expect_evt(hci.AcceptConnectionRequestStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll( - ll.PageResponse(source_address=controller.address, destination_address=peer_address, try_role_switch=False)) - - await self.expect_evt( - hci.ConnectionComplete(status=ErrorCode.SUCCESS, - connection_handle=acl_connection_handle, - bd_addr=peer_address, - link_type=hci.LinkType.ACL, - encryption_enabled=hci.Enable.DISABLED)) - - controller.send_cmd( - hci.WriteLinkPolicySettings(connection_handle=acl_connection_handle, - link_policy_settings=hci.LinkPolicy.ENABLE_ROLE_SWITCH)) - - await self.expect_evt( - hci.WriteLinkPolicySettingsComplete(status=ErrorCode.SUCCESS, - num_hci_command_packets=1, - connection_handle=acl_connection_handle)) - - controller.send_cmd(hci.SwitchRole(bd_addr=peer_address, role=hci.Role.CENTRAL)) - - await self.expect_evt(hci.SwitchRoleStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll(ll.RoleSwitchRequest(source_address=controller.address, destination_address=peer_address)) - - controller.send_ll( - ll.RoleSwitchResponse(source_address=peer_address, - destination_address=controller.address, - status=ErrorCode.ROLE_CHANGE_NOT_ALLOWED)) - - await self.expect_evt( - hci.RoleChange(status=ErrorCode.ROLE_CHANGE_NOT_ALLOWED, bd_addr=peer_address, - new_role=hci.Role.PERIPHERAL)) - - controller.send_cmd(hci.SwitchRole(bd_addr=peer_address, role=hci.Role.PERIPHERAL)) - - await self.expect_evt(hci.SwitchRoleStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_evt( - hci.RoleChange(status=ErrorCode.ROLE_SWITCH_FAILED, bd_addr=peer_address, new_role=hci.Role.PERIPHERAL)) diff --git a/tools/rootcanal/test/LMP/LIH/BV_144_C.py b/tools/rootcanal/test/LMP/LIH/BV_144_C.py deleted file mode 100644 index fedd386f98..0000000000 --- a/tools/rootcanal/test/LMP/LIH/BV_144_C.py +++ /dev/null @@ -1,41 +0,0 @@ -from dataclasses import dataclass -import hci_packets as hci -import link_layer_packets as ll -import unittest -from hci_packets import ErrorCode -from py.bluetooth import Address -from py.controller import ControllerTest - - -class Test(ControllerTest): - - # LMP/LIH/BV-144-C [Rejected Role Switch request at Setup, Peripheral] - async def test(self): - # Test parameters. - controller = self.controller - acl_connection_handle = 0xefe - peer_address = Address('11:22:33:44:55:66') - - controller.send_cmd(hci.WriteScanEnable(scan_enable=hci.ScanEnable.PAGE_SCAN_ONLY)) - - await self.expect_evt(hci.WriteScanEnableComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - controller.send_ll( - ll.Page(source_address=peer_address, destination_address=controller.address, allow_role_switch=False)) - - await self.expect_evt(hci.ConnectionRequest(bd_addr=peer_address, link_type=hci.ConnectionRequestLinkType.ACL)) - - controller.send_cmd( - hci.AcceptConnectionRequest(bd_addr=peer_address, role=hci.AcceptConnectionRequestRole.BECOME_CENTRAL)) - - await self.expect_evt(hci.AcceptConnectionRequestStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll( - ll.PageResponse(source_address=controller.address, destination_address=peer_address, try_role_switch=True)) - - await self.expect_evt( - hci.ConnectionComplete(status=ErrorCode.SUCCESS, - connection_handle=acl_connection_handle, - bd_addr=peer_address, - link_type=hci.LinkType.ACL, - encryption_enabled=hci.Enable.DISABLED)) diff --git a/tools/rootcanal/test/LMP/LIH/BV_149_C.py b/tools/rootcanal/test/LMP/LIH/BV_149_C.py deleted file mode 100644 index 51715321b9..0000000000 --- a/tools/rootcanal/test/LMP/LIH/BV_149_C.py +++ /dev/null @@ -1,62 +0,0 @@ -from dataclasses import dataclass -import hci_packets as hci -import link_layer_packets as ll -import unittest -from hci_packets import ErrorCode -from py.bluetooth import Address -from py.controller import ControllerTest - - -class Test(ControllerTest): - - # LMP/LIH/BV-149-C [Reject Role Switch] - async def test(self): - # Test parameters. - controller = self.controller - acl_connection_handle = 0xefe - peer_address = Address('11:22:33:44:55:66') - - controller.send_cmd( - hci.CreateConnection(bd_addr=peer_address, - packet_type=0x7fff, - page_scan_repetition_mode=hci.PageScanRepetitionMode.R0, - allow_role_switch=hci.CreateConnectionRoleSwitch.REMAIN_CENTRAL)) - - await self.expect_evt(hci.CreateConnectionStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll( - ll.Page(source_address=controller.address, destination_address=peer_address, allow_role_switch=False)) - - controller.send_ll( - ll.PageResponse(source_address=peer_address, destination_address=controller.address, try_role_switch=False)) - - await self.expect_evt( - hci.ConnectionComplete(status=ErrorCode.SUCCESS, - connection_handle=acl_connection_handle, - bd_addr=peer_address, - link_type=hci.LinkType.ACL, - encryption_enabled=hci.Enable.DISABLED)) - - controller.send_cmd( - hci.WriteLinkPolicySettings(connection_handle=acl_connection_handle, - link_policy_settings=hci.LinkPolicy.ENABLE_ROLE_SWITCH)) - - await self.expect_evt(hci.WriteLinkPolicySettingsComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - controller.send_cmd(hci.SwitchRole(bd_addr=peer_address, role=hci.Role.CENTRAL)) - - await self.expect_evt(hci.SwitchRoleStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_evt( - hci.RoleChange(status=ErrorCode.ROLE_SWITCH_FAILED, bd_addr=peer_address, role=hci.Role.CENTRAL)) - - controller.send_cmd(hci.SwitchRole(bd_addr=peer_address, role=hci.Role.PERIPHERAL)) - - await self.expect_evt(hci.SwitchRoleStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll(ll.RoleSwitchRequest()) - - controller.send_ll(ll.RoleSwitchResponse(status=ErrorCode.ROLE_CHANGE_NOT_ALLLOWED)) - - await self.expect_evt( - hci.RoleChange(status=ErrorCode.ROLE_CHANGE_NOT_ALLLOWED, bd_addr=peer_address, role=hci.Role.CENTRAL)) diff --git a/tools/rootcanal/test/LMP/LIH/BV_78_C.py b/tools/rootcanal/test/LMP/LIH/BV_78_C.py deleted file mode 100644 index 42903472e1..0000000000 --- a/tools/rootcanal/test/LMP/LIH/BV_78_C.py +++ /dev/null @@ -1,41 +0,0 @@ -from dataclasses import dataclass -import hci_packets as hci -import link_layer_packets as ll -import unittest -from hci_packets import ErrorCode -from py.bluetooth import Address -from py.controller import ControllerTest - - -class Test(ControllerTest): - - # LMP/LIH/BV-78-C [Role Switch at Setup, Central] - async def test(self): - # Test parameters. - controller = self.controller - acl_connection_handle = 0xefe - peer_address = Address('11:22:33:44:55:66') - - controller.send_cmd( - hci.CreateConnection(bd_addr=peer_address, - packet_type=0x7fff, - page_scan_repetition_mode=hci.PageScanRepetitionMode.R1, - allow_role_switch=hci.CreateConnectionRoleSwitch.ALLOW_ROLE_SWITCH)) - - await self.expect_evt(hci.CreateConnectionStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll( - ll.Page(source_address=controller.address, destination_address=peer_address, allow_role_switch=True)) - - controller.send_ll( - ll.PageResponse(source_address=peer_address, destination_address=controller.address, try_role_switch=True)) - - await self.expect_evt( - hci.RoleChange(status=ErrorCode.SUCCESS, bd_addr=peer_address, new_role=hci.Role.PERIPHERAL)) - - await self.expect_evt( - hci.ConnectionComplete(status=ErrorCode.SUCCESS, - connection_handle=acl_connection_handle, - bd_addr=peer_address, - link_type=hci.LinkType.ACL, - encryption_enabled=hci.Enable.DISABLED)) diff --git a/tools/rootcanal/test/LMP/LIH/BV_79_C.py b/tools/rootcanal/test/LMP/LIH/BV_79_C.py deleted file mode 100644 index 85a3bb0249..0000000000 --- a/tools/rootcanal/test/LMP/LIH/BV_79_C.py +++ /dev/null @@ -1,43 +0,0 @@ -from dataclasses import dataclass -import hci_packets as hci -import link_layer_packets as ll -import unittest -from hci_packets import ErrorCode -from py.bluetooth import Address -from py.controller import ControllerTest - - -class Test(ControllerTest): - - # LMP/LIH/BV-79-C [Role Switch at Setup, Peripheral] - async def test(self): - # Test parameters. - controller = self.controller - acl_connection_handle = 0xefe - peer_address = Address('11:22:33:44:55:66') - - controller.send_cmd(hci.WriteScanEnable(scan_enable=hci.ScanEnable.PAGE_SCAN_ONLY)) - - await self.expect_evt(hci.WriteScanEnableComplete(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - controller.send_ll( - ll.Page(source_address=peer_address, destination_address=controller.address, allow_role_switch=True)) - - await self.expect_evt(hci.ConnectionRequest(bd_addr=peer_address, link_type=hci.ConnectionRequestLinkType.ACL)) - - controller.send_cmd( - hci.AcceptConnectionRequest(bd_addr=peer_address, role=hci.AcceptConnectionRequestRole.BECOME_CENTRAL)) - - await self.expect_evt(hci.AcceptConnectionRequestStatus(status=ErrorCode.SUCCESS, num_hci_command_packets=1)) - - await self.expect_ll( - ll.PageResponse(source_address=controller.address, destination_address=peer_address, try_role_switch=True)) - - await self.expect_evt(hci.RoleChange(status=ErrorCode.SUCCESS, bd_addr=peer_address, new_role=hci.Role.CENTRAL)) - - await self.expect_evt( - hci.ConnectionComplete(status=ErrorCode.SUCCESS, - connection_handle=acl_connection_handle, - bd_addr=peer_address, - link_type=hci.LinkType.ACL, - encryption_enabled=hci.Enable.DISABLED)) diff --git a/tools/rootcanal/test/main.py b/tools/rootcanal/test/main.py index 868baad5b2..8868e26c0a 100644 --- a/tools/rootcanal/test/main.py +++ b/tools/rootcanal/test/main.py @@ -35,14 +35,6 @@ tests = [ 'LL.DDI.SCN.BV_18_C', 'LL.DDI.SCN.BV_19_C', 'LL.DDI.SCN.BV_79_C', - 'LMP.LIH.BV_01_C', - 'LMP.LIH.BV_02_C', - 'LMP.LIH.BV_78_C', - 'LMP.LIH.BV_79_C', - 'LMP.LIH.BV_142_C', - 'LMP.LIH.BV_143_C', - 'LMP.LIH.BV_144_C', - 'LMP.LIH.BV_149_C', ] if __name__ == "__main__": |