hci_event.c (5d43889c07bb38694742936aa70d1187c012e198) | hci_event.c (18722c247023035b9e2e2a08a887adec2a9a6e49) |
---|---|
1/* 2 BlueZ - Bluetooth protocol stack for Linux 3 Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved. 4 5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License version 2 as --- 472 unchanged lines hidden (view full) --- 481 482static void hci_cc_read_local_commands(struct hci_dev *hdev, 483 struct sk_buff *skb) 484{ 485 struct hci_rp_read_local_commands *rp = (void *) skb->data; 486 487 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 488 | 1/* 2 BlueZ - Bluetooth protocol stack for Linux 3 Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved. 4 5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License version 2 as --- 472 unchanged lines hidden (view full) --- 481 482static void hci_cc_read_local_commands(struct hci_dev *hdev, 483 struct sk_buff *skb) 484{ 485 struct hci_rp_read_local_commands *rp = (void *) skb->data; 486 487 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 488 |
489 if (!rp->status) | 489 if (rp->status) 490 return; 491 492 if (test_bit(HCI_SETUP, &hdev->dev_flags)) |
490 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); 491} 492 493static void hci_cc_read_local_features(struct hci_dev *hdev, 494 struct sk_buff *skb) 495{ 496 struct hci_rp_read_local_features *rp = (void *) skb->data; 497 --- 35 unchanged lines hidden (view full) --- 533 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) 534 hdev->esco_type |= (ESCO_2EV3); 535 536 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) 537 hdev->esco_type |= (ESCO_3EV3); 538 539 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) 540 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); | 493 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); 494} 495 496static void hci_cc_read_local_features(struct hci_dev *hdev, 497 struct sk_buff *skb) 498{ 499 struct hci_rp_read_local_features *rp = (void *) skb->data; 500 --- 35 unchanged lines hidden (view full) --- 536 if (hdev->features[0][5] & LMP_EDR_ESCO_2M) 537 hdev->esco_type |= (ESCO_2EV3); 538 539 if (hdev->features[0][5] & LMP_EDR_ESCO_3M) 540 hdev->esco_type |= (ESCO_3EV3); 541 542 if (hdev->features[0][5] & LMP_EDR_3S_ESCO) 543 hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5); |
541 542 BT_DBG("%s features 0x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", hdev->name, 543 hdev->features[0][0], hdev->features[0][1], 544 hdev->features[0][2], hdev->features[0][3], 545 hdev->features[0][4], hdev->features[0][5], 546 hdev->features[0][6], hdev->features[0][7]); | |
547} 548 549static void hci_cc_read_local_ext_features(struct hci_dev *hdev, 550 struct sk_buff *skb) 551{ 552 struct hci_rp_read_local_ext_features *rp = (void *) skb->data; 553 554 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); --- 1222 unchanged lines hidden (view full) --- 1777 default: 1778 return MGMT_DEV_DISCONN_UNKNOWN; 1779 } 1780} 1781 1782static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 1783{ 1784 struct hci_ev_disconn_complete *ev = (void *) skb->data; | 544} 545 546static void hci_cc_read_local_ext_features(struct hci_dev *hdev, 547 struct sk_buff *skb) 548{ 549 struct hci_rp_read_local_ext_features *rp = (void *) skb->data; 550 551 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); --- 1222 unchanged lines hidden (view full) --- 1774 default: 1775 return MGMT_DEV_DISCONN_UNKNOWN; 1776 } 1777} 1778 1779static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 1780{ 1781 struct hci_ev_disconn_complete *ev = (void *) skb->data; |
1782 u8 reason = hci_to_mgmt_reason(ev->reason); |
|
1785 struct hci_conn *conn; | 1783 struct hci_conn *conn; |
1784 u8 type; |
|
1786 1787 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 1788 1789 hci_dev_lock(hdev); 1790 1791 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 1792 if (!conn) 1793 goto unlock; 1794 | 1785 1786 BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); 1787 1788 hci_dev_lock(hdev); 1789 1790 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 1791 if (!conn) 1792 goto unlock; 1793 |
1795 if (ev->status == 0) 1796 conn->state = BT_CLOSED; | 1794 if (ev->status) { 1795 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, 1796 conn->dst_type, ev->status); 1797 goto unlock; 1798 } |
1797 | 1799 |
1798 if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags) && 1799 (conn->type == ACL_LINK || conn->type == LE_LINK)) { 1800 if (ev->status) { 1801 mgmt_disconnect_failed(hdev, &conn->dst, conn->type, 1802 conn->dst_type, ev->status); 1803 } else { 1804 u8 reason = hci_to_mgmt_reason(ev->reason); | 1800 conn->state = BT_CLOSED; |
1805 | 1801 |
1806 mgmt_device_disconnected(hdev, &conn->dst, conn->type, 1807 conn->dst_type, reason); 1808 } 1809 } | 1802 if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) 1803 mgmt_device_disconnected(hdev, &conn->dst, conn->type, 1804 conn->dst_type, reason); |
1810 | 1805 |
1811 if (ev->status == 0) { 1812 u8 type = conn->type; | 1806 if (conn->type == ACL_LINK && conn->flush_key) 1807 hci_remove_link_key(hdev, &conn->dst); |
1813 | 1808 |
1814 if (type == ACL_LINK && conn->flush_key) 1815 hci_remove_link_key(hdev, &conn->dst); 1816 hci_proto_disconn_cfm(conn, ev->reason); 1817 hci_conn_del(conn); | 1809 type = conn->type; |
1818 | 1810 |
1819 /* Re-enable advertising if necessary, since it might 1820 * have been disabled by the connection. From the 1821 * HCI_LE_Set_Advertise_Enable command description in 1822 * the core specification (v4.0): 1823 * "The Controller shall continue advertising until the Host 1824 * issues an LE_Set_Advertise_Enable command with 1825 * Advertising_Enable set to 0x00 (Advertising is disabled) 1826 * or until a connection is created or until the Advertising 1827 * is timed out due to Directed Advertising." 1828 */ 1829 if (type == LE_LINK) 1830 mgmt_reenable_advertising(hdev); 1831 } | 1811 hci_proto_disconn_cfm(conn, ev->reason); 1812 hci_conn_del(conn); |
1832 | 1813 |
1814 /* Re-enable advertising if necessary, since it might 1815 * have been disabled by the connection. From the 1816 * HCI_LE_Set_Advertise_Enable command description in 1817 * the core specification (v4.0): 1818 * "The Controller shall continue advertising until the Host 1819 * issues an LE_Set_Advertise_Enable command with 1820 * Advertising_Enable set to 0x00 (Advertising is disabled) 1821 * or until a connection is created or until the Advertising 1822 * is timed out due to Directed Advertising." 1823 */ 1824 if (type == LE_LINK) 1825 mgmt_reenable_advertising(hdev); 1826 |
|
1833unlock: 1834 hci_dev_unlock(hdev); 1835} 1836 1837static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 1838{ 1839 struct hci_ev_auth_complete *ev = (void *) skb->data; 1840 struct hci_conn *conn; --- 1693 unchanged lines hidden (view full) --- 3534 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) 3535 mgmt_device_connected(hdev, &ev->bdaddr, conn->type, 3536 conn->dst_type, 0, NULL, 0, NULL); 3537 3538 conn->sec_level = BT_SECURITY_LOW; 3539 conn->handle = __le16_to_cpu(ev->handle); 3540 conn->state = BT_CONNECTED; 3541 | 1827unlock: 1828 hci_dev_unlock(hdev); 1829} 1830 1831static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 1832{ 1833 struct hci_ev_auth_complete *ev = (void *) skb->data; 1834 struct hci_conn *conn; --- 1693 unchanged lines hidden (view full) --- 3528 if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags)) 3529 mgmt_device_connected(hdev, &ev->bdaddr, conn->type, 3530 conn->dst_type, 0, NULL, 0, NULL); 3531 3532 conn->sec_level = BT_SECURITY_LOW; 3533 conn->handle = __le16_to_cpu(ev->handle); 3534 conn->state = BT_CONNECTED; 3535 |
3536 if (test_bit(HCI_6LOWPAN_ENABLED, &hdev->dev_flags)) 3537 set_bit(HCI_CONN_6LOWPAN, &conn->flags); 3538 |
|
3542 hci_conn_add_sysfs(conn); 3543 3544 hci_proto_connect_cfm(conn, ev->status); 3545 3546unlock: 3547 hci_dev_unlock(hdev); 3548} 3549 --- 307 unchanged lines hidden --- | 3539 hci_conn_add_sysfs(conn); 3540 3541 hci_proto_connect_cfm(conn, ev->status); 3542 3543unlock: 3544 hci_dev_unlock(hdev); 3545} 3546 --- 307 unchanged lines hidden --- |