Loading system/gd/cert/captures.py +3 −4 Original line number Diff line number Diff line Loading @@ -86,9 +86,8 @@ class L2capCaptures(object): return l2cap_packets.LeCreditBasedConnectionRequestView(frame) @staticmethod def CreditBasedConnectionResponse(scid): return Capture( L2capMatchers.CreditBasedConnectionResponse(scid), def CreditBasedConnectionResponse(): return Capture(L2capMatchers.CreditBasedConnectionResponse(), L2capCaptures._extract_credit_based_connection_response) @staticmethod Loading system/gd/cert/matchers.py +7 −3 Original line number Diff line number Diff line Loading @@ -72,8 +72,12 @@ class L2capMatchers(object): @staticmethod def CreditBasedConnectionResponse( scid, result=LeCreditBasedConnectionResponseResult.SUCCESS): return lambda packet: L2capMatchers._is_matching_credit_based_connection_response(packet, scid, result) result=LeCreditBasedConnectionResponseResult.SUCCESS): return lambda packet: L2capMatchers._is_matching_credit_based_connection_response(packet, result) @staticmethod def CreditBasedConnectionResponseUsedCid(): return lambda packet: L2capMatchers._is_matching_credit_based_connection_response(packet, LeCreditBasedConnectionResponseResult.SOURCE_CID_ALREADY_ALLOCATED) or L2capMatchers._is_le_control_frame_with_code(packet, LeCommandCode.COMMAND_REJECT) @staticmethod def LeDisconnectionRequest(scid, dcid): Loading Loading @@ -327,7 +331,7 @@ class L2capMatchers(object): return request.GetLePsm() == psm @staticmethod def _is_matching_credit_based_connection_response(packet, scid, result): def _is_matching_credit_based_connection_response(packet, result): frame = L2capMatchers.le_control_frame_with_code( packet, LeCommandCode.LE_CREDIT_BASED_CONNECTION_RESPONSE) if frame is None: Loading system/gd/l2cap/le/cert/cert_le_l2cap.py +1 −1 Original line number Diff line number Diff line Loading @@ -142,7 +142,7 @@ class CertLeL2cap(Closable): l2cap_packets.LeCreditBasedConnectionRequestBuilder( signal_id, psm, scid, mtu, mps, initial_credit)) response = L2capCaptures.CreditBasedConnectionResponse(scid) response = L2capCaptures.CreditBasedConnectionResponse() assertThat(self.control_channel).emits(response) channel = CertLeL2capChannel(self._device, scid, response.get().GetDestinationCid(), Loading system/gd/l2cap/le/cert/le_l2cap_test.py +29 −1 Original line number Diff line number Diff line Loading @@ -367,7 +367,6 @@ class LeL2capTest(GdBaseTestClass): 1, 0x34, 0x0101, 2000, 1000, 1000)) assertThat(self.cert_l2cap.get_control_channel()).emits( L2capMatchers.CreditBasedConnectionResponse( 0x0101, result=LeCreditBasedConnectionResponseResult. LE_PSM_NOT_SUPPORTED)) Loading Loading @@ -461,6 +460,35 @@ class LeL2capTest(GdBaseTestClass): assertThat(response_future.get_status()).isEqualTo( LeCreditBasedConnectionResponseResult.INVALID_SOURCE_CID) def test_request_refused_due_to_source_cid_already_allocated_initiator( self): """ L2CAP/LE/CFC/BV-19-C """ self._setup_link_from_cert() response_future = self.dut_l2cap.connect_coc_to_cert(psm=0x33) self.cert_l2cap.verify_and_respond_open_channel_from_remote( psm=0x33, result=LeCreditBasedConnectionResponseResult. SOURCE_CID_ALREADY_ALLOCATED) assertThat(response_future.get_status()).isEqualTo( LeCreditBasedConnectionResponseResult.SOURCE_CID_ALREADY_ALLOCATED) def test_request_refused_due_to_source_cid_already_allocated_responder( self): """ L2CAP/LE/CFC/BV-20-C """ self._setup_link_from_cert() (dut_channel, cert_channel) = self._open_channel_from_cert( psm=0x33, scid=0x0101) self.dut_l2cap.register_coc(psm=0x35) self.cert_l2cap.get_control_channel().send( l2cap_packets.LeCreditBasedConnectionRequestBuilder( 2, 0x35, 0x0101, 1000, 1000, 1000)) assertThat(self.cert_l2cap.get_control_channel()).emits( L2capMatchers.CreditBasedConnectionResponseUsedCid()) def test_request_refused_due_to_unacceptable_parameters_initiator(self): """ L2CAP/LE/CFC/BV-21-C Loading system/gd/l2cap/le/internal/signalling_manager.cc +2 −1 Original line number Diff line number Diff line Loading @@ -192,8 +192,9 @@ void LeSignallingManager::OnConnectionRequest(SignalId signal_id, Psm psm, Cid r auto new_channel = link_->AllocateDynamicChannel(psm, remote_cid, {}); if (new_channel == nullptr) { LOG_WARN("Can't allocate dynamic channel"); // TODO: We need to respond with the correct reason send_connection_response(signal_id, kInvalidCid, 0, 0, 0, LeCreditBasedConnectionResponseResult::NO_RESOURCES_AVAILABLE); LeCreditBasedConnectionResponseResult::SOURCE_CID_ALREADY_ALLOCATED); return; } Loading Loading
system/gd/cert/captures.py +3 −4 Original line number Diff line number Diff line Loading @@ -86,9 +86,8 @@ class L2capCaptures(object): return l2cap_packets.LeCreditBasedConnectionRequestView(frame) @staticmethod def CreditBasedConnectionResponse(scid): return Capture( L2capMatchers.CreditBasedConnectionResponse(scid), def CreditBasedConnectionResponse(): return Capture(L2capMatchers.CreditBasedConnectionResponse(), L2capCaptures._extract_credit_based_connection_response) @staticmethod Loading
system/gd/cert/matchers.py +7 −3 Original line number Diff line number Diff line Loading @@ -72,8 +72,12 @@ class L2capMatchers(object): @staticmethod def CreditBasedConnectionResponse( scid, result=LeCreditBasedConnectionResponseResult.SUCCESS): return lambda packet: L2capMatchers._is_matching_credit_based_connection_response(packet, scid, result) result=LeCreditBasedConnectionResponseResult.SUCCESS): return lambda packet: L2capMatchers._is_matching_credit_based_connection_response(packet, result) @staticmethod def CreditBasedConnectionResponseUsedCid(): return lambda packet: L2capMatchers._is_matching_credit_based_connection_response(packet, LeCreditBasedConnectionResponseResult.SOURCE_CID_ALREADY_ALLOCATED) or L2capMatchers._is_le_control_frame_with_code(packet, LeCommandCode.COMMAND_REJECT) @staticmethod def LeDisconnectionRequest(scid, dcid): Loading Loading @@ -327,7 +331,7 @@ class L2capMatchers(object): return request.GetLePsm() == psm @staticmethod def _is_matching_credit_based_connection_response(packet, scid, result): def _is_matching_credit_based_connection_response(packet, result): frame = L2capMatchers.le_control_frame_with_code( packet, LeCommandCode.LE_CREDIT_BASED_CONNECTION_RESPONSE) if frame is None: Loading
system/gd/l2cap/le/cert/cert_le_l2cap.py +1 −1 Original line number Diff line number Diff line Loading @@ -142,7 +142,7 @@ class CertLeL2cap(Closable): l2cap_packets.LeCreditBasedConnectionRequestBuilder( signal_id, psm, scid, mtu, mps, initial_credit)) response = L2capCaptures.CreditBasedConnectionResponse(scid) response = L2capCaptures.CreditBasedConnectionResponse() assertThat(self.control_channel).emits(response) channel = CertLeL2capChannel(self._device, scid, response.get().GetDestinationCid(), Loading
system/gd/l2cap/le/cert/le_l2cap_test.py +29 −1 Original line number Diff line number Diff line Loading @@ -367,7 +367,6 @@ class LeL2capTest(GdBaseTestClass): 1, 0x34, 0x0101, 2000, 1000, 1000)) assertThat(self.cert_l2cap.get_control_channel()).emits( L2capMatchers.CreditBasedConnectionResponse( 0x0101, result=LeCreditBasedConnectionResponseResult. LE_PSM_NOT_SUPPORTED)) Loading Loading @@ -461,6 +460,35 @@ class LeL2capTest(GdBaseTestClass): assertThat(response_future.get_status()).isEqualTo( LeCreditBasedConnectionResponseResult.INVALID_SOURCE_CID) def test_request_refused_due_to_source_cid_already_allocated_initiator( self): """ L2CAP/LE/CFC/BV-19-C """ self._setup_link_from_cert() response_future = self.dut_l2cap.connect_coc_to_cert(psm=0x33) self.cert_l2cap.verify_and_respond_open_channel_from_remote( psm=0x33, result=LeCreditBasedConnectionResponseResult. SOURCE_CID_ALREADY_ALLOCATED) assertThat(response_future.get_status()).isEqualTo( LeCreditBasedConnectionResponseResult.SOURCE_CID_ALREADY_ALLOCATED) def test_request_refused_due_to_source_cid_already_allocated_responder( self): """ L2CAP/LE/CFC/BV-20-C """ self._setup_link_from_cert() (dut_channel, cert_channel) = self._open_channel_from_cert( psm=0x33, scid=0x0101) self.dut_l2cap.register_coc(psm=0x35) self.cert_l2cap.get_control_channel().send( l2cap_packets.LeCreditBasedConnectionRequestBuilder( 2, 0x35, 0x0101, 1000, 1000, 1000)) assertThat(self.cert_l2cap.get_control_channel()).emits( L2capMatchers.CreditBasedConnectionResponseUsedCid()) def test_request_refused_due_to_unacceptable_parameters_initiator(self): """ L2CAP/LE/CFC/BV-21-C Loading
system/gd/l2cap/le/internal/signalling_manager.cc +2 −1 Original line number Diff line number Diff line Loading @@ -192,8 +192,9 @@ void LeSignallingManager::OnConnectionRequest(SignalId signal_id, Psm psm, Cid r auto new_channel = link_->AllocateDynamicChannel(psm, remote_cid, {}); if (new_channel == nullptr) { LOG_WARN("Can't allocate dynamic channel"); // TODO: We need to respond with the correct reason send_connection_response(signal_id, kInvalidCid, 0, 0, 0, LeCreditBasedConnectionResponseResult::NO_RESOURCES_AVAILABLE); LeCreditBasedConnectionResponseResult::SOURCE_CID_ALREADY_ALLOCATED); return; } Loading