Commit fc7f8a7e authored by Gustavo F. Padovan's avatar Gustavo F. Padovan

Bluetooth: Move ident to struct l2cap_chan

ident is chan property, no need to reside on socket.
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent 820ffdb3
...@@ -279,6 +279,8 @@ struct l2cap_conn_param_update_rsp { ...@@ -279,6 +279,8 @@ struct l2cap_conn_param_update_rsp {
/* ----- L2CAP channels and connections ----- */ /* ----- L2CAP channels and connections ----- */
struct l2cap_chan { struct l2cap_chan {
struct sock *sk; struct sock *sk;
__u8 ident;
struct list_head list; struct list_head list;
}; };
...@@ -363,8 +365,6 @@ struct l2cap_pinfo { ...@@ -363,8 +365,6 @@ struct l2cap_pinfo {
__u16 partial_sdu_len; __u16 partial_sdu_len;
struct sk_buff *sdu; struct sk_buff *sdu;
__u8 ident;
__u8 tx_win; __u8 tx_win;
__u8 max_tx; __u8 max_tx;
__u8 remote_tx_win; __u8 remote_tx_win;
......
...@@ -118,8 +118,7 @@ static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8 ...@@ -118,8 +118,7 @@ static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8
struct l2cap_chan *c; struct l2cap_chan *c;
list_for_each_entry(c, &conn->chan_l, list) { list_for_each_entry(c, &conn->chan_l, list) {
struct sock *s = c->sk; if (c->ident == ident)
if (l2cap_pi(s)->ident == ident)
return c; return c;
} }
return NULL; return NULL;
...@@ -410,8 +409,9 @@ static inline int __l2cap_no_conn_pending(struct sock *sk) ...@@ -410,8 +409,9 @@ static inline int __l2cap_no_conn_pending(struct sock *sk)
return !(l2cap_pi(sk)->conf_state & L2CAP_CONF_CONNECT_PEND); return !(l2cap_pi(sk)->conf_state & L2CAP_CONF_CONNECT_PEND);
} }
static void l2cap_do_start(struct sock *sk) static void l2cap_do_start(struct l2cap_chan *chan)
{ {
struct sock *sk = chan->sk;
struct l2cap_conn *conn = l2cap_pi(sk)->conn; struct l2cap_conn *conn = l2cap_pi(sk)->conn;
if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) { if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) {
...@@ -423,11 +423,11 @@ static void l2cap_do_start(struct sock *sk) ...@@ -423,11 +423,11 @@ static void l2cap_do_start(struct sock *sk)
req.scid = cpu_to_le16(l2cap_pi(sk)->scid); req.scid = cpu_to_le16(l2cap_pi(sk)->scid);
req.psm = l2cap_pi(sk)->psm; req.psm = l2cap_pi(sk)->psm;
l2cap_pi(sk)->ident = l2cap_get_ident(conn); chan->ident = l2cap_get_ident(conn);
l2cap_pi(sk)->conf_state |= L2CAP_CONF_CONNECT_PEND; l2cap_pi(sk)->conf_state |= L2CAP_CONF_CONNECT_PEND;
l2cap_send_cmd(conn, l2cap_pi(sk)->ident, l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ,
L2CAP_CONN_REQ, sizeof(req), &req); sizeof(req), &req);
} }
} else { } else {
struct l2cap_info_req req; struct l2cap_info_req req;
...@@ -529,11 +529,11 @@ static void l2cap_conn_start(struct l2cap_conn *conn) ...@@ -529,11 +529,11 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
req.scid = cpu_to_le16(l2cap_pi(sk)->scid); req.scid = cpu_to_le16(l2cap_pi(sk)->scid);
req.psm = l2cap_pi(sk)->psm; req.psm = l2cap_pi(sk)->psm;
l2cap_pi(sk)->ident = l2cap_get_ident(conn); chan->ident = l2cap_get_ident(conn);
l2cap_pi(sk)->conf_state |= L2CAP_CONF_CONNECT_PEND; l2cap_pi(sk)->conf_state |= L2CAP_CONF_CONNECT_PEND;
l2cap_send_cmd(conn, l2cap_pi(sk)->ident, l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ,
L2CAP_CONN_REQ, sizeof(req), &req); sizeof(req), &req);
} else if (sk->sk_state == BT_CONNECT2) { } else if (sk->sk_state == BT_CONNECT2) {
struct l2cap_conn_rsp rsp; struct l2cap_conn_rsp rsp;
...@@ -558,8 +558,8 @@ static void l2cap_conn_start(struct l2cap_conn *conn) ...@@ -558,8 +558,8 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
rsp.status = cpu_to_le16(L2CAP_CS_AUTHEN_PEND); rsp.status = cpu_to_le16(L2CAP_CS_AUTHEN_PEND);
} }
l2cap_send_cmd(conn, l2cap_pi(sk)->ident, l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP,
L2CAP_CONN_RSP, sizeof(rsp), &rsp); sizeof(rsp), &rsp);
if (l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT || if (l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT ||
rsp.result != L2CAP_CR_SUCCESS) { rsp.result != L2CAP_CR_SUCCESS) {
...@@ -694,7 +694,7 @@ static void l2cap_conn_ready(struct l2cap_conn *conn) ...@@ -694,7 +694,7 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
sk->sk_state = BT_CONNECTED; sk->sk_state = BT_CONNECTED;
sk->sk_state_change(sk); sk->sk_state_change(sk);
} else if (sk->sk_state == BT_CONNECT) } else if (sk->sk_state == BT_CONNECT)
l2cap_do_start(sk); l2cap_do_start(chan);
bh_unlock_sock(sk); bh_unlock_sock(sk);
} }
...@@ -904,7 +904,7 @@ int l2cap_do_connect(struct sock *sk) ...@@ -904,7 +904,7 @@ int l2cap_do_connect(struct sock *sk)
if (l2cap_check_security(sk)) if (l2cap_check_security(sk))
sk->sk_state = BT_CONNECTED; sk->sk_state = BT_CONNECTED;
} else } else
l2cap_do_start(sk); l2cap_do_start(chan);
} }
err = 0; err = 0;
...@@ -2064,7 +2064,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -2064,7 +2064,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
l2cap_sock_set_timer(sk, sk->sk_sndtimeo); l2cap_sock_set_timer(sk, sk->sk_sndtimeo);
l2cap_pi(sk)->ident = cmd->ident; chan->ident = cmd->ident;
if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) { if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) {
if (l2cap_check_security(sk)) { if (l2cap_check_security(sk)) {
...@@ -2157,7 +2157,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -2157,7 +2157,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
switch (result) { switch (result) {
case L2CAP_CR_SUCCESS: case L2CAP_CR_SUCCESS:
sk->sk_state = BT_CONFIG; sk->sk_state = BT_CONFIG;
l2cap_pi(sk)->ident = 0; chan->ident = 0;
l2cap_pi(sk)->dcid = dcid; l2cap_pi(sk)->dcid = dcid;
l2cap_pi(sk)->conf_state &= ~L2CAP_CONF_CONNECT_PEND; l2cap_pi(sk)->conf_state &= ~L2CAP_CONF_CONNECT_PEND;
...@@ -3862,10 +3862,10 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) ...@@ -3862,10 +3862,10 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
req.scid = cpu_to_le16(l2cap_pi(sk)->scid); req.scid = cpu_to_le16(l2cap_pi(sk)->scid);
req.psm = l2cap_pi(sk)->psm; req.psm = l2cap_pi(sk)->psm;
l2cap_pi(sk)->ident = l2cap_get_ident(conn); chan->ident = l2cap_get_ident(conn);
l2cap_pi(sk)->conf_state |= L2CAP_CONF_CONNECT_PEND; l2cap_pi(sk)->conf_state |= L2CAP_CONF_CONNECT_PEND;
l2cap_send_cmd(conn, l2cap_pi(sk)->ident, l2cap_send_cmd(conn, chan->ident,
L2CAP_CONN_REQ, sizeof(req), &req); L2CAP_CONN_REQ, sizeof(req), &req);
} else { } else {
l2cap_sock_clear_timer(sk); l2cap_sock_clear_timer(sk);
...@@ -3888,8 +3888,8 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) ...@@ -3888,8 +3888,8 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid);
rsp.result = cpu_to_le16(result); rsp.result = cpu_to_le16(result);
rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
l2cap_send_cmd(conn, l2cap_pi(sk)->ident, l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP,
L2CAP_CONN_RSP, sizeof(rsp), &rsp); sizeof(rsp), &rsp);
} }
bh_unlock_sock(sk); bh_unlock_sock(sk);
......
...@@ -818,7 +818,7 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms ...@@ -818,7 +818,7 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms
rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid);
rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS); rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS);
rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
l2cap_send_cmd(l2cap_pi(sk)->conn, l2cap_pi(sk)->ident, l2cap_send_cmd(l2cap_pi(sk)->conn, l2cap_pi(sk)->chan->ident,
L2CAP_CONN_RSP, sizeof(rsp), &rsp); L2CAP_CONN_RSP, sizeof(rsp), &rsp);
if (l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT) { if (l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT) {
...@@ -921,7 +921,7 @@ void __l2cap_sock_close(struct sock *sk, int reason) ...@@ -921,7 +921,7 @@ void __l2cap_sock_close(struct sock *sk, int reason)
rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid);
rsp.result = cpu_to_le16(result); rsp.result = cpu_to_le16(result);
rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
l2cap_send_cmd(conn, l2cap_pi(sk)->ident, l2cap_send_cmd(conn, l2cap_pi(sk)->chan->ident,
L2CAP_CONN_RSP, sizeof(rsp), &rsp); L2CAP_CONN_RSP, sizeof(rsp), &rsp);
} }
......
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