Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions scapy/layers/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,18 @@ class EIR_AdvertisingInterval(EIR_Element):
]


class EIR_LEBluetoothDeviceAddress(EIR_Element):
name = "LE Bluetooth Device Address"
fields_desc = [
XBitField('reserved', 0, 7, tot_size=-1),
BitEnumField('addr_type', 0, 1, end_tot_size=-1, enum={
0x0: 'Public',
0x1: 'Random'
}),
LEMACField('bd_addr', None)
]


class EIR_Appearance(EIR_Element):
name = "EIR_Appearance"
fields_desc = [
Expand Down Expand Up @@ -2649,6 +2661,7 @@ class HCI_LE_Meta_Long_Term_Key_Request(Packet):
bind_layers(EIR_Hdr, EIR_PublicTargetAddress, type=0x17)
bind_layers(EIR_Hdr, EIR_Appearance, type=0x19)
bind_layers(EIR_Hdr, EIR_AdvertisingInterval, type=0x1a)
bind_layers(EIR_Hdr, EIR_LEBluetoothDeviceAddress, type=0x1b)
bind_layers(EIR_Hdr, EIR_ServiceData32BitUUID, type=0x20)
bind_layers(EIR_Hdr, EIR_ServiceData128BitUUID, type=0x21)
bind_layers(EIR_Hdr, EIR_URI, type=0x24)
Expand Down
6 changes: 6 additions & 0 deletions test/scapy/layers/bluetooth.uts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,12 @@ p = HCI_Event_Hdr(hex_bytes('3e23020100002e4961121110170201060f0954656c655361742
assert EIR_AdvertisingInterval in p
assert p[EIR_AdvertisingInterval].advertising_interval == 400

= Parse EIR_LEBluetoothDeviceAddress
p = HCI_Event_Hdr(hex_bytes("3e2a02010000d93519d7ba4c1e0201020affc4000734151317fd80081b00d93519d7ba4c0303b9fe020ad4ad"))
assert EIR_LEBluetoothDeviceAddress in p
assert p[EIR_LEBluetoothDeviceAddress].addr_type == 0x0
assert p[EIR_LEBluetoothDeviceAddress].bd_addr == '4c:ba:d7:19:35:d9'

= Parse EIR_Appearance
p = BTLE(hex_bytes("d6be898e201660d4d3cebffb0201050319420c0303e7fe040948393850c27c"))
assert EIR_Appearance in p
Expand Down
Loading