Commit eea96364 authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg

Bluetooth: Store SCO address information in its own socket structure

The address information of SCO sockets should be stored in its own
socket structure. Trying to generalize them is not helpful since
different transports have different address types.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 041987cf
...@@ -69,6 +69,8 @@ struct sco_conn { ...@@ -69,6 +69,8 @@ struct sco_conn {
struct sco_pinfo { struct sco_pinfo {
struct bt_sock bt; struct bt_sock bt;
bdaddr_t src;
bdaddr_t dst;
__u32 flags; __u32 flags;
__u16 setting; __u16 setting;
struct sco_conn *conn; struct sco_conn *conn;
......
...@@ -158,9 +158,9 @@ static int sco_connect(struct sock *sk) ...@@ -158,9 +158,9 @@ static int sco_connect(struct sock *sk)
struct hci_dev *hdev; struct hci_dev *hdev;
int err, type; int err, type;
BT_DBG("%pMR -> %pMR", &bt_sk(sk)->src, &bt_sk(sk)->dst); BT_DBG("%pMR -> %pMR", &sco_pi(sk)->src, &sco_pi(sk)->dst);
hdev = hci_get_route(&bt_sk(sk)->dst, &bt_sk(sk)->src); hdev = hci_get_route(&sco_pi(sk)->dst, &sco_pi(sk)->src);
if (!hdev) if (!hdev)
return -EHOSTUNREACH; return -EHOSTUNREACH;
...@@ -177,7 +177,7 @@ static int sco_connect(struct sock *sk) ...@@ -177,7 +177,7 @@ static int sco_connect(struct sock *sk)
goto done; goto done;
} }
hcon = hci_connect_sco(hdev, type, &bt_sk(sk)->dst, hcon = hci_connect_sco(hdev, type, &sco_pi(sk)->dst,
sco_pi(sk)->setting); sco_pi(sk)->setting);
if (IS_ERR(hcon)) { if (IS_ERR(hcon)) {
err = PTR_ERR(hcon); err = PTR_ERR(hcon);
...@@ -192,7 +192,7 @@ static int sco_connect(struct sock *sk) ...@@ -192,7 +192,7 @@ static int sco_connect(struct sock *sk)
} }
/* Update source addr of the socket */ /* Update source addr of the socket */
bacpy(&bt_sk(sk)->src, &hcon->src); bacpy(&sco_pi(sk)->src, &hcon->src);
err = sco_chan_add(conn, sk, NULL); err = sco_chan_add(conn, sk, NULL);
if (err) if (err)
...@@ -266,7 +266,7 @@ static struct sock *__sco_get_sock_listen_by_addr(bdaddr_t *ba) ...@@ -266,7 +266,7 @@ static struct sock *__sco_get_sock_listen_by_addr(bdaddr_t *ba)
if (sk->sk_state != BT_LISTEN) if (sk->sk_state != BT_LISTEN)
continue; continue;
if (!bacmp(&bt_sk(sk)->src, ba)) if (!bacmp(&sco_pi(sk)->src, ba))
return sk; return sk;
} }
...@@ -287,11 +287,11 @@ static struct sock *sco_get_sock_listen(bdaddr_t *src) ...@@ -287,11 +287,11 @@ static struct sock *sco_get_sock_listen(bdaddr_t *src)
continue; continue;
/* Exact match. */ /* Exact match. */
if (!bacmp(&bt_sk(sk)->src, src)) if (!bacmp(&sco_pi(sk)->src, src))
break; break;
/* Closest match */ /* Closest match */
if (!bacmp(&bt_sk(sk)->src, BDADDR_ANY)) if (!bacmp(&sco_pi(sk)->src, BDADDR_ANY))
sk1 = sk; sk1 = sk;
} }
...@@ -471,7 +471,7 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le ...@@ -471,7 +471,7 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
goto done; goto done;
} }
bacpy(&bt_sk(sk)->src, &sa->sco_bdaddr); bacpy(&sco_pi(sk)->src, &sa->sco_bdaddr);
sk->sk_state = BT_BOUND; sk->sk_state = BT_BOUND;
...@@ -501,7 +501,7 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen ...@@ -501,7 +501,7 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
lock_sock(sk); lock_sock(sk);
/* Set destination address and psm */ /* Set destination address and psm */
bacpy(&bt_sk(sk)->dst, &sa->sco_bdaddr); bacpy(&sco_pi(sk)->dst, &sa->sco_bdaddr);
err = sco_connect(sk); err = sco_connect(sk);
if (err) if (err)
...@@ -518,7 +518,7 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen ...@@ -518,7 +518,7 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
static int sco_sock_listen(struct socket *sock, int backlog) static int sco_sock_listen(struct socket *sock, int backlog)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
bdaddr_t *src = &bt_sk(sk)->src; bdaddr_t *src = &sco_pi(sk)->src;
int err = 0; int err = 0;
BT_DBG("sk %p backlog %d", sk, backlog); BT_DBG("sk %p backlog %d", sk, backlog);
...@@ -622,9 +622,9 @@ static int sco_sock_getname(struct socket *sock, struct sockaddr *addr, int *len ...@@ -622,9 +622,9 @@ static int sco_sock_getname(struct socket *sock, struct sockaddr *addr, int *len
*len = sizeof(struct sockaddr_sco); *len = sizeof(struct sockaddr_sco);
if (peer) if (peer)
bacpy(&sa->sco_bdaddr, &bt_sk(sk)->dst); bacpy(&sa->sco_bdaddr, &sco_pi(sk)->dst);
else else
bacpy(&sa->sco_bdaddr, &bt_sk(sk)->src); bacpy(&sa->sco_bdaddr, &sco_pi(sk)->src);
return 0; return 0;
} }
...@@ -1013,8 +1013,8 @@ static void sco_conn_ready(struct sco_conn *conn) ...@@ -1013,8 +1013,8 @@ static void sco_conn_ready(struct sco_conn *conn)
sco_sock_init(sk, parent); sco_sock_init(sk, parent);
bacpy(&bt_sk(sk)->src, &conn->hcon->src); bacpy(&sco_pi(sk)->src, &conn->hcon->src);
bacpy(&bt_sk(sk)->dst, &conn->hcon->dst); bacpy(&sco_pi(sk)->dst, &conn->hcon->dst);
hci_conn_hold(conn->hcon); hci_conn_hold(conn->hcon);
__sco_chan_add(conn, sk, parent); __sco_chan_add(conn, sk, parent);
...@@ -1047,8 +1047,8 @@ int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags) ...@@ -1047,8 +1047,8 @@ int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
if (sk->sk_state != BT_LISTEN) if (sk->sk_state != BT_LISTEN)
continue; continue;
if (!bacmp(&bt_sk(sk)->src, &hdev->bdaddr) || if (!bacmp(&sco_pi(sk)->src, &hdev->bdaddr) ||
!bacmp(&bt_sk(sk)->src, BDADDR_ANY)) { !bacmp(&sco_pi(sk)->src, BDADDR_ANY)) {
lm |= HCI_LM_ACCEPT; lm |= HCI_LM_ACCEPT;
if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags))
...@@ -1107,8 +1107,8 @@ static int sco_debugfs_show(struct seq_file *f, void *p) ...@@ -1107,8 +1107,8 @@ static int sco_debugfs_show(struct seq_file *f, void *p)
read_lock(&sco_sk_list.lock); read_lock(&sco_sk_list.lock);
sk_for_each(sk, &sco_sk_list.head) { sk_for_each(sk, &sco_sk_list.head) {
seq_printf(f, "%pMR %pMR %d\n", &bt_sk(sk)->src, seq_printf(f, "%pMR %pMR %d\n", &sco_pi(sk)->src,
&bt_sk(sk)->dst, sk->sk_state); &sco_pi(sk)->dst, sk->sk_state);
} }
read_unlock(&sco_sk_list.lock); read_unlock(&sco_sk_list.lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment