diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-09-26 03:43:48 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-28 21:01:33 -0400 |
commit | 6ac59344ef25d5f0ebadb5663cf700d25d2a3886 (patch) | |
tree | b4dbdf1589e0a7b6d3ed04d38fb7615a54f0d7af /net/bluetooth/hci_conn.c | |
parent | 1143e5a6d4d69cd36d44e0184769aa2b17041a10 (diff) |
[Bluetooth] Support create connection cancel command
In case of non-blocking connects it is possible that the last user
of an ACL link quits before the connection has been fully established.
This will lead to a race condition where the internal state of a
connection is closed, but the actual link has been established and is
active. In case of Bluetooth 1.2 and later devices it is possible to
call create connection cancel to abort the connect. For older devices
the disconnect timer will be used to trigger the needed disconnect.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_conn.c')
-rw-r--r-- | net/bluetooth/hci_conn.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 7e9515b41cc0..90e3a285a17e 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -84,6 +84,20 @@ static void hci_acl_connect(struct hci_conn *conn) | |||
84 | hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, sizeof(cp), &cp); | 84 | hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, sizeof(cp), &cp); |
85 | } | 85 | } |
86 | 86 | ||
87 | static void hci_acl_connect_cancel(struct hci_conn *conn) | ||
88 | { | ||
89 | struct hci_cp_create_conn_cancel cp; | ||
90 | |||
91 | BT_DBG("%p", conn); | ||
92 | |||
93 | if (conn->hdev->hci_ver < 2) | ||
94 | return; | ||
95 | |||
96 | bacpy(&cp.bdaddr, &conn->dst); | ||
97 | hci_send_cmd(conn->hdev, OGF_LINK_CTL, | ||
98 | OCF_CREATE_CONN_CANCEL, sizeof(cp), &cp); | ||
99 | } | ||
100 | |||
87 | void hci_acl_disconn(struct hci_conn *conn, __u8 reason) | 101 | void hci_acl_disconn(struct hci_conn *conn, __u8 reason) |
88 | { | 102 | { |
89 | struct hci_cp_disconnect cp; | 103 | struct hci_cp_disconnect cp; |
@@ -94,7 +108,8 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason) | |||
94 | 108 | ||
95 | cp.handle = __cpu_to_le16(conn->handle); | 109 | cp.handle = __cpu_to_le16(conn->handle); |
96 | cp.reason = reason; | 110 | cp.reason = reason; |
97 | hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_DISCONNECT, sizeof(cp), &cp); | 111 | hci_send_cmd(conn->hdev, OGF_LINK_CTL, |
112 | OCF_DISCONNECT, sizeof(cp), &cp); | ||
98 | } | 113 | } |
99 | 114 | ||
100 | void hci_add_sco(struct hci_conn *conn, __u16 handle) | 115 | void hci_add_sco(struct hci_conn *conn, __u16 handle) |
@@ -124,12 +139,20 @@ static void hci_conn_timeout(unsigned long arg) | |||
124 | return; | 139 | return; |
125 | 140 | ||
126 | hci_dev_lock(hdev); | 141 | hci_dev_lock(hdev); |
127 | if (conn->state == BT_CONNECTED) | 142 | |
143 | switch (conn->state) { | ||
144 | case BT_CONNECT: | ||
145 | hci_acl_connect_cancel(conn); | ||
146 | break; | ||
147 | case BT_CONNECTED: | ||
128 | hci_acl_disconn(conn, 0x13); | 148 | hci_acl_disconn(conn, 0x13); |
129 | else | 149 | break; |
150 | default: | ||
130 | conn->state = BT_CLOSED; | 151 | conn->state = BT_CLOSED; |
152 | break; | ||
153 | } | ||
154 | |||
131 | hci_dev_unlock(hdev); | 155 | hci_dev_unlock(hdev); |
132 | return; | ||
133 | } | 156 | } |
134 | 157 | ||
135 | static void hci_conn_idle(unsigned long arg) | 158 | static void hci_conn_idle(unsigned long arg) |