Lines Matching +full:unlock +full:- +full:keys

2    BlueZ - Bluetooth protocol stack for Linux
5 Copyright (C) 2011-2012 Intel Corporation
291 case -EPERM: in mgmt_errno_status()
293 case -EINVAL: in mgmt_errno_status()
295 case -EOPNOTSUPP: in mgmt_errno_status()
297 case -EBUSY: in mgmt_errno_status()
299 case -ETIMEDOUT: in mgmt_errno_status()
301 case -ENOMEM: in mgmt_errno_status()
303 case -EISCONN: in mgmt_errno_status()
305 case -ENOTCONN: in mgmt_errno_status()
362 rp->version = MGMT_VERSION; in mgmt_fill_version_info()
363 rp->revision = cpu_to_le16(MGMT_REVISION); in mgmt_fill_version_info()
401 return -ENOMEM; in read_commands()
403 rp->num_commands = cpu_to_le16(num_commands); in read_commands()
404 rp->num_events = cpu_to_le16(num_events); in read_commands()
407 __le16 *opcode = rp->opcodes; in read_commands()
415 __le16 *opcode = rp->opcodes; in read_commands()
446 if (d->dev_type == HCI_PRIMARY && in read_index_list()
455 return -ENOMEM; in read_index_list()
465 /* Devices marked as raw-only are neither configured in read_index_list()
468 if (test_bit(HCI_QUIRK_RAW_DEVICE, &d->quirks)) in read_index_list()
471 if (d->dev_type == HCI_PRIMARY && in read_index_list()
473 rp->index[count++] = cpu_to_le16(d->id); in read_index_list()
474 bt_dev_dbg(hdev, "Added hci%u", d->id); in read_index_list()
478 rp->num_controllers = cpu_to_le16(count); in read_index_list()
506 if (d->dev_type == HCI_PRIMARY && in read_unconf_index_list()
515 return -ENOMEM; in read_unconf_index_list()
525 /* Devices marked as raw-only are neither configured in read_unconf_index_list()
528 if (test_bit(HCI_QUIRK_RAW_DEVICE, &d->quirks)) in read_unconf_index_list()
531 if (d->dev_type == HCI_PRIMARY && in read_unconf_index_list()
533 rp->index[count++] = cpu_to_le16(d->id); in read_unconf_index_list()
534 bt_dev_dbg(hdev, "Added hci%u", d->id); in read_unconf_index_list()
538 rp->num_controllers = cpu_to_le16(count); in read_unconf_index_list()
565 if (d->dev_type == HCI_PRIMARY || d->dev_type == HCI_AMP) in read_ext_index_list()
572 return -ENOMEM; in read_ext_index_list()
582 /* Devices marked as raw-only are neither configured in read_ext_index_list()
585 if (test_bit(HCI_QUIRK_RAW_DEVICE, &d->quirks)) in read_ext_index_list()
588 if (d->dev_type == HCI_PRIMARY) { in read_ext_index_list()
590 rp->entry[count].type = 0x01; in read_ext_index_list()
592 rp->entry[count].type = 0x00; in read_ext_index_list()
593 } else if (d->dev_type == HCI_AMP) { in read_ext_index_list()
594 rp->entry[count].type = 0x02; in read_ext_index_list()
599 rp->entry[count].bus = d->bus; in read_ext_index_list()
600 rp->entry[count++].index = cpu_to_le16(d->id); in read_ext_index_list()
601 bt_dev_dbg(hdev, "Added hci%u", d->id); in read_ext_index_list()
604 rp->num_controllers = cpu_to_le16(count); in read_ext_index_list()
627 if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) && in is_configured()
631 if ((test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks) || in is_configured()
632 test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks)) && in is_configured()
633 !bacmp(&hdev->public_addr, BDADDR_ANY)) in is_configured()
643 if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) && in get_missing_options()
647 if ((test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks) || in get_missing_options()
648 test_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks)) && in get_missing_options()
649 !bacmp(&hdev->public_addr, BDADDR_ANY)) in get_missing_options()
667 return mgmt_cmd_complete(sk, hdev->id, opcode, 0, &options, in send_options_rsp()
682 rp.manufacturer = cpu_to_le16(hdev->manufacturer); in read_config_info()
684 if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks)) in read_config_info()
687 if (hdev->set_bdaddr) in read_config_info()
695 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_READ_CONFIG_INFO, 0, in read_config_info()
706 if (hdev->features[0][0] & LMP_3SLOT) in get_supported_phys()
709 if (hdev->features[0][0] & LMP_5SLOT) in get_supported_phys()
737 if (hdev->le_features[1] & HCI_LE_PHY_2M) { in get_supported_phys()
742 if (hdev->le_features[1] & HCI_LE_PHY_CODED) { in get_supported_phys()
758 if (hdev->pkt_type & (HCI_DM3 | HCI_DH3)) in get_selected_phys()
761 if (hdev->pkt_type & (HCI_DM5 | HCI_DH5)) in get_selected_phys()
765 if (!(hdev->pkt_type & HCI_2DH1)) in get_selected_phys()
769 !(hdev->pkt_type & HCI_2DH3)) in get_selected_phys()
773 !(hdev->pkt_type & HCI_2DH5)) in get_selected_phys()
777 if (!(hdev->pkt_type & HCI_3DH1)) in get_selected_phys()
781 !(hdev->pkt_type & HCI_3DH3)) in get_selected_phys()
785 !(hdev->pkt_type & HCI_3DH5)) in get_selected_phys()
792 if (hdev->le_tx_def_phys & HCI_LE_SET_PHY_1M) in get_selected_phys()
795 if (hdev->le_rx_def_phys & HCI_LE_SET_PHY_1M) in get_selected_phys()
798 if (hdev->le_tx_def_phys & HCI_LE_SET_PHY_2M) in get_selected_phys()
801 if (hdev->le_rx_def_phys & HCI_LE_SET_PHY_2M) in get_selected_phys()
804 if (hdev->le_tx_def_phys & HCI_LE_SET_PHY_CODED) in get_selected_phys()
807 if (hdev->le_rx_def_phys & HCI_LE_SET_PHY_CODED) in get_selected_phys()
831 if (hdev->hci_ver >= BLUETOOTH_VER_1_2) in get_supported_settings()
846 &hdev->quirks)) in get_supported_settings()
858 if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) || in get_supported_settings()
859 hdev->set_bdaddr) in get_supported_settings()
921 * For single mode LE only controllers and dual-mode controllers in get_current_settings()
927 !bacmp(&hdev->bdaddr, BDADDR_ANY)) { in get_current_settings()
928 if (bacmp(&hdev->static_addr, BDADDR_ANY)) in get_current_settings()
952 struct mgmt_mode *cp = cmd->param; in mgmt_get_adv_discov_flags()
953 if (cp->val == 0x01) in mgmt_get_adv_discov_flags()
955 else if (cp->val == 0x02) in mgmt_get_adv_discov_flags()
976 struct mgmt_mode *cp = cmd->param; in mgmt_get_connectable()
978 return cp->val; in mgmt_get_connectable()
1010 return hci_start_ext_adv_sync(hdev, hdev->cur_adv_instance); in rpa_expired_sync()
1046 hdev->discov_timeout = 0; in discov_off()
1060 u8 handle = mesh_tx->handle; in mesh_send_complete()
1119 INIT_DELAYED_WORK(&hdev->discov_off, discov_off); in mgmt_init_hdev()
1120 INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); in mgmt_init_hdev()
1121 INIT_DELAYED_WORK(&hdev->rpa_expired, rpa_expired); in mgmt_init_hdev()
1122 INIT_DELAYED_WORK(&hdev->mesh_send_done, mesh_send_done); in mgmt_init_hdev()
1124 /* Non-mgmt controlled devices get this bit set in mgmt_init_hdev()
1126 * for mgmt we require user-space to explicitly enable in mgmt_init_hdev()
1145 bacpy(&rp.bdaddr, &hdev->bdaddr); in read_controller_info()
1147 rp.version = hdev->hci_ver; in read_controller_info()
1148 rp.manufacturer = cpu_to_le16(hdev->manufacturer); in read_controller_info()
1153 memcpy(rp.dev_class, hdev->dev_class, 3); in read_controller_info()
1155 memcpy(rp.name, hdev->dev_name, sizeof(hdev->dev_name)); in read_controller_info()
1156 memcpy(rp.short_name, hdev->short_name, sizeof(hdev->short_name)); in read_controller_info()
1160 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_READ_INFO, 0, &rp, in read_controller_info()
1171 hdev->dev_class, 3); in append_eir_data_to_buf()
1175 hdev->appearance); in append_eir_data_to_buf()
1177 name_len = strnlen(hdev->dev_name, sizeof(hdev->dev_name)); in append_eir_data_to_buf()
1179 hdev->dev_name, name_len); in append_eir_data_to_buf()
1181 name_len = strnlen(hdev->short_name, sizeof(hdev->short_name)); in append_eir_data_to_buf()
1183 hdev->short_name, name_len); in append_eir_data_to_buf()
1201 bacpy(&rp->bdaddr, &hdev->bdaddr); in read_ext_controller_info()
1203 rp->version = hdev->hci_ver; in read_ext_controller_info()
1204 rp->manufacturer = cpu_to_le16(hdev->manufacturer); in read_ext_controller_info()
1206 rp->supported_settings = cpu_to_le32(get_supported_settings(hdev)); in read_ext_controller_info()
1207 rp->current_settings = cpu_to_le32(get_current_settings(hdev)); in read_ext_controller_info()
1210 eir_len = append_eir_data_to_buf(hdev, rp->eir); in read_ext_controller_info()
1211 rp->eir_len = cpu_to_le16(eir_len); in read_ext_controller_info()
1224 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_READ_EXT_INFO, 0, rp, in read_ext_controller_info()
1236 eir_len = append_eir_data_to_buf(hdev, ev->eir); in ext_info_changed()
1237 ev->eir_len = cpu_to_le16(eir_len); in ext_info_changed()
1248 return mgmt_cmd_complete(sk, hdev->id, opcode, 0, &settings, in send_settings_rsp()
1273 if (hdev->adv_instance_timeout) { in cancel_adv_timeout()
1274 hdev->adv_instance_timeout = 0; in cancel_adv_timeout()
1275 cancel_delayed_work(&hdev->adv_instance_expire); in cancel_adv_timeout()
1279 /* This function requires the caller holds hdev->lock */
1284 list_for_each_entry(p, &hdev->le_conn_params, list) { in restart_le_actions()
1288 list_del_init(&p->action); in restart_le_actions()
1290 switch (p->auto_connect) { in restart_le_actions()
1293 list_add(&p->action, &hdev->pend_le_conns); in restart_le_actions()
1296 list_add(&p->action, &hdev->pend_le_reports); in restart_le_actions()
1321 cp = cmd->param; in mgmt_set_powered_complete()
1326 if (cp->val) { in mgmt_set_powered_complete()
1333 send_settings_rsp(cmd->sk, cmd->opcode, hdev); in mgmt_set_powered_complete()
1336 * to hdev->power_off work which does call hci_dev_do_close. in mgmt_set_powered_complete()
1338 if (cp->val) in mgmt_set_powered_complete()
1339 new_settings(hdev, cmd->sk); in mgmt_set_powered_complete()
1341 mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_POWERED, in mgmt_set_powered_complete()
1351 struct mgmt_mode *cp = cmd->param; in set_powered_sync()
1353 BT_DBG("%s", hdev->name); in set_powered_sync()
1355 return hci_set_powered_sync(hdev, cp->val); in set_powered_sync()
1367 if (cp->val != 0x00 && cp->val != 0x01) in set_powered()
1368 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED, in set_powered()
1374 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED, in set_powered()
1379 if (!!cp->val == hdev_is_powered(hdev)) { in set_powered()
1386 err = -ENOMEM; in set_powered()
1416 send_settings_rsp(cmd->sk, cmd->opcode, match->hdev); in settings_rsp()
1418 list_del(&cmd->list); in settings_rsp()
1420 if (match->sk == NULL) { in settings_rsp()
1421 match->sk = cmd->sk; in settings_rsp()
1422 sock_hold(match->sk); in settings_rsp()
1432 mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, *status); in cmd_status_rsp()
1438 if (cmd->cmd_complete) { in cmd_complete_rsp()
1441 cmd->cmd_complete(cmd, *status); in cmd_complete_rsp()
1452 return mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status, in generic_cmd_complete()
1453 cmd->param, cmd->param_len); in generic_cmd_complete()
1458 return mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status, in addr_cmd_complete()
1459 cmd->param, sizeof(struct mgmt_addr_info)); in addr_cmd_complete()
1497 mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err); in mgmt_set_discoverable_complete()
1503 hdev->discov_timeout > 0) { in mgmt_set_discoverable_complete()
1504 int to = msecs_to_jiffies(hdev->discov_timeout * 1000); in mgmt_set_discoverable_complete()
1505 queue_delayed_work(hdev->req_workqueue, &hdev->discov_off, to); in mgmt_set_discoverable_complete()
1508 send_settings_rsp(cmd->sk, MGMT_OP_SET_DISCOVERABLE, hdev); in mgmt_set_discoverable_complete()
1509 new_settings(hdev, cmd->sk); in mgmt_set_discoverable_complete()
1518 BT_DBG("%s", hdev->name); in set_discoverable_sync()
1535 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, in set_discoverable()
1538 if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02) in set_discoverable()
1539 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, in set_discoverable()
1542 timeout = __le16_to_cpu(cp->timeout); in set_discoverable()
1547 if ((cp->val == 0x00 && timeout > 0) || in set_discoverable()
1548 (cp->val == 0x02 && timeout == 0)) in set_discoverable()
1549 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, in set_discoverable()
1555 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, in set_discoverable()
1562 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, in set_discoverable()
1568 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, in set_discoverable()
1573 if (hdev->advertising_paused) { in set_discoverable()
1574 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, in set_discoverable()
1586 if (!!cp->val != hci_dev_test_flag(hdev, HCI_DISCOVERABLE)) { in set_discoverable()
1605 if (!!cp->val == hci_dev_test_flag(hdev, HCI_DISCOVERABLE) && in set_discoverable()
1606 (cp->val == 0x02) == hci_dev_test_flag(hdev, in set_discoverable()
1608 cancel_delayed_work(&hdev->discov_off); in set_discoverable()
1609 hdev->discov_timeout = timeout; in set_discoverable()
1611 if (cp->val && hdev->discov_timeout > 0) { in set_discoverable()
1612 int to = msecs_to_jiffies(hdev->discov_timeout * 1000); in set_discoverable()
1613 queue_delayed_work(hdev->req_workqueue, in set_discoverable()
1614 &hdev->discov_off, to); in set_discoverable()
1623 err = -ENOMEM; in set_discoverable()
1631 cancel_delayed_work(&hdev->discov_off); in set_discoverable()
1632 hdev->discov_timeout = timeout; in set_discoverable()
1634 if (cp->val) in set_discoverable()
1640 if (cp->val == 0x02) in set_discoverable()
1671 mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err); in mgmt_set_connectable_complete()
1675 send_settings_rsp(cmd->sk, MGMT_OP_SET_CONNECTABLE, hdev); in mgmt_set_connectable_complete()
1676 new_settings(hdev, cmd->sk); in mgmt_set_connectable_complete()
1716 BT_DBG("%s", hdev->name); in set_connectable_sync()
1732 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, in set_connectable()
1735 if (cp->val != 0x00 && cp->val != 0x01) in set_connectable()
1736 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, in set_connectable()
1742 err = set_connectable_update_settings(hdev, sk, cp->val); in set_connectable()
1748 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, in set_connectable()
1755 err = -ENOMEM; in set_connectable()
1759 if (cp->val) { in set_connectable()
1762 if (hdev->discov_timeout > 0) in set_connectable()
1763 cancel_delayed_work(&hdev->discov_off); in set_connectable()
1790 if (cp->val != 0x00 && cp->val != 0x01) in set_bondable()
1791 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BONDABLE, in set_bondable()
1796 if (cp->val) in set_bondable()
1803 goto unlock; in set_bondable()
1814 unlock: in set_bondable()
1831 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, in set_link_security()
1834 if (cp->val != 0x00 && cp->val != 0x01) in set_link_security()
1835 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, in set_link_security()
1843 if (!!cp->val != hci_dev_test_flag(hdev, HCI_LINK_SECURITY)) { in set_link_security()
1859 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, in set_link_security()
1864 val = !!cp->val; in set_link_security()
1866 if (test_bit(HCI_AUTH, &hdev->flags) == val) { in set_link_security()
1873 err = -ENOMEM; in set_link_security()
1892 struct mgmt_mode *cp = cmd->param; in set_ssp_complete()
1893 u8 enable = cp->val; in set_ssp_complete()
1940 struct mgmt_mode *cp = cmd->param; in set_ssp_sync()
1944 if (cp->val) in set_ssp_sync()
1947 err = hci_write_ssp_mode_sync(hdev, cp->val); in set_ssp_sync()
1966 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, status); in set_ssp()
1969 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, in set_ssp()
1972 if (cp->val != 0x00 && cp->val != 0x01) in set_ssp()
1973 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, in set_ssp()
1981 if (cp->val) { in set_ssp()
2005 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, in set_ssp()
2010 if (!!cp->val == hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) { in set_ssp()
2017 err = -ENOMEM; in set_ssp()
2023 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, in set_ssp()
2045 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, in set_hs()
2050 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, status); in set_hs()
2053 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, in set_hs()
2057 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, in set_hs()
2060 if (cp->val != 0x00 && cp->val != 0x01) in set_hs()
2061 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, in set_hs()
2067 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, in set_hs()
2069 goto unlock; in set_hs()
2072 if (cp->val) { in set_hs()
2076 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, in set_hs()
2078 goto unlock; in set_hs()
2086 goto unlock; in set_hs()
2091 unlock: in set_hs()
2120 struct mgmt_mode *cp = cmd->param; in set_le_sync()
2121 u8 val = !!cp->val; in set_le_sync()
2131 hci_remove_ext_adv_instance_sync(hdev, 0, cmd->sk); in set_le_sync()
2165 struct sock *sk = cmd->sk; in set_mesh_complete()
2174 mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER, 0, NULL, 0); in set_mesh_complete()
2180 struct mgmt_cp_set_mesh *cp = cmd->param; in set_mesh_sync()
2181 size_t len = cmd->param_len; in set_mesh_sync()
2183 memset(hdev->mesh_ad_types, 0, sizeof(hdev->mesh_ad_types)); in set_mesh_sync()
2185 if (cp->enable) in set_mesh_sync()
2190 len -= sizeof(*cp); in set_mesh_sync()
2193 if (len <= sizeof(hdev->mesh_ad_types)) in set_mesh_sync()
2194 memcpy(hdev->mesh_ad_types, cp->ad_types, len); in set_mesh_sync()
2210 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER, in set_mesh()
2213 if (cp->enable != 0x00 && cp->enable != 0x01) in set_mesh()
2214 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER, in set_mesh()
2221 err = -ENOMEM; in set_mesh()
2227 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER, in set_mesh()
2241 struct mgmt_cp_mesh_send *send = (void *)mesh_tx->param; in mesh_send_start_complete()
2254 mesh_send_interval = msecs_to_jiffies((send->cnt) * 25); in mesh_send_start_complete()
2255 queue_delayed_work(hdev->req_workqueue, &hdev->mesh_send_done, in mesh_send_start_complete()
2262 struct mgmt_cp_mesh_send *send = (void *)mesh_tx->param; in mesh_send_sync()
2264 u8 instance = hdev->le_num_of_adv_sets + 1; in mesh_send_sync()
2268 if (hdev->le_num_of_adv_sets <= hdev->adv_instance_cnt) in mesh_send_sync()
2272 duration = send->cnt * INTERVAL_TO_MS(hdev->le_adv_max_interval); in mesh_send_sync()
2274 send->adv_data_len, send->adv_data, in mesh_send_sync()
2278 hdev->le_adv_min_interval, in mesh_send_sync()
2279 hdev->le_adv_max_interval, in mesh_send_sync()
2280 mesh_tx->handle); in mesh_send_sync()
2283 mesh_tx->instance = instance; in mesh_send_sync()
2287 if (hdev->cur_adv_instance == instance) { in mesh_send_sync()
2297 instance = next_instance->instance; in mesh_send_sync()
2300 } else if (hdev->adv_instance_timeout) { in mesh_send_sync()
2317 if (rp->used_handles >= rp->max_handles) in send_count()
2320 rp->handles[rp->used_handles++] = mesh_tx->handle; in send_count()
2330 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_READ_FEATURES, in mesh_features()
2334 rp.index = cpu_to_le16(hdev->id); in mesh_features()
2343 mgmt_cmd_complete(sk, hdev->id, MGMT_OP_MESH_READ_FEATURES, 0, &rp, in mesh_features()
2344 rp.used_handles + sizeof(rp) - MESH_HANDLES_MAX); in mesh_features()
2353 struct mgmt_cp_mesh_send_cancel *cancel = (void *)cmd->param; in send_cancel()
2356 if (!cancel->handle) { in send_cancel()
2358 mesh_tx = mgmt_mesh_next(hdev, cmd->sk); in send_cancel()
2364 mesh_tx = mgmt_mesh_find(hdev, cancel->handle); in send_cancel()
2366 if (mesh_tx && mesh_tx->sk == cmd->sk) in send_cancel()
2370 mgmt_cmd_complete(cmd->sk, hdev->id, MGMT_OP_MESH_SEND_CANCEL, in send_cancel()
2385 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND_CANCEL, in mesh_send_cancel()
2389 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND_CANCEL, in mesh_send_cancel()
2395 err = -ENOMEM; in mesh_send_cancel()
2400 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND_CANCEL, in mesh_send_cancel()
2421 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND, in mesh_send()
2426 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND, in mesh_send()
2437 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND, in mesh_send()
2446 err = -ENOMEM; in mesh_send()
2453 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND, in mesh_send()
2463 mgmt_cmd_complete(sk, hdev->id, MGMT_OP_MESH_SEND, 0, in mesh_send()
2464 &mesh_tx->handle, 1); in mesh_send()
2482 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE, in set_le()
2485 if (cp->val != 0x00 && cp->val != 0x01) in set_le()
2486 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE, in set_le()
2489 /* Bluetooth single mode LE only controllers or dual-mode in set_le()
2499 if (cp->val == 0x01) in set_le()
2502 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE, in set_le()
2508 val = !!cp->val; in set_le()
2526 goto unlock; in set_le()
2531 goto unlock; in set_le()
2536 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE, in set_le()
2538 goto unlock; in set_le()
2543 err = -ENOMEM; in set_le()
2549 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE, in set_le()
2556 unlock: in set_le()
2571 list_for_each_entry(cmd, &hdev->mgmt_pending, list) { in pending_eir_or_class()
2572 switch (cmd->opcode) { in pending_eir_or_class()
2609 mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, in mgmt_class_complete()
2610 mgmt_status(err), hdev->dev_class, 3); in mgmt_class_complete()
2638 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_UUID, in add_uuid()
2645 err = -ENOMEM; in add_uuid()
2649 memcpy(uuid->uuid, cp->uuid, 16); in add_uuid()
2650 uuid->svc_hint = cp->svc_hint; in add_uuid()
2651 uuid->size = get_uuid_size(cp->uuid); in add_uuid()
2653 list_add_tail(&uuid->list, &hdev->uuids); in add_uuid()
2657 err = -ENOMEM; in add_uuid()
2678 queue_delayed_work(hdev->workqueue, &hdev->service_cache, in enable_service_cache()
2713 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID, in remove_uuid()
2715 goto unlock; in remove_uuid()
2718 if (memcmp(cp->uuid, bt_uuid_any, 16) == 0) { in remove_uuid()
2722 err = mgmt_cmd_complete(sk, hdev->id, in remove_uuid()
2724 0, hdev->dev_class, 3); in remove_uuid()
2725 goto unlock; in remove_uuid()
2733 list_for_each_entry_safe(match, tmp, &hdev->uuids, list) { in remove_uuid()
2734 if (memcmp(match->uuid, cp->uuid, 16) != 0) in remove_uuid()
2737 list_del(&match->list); in remove_uuid()
2743 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID, in remove_uuid()
2745 goto unlock; in remove_uuid()
2751 err = -ENOMEM; in remove_uuid()
2752 goto unlock; in remove_uuid()
2760 unlock: in remove_uuid()
2770 cancel_delayed_work_sync(&hdev->service_cache); in set_class_sync()
2790 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, in set_dev_class()
2796 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, in set_dev_class()
2798 goto unlock; in set_dev_class()
2801 if ((cp->minor & 0x03) != 0 || (cp->major & 0xe0) != 0) { in set_dev_class()
2802 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, in set_dev_class()
2804 goto unlock; in set_dev_class()
2807 hdev->major_class = cp->major; in set_dev_class()
2808 hdev->minor_class = cp->minor; in set_dev_class()
2811 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, 0, in set_dev_class()
2812 hdev->dev_class, 3); in set_dev_class()
2813 goto unlock; in set_dev_class()
2818 err = -ENOMEM; in set_dev_class()
2819 goto unlock; in set_dev_class()
2827 unlock: in set_dev_class()
2836 const u16 max_key_count = ((U16_MAX - sizeof(*cp)) / in load_link_keys()
2845 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, in load_link_keys()
2848 key_count = __le16_to_cpu(cp->key_count); in load_link_keys()
2852 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, in load_link_keys()
2856 expected_len = struct_size(cp, keys, key_count); in load_link_keys()
2860 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, in load_link_keys()
2864 if (cp->debug_keys != 0x00 && cp->debug_keys != 0x01) in load_link_keys()
2865 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, in load_link_keys()
2868 bt_dev_dbg(hdev, "debug_keys %u key_count %u", cp->debug_keys, in load_link_keys()
2872 struct mgmt_link_key_info *key = &cp->keys[i]; in load_link_keys()
2874 if (key->addr.type != BDADDR_BREDR || key->type > 0x08) in load_link_keys()
2875 return mgmt_cmd_status(sk, hdev->id, in load_link_keys()
2884 if (cp->debug_keys) in load_link_keys()
2894 struct mgmt_link_key_info *key = &cp->keys[i]; in load_link_keys()
2898 key->val)) { in load_link_keys()
2900 &key->addr.bdaddr); in load_link_keys()
2904 /* Always ignore debug keys and require a new pairing if in load_link_keys()
2907 if (key->type == HCI_LK_DEBUG_COMBINATION) in load_link_keys()
2910 hci_add_link_key(hdev, NULL, &key->addr.bdaddr, key->val, in load_link_keys()
2911 key->type, key->pin_len, NULL); in load_link_keys()
2914 mgmt_cmd_complete(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, 0, NULL, 0); in load_link_keys()
2936 struct mgmt_cp_unpair_device *cp = cmd->param; in unpair_device_complete()
2939 device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, cmd->sk); in unpair_device_complete()
2941 cmd->cmd_complete(cmd, err); in unpair_device_complete()
2948 struct mgmt_cp_unpair_device *cp = cmd->param; in unpair_device_sync()
2951 if (cp->addr.type == BDADDR_BREDR) in unpair_device_sync()
2953 &cp->addr.bdaddr); in unpair_device_sync()
2955 conn = hci_conn_hash_lookup_le(hdev, &cp->addr.bdaddr, in unpair_device_sync()
2956 le_addr_type(cp->addr.type)); in unpair_device_sync()
2976 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); in unpair_device()
2977 rp.addr.type = cp->addr.type; in unpair_device()
2979 if (!bdaddr_type_is_valid(cp->addr.type)) in unpair_device()
2980 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, in unpair_device()
2984 if (cp->disconnect != 0x00 && cp->disconnect != 0x01) in unpair_device()
2985 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, in unpair_device()
2992 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, in unpair_device()
2995 goto unlock; in unpair_device()
2998 if (cp->addr.type == BDADDR_BREDR) { in unpair_device()
3006 if (cp->disconnect) in unpair_device()
3008 &cp->addr.bdaddr); in unpair_device()
3012 err = hci_remove_link_key(hdev, &cp->addr.bdaddr); in unpair_device()
3014 err = mgmt_cmd_complete(sk, hdev->id, in unpair_device()
3018 goto unlock; in unpair_device()
3025 addr_type = le_addr_type(cp->addr.type); in unpair_device()
3028 err = smp_cancel_and_remove_pairing(hdev, &cp->addr.bdaddr, addr_type); in unpair_device()
3030 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, in unpair_device()
3033 goto unlock; in unpair_device()
3036 conn = hci_conn_hash_lookup_le(hdev, &cp->addr.bdaddr, addr_type); in unpair_device()
3038 hci_conn_params_del(hdev, &cp->addr.bdaddr, addr_type); in unpair_device()
3046 set_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags); in unpair_device()
3048 /* Disable auto-connection parameters if present */ in unpair_device()
3049 params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr, addr_type); in unpair_device()
3051 if (params->explicit_connect) in unpair_device()
3052 params->auto_connect = HCI_AUTO_CONN_EXPLICIT; in unpair_device()
3054 params->auto_connect = HCI_AUTO_CONN_DISABLED; in unpair_device()
3060 if (!cp->disconnect) in unpair_device()
3068 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, 0, in unpair_device()
3070 device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, sk); in unpair_device()
3071 goto unlock; in unpair_device()
3077 err = -ENOMEM; in unpair_device()
3078 goto unlock; in unpair_device()
3081 cmd->cmd_complete = addr_cmd_complete; in unpair_device()
3088 unlock: in unpair_device()
3105 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); in disconnect()
3106 rp.addr.type = cp->addr.type; in disconnect()
3108 if (!bdaddr_type_is_valid(cp->addr.type)) in disconnect()
3109 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_DISCONNECT, in disconnect()
3115 if (!test_bit(HCI_UP, &hdev->flags)) { in disconnect()
3116 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_DISCONNECT, in disconnect()
3123 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_DISCONNECT, in disconnect()
3128 if (cp->addr.type == BDADDR_BREDR) in disconnect()
3130 &cp->addr.bdaddr); in disconnect()
3132 conn = hci_conn_hash_lookup_le(hdev, &cp->addr.bdaddr, in disconnect()
3133 le_addr_type(cp->addr.type)); in disconnect()
3135 if (!conn || conn->state == BT_OPEN || conn->state == BT_CLOSED) { in disconnect()
3136 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_DISCONNECT, in disconnect()
3144 err = -ENOMEM; in disconnect()
3148 cmd->cmd_complete = generic_cmd_complete; in disconnect()
3191 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_CONNECTIONS, in get_connections()
3193 goto unlock; in get_connections()
3197 list_for_each_entry(c, &hdev->conn_hash.list, list) { in get_connections()
3198 if (test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) in get_connections()
3204 err = -ENOMEM; in get_connections()
3205 goto unlock; in get_connections()
3209 list_for_each_entry(c, &hdev->conn_hash.list, list) { in get_connections()
3210 if (!test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) in get_connections()
3212 bacpy(&rp->addr[i].bdaddr, &c->dst); in get_connections()
3213 rp->addr[i].type = link_to_bdaddr(c->type, c->dst_type); in get_connections()
3214 if (c->type == SCO_LINK || c->type == ESCO_LINK) in get_connections()
3219 rp->conn_count = cpu_to_le16(i); in get_connections()
3222 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CONNECTIONS, 0, rp, in get_connections()
3227 unlock: in get_connections()
3241 return -ENOMEM; in send_pin_code_neg_reply()
3243 cmd->cmd_complete = addr_cmd_complete; in send_pin_code_neg_reply()
3246 sizeof(cp->addr.bdaddr), &cp->addr.bdaddr); in send_pin_code_neg_reply()
3267 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, in pin_code_reply()
3272 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr); in pin_code_reply()
3274 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, in pin_code_reply()
3279 if (conn->pending_sec_level == BT_SECURITY_HIGH && cp->pin_len != 16) { in pin_code_reply()
3282 memcpy(&ncp.addr, &cp->addr, sizeof(ncp.addr)); in pin_code_reply()
3288 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, in pin_code_reply()
3296 err = -ENOMEM; in pin_code_reply()
3300 cmd->cmd_complete = addr_cmd_complete; in pin_code_reply()
3302 bacpy(&reply.bdaddr, &cp->addr.bdaddr); in pin_code_reply()
3303 reply.pin_len = cp->pin_len; in pin_code_reply()
3304 memcpy(reply.pin_code, cp->pin_code, sizeof(reply.pin_code)); in pin_code_reply()
3322 if (cp->io_capability > SMP_IO_KEYBOARD_DISPLAY) in set_io_capability()
3323 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_IO_CAPABILITY, in set_io_capability()
3328 hdev->io_capability = cp->io_capability; in set_io_capability()
3330 bt_dev_dbg(hdev, "IO capability set to 0x%02x", hdev->io_capability); in set_io_capability()
3334 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_IO_CAPABILITY, 0, in set_io_capability()
3340 struct hci_dev *hdev = conn->hdev; in find_pairing()
3343 list_for_each_entry(cmd, &hdev->mgmt_pending, list) { in find_pairing()
3344 if (cmd->opcode != MGMT_OP_PAIR_DEVICE) in find_pairing()
3347 if (cmd->user_data != conn) in find_pairing()
3359 struct hci_conn *conn = cmd->user_data; in pairing_complete()
3362 bacpy(&rp.addr.bdaddr, &conn->dst); in pairing_complete()
3363 rp.addr.type = link_to_bdaddr(conn->type, conn->dst_type); in pairing_complete()
3365 err = mgmt_cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, in pairing_complete()
3369 conn->connect_cfm_cb = NULL; in pairing_complete()
3370 conn->security_cfm_cb = NULL; in pairing_complete()
3371 conn->disconn_cfm_cb = NULL; in pairing_complete()
3378 clear_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags); in pairing_complete()
3392 cmd->cmd_complete(cmd, status); in mgmt_smp_complete()
3409 cmd->cmd_complete(cmd, mgmt_status(status)); in pairing_complete_cb()
3428 cmd->cmd_complete(cmd, mgmt_status(status)); in le_pairing_complete_cb()
3445 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); in pair_device()
3446 rp.addr.type = cp->addr.type; in pair_device()
3448 if (!bdaddr_type_is_valid(cp->addr.type)) in pair_device()
3449 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, in pair_device()
3453 if (cp->io_cap > SMP_IO_KEYBOARD_DISPLAY) in pair_device()
3454 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, in pair_device()
3461 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, in pair_device()
3464 goto unlock; in pair_device()
3467 if (hci_bdaddr_is_paired(hdev, &cp->addr.bdaddr, cp->addr.type)) { in pair_device()
3468 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, in pair_device()
3471 goto unlock; in pair_device()
3477 if (cp->addr.type == BDADDR_BREDR) { in pair_device()
3478 conn = hci_connect_acl(hdev, &cp->addr.bdaddr, sec_level, in pair_device()
3481 u8 addr_type = le_addr_type(cp->addr.type); in pair_device()
3493 p = hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type); in pair_device()
3495 if (p->auto_connect == HCI_AUTO_CONN_EXPLICIT) in pair_device()
3496 p->auto_connect = HCI_AUTO_CONN_DISABLED; in pair_device()
3498 conn = hci_connect_le_scan(hdev, &cp->addr.bdaddr, addr_type, in pair_device()
3506 if (PTR_ERR(conn) == -EBUSY) in pair_device()
3508 else if (PTR_ERR(conn) == -EOPNOTSUPP) in pair_device()
3510 else if (PTR_ERR(conn) == -ECONNREFUSED) in pair_device()
3515 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, in pair_device()
3517 goto unlock; in pair_device()
3520 if (conn->connect_cfm_cb) { in pair_device()
3522 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_PAIR_DEVICE, in pair_device()
3524 goto unlock; in pair_device()
3529 err = -ENOMEM; in pair_device()
3531 goto unlock; in pair_device()
3534 cmd->cmd_complete = pairing_complete; in pair_device()
3537 if (cp->addr.type == BDADDR_BREDR) { in pair_device()
3538 conn->connect_cfm_cb = pairing_complete_cb; in pair_device()
3539 conn->security_cfm_cb = pairing_complete_cb; in pair_device()
3540 conn->disconn_cfm_cb = pairing_complete_cb; in pair_device()
3542 conn->connect_cfm_cb = le_pairing_complete_cb; in pair_device()
3543 conn->security_cfm_cb = le_pairing_complete_cb; in pair_device()
3544 conn->disconn_cfm_cb = le_pairing_complete_cb; in pair_device()
3547 conn->io_capability = cp->io_cap; in pair_device()
3548 cmd->user_data = hci_conn_get(conn); in pair_device()
3550 if ((conn->state == BT_CONNECTED || conn->state == BT_CONFIG) && in pair_device()
3552 cmd->cmd_complete(cmd, 0); in pair_device()
3558 unlock: in pair_device()
3588 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, in cancel_pair_device()
3590 goto unlock; in cancel_pair_device()
3595 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, in cancel_pair_device()
3597 goto unlock; in cancel_pair_device()
3600 conn = cmd->user_data; in cancel_pair_device()
3602 if (bacmp(&addr->bdaddr, &conn->dst) != 0) { in cancel_pair_device()
3603 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, in cancel_pair_device()
3605 goto unlock; in cancel_pair_device()
3608 cmd->cmd_complete(cmd, MGMT_STATUS_CANCELLED); in cancel_pair_device()
3611 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, 0, in cancel_pair_device()
3618 if (addr->type == BDADDR_BREDR) in cancel_pair_device()
3619 hci_remove_link_key(hdev, &addr->bdaddr); in cancel_pair_device()
3621 smp_cancel_and_remove_pairing(hdev, &addr->bdaddr, in cancel_pair_device()
3622 le_addr_type(addr->type)); in cancel_pair_device()
3624 if (conn->conn_reason == CONN_REASON_PAIR_DEVICE) in cancel_pair_device()
3625 hci_cmd_sync_queue(hdev, abort_conn_sync, ERR_PTR(conn->handle), in cancel_pair_device()
3628 unlock: in cancel_pair_device()
3644 err = mgmt_cmd_complete(sk, hdev->id, mgmt_op, in user_pairing_resp()
3650 if (addr->type == BDADDR_BREDR) in user_pairing_resp()
3651 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &addr->bdaddr); in user_pairing_resp()
3653 conn = hci_conn_hash_lookup_le(hdev, &addr->bdaddr, in user_pairing_resp()
3654 le_addr_type(addr->type)); in user_pairing_resp()
3657 err = mgmt_cmd_complete(sk, hdev->id, mgmt_op, in user_pairing_resp()
3663 if (addr->type == BDADDR_LE_PUBLIC || addr->type == BDADDR_LE_RANDOM) { in user_pairing_resp()
3666 err = mgmt_cmd_complete(sk, hdev->id, mgmt_op, in user_pairing_resp()
3670 err = mgmt_cmd_complete(sk, hdev->id, mgmt_op, in user_pairing_resp()
3679 err = -ENOMEM; in user_pairing_resp()
3683 cmd->cmd_complete = addr_cmd_complete; in user_pairing_resp()
3689 bacpy(&cp.bdaddr, &addr->bdaddr); in user_pairing_resp()
3693 err = hci_send_cmd(hdev, hci_op, sizeof(addr->bdaddr), in user_pairing_resp()
3694 &addr->bdaddr); in user_pairing_resp()
3711 return user_pairing_resp(sk, hdev, &cp->addr, in pin_code_neg_reply()
3724 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_USER_CONFIRM_REPLY, in user_confirm_reply()
3727 return user_pairing_resp(sk, hdev, &cp->addr, in user_confirm_reply()
3739 return user_pairing_resp(sk, hdev, &cp->addr, in user_confirm_neg_reply()
3751 return user_pairing_resp(sk, hdev, &cp->addr, in user_passkey_reply()
3753 HCI_OP_USER_PASSKEY_REPLY, cp->passkey); in user_passkey_reply()
3763 return user_pairing_resp(sk, hdev, &cp->addr, in user_passkey_neg_reply()
3772 adv_instance = hci_find_adv_instance(hdev, hdev->cur_adv_instance); in adv_expire_sync()
3777 if (!(adv_instance->flags & flags)) in adv_expire_sync()
3782 adv_instance = hci_get_next_instance(hdev, adv_instance->instance); in adv_expire_sync()
3786 hci_schedule_adv_instance_sync(hdev, adv_instance->instance, true); in adv_expire_sync()
3799 struct mgmt_cp_set_local_name *cp = cmd->param; in set_name_complete()
3808 mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, in set_name_complete()
3811 mgmt_cmd_complete(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, in set_name_complete()
3832 hci_update_scan_rsp_data_sync(hdev, hdev->cur_adv_instance); in set_name_sync()
3851 if (!memcmp(hdev->dev_name, cp->name, sizeof(hdev->dev_name)) && in set_local_name()
3852 !memcmp(hdev->short_name, cp->short_name, in set_local_name()
3853 sizeof(hdev->short_name))) { in set_local_name()
3854 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, in set_local_name()
3859 memcpy(hdev->short_name, cp->short_name, sizeof(hdev->short_name)); in set_local_name()
3862 memcpy(hdev->dev_name, cp->name, sizeof(hdev->dev_name)); in set_local_name()
3864 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, in set_local_name()
3878 err = -ENOMEM; in set_local_name()
3884 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, in set_local_name()
3893 memcpy(hdev->dev_name, cp->name, sizeof(hdev->dev_name)); in set_local_name()
3915 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_APPEARANCE, in set_appearance()
3918 appearance = le16_to_cpu(cp->appearance); in set_appearance()
3922 if (hdev->appearance != appearance) { in set_appearance()
3923 hdev->appearance = appearance; in set_appearance()
3932 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_APPEARANCE, 0, NULL, in set_appearance()
3957 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_PHY_CONFIGURATION, 0, in get_phy_configuration()
3976 struct sk_buff *skb = cmd->skb; in set_default_phy_complete()
3988 status = mgmt_status(skb->data[0]); in set_default_phy_complete()
3994 mgmt_cmd_status(cmd->sk, hdev->id, in set_default_phy_complete()
3997 mgmt_cmd_complete(cmd->sk, hdev->id, in set_default_phy_complete()
4001 mgmt_phy_configuration_changed(hdev, cmd->sk); in set_default_phy_complete()
4013 struct mgmt_cp_set_phy_configuration *cp = cmd->param; in set_default_phy_sync()
4015 u32 selected_phys = __le32_to_cpu(cp->selected_phys); in set_default_phy_sync()
4043 cmd->skb = __hci_cmd_sync(hdev, HCI_OP_LE_SET_DEFAULT_PHY, in set_default_phy_sync()
4063 selected_phys = __le32_to_cpu(cp->selected_phys); in set_phy_configuration()
4066 return mgmt_cmd_status(sk, hdev->id, in set_phy_configuration()
4073 return mgmt_cmd_status(sk, hdev->id, in set_phy_configuration()
4078 return mgmt_cmd_complete(sk, hdev->id, in set_phy_configuration()
4085 err = mgmt_cmd_status(sk, hdev->id, in set_phy_configuration()
4088 goto unlock; in set_phy_configuration()
4092 err = mgmt_cmd_status(sk, hdev->id, in set_phy_configuration()
4095 goto unlock; in set_phy_configuration()
4138 if (pkt_type != hdev->pkt_type) { in set_phy_configuration()
4139 hdev->pkt_type = pkt_type; in set_phy_configuration()
4148 err = mgmt_cmd_complete(sk, hdev->id, in set_phy_configuration()
4152 goto unlock; in set_phy_configuration()
4158 err = -ENOMEM; in set_phy_configuration()
4164 err = mgmt_cmd_status(sk, hdev->id, in set_phy_configuration()
4172 unlock: in set_phy_configuration()
4182 struct mgmt_cp_set_blocked_keys *keys = data; in set_blocked_keys() local
4183 const u16 max_key_count = ((U16_MAX - sizeof(*keys)) / in set_blocked_keys()
4190 key_count = __le16_to_cpu(keys->key_count); in set_blocked_keys()
4193 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BLOCKED_KEYS, in set_blocked_keys()
4197 expected_len = struct_size(keys, keys, key_count); in set_blocked_keys()
4201 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BLOCKED_KEYS, in set_blocked_keys()
4217 b->type = keys->keys[i].type; in set_blocked_keys()
4218 memcpy(b->val, keys->keys[i].val, sizeof(b->val)); in set_blocked_keys()
4219 list_add_rcu(&b->list, &hdev->blocked_keys); in set_blocked_keys()
4223 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_BLOCKED_KEYS, in set_blocked_keys()
4236 if (!test_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks)) in set_wideband_speech()
4237 return mgmt_cmd_status(sk, hdev->id, in set_wideband_speech()
4241 if (cp->val != 0x00 && cp->val != 0x01) in set_wideband_speech()
4242 return mgmt_cmd_status(sk, hdev->id, in set_wideband_speech()
4249 !!cp->val != hci_dev_test_flag(hdev, in set_wideband_speech()
4251 err = mgmt_cmd_status(sk, hdev->id, in set_wideband_speech()
4254 goto unlock; in set_wideband_speech()
4257 if (cp->val) in set_wideband_speech()
4266 goto unlock; in set_wideband_speech()
4271 unlock: in set_wideband_speech()
4297 if ((hdev->commands[41] & 0x08) || msft_curve_validity(hdev)) in read_controller_cap()
4305 if (hdev->commands[20] & 0x10) in read_controller_cap()
4310 cap_len = eir_append_data(rp->cap, cap_len, MGMT_CAP_SEC_FLAGS, in read_controller_cap()
4316 if (hdev->commands[41] & 0x08) in read_controller_cap()
4317 cap_len = eir_append_le16(rp->cap, cap_len, in read_controller_cap()
4319 hdev->max_enc_key_size); in read_controller_cap()
4321 cap_len = eir_append_le16(rp->cap, cap_len, in read_controller_cap()
4328 if (hdev->commands[38] & 0x80) { in read_controller_cap()
4329 memcpy(&tx_power_range[0], &hdev->min_le_tx_power, 1); in read_controller_cap()
4330 memcpy(&tx_power_range[1], &hdev->max_le_tx_power, 1); in read_controller_cap()
4331 cap_len = eir_append_data(rp->cap, cap_len, MGMT_CAP_LE_TX_PWR, in read_controller_cap()
4335 rp->cap_len = cpu_to_le16(cap_len); in read_controller_cap()
4339 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_READ_CONTROLLER_CAP, 0, in read_controller_cap()
4344 /* d4992530-b9ec-469f-ab01-6c481c47da1c */
4351 /* 330859bc-7506-492d-9370-9a6f0614037f */
4357 /* a6695ace-ee7f-4fb9-881a-5fac66c629af */
4363 /* 671b10b5-42c0-4696-9227-eb28d1b049d6 */
4369 /* 15c0a148-c273-11ea-b3de-0242ac130004 */
4375 /* 6fbaf188-05e0-496a-9885-d6ddfdb4e03e */
4381 /* 2ce463d7-7a03-4d8d-bf05-5f24e8f36e76 */
4399 len = sizeof(*rp) + (sizeof(rp->features[0]) * 7); in read_exp_features_info()
4402 return -ENOMEM; in read_exp_features_info()
4408 memcpy(rp->features[idx].uuid, debug_uuid, 16); in read_exp_features_info()
4409 rp->features[idx].flags = cpu_to_le32(flags); in read_exp_features_info()
4420 memcpy(rp->features[idx].uuid, le_simultaneous_roles_uuid, 16); in read_exp_features_info()
4421 rp->features[idx].flags = cpu_to_le32(flags); in read_exp_features_info()
4431 memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); in read_exp_features_info()
4432 rp->features[idx].flags = cpu_to_le32(flags); in read_exp_features_info()
4437 hdev->set_quality_report)) { in read_exp_features_info()
4443 memcpy(rp->features[idx].uuid, quality_report_uuid, 16); in read_exp_features_info()
4444 rp->features[idx].flags = cpu_to_le32(flags); in read_exp_features_info()
4448 if (hdev && hdev->get_data_path_id) { in read_exp_features_info()
4454 memcpy(rp->features[idx].uuid, offload_codecs_uuid, 16); in read_exp_features_info()
4455 rp->features[idx].flags = cpu_to_le32(flags); in read_exp_features_info()
4461 memcpy(rp->features[idx].uuid, iso_socket_uuid, 16); in read_exp_features_info()
4462 rp->features[idx].flags = cpu_to_le32(flags); in read_exp_features_info()
4472 memcpy(rp->features[idx].uuid, mgmt_mesh_uuid, 16); in read_exp_features_info()
4473 rp->features[idx].flags = cpu_to_le32(flags); in read_exp_features_info()
4477 rp->feature_count = cpu_to_le16(idx); in read_exp_features_info()
4484 status = mgmt_cmd_complete(sk, hdev ? hdev->id : MGMT_INDEX_NONE, in read_exp_features_info()
4503 hdev->conn_flags |= HCI_CONN_FLAG_DEVICE_PRIVACY; in exp_ll_privacy_feature_changed()
4505 hdev->conn_flags &= ~HCI_CONN_FLAG_DEVICE_PRIVACY; in exp_ll_privacy_feature_changed()
4565 return mgmt_cmd_complete(sk, hdev ? hdev->id : MGMT_INDEX_NONE, in set_zero_key_func()
4579 /* Command requires to use the non-controller index */ in set_debug_func()
4581 return mgmt_cmd_status(sk, hdev->id, in set_debug_func()
4592 if (cp->param[0] != 0x00 && cp->param[0] != 0x01) in set_debug_func()
4597 val = !!cp->param[0]; in set_debug_func()
4632 return mgmt_cmd_status(sk, hdev->id, in set_mgmt_mesh_func()
4638 return mgmt_cmd_status(sk, hdev->id, in set_mgmt_mesh_func()
4643 if (cp->param[0] != 0x00 && cp->param[0] != 0x01) in set_mgmt_mesh_func()
4644 return mgmt_cmd_status(sk, hdev->id, in set_mgmt_mesh_func()
4648 val = !!cp->param[0]; in set_mgmt_mesh_func()
4664 err = mgmt_cmd_complete(sk, hdev->id, in set_mgmt_mesh_func()
4691 return mgmt_cmd_status(sk, hdev->id, in set_rpa_resolution_func()
4697 return mgmt_cmd_status(sk, hdev->id, in set_rpa_resolution_func()
4702 if (cp->param[0] != 0x00 && cp->param[0] != 0x01) in set_rpa_resolution_func()
4703 return mgmt_cmd_status(sk, hdev->id, in set_rpa_resolution_func()
4707 val = !!cp->param[0]; in set_rpa_resolution_func()
4729 err = mgmt_cmd_complete(sk, hdev->id, in set_rpa_resolution_func()
4755 return mgmt_cmd_status(sk, hdev->id, in set_quality_report_func()
4760 if (cp->param[0] != 0x00 && cp->param[0] != 0x01) in set_quality_report_func()
4761 return mgmt_cmd_status(sk, hdev->id, in set_quality_report_func()
4767 val = !!cp->param[0]; in set_quality_report_func()
4770 if (!aosp_has_quality_report(hdev) && !hdev->set_quality_report) { in set_quality_report_func()
4771 err = mgmt_cmd_status(sk, hdev->id, in set_quality_report_func()
4778 if (hdev->set_quality_report) in set_quality_report_func()
4779 err = hdev->set_quality_report(hdev, val); in set_quality_report_func()
4784 err = mgmt_cmd_status(sk, hdev->id, in set_quality_report_func()
4802 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_EXP_FEATURE, 0, in set_quality_report_func()
4829 return mgmt_cmd_status(sk, hdev->id, in set_offload_codec_func()
4834 if (cp->param[0] != 0x00 && cp->param[0] != 0x01) in set_offload_codec_func()
4835 return mgmt_cmd_status(sk, hdev->id, in set_offload_codec_func()
4839 val = !!cp->param[0]; in set_offload_codec_func()
4842 if (!hdev->get_data_path_id) { in set_offload_codec_func()
4843 return mgmt_cmd_status(sk, hdev->id, in set_offload_codec_func()
4861 err = mgmt_cmd_complete(sk, hdev->id, in set_offload_codec_func()
4887 return mgmt_cmd_status(sk, hdev->id, in set_le_simultaneous_roles_func()
4892 if (cp->param[0] != 0x00 && cp->param[0] != 0x01) in set_le_simultaneous_roles_func()
4893 return mgmt_cmd_status(sk, hdev->id, in set_le_simultaneous_roles_func()
4897 val = !!cp->param[0]; in set_le_simultaneous_roles_func()
4901 return mgmt_cmd_status(sk, hdev->id, in set_le_simultaneous_roles_func()
4919 err = mgmt_cmd_complete(sk, hdev->id, in set_le_simultaneous_roles_func()
4937 /* Command requires to use the non-controller index */ in set_iso_socket_func()
4939 return mgmt_cmd_status(sk, hdev->id, in set_iso_socket_func()
4950 if (cp->param[0] != 0x00 && cp->param[0] != 0x01) in set_iso_socket_func()
4955 val = cp->param[0] ? true : false; in set_iso_socket_func()
5011 if (!memcmp(cp->uuid, exp_features[i].uuid, 16)) in set_exp_feature()
5015 return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, in set_exp_feature()
5023 u32 flags = hdev->conn_flags; in get_params_flags()
5030 hci_find_irk_by_addr(hdev, &params->addr, params->addr_type)) in get_params_flags()
5048 &cp->addr.bdaddr, cp->addr.type); in get_device_flags()
5052 supported_flags = hdev->conn_flags; in get_device_flags()
5056 if (cp->addr.type == BDADDR_BREDR) { in get_device_flags()
5057 br_params = hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in get_device_flags()
5058 &cp->addr.bdaddr, in get_device_flags()
5059 cp->addr.type); in get_device_flags()
5063 current_flags = br_params->flags; in get_device_flags()
5065 params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr, in get_device_flags()
5066 le_addr_type(cp->addr.type)); in get_device_flags()
5071 current_flags = params->flags; in get_device_flags()
5074 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); in get_device_flags()
5075 rp.addr.type = cp->addr.type; in get_device_flags()
5084 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_DEVICE_FLAGS, status, in get_device_flags()
5110 u32 current_flags = __le32_to_cpu(cp->current_flags); in set_device_flags()
5113 &cp->addr.bdaddr, cp->addr.type, current_flags); in set_device_flags()
5116 supported_flags = hdev->conn_flags; in set_device_flags()
5126 if (cp->addr.type == BDADDR_BREDR) { in set_device_flags()
5127 br_params = hci_bdaddr_list_lookup_with_flags(&hdev->accept_list, in set_device_flags()
5128 &cp->addr.bdaddr, in set_device_flags()
5129 cp->addr.type); in set_device_flags()
5132 br_params->flags = current_flags; in set_device_flags()
5136 &cp->addr.bdaddr, cp->addr.type); in set_device_flags()
5139 goto unlock; in set_device_flags()
5142 params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr, in set_device_flags()
5143 le_addr_type(cp->addr.type)); in set_device_flags()
5146 &cp->addr.bdaddr, le_addr_type(cp->addr.type)); in set_device_flags()
5147 goto unlock; in set_device_flags()
5155 goto unlock; in set_device_flags()
5158 params->flags = current_flags; in set_device_flags()
5164 if (params->flags & HCI_CONN_FLAG_DEVICE_PRIVACY) in set_device_flags()
5167 unlock: in set_device_flags()
5172 device_flags_changed(sk, hdev, &cp->addr.bdaddr, cp->addr.type, in set_device_flags()
5175 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_DEVICE_FLAGS, status, in set_device_flags()
5176 &cp->addr, sizeof(cp->addr)); in set_device_flags()
5198 cp = cmd->param; in mgmt_adv_monitor_removed()
5200 if (cp->monitor_handle) in mgmt_adv_monitor_removed()
5201 sk_skip = cmd->sk; in mgmt_adv_monitor_removed()
5221 BT_DBG("request for %s", hdev->name); in read_adv_mon_features()
5228 idr_for_each_entry(&hdev->adv_monitors_idr, monitor, handle) in read_adv_mon_features()
5229 handles[num_handles++] = monitor->handle; in read_adv_mon_features()
5236 return -ENOMEM; in read_adv_mon_features()
5241 rp->supported_features = cpu_to_le32(supported); in read_adv_mon_features()
5242 rp->enabled_features = cpu_to_le32(enabled); in read_adv_mon_features()
5243 rp->max_num_handles = cpu_to_le16(HCI_MAX_ADV_MONITOR_NUM_HANDLES); in read_adv_mon_features()
5244 rp->max_num_patterns = HCI_MAX_ADV_MONITOR_NUM_PATTERNS; in read_adv_mon_features()
5245 rp->num_handles = cpu_to_le16(num_handles); in read_adv_mon_features()
5247 memcpy(&rp->handles, &handles, (num_handles * sizeof(u16))); in read_adv_mon_features()
5249 err = mgmt_cmd_complete(sk, hdev->id, in read_adv_mon_features()
5263 struct adv_monitor *monitor = cmd->user_data; in mgmt_add_adv_patterns_monitor_complete()
5267 rp.monitor_handle = cpu_to_le16(monitor->handle); in mgmt_add_adv_patterns_monitor_complete()
5270 mgmt_adv_monitor_added(cmd->sk, hdev, monitor->handle); in mgmt_add_adv_patterns_monitor_complete()
5271 hdev->adv_monitors_cnt++; in mgmt_add_adv_patterns_monitor_complete()
5272 if (monitor->state == ADV_MONITOR_STATE_NOT_REGISTERED) in mgmt_add_adv_patterns_monitor_complete()
5273 monitor->state = ADV_MONITOR_STATE_REGISTERED; in mgmt_add_adv_patterns_monitor_complete()
5277 mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, in mgmt_add_adv_patterns_monitor_complete()
5289 struct adv_monitor *monitor = cmd->user_data; in mgmt_add_adv_patterns_monitor_sync()
5304 goto unlock; in __add_adv_patterns_monitor()
5311 goto unlock; in __add_adv_patterns_monitor()
5317 goto unlock; in __add_adv_patterns_monitor()
5320 cmd->user_data = m; in __add_adv_patterns_monitor()
5324 if (err == -ENOMEM) in __add_adv_patterns_monitor()
5329 goto unlock; in __add_adv_patterns_monitor()
5336 unlock: in __add_adv_patterns_monitor()
5339 return mgmt_cmd_status(sk, hdev->id, op, status); in __add_adv_patterns_monitor()
5346 m->rssi.low_threshold = rssi->low_threshold; in parse_adv_monitor_rssi()
5347 m->rssi.low_threshold_timeout = in parse_adv_monitor_rssi()
5348 __le16_to_cpu(rssi->low_threshold_timeout); in parse_adv_monitor_rssi()
5349 m->rssi.high_threshold = rssi->high_threshold; in parse_adv_monitor_rssi()
5350 m->rssi.high_threshold_timeout = in parse_adv_monitor_rssi()
5351 __le16_to_cpu(rssi->high_threshold_timeout); in parse_adv_monitor_rssi()
5352 m->rssi.sampling_period = rssi->sampling_period; in parse_adv_monitor_rssi()
5359 m->rssi.low_threshold = -127; in parse_adv_monitor_rssi()
5360 m->rssi.low_threshold_timeout = 60; in parse_adv_monitor_rssi()
5361 m->rssi.high_threshold = -127; in parse_adv_monitor_rssi()
5362 m->rssi.high_threshold_timeout = 0; in parse_adv_monitor_rssi()
5363 m->rssi.sampling_period = 0; in parse_adv_monitor_rssi()
5386 p->ad_type = patterns[i].ad_type; in parse_adv_monitor_pattern()
5387 p->offset = patterns[i].offset; in parse_adv_monitor_pattern()
5388 p->length = patterns[i].length; in parse_adv_monitor_pattern()
5389 memcpy(p->value, patterns[i].value, p->length); in parse_adv_monitor_pattern()
5391 INIT_LIST_HEAD(&p->list); in parse_adv_monitor_pattern()
5392 list_add(&p->list, &m->patterns); in parse_adv_monitor_pattern()
5406 BT_DBG("request for %s", hdev->name); in add_adv_patterns_monitor()
5413 expected_size += cp->pattern_count * sizeof(struct mgmt_adv_pattern); in add_adv_patterns_monitor()
5425 INIT_LIST_HEAD(&m->patterns); in add_adv_patterns_monitor()
5428 status = parse_adv_monitor_pattern(m, cp->pattern_count, cp->patterns); in add_adv_patterns_monitor()
5443 BT_DBG("request for %s", hdev->name); in add_adv_patterns_monitor_rssi()
5450 expected_size += cp->pattern_count * sizeof(struct mgmt_adv_pattern); in add_adv_patterns_monitor_rssi()
5462 INIT_LIST_HEAD(&m->patterns); in add_adv_patterns_monitor_rssi()
5464 parse_adv_monitor_rssi(m, &cp->rssi); in add_adv_patterns_monitor_rssi()
5465 status = parse_adv_monitor_pattern(m, cp->pattern_count, cp->patterns); in add_adv_patterns_monitor_rssi()
5477 struct mgmt_cp_remove_adv_monitor *cp = cmd->param; in mgmt_remove_adv_monitor_complete()
5481 rp.monitor_handle = cp->monitor_handle; in mgmt_remove_adv_monitor_complete()
5486 mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, in mgmt_remove_adv_monitor_complete()
5498 struct mgmt_cp_remove_adv_monitor *cp = cmd->param; in mgmt_remove_adv_monitor_sync()
5499 u16 handle = __le16_to_cpu(cp->monitor_handle); in mgmt_remove_adv_monitor_sync()
5520 goto unlock; in remove_adv_monitor()
5526 goto unlock; in remove_adv_monitor()
5535 if (err == -ENOMEM) in remove_adv_monitor()
5540 goto unlock; in remove_adv_monitor()
5547 unlock: in remove_adv_monitor()
5549 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_REMOVE_ADV_MONITOR, in remove_adv_monitor()
5558 struct sk_buff *skb = cmd->skb; in read_local_oob_data_complete()
5567 status = mgmt_status(skb->data[0]); in read_local_oob_data_complete()
5573 mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, status); in read_local_oob_data_complete()
5580 struct hci_rp_read_local_oob_data *rp = (void *) skb->data; in read_local_oob_data_complete()
5582 if (skb->len < sizeof(*rp)) { in read_local_oob_data_complete()
5583 mgmt_cmd_status(cmd->sk, hdev->id, in read_local_oob_data_complete()
5589 memcpy(mgmt_rp.hash192, rp->hash, sizeof(rp->hash)); in read_local_oob_data_complete()
5590 memcpy(mgmt_rp.rand192, rp->rand, sizeof(rp->rand)); in read_local_oob_data_complete()
5592 rp_size -= sizeof(mgmt_rp.hash256) + sizeof(mgmt_rp.rand256); in read_local_oob_data_complete()
5594 struct hci_rp_read_local_oob_ext_data *rp = (void *) skb->data; in read_local_oob_data_complete()
5596 if (skb->len < sizeof(*rp)) { in read_local_oob_data_complete()
5597 mgmt_cmd_status(cmd->sk, hdev->id, in read_local_oob_data_complete()
5603 memcpy(mgmt_rp.hash192, rp->hash192, sizeof(rp->hash192)); in read_local_oob_data_complete()
5604 memcpy(mgmt_rp.rand192, rp->rand192, sizeof(rp->rand192)); in read_local_oob_data_complete()
5606 memcpy(mgmt_rp.hash256, rp->hash256, sizeof(rp->hash256)); in read_local_oob_data_complete()
5607 memcpy(mgmt_rp.rand256, rp->rand256, sizeof(rp->rand256)); in read_local_oob_data_complete()
5610 mgmt_cmd_complete(cmd->sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, in read_local_oob_data_complete()
5625 cmd->skb = hci_read_local_oob_data_sync(hdev, true, cmd->sk); in read_local_oob_data_sync()
5627 cmd->skb = hci_read_local_oob_data_sync(hdev, false, cmd->sk); in read_local_oob_data_sync()
5629 if (IS_ERR(cmd->skb)) in read_local_oob_data_sync()
5630 return PTR_ERR(cmd->skb); in read_local_oob_data_sync()
5646 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, in read_local_oob_data()
5648 goto unlock; in read_local_oob_data()
5652 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, in read_local_oob_data()
5654 goto unlock; in read_local_oob_data()
5659 err = -ENOMEM; in read_local_oob_data()
5665 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, in read_local_oob_data()
5672 unlock: in read_local_oob_data()
5685 if (!bdaddr_type_is_valid(addr->type)) in add_remote_oob_data()
5686 return mgmt_cmd_complete(sk, hdev->id, in add_remote_oob_data()
5697 if (cp->addr.type != BDADDR_BREDR) { in add_remote_oob_data()
5698 err = mgmt_cmd_complete(sk, hdev->id, in add_remote_oob_data()
5701 &cp->addr, sizeof(cp->addr)); in add_remote_oob_data()
5702 goto unlock; in add_remote_oob_data()
5705 err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, in add_remote_oob_data()
5706 cp->addr.type, cp->hash, in add_remote_oob_data()
5707 cp->rand, NULL, NULL); in add_remote_oob_data()
5713 err = mgmt_cmd_complete(sk, hdev->id, in add_remote_oob_data()
5715 &cp->addr, sizeof(cp->addr)); in add_remote_oob_data()
5721 if (bdaddr_type_is_le(cp->addr.type)) { in add_remote_oob_data()
5722 /* Enforce zero-valued 192-bit parameters as in add_remote_oob_data()
5725 if (memcmp(cp->rand192, ZERO_KEY, 16) || in add_remote_oob_data()
5726 memcmp(cp->hash192, ZERO_KEY, 16)) { in add_remote_oob_data()
5727 err = mgmt_cmd_complete(sk, hdev->id, in add_remote_oob_data()
5731 goto unlock; in add_remote_oob_data()
5737 /* In case one of the P-192 values is set to zero, in add_remote_oob_data()
5738 * then just disable OOB data for P-192. in add_remote_oob_data()
5740 if (!memcmp(cp->rand192, ZERO_KEY, 16) || in add_remote_oob_data()
5741 !memcmp(cp->hash192, ZERO_KEY, 16)) { in add_remote_oob_data()
5745 rand192 = cp->rand192; in add_remote_oob_data()
5746 hash192 = cp->hash192; in add_remote_oob_data()
5750 /* In case one of the P-256 values is set to zero, then just in add_remote_oob_data()
5751 * disable OOB data for P-256. in add_remote_oob_data()
5753 if (!memcmp(cp->rand256, ZERO_KEY, 16) || in add_remote_oob_data()
5754 !memcmp(cp->hash256, ZERO_KEY, 16)) { in add_remote_oob_data()
5758 rand256 = cp->rand256; in add_remote_oob_data()
5759 hash256 = cp->hash256; in add_remote_oob_data()
5762 err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, in add_remote_oob_data()
5763 cp->addr.type, hash192, rand192, in add_remote_oob_data()
5770 err = mgmt_cmd_complete(sk, hdev->id, in add_remote_oob_data()
5772 status, &cp->addr, sizeof(cp->addr)); in add_remote_oob_data()
5776 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, in add_remote_oob_data()
5780 unlock: in add_remote_oob_data()
5794 if (cp->addr.type != BDADDR_BREDR) in remove_remote_oob_data()
5795 return mgmt_cmd_complete(sk, hdev->id, in remove_remote_oob_data()
5798 &cp->addr, sizeof(cp->addr)); in remove_remote_oob_data()
5802 if (!bacmp(&cp->addr.bdaddr, BDADDR_ANY)) { in remove_remote_oob_data()
5808 err = hci_remove_remote_oob_data(hdev, &cp->addr.bdaddr, cp->addr.type); in remove_remote_oob_data()
5815 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_REMOTE_OOB_DATA, in remove_remote_oob_data()
5816 status, &cp->addr, sizeof(cp->addr)); in remove_remote_oob_data()
5838 cmd->cmd_complete(cmd, mgmt_status(status)); in mgmt_start_discovery_complete()
5883 mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, mgmt_status(err), in start_discovery_complete()
5884 cmd->param, 1); in start_discovery_complete()
5909 err = mgmt_cmd_complete(sk, hdev->id, op, in start_discovery_internal()
5911 &cp->type, sizeof(cp->type)); in start_discovery_internal()
5915 if (hdev->discovery.state != DISCOVERY_STOPPED || in start_discovery_internal()
5917 err = mgmt_cmd_complete(sk, hdev->id, op, MGMT_STATUS_BUSY, in start_discovery_internal()
5918 &cp->type, sizeof(cp->type)); in start_discovery_internal()
5922 if (!discovery_type_is_valid(hdev, cp->type, &status)) { in start_discovery_internal()
5923 err = mgmt_cmd_complete(sk, hdev->id, op, status, in start_discovery_internal()
5924 &cp->type, sizeof(cp->type)); in start_discovery_internal()
5929 if (hdev->discovery_paused) { in start_discovery_internal()
5930 err = mgmt_cmd_complete(sk, hdev->id, op, MGMT_STATUS_BUSY, in start_discovery_internal()
5931 &cp->type, sizeof(cp->type)); in start_discovery_internal()
5940 hdev->discovery.type = cp->type; in start_discovery_internal()
5941 hdev->discovery.report_invalid_rssi = false; in start_discovery_internal()
5943 hdev->discovery.limited = true; in start_discovery_internal()
5945 hdev->discovery.limited = false; in start_discovery_internal()
5949 err = -ENOMEM; in start_discovery_internal()
5987 const u16 max_uuid_count = ((U16_MAX - sizeof(*cp)) / 16); in start_service_discovery()
5997 err = mgmt_cmd_complete(sk, hdev->id, in start_service_discovery()
6000 &cp->type, sizeof(cp->type)); in start_service_discovery()
6004 if (hdev->discovery.state != DISCOVERY_STOPPED || in start_service_discovery()
6006 err = mgmt_cmd_complete(sk, hdev->id, in start_service_discovery()
6008 MGMT_STATUS_BUSY, &cp->type, in start_service_discovery()
6009 sizeof(cp->type)); in start_service_discovery()
6013 if (hdev->discovery_paused) { in start_service_discovery()
6014 err = mgmt_cmd_complete(sk, hdev->id, in start_service_discovery()
6016 MGMT_STATUS_BUSY, &cp->type, in start_service_discovery()
6017 sizeof(cp->type)); in start_service_discovery()
6021 uuid_count = __le16_to_cpu(cp->uuid_count); in start_service_discovery()
6025 err = mgmt_cmd_complete(sk, hdev->id, in start_service_discovery()
6027 MGMT_STATUS_INVALID_PARAMS, &cp->type, in start_service_discovery()
6028 sizeof(cp->type)); in start_service_discovery()
6036 err = mgmt_cmd_complete(sk, hdev->id, in start_service_discovery()
6038 MGMT_STATUS_INVALID_PARAMS, &cp->type, in start_service_discovery()
6039 sizeof(cp->type)); in start_service_discovery()
6043 if (!discovery_type_is_valid(hdev, cp->type, &status)) { in start_service_discovery()
6044 err = mgmt_cmd_complete(sk, hdev->id, in start_service_discovery()
6046 status, &cp->type, sizeof(cp->type)); in start_service_discovery()
6053 err = -ENOMEM; in start_service_discovery()
6062 hdev->discovery.result_filtering = true; in start_service_discovery()
6063 hdev->discovery.type = cp->type; in start_service_discovery()
6064 hdev->discovery.rssi = cp->rssi; in start_service_discovery()
6065 hdev->discovery.uuid_count = uuid_count; in start_service_discovery()
6068 hdev->discovery.uuids = kmemdup(cp->uuids, uuid_count * 16, in start_service_discovery()
6070 if (!hdev->discovery.uuids) { in start_service_discovery()
6071 err = mgmt_cmd_complete(sk, hdev->id, in start_service_discovery()
6074 &cp->type, sizeof(cp->type)); in start_service_discovery()
6104 cmd->cmd_complete(cmd, mgmt_status(status)); in mgmt_stop_discovery_complete()
6120 mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, mgmt_status(err), in stop_discovery_complete()
6121 cmd->param, 1); in stop_discovery_complete()
6145 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, in stop_discovery()
6146 MGMT_STATUS_REJECTED, &mgmt_cp->type, in stop_discovery()
6147 sizeof(mgmt_cp->type)); in stop_discovery()
6148 goto unlock; in stop_discovery()
6151 if (hdev->discovery.type != mgmt_cp->type) { in stop_discovery()
6152 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, in stop_discovery()
6154 &mgmt_cp->type, sizeof(mgmt_cp->type)); in stop_discovery()
6155 goto unlock; in stop_discovery()
6160 err = -ENOMEM; in stop_discovery()
6161 goto unlock; in stop_discovery()
6168 goto unlock; in stop_discovery()
6173 unlock: in stop_discovery()
6190 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_CONFIRM_NAME, in confirm_name()
6191 MGMT_STATUS_FAILED, &cp->addr, in confirm_name()
6192 sizeof(cp->addr)); in confirm_name()
6196 e = hci_inquiry_cache_lookup_unknown(hdev, &cp->addr.bdaddr); in confirm_name()
6198 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_CONFIRM_NAME, in confirm_name()
6199 MGMT_STATUS_INVALID_PARAMS, &cp->addr, in confirm_name()
6200 sizeof(cp->addr)); in confirm_name()
6204 if (cp->name_known) { in confirm_name()
6205 e->name_state = NAME_KNOWN; in confirm_name()
6206 list_del(&e->list); in confirm_name()
6208 e->name_state = NAME_NEEDED; in confirm_name()
6212 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_CONFIRM_NAME, 0, in confirm_name()
6213 &cp->addr, sizeof(cp->addr)); in confirm_name()
6229 if (!bdaddr_type_is_valid(cp->addr.type)) in block_device()
6230 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_BLOCK_DEVICE, in block_device()
6232 &cp->addr, sizeof(cp->addr)); in block_device()
6236 err = hci_bdaddr_list_add(&hdev->reject_list, &cp->addr.bdaddr, in block_device()
6237 cp->addr.type); in block_device()
6243 mgmt_event(MGMT_EV_DEVICE_BLOCKED, hdev, &cp->addr, sizeof(cp->addr), in block_device()
6248 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_BLOCK_DEVICE, status, in block_device()
6249 &cp->addr, sizeof(cp->addr)); in block_device()
6265 if (!bdaddr_type_is_valid(cp->addr.type)) in unblock_device()
6266 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNBLOCK_DEVICE, in unblock_device()
6268 &cp->addr, sizeof(cp->addr)); in unblock_device()
6272 err = hci_bdaddr_list_del(&hdev->reject_list, &cp->addr.bdaddr, in unblock_device()
6273 cp->addr.type); in unblock_device()
6279 mgmt_event(MGMT_EV_DEVICE_UNBLOCKED, hdev, &cp->addr, sizeof(cp->addr), in unblock_device()
6284 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNBLOCK_DEVICE, status, in unblock_device()
6285 &cp->addr, sizeof(cp->addr)); in unblock_device()
6306 source = __le16_to_cpu(cp->source); in set_device_id()
6309 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEVICE_ID, in set_device_id()
6314 hdev->devid_source = source; in set_device_id()
6315 hdev->devid_vendor = __le16_to_cpu(cp->vendor); in set_device_id()
6316 hdev->devid_product = __le16_to_cpu(cp->product); in set_device_id()
6317 hdev->devid_version = __le16_to_cpu(cp->version); in set_device_id()
6319 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_DEVICE_ID, 0, in set_device_id()
6332 bt_dev_err(hdev, "failed to re-configure advertising %d", err); in enable_advertising_instance()
6364 * set up earlier, then re-enable multi-instance advertising. in set_advertising_complete()
6367 list_empty(&hdev->adv_instances)) in set_advertising_complete()
6370 instance = hdev->cur_adv_instance; in set_advertising_complete()
6372 adv_instance = list_first_entry_or_null(&hdev->adv_instances, in set_advertising_complete()
6377 instance = adv_instance->instance; in set_advertising_complete()
6388 struct mgmt_mode *cp = cmd->param; in set_adv_sync()
6389 u8 val = !!cp->val; in set_adv_sync()
6391 if (cp->val == 0x02) in set_adv_sync()
6403 hdev->cur_adv_instance = 0x00; in set_adv_sync()
6431 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, in set_advertising()
6434 if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02) in set_advertising()
6435 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, in set_advertising()
6438 if (hdev->advertising_paused) in set_advertising()
6439 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, in set_advertising()
6444 val = !!cp->val; in set_advertising()
6453 (cp->val == 0x02) == hci_dev_test_flag(hdev, HCI_ADVERTISING_CONNECTABLE)) || in set_advertising()
6457 hdev->le_scan_type == LE_SCAN_ACTIVE)) { in set_advertising()
6460 if (cp->val) { in set_advertising()
6461 hdev->cur_adv_instance = 0x00; in set_advertising()
6463 if (cp->val == 0x02) in set_advertising()
6474 goto unlock; in set_advertising()
6479 goto unlock; in set_advertising()
6484 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, in set_advertising()
6486 goto unlock; in set_advertising()
6491 err = -ENOMEM; in set_advertising()
6499 unlock: in set_advertising()
6513 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_STATIC_ADDRESS, in set_static_address()
6517 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_STATIC_ADDRESS, in set_static_address()
6520 if (bacmp(&cp->bdaddr, BDADDR_ANY)) { in set_static_address()
6521 if (!bacmp(&cp->bdaddr, BDADDR_NONE)) in set_static_address()
6522 return mgmt_cmd_status(sk, hdev->id, in set_static_address()
6527 if ((cp->bdaddr.b[5] & 0xc0) != 0xc0) in set_static_address()
6528 return mgmt_cmd_status(sk, hdev->id, in set_static_address()
6535 bacpy(&hdev->static_addr, &cp->bdaddr); in set_static_address()
6539 goto unlock; in set_static_address()
6543 unlock: in set_static_address()
6558 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS, in set_scan_params()
6561 interval = __le16_to_cpu(cp->interval); in set_scan_params()
6564 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS, in set_scan_params()
6567 window = __le16_to_cpu(cp->window); in set_scan_params()
6570 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS, in set_scan_params()
6574 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS, in set_scan_params()
6579 hdev->le_scan_interval = interval; in set_scan_params()
6580 hdev->le_scan_window = window; in set_scan_params()
6582 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS, 0, in set_scan_params()
6589 hdev->discovery.state == DISCOVERY_STOPPED) in set_scan_params()
6604 mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, in fast_connectable_complete()
6607 struct mgmt_mode *cp = cmd->param; in fast_connectable_complete()
6609 if (cp->val) in fast_connectable_complete()
6614 send_settings_rsp(cmd->sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev); in fast_connectable_complete()
6615 new_settings(hdev, cmd->sk); in fast_connectable_complete()
6624 struct mgmt_mode *cp = cmd->param; in write_fast_connectable_sync()
6626 return hci_write_fast_connectable_sync(hdev, cp->val); in write_fast_connectable_sync()
6639 hdev->hci_ver < BLUETOOTH_VER_1_2) in set_fast_connectable()
6640 return mgmt_cmd_status(sk, hdev->id, in set_fast_connectable()
6644 if (cp->val != 0x00 && cp->val != 0x01) in set_fast_connectable()
6645 return mgmt_cmd_status(sk, hdev->id, in set_fast_connectable()
6651 if (!!cp->val == hci_dev_test_flag(hdev, HCI_FAST_CONNECTABLE)) { in set_fast_connectable()
6653 goto unlock; in set_fast_connectable()
6660 goto unlock; in set_fast_connectable()
6666 err = -ENOMEM; in set_fast_connectable()
6672 mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, in set_fast_connectable()
6679 unlock: in set_fast_connectable()
6699 mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err); in set_bredr_complete()
6701 send_settings_rsp(cmd->sk, MGMT_OP_SET_BREDR, hdev); in set_bredr_complete()
6702 new_settings(hdev, cmd->sk); in set_bredr_complete()
6721 status = hci_update_adv_data_sync(hdev, hdev->cur_adv_instance); in set_bredr_sync()
6735 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, in set_bredr()
6739 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, in set_bredr()
6742 if (cp->val != 0x00 && cp->val != 0x01) in set_bredr()
6743 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, in set_bredr()
6748 if (cp->val == hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { in set_bredr()
6750 goto unlock; in set_bredr()
6754 if (!cp->val) { in set_bredr()
6766 goto unlock; in set_bredr()
6769 goto unlock; in set_bredr()
6773 if (!cp->val) { in set_bredr()
6774 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, in set_bredr()
6776 goto unlock; in set_bredr()
6778 /* When configuring a dual-mode controller to operate in set_bredr()
6782 * Dual-mode controllers shall operate with the public in set_bredr()
6793 (bacmp(&hdev->static_addr, BDADDR_ANY) || in set_bredr()
6795 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, in set_bredr()
6797 goto unlock; in set_bredr()
6803 err = -ENOMEM; in set_bredr()
6809 mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, in set_bredr()
6814 goto unlock; in set_bredr()
6822 unlock: in set_bredr()
6837 mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err); in set_secure_conn_complete()
6841 cp = cmd->param; in set_secure_conn_complete()
6843 switch (cp->val) { in set_secure_conn_complete()
6858 send_settings_rsp(cmd->sk, cmd->opcode, hdev); in set_secure_conn_complete()
6859 new_settings(hdev, cmd->sk); in set_secure_conn_complete()
6868 struct mgmt_mode *cp = cmd->param; in set_secure_conn_sync()
6869 u8 val = !!cp->val; in set_secure_conn_sync()
6889 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, in set_secure_conn()
6895 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, in set_secure_conn()
6898 if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02) in set_secure_conn()
6899 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, in set_secure_conn()
6908 if (cp->val) { in set_secure_conn()
6911 if (cp->val == 0x02) in set_secure_conn()
6931 val = !!cp->val; in set_secure_conn()
6934 (cp->val == 0x02) == hci_dev_test_flag(hdev, HCI_SC_ONLY)) { in set_secure_conn()
6941 err = -ENOMEM; in set_secure_conn()
6947 mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, in set_secure_conn()
6967 if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02) in set_debug_keys()
6968 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEBUG_KEYS, in set_debug_keys()
6973 if (cp->val) in set_debug_keys()
6979 if (cp->val == 0x02) in set_debug_keys()
6988 u8 mode = (cp->val == 0x02) ? 0x01 : 0x00; in set_debug_keys()
6995 goto unlock; in set_debug_keys()
7000 unlock: in set_debug_keys()
7015 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY, in set_privacy()
7018 if (cp->privacy != 0x00 && cp->privacy != 0x01 && cp->privacy != 0x02) in set_privacy()
7019 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY, in set_privacy()
7023 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY, in set_privacy()
7033 if (cp->privacy) { in set_privacy()
7035 memcpy(hdev->irk, cp->irk, sizeof(hdev->irk)); in set_privacy()
7038 if (cp->privacy == 0x02) in set_privacy()
7044 memset(hdev->irk, 0, sizeof(hdev->irk)); in set_privacy()
7052 goto unlock; in set_privacy()
7057 unlock: in set_privacy()
7064 switch (irk->addr.type) { in irk_is_valid()
7070 if ((irk->addr.bdaddr.b[5] & 0xc0) != 0xc0) in irk_is_valid()
7082 const u16 max_irk_count = ((U16_MAX - sizeof(*cp)) / in load_irks()
7090 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS, in load_irks()
7093 irk_count = __le16_to_cpu(cp->irk_count); in load_irks()
7097 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS, in load_irks()
7105 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS, in load_irks()
7112 struct mgmt_irk_info *key = &cp->irks[i]; in load_irks()
7115 return mgmt_cmd_status(sk, hdev->id, in load_irks()
7125 struct mgmt_irk_info *irk = &cp->irks[i]; in load_irks()
7129 irk->val)) { in load_irks()
7131 &irk->addr.bdaddr); in load_irks()
7135 hci_add_irk(hdev, &irk->addr.bdaddr, in load_irks()
7136 le_addr_type(irk->addr.type), irk->val, in load_irks()
7142 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_LOAD_IRKS, 0, NULL, 0); in load_irks()
7151 if (key->initiator != 0x00 && key->initiator != 0x01) in ltk_is_valid()
7154 switch (key->addr.type) { in ltk_is_valid()
7160 if ((key->addr.bdaddr.b[5] & 0xc0) != 0xc0) in ltk_is_valid()
7172 const u16 max_key_count = ((U16_MAX - sizeof(*cp)) / in load_long_term_keys()
7180 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, in load_long_term_keys()
7183 key_count = __le16_to_cpu(cp->key_count); in load_long_term_keys()
7187 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, in load_long_term_keys()
7191 expected_len = struct_size(cp, keys, key_count); in load_long_term_keys()
7195 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, in load_long_term_keys()
7202 struct mgmt_ltk_info *key = &cp->keys[i]; in load_long_term_keys()
7205 return mgmt_cmd_status(sk, hdev->id, in load_long_term_keys()
7215 struct mgmt_ltk_info *key = &cp->keys[i]; in load_long_term_keys()
7220 key->val)) { in load_long_term_keys()
7222 &key->addr.bdaddr); in load_long_term_keys()
7226 switch (key->type) { in load_long_term_keys()
7229 type = key->initiator ? SMP_LTK : SMP_LTK_RESPONDER; in load_long_term_keys()
7233 type = key->initiator ? SMP_LTK : SMP_LTK_RESPONDER; in load_long_term_keys()
7251 hci_add_ltk(hdev, &key->addr.bdaddr, in load_long_term_keys()
7252 le_addr_type(key->addr.type), type, authenticated, in load_long_term_keys()
7253 key->val, key->enc_size, key->ediv, key->rand); in load_long_term_keys()
7256 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, 0, in load_long_term_keys()
7267 struct hci_conn *conn = cmd->user_data; in get_conn_info_complete()
7268 struct mgmt_cp_get_conn_info *cp = cmd->param; in get_conn_info_complete()
7274 memcpy(&rp.addr, &cp->addr.bdaddr, sizeof(rp.addr)); in get_conn_info_complete()
7278 rp.rssi = conn->rssi; in get_conn_info_complete()
7279 rp.tx_power = conn->tx_power; in get_conn_info_complete()
7280 rp.max_tx_power = conn->max_tx_power; in get_conn_info_complete()
7287 mgmt_cmd_complete(cmd->sk, cmd->index, MGMT_OP_GET_CONN_INFO, status, in get_conn_info_complete()
7296 struct mgmt_cp_get_conn_info *cp = cmd->param; in get_conn_info_sync()
7302 if (cp->addr.type == BDADDR_BREDR) in get_conn_info_sync()
7304 &cp->addr.bdaddr); in get_conn_info_sync()
7306 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->addr.bdaddr); in get_conn_info_sync()
7308 if (!conn || conn->state != BT_CONNECTED) in get_conn_info_sync()
7311 cmd->user_data = conn; in get_conn_info_sync()
7312 handle = cpu_to_le16(conn->handle); in get_conn_info_sync()
7320 if (!err && (!bdaddr_type_is_le(cp->addr.type) || in get_conn_info_sync()
7321 conn->tx_power == HCI_TX_POWER_INVALID)) in get_conn_info_sync()
7325 if (!err && conn->max_tx_power == HCI_TX_POWER_INVALID) in get_conn_info_sync()
7343 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); in get_conn_info()
7344 rp.addr.type = cp->addr.type; in get_conn_info()
7346 if (!bdaddr_type_is_valid(cp->addr.type)) in get_conn_info()
7347 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CONN_INFO, in get_conn_info()
7354 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CONN_INFO, in get_conn_info()
7357 goto unlock; in get_conn_info()
7360 if (cp->addr.type == BDADDR_BREDR) in get_conn_info()
7362 &cp->addr.bdaddr); in get_conn_info()
7364 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->addr.bdaddr); in get_conn_info()
7366 if (!conn || conn->state != BT_CONNECTED) { in get_conn_info()
7367 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CONN_INFO, in get_conn_info()
7370 goto unlock; in get_conn_info()
7376 conn_info_age = hdev->conn_info_min_age + in get_conn_info()
7377 prandom_u32_max(hdev->conn_info_max_age - in get_conn_info()
7378 hdev->conn_info_min_age); in get_conn_info()
7383 if (time_after(jiffies, conn->conn_info_timestamp + in get_conn_info()
7385 !conn->conn_info_timestamp) { in get_conn_info()
7391 err = -ENOMEM; in get_conn_info()
7398 mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CONN_INFO, in get_conn_info()
7404 goto unlock; in get_conn_info()
7407 conn->conn_info_timestamp = jiffies; in get_conn_info()
7410 rp.rssi = conn->rssi; in get_conn_info()
7411 rp.tx_power = conn->tx_power; in get_conn_info()
7412 rp.max_tx_power = conn->max_tx_power; in get_conn_info()
7414 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CONN_INFO, in get_conn_info()
7418 unlock: in get_conn_info()
7426 struct mgmt_cp_get_clock_info *cp = cmd->param; in get_clock_info_complete()
7428 struct hci_conn *conn = cmd->user_data; in get_clock_info_complete()
7434 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); in get_clock_info_complete()
7435 rp.addr.type = cp->addr.type; in get_clock_info_complete()
7440 rp.local_clock = cpu_to_le32(hdev->clock); in get_clock_info_complete()
7443 rp.piconet_clock = cpu_to_le32(conn->clock); in get_clock_info_complete()
7444 rp.accuracy = cpu_to_le16(conn->clock_accuracy); in get_clock_info_complete()
7448 mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, status, &rp, in get_clock_info_complete()
7457 struct mgmt_cp_get_clock_info *cp = cmd->param; in get_clock_info_sync()
7465 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr); in get_clock_info_sync()
7466 if (!conn || conn->state != BT_CONNECTED) in get_clock_info_sync()
7469 cmd->user_data = conn; in get_clock_info_sync()
7470 hci_cp.handle = cpu_to_le16(conn->handle); in get_clock_info_sync()
7488 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); in get_clock_info()
7489 rp.addr.type = cp->addr.type; in get_clock_info()
7491 if (cp->addr.type != BDADDR_BREDR) in get_clock_info()
7492 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CLOCK_INFO, in get_clock_info()
7499 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CLOCK_INFO, in get_clock_info()
7502 goto unlock; in get_clock_info()
7505 if (bacmp(&cp->addr.bdaddr, BDADDR_ANY)) { in get_clock_info()
7507 &cp->addr.bdaddr); in get_clock_info()
7508 if (!conn || conn->state != BT_CONNECTED) { in get_clock_info()
7509 err = mgmt_cmd_complete(sk, hdev->id, in get_clock_info()
7513 goto unlock; in get_clock_info()
7521 err = -ENOMEM; in get_clock_info()
7527 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CLOCK_INFO, in get_clock_info()
7535 unlock: in get_clock_info()
7548 if (conn->dst_type != type) in is_connected()
7551 if (conn->state != BT_CONNECTED) in is_connected()
7557 /* This function requires the caller holds hdev->lock */
7565 return -EIO; in hci_conn_params_set()
7567 if (params->auto_connect == auto_connect) in hci_conn_params_set()
7570 list_del_init(&params->action); in hci_conn_params_set()
7578 if (params->explicit_connect) in hci_conn_params_set()
7579 list_add(&params->action, &hdev->pend_le_conns); in hci_conn_params_set()
7582 if (params->explicit_connect) in hci_conn_params_set()
7583 list_add(&params->action, &hdev->pend_le_conns); in hci_conn_params_set()
7585 list_add(&params->action, &hdev->pend_le_reports); in hci_conn_params_set()
7590 list_add(&params->action, &hdev->pend_le_conns); in hci_conn_params_set()
7594 params->auto_connect = auto_connect; in hci_conn_params_set()
7631 if (!bdaddr_type_is_valid(cp->addr.type) || in add_device()
7632 !bacmp(&cp->addr.bdaddr, BDADDR_ANY)) in add_device()
7633 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE, in add_device()
7635 &cp->addr, sizeof(cp->addr)); in add_device()
7637 if (cp->action != 0x00 && cp->action != 0x01 && cp->action != 0x02) in add_device()
7638 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE, in add_device()
7640 &cp->addr, sizeof(cp->addr)); in add_device()
7644 if (cp->addr.type == BDADDR_BREDR) { in add_device()
7646 if (cp->action != 0x01) { in add_device()
7647 err = mgmt_cmd_complete(sk, hdev->id, in add_device()
7650 &cp->addr, sizeof(cp->addr)); in add_device()
7651 goto unlock; in add_device()
7654 err = hci_bdaddr_list_add_with_flags(&hdev->accept_list, in add_device()
7655 &cp->addr.bdaddr, in add_device()
7656 cp->addr.type, 0); in add_device()
7658 goto unlock; in add_device()
7665 addr_type = le_addr_type(cp->addr.type); in add_device()
7667 if (cp->action == 0x02) in add_device()
7669 else if (cp->action == 0x01) in add_device()
7679 if (!hci_is_identity_address(&cp->addr.bdaddr, addr_type)) { in add_device()
7680 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE, in add_device()
7682 &cp->addr, sizeof(cp->addr)); in add_device()
7683 goto unlock; in add_device()
7689 if (hci_conn_params_set(hdev, &cp->addr.bdaddr, addr_type, in add_device()
7691 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE, in add_device()
7692 MGMT_STATUS_FAILED, &cp->addr, in add_device()
7693 sizeof(cp->addr)); in add_device()
7694 goto unlock; in add_device()
7696 params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr, in add_device()
7699 current_flags = params->flags; in add_device()
7704 goto unlock; in add_device()
7707 device_added(sk, hdev, &cp->addr.bdaddr, cp->addr.type, cp->action); in add_device()
7708 supported_flags = hdev->conn_flags; in add_device()
7709 device_flags_changed(NULL, hdev, &cp->addr.bdaddr, cp->addr.type, in add_device()
7712 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE, in add_device()
7713 MGMT_STATUS_SUCCESS, &cp->addr, in add_device()
7714 sizeof(cp->addr)); in add_device()
7716 unlock: in add_device()
7747 if (bacmp(&cp->addr.bdaddr, BDADDR_ANY)) { in remove_device()
7751 if (!bdaddr_type_is_valid(cp->addr.type)) { in remove_device()
7752 err = mgmt_cmd_complete(sk, hdev->id, in remove_device()
7755 &cp->addr, sizeof(cp->addr)); in remove_device()
7756 goto unlock; in remove_device()
7759 if (cp->addr.type == BDADDR_BREDR) { in remove_device()
7760 err = hci_bdaddr_list_del(&hdev->accept_list, in remove_device()
7761 &cp->addr.bdaddr, in remove_device()
7762 cp->addr.type); in remove_device()
7764 err = mgmt_cmd_complete(sk, hdev->id, in remove_device()
7767 &cp->addr, in remove_device()
7768 sizeof(cp->addr)); in remove_device()
7769 goto unlock; in remove_device()
7774 device_removed(sk, hdev, &cp->addr.bdaddr, in remove_device()
7775 cp->addr.type); in remove_device()
7779 addr_type = le_addr_type(cp->addr.type); in remove_device()
7786 if (!hci_is_identity_address(&cp->addr.bdaddr, addr_type)) { in remove_device()
7787 err = mgmt_cmd_complete(sk, hdev->id, in remove_device()
7790 &cp->addr, sizeof(cp->addr)); in remove_device()
7791 goto unlock; in remove_device()
7794 params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr, in remove_device()
7797 err = mgmt_cmd_complete(sk, hdev->id, in remove_device()
7800 &cp->addr, sizeof(cp->addr)); in remove_device()
7801 goto unlock; in remove_device()
7804 if (params->auto_connect == HCI_AUTO_CONN_DISABLED || in remove_device()
7805 params->auto_connect == HCI_AUTO_CONN_EXPLICIT) { in remove_device()
7806 err = mgmt_cmd_complete(sk, hdev->id, in remove_device()
7809 &cp->addr, sizeof(cp->addr)); in remove_device()
7810 goto unlock; in remove_device()
7813 list_del(&params->action); in remove_device()
7814 list_del(&params->list); in remove_device()
7817 device_removed(sk, hdev, &cp->addr.bdaddr, cp->addr.type); in remove_device()
7822 if (cp->addr.type) { in remove_device()
7823 err = mgmt_cmd_complete(sk, hdev->id, in remove_device()
7826 &cp->addr, sizeof(cp->addr)); in remove_device()
7827 goto unlock; in remove_device()
7830 list_for_each_entry_safe(b, btmp, &hdev->accept_list, list) { in remove_device()
7831 device_removed(sk, hdev, &b->bdaddr, b->bdaddr_type); in remove_device()
7832 list_del(&b->list); in remove_device()
7838 list_for_each_entry_safe(p, tmp, &hdev->le_conn_params, list) { in remove_device()
7839 if (p->auto_connect == HCI_AUTO_CONN_DISABLED) in remove_device()
7841 device_removed(sk, hdev, &p->addr, p->addr_type); in remove_device()
7842 if (p->explicit_connect) { in remove_device()
7843 p->auto_connect = HCI_AUTO_CONN_EXPLICIT; in remove_device()
7846 list_del(&p->action); in remove_device()
7847 list_del(&p->list); in remove_device()
7857 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_REMOVE_DEVICE, in remove_device()
7858 MGMT_STATUS_SUCCESS, &cp->addr, in remove_device()
7859 sizeof(cp->addr)); in remove_device()
7860 unlock: in remove_device()
7869 const u16 max_param_count = ((U16_MAX - sizeof(*cp)) / in load_conn_param()
7875 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM, in load_conn_param()
7878 param_count = __le16_to_cpu(cp->param_count); in load_conn_param()
7882 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM, in load_conn_param()
7890 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM, in load_conn_param()
7901 struct mgmt_conn_param *param = &cp->params[i]; in load_conn_param()
7906 bt_dev_dbg(hdev, "Adding %pMR (type %u)", &param->addr.bdaddr, in load_conn_param()
7907 param->addr.type); in load_conn_param()
7909 if (param->addr.type == BDADDR_LE_PUBLIC) { in load_conn_param()
7911 } else if (param->addr.type == BDADDR_LE_RANDOM) { in load_conn_param()
7918 min = le16_to_cpu(param->min_interval); in load_conn_param()
7919 max = le16_to_cpu(param->max_interval); in load_conn_param()
7920 latency = le16_to_cpu(param->latency); in load_conn_param()
7921 timeout = le16_to_cpu(param->timeout); in load_conn_param()
7931 hci_param = hci_conn_params_add(hdev, &param->addr.bdaddr, in load_conn_param()
7938 hci_param->conn_min_interval = min; in load_conn_param()
7939 hci_param->conn_max_interval = max; in load_conn_param()
7940 hci_param->conn_latency = latency; in load_conn_param()
7941 hci_param->supervision_timeout = timeout; in load_conn_param()
7946 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM, 0, in load_conn_param()
7960 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG, in set_external_config()
7963 if (cp->config != 0x00 && cp->config != 0x01) in set_external_config()
7964 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG, in set_external_config()
7967 if (!test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks)) in set_external_config()
7968 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG, in set_external_config()
7973 if (cp->config) in set_external_config()
7980 goto unlock; in set_external_config()
7983 goto unlock; in set_external_config()
7994 queue_work(hdev->req_workqueue, &hdev->power_on); in set_external_config()
7996 set_bit(HCI_RAW, &hdev->flags); in set_external_config()
8001 unlock: in set_external_config()
8016 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PUBLIC_ADDRESS, in set_public_address()
8019 if (!bacmp(&cp->bdaddr, BDADDR_ANY)) in set_public_address()
8020 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PUBLIC_ADDRESS, in set_public_address()
8023 if (!hdev->set_bdaddr) in set_public_address()
8024 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PUBLIC_ADDRESS, in set_public_address()
8029 changed = !!bacmp(&hdev->public_addr, &cp->bdaddr); in set_public_address()
8030 bacpy(&hdev->public_addr, &cp->bdaddr); in set_public_address()
8034 goto unlock; in set_public_address()
8037 goto unlock; in set_public_address()
8050 queue_work(hdev->req_workqueue, &hdev->power_on); in set_public_address()
8053 unlock: in set_public_address()
8065 struct sk_buff *skb = cmd->skb; in read_local_oob_ext_data_complete()
8078 status = mgmt_status(skb->data[0]); in read_local_oob_ext_data_complete()
8083 mgmt_cp = cmd->param; in read_local_oob_ext_data_complete()
8096 if (skb->len != sizeof(*rp)) { in read_local_oob_ext_data_complete()
8101 rp = (void *)skb->data; in read_local_oob_ext_data_complete()
8104 h192 = rp->hash; in read_local_oob_ext_data_complete()
8105 r192 = rp->rand; in read_local_oob_ext_data_complete()
8112 if (skb->len != sizeof(*rp)) { in read_local_oob_ext_data_complete()
8117 rp = (void *)skb->data; in read_local_oob_ext_data_complete()
8125 h192 = rp->hash192; in read_local_oob_ext_data_complete()
8126 r192 = rp->rand192; in read_local_oob_ext_data_complete()
8129 h256 = rp->hash256; in read_local_oob_ext_data_complete()
8130 r256 = rp->rand256; in read_local_oob_ext_data_complete()
8141 eir_len = eir_append_data(mgmt_rp->eir, 0, EIR_CLASS_OF_DEV, in read_local_oob_ext_data_complete()
8142 hdev->dev_class, 3); in read_local_oob_ext_data_complete()
8145 eir_len = eir_append_data(mgmt_rp->eir, eir_len, in read_local_oob_ext_data_complete()
8147 eir_len = eir_append_data(mgmt_rp->eir, eir_len, in read_local_oob_ext_data_complete()
8152 eir_len = eir_append_data(mgmt_rp->eir, eir_len, in read_local_oob_ext_data_complete()
8154 eir_len = eir_append_data(mgmt_rp->eir, eir_len, in read_local_oob_ext_data_complete()
8159 mgmt_rp->type = mgmt_cp->type; in read_local_oob_ext_data_complete()
8160 mgmt_rp->eir_len = cpu_to_le16(eir_len); in read_local_oob_ext_data_complete()
8162 err = mgmt_cmd_complete(cmd->sk, hdev->id, in read_local_oob_ext_data_complete()
8168 hci_sock_set_flag(cmd->sk, HCI_MGMT_OOB_DATA_EVENTS); in read_local_oob_ext_data_complete()
8172 HCI_MGMT_OOB_DATA_EVENTS, cmd->sk); in read_local_oob_ext_data_complete()
8190 return -ENOMEM; in read_local_ssp_oob_req()
8216 switch (cp->type) { in read_local_oob_ext_data()
8244 return -ENOMEM; in read_local_oob_ext_data()
8257 switch (cp->type) { in read_local_oob_ext_data()
8268 eir_len = eir_append_data(rp->eir, eir_len, in read_local_oob_ext_data()
8270 hdev->dev_class, 3); in read_local_oob_ext_data()
8284 * local out-of-band data when privacy is in use. in read_local_oob_ext_data()
8298 !bacmp(&hdev->bdaddr, BDADDR_ANY) || in read_local_oob_ext_data()
8300 bacmp(&hdev->static_addr, BDADDR_ANY))) { in read_local_oob_ext_data()
8301 memcpy(addr, &hdev->static_addr, 6); in read_local_oob_ext_data()
8304 memcpy(addr, &hdev->bdaddr, 6); in read_local_oob_ext_data()
8308 eir_len = eir_append_data(rp->eir, eir_len, EIR_LE_BDADDR, in read_local_oob_ext_data()
8316 eir_len = eir_append_data(rp->eir, eir_len, EIR_LE_ROLE, in read_local_oob_ext_data()
8320 eir_len = eir_append_data(rp->eir, eir_len, in read_local_oob_ext_data()
8324 eir_len = eir_append_data(rp->eir, eir_len, in read_local_oob_ext_data()
8334 eir_len = eir_append_data(rp->eir, eir_len, EIR_FLAGS, in read_local_oob_ext_data()
8346 rp->type = cp->type; in read_local_oob_ext_data()
8347 rp->eir_len = cpu_to_le16(eir_len); in read_local_oob_ext_data()
8349 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_EXT_DATA, in read_local_oob_ext_data()
8383 if (hdev->adv_tx_power != HCI_TX_POWER_INVALID || ext_adv_capable(hdev)) in get_supported_adv_flags()
8391 if (hdev->le_features[1] & HCI_LE_PHY_2M) in get_supported_adv_flags()
8394 if (hdev->le_features[1] & HCI_LE_PHY_CODED) in get_supported_adv_flags()
8414 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_READ_ADV_FEATURES, in read_adv_features()
8419 rp_len = sizeof(*rp) + hdev->adv_instance_cnt; in read_adv_features()
8423 return -ENOMEM; in read_adv_features()
8428 rp->supported_flags = cpu_to_le32(supported_flags); in read_adv_features()
8429 rp->max_adv_data_len = HCI_MAX_AD_LENGTH; in read_adv_features()
8430 rp->max_scan_rsp_len = HCI_MAX_AD_LENGTH; in read_adv_features()
8431 rp->max_instances = hdev->le_num_of_adv_sets; in read_adv_features()
8432 rp->num_instances = hdev->adv_instance_cnt; in read_adv_features()
8434 instance = rp->instance; in read_adv_features()
8435 list_for_each_entry(adv_instance, &hdev->adv_instances, list) { in read_adv_features()
8436 /* Only instances 1-le_num_of_adv_sets are externally visible */ in read_adv_features()
8437 if (adv_instance->instance <= hdev->adv_instance_cnt) { in read_adv_features()
8438 *instance = adv_instance->instance; in read_adv_features()
8441 rp->num_instances--; in read_adv_features()
8442 rp_len--; in read_adv_features()
8448 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_READ_ADV_FEATURES, in read_adv_features()
8472 max_len -= 3; in tlv_data_max_len()
8475 max_len -= 3; in tlv_data_max_len()
8478 max_len -= calculate_name_len(hdev); in tlv_data_max_len()
8481 max_len -= 4; in tlv_data_max_len()
8564 ((phy_flags && (phy_flags ^ (phy_flags & -phy_flags))))) in requested_adv_flags_are_valid()
8584 list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) { in add_adv_complete()
8587 if (!adv->pending) in add_adv_complete()
8591 adv->pending = false; in add_adv_complete()
8595 instance = adv->instance; in add_adv_complete()
8597 if (hdev->cur_adv_instance == instance) in add_adv_complete()
8610 struct mgmt_cp_add_advertising *cp = cmd->param; in add_advertising_complete()
8615 rp.instance = cp->instance; in add_advertising_complete()
8618 mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, in add_advertising_complete()
8621 mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, in add_advertising_complete()
8624 add_adv_complete(hdev, cmd->sk, cp->instance, err); in add_advertising_complete()
8632 struct mgmt_cp_add_advertising *cp = cmd->param; in add_advertising_sync()
8634 return hci_schedule_adv_instance_sync(hdev, cp->instance, true); in add_advertising_sync()
8655 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, in add_advertising()
8658 if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets) in add_advertising()
8659 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, in add_advertising()
8662 if (data_len != sizeof(*cp) + cp->adv_data_len + cp->scan_rsp_len) in add_advertising()
8663 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, in add_advertising()
8666 flags = __le32_to_cpu(cp->flags); in add_advertising()
8667 timeout = __le16_to_cpu(cp->timeout); in add_advertising()
8668 duration = __le16_to_cpu(cp->duration); in add_advertising()
8671 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, in add_advertising()
8677 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, in add_advertising()
8679 goto unlock; in add_advertising()
8683 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, in add_advertising()
8685 goto unlock; in add_advertising()
8688 if (!tlv_data_is_valid(hdev, flags, cp->data, cp->adv_data_len, true) || in add_advertising()
8689 !tlv_data_is_valid(hdev, flags, cp->data + cp->adv_data_len, in add_advertising()
8690 cp->scan_rsp_len, false)) { in add_advertising()
8691 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, in add_advertising()
8693 goto unlock; in add_advertising()
8696 prev_instance_cnt = hdev->adv_instance_cnt; in add_advertising()
8698 adv = hci_add_adv_instance(hdev, cp->instance, flags, in add_advertising()
8699 cp->adv_data_len, cp->data, in add_advertising()
8700 cp->scan_rsp_len, in add_advertising()
8701 cp->data + cp->adv_data_len, in add_advertising()
8704 hdev->le_adv_min_interval, in add_advertising()
8705 hdev->le_adv_max_interval, 0); in add_advertising()
8707 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, in add_advertising()
8709 goto unlock; in add_advertising()
8715 if (hdev->adv_instance_cnt > prev_instance_cnt) in add_advertising()
8716 mgmt_advertising_added(sk, hdev, cp->instance); in add_advertising()
8718 if (hdev->cur_adv_instance == cp->instance) { in add_advertising()
8726 next_instance = hci_get_next_instance(hdev, cp->instance); in add_advertising()
8728 schedule_instance = next_instance->instance; in add_advertising()
8729 } else if (!hdev->adv_instance_timeout) { in add_advertising()
8733 schedule_instance = cp->instance; in add_advertising()
8743 rp.instance = cp->instance; in add_advertising()
8744 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, in add_advertising()
8746 goto unlock; in add_advertising()
8755 err = -ENOMEM; in add_advertising()
8756 goto unlock; in add_advertising()
8759 cp->instance = schedule_instance; in add_advertising()
8766 unlock: in add_advertising()
8776 struct mgmt_cp_add_ext_adv_params *cp = cmd->param; in add_ext_adv_params_complete()
8781 BT_DBG("%s", hdev->name); in add_ext_adv_params_complete()
8785 adv = hci_find_adv_instance(hdev, cp->instance); in add_ext_adv_params_complete()
8787 goto unlock; in add_ext_adv_params_complete()
8789 rp.instance = cp->instance; in add_ext_adv_params_complete()
8790 rp.tx_power = adv->tx_power; in add_ext_adv_params_complete()
8795 flags = __le32_to_cpu(cp->flags); in add_ext_adv_params_complete()
8804 if (!adv->pending) in add_ext_adv_params_complete()
8805 mgmt_advertising_removed(cmd->sk, hdev, cp->instance); in add_ext_adv_params_complete()
8807 hci_remove_adv_instance(hdev, cp->instance); in add_ext_adv_params_complete()
8809 mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, in add_ext_adv_params_complete()
8812 mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, in add_ext_adv_params_complete()
8816 unlock: in add_ext_adv_params_complete()
8826 struct mgmt_cp_add_ext_adv_params *cp = cmd->param; in add_ext_adv_params_sync()
8828 return hci_setup_ext_adv_instance_sync(hdev, cp->instance); in add_ext_adv_params_sync()
8844 BT_DBG("%s", hdev->name); in add_ext_adv_params()
8848 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, in add_ext_adv_params()
8851 if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets) in add_ext_adv_params()
8852 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, in add_ext_adv_params()
8862 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING, in add_ext_adv_params()
8865 flags = __le32_to_cpu(cp->flags); in add_ext_adv_params()
8868 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, in add_ext_adv_params()
8875 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, in add_ext_adv_params()
8877 goto unlock; in add_ext_adv_params()
8881 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, in add_ext_adv_params()
8883 goto unlock; in add_ext_adv_params()
8888 __le16_to_cpu(cp->timeout) : 0; in add_ext_adv_params()
8891 __le16_to_cpu(cp->duration) : in add_ext_adv_params()
8892 hdev->def_multi_adv_rotation_duration; in add_ext_adv_params()
8895 __le32_to_cpu(cp->min_interval) : in add_ext_adv_params()
8896 hdev->le_adv_min_interval; in add_ext_adv_params()
8899 __le32_to_cpu(cp->max_interval) : in add_ext_adv_params()
8900 hdev->le_adv_max_interval; in add_ext_adv_params()
8903 cp->tx_power : in add_ext_adv_params()
8907 adv = hci_add_adv_instance(hdev, cp->instance, flags, 0, NULL, 0, NULL, in add_ext_adv_params()
8912 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_PARAMS, in add_ext_adv_params()
8914 goto unlock; in add_ext_adv_params()
8922 err = -ENOMEM; in add_ext_adv_params()
8923 hci_remove_adv_instance(hdev, cp->instance); in add_ext_adv_params()
8924 goto unlock; in add_ext_adv_params()
8932 rp.instance = cp->instance; in add_ext_adv_params()
8936 err = mgmt_cmd_complete(sk, hdev->id, in add_ext_adv_params()
8941 unlock: in add_ext_adv_params()
8950 struct mgmt_cp_add_ext_adv_data *cp = cmd->param; in add_ext_adv_data_complete()
8953 add_adv_complete(hdev, cmd->sk, cp->instance, err); in add_ext_adv_data_complete()
8957 rp.instance = cp->instance; in add_ext_adv_data_complete()
8960 mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, in add_ext_adv_data_complete()
8963 mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, in add_ext_adv_data_complete()
8972 struct mgmt_cp_add_ext_adv_data *cp = cmd->param; in add_ext_adv_data_sync()
8976 err = hci_update_adv_data_sync(hdev, cp->instance); in add_ext_adv_data_sync()
8980 err = hci_update_scan_rsp_data_sync(hdev, cp->instance); in add_ext_adv_data_sync()
8984 return hci_enable_ext_advertising_sync(hdev, cp->instance); in add_ext_adv_data_sync()
8987 return hci_schedule_adv_instance_sync(hdev, cp->instance, true); in add_ext_adv_data_sync()
9001 BT_DBG("%s", hdev->name); in add_ext_adv_data()
9005 adv_instance = hci_find_adv_instance(hdev, cp->instance); in add_ext_adv_data()
9008 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, in add_ext_adv_data()
9010 goto unlock; in add_ext_adv_data()
9015 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, in add_ext_adv_data()
9021 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, in add_ext_adv_data()
9027 if (!tlv_data_is_valid(hdev, adv_instance->flags, cp->data, in add_ext_adv_data()
9028 cp->adv_data_len, true) || in add_ext_adv_data()
9029 !tlv_data_is_valid(hdev, adv_instance->flags, cp->data + in add_ext_adv_data()
9030 cp->adv_data_len, cp->scan_rsp_len, false)) { in add_ext_adv_data()
9031 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, in add_ext_adv_data()
9037 hci_set_adv_instance_data(hdev, cp->instance, cp->adv_data_len, in add_ext_adv_data()
9038 cp->data, cp->scan_rsp_len, in add_ext_adv_data()
9039 cp->data + cp->adv_data_len); in add_ext_adv_data()
9042 if (hdev->cur_adv_instance == cp->instance) { in add_ext_adv_data()
9051 next_instance = hci_get_next_instance(hdev, cp->instance); in add_ext_adv_data()
9053 schedule_instance = next_instance->instance; in add_ext_adv_data()
9054 } else if (!hdev->adv_instance_timeout) { in add_ext_adv_data()
9058 schedule_instance = cp->instance; in add_ext_adv_data()
9066 if (adv_instance->pending) { in add_ext_adv_data()
9067 mgmt_advertising_added(sk, hdev, cp->instance); in add_ext_adv_data()
9068 adv_instance->pending = false; in add_ext_adv_data()
9070 rp.instance = cp->instance; in add_ext_adv_data()
9071 err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ADD_EXT_ADV_DATA, in add_ext_adv_data()
9073 goto unlock; in add_ext_adv_data()
9079 err = -ENOMEM; in add_ext_adv_data()
9095 if (adv_instance->pending) in add_ext_adv_data()
9096 mgmt_advertising_added(sk, hdev, cp->instance); in add_ext_adv_data()
9098 goto unlock; in add_ext_adv_data()
9101 hci_remove_adv_instance(hdev, cp->instance); in add_ext_adv_data()
9103 unlock: in add_ext_adv_data()
9113 struct mgmt_cp_remove_advertising *cp = cmd->param; in remove_advertising_complete()
9119 rp.instance = cp->instance; in remove_advertising_complete()
9122 mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, in remove_advertising_complete()
9125 mgmt_cmd_complete(cmd->sk, cmd->index, cmd->opcode, in remove_advertising_complete()
9134 struct mgmt_cp_remove_advertising *cp = cmd->param; in remove_advertising_sync()
9137 err = hci_remove_advertising_sync(hdev, cmd->sk, cp->instance, true); in remove_advertising_sync()
9141 if (list_empty(&hdev->adv_instances)) in remove_advertising_sync()
9158 if (cp->instance && !hci_find_adv_instance(hdev, cp->instance)) { in remove_advertising()
9159 err = mgmt_cmd_status(sk, hdev->id, in remove_advertising()
9162 goto unlock; in remove_advertising()
9166 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_REMOVE_ADVERTISING, in remove_advertising()
9168 goto unlock; in remove_advertising()
9171 if (list_empty(&hdev->adv_instances)) { in remove_advertising()
9172 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_REMOVE_ADVERTISING, in remove_advertising()
9174 goto unlock; in remove_advertising()
9180 err = -ENOMEM; in remove_advertising()
9181 goto unlock; in remove_advertising()
9189 unlock: in remove_advertising()
9205 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO, in get_adv_size_info()
9208 if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets) in get_adv_size_info()
9209 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO, in get_adv_size_info()
9212 flags = __le32_to_cpu(cp->flags); in get_adv_size_info()
9219 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO, in get_adv_size_info()
9222 rp.instance = cp->instance; in get_adv_size_info()
9223 rp.flags = cp->flags; in get_adv_size_info()
9227 return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO, in get_adv_size_info()
9368 if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) in mgmt_index_added()
9371 switch (hdev->dev_type) { in mgmt_index_added()
9390 ev.bus = hdev->bus; in mgmt_index_added()
9401 if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) in mgmt_index_removed()
9404 switch (hdev->dev_type) { in mgmt_index_removed()
9425 ev.bus = hdev->bus; in mgmt_index_removed()
9433 cancel_delayed_work_sync(&hdev->discov_off); in mgmt_index_removed()
9434 cancel_delayed_work_sync(&hdev->service_cache); in mgmt_index_removed()
9435 cancel_delayed_work_sync(&hdev->rpa_expired); in mgmt_index_removed()
9482 if (memcmp(hdev->dev_class, zero_cod, sizeof(zero_cod)) != 0) { in __mgmt_power_off()
9504 if (err == -ERFKILL) in mgmt_set_powered_failed()
9509 mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_POWERED, status); in mgmt_set_powered_failed()
9522 bacpy(&ev.key.addr.bdaddr, &key->bdaddr); in mgmt_new_link_key()
9524 ev.key.type = key->type; in mgmt_new_link_key()
9525 memcpy(ev.key.val, key->val, HCI_LINK_KEY_SIZE); in mgmt_new_link_key()
9526 ev.key.pin_len = key->pin_len; in mgmt_new_link_key()
9533 switch (ltk->type) { in mgmt_ltk_type()
9536 if (ltk->authenticated) in mgmt_ltk_type()
9540 if (ltk->authenticated) in mgmt_ltk_type()
9556 /* Devices using resolvable or non-resolvable random addresses in mgmt_new_ltk()
9558 * to store long term keys. Their addresses will change the in mgmt_new_ltk()
9563 * identity is known, the long term keys are internally in mgmt_new_ltk()
9567 if (key->bdaddr_type == ADDR_LE_DEV_RANDOM && in mgmt_new_ltk()
9568 (key->bdaddr.b[5] & 0xc0) != 0xc0) in mgmt_new_ltk()
9573 bacpy(&ev.key.addr.bdaddr, &key->bdaddr); in mgmt_new_ltk()
9574 ev.key.addr.type = link_to_bdaddr(LE_LINK, key->bdaddr_type); in mgmt_new_ltk()
9576 ev.key.enc_size = key->enc_size; in mgmt_new_ltk()
9577 ev.key.ediv = key->ediv; in mgmt_new_ltk()
9578 ev.key.rand = key->rand; in mgmt_new_ltk()
9580 if (key->type == SMP_LTK) in mgmt_new_ltk()
9586 memcpy(ev.key.val, key->val, key->enc_size); in mgmt_new_ltk()
9587 memset(ev.key.val + key->enc_size, 0, in mgmt_new_ltk()
9588 sizeof(ev.key.val) - key->enc_size); in mgmt_new_ltk()
9601 bacpy(&ev.rpa, &irk->rpa); in mgmt_new_irk()
9602 bacpy(&ev.irk.addr.bdaddr, &irk->bdaddr); in mgmt_new_irk()
9603 ev.irk.addr.type = link_to_bdaddr(LE_LINK, irk->addr_type); in mgmt_new_irk()
9604 memcpy(ev.irk.val, irk->val, sizeof(irk->val)); in mgmt_new_irk()
9616 /* Devices using resolvable or non-resolvable random addresses in mgmt_new_csrk()
9618 * to store signature resolving keys. Their addresses will change in mgmt_new_csrk()
9625 if (csrk->bdaddr_type == ADDR_LE_DEV_RANDOM && in mgmt_new_csrk()
9626 (csrk->bdaddr.b[5] & 0xc0) != 0xc0) in mgmt_new_csrk()
9631 bacpy(&ev.key.addr.bdaddr, &csrk->bdaddr); in mgmt_new_csrk()
9632 ev.key.addr.type = link_to_bdaddr(LE_LINK, csrk->bdaddr_type); in mgmt_new_csrk()
9633 ev.key.type = csrk->type; in mgmt_new_csrk()
9634 memcpy(ev.key.val, csrk->val, sizeof(csrk->val)); in mgmt_new_csrk()
9669 if (conn->le_adv_data_len > 0) in mgmt_device_connected()
9671 sizeof(*ev) + conn->le_adv_data_len); in mgmt_device_connected()
9675 eir_precalc_len(sizeof(conn->dev_class))); in mgmt_device_connected()
9678 bacpy(&ev->addr.bdaddr, &conn->dst); in mgmt_device_connected()
9679 ev->addr.type = link_to_bdaddr(conn->type, conn->dst_type); in mgmt_device_connected()
9681 if (conn->out) in mgmt_device_connected()
9684 ev->flags = __cpu_to_le32(flags); in mgmt_device_connected()
9690 if (conn->le_adv_data_len > 0) { in mgmt_device_connected()
9691 skb_put_data(skb, conn->le_adv_data, conn->le_adv_data_len); in mgmt_device_connected()
9692 eir_len = conn->le_adv_data_len; in mgmt_device_connected()
9697 if (memcmp(conn->dev_class, "\0\0\0", sizeof(conn->dev_class))) in mgmt_device_connected()
9699 conn->dev_class, sizeof(conn->dev_class)); in mgmt_device_connected()
9702 ev->eir_len = cpu_to_le16(eir_len); in mgmt_device_connected()
9711 cmd->cmd_complete(cmd, 0); in disconnect_rsp()
9713 *sk = cmd->sk; in disconnect_rsp()
9722 struct mgmt_cp_unpair_device *cp = cmd->param; in unpair_device_rsp()
9724 device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, cmd->sk); in unpair_device_rsp()
9726 cmd->cmd_complete(cmd, 0); in unpair_device_rsp()
9739 cp = cmd->param; in mgmt_powering_down()
9740 if (!cp->val) in mgmt_powering_down()
9757 cancel_delayed_work(&hdev->power_off); in mgmt_device_disconnected()
9758 queue_work(hdev->req_workqueue, &hdev->power_off.work); in mgmt_device_disconnected()
9774 if (hdev->suspended) in mgmt_device_disconnected()
9800 cp = cmd->param; in mgmt_disconnect_failed()
9802 if (bacmp(bdaddr, &cp->addr.bdaddr)) in mgmt_disconnect_failed()
9805 if (cp->addr.type != bdaddr_type) in mgmt_disconnect_failed()
9808 cmd->cmd_complete(cmd, mgmt_status(status)); in mgmt_disconnect_failed()
9821 cancel_delayed_work(&hdev->power_off); in mgmt_connect_failed()
9822 queue_work(hdev->req_workqueue, &hdev->power_off.work); in mgmt_connect_failed()
9852 cmd->cmd_complete(cmd, mgmt_status(status)); in mgmt_pin_code_reply_complete()
9865 cmd->cmd_complete(cmd, mgmt_status(status)); in mgmt_pin_code_neg_reply_complete()
9908 return -ENOENT; in user_pairing_resp_complete()
9910 cmd->cmd_complete(cmd, mgmt_status(status)); in user_pairing_resp_complete()
9968 bacpy(&ev.addr.bdaddr, &conn->dst); in mgmt_auth_failed()
9969 ev.addr.type = link_to_bdaddr(conn->type, conn->dst_type); in mgmt_auth_failed()
9974 mgmt_event(MGMT_EV_AUTH_FAILED, conn->hdev, &ev, sizeof(ev), in mgmt_auth_failed()
9975 cmd ? cmd->sk : NULL); in mgmt_auth_failed()
9978 cmd->cmd_complete(cmd, status); in mgmt_auth_failed()
9995 if (test_bit(HCI_AUTH, &hdev->flags)) in mgmt_auth_enable_complete()
10014 if (match->sk == NULL) { in sk_lookup()
10015 match->sk = cmd->sk; in sk_lookup()
10016 sock_hold(match->sk); in sk_lookup()
10049 memcpy(ev.short_name, hdev->short_name, HCI_MAX_SHORT_NAME_LENGTH); in mgmt_set_local_name_complete()
10053 memcpy(hdev->dev_name, name, sizeof(hdev->dev_name)); in mgmt_set_local_name_complete()
10063 HCI_MGMT_LOCAL_NAME_EVENTS, cmd ? cmd->sk : NULL); in mgmt_set_local_name_complete()
10064 ext_info_changed(hdev, cmd ? cmd->sk : NULL); in mgmt_set_local_name_complete()
10091 if (eir_len - parsed < field_len + 1) in eir_has_uuids()
10141 hdev->discovery.scan_start + in restart_le_scan()
10142 hdev->discovery.scan_duration)) in restart_le_scan()
10145 queue_delayed_work(hdev->req_workqueue, &hdev->le_scan_restart, in restart_le_scan()
10161 if (hdev->discovery.rssi != HCI_RSSI_INVALID && in is_filter_match()
10163 (rssi < hdev->discovery.rssi && in is_filter_match()
10164 !test_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks)))) in is_filter_match()
10167 if (hdev->discovery.uuid_count != 0) { in is_filter_match()
10171 if (!eir_has_uuids(eir, eir_len, hdev->discovery.uuid_count, in is_filter_match()
10172 hdev->discovery.uuids) && in is_filter_match()
10174 hdev->discovery.uuid_count, in is_filter_match()
10175 hdev->discovery.uuids)) in is_filter_match()
10182 if (test_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks)) { in is_filter_match()
10186 if (hdev->discovery.rssi != HCI_RSSI_INVALID && in is_filter_match()
10187 rssi < hdev->discovery.rssi) in is_filter_match()
10219 advmon_skb_len = (sizeof(struct mgmt_ev_adv_monitor_device_found) - in mgmt_send_adv_monitor_device_found()
10220 sizeof(struct mgmt_ev_device_found)) + skb->len; in mgmt_send_adv_monitor_device_found()
10232 skb_put_data(advmon_skb, skb->data, skb->len); in mgmt_send_adv_monitor_device_found()
10261 if (report_device && !hdev->advmon_pend_notify) { in mgmt_adv_monitor_device_found()
10266 hdev->advmon_pend_notify = false; in mgmt_adv_monitor_device_found()
10268 list_for_each_entry_safe(dev, tmp, &hdev->monitored_devices, list) { in mgmt_adv_monitor_device_found()
10269 if (!bacmp(&dev->bdaddr, bdaddr)) { in mgmt_adv_monitor_device_found()
10272 if (!dev->notified) { in mgmt_adv_monitor_device_found()
10275 dev->handle); in mgmt_adv_monitor_device_found()
10277 dev->notified = true; in mgmt_adv_monitor_device_found()
10281 if (!dev->notified) in mgmt_adv_monitor_device_found()
10282 hdev->advmon_pend_notify = true; in mgmt_adv_monitor_device_found()
10310 if (!hdev->mesh_ad_types[0]) in mesh_device_found()
10316 for (j = 0; j < sizeof(hdev->mesh_ad_types); j++) { in mesh_device_found()
10317 if (!hdev->mesh_ad_types[j]) in mesh_device_found()
10320 if (hdev->mesh_ad_types[j] == eir[i + 1]) in mesh_device_found()
10328 for (j = 0; j < sizeof(hdev->mesh_ad_types); j++) { in mesh_device_found()
10329 if (!hdev->mesh_ad_types[j]) in mesh_device_found()
10332 if (hdev->mesh_ad_types[j] == scan_rsp[i + 1]) in mesh_device_found()
10348 bacpy(&ev->addr.bdaddr, bdaddr); in mesh_device_found()
10349 ev->addr.type = link_to_bdaddr(LE_LINK, addr_type); in mesh_device_found()
10350 ev->rssi = rssi; in mesh_device_found()
10351 ev->flags = cpu_to_le32(flags); in mesh_device_found()
10352 ev->instant = cpu_to_le64(instant); in mesh_device_found()
10362 ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len); in mesh_device_found()
10381 /* Don't send events for a non-kernel initiated discovery. With in mgmt_device_found()
10388 if (link_type == LE_LINK && !list_empty(&hdev->pend_le_reports)) in mgmt_device_found()
10394 if (hdev->discovery.result_filtering) { in mgmt_device_found()
10401 if (hdev->discovery.limited) { in mgmt_device_found()
10429 if (rssi == HCI_RSSI_INVALID && !hdev->discovery.report_invalid_rssi && in mgmt_device_found()
10433 bacpy(&ev->addr.bdaddr, bdaddr); in mgmt_device_found()
10434 ev->addr.type = link_to_bdaddr(link_type, addr_type); in mgmt_device_found()
10435 ev->rssi = rssi; in mgmt_device_found()
10436 ev->flags = cpu_to_le32(flags); in mgmt_device_found()
10454 ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len); in mgmt_device_found()
10471 bacpy(&ev->addr.bdaddr, bdaddr); in mgmt_remote_name()
10472 ev->addr.type = link_to_bdaddr(link_type, addr_type); in mgmt_remote_name()
10473 ev->rssi = rssi; in mgmt_remote_name()
10480 ev->eir_len = cpu_to_le16(eir_len); in mgmt_remote_name()
10481 ev->flags = cpu_to_le32(flags); in mgmt_remote_name()
10493 ev.type = hdev->discovery.type; in mgmt_discovering()