def test_respond_to_echo_request(self): """ L2CAP/COS/ECH/BV-01-C [Respond to Echo Request] Verify that the IUT responds to an echo request. """ self._setup_link_from_cert() asserts.skip("is echo without a channel supported?") echo_request = l2cap_packets.EchoRequestBuilder( 100, l2cap_packets.DisconnectionRequestBuilder(1, 2, 3)) echo_request_l2cap = l2cap_packets.BasicFrameBuilder(1, echo_request) self.cert_send_b_frame(echo_request_l2cap) assertThat(self.cert_channel).emits( L2capMatchers.PartialData(b"\x06\x01\x04\x00\x02\x00\x03\x00"))
def test_l2cap_config_options(self): mtu_opt = l2cap_packets.MtuConfigurationOption() mtu_opt.mtu = 123 fcs_opt = l2cap_packets.FrameCheckSequenceOption() fcs_opt.fcs_type = l2cap_packets.FcsType.DEFAULT request = l2cap_packets.ConfigurationRequestBuilder( 0x1d, # Command ID 0xc1d, # Channel ID l2cap_packets.Continuation.END, [mtu_opt, fcs_opt]) request_b_frame = l2cap_packets.BasicFrameBuilder(0x01, request) handle = 123 wrapped = hci_packets.AclPacketBuilder( handle, hci_packets.PacketBoundaryFlag.FIRST_NON_AUTOMATICALLY_FLUSHABLE, hci_packets.BroadcastFlag.POINT_TO_POINT, request_b_frame) # Size is ACL (4) + L2CAP (4) + Configure (8) + MTU (4) + FCS (3) asserts.assert_true( len(wrapped.Serialize()) == 23, "Packet serialized incorrectly")
def test_respond_configuration_request_ertm(self): """ L2CAP/CMC/BV-02-C [Lower Tester Initiated Configuration of Enhanced Retransmission Mode] Verify the IUT can accept a Configuration Request from the Lower Tester containing an F&EC option that specifies Enhanced Retransmission Mode. """ self._setup_link_from_cert() psm = 1 scid = 0x0101 self.retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM self.dut.l2cap.SetDynamicChannel( l2cap_facade_pb2.SetEnableDynamicChannelRequest( psm=psm, retransmission_mode=self.retransmission_mode)) open_channel = l2cap_packets.ConnectionRequestBuilder(1, psm, scid) open_channel_l2cap = l2cap_packets.BasicFrameBuilder(1, open_channel) self.cert_send_b_frame(open_channel_l2cap) # TODO: Verify that the type should be ERTM assertThat(self.cert_l2cap.get_control_channel()).emits( L2capMatchers.ConfigurationResponse())
def send(self, packet): frame = l2cap_packets.BasicFrameBuilder(self._dcid, packet) self._acl.send(frame.Serialize()) self._credits_left -= 1