@@ -313,7 +313,7 @@ static struct hciemu_client *hciemu_client_new(struct hciemu *hciemu,
if (!client)
return NULL;
- client->dev = btdev_create(hciemu->btdev_type, id++);
+ client->dev = btdev_create(hciemu->btdev_type, id);
if (!client->dev) {
free(client);
return NULL;
@@ -122,14 +122,15 @@ struct vhci *vhci_open(uint8_t type)
break;
}
- if (write(fd, &req, sizeof(req)) < 0) {
+ if (write(fd, &req, sizeof(req)) != sizeof(req)) {
close(fd);
return NULL;
}
memset(&rsp, 0, sizeof(rsp));
- if (read(fd, &rsp, sizeof(rsp)) < 0) {
+ if (read(fd, &rsp, sizeof(rsp)) != sizeof(rsp) ||
+ !(rsp.pkt_type == HCI_VENDOR_PKT && rsp.opcode == req.opcode)) {
close(fd);
return NULL;
}