From 1a99f355295116d8efd147c9a7a287f422fe928b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martijn=20The=CC=81?= <martijn@pebble.com> Date: Mon, 25 Apr 2016 22:33:06 +0200 Subject: [PATCH] Bluetooth: Add HCI Disconnect command --- scapy/layers/bluetooth.py | 6 ++++++ test/bluetooth.uts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/scapy/layers/bluetooth.py b/scapy/layers/bluetooth.py index c6081814..56310bec 100644 --- a/scapy/layers/bluetooth.py +++ b/scapy/layers/bluetooth.py @@ -464,6 +464,11 @@ class HCI_Cmd_LE_Set_Scan_Enable(Packet): fields_desc = [ ByteField("enable", 1), ByteField("filter_dups", 1), ] +class HCI_Cmd_Disconnect(Packet): + name = "Disconnect" + fields_desc = [ XLEShortField("handle", 0), + ByteField("reason", 0x13), ] + class HCI_Cmd_LE_Create_Connection(Packet): name = "LE Create Connection" fields_desc = [ LEShortField("interval", 96), @@ -613,6 +618,7 @@ bind_layers( HCI_Command_Hdr, HCI_Cmd_LE_Set_Advertising_Data, opcode=0x2008) bind_layers( HCI_Command_Hdr, HCI_Cmd_LE_Set_Advertise_Enable, opcode=0x200a) bind_layers( HCI_Command_Hdr, HCI_Cmd_LE_Set_Scan_Parameters, opcode=0x200b) bind_layers( HCI_Command_Hdr, HCI_Cmd_LE_Set_Scan_Enable, opcode=0x200c) +bind_layers( HCI_Command_Hdr, HCI_Cmd_Disconnect, opcode=0x406) bind_layers( HCI_Command_Hdr, HCI_Cmd_LE_Create_Connection, opcode=0x200d) bind_layers( HCI_Command_Hdr, HCI_Cmd_LE_Create_Connection_Cancel, opcode=0x200e) bind_layers( HCI_Command_Hdr, HCI_Cmd_LE_Long_Term_Key_Request_Reply, opcode=0x201a) diff --git a/test/bluetooth.uts b/test/bluetooth.uts index 0f3e8c02..65c46449 100644 --- a/test/bluetooth.uts +++ b/test/bluetooth.uts @@ -7,6 +7,11 @@ expected_cmd_raw_data = "010e2000".decode('hex') cmd_raw_data = str(HCI_Hdr() / HCI_Command_Hdr() / HCI_Cmd_LE_Create_Connection_Cancel()) assert(expected_cmd_raw_data == cmd_raw_data) += Disconnect +expected_cmd_raw_data = "01060403341213".decode('hex') +cmd_raw_data = str(HCI_Hdr() / HCI_Command_Hdr() / HCI_Cmd_Disconnect(handle=0x1234)) +assert(expected_cmd_raw_data == cmd_raw_data) + + Bluetooth LE Advertising / Scan Response Data Parsing = Parse EIR_Flags, EIR_CompleteList16BitServiceUUIDs, EIR_CompleteLocalName and EIR_TX_Power_Level -- GitLab