Commit cb75e1ff authored by Maksim Krasnyanskiy's avatar Maksim Krasnyanskiy

[Bluetooth] L2CAP config req/rsp fixes.

We have to set continuation flag in config rsp if it was set in req.
parent 5a73a1cf
...@@ -231,9 +231,9 @@ struct l2cap_pinfo { ...@@ -231,9 +231,9 @@ struct l2cap_pinfo {
struct sock *prev_c; struct sock *prev_c;
}; };
#define CONF_REQ_SENT 0x01 #define L2CAP_CONF_REQ_SENT 0x01
#define CONF_INPUT_DONE 0x02 #define L2CAP_CONF_INPUT_DONE 0x02
#define CONF_OUTPUT_DONE 0x04 #define L2CAP_CONF_OUTPUT_DONE 0x04
void l2cap_load(void); void l2cap_load(void);
......
...@@ -1313,15 +1313,18 @@ static int l2cap_build_conf_rsp(struct sock *sk, void *data, int *result) ...@@ -1313,15 +1313,18 @@ static int l2cap_build_conf_rsp(struct sock *sk, void *data, int *result)
{ {
struct l2cap_conf_rsp *rsp = data; struct l2cap_conf_rsp *rsp = data;
void *ptr = rsp->data; void *ptr = rsp->data;
u16 flags = 0;
BT_DBG("sk %p complete %d", sk, result ? 1 : 0); BT_DBG("sk %p complete %d", sk, result ? 1 : 0);
if (result) if (result)
*result = l2cap_conf_output(sk, &ptr); *result = l2cap_conf_output(sk, &ptr);
else
flags = 0x0001;
rsp->scid = __cpu_to_le16(l2cap_pi(sk)->dcid); rsp->scid = __cpu_to_le16(l2cap_pi(sk)->dcid);
rsp->result = __cpu_to_le16(result ? *result : 0); rsp->result = __cpu_to_le16(result ? *result : 0);
rsp->flags = __cpu_to_le16(0); rsp->flags = __cpu_to_le16(flags);
return ptr - data; return ptr - data;
} }
...@@ -1434,7 +1437,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -1434,7 +1437,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
case L2CAP_CR_SUCCESS: case L2CAP_CR_SUCCESS:
sk->state = BT_CONFIG; sk->state = BT_CONFIG;
l2cap_pi(sk)->dcid = dcid; l2cap_pi(sk)->dcid = dcid;
l2cap_pi(sk)->conf_state |= CONF_REQ_SENT; l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;
l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req); l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req);
break; break;
...@@ -1469,7 +1472,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -1469,7 +1472,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
l2cap_parse_conf_req(sk, req->data, cmd->len - sizeof(*req)); l2cap_parse_conf_req(sk, req->data, cmd->len - sizeof(*req));
if (flags & 0x01) { if (flags & 0x0001) {
/* Incomplete config. Send empty response. */ /* Incomplete config. Send empty response. */
l2cap_send_rsp(conn, cmd->ident, L2CAP_CONF_RSP, l2cap_build_conf_rsp(sk, rsp, NULL), rsp); l2cap_send_rsp(conn, cmd->ident, L2CAP_CONF_RSP, l2cap_build_conf_rsp(sk, rsp, NULL), rsp);
goto unlock; goto unlock;
...@@ -1482,12 +1485,12 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -1482,12 +1485,12 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
goto unlock; goto unlock;
/* Output config done */ /* Output config done */
l2cap_pi(sk)->conf_state |= CONF_OUTPUT_DONE; l2cap_pi(sk)->conf_state |= L2CAP_CONF_OUTPUT_DONE;
if (l2cap_pi(sk)->conf_state & CONF_INPUT_DONE) { if (l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE) {
sk->state = BT_CONNECTED; sk->state = BT_CONNECTED;
l2cap_chan_ready(sk); l2cap_chan_ready(sk);
} else if (!(l2cap_pi(sk)->conf_state & CONF_REQ_SENT)) { } else if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT)) {
u8 req[64]; u8 req[64];
l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req); l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req);
} }
...@@ -1532,9 +1535,9 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -1532,9 +1535,9 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
goto done; goto done;
/* Input config done */ /* Input config done */
l2cap_pi(sk)->conf_state |= CONF_INPUT_DONE; l2cap_pi(sk)->conf_state |= L2CAP_CONF_INPUT_DONE;
if (l2cap_pi(sk)->conf_state & CONF_OUTPUT_DONE) { if (l2cap_pi(sk)->conf_state & L2CAP_CONF_OUTPUT_DONE) {
sk->state = BT_CONNECTED; sk->state = BT_CONNECTED;
l2cap_chan_ready(sk); l2cap_chan_ready(sk);
} }
......
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