aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ad6613d17ca6..a3329cbd3e4d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -193,6 +193,11 @@ static u8 mgmt_status_table[] = {
193 MGMT_STATUS_CONNECT_FAILED, /* MAC Connection Failed */ 193 MGMT_STATUS_CONNECT_FAILED, /* MAC Connection Failed */
194}; 194};
195 195
196bool mgmt_valid_hdev(struct hci_dev *hdev)
197{
198 return hdev->dev_type == HCI_BREDR;
199}
200
196static u8 mgmt_status(u8 hci_status) 201static u8 mgmt_status(u8 hci_status)
197{ 202{
198 if (hci_status < ARRAY_SIZE(mgmt_status_table)) 203 if (hci_status < ARRAY_SIZE(mgmt_status_table))
@@ -317,7 +322,6 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
317 u16 data_len) 322 u16 data_len)
318{ 323{
319 struct mgmt_rp_read_index_list *rp; 324 struct mgmt_rp_read_index_list *rp;
320 struct list_head *p;
321 struct hci_dev *d; 325 struct hci_dev *d;
322 size_t rp_len; 326 size_t rp_len;
323 u16 count; 327 u16 count;
@@ -328,7 +332,10 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
328 read_lock(&hci_dev_list_lock); 332 read_lock(&hci_dev_list_lock);
329 333
330 count = 0; 334 count = 0;
331 list_for_each(p, &hci_dev_list) { 335 list_for_each_entry(d, &hci_dev_list, list) {
336 if (!mgmt_valid_hdev(d))
337 continue;
338
332 count++; 339 count++;
333 } 340 }
334 341
@@ -346,6 +353,9 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
346 if (test_bit(HCI_SETUP, &d->dev_flags)) 353 if (test_bit(HCI_SETUP, &d->dev_flags))
347 continue; 354 continue;
348 355
356 if (!mgmt_valid_hdev(d))
357 continue;
358
349 rp->index[i++] = cpu_to_le16(d->id); 359 rp->index[i++] = cpu_to_le16(d->id);
350 BT_DBG("Added hci%u", d->id); 360 BT_DBG("Added hci%u", d->id);
351 } 361 }
@@ -370,10 +380,10 @@ static u32 get_supported_settings(struct hci_dev *hdev)
370 settings |= MGMT_SETTING_DISCOVERABLE; 380 settings |= MGMT_SETTING_DISCOVERABLE;
371 settings |= MGMT_SETTING_PAIRABLE; 381 settings |= MGMT_SETTING_PAIRABLE;
372 382
373 if (hdev->features[6] & LMP_SIMPLE_PAIR) 383 if (lmp_ssp_capable(hdev))
374 settings |= MGMT_SETTING_SSP; 384 settings |= MGMT_SETTING_SSP;
375 385
376 if (!(hdev->features[4] & LMP_NO_BREDR)) { 386 if (lmp_bredr_capable(hdev)) {
377 settings |= MGMT_SETTING_BREDR; 387 settings |= MGMT_SETTING_BREDR;
378 settings |= MGMT_SETTING_LINK_SECURITY; 388 settings |= MGMT_SETTING_LINK_SECURITY;
379 } 389 }
@@ -381,7 +391,7 @@ static u32 get_supported_settings(struct hci_dev *hdev)
381 if (enable_hs) 391 if (enable_hs)
382 settings |= MGMT_SETTING_HS; 392 settings |= MGMT_SETTING_HS;
383 393
384 if (hdev->features[4] & LMP_LE) 394 if (lmp_le_capable(hdev))
385 settings |= MGMT_SETTING_LE; 395 settings |= MGMT_SETTING_LE;
386 396
387 return settings; 397 return settings;
@@ -403,7 +413,7 @@ static u32 get_current_settings(struct hci_dev *hdev)
403 if (test_bit(HCI_PAIRABLE, &hdev->dev_flags)) 413 if (test_bit(HCI_PAIRABLE, &hdev->dev_flags))
404 settings |= MGMT_SETTING_PAIRABLE; 414 settings |= MGMT_SETTING_PAIRABLE;
405 415
406 if (!(hdev->features[4] & LMP_NO_BREDR)) 416 if (lmp_bredr_capable(hdev))
407 settings |= MGMT_SETTING_BREDR; 417 settings |= MGMT_SETTING_BREDR;
408 418
409 if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) 419 if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
@@ -1111,7 +1121,7 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1111 1121
1112 hci_dev_lock(hdev); 1122 hci_dev_lock(hdev);
1113 1123
1114 if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) { 1124 if (!lmp_ssp_capable(hdev)) {
1115 err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, 1125 err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
1116 MGMT_STATUS_NOT_SUPPORTED); 1126 MGMT_STATUS_NOT_SUPPORTED);
1117 goto failed; 1127 goto failed;
@@ -1195,7 +1205,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1195 1205
1196 hci_dev_lock(hdev); 1206 hci_dev_lock(hdev);
1197 1207
1198 if (!(hdev->features[4] & LMP_LE)) { 1208 if (!lmp_le_capable(hdev)) {
1199 err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE, 1209 err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
1200 MGMT_STATUS_NOT_SUPPORTED); 1210 MGMT_STATUS_NOT_SUPPORTED);
1201 goto unlock; 1211 goto unlock;
@@ -2191,7 +2201,7 @@ static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev,
2191 goto unlock; 2201 goto unlock;
2192 } 2202 }
2193 2203
2194 if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) { 2204 if (!lmp_ssp_capable(hdev)) {
2195 err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, 2205 err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA,
2196 MGMT_STATUS_NOT_SUPPORTED); 2206 MGMT_STATUS_NOT_SUPPORTED);
2197 goto unlock; 2207 goto unlock;
@@ -2820,6 +2830,9 @@ static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
2820 2830
2821int mgmt_index_added(struct hci_dev *hdev) 2831int mgmt_index_added(struct hci_dev *hdev)
2822{ 2832{
2833 if (!mgmt_valid_hdev(hdev))
2834 return -ENOTSUPP;
2835
2823 return mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL); 2836 return mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL);
2824} 2837}
2825 2838
@@ -2827,6 +2840,9 @@ int mgmt_index_removed(struct hci_dev *hdev)
2827{ 2840{
2828 u8 status = MGMT_STATUS_INVALID_INDEX; 2841 u8 status = MGMT_STATUS_INVALID_INDEX;
2829 2842
2843 if (!mgmt_valid_hdev(hdev))
2844 return -ENOTSUPP;
2845
2830 mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); 2846 mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
2831 2847
2832 return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL); 2848 return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL);