summaryrefslogtreecommitdiff
path: root/emulator/bthost.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-01-23 13:57:08 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2015-01-23 13:57:08 +0200
commit698742c9dcc295c574a37885c4b5c5a1ca2b048c (patch)
tree95aad0adea4eb5075ac17845ee0b914ff0967ade /emulator/bthost.c
parente9c1c41ac195c885341f7a2e4968a8c62e2ce91a (diff)
downloadbluez-698742c9dcc295c574a37885c4b5c5a1ca2b048c.tar.gz
emulator: Fix L2CAP & RFCOMM state changes
We should only move to do RFCOMM operations once we exist the CONFIG state. This means not doing anything if we get a "pending" response and moving to RFCOMM only once the config req/rsp messages are exchanged. This patch still isn't a "complete" fix in that it only waits for a response to our config request, but it's good enough for now and makes the RFCOMM server tests in rfcomm-tester pass again.
Diffstat (limited to 'emulator/bthost.c')
-rw-r--r--emulator/bthost.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/emulator/bthost.c b/emulator/bthost.c
index 6c616e8f4..5e83e145a 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -1376,6 +1376,7 @@ static bool l2cap_conn_rsp(struct bthost *bthost, struct btconn *conn,
uint8_t ident, const void *data, uint16_t len)
{
const struct bt_l2cap_pdu_conn_rsp *rsp = data;
+ struct bt_l2cap_pdu_config_req req;
struct l2conn *l2conn;
if (len < sizeof(*rsp))
@@ -1387,18 +1388,14 @@ static bool l2cap_conn_rsp(struct bthost *bthost, struct btconn *conn,
else
return false;
- if (le16_to_cpu(rsp->result) == 0x0001) {
- struct bt_l2cap_pdu_config_req req;
+ if (rsp->result)
+ return true;
- memset(&req, 0, sizeof(req));
- req.dcid = rsp->dcid;
+ memset(&req, 0, sizeof(req));
+ req.dcid = rsp->dcid;
- l2cap_sig_send(bthost, conn, BT_L2CAP_PDU_CONFIG_REQ, 0,
+ l2cap_sig_send(bthost, conn, BT_L2CAP_PDU_CONFIG_REQ, 0,
&req, sizeof(req));
- } else if (l2conn->psm == 0x0003 && !rsp->result && !rsp->status &&
- bthost->rfcomm_conn_data) {
- rfcomm_sabm_send(bthost, conn, l2conn, 1, 0);
- }
return true;
}
@@ -1434,10 +1431,18 @@ static bool l2cap_config_rsp(struct bthost *bthost, struct btconn *conn,
uint8_t ident, const void *data, uint16_t len)
{
const struct bt_l2cap_pdu_config_rsp *rsp = data;
+ struct l2conn *l2conn;
if (len < sizeof(*rsp))
return false;
+ l2conn = btconn_find_l2cap_conn_by_scid(conn, rsp->scid);
+ if (!l2conn)
+ return false;
+
+ if (l2conn->psm == 0x0003 && !rsp->result && bthost->rfcomm_conn_data)
+ rfcomm_sabm_send(bthost, conn, l2conn, 1, 0);
+
return true;
}