scapy/test/bluetooth4LE.uts

40 lines
1.1 KiB
Plaintext
Raw Normal View History

% 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"
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"
test2 = BTLE(access_addr=1) / BTLE_DATA() / CtrlPDU(version=7)
test2e = BTLE(raw(test2))
assert test2e[CtrlPDU].version == 7
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