Skip to content

Commit a8583a5

Browse files
bluetooth: Add EIR service solicitation types (#4602)
1 parent 535fc33 commit a8583a5

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

scapy/layers/bluetooth.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,30 @@ class EIR_Device_ID(EIR_Element):
12191219
]
12201220

12211221

1222+
class EIR_ServiceSolicitation16BitUUID(EIR_Element):
1223+
name = "EIR Service Solicitation - 16-bit UUID"
1224+
fields_desc = [
1225+
XLEShortField("svc_uuid", None)
1226+
]
1227+
1228+
def extract_padding(self, s):
1229+
# Needed to end each EIR_Element packet and make PacketListField work.
1230+
plen = EIR_Element.length_from(self) - 2
1231+
return s[:plen], s[plen:]
1232+
1233+
1234+
class EIR_ServiceSolicitation128BitUUID(EIR_Element):
1235+
name = "EIR Service Solicitation - 128-bit UUID"
1236+
fields_desc = [
1237+
UUIDField('svc_uuid', None, uuid_fmt=UUIDField.FORMAT_REV)
1238+
]
1239+
1240+
def extract_padding(self, s):
1241+
# Needed to end each EIR_Element packet and make PacketListField work.
1242+
plen = EIR_Element.length_from(self) - 2
1243+
return s[:plen], s[plen:]
1244+
1245+
12221246
class EIR_ServiceData16BitUUID(EIR_Element):
12231247
name = "EIR Service Data - 16-bit UUID"
12241248
fields_desc = [
@@ -2348,6 +2372,8 @@ class HCI_LE_Meta_Long_Term_Key_Request(Packet):
23482372
bind_layers(EIR_Hdr, EIR_SecureSimplePairingRandomizerR192, type=0x0f)
23492373
bind_layers(EIR_Hdr, EIR_SecurityManagerOOBFlags, type=0x11)
23502374
bind_layers(EIR_Hdr, EIR_PeripheralConnectionIntervalRange, type=0x12)
2375+
bind_layers(EIR_Hdr, EIR_ServiceSolicitation16BitUUID, type=0x14)
2376+
bind_layers(EIR_Hdr, EIR_ServiceSolicitation128BitUUID, type=0x15)
23512377
bind_layers(EIR_Hdr, EIR_ServiceData16BitUUID, type=0x16)
23522378
bind_layers(EIR_Hdr, EIR_PublicTargetAddress, type=0x17)
23532379
bind_layers(EIR_Hdr, EIR_ServiceData32BitUUID, type=0x20)

test/scapy/layers/bluetooth.uts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,13 @@ except TypeError:
552552
else:
553553
assert False, "expected exception"
554554

555+
= Parse EIR_ServiceSolicitation16BitUUID and EIR_ServiceSolicitation128BitUUID
556+
557+
d = hex_bytes("043e29020100013d1ef10747d81d0319000002010603140d181115d0002d121e4b0fa4994eceb531f40579aa")
558+
p = HCI_Hdr(d)
559+
assert p[EIR_ServiceSolicitation16BitUUID].svc_uuid == 0x180d
560+
assert p[EIR_ServiceSolicitation128BitUUID].svc_uuid == UUID('7905f431-b5ce-4e99-a40f-4b1e122d00d0')
561+
555562
= Parse EIR_ServiceData16BitUUID
556563

557564
d = hex_bytes("043e1902010001abcdef7da97f0d020102030350fe051650fee6c2ac")

0 commit comments

Comments
 (0)