History

Bluetooth: hci_sync: Convert MGMT_OP_SSP

mgmt-tester paths: Set SSP on - Success 2 Set Device ID - SSP off and Power on

Brian Gix committed 5 years ago

Commit 32448451 parent 5e233ed5 files · +80 −83Browse files

Unified · Split

5 files
  1. include/net/bluetooth/hci_core.h +0 −1
  2. include/net/bluetooth/hci_sync.h +1 −0
  3. net/bluetooth/hci_event.c +1 −3
  4. net/bluetooth/hci_sync.c +6 −1
  5. net/bluetooth/mgmt.c +72 −78
include/net/bluetooth/hci_core.h+0−1
@@ -1806,7 +1806,6 @@ int mgmt_user_passkey_notify(struct hci_dev *hdev, bdaddr_t *bdaddr, · 1805 unmodified lines
1806 u8 entered);1806 u8 entered);
1807void mgmt_auth_failed(struct hci_conn *conn, u8 status);1807void mgmt_auth_failed(struct hci_conn *conn, u8 status);
1808void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status);1808void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status);
1809void mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status);
1810void mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class,1809void mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class,
1811 u8 status);1810 u8 status);
1812void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status);1811void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status);
include/net/bluetooth/hci_sync.h+1−0
@@ -47,6 +47,7 @@ int hci_update_class_sync(struct hci_dev *hdev); · 46 unmodified lines
47int hci_update_eir_sync(struct hci_dev *hdev);47int hci_update_eir_sync(struct hci_dev *hdev);
48int hci_update_class_sync(struct hci_dev *hdev);48int hci_update_class_sync(struct hci_dev *hdev);
49int hci_update_name_sync(struct hci_dev *hdev);49int hci_update_name_sync(struct hci_dev *hdev);
50int hci_write_ssp_mode_sync(struct hci_dev *hdev, u8 mode);
50 51
51int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,52int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,
52 bool rpa, u8 *own_addr_type);53 bool rpa, u8 *own_addr_type);
net/bluetooth/hci_event.c+1−3
@@ -545,9 +545,7 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) · 544 unmodified lines
545 hdev->features[1][0] &= ~LMP_HOST_SSP;545 hdev->features[1][0] &= ~LMP_HOST_SSP;
546 }546 }
547 547
548 if (hci_dev_test_flag(hdev, HCI_MGMT))548 if (!status) {
549 mgmt_ssp_enable_complete(hdev, sent->mode, status);
550 else if (!status) {
551 if (sent->mode)549 if (sent->mode)
552 hci_dev_set_flag(hdev, HCI_SSP_ENABLED);550 hci_dev_set_flag(hdev, HCI_SSP_ENABLED);
553 else551 else
net/bluetooth/hci_sync.c+6−1
@@ -2142,7 +2142,7 @@ int hci_write_sc_support_sync(struct hci_dev *hdev, u8 val) · 2141 unmodified lines
2142 return err;2142 return err;
2143}2143}
2144 2144
2145static int hci_write_ssp_mode_sync(struct hci_dev *hdev, u8 mode)2145int hci_write_ssp_mode_sync(struct hci_dev *hdev, u8 mode)
2146{2146{
2147 int err;2147 int err;
2148 2148
@@ -2150,6 +2150,11 @@ static int hci_write_ssp_mode_sync(struct hci_dev *hdev, u8 mode) · 1 unmodified line
2150 lmp_host_ssp_capable(hdev))2150 lmp_host_ssp_capable(hdev))
2151 return 0;2151 return 0;
2152 2152
2153 if (!mode && hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS)) {
2154 __hci_cmd_sync_status(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE,
2155 sizeof(mode), &mode, HCI_CMD_TIMEOUT);
2156 }
2157
2153 err = __hci_cmd_sync_status(hdev, HCI_OP_WRITE_SSP_MODE,2158 err = __hci_cmd_sync_status(hdev, HCI_OP_WRITE_SSP_MODE,
2154 sizeof(mode), &mode, HCI_CMD_TIMEOUT);2159 sizeof(mode), &mode, HCI_CMD_TIMEOUT);
2155 if (err)2160 if (err)
net/bluetooth/mgmt.c+72−78
@@ -1760,6 +1760,69 @@ failed: · 1759 unmodified lines
1760 return err;1760 return err;
1761}1761}
1762 1762
1763static void set_ssp_complete(struct hci_dev *hdev, void *data, int err)
1764{
1765 struct cmd_lookup match = { NULL, hdev };
1766 struct mgmt_pending_cmd *cmd = data;
1767 struct mgmt_mode *cp = cmd->param;
1768 u8 enable = cp->val;
1769 bool changed;
1770
1771 if (err) {
1772 u8 mgmt_err = mgmt_status(err);
1773
1774 if (enable && hci_dev_test_and_clear_flag(hdev,
1775 HCI_SSP_ENABLED)) {
1776 hci_dev_clear_flag(hdev, HCI_HS_ENABLED);
1777 new_settings(hdev, NULL);
1778 }
1779
1780 mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, cmd_status_rsp,
1781 &mgmt_err);
1782 return;
1783 }
1784
1785 if (enable) {
1786 changed = !hci_dev_test_and_set_flag(hdev, HCI_SSP_ENABLED);
1787 } else {
1788 changed = hci_dev_test_and_clear_flag(hdev, HCI_SSP_ENABLED);
1789
1790 if (!changed)
1791 changed = hci_dev_test_and_clear_flag(hdev,
1792 HCI_HS_ENABLED);
1793 else
1794 hci_dev_clear_flag(hdev, HCI_HS_ENABLED);
1795 }
1796
1797 mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, settings_rsp, &match);
1798
1799 if (changed)
1800 new_settings(hdev, match.sk);
1801
1802 if (match.sk)
1803 sock_put(match.sk);
1804
1805 hci_update_eir_sync(hdev);
1806}
1807
1808static int set_ssp_sync(struct hci_dev *hdev, void *data)
1809{
1810 struct mgmt_pending_cmd *cmd = data;
1811 struct mgmt_mode *cp = cmd->param;
1812 bool changed = false;
1813 int err;
1814
1815 if (cp->val)
1816 changed = !hci_dev_test_and_set_flag(hdev, HCI_SSP_ENABLED);
1817
1818 err = hci_write_ssp_mode_sync(hdev, cp->val);
1819
1820 if (!err && changed)
1821 hci_dev_clear_flag(hdev, HCI_SSP_ENABLED);
1822
1823 return err;
1824}
1825
1763static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)1826static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1764{1827{
1765 struct mgmt_mode *cp = data;1828 struct mgmt_mode *cp = data;
@@ -1821,19 +1884,18 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) · 55 unmodified lines
1821 }1884 }
1822 1885
1823 cmd = mgmt_pending_add(sk, MGMT_OP_SET_SSP, hdev, data, len);1886 cmd = mgmt_pending_add(sk, MGMT_OP_SET_SSP, hdev, data, len);
1824 if (!cmd) {1887 if (!cmd)
1825 err = -ENOMEM;1888 err = -ENOMEM;
1826 goto failed;1889 else
1827 }1890 err = hci_cmd_sync_queue(hdev, set_ssp_sync, cmd,
1828 1891 set_ssp_complete);
1829 if (!cp->val && hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS))
1830 hci_send_cmd(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE,
1831 sizeof(cp->val), &cp->val);
1832 1892
1833 err = hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, 1, &cp->val);
1834 if (err < 0) {1893 if (err < 0) {
1835 mgmt_pending_remove(cmd);1894 err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
1836 goto failed;1895 MGMT_STATUS_FAILED);
1896
1897 if (cmd)
1898 mgmt_pending_remove(cmd);
1837 }1899 }
1838 1900
1839failed:1901failed:
@@ -9309,74 +9371,6 @@ void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) · 7469 unmodified lines
9309 sock_put(match.sk);9371 sock_put(match.sk);
9310}9372}
9311 9373
9312static void clear_eir(struct hci_request *req)
9313{
9314 struct hci_dev *hdev = req->hdev;
9315 struct hci_cp_write_eir cp;
9316
9317 if (!lmp_ext_inq_capable(hdev))
9318 return;
9319
9320 memset(hdev->eir, 0, sizeof(hdev->eir));
9321
9322 memset(&cp, 0, sizeof(cp));
9323
9324 hci_req_add(req, HCI_OP_WRITE_EIR, sizeof(cp), &cp);
9325}
9326
9327void mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status)
9328{
9329 struct cmd_lookup match = { NULL, hdev };
9330 struct hci_request req;
9331 bool changed = false;
9332
9333 if (status) {
9334 u8 mgmt_err = mgmt_status(status);
9335
9336 if (enable && hci_dev_test_and_clear_flag(hdev,
9337 HCI_SSP_ENABLED)) {
9338 hci_dev_clear_flag(hdev, HCI_HS_ENABLED);
9339 new_settings(hdev, NULL);
9340 }
9341
9342 mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, cmd_status_rsp,
9343 &mgmt_err);
9344 return;
9345 }
9346
9347 if (enable) {
9348 changed = !hci_dev_test_and_set_flag(hdev, HCI_SSP_ENABLED);
9349 } else {
9350 changed = hci_dev_test_and_clear_flag(hdev, HCI_SSP_ENABLED);
9351 if (!changed)
9352 changed = hci_dev_test_and_clear_flag(hdev,
9353 HCI_HS_ENABLED);
9354 else
9355 hci_dev_clear_flag(hdev, HCI_HS_ENABLED);
9356 }
9357
9358 mgmt_pending_foreach(MGMT_OP_SET_SSP, hdev, settings_rsp, &match);
9359
9360 if (changed)
9361 new_settings(hdev, match.sk);
9362
9363 if (match.sk)
9364 sock_put(match.sk);
9365
9366 hci_req_init(&req, hdev);
9367
9368 if (hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) {
9369 if (hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS))
9370 hci_req_add(&req, HCI_OP_WRITE_SSP_DEBUG_MODE,
9371 sizeof(enable), &enable);
9372 __hci_req_update_eir(&req);
9373 } else {
9374 clear_eir(&req);
9375 }
9376
9377 hci_req_run(&req, NULL);
9378}
9379
9380static void sk_lookup(struct mgmt_pending_cmd *cmd, void *data)9374static void sk_lookup(struct mgmt_pending_cmd *cmd, void *data)
9381{9375{
9382 struct cmd_lookup *match = data;9376 struct cmd_lookup *match = data;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t