% Regression tests for the bluetooth4LE layer ################################### #### Bluetooth 4.0 Low Energie #### ################################### + BTLE tests = Default build a = BTLE()/BTLE_ADV()/BTLE_ADV_IND() assert raw(a) == b'\xd6\xbe\x89\x8e\x00\x06\x00\x00\x00\x00\x00\x00Z9`' = Basic dissection b = BTLE(raw(a)) assert b.crc == 0x5a3960 assert b[BTLE_ADV_IND].AdvA == '00:00:00:00:00:00' = BTLE_DATA build a = BTLE(access_addr=0)/BTLE_DATA()/"toto" a = BTLE(raw(a)) assert a[BTLE_DATA].len == 4 assert a[Raw].load == b"toto" = BTLE_DATA + EIR_ShortenedLocalName test1 = BTLE() / BTLE_ADV() / BTLE_ADV_IND() / EIR_Hdr() / EIR_ShortenedLocalName(local_name= 'wussa') test1e = BTLE(raw(test1)) assert test1e[EIR_ShortenedLocalName].local_name == b"wussa" = BTLE_DATA + CtrlPDU test2 = BTLE(access_addr=1) / BTLE_DATA() / CtrlPDU(version=7) test2e = BTLE(raw(test2)) assert test2e[CtrlPDU].version == 7 = BTLE_DATA + ATT_PrepareWriteReq test3 = BTLE(access_addr=1) / BTLE_DATA() / L2CAP_Hdr() / ATT_Hdr() / ATT_PrepareWriteReq(handle = 0xa, value="test") test3e = BTLE(raw(test3)) assert test3e[ATT_PrepareWriteReq].value == b"test" assert test3e[ATT_PrepareWriteReq].handle == 0xa assert test3e[ATT_Hdr].opcode == 0x16 = BTLE layers # a crazy packet with all classes in it! pkt = BTLE()/BTLE_ADV()/BTLE_ADV_DIRECT_IND()/BTLE_ADV_IND()/BTLE_ADV_NONCONN_IND()/BTLE_ADV_SCAN_IND()/BTLE_CONNECT_REQ()/BTLE_DATA()/BTLE_PPI()/BTLE_SCAN_REQ()/BTLE_SCAN_RSP() assert BTLE in pkt.layers() assert BTLE_ADV in pkt.layers() assert BTLE_ADV_DIRECT_IND in pkt.layers() assert BTLE_ADV_IND in pkt.layers() assert BTLE_ADV_NONCONN_IND in pkt.layers() assert BTLE_ADV_SCAN_IND in pkt.layers() assert BTLE_CONNECT_REQ in pkt.layers() assert BTLE_DATA in pkt.layers() assert BTLE_PPI in pkt.layers() assert BTLE_SCAN_REQ in pkt.layers() assert BTLE_SCAN_RSP in pkt.layers() = BTLE_RF link a = BTLE_RF()/BTLE()/BTLE_ADV()/BTLE_SCAN_REQ() a.ScanA = "aa:aa:aa:aa:aa:aa" a.AdvA = "bb:bb:bb:bb:bb:bb" a.flags = 0x10 a.reference_access_address = 0x8e89bed6 a.noise = -90 a.signal = -75 a.rf_channel = 6 a.access_address_offenses = 10 assert raw(a) == b'\x06\xb5\xa6\n\xd6\xbe\x89\x8e\x10\x00\xd6\xbe\x89\x8e\x03\x0c\xaa\xaa\xaa\xaa\xaa\xaa\xbb\xbb\xbb\xbb\xbb\xbb\x07\xb2a' a = BTLE_RF(raw(a)) assert a.noise == -90 assert a.signal == -75 assert a.flags == "reference_access_address_valid" assert a[BTLE_SCAN_REQ].ScanA == "aa:aa:aa:aa:aa:aa" + Specific tests after issue GH#1673 = With PPI pkt = PPI(b'\x00\x00\x18\x00\x93\x00\x00\x006u\x0c\x00\x00b\t\x00\xe1\xcf\x01\x00\xf1\xe3\x92\x00\xd6\xbe\x89\x8e@\x14M\x95P\x16\xfev\x02\x01\x1a\n\xffL\x00\x10\x05\x0b\x1c\x0e\xa86Z\xf0\x04') assert BTLE_PPI in pkt.PPIFieldHeaders[0] assert BTLE in pkt = Without PPI pkt = BTLE_RF(b'\x00\xc6\x80\x00\xd6\xbe\x89\x8e7\x00\xd6\xbe\x89\x8e@\x14\x03g\xa6+\xcbi\x00\x01\x1a\n\xffL\x00\x12E\x03\x18y\x9e\x96\x07\xfa%') assert BTLE_RF in pkt assert BTLE in pkt