lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 22 Apr 2019 17:20:33 +0800
From:   Kai-Heng Feng <kai.heng.feng@...onical.com>
To:     marcel@...tmann.org, johan.hedberg@...il.com
Cc:     linux-bluetooth@...r.kernel.org, linux-kernel@...r.kernel.org,
        Kai-Heng Feng <kai.heng.feng@...onical.com>
Subject: [PATCH 1/2] Bluetooth: Add helpers to enable or disable LE Advertising

This patch adds helpers to enable or disable LE Advertising.
To be used by later patch.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@...onical.com>
---
 include/net/bluetooth/hci_core.h |  3 ++
 net/bluetooth/hci_core.c         | 47 ++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index e5ea633ea368..ef92dd12f816 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -269,6 +269,7 @@ struct hci_dev {
 	__u16		le_max_rx_time;
 	__u8		le_max_key_size;
 	__u8		le_min_key_size;
+	__u8		le_events[8];
 	__u16		discov_interleaved_timeout;
 	__u16		conn_info_min_age;
 	__u16		conn_info_max_age;
@@ -1141,6 +1142,8 @@ void hci_init_sysfs(struct hci_dev *hdev);
 void hci_conn_init_sysfs(struct hci_conn *conn);
 void hci_conn_add_sysfs(struct hci_conn *conn);
 void hci_conn_del_sysfs(struct hci_conn *conn);
+int hci_enable_le_advertising(struct hci_dev *hdev);
+int hci_disable_le_advertising(struct hci_dev *hdev);
 
 #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev))
 
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 7352fe85674b..0bed66908588 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -411,6 +412,53 @@ static void hci_setup_event_mask(struct hci_request *req)
 	hci_req_add(req, HCI_OP_SET_EVENT_MASK, sizeof(events), events);
 }
 
+static int hci_enable_le_advertising_req(struct hci_request *req, unsigned long opt)
+{
+	struct hci_dev *hdev = req->hdev;
+	u8 events[8];
+
+	memcpy(events, hdev->le_events, sizeof(events));
+
+	hci_req_add(req, HCI_OP_LE_SET_EVENT_MASK, sizeof(events),
+		    events);
+
+	return 0;
+}
+
+static int hci_disable_le_advertising_req(struct hci_request *req, unsigned long opt)
+{
+	struct hci_dev *hdev = req->hdev;
+
+	u8 events[8];
+
+	memcpy(events, hdev->le_events, sizeof(events));
+
+	events[0] &= ~(u8)0x02;	/* LE Advertising Report */
+
+	hci_req_add(req, HCI_OP_LE_SET_EVENT_MASK, sizeof(events),
+		    events);
+
+	return 0;
+}
+
+int hci_enable_le_advertising(struct hci_dev *hdev)
+{
+	if (!lmp_le_capable(hdev))
+		return 0;
+
+	return __hci_req_sync(hdev, hci_enable_le_advertising_req, 0, HCI_CMD_TIMEOUT, NULL);
+}
+EXPORT_SYMBOL(hci_enable_le_advertising);
+
+int hci_disable_le_advertising(struct hci_dev *hdev)
+{
+	if (!lmp_le_capable(hdev))
+		return 0;
+
+	return __hci_req_sync(hdev, hci_disable_le_advertising_req, 0, HCI_CMD_TIMEOUT, NULL);
+}
+EXPORT_SYMBOL(hci_disable_le_advertising);
+
 static int hci_init2_req(struct hci_request *req, unsigned long opt)
 {
 	struct hci_dev *hdev = req->hdev;
@@ -771,6 +818,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
 		}
 
 		hci_set_le_support(req);
+
+		memcpy(hdev->le_events, events, sizeof(events));
 	}
 
 	/* Read features beyond page 1 if available */
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ