aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/bluetooth/hci_core.h2
-rw-r--r--include/net/bluetooth/mgmt.h8
-rw-r--r--net/bluetooth/hci_event.c22
-rw-r--r--net/bluetooth/mgmt.c17
4 files changed, 41 insertions, 8 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 3b2f09df279a..2a88fc82429b 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -787,6 +787,8 @@ int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status);
787int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status); 787int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status);
788int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, 788int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,
789 u8 status); 789 u8 status);
790int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi,
791 u8 *eir);
790 792
791/* HCI info for socket */ 793/* HCI info for socket */
792#define hci_pi(sk) ((struct hci_pinfo *) sk) 794#define hci_pi(sk) ((struct hci_pinfo *) sk)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 1a6283f9fee8..864d0cbd2d57 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -267,3 +267,11 @@ struct mgmt_ev_auth_failed {
267struct mgmt_ev_local_name_changed { 267struct mgmt_ev_local_name_changed {
268 __u8 name[MGMT_MAX_NAME_LENGTH]; 268 __u8 name[MGMT_MAX_NAME_LENGTH];
269} __packed; 269} __packed;
270
271#define MGMT_EV_DEVICE_FOUND 0x0012
272struct mgmt_ev_device_found {
273 bdaddr_t bdaddr;
274 __u8 dev_class[3];
275 __s8 rssi;
276 __u8 eir[HCI_MAX_EIR_LENGTH];
277} __packed;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 833797e9654b..d04011c06be0 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1228,7 +1228,7 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
1228 1228
1229 hci_dev_lock(hdev); 1229 hci_dev_lock(hdev);
1230 1230
1231 for (; num_rsp; num_rsp--) { 1231 for (; num_rsp; num_rsp--, info++) {
1232 bacpy(&data.bdaddr, &info->bdaddr); 1232 bacpy(&data.bdaddr, &info->bdaddr);
1233 data.pscan_rep_mode = info->pscan_rep_mode; 1233 data.pscan_rep_mode = info->pscan_rep_mode;
1234 data.pscan_period_mode = info->pscan_period_mode; 1234 data.pscan_period_mode = info->pscan_period_mode;
@@ -1237,8 +1237,9 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
1237 data.clock_offset = info->clock_offset; 1237 data.clock_offset = info->clock_offset;
1238 data.rssi = 0x00; 1238 data.rssi = 0x00;
1239 data.ssp_mode = 0x00; 1239 data.ssp_mode = 0x00;
1240 info++;
1241 hci_inquiry_cache_update(hdev, &data); 1240 hci_inquiry_cache_update(hdev, &data);
1241 mgmt_device_found(hdev->id, &info->bdaddr, info->dev_class, 0,
1242 NULL);
1242 } 1243 }
1243 1244
1244 hci_dev_unlock(hdev); 1245 hci_dev_unlock(hdev);
@@ -2158,7 +2159,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
2158 struct inquiry_info_with_rssi_and_pscan_mode *info; 2159 struct inquiry_info_with_rssi_and_pscan_mode *info;
2159 info = (void *) (skb->data + 1); 2160 info = (void *) (skb->data + 1);
2160 2161
2161 for (; num_rsp; num_rsp--) { 2162 for (; num_rsp; num_rsp--, info++) {
2162 bacpy(&data.bdaddr, &info->bdaddr); 2163 bacpy(&data.bdaddr, &info->bdaddr);
2163 data.pscan_rep_mode = info->pscan_rep_mode; 2164 data.pscan_rep_mode = info->pscan_rep_mode;
2164 data.pscan_period_mode = info->pscan_period_mode; 2165 data.pscan_period_mode = info->pscan_period_mode;
@@ -2167,13 +2168,15 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
2167 data.clock_offset = info->clock_offset; 2168 data.clock_offset = info->clock_offset;
2168 data.rssi = info->rssi; 2169 data.rssi = info->rssi;
2169 data.ssp_mode = 0x00; 2170 data.ssp_mode = 0x00;
2170 info++;
2171 hci_inquiry_cache_update(hdev, &data); 2171 hci_inquiry_cache_update(hdev, &data);
2172 mgmt_device_found(hdev->id, &info->bdaddr,
2173 info->dev_class, info->rssi,
2174 NULL);
2172 } 2175 }
2173 } else { 2176 } else {
2174 struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); 2177 struct inquiry_info_with_rssi *info = (void *) (skb->data + 1);
2175 2178
2176 for (; num_rsp; num_rsp--) { 2179 for (; num_rsp; num_rsp--, info++) {
2177 bacpy(&data.bdaddr, &info->bdaddr); 2180 bacpy(&data.bdaddr, &info->bdaddr);
2178 data.pscan_rep_mode = info->pscan_rep_mode; 2181 data.pscan_rep_mode = info->pscan_rep_mode;
2179 data.pscan_period_mode = info->pscan_period_mode; 2182 data.pscan_period_mode = info->pscan_period_mode;
@@ -2182,8 +2185,10 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
2182 data.clock_offset = info->clock_offset; 2185 data.clock_offset = info->clock_offset;
2183 data.rssi = info->rssi; 2186 data.rssi = info->rssi;
2184 data.ssp_mode = 0x00; 2187 data.ssp_mode = 0x00;
2185 info++;
2186 hci_inquiry_cache_update(hdev, &data); 2188 hci_inquiry_cache_update(hdev, &data);
2189 mgmt_device_found(hdev->id, &info->bdaddr,
2190 info->dev_class, info->rssi,
2191 NULL);
2187 } 2192 }
2188 } 2193 }
2189 2194
@@ -2314,7 +2319,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
2314 2319
2315 hci_dev_lock(hdev); 2320 hci_dev_lock(hdev);
2316 2321
2317 for (; num_rsp; num_rsp--) { 2322 for (; num_rsp; num_rsp--, info++) {
2318 bacpy(&data.bdaddr, &info->bdaddr); 2323 bacpy(&data.bdaddr, &info->bdaddr);
2319 data.pscan_rep_mode = info->pscan_rep_mode; 2324 data.pscan_rep_mode = info->pscan_rep_mode;
2320 data.pscan_period_mode = info->pscan_period_mode; 2325 data.pscan_period_mode = info->pscan_period_mode;
@@ -2323,8 +2328,9 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
2323 data.clock_offset = info->clock_offset; 2328 data.clock_offset = info->clock_offset;
2324 data.rssi = info->rssi; 2329 data.rssi = info->rssi;
2325 data.ssp_mode = 0x01; 2330 data.ssp_mode = 0x01;
2326 info++;
2327 hci_inquiry_cache_update(hdev, &data); 2331 hci_inquiry_cache_update(hdev, &data);
2332 mgmt_device_found(hdev->id, &info->bdaddr, info->dev_class,
2333 info->rssi, info->data);
2328 } 2334 }
2329 2335
2330 hci_dev_unlock(hdev); 2336 hci_dev_unlock(hdev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f87691e04dca..86fb50215485 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2046,3 +2046,20 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,
2046 2046
2047 return err; 2047 return err;
2048} 2048}
2049
2050int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi,
2051 u8 *eir)
2052{
2053 struct mgmt_ev_device_found ev;
2054
2055 memset(&ev, 0, sizeof(ev));
2056
2057 bacpy(&ev.bdaddr, bdaddr);
2058 memcpy(ev.dev_class, dev_class, sizeof(ev.dev_class));
2059 ev.rssi = rssi;
2060
2061 if (eir)
2062 memcpy(ev.eir, eir, sizeof(ev.eir));
2063
2064 return mgmt_event(MGMT_EV_DEVICE_FOUND, index, &ev, sizeof(ev), NULL);
2065}