diff --git a/emulator/bthost.c b/emulator/bthost.c
index 5e3592b..20d90c9 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
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;
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)
{
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) {
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));
}
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));
}
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;
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;
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;
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
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
#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
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
+#include <stdbool.h>
#include <glib.h>
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));
}