YOSHIFUJI Hideaki | 8e87d14 | 2007-02-09 23:24:33 +0900 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | BlueZ - Bluetooth protocol stack for Linux |
| 3 | Copyright (C) 2000-2001 Qualcomm Incorporated |
| 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 |
| 9 | published by the Free Software Foundation; |
| 10 | |
| 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
| 14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY |
YOSHIFUJI Hideaki | 8e87d14 | 2007-02-09 23:24:33 +0900 | [diff] [blame] | 15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
| 16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 19 | |
YOSHIFUJI Hideaki | 8e87d14 | 2007-02-09 23:24:33 +0900 | [diff] [blame] | 20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
| 21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | SOFTWARE IS DISCLAIMED. |
| 23 | */ |
| 24 | |
| 25 | /* Bluetooth SCO sockets. */ |
| 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/module.h> |
Marcel Holtmann | aef7d97 | 2010-03-21 05:27:45 +0100 | [diff] [blame] | 28 | #include <linux/debugfs.h> |
| 29 | #include <linux/seq_file.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | #include <net/bluetooth/bluetooth.h> |
| 32 | #include <net/bluetooth/hci_core.h> |
| 33 | #include <net/bluetooth/sco.h> |
| 34 | |
Rusty Russell | eb93992 | 2011-12-19 14:08:01 +0000 | [diff] [blame] | 35 | static bool disable_esco; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Eric Dumazet | 90ddc4f | 2005-12-22 12:49:22 -0800 | [diff] [blame] | 37 | static const struct proto_ops sco_sock_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | static struct bt_sock_list sco_sk_list = { |
Robert P. J. Day | d5fb296 | 2008-03-28 16:17:38 -0700 | [diff] [blame] | 40 | .lock = __RW_LOCK_UNLOCKED(sco_sk_list.lock) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | static void __sco_chan_add(struct sco_conn *conn, struct sock *sk, struct sock *parent); |
| 44 | static void sco_chan_del(struct sock *sk, int err); |
| 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | static void sco_sock_close(struct sock *sk); |
| 47 | static void sco_sock_kill(struct sock *sk); |
| 48 | |
| 49 | /* ---- SCO timers ---- */ |
| 50 | static void sco_sock_timeout(unsigned long arg) |
| 51 | { |
| 52 | struct sock *sk = (struct sock *) arg; |
| 53 | |
| 54 | BT_DBG("sock %p state %d", sk, sk->sk_state); |
| 55 | |
| 56 | bh_lock_sock(sk); |
| 57 | sk->sk_err = ETIMEDOUT; |
| 58 | sk->sk_state_change(sk); |
| 59 | bh_unlock_sock(sk); |
| 60 | |
| 61 | sco_sock_kill(sk); |
| 62 | sock_put(sk); |
| 63 | } |
| 64 | |
| 65 | static void sco_sock_set_timer(struct sock *sk, long timeout) |
| 66 | { |
| 67 | BT_DBG("sock %p state %d timeout %ld", sk, sk->sk_state, timeout); |
| 68 | sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout); |
| 69 | } |
| 70 | |
| 71 | static void sco_sock_clear_timer(struct sock *sk) |
| 72 | { |
| 73 | BT_DBG("sock %p state %d", sk, sk->sk_state); |
| 74 | sk_stop_timer(sk, &sk->sk_timer); |
| 75 | } |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | /* ---- SCO connections ---- */ |
Lukasz Rymanowski | 519e42b | 2012-04-19 16:12:28 +0200 | [diff] [blame] | 78 | static struct sco_conn *sco_conn_add(struct hci_conn *hcon) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | { |
| 80 | struct hci_dev *hdev = hcon->hdev; |
Marcel Holtmann | 25ea6db | 2006-07-06 15:40:09 +0200 | [diff] [blame] | 81 | struct sco_conn *conn = hcon->sco_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
Lukasz Rymanowski | 519e42b | 2012-04-19 16:12:28 +0200 | [diff] [blame] | 83 | if (conn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | return conn; |
| 85 | |
Marcel Holtmann | 25ea6db | 2006-07-06 15:40:09 +0200 | [diff] [blame] | 86 | conn = kzalloc(sizeof(struct sco_conn), GFP_ATOMIC); |
| 87 | if (!conn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
| 90 | spin_lock_init(&conn->lock); |
| 91 | |
| 92 | hcon->sco_data = conn; |
| 93 | conn->hcon = hcon; |
| 94 | |
| 95 | conn->src = &hdev->bdaddr; |
| 96 | conn->dst = &hcon->dst; |
| 97 | |
| 98 | if (hdev->sco_mtu > 0) |
| 99 | conn->mtu = hdev->sco_mtu; |
| 100 | else |
| 101 | conn->mtu = 60; |
| 102 | |
| 103 | BT_DBG("hcon %p conn %p", hcon, conn); |
Marcel Holtmann | 25ea6db | 2006-07-06 15:40:09 +0200 | [diff] [blame] | 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | return conn; |
| 106 | } |
| 107 | |
Gustavo Padovan | 6039aa7 | 2012-05-23 04:04:18 -0300 | [diff] [blame] | 108 | static struct sock *sco_chan_get(struct sco_conn *conn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | { |
| 110 | struct sock *sk = NULL; |
| 111 | sco_conn_lock(conn); |
| 112 | sk = conn->sk; |
| 113 | sco_conn_unlock(conn); |
| 114 | return sk; |
| 115 | } |
| 116 | |
| 117 | static int sco_conn_del(struct hci_conn *hcon, int err) |
| 118 | { |
Andrei Emeltchenko | 735cbc4 | 2010-12-01 16:58:22 +0200 | [diff] [blame] | 119 | struct sco_conn *conn = hcon->sco_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | struct sock *sk; |
| 121 | |
Andrei Emeltchenko | 735cbc4 | 2010-12-01 16:58:22 +0200 | [diff] [blame] | 122 | if (!conn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | return 0; |
| 124 | |
| 125 | BT_DBG("hcon %p conn %p, err %d", hcon, conn, err); |
| 126 | |
| 127 | /* Kill socket */ |
Andrei Emeltchenko | 735cbc4 | 2010-12-01 16:58:22 +0200 | [diff] [blame] | 128 | sk = sco_chan_get(conn); |
| 129 | if (sk) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | bh_lock_sock(sk); |
| 131 | sco_sock_clear_timer(sk); |
| 132 | sco_chan_del(sk, err); |
| 133 | bh_unlock_sock(sk); |
Gustavo Padovan | 269c484 | 2012-06-15 02:30:20 -0300 | [diff] [blame] | 134 | |
| 135 | sco_conn_lock(conn); |
| 136 | conn->sk = NULL; |
| 137 | sco_pi(sk)->conn = NULL; |
| 138 | sco_conn_unlock(conn); |
| 139 | |
| 140 | if (conn->hcon) |
| 141 | hci_conn_put(conn->hcon); |
| 142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | sco_sock_kill(sk); |
| 144 | } |
| 145 | |
| 146 | hcon->sco_data = NULL; |
| 147 | kfree(conn); |
| 148 | return 0; |
| 149 | } |
| 150 | |
Gustavo Padovan | 6039aa7 | 2012-05-23 04:04:18 -0300 | [diff] [blame] | 151 | static int sco_chan_add(struct sco_conn *conn, struct sock *sk, |
| 152 | struct sock *parent) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | { |
| 154 | int err = 0; |
| 155 | |
| 156 | sco_conn_lock(conn); |
Gustavo F. Padovan | b9dbdbc | 2010-05-01 16:15:35 -0300 | [diff] [blame] | 157 | if (conn->sk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | err = -EBUSY; |
Gustavo F. Padovan | b9dbdbc | 2010-05-01 16:15:35 -0300 | [diff] [blame] | 159 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | __sco_chan_add(conn, sk, parent); |
Gustavo F. Padovan | b9dbdbc | 2010-05-01 16:15:35 -0300 | [diff] [blame] | 161 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | sco_conn_unlock(conn); |
| 163 | return err; |
| 164 | } |
| 165 | |
| 166 | static int sco_connect(struct sock *sk) |
| 167 | { |
| 168 | bdaddr_t *src = &bt_sk(sk)->src; |
| 169 | bdaddr_t *dst = &bt_sk(sk)->dst; |
| 170 | struct sco_conn *conn; |
| 171 | struct hci_conn *hcon; |
| 172 | struct hci_dev *hdev; |
Marcel Holtmann | b6a0dc8 | 2007-10-20 14:55:10 +0200 | [diff] [blame] | 173 | int err, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
Andrei Emeltchenko | 6ed93dc | 2012-09-25 12:49:43 +0300 | [diff] [blame] | 175 | BT_DBG("%pMR -> %pMR", src, dst); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
Andrei Emeltchenko | 735cbc4 | 2010-12-01 16:58:22 +0200 | [diff] [blame] | 177 | hdev = hci_get_route(dst, src); |
| 178 | if (!hdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | return -EHOSTUNREACH; |
| 180 | |
Gustavo F. Padovan | 09fd0de | 2011-06-17 13:03:21 -0300 | [diff] [blame] | 181 | hci_dev_lock(hdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Marcel Holtmann | 7cb127d | 2008-07-14 20:13:53 +0200 | [diff] [blame] | 183 | if (lmp_esco_capable(hdev) && !disable_esco) |
| 184 | type = ESCO_LINK; |
| 185 | else |
| 186 | type = SCO_LINK; |
Marcel Holtmann | b6a0dc8 | 2007-10-20 14:55:10 +0200 | [diff] [blame] | 187 | |
Andre Guedes | b12f62c | 2012-04-24 21:02:54 -0300 | [diff] [blame] | 188 | hcon = hci_connect(hdev, type, dst, BDADDR_BREDR, BT_SECURITY_LOW, |
| 189 | HCI_AT_NO_BONDING); |
Ville Tervo | 30e7627 | 2011-02-22 16:10:53 -0300 | [diff] [blame] | 190 | if (IS_ERR(hcon)) { |
| 191 | err = PTR_ERR(hcon); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | goto done; |
Ville Tervo | 30e7627 | 2011-02-22 16:10:53 -0300 | [diff] [blame] | 193 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
Lukasz Rymanowski | 519e42b | 2012-04-19 16:12:28 +0200 | [diff] [blame] | 195 | conn = sco_conn_add(hcon); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | if (!conn) { |
| 197 | hci_conn_put(hcon); |
Ville Tervo | 30e7627 | 2011-02-22 16:10:53 -0300 | [diff] [blame] | 198 | err = -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | goto done; |
| 200 | } |
| 201 | |
| 202 | /* Update source addr of the socket */ |
| 203 | bacpy(src, conn->src); |
| 204 | |
| 205 | err = sco_chan_add(conn, sk, NULL); |
| 206 | if (err) |
| 207 | goto done; |
| 208 | |
| 209 | if (hcon->state == BT_CONNECTED) { |
| 210 | sco_sock_clear_timer(sk); |
| 211 | sk->sk_state = BT_CONNECTED; |
| 212 | } else { |
| 213 | sk->sk_state = BT_CONNECT; |
| 214 | sco_sock_set_timer(sk, sk->sk_sndtimeo); |
| 215 | } |
Marcel Holtmann | b6a0dc8 | 2007-10-20 14:55:10 +0200 | [diff] [blame] | 216 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | done: |
Gustavo F. Padovan | 09fd0de | 2011-06-17 13:03:21 -0300 | [diff] [blame] | 218 | hci_dev_unlock(hdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | hci_dev_put(hdev); |
| 220 | return err; |
| 221 | } |
| 222 | |
Gustavo Padovan | 6039aa7 | 2012-05-23 04:04:18 -0300 | [diff] [blame] | 223 | static int sco_send_frame(struct sock *sk, struct msghdr *msg, int len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | { |
| 225 | struct sco_conn *conn = sco_pi(sk)->conn; |
| 226 | struct sk_buff *skb; |
Mikel Astiz | 088ce08 | 2012-04-11 08:48:48 +0200 | [diff] [blame] | 227 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | /* Check outgoing MTU */ |
| 230 | if (len > conn->mtu) |
| 231 | return -EINVAL; |
| 232 | |
| 233 | BT_DBG("sk %p len %d", sk, len); |
| 234 | |
Mikel Astiz | 088ce08 | 2012-04-11 08:48:48 +0200 | [diff] [blame] | 235 | skb = bt_skb_send_alloc(sk, len, msg->msg_flags & MSG_DONTWAIT, &err); |
Gustavo F. Padovan | b9dbdbc | 2010-05-01 16:15:35 -0300 | [diff] [blame] | 236 | if (!skb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | return err; |
| 238 | |
Mikel Astiz | 088ce08 | 2012-04-11 08:48:48 +0200 | [diff] [blame] | 239 | if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) { |
Gustavo F. Padovan | b9dbdbc | 2010-05-01 16:15:35 -0300 | [diff] [blame] | 240 | kfree_skb(skb); |
| 241 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | } |
| 243 | |
Gustavo F. Padovan | 0d861d8 | 2010-05-01 16:15:35 -0300 | [diff] [blame] | 244 | hci_send_sco(conn->hcon, skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | |
Mikel Astiz | 088ce08 | 2012-04-11 08:48:48 +0200 | [diff] [blame] | 246 | return len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Gustavo Padovan | 6039aa7 | 2012-05-23 04:04:18 -0300 | [diff] [blame] | 249 | static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | { |
| 251 | struct sock *sk = sco_chan_get(conn); |
| 252 | |
| 253 | if (!sk) |
| 254 | goto drop; |
| 255 | |
| 256 | BT_DBG("sk %p len %d", sk, skb->len); |
| 257 | |
| 258 | if (sk->sk_state != BT_CONNECTED) |
| 259 | goto drop; |
| 260 | |
| 261 | if (!sock_queue_rcv_skb(sk, skb)) |
| 262 | return; |
| 263 | |
| 264 | drop: |
| 265 | kfree_skb(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | /* -------- Socket interface ---------- */ |
Marcel Holtmann | fb33405 | 2012-04-19 14:37:58 +0200 | [diff] [blame] | 269 | static struct sock *__sco_get_sock_listen_by_addr(bdaddr_t *ba) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | struct hlist_node *node; |
Marcel Holtmann | fb33405 | 2012-04-19 14:37:58 +0200 | [diff] [blame] | 272 | struct sock *sk; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | |
Marcel Holtmann | fb33405 | 2012-04-19 14:37:58 +0200 | [diff] [blame] | 274 | sk_for_each(sk, node, &sco_sk_list.head) { |
| 275 | if (sk->sk_state != BT_LISTEN) |
| 276 | continue; |
| 277 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | if (!bacmp(&bt_sk(sk)->src, ba)) |
Marcel Holtmann | fb33405 | 2012-04-19 14:37:58 +0200 | [diff] [blame] | 279 | return sk; |
| 280 | } |
| 281 | |
| 282 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | /* Find socket listening on source bdaddr. |
| 286 | * Returns closest match. |
| 287 | */ |
| 288 | static struct sock *sco_get_sock_listen(bdaddr_t *src) |
| 289 | { |
| 290 | struct sock *sk = NULL, *sk1 = NULL; |
| 291 | struct hlist_node *node; |
| 292 | |
| 293 | read_lock(&sco_sk_list.lock); |
| 294 | |
| 295 | sk_for_each(sk, node, &sco_sk_list.head) { |
| 296 | if (sk->sk_state != BT_LISTEN) |
| 297 | continue; |
| 298 | |
| 299 | /* Exact match. */ |
| 300 | if (!bacmp(&bt_sk(sk)->src, src)) |
| 301 | break; |
| 302 | |
| 303 | /* Closest match */ |
| 304 | if (!bacmp(&bt_sk(sk)->src, BDADDR_ANY)) |
| 305 | sk1 = sk; |
| 306 | } |
| 307 | |
| 308 | read_unlock(&sco_sk_list.lock); |
| 309 | |
| 310 | return node ? sk : sk1; |
| 311 | } |
| 312 | |
| 313 | static void sco_sock_destruct(struct sock *sk) |
| 314 | { |
| 315 | BT_DBG("sk %p", sk); |
| 316 | |
| 317 | skb_queue_purge(&sk->sk_receive_queue); |
| 318 | skb_queue_purge(&sk->sk_write_queue); |
| 319 | } |
| 320 | |
| 321 | static void sco_sock_cleanup_listen(struct sock *parent) |
| 322 | { |
| 323 | struct sock *sk; |
| 324 | |
| 325 | BT_DBG("parent %p", parent); |
| 326 | |
| 327 | /* Close not yet accepted channels */ |
| 328 | while ((sk = bt_accept_dequeue(parent, NULL))) { |
| 329 | sco_sock_close(sk); |
| 330 | sco_sock_kill(sk); |
| 331 | } |
| 332 | |
| 333 | parent->sk_state = BT_CLOSED; |
| 334 | sock_set_flag(parent, SOCK_ZAPPED); |
| 335 | } |
| 336 | |
| 337 | /* Kill socket (only if zapped and orphan) |
| 338 | * Must be called on unlocked socket. |
| 339 | */ |
| 340 | static void sco_sock_kill(struct sock *sk) |
| 341 | { |
| 342 | if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket) |
| 343 | return; |
| 344 | |
| 345 | BT_DBG("sk %p state %d", sk, sk->sk_state); |
| 346 | |
| 347 | /* Kill poor orphan */ |
| 348 | bt_sock_unlink(&sco_sk_list, sk); |
| 349 | sock_set_flag(sk, SOCK_DEAD); |
| 350 | sock_put(sk); |
| 351 | } |
| 352 | |
Marcel Holtmann | fd0b3ff | 2009-06-16 00:01:49 +0200 | [diff] [blame] | 353 | static void __sco_sock_close(struct sock *sk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | { |
Marcel Holtmann | fd0b3ff | 2009-06-16 00:01:49 +0200 | [diff] [blame] | 355 | BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | |
| 357 | switch (sk->sk_state) { |
| 358 | case BT_LISTEN: |
| 359 | sco_sock_cleanup_listen(sk); |
| 360 | break; |
| 361 | |
| 362 | case BT_CONNECTED: |
| 363 | case BT_CONFIG: |
Luiz Augusto von Dentz | 4a77708 | 2011-05-12 11:13:15 +0300 | [diff] [blame] | 364 | if (sco_pi(sk)->conn) { |
| 365 | sk->sk_state = BT_DISCONN; |
| 366 | sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT); |
| 367 | hci_conn_put(sco_pi(sk)->conn->hcon); |
| 368 | sco_pi(sk)->conn->hcon = NULL; |
| 369 | } else |
| 370 | sco_chan_del(sk, ECONNRESET); |
| 371 | break; |
| 372 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | case BT_CONNECT: |
| 374 | case BT_DISCONN: |
| 375 | sco_chan_del(sk, ECONNRESET); |
| 376 | break; |
| 377 | |
| 378 | default: |
| 379 | sock_set_flag(sk, SOCK_ZAPPED); |
| 380 | break; |
Stephen Hemminger | 3ff50b7 | 2007-04-20 17:09:22 -0700 | [diff] [blame] | 381 | } |
Marcel Holtmann | fd0b3ff | 2009-06-16 00:01:49 +0200 | [diff] [blame] | 382 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | |
Marcel Holtmann | fd0b3ff | 2009-06-16 00:01:49 +0200 | [diff] [blame] | 384 | /* Must be called on unlocked socket. */ |
| 385 | static void sco_sock_close(struct sock *sk) |
| 386 | { |
| 387 | sco_sock_clear_timer(sk); |
| 388 | lock_sock(sk); |
| 389 | __sco_sock_close(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | release_sock(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | sco_sock_kill(sk); |
| 392 | } |
| 393 | |
| 394 | static void sco_sock_init(struct sock *sk, struct sock *parent) |
| 395 | { |
| 396 | BT_DBG("sk %p", sk); |
| 397 | |
Paul Moore | 6230c9b | 2011-10-07 09:40:59 +0000 | [diff] [blame] | 398 | if (parent) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | sk->sk_type = parent->sk_type; |
Frédéric Dalleau | 20714bfe | 2012-11-21 10:51:12 +0100 | [diff] [blame^] | 400 | bt_sk(sk)->flags = bt_sk(parent)->flags; |
Paul Moore | 6230c9b | 2011-10-07 09:40:59 +0000 | [diff] [blame] | 401 | security_sk_clone(parent, sk); |
| 402 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | static struct proto sco_proto = { |
| 406 | .name = "SCO", |
| 407 | .owner = THIS_MODULE, |
| 408 | .obj_size = sizeof(struct sco_pinfo) |
| 409 | }; |
| 410 | |
Eric W. Biederman | 1b8d7ae | 2007-10-08 23:24:22 -0700 | [diff] [blame] | 411 | static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | { |
| 413 | struct sock *sk; |
| 414 | |
Pavel Emelyanov | 6257ff2 | 2007-11-01 00:39:31 -0700 | [diff] [blame] | 415 | sk = sk_alloc(net, PF_BLUETOOTH, prio, &sco_proto); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | if (!sk) |
| 417 | return NULL; |
| 418 | |
| 419 | sock_init_data(sock, sk); |
| 420 | INIT_LIST_HEAD(&bt_sk(sk)->accept_q); |
| 421 | |
| 422 | sk->sk_destruct = sco_sock_destruct; |
| 423 | sk->sk_sndtimeo = SCO_CONN_TIMEOUT; |
| 424 | |
| 425 | sock_reset_flag(sk, SOCK_ZAPPED); |
| 426 | |
| 427 | sk->sk_protocol = proto; |
| 428 | sk->sk_state = BT_OPEN; |
| 429 | |
Pavel Emelyanov | b24b8a2 | 2008-01-23 21:20:07 -0800 | [diff] [blame] | 430 | setup_timer(&sk->sk_timer, sco_sock_timeout, (unsigned long)sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | |
| 432 | bt_sock_link(&sco_sk_list, sk); |
| 433 | return sk; |
| 434 | } |
| 435 | |
Eric Paris | 3f378b6 | 2009-11-05 22:18:14 -0800 | [diff] [blame] | 436 | static int sco_sock_create(struct net *net, struct socket *sock, int protocol, |
| 437 | int kern) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | { |
| 439 | struct sock *sk; |
| 440 | |
| 441 | BT_DBG("sock %p", sock); |
| 442 | |
| 443 | sock->state = SS_UNCONNECTED; |
| 444 | |
| 445 | if (sock->type != SOCK_SEQPACKET) |
| 446 | return -ESOCKTNOSUPPORT; |
| 447 | |
| 448 | sock->ops = &sco_sock_ops; |
| 449 | |
Eric W. Biederman | 1b8d7ae | 2007-10-08 23:24:22 -0700 | [diff] [blame] | 450 | sk = sco_sock_alloc(net, sock, protocol, GFP_ATOMIC); |
Marcel Holtmann | 74da626 | 2006-10-15 17:31:14 +0200 | [diff] [blame] | 451 | if (!sk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | return -ENOMEM; |
| 453 | |
| 454 | sco_sock_init(sk, NULL); |
| 455 | return 0; |
| 456 | } |
| 457 | |
| 458 | static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len) |
| 459 | { |
| 460 | struct sockaddr_sco *sa = (struct sockaddr_sco *) addr; |
| 461 | struct sock *sk = sock->sk; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | int err = 0; |
| 463 | |
Andrei Emeltchenko | 6ed93dc | 2012-09-25 12:49:43 +0300 | [diff] [blame] | 464 | BT_DBG("sk %p %pMR", sk, &sa->sco_bdaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | |
| 466 | if (!addr || addr->sa_family != AF_BLUETOOTH) |
| 467 | return -EINVAL; |
| 468 | |
| 469 | lock_sock(sk); |
| 470 | |
| 471 | if (sk->sk_state != BT_OPEN) { |
| 472 | err = -EBADFD; |
| 473 | goto done; |
| 474 | } |
| 475 | |
Marcel Holtmann | 8ed21f7 | 2012-04-19 13:43:53 +0200 | [diff] [blame] | 476 | if (sk->sk_type != SOCK_SEQPACKET) { |
| 477 | err = -EINVAL; |
| 478 | goto done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | } |
| 480 | |
Marcel Holtmann | 8ed21f7 | 2012-04-19 13:43:53 +0200 | [diff] [blame] | 481 | bacpy(&bt_sk(sk)->src, &sa->sco_bdaddr); |
| 482 | |
| 483 | sk->sk_state = BT_BOUND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | |
| 485 | done: |
| 486 | release_sock(sk); |
| 487 | return err; |
| 488 | } |
| 489 | |
| 490 | static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int flags) |
| 491 | { |
| 492 | struct sockaddr_sco *sa = (struct sockaddr_sco *) addr; |
| 493 | struct sock *sk = sock->sk; |
| 494 | int err = 0; |
| 495 | |
| 496 | |
| 497 | BT_DBG("sk %p", sk); |
| 498 | |
Changli Gao | 6503d96 | 2010-03-31 22:58:26 +0000 | [diff] [blame] | 499 | if (alen < sizeof(struct sockaddr_sco) || |
| 500 | addr->sa_family != AF_BLUETOOTH) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | return -EINVAL; |
| 502 | |
| 503 | if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) |
| 504 | return -EBADFD; |
| 505 | |
| 506 | if (sk->sk_type != SOCK_SEQPACKET) |
| 507 | return -EINVAL; |
| 508 | |
| 509 | lock_sock(sk); |
| 510 | |
| 511 | /* Set destination address and psm */ |
| 512 | bacpy(&bt_sk(sk)->dst, &sa->sco_bdaddr); |
| 513 | |
Andrei Emeltchenko | 735cbc4 | 2010-12-01 16:58:22 +0200 | [diff] [blame] | 514 | err = sco_connect(sk); |
| 515 | if (err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | goto done; |
| 517 | |
YOSHIFUJI Hideaki | 8e87d14 | 2007-02-09 23:24:33 +0900 | [diff] [blame] | 518 | err = bt_sock_wait_state(sk, BT_CONNECTED, |
Gustavo Padovan | be7c2b9 | 2012-05-17 00:36:21 -0300 | [diff] [blame] | 519 | sock_sndtimeo(sk, flags & O_NONBLOCK)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | |
| 521 | done: |
| 522 | release_sock(sk); |
| 523 | return err; |
| 524 | } |
| 525 | |
| 526 | static int sco_sock_listen(struct socket *sock, int backlog) |
| 527 | { |
| 528 | struct sock *sk = sock->sk; |
Marcel Holtmann | fb33405 | 2012-04-19 14:37:58 +0200 | [diff] [blame] | 529 | bdaddr_t *src = &bt_sk(sk)->src; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | int err = 0; |
| 531 | |
| 532 | BT_DBG("sk %p backlog %d", sk, backlog); |
| 533 | |
| 534 | lock_sock(sk); |
| 535 | |
Marcel Holtmann | 7d5d775 | 2012-04-19 13:43:52 +0200 | [diff] [blame] | 536 | if (sk->sk_state != BT_BOUND) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | err = -EBADFD; |
| 538 | goto done; |
| 539 | } |
| 540 | |
Marcel Holtmann | 7d5d775 | 2012-04-19 13:43:52 +0200 | [diff] [blame] | 541 | if (sk->sk_type != SOCK_SEQPACKET) { |
| 542 | err = -EINVAL; |
| 543 | goto done; |
| 544 | } |
| 545 | |
Marcel Holtmann | fb33405 | 2012-04-19 14:37:58 +0200 | [diff] [blame] | 546 | write_lock(&sco_sk_list.lock); |
| 547 | |
| 548 | if (__sco_get_sock_listen_by_addr(src)) { |
| 549 | err = -EADDRINUSE; |
| 550 | goto unlock; |
| 551 | } |
| 552 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | sk->sk_max_ack_backlog = backlog; |
| 554 | sk->sk_ack_backlog = 0; |
Marcel Holtmann | fb33405 | 2012-04-19 14:37:58 +0200 | [diff] [blame] | 555 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | sk->sk_state = BT_LISTEN; |
| 557 | |
Marcel Holtmann | fb33405 | 2012-04-19 14:37:58 +0200 | [diff] [blame] | 558 | unlock: |
| 559 | write_unlock(&sco_sk_list.lock); |
| 560 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | done: |
| 562 | release_sock(sk); |
| 563 | return err; |
| 564 | } |
| 565 | |
| 566 | static int sco_sock_accept(struct socket *sock, struct socket *newsock, int flags) |
| 567 | { |
| 568 | DECLARE_WAITQUEUE(wait, current); |
| 569 | struct sock *sk = sock->sk, *ch; |
| 570 | long timeo; |
| 571 | int err = 0; |
| 572 | |
| 573 | lock_sock(sk); |
| 574 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); |
| 576 | |
| 577 | BT_DBG("sk %p timeo %ld", sk, timeo); |
| 578 | |
| 579 | /* Wait for an incoming connection. (wake-one). */ |
Eric Dumazet | aa39514 | 2010-04-20 13:03:51 +0000 | [diff] [blame] | 580 | add_wait_queue_exclusive(sk_sleep(sk), &wait); |
Peter Hurley | 552b0d3 | 2011-07-24 00:11:01 -0400 | [diff] [blame] | 581 | while (1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | |
| 584 | if (sk->sk_state != BT_LISTEN) { |
| 585 | err = -EBADFD; |
| 586 | break; |
| 587 | } |
| 588 | |
Peter Hurley | 552b0d3 | 2011-07-24 00:11:01 -0400 | [diff] [blame] | 589 | ch = bt_accept_dequeue(sk, newsock); |
| 590 | if (ch) |
| 591 | break; |
| 592 | |
| 593 | if (!timeo) { |
| 594 | err = -EAGAIN; |
| 595 | break; |
| 596 | } |
| 597 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | if (signal_pending(current)) { |
| 599 | err = sock_intr_errno(timeo); |
| 600 | break; |
| 601 | } |
Peter Hurley | 552b0d3 | 2011-07-24 00:11:01 -0400 | [diff] [blame] | 602 | |
| 603 | release_sock(sk); |
| 604 | timeo = schedule_timeout(timeo); |
| 605 | lock_sock(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | } |
Peter Hurley | 552b0d3 | 2011-07-24 00:11:01 -0400 | [diff] [blame] | 607 | __set_current_state(TASK_RUNNING); |
Eric Dumazet | aa39514 | 2010-04-20 13:03:51 +0000 | [diff] [blame] | 608 | remove_wait_queue(sk_sleep(sk), &wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | |
| 610 | if (err) |
| 611 | goto done; |
| 612 | |
| 613 | newsock->state = SS_CONNECTED; |
| 614 | |
| 615 | BT_DBG("new socket %p", ch); |
| 616 | |
| 617 | done: |
| 618 | release_sock(sk); |
| 619 | return err; |
| 620 | } |
| 621 | |
| 622 | static int sco_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer) |
| 623 | { |
| 624 | struct sockaddr_sco *sa = (struct sockaddr_sco *) addr; |
| 625 | struct sock *sk = sock->sk; |
| 626 | |
| 627 | BT_DBG("sock %p, sk %p", sock, sk); |
| 628 | |
| 629 | addr->sa_family = AF_BLUETOOTH; |
| 630 | *len = sizeof(struct sockaddr_sco); |
| 631 | |
| 632 | if (peer) |
| 633 | bacpy(&sa->sco_bdaddr, &bt_sk(sk)->dst); |
| 634 | else |
| 635 | bacpy(&sa->sco_bdaddr, &bt_sk(sk)->src); |
| 636 | |
| 637 | return 0; |
| 638 | } |
| 639 | |
YOSHIFUJI Hideaki | 8e87d14 | 2007-02-09 23:24:33 +0900 | [diff] [blame] | 640 | static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | struct msghdr *msg, size_t len) |
| 642 | { |
| 643 | struct sock *sk = sock->sk; |
Gustavo F. Padovan | b9dbdbc | 2010-05-01 16:15:35 -0300 | [diff] [blame] | 644 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | |
| 646 | BT_DBG("sock %p, sk %p", sock, sk); |
| 647 | |
Benjamin LaHaise | c1cbe4b | 2005-12-13 23:22:19 -0800 | [diff] [blame] | 648 | err = sock_error(sk); |
| 649 | if (err) |
| 650 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | |
| 652 | if (msg->msg_flags & MSG_OOB) |
| 653 | return -EOPNOTSUPP; |
| 654 | |
| 655 | lock_sock(sk); |
| 656 | |
| 657 | if (sk->sk_state == BT_CONNECTED) |
| 658 | err = sco_send_frame(sk, msg, len); |
| 659 | else |
| 660 | err = -ENOTCONN; |
| 661 | |
| 662 | release_sock(sk); |
| 663 | return err; |
| 664 | } |
| 665 | |
Frédéric Dalleau | 20714bfe | 2012-11-21 10:51:12 +0100 | [diff] [blame^] | 666 | static int sco_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
| 667 | struct msghdr *msg, size_t len, int flags) |
| 668 | { |
| 669 | struct sock *sk = sock->sk; |
| 670 | struct sco_pinfo *pi = sco_pi(sk); |
| 671 | |
| 672 | lock_sock(sk); |
| 673 | |
| 674 | if (sk->sk_state == BT_CONNECT2 && |
| 675 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) { |
| 676 | hci_conn_accept(pi->conn->hcon, 0); |
| 677 | sk->sk_state = BT_CONFIG; |
| 678 | |
| 679 | release_sock(sk); |
| 680 | return 0; |
| 681 | } |
| 682 | |
| 683 | release_sock(sk); |
| 684 | |
| 685 | return bt_sock_recvmsg(iocb, sock, msg, len, flags); |
| 686 | } |
| 687 | |
David S. Miller | b705884 | 2009-09-30 16:12:20 -0700 | [diff] [blame] | 688 | static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | { |
| 690 | struct sock *sk = sock->sk; |
| 691 | int err = 0; |
Frédéric Dalleau | b96e9c6 | 2012-11-21 10:51:11 +0100 | [diff] [blame] | 692 | u32 opt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | |
| 694 | BT_DBG("sk %p", sk); |
| 695 | |
| 696 | lock_sock(sk); |
| 697 | |
| 698 | switch (optname) { |
Frédéric Dalleau | b96e9c6 | 2012-11-21 10:51:11 +0100 | [diff] [blame] | 699 | |
| 700 | case BT_DEFER_SETUP: |
| 701 | if (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) { |
| 702 | err = -EINVAL; |
| 703 | break; |
| 704 | } |
| 705 | |
| 706 | if (get_user(opt, (u32 __user *) optval)) { |
| 707 | err = -EFAULT; |
| 708 | break; |
| 709 | } |
| 710 | |
| 711 | if (opt) |
| 712 | set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags); |
| 713 | else |
| 714 | clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags); |
| 715 | break; |
| 716 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | default: |
| 718 | err = -ENOPROTOOPT; |
| 719 | break; |
| 720 | } |
| 721 | |
| 722 | release_sock(sk); |
| 723 | return err; |
| 724 | } |
| 725 | |
Marcel Holtmann | d58daf4 | 2009-01-15 21:52:14 +0100 | [diff] [blame] | 726 | static int sco_sock_getsockopt_old(struct socket *sock, int optname, char __user *optval, int __user *optlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | { |
| 728 | struct sock *sk = sock->sk; |
| 729 | struct sco_options opts; |
| 730 | struct sco_conninfo cinfo; |
YOSHIFUJI Hideaki | 8e87d14 | 2007-02-09 23:24:33 +0900 | [diff] [blame] | 731 | int len, err = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | |
| 733 | BT_DBG("sk %p", sk); |
| 734 | |
| 735 | if (get_user(len, optlen)) |
| 736 | return -EFAULT; |
| 737 | |
| 738 | lock_sock(sk); |
| 739 | |
| 740 | switch (optname) { |
| 741 | case SCO_OPTIONS: |
| 742 | if (sk->sk_state != BT_CONNECTED) { |
| 743 | err = -ENOTCONN; |
| 744 | break; |
| 745 | } |
| 746 | |
| 747 | opts.mtu = sco_pi(sk)->conn->mtu; |
| 748 | |
| 749 | BT_DBG("mtu %d", opts.mtu); |
| 750 | |
| 751 | len = min_t(unsigned int, len, sizeof(opts)); |
| 752 | if (copy_to_user(optval, (char *)&opts, len)) |
| 753 | err = -EFAULT; |
| 754 | |
| 755 | break; |
| 756 | |
| 757 | case SCO_CONNINFO: |
| 758 | if (sk->sk_state != BT_CONNECTED) { |
| 759 | err = -ENOTCONN; |
| 760 | break; |
| 761 | } |
| 762 | |
Vasiliy Kulikov | c4c896e | 2011-02-14 13:54:26 +0300 | [diff] [blame] | 763 | memset(&cinfo, 0, sizeof(cinfo)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | cinfo.hci_handle = sco_pi(sk)->conn->hcon->handle; |
| 765 | memcpy(cinfo.dev_class, sco_pi(sk)->conn->hcon->dev_class, 3); |
| 766 | |
| 767 | len = min_t(unsigned int, len, sizeof(cinfo)); |
| 768 | if (copy_to_user(optval, (char *)&cinfo, len)) |
| 769 | err = -EFAULT; |
| 770 | |
| 771 | break; |
| 772 | |
| 773 | default: |
| 774 | err = -ENOPROTOOPT; |
| 775 | break; |
| 776 | } |
| 777 | |
| 778 | release_sock(sk); |
| 779 | return err; |
| 780 | } |
| 781 | |
Marcel Holtmann | d58daf4 | 2009-01-15 21:52:14 +0100 | [diff] [blame] | 782 | static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) |
| 783 | { |
| 784 | struct sock *sk = sock->sk; |
| 785 | int len, err = 0; |
| 786 | |
| 787 | BT_DBG("sk %p", sk); |
| 788 | |
| 789 | if (level == SOL_SCO) |
| 790 | return sco_sock_getsockopt_old(sock, optname, optval, optlen); |
| 791 | |
| 792 | if (get_user(len, optlen)) |
| 793 | return -EFAULT; |
| 794 | |
| 795 | lock_sock(sk); |
| 796 | |
| 797 | switch (optname) { |
Frédéric Dalleau | b96e9c6 | 2012-11-21 10:51:11 +0100 | [diff] [blame] | 798 | |
| 799 | case BT_DEFER_SETUP: |
| 800 | if (sk->sk_state != BT_BOUND && sk->sk_state != BT_LISTEN) { |
| 801 | err = -EINVAL; |
| 802 | break; |
| 803 | } |
| 804 | |
| 805 | if (put_user(test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags), |
| 806 | (u32 __user *) optval)) |
| 807 | err = -EFAULT; |
| 808 | |
| 809 | break; |
| 810 | |
Marcel Holtmann | d58daf4 | 2009-01-15 21:52:14 +0100 | [diff] [blame] | 811 | default: |
| 812 | err = -ENOPROTOOPT; |
| 813 | break; |
| 814 | } |
| 815 | |
| 816 | release_sock(sk); |
| 817 | return err; |
| 818 | } |
| 819 | |
Marcel Holtmann | fd0b3ff | 2009-06-16 00:01:49 +0200 | [diff] [blame] | 820 | static int sco_sock_shutdown(struct socket *sock, int how) |
| 821 | { |
| 822 | struct sock *sk = sock->sk; |
| 823 | int err = 0; |
| 824 | |
| 825 | BT_DBG("sock %p, sk %p", sock, sk); |
| 826 | |
| 827 | if (!sk) |
| 828 | return 0; |
| 829 | |
| 830 | lock_sock(sk); |
| 831 | if (!sk->sk_shutdown) { |
| 832 | sk->sk_shutdown = SHUTDOWN_MASK; |
| 833 | sco_sock_clear_timer(sk); |
| 834 | __sco_sock_close(sk); |
| 835 | |
| 836 | if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) |
| 837 | err = bt_sock_wait_state(sk, BT_CLOSED, |
Gustavo Padovan | be7c2b9 | 2012-05-17 00:36:21 -0300 | [diff] [blame] | 838 | sk->sk_lingertime); |
Marcel Holtmann | fd0b3ff | 2009-06-16 00:01:49 +0200 | [diff] [blame] | 839 | } |
| 840 | release_sock(sk); |
| 841 | return err; |
| 842 | } |
| 843 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | static int sco_sock_release(struct socket *sock) |
| 845 | { |
| 846 | struct sock *sk = sock->sk; |
| 847 | int err = 0; |
| 848 | |
| 849 | BT_DBG("sock %p, sk %p", sock, sk); |
| 850 | |
| 851 | if (!sk) |
| 852 | return 0; |
| 853 | |
| 854 | sco_sock_close(sk); |
| 855 | |
| 856 | if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) { |
| 857 | lock_sock(sk); |
| 858 | err = bt_sock_wait_state(sk, BT_CLOSED, sk->sk_lingertime); |
| 859 | release_sock(sk); |
| 860 | } |
| 861 | |
| 862 | sock_orphan(sk); |
| 863 | sco_sock_kill(sk); |
| 864 | return err; |
| 865 | } |
| 866 | |
| 867 | static void __sco_chan_add(struct sco_conn *conn, struct sock *sk, struct sock *parent) |
| 868 | { |
| 869 | BT_DBG("conn %p", conn); |
| 870 | |
| 871 | sco_pi(sk)->conn = conn; |
| 872 | conn->sk = sk; |
| 873 | |
| 874 | if (parent) |
| 875 | bt_accept_enqueue(parent, sk); |
| 876 | } |
| 877 | |
YOSHIFUJI Hideaki | 8e87d14 | 2007-02-09 23:24:33 +0900 | [diff] [blame] | 878 | /* Delete channel. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | * Must be called on the locked socket. */ |
| 880 | static void sco_chan_del(struct sock *sk, int err) |
| 881 | { |
| 882 | struct sco_conn *conn; |
| 883 | |
| 884 | conn = sco_pi(sk)->conn; |
| 885 | |
| 886 | BT_DBG("sk %p, conn %p, err %d", sk, conn, err); |
| 887 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | sk->sk_state = BT_CLOSED; |
| 889 | sk->sk_err = err; |
| 890 | sk->sk_state_change(sk); |
| 891 | |
| 892 | sock_set_flag(sk, SOCK_ZAPPED); |
| 893 | } |
| 894 | |
| 895 | static void sco_conn_ready(struct sco_conn *conn) |
| 896 | { |
Andrei Emeltchenko | 735cbc4 | 2010-12-01 16:58:22 +0200 | [diff] [blame] | 897 | struct sock *parent; |
| 898 | struct sock *sk = conn->sk; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | |
| 900 | BT_DBG("conn %p", conn); |
| 901 | |
| 902 | sco_conn_lock(conn); |
| 903 | |
Andrei Emeltchenko | 735cbc4 | 2010-12-01 16:58:22 +0200 | [diff] [blame] | 904 | if (sk) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | sco_sock_clear_timer(sk); |
| 906 | bh_lock_sock(sk); |
| 907 | sk->sk_state = BT_CONNECTED; |
| 908 | sk->sk_state_change(sk); |
| 909 | bh_unlock_sock(sk); |
| 910 | } else { |
| 911 | parent = sco_get_sock_listen(conn->src); |
| 912 | if (!parent) |
| 913 | goto done; |
| 914 | |
| 915 | bh_lock_sock(parent); |
| 916 | |
Gustavo F. Padovan | b9dbdbc | 2010-05-01 16:15:35 -0300 | [diff] [blame] | 917 | sk = sco_sock_alloc(sock_net(parent), NULL, |
Gustavo Padovan | be7c2b9 | 2012-05-17 00:36:21 -0300 | [diff] [blame] | 918 | BTPROTO_SCO, GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | if (!sk) { |
| 920 | bh_unlock_sock(parent); |
| 921 | goto done; |
| 922 | } |
| 923 | |
| 924 | sco_sock_init(sk, parent); |
| 925 | |
| 926 | bacpy(&bt_sk(sk)->src, conn->src); |
| 927 | bacpy(&bt_sk(sk)->dst, conn->dst); |
| 928 | |
| 929 | hci_conn_hold(conn->hcon); |
| 930 | __sco_chan_add(conn, sk, parent); |
| 931 | |
Frédéric Dalleau | 20714bfe | 2012-11-21 10:51:12 +0100 | [diff] [blame^] | 932 | if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(parent)->flags)) |
| 933 | sk->sk_state = BT_CONNECT2; |
| 934 | else |
| 935 | sk->sk_state = BT_CONNECTED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | |
| 937 | /* Wake up parent */ |
| 938 | parent->sk_data_ready(parent, 1); |
| 939 | |
| 940 | bh_unlock_sock(parent); |
| 941 | } |
| 942 | |
| 943 | done: |
| 944 | sco_conn_unlock(conn); |
| 945 | } |
| 946 | |
| 947 | /* ----- SCO interface with lower layer (HCI) ----- */ |
Frédéric Dalleau | 20714bfe | 2012-11-21 10:51:12 +0100 | [diff] [blame^] | 948 | int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | { |
Gustavo Padovan | fc5fef6 | 2012-05-23 04:04:19 -0300 | [diff] [blame] | 950 | struct sock *sk; |
Marcel Holtmann | 71aeeaa | 2009-01-15 21:57:02 +0100 | [diff] [blame] | 951 | struct hlist_node *node; |
| 952 | int lm = 0; |
| 953 | |
Andrei Emeltchenko | 6ed93dc | 2012-09-25 12:49:43 +0300 | [diff] [blame] | 954 | BT_DBG("hdev %s, bdaddr %pMR", hdev->name, bdaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | |
Marcel Holtmann | 71aeeaa | 2009-01-15 21:57:02 +0100 | [diff] [blame] | 956 | /* Find listening sockets */ |
| 957 | read_lock(&sco_sk_list.lock); |
| 958 | sk_for_each(sk, node, &sco_sk_list.head) { |
| 959 | if (sk->sk_state != BT_LISTEN) |
| 960 | continue; |
| 961 | |
| 962 | if (!bacmp(&bt_sk(sk)->src, &hdev->bdaddr) || |
Gustavo Padovan | be7c2b9 | 2012-05-17 00:36:21 -0300 | [diff] [blame] | 963 | !bacmp(&bt_sk(sk)->src, BDADDR_ANY)) { |
Marcel Holtmann | 71aeeaa | 2009-01-15 21:57:02 +0100 | [diff] [blame] | 964 | lm |= HCI_LM_ACCEPT; |
Frédéric Dalleau | 20714bfe | 2012-11-21 10:51:12 +0100 | [diff] [blame^] | 965 | |
| 966 | if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) |
| 967 | *flags |= HCI_PROTO_DEFER; |
Marcel Holtmann | 71aeeaa | 2009-01-15 21:57:02 +0100 | [diff] [blame] | 968 | break; |
| 969 | } |
| 970 | } |
| 971 | read_unlock(&sco_sk_list.lock); |
| 972 | |
| 973 | return lm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | } |
| 975 | |
Andrei Emeltchenko | 9e66463 | 2012-07-24 16:06:15 +0300 | [diff] [blame] | 976 | void sco_connect_cfm(struct hci_conn *hcon, __u8 status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | { |
Andrei Emeltchenko | 6ed93dc | 2012-09-25 12:49:43 +0300 | [diff] [blame] | 978 | BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | if (!status) { |
| 980 | struct sco_conn *conn; |
| 981 | |
Lukasz Rymanowski | 519e42b | 2012-04-19 16:12:28 +0200 | [diff] [blame] | 982 | conn = sco_conn_add(hcon); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | if (conn) |
| 984 | sco_conn_ready(conn); |
YOSHIFUJI Hideaki | 8e87d14 | 2007-02-09 23:24:33 +0900 | [diff] [blame] | 985 | } else |
Joe Perches | e175072 | 2011-06-29 18:18:29 -0700 | [diff] [blame] | 986 | sco_conn_del(hcon, bt_to_errno(status)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | } |
| 988 | |
Andrei Emeltchenko | 9e66463 | 2012-07-24 16:06:15 +0300 | [diff] [blame] | 989 | void sco_disconn_cfm(struct hci_conn *hcon, __u8 reason) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | { |
| 991 | BT_DBG("hcon %p reason %d", hcon, reason); |
| 992 | |
Joe Perches | e175072 | 2011-06-29 18:18:29 -0700 | [diff] [blame] | 993 | sco_conn_del(hcon, bt_to_errno(reason)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | } |
| 995 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 996 | int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | { |
| 998 | struct sco_conn *conn = hcon->sco_data; |
| 999 | |
| 1000 | if (!conn) |
| 1001 | goto drop; |
| 1002 | |
| 1003 | BT_DBG("conn %p len %d", conn, skb->len); |
| 1004 | |
| 1005 | if (skb->len) { |
| 1006 | sco_recv_frame(conn, skb); |
| 1007 | return 0; |
| 1008 | } |
| 1009 | |
| 1010 | drop: |
YOSHIFUJI Hideaki | 8e87d14 | 2007-02-09 23:24:33 +0900 | [diff] [blame] | 1011 | kfree_skb(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | return 0; |
| 1013 | } |
| 1014 | |
Marcel Holtmann | aef7d97 | 2010-03-21 05:27:45 +0100 | [diff] [blame] | 1015 | static int sco_debugfs_show(struct seq_file *f, void *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | { |
| 1017 | struct sock *sk; |
| 1018 | struct hlist_node *node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1019 | |
Gustavo F. Padovan | ee65d19 | 2011-12-27 15:28:46 -0200 | [diff] [blame] | 1020 | read_lock(&sco_sk_list.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1021 | |
Marcel Holtmann | be9d122 | 2005-11-08 09:57:38 -0800 | [diff] [blame] | 1022 | sk_for_each(sk, node, &sco_sk_list.head) { |
Andrei Emeltchenko | fcb7333 | 2012-09-25 12:49:44 +0300 | [diff] [blame] | 1023 | seq_printf(f, "%pMR %pMR %d\n", &bt_sk(sk)->src, |
| 1024 | &bt_sk(sk)->dst, sk->sk_state); |
Marcel Holtmann | be9d122 | 2005-11-08 09:57:38 -0800 | [diff] [blame] | 1025 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | |
Gustavo F. Padovan | ee65d19 | 2011-12-27 15:28:46 -0200 | [diff] [blame] | 1027 | read_unlock(&sco_sk_list.lock); |
Marcel Holtmann | be9d122 | 2005-11-08 09:57:38 -0800 | [diff] [blame] | 1028 | |
Marcel Holtmann | aef7d97 | 2010-03-21 05:27:45 +0100 | [diff] [blame] | 1029 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | } |
| 1031 | |
Marcel Holtmann | aef7d97 | 2010-03-21 05:27:45 +0100 | [diff] [blame] | 1032 | static int sco_debugfs_open(struct inode *inode, struct file *file) |
| 1033 | { |
| 1034 | return single_open(file, sco_debugfs_show, inode->i_private); |
| 1035 | } |
| 1036 | |
| 1037 | static const struct file_operations sco_debugfs_fops = { |
| 1038 | .open = sco_debugfs_open, |
| 1039 | .read = seq_read, |
| 1040 | .llseek = seq_lseek, |
| 1041 | .release = single_release, |
| 1042 | }; |
| 1043 | |
| 1044 | static struct dentry *sco_debugfs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | |
Eric Dumazet | 90ddc4f | 2005-12-22 12:49:22 -0800 | [diff] [blame] | 1046 | static const struct proto_ops sco_sock_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | .family = PF_BLUETOOTH, |
| 1048 | .owner = THIS_MODULE, |
| 1049 | .release = sco_sock_release, |
| 1050 | .bind = sco_sock_bind, |
| 1051 | .connect = sco_sock_connect, |
| 1052 | .listen = sco_sock_listen, |
| 1053 | .accept = sco_sock_accept, |
| 1054 | .getname = sco_sock_getname, |
| 1055 | .sendmsg = sco_sock_sendmsg, |
Frédéric Dalleau | 20714bfe | 2012-11-21 10:51:12 +0100 | [diff] [blame^] | 1056 | .recvmsg = sco_sock_recvmsg, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | .poll = bt_sock_poll, |
Marcel Holtmann | 3241ad8 | 2008-07-14 20:13:50 +0200 | [diff] [blame] | 1058 | .ioctl = bt_sock_ioctl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | .mmap = sock_no_mmap, |
| 1060 | .socketpair = sock_no_socketpair, |
Marcel Holtmann | fd0b3ff | 2009-06-16 00:01:49 +0200 | [diff] [blame] | 1061 | .shutdown = sco_sock_shutdown, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | .setsockopt = sco_sock_setsockopt, |
| 1063 | .getsockopt = sco_sock_getsockopt |
| 1064 | }; |
| 1065 | |
Stephen Hemminger | ec1b4cf | 2009-10-05 05:58:39 +0000 | [diff] [blame] | 1066 | static const struct net_proto_family sco_sock_family_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | .family = PF_BLUETOOTH, |
| 1068 | .owner = THIS_MODULE, |
| 1069 | .create = sco_sock_create, |
| 1070 | }; |
| 1071 | |
Gustavo F. Padovan | 6427451 | 2011-02-07 20:08:52 -0200 | [diff] [blame] | 1072 | int __init sco_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | { |
| 1074 | int err; |
| 1075 | |
| 1076 | err = proto_register(&sco_proto, 0); |
| 1077 | if (err < 0) |
| 1078 | return err; |
| 1079 | |
| 1080 | err = bt_sock_register(BTPROTO_SCO, &sco_sock_family_ops); |
| 1081 | if (err < 0) { |
| 1082 | BT_ERR("SCO socket registration failed"); |
| 1083 | goto error; |
| 1084 | } |
| 1085 | |
Masatake YAMATO | de9b921 | 2012-07-26 01:30:12 +0900 | [diff] [blame] | 1086 | err = bt_procfs_init(THIS_MODULE, &init_net, "sco", &sco_sk_list, NULL); |
| 1087 | if (err < 0) { |
| 1088 | BT_ERR("Failed to create SCO proc file"); |
| 1089 | bt_sock_unregister(BTPROTO_SCO); |
| 1090 | goto error; |
| 1091 | } |
| 1092 | |
Marcel Holtmann | aef7d97 | 2010-03-21 05:27:45 +0100 | [diff] [blame] | 1093 | if (bt_debugfs) { |
Gustavo Padovan | be7c2b9 | 2012-05-17 00:36:21 -0300 | [diff] [blame] | 1094 | sco_debugfs = debugfs_create_file("sco", 0444, bt_debugfs, |
| 1095 | NULL, &sco_debugfs_fops); |
Marcel Holtmann | aef7d97 | 2010-03-21 05:27:45 +0100 | [diff] [blame] | 1096 | if (!sco_debugfs) |
| 1097 | BT_ERR("Failed to create SCO debug file"); |
| 1098 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | BT_INFO("SCO socket layer initialized"); |
| 1101 | |
| 1102 | return 0; |
| 1103 | |
| 1104 | error: |
| 1105 | proto_unregister(&sco_proto); |
| 1106 | return err; |
| 1107 | } |
| 1108 | |
Gustavo F. Padovan | 6427451 | 2011-02-07 20:08:52 -0200 | [diff] [blame] | 1109 | void __exit sco_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | { |
Masatake YAMATO | de9b921 | 2012-07-26 01:30:12 +0900 | [diff] [blame] | 1111 | bt_procfs_cleanup(&init_net, "sco"); |
| 1112 | |
Marcel Holtmann | aef7d97 | 2010-03-21 05:27:45 +0100 | [diff] [blame] | 1113 | debugfs_remove(sco_debugfs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | |
| 1115 | if (bt_sock_unregister(BTPROTO_SCO) < 0) |
| 1116 | BT_ERR("SCO socket unregistration failed"); |
| 1117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | proto_unregister(&sco_proto); |
| 1119 | } |
| 1120 | |
Marcel Holtmann | 7cb127d | 2008-07-14 20:13:53 +0200 | [diff] [blame] | 1121 | module_param(disable_esco, bool, 0644); |
| 1122 | MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation"); |