aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/bluetooth/hci_core.h1
-rw-r--r--net/bluetooth/hci_core.c56
2 files changed, 32 insertions, 25 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 4b192d0fa76e..79a75edc62d0 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1150,6 +1150,7 @@ void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen,
1150void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status); 1150void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status);
1151 1151
1152void hci_req_add_le_scan_disable(struct hci_request *req); 1152void hci_req_add_le_scan_disable(struct hci_request *req);
1153void hci_req_add_le_passive_scan(struct hci_request *req);
1153 1154
1154struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, 1155struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
1155 const void *param, u32 timeout); 1156 const void *param, u32 timeout);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 0b96f20238d8..bbd085d32d78 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -5115,6 +5115,36 @@ void hci_req_add_le_scan_disable(struct hci_request *req)
5115 hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); 5115 hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
5116} 5116}
5117 5117
5118void hci_req_add_le_passive_scan(struct hci_request *req)
5119{
5120 struct hci_cp_le_set_scan_param param_cp;
5121 struct hci_cp_le_set_scan_enable enable_cp;
5122 struct hci_dev *hdev = req->hdev;
5123 u8 own_addr_type;
5124
5125 /* Set require_privacy to true to avoid identification from
5126 * unknown peer devices. Since this is passive scanning, no
5127 * SCAN_REQ using the local identity should be sent. Mandating
5128 * privacy is just an extra precaution.
5129 */
5130 if (hci_update_random_address(req, true, &own_addr_type))
5131 return;
5132
5133 memset(&param_cp, 0, sizeof(param_cp));
5134 param_cp.type = LE_SCAN_PASSIVE;
5135 param_cp.interval = cpu_to_le16(hdev->le_scan_interval);
5136 param_cp.window = cpu_to_le16(hdev->le_scan_window);
5137 param_cp.own_address_type = own_addr_type;
5138 hci_req_add(req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp),
5139 &param_cp);
5140
5141 memset(&enable_cp, 0, sizeof(enable_cp));
5142 enable_cp.enable = LE_SCAN_ENABLE;
5143 enable_cp.filter_dup = LE_SCAN_FILTER_DUP_DISABLE;
5144 hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(enable_cp),
5145 &enable_cp);
5146}
5147
5118static void update_background_scan_complete(struct hci_dev *hdev, u8 status) 5148static void update_background_scan_complete(struct hci_dev *hdev, u8 status)
5119{ 5149{
5120 if (status) 5150 if (status)
@@ -5130,8 +5160,6 @@ static void update_background_scan_complete(struct hci_dev *hdev, u8 status)
5130 */ 5160 */
5131void hci_update_background_scan(struct hci_dev *hdev) 5161void hci_update_background_scan(struct hci_dev *hdev)
5132{ 5162{
5133 struct hci_cp_le_set_scan_param param_cp;
5134 struct hci_cp_le_set_scan_enable enable_cp;
5135 struct hci_request req; 5163 struct hci_request req;
5136 struct hci_conn *conn; 5164 struct hci_conn *conn;
5137 int err; 5165 int err;
@@ -5151,8 +5179,6 @@ void hci_update_background_scan(struct hci_dev *hdev)
5151 5179
5152 BT_DBG("%s stopping background scanning", hdev->name); 5180 BT_DBG("%s stopping background scanning", hdev->name);
5153 } else { 5181 } else {
5154 u8 own_addr_type;
5155
5156 /* If there is at least one pending LE connection, we should 5182 /* If there is at least one pending LE connection, we should
5157 * keep the background scan running. 5183 * keep the background scan running.
5158 */ 5184 */
@@ -5169,27 +5195,7 @@ void hci_update_background_scan(struct hci_dev *hdev)
5169 if (conn) 5195 if (conn)
5170 return; 5196 return;
5171 5197
5172 /* Set require_privacy to true to avoid identification from 5198 hci_req_add_le_passive_scan(&req);
5173 * unknown peer devices. Since this is passive scanning, no
5174 * SCAN_REQ using the local identity should be sent. Mandating
5175 * privacy is just an extra precaution.
5176 */
5177 if (hci_update_random_address(&req, true, &own_addr_type))
5178 return;
5179
5180 memset(&param_cp, 0, sizeof(param_cp));
5181 param_cp.type = LE_SCAN_PASSIVE;
5182 param_cp.interval = cpu_to_le16(hdev->le_scan_interval);
5183 param_cp.window = cpu_to_le16(hdev->le_scan_window);
5184 param_cp.own_address_type = own_addr_type;
5185 hci_req_add(&req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp),
5186 &param_cp);
5187
5188 memset(&enable_cp, 0, sizeof(enable_cp));
5189 enable_cp.enable = LE_SCAN_ENABLE;
5190 enable_cp.filter_dup = LE_SCAN_FILTER_DUP_DISABLE;
5191 hci_req_add(&req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(enable_cp),
5192 &enable_cp);
5193 5199
5194 BT_DBG("%s starting background scanning", hdev->name); 5200 BT_DBG("%s starting background scanning", hdev->name);
5195 } 5201 }