diff --git a/scapy/layers/bluetooth.py b/scapy/layers/bluetooth.py index 9d7fe252feb..9e131f69d84 100644 --- a/scapy/layers/bluetooth.py +++ b/scapy/layers/bluetooth.py @@ -1219,6 +1219,30 @@ class EIR_Device_ID(EIR_Element): ] +class EIR_ServiceSolicitation16BitUUID(EIR_Element): + name = "EIR Service Solicitation - 16-bit UUID" + fields_desc = [ + XLEShortField("svc_uuid", None) + ] + + def extract_padding(self, s): + # Needed to end each EIR_Element packet and make PacketListField work. + plen = EIR_Element.length_from(self) - 2 + return s[:plen], s[plen:] + + +class EIR_ServiceSolicitation128BitUUID(EIR_Element): + name = "EIR Service Solicitation - 128-bit UUID" + fields_desc = [ + UUIDField('svc_uuid', None, uuid_fmt=UUIDField.FORMAT_REV) + ] + + def extract_padding(self, s): + # Needed to end each EIR_Element packet and make PacketListField work. + plen = EIR_Element.length_from(self) - 2 + return s[:plen], s[plen:] + + class EIR_ServiceData16BitUUID(EIR_Element): name = "EIR Service Data - 16-bit UUID" fields_desc = [ @@ -2348,6 +2372,8 @@ class HCI_LE_Meta_Long_Term_Key_Request(Packet): bind_layers(EIR_Hdr, EIR_SecureSimplePairingRandomizerR192, type=0x0f) bind_layers(EIR_Hdr, EIR_SecurityManagerOOBFlags, type=0x11) bind_layers(EIR_Hdr, EIR_PeripheralConnectionIntervalRange, type=0x12) +bind_layers(EIR_Hdr, EIR_ServiceSolicitation16BitUUID, type=0x14) +bind_layers(EIR_Hdr, EIR_ServiceSolicitation128BitUUID, type=0x15) bind_layers(EIR_Hdr, EIR_ServiceData16BitUUID, type=0x16) bind_layers(EIR_Hdr, EIR_PublicTargetAddress, type=0x17) bind_layers(EIR_Hdr, EIR_ServiceData32BitUUID, type=0x20) diff --git a/test/scapy/layers/bluetooth.uts b/test/scapy/layers/bluetooth.uts index a50b078fcbd..73daa4eabce 100644 --- a/test/scapy/layers/bluetooth.uts +++ b/test/scapy/layers/bluetooth.uts @@ -552,6 +552,13 @@ except TypeError: else: assert False, "expected exception" += Parse EIR_ServiceSolicitation16BitUUID and EIR_ServiceSolicitation128BitUUID + +d = hex_bytes("043e29020100013d1ef10747d81d0319000002010603140d181115d0002d121e4b0fa4994eceb531f40579aa") +p = HCI_Hdr(d) +assert p[EIR_ServiceSolicitation16BitUUID].svc_uuid == 0x180d +assert p[EIR_ServiceSolicitation128BitUUID].svc_uuid == UUID('7905f431-b5ce-4e99-a40f-4b1e122d00d0') + = Parse EIR_ServiceData16BitUUID d = hex_bytes("043e1902010001abcdef7da97f0d020102030350fe051650fee6c2ac")