Diff between 97d492f2393ba7b599c5597dd9a4b1b46ddc9e5b and 391dbdefa0dfe3e8cddcd280019cb39b5aa0b24e

Changed Files

File Additions Deletions Status
emulator/bthost.c +22 -9 modified
emulator/bthost.h +2 -2 modified
src/shared/hciemu.c +1 -0 modified
tools/l2cap-tester.c +2 -1 modified

Full Patch

diff --git a/emulator/bthost.c b/emulator/bthost.c
index 5e3592b..20d90c9 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -257,8 +257,9 @@ static void send_acl(struct bthost *bthost, uint16_t handle, uint16_t cid,
 	free(pkt_data);
 }
 
-uint8_t bthost_l2cap_cmd(struct bthost *bthost, uint16_t handle, uint8_t code,
-				uint8_t ident, const void *data, uint16_t len)
+static uint8_t l2cap_sig_send(struct bthost *bthost, uint16_t handle,
+					uint8_t code, uint8_t ident,
+					const void *data, uint16_t len)
 {
 	static uint8_t next_ident = 1;
 	struct bt_l2cap_hdr_sig *hdr;
@@ -292,6 +293,18 @@ uint8_t bthost_l2cap_cmd(struct bthost *bthost, uint16_t handle, uint8_t code,
 	return ident;
 }
 
+bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t req,
+					const void *data, uint16_t len)
+{
+	uint8_t ident;
+
+	ident = l2cap_sig_send(bthost, handle, req, 0, data, len);
+	if (!ident)
+		return false;
+
+	return true;
+}
+
 static void send_command(struct bthost *bthost, uint16_t opcode,
 						const void *data, uint8_t len)
 {
@@ -567,7 +580,7 @@ static bool l2cap_conn_req(struct bthost *bthost, uint16_t handle,
 	else
 		rsp.result = cpu_to_le16(0x0002); /* PSM Not Supported */
 
-	bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CONN_RSP, ident, &rsp,
+	l2cap_sig_send(bthost, handle, BT_L2CAP_PDU_CONN_RSP, ident, &rsp,
 								sizeof(rsp));
 
 	if (!rsp.result) {
@@ -579,7 +592,7 @@ static bool l2cap_conn_req(struct bthost *bthost, uint16_t handle,
 		memset(&conf_req, 0, sizeof(conf_req));
 		conf_req.dcid = rsp.dcid;
 
-		bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CONFIG_REQ, 0,
+		l2cap_sig_send(bthost, handle, BT_L2CAP_PDU_CONFIG_REQ, 0,
 						&conf_req, sizeof(conf_req));
 	}
 
@@ -603,7 +616,7 @@ static bool l2cap_conn_rsp(struct bthost *bthost, uint16_t handle,
 		memset(&req, 0, sizeof(req));
 		req.dcid = rsp->dcid;
 
-		bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CONFIG_REQ, 0,
+		l2cap_sig_send(bthost, handle, BT_L2CAP_PDU_CONFIG_REQ, 0,
 							&req, sizeof(req));
 	}
 
@@ -631,7 +644,7 @@ static bool l2cap_config_req(struct bthost *bthost, uint16_t handle,
 	rsp.scid  = cpu_to_le16(l2conn->dcid);
 	rsp.flags = req->flags;
 
-	bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CONFIG_RSP, ident, &rsp,
+	l2cap_sig_send(bthost, handle, BT_L2CAP_PDU_CONFIG_RSP, ident, &rsp,
 								sizeof(rsp));
 
 	return true;
@@ -661,7 +674,7 @@ static bool l2cap_disconn_req(struct bthost *bthost, uint16_t handle,
 	rsp.dcid = req->dcid;
 	rsp.scid = req->scid;
 
-	bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_DISCONN_RSP, ident, &rsp,
+	l2cap_sig_send(bthost, handle, BT_L2CAP_PDU_DISCONN_RSP, ident, &rsp,
 								sizeof(rsp));
 
 	return true;
@@ -679,7 +692,7 @@ static bool l2cap_info_req(struct bthost *bthost, uint16_t handle,
 	rsp.type = req->type;
 	rsp.result = cpu_to_le16(0x0001); /* Not Supported */
 
-	bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_INFO_RSP, ident, &rsp,
+	l2cap_sig_send(bthost, handle, BT_L2CAP_PDU_INFO_RSP, ident, &rsp,
 								sizeof(rsp));
 
 	return true;
@@ -742,7 +755,7 @@ static void l2cap_sig(struct bthost *bthost, uint16_t handle, const void *data,
 
 reject:
 	memset(&rej, 0, sizeof(rej));
-	bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CMD_REJECT, 0,
+	l2cap_sig_send(bthost, handle, BT_L2CAP_PDU_CMD_REJECT, 0,
 							&rej, sizeof(rej));
 }
 
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 777dfb4..609da80 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -51,8 +51,8 @@ void bthost_set_connect_cb(struct bthost *bthost, bthost_new_conn_cb cb,
 
 void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr);
 
-uint8_t bthost_l2cap_cmd(struct bthost *bthost, uint16_t handle, uint8_t code,
-				uint8_t ident, const void *data, uint16_t len);
+bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t req,
+					const void *data, uint16_t len);
 
 void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan);
 
diff --git a/src/shared/hciemu.c b/src/shared/hciemu.c
index f9a7d1d..a0b347c 100644
--- a/src/shared/hciemu.c
+++ b/src/shared/hciemu.c
@@ -30,6 +30,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdbool.h>
 #include <sys/socket.h>
 
 #include <glib.h>
diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index 5405691..f6426a7 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
+#include <stdbool.h>
 
 #include <glib.h>
 
@@ -479,7 +480,7 @@ static void client_new_conn(uint16_t handle, void *user_data)
 	req.scid = htobs(0x0041);
 
 	bthost = hciemu_client_get_host(data->hciemu);
-	bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CONN_REQ, 0,
+	bthost_l2cap_req(bthost, handle, BT_L2CAP_PDU_CONN_REQ,
 							&req, sizeof(req));
 }