aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_event.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r--net/bluetooth/hci_event.c103
1 files changed, 60 insertions, 43 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 4785ab0795f5..5391469ff1a5 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -29,8 +29,9 @@
29#include <net/bluetooth/bluetooth.h> 29#include <net/bluetooth/bluetooth.h>
30#include <net/bluetooth/hci_core.h> 30#include <net/bluetooth/hci_core.h>
31#include <net/bluetooth/mgmt.h> 31#include <net/bluetooth/mgmt.h>
32#include <net/bluetooth/a2mp.h> 32
33#include <net/bluetooth/amp.h> 33#include "a2mp.h"
34#include "amp.h"
34 35
35/* Handle HCI Event packets */ 36/* Handle HCI Event packets */
36 37
@@ -417,6 +418,21 @@ static void hci_cc_write_voice_setting(struct hci_dev *hdev,
417 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); 418 hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
418} 419}
419 420
421static void hci_cc_read_num_supported_iac(struct hci_dev *hdev,
422 struct sk_buff *skb)
423{
424 struct hci_rp_read_num_supported_iac *rp = (void *) skb->data;
425
426 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
427
428 if (rp->status)
429 return;
430
431 hdev->num_iac = rp->num_iac;
432
433 BT_DBG("%s num iac %d", hdev->name, hdev->num_iac);
434}
435
420static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) 436static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
421{ 437{
422 __u8 status = *((__u8 *) skb->data); 438 __u8 status = *((__u8 *) skb->data);
@@ -918,12 +934,12 @@ static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb)
918 934
919 if (!status) { 935 if (!status) {
920 if (*sent) 936 if (*sent)
921 set_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags); 937 set_bit(HCI_ADVERTISING, &hdev->dev_flags);
922 else 938 else
923 clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags); 939 clear_bit(HCI_ADVERTISING, &hdev->dev_flags);
924 } 940 }
925 941
926 if (!test_bit(HCI_INIT, &hdev->flags)) { 942 if (*sent && !test_bit(HCI_INIT, &hdev->flags)) {
927 struct hci_request req; 943 struct hci_request req;
928 944
929 hci_req_init(&req, hdev); 945 hci_req_init(&req, hdev);
@@ -1005,7 +1021,7 @@ static void hci_cc_write_le_host_supported(struct hci_dev *hdev,
1005 } else { 1021 } else {
1006 hdev->features[1][0] &= ~LMP_HOST_LE; 1022 hdev->features[1][0] &= ~LMP_HOST_LE;
1007 clear_bit(HCI_LE_ENABLED, &hdev->dev_flags); 1023 clear_bit(HCI_LE_ENABLED, &hdev->dev_flags);
1008 clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags); 1024 clear_bit(HCI_ADVERTISING, &hdev->dev_flags);
1009 } 1025 }
1010 1026
1011 if (sent->simul) 1027 if (sent->simul)
@@ -1296,9 +1312,11 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status)
1296 goto unlock; 1312 goto unlock;
1297 1313
1298 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { 1314 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
1299 struct hci_cp_auth_requested cp; 1315 struct hci_cp_auth_requested auth_cp;
1300 cp.handle = __cpu_to_le16(conn->handle); 1316
1301 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); 1317 auth_cp.handle = __cpu_to_le16(conn->handle);
1318 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED,
1319 sizeof(auth_cp), &auth_cp);
1302 } 1320 }
1303 1321
1304unlock: 1322unlock:
@@ -1470,33 +1488,6 @@ static void hci_cs_disconnect(struct hci_dev *hdev, u8 status)
1470 hci_dev_unlock(hdev); 1488 hci_dev_unlock(hdev);
1471} 1489}
1472 1490
1473static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
1474{
1475 struct hci_conn *conn;
1476
1477 BT_DBG("%s status 0x%2.2x", hdev->name, status);
1478
1479 if (status) {
1480 hci_dev_lock(hdev);
1481
1482 conn = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT);
1483 if (!conn) {
1484 hci_dev_unlock(hdev);
1485 return;
1486 }
1487
1488 BT_DBG("%s bdaddr %pMR conn %p", hdev->name, &conn->dst, conn);
1489
1490 conn->state = BT_CLOSED;
1491 mgmt_connect_failed(hdev, &conn->dst, conn->type,
1492 conn->dst_type, status);
1493 hci_proto_connect_cfm(conn, status);
1494 hci_conn_del(conn);
1495
1496 hci_dev_unlock(hdev);
1497 }
1498}
1499
1500static void hci_cs_create_phylink(struct hci_dev *hdev, u8 status) 1491static void hci_cs_create_phylink(struct hci_dev *hdev, u8 status)
1501{ 1492{
1502 struct hci_cp_create_phy_link *cp; 1493 struct hci_cp_create_phy_link *cp;
@@ -1826,10 +1817,25 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
1826 } 1817 }
1827 1818
1828 if (ev->status == 0) { 1819 if (ev->status == 0) {
1829 if (conn->type == ACL_LINK && conn->flush_key) 1820 u8 type = conn->type;
1821
1822 if (type == ACL_LINK && conn->flush_key)
1830 hci_remove_link_key(hdev, &conn->dst); 1823 hci_remove_link_key(hdev, &conn->dst);
1831 hci_proto_disconn_cfm(conn, ev->reason); 1824 hci_proto_disconn_cfm(conn, ev->reason);
1832 hci_conn_del(conn); 1825 hci_conn_del(conn);
1826
1827 /* Re-enable advertising if necessary, since it might
1828 * have been disabled by the connection. From the
1829 * HCI_LE_Set_Advertise_Enable command description in
1830 * the core specification (v4.0):
1831 * "The Controller shall continue advertising until the Host
1832 * issues an LE_Set_Advertise_Enable command with
1833 * Advertising_Enable set to 0x00 (Advertising is disabled)
1834 * or until a connection is created or until the Advertising
1835 * is timed out due to Directed Advertising."
1836 */
1837 if (type == LE_LINK)
1838 mgmt_reenable_advertising(hdev);
1833 } 1839 }
1834 1840
1835unlock: 1841unlock:
@@ -2144,6 +2150,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
2144 hci_cc_write_voice_setting(hdev, skb); 2150 hci_cc_write_voice_setting(hdev, skb);
2145 break; 2151 break;
2146 2152
2153 case HCI_OP_READ_NUM_SUPPORTED_IAC:
2154 hci_cc_read_num_supported_iac(hdev, skb);
2155 break;
2156
2147 case HCI_OP_WRITE_SSP_MODE: 2157 case HCI_OP_WRITE_SSP_MODE:
2148 hci_cc_write_ssp_mode(hdev, skb); 2158 hci_cc_write_ssp_mode(hdev, skb);
2149 break; 2159 break;
@@ -2347,10 +2357,6 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
2347 hci_cs_disconnect(hdev, ev->status); 2357 hci_cs_disconnect(hdev, ev->status);
2348 break; 2358 break;
2349 2359
2350 case HCI_OP_LE_CREATE_CONN:
2351 hci_cs_le_create_conn(hdev, ev->status);
2352 break;
2353
2354 case HCI_OP_CREATE_PHY_LINK: 2360 case HCI_OP_CREATE_PHY_LINK:
2355 hci_cs_create_phylink(hdev, ev->status); 2361 hci_cs_create_phylink(hdev, ev->status);
2356 break; 2362 break;
@@ -3490,6 +3496,17 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
3490 3496
3491 conn->dst_type = ev->bdaddr_type; 3497 conn->dst_type = ev->bdaddr_type;
3492 3498
3499 /* The advertising parameters for own address type
3500 * define which source address and source address
3501 * type this connections has.
3502 */
3503 if (bacmp(&conn->src, BDADDR_ANY)) {
3504 conn->src_type = ADDR_LE_DEV_PUBLIC;
3505 } else {
3506 bacpy(&conn->src, &hdev->static_addr);
3507 conn->src_type = ADDR_LE_DEV_RANDOM;
3508 }
3509
3493 if (ev->role == LE_CONN_ROLE_MASTER) { 3510 if (ev->role == LE_CONN_ROLE_MASTER) {
3494 conn->out = true; 3511 conn->out = true;
3495 conn->link_mode |= HCI_LM_MASTER; 3512 conn->link_mode |= HCI_LM_MASTER;
@@ -3645,8 +3662,8 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
3645 skb_pull(skb, HCI_EVENT_HDR_SIZE); 3662 skb_pull(skb, HCI_EVENT_HDR_SIZE);
3646 3663
3647 if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->req.event == event) { 3664 if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->req.event == event) {
3648 struct hci_command_hdr *hdr = (void *) hdev->sent_cmd->data; 3665 struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data;
3649 u16 opcode = __le16_to_cpu(hdr->opcode); 3666 u16 opcode = __le16_to_cpu(cmd_hdr->opcode);
3650 3667
3651 hci_req_cmd_complete(hdev, opcode, 0); 3668 hci_req_cmd_complete(hdev, opcode, 0);
3652 } 3669 }