diff --git a/lib/mgmt.h b/lib/mgmt.h
index d9e8d47..4d2ed21 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
} __packed;
struct mgmt_rp_disconnect {
struct mgmt_addr_info addr;
- uint8_t status;
} __packed;
#define MGMT_OP_GET_CONNECTIONS 0x0015
} __packed;
struct mgmt_rp_pair_device {
struct mgmt_addr_info addr;
- uint8_t status;
} __packed;
#define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A
} __packed;
struct mgmt_rp_unpair_device {
struct mgmt_addr_info addr;
- uint8_t status;
} __packed;
#define MGMT_OP_USER_CONFIRM_REPLY 0x001C
} __packed;
struct mgmt_rp_user_confirm_reply {
struct mgmt_addr_info addr;
- uint8_t status;
} __packed;
#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D
} __packed;
struct mgmt_rp_user_passkey_reply {
struct mgmt_addr_info addr;
- uint8_t status;
} __packed;
#define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F
} __packed;
struct mgmt_rp_confirm_name {
struct mgmt_addr_info addr;
- uint8_t status;
} __packed;
#define MGMT_OP_BLOCK_DEVICE 0x0026
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {
uint16_t opcode;
+ uint8_t status;
uint8_t data[0];
} __packed;
diff --git a/mgmt/main.c b/mgmt/main.c
index c3a51c3..72791cf 100644
--- a/mgmt/main.c
+++ b/mgmt/main.c
printf("%s complete, opcode 0x%04x len %u\n", mgmt_opstr(op),
op, len);
- mgmt_check_pending(mgmt_sk, op, index, 0, ev->data, len);
+ mgmt_check_pending(mgmt_sk, op, index, ev->status, ev->data, len);
return 0;
}
struct mgmt_rp_confirm_name *rp = rsp;
char addr[18];
- if (status != 0) {
+ if (len == 0 && status != 0) {
fprintf(stderr,
"hci%u confirm_name failed with status 0x%02x (%s)\n",
id, status, mgmt_errstr(status));
ba2str(&rp->addr.bdaddr, addr);
- if (rp->status != 0)
+ if (status != 0)
fprintf(stderr,
"hci%u confirm_name for %s failed: 0x%02x (%s)\n",
- id, addr, rp->status, mgmt_errstr(status));
+ id, addr, status, mgmt_errstr(status));
else
printf("hci%u confirm_name succeeded for %s\n", id, addr);
}
struct mgmt_rp_disconnect *rp = rsp;
char addr[18];
- if (status != 0) {
+ if (len == 0 && status != 0) {
fprintf(stderr, "Disconnect failed with status 0x%02x (%s)\n",
status, mgmt_errstr(status));
exit(EXIT_FAILURE);
ba2str(&rp->addr.bdaddr, addr);
- if (rp->status == 0) {
+ if (status == 0) {
printf("%s disconnected\n", addr);
exit(EXIT_SUCCESS);
} else {
fprintf(stderr,
"Disconnecting %s failed with status 0x%02x (%s)\n",
- addr, rp->status, mgmt_errstr(rp->status));
+ addr, status, mgmt_errstr(status));
exit(EXIT_FAILURE);
}
}
struct mgmt_rp_pair_device *rp = rsp;
char addr[18];
- if (status != 0) {
+ if (len == 0 && status != 0) {
fprintf(stderr, "Pairing failed with status 0x%02x (%s)\n",
status, mgmt_errstr(status));
exit(EXIT_FAILURE);
ba2str(&rp->addr.bdaddr, addr);
- if (rp->status != 0) {
+ if (status != 0) {
fprintf(stderr,
"Pairing with %s (%s) failed. status 0x%02x (%s)\n",
- addr, typestr(rp->addr.type), rp->status,
- mgmt_errstr(rp->status));
+ addr, typestr(rp->addr.type), status,
+ mgmt_errstr(status));
exit(EXIT_FAILURE);
}
struct mgmt_rp_unpair_device *rp = rsp;
char addr[18];
- if (status != 0) {
+ if (len == 0 && status != 0) {
fprintf(stderr, "Unpair device failed. status 0x%02x (%s)\n",
status, mgmt_errstr(status));
exit(EXIT_FAILURE);
ba2str(&rp->addr.bdaddr, addr);
- if (rp->status != 0) {
+ if (status != 0) {
fprintf(stderr,
"Unpairing %s failed. status 0x%02x (%s)\n",
- addr, rp->status, mgmt_errstr(rp->status));
+ addr, status, mgmt_errstr(status));
exit(EXIT_FAILURE);
}
diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index 020c277..716b4ed 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
btd_adapter_unref(adapter);
}
-static void disconnect_complete(int sk, uint16_t index, void *buf, size_t len)
+static void disconnect_complete(int sk, uint16_t index, uint8_t status,
+ void *buf, size_t len)
{
struct mgmt_rp_disconnect *rp = buf;
struct controller_info *info;
ba2str(&rp->addr.bdaddr, addr);
- if (rp->status != 0) {
- error("Disconnecting %s failed with status %u",
- addr, rp->status);
+ if (status != 0) {
+ error("Disconnecting %s failed with status %u", addr, status);
return;
}
bonding_complete(info, &rp->addr.bdaddr, HCI_CONNECTION_TERMINATED);
}
-static void pair_device_complete(int sk, uint16_t index, void *buf, size_t len)
+static void pair_device_complete(int sk, uint16_t index, uint8_t status,
+ void *buf, size_t len)
{
struct mgmt_rp_pair_device *rp = buf;
struct controller_info *info;
ba2str(&rp->addr.bdaddr, addr);
- DBG("hci%d %s pairing complete status %u", index, addr, rp->status);
+ DBG("hci%d %s pairing complete status %u", index, addr, status);
if (index > max_index) {
error("Unexpected index %u in pair_device complete", index);
info = &controllers[index];
- bonding_complete(info, &rp->addr.bdaddr, rp->status);
+ bonding_complete(info, &rp->addr.bdaddr, status);
}
static void get_connections_complete(int sk, uint16_t index, void *buf,
break;
case MGMT_OP_DISCONNECT:
DBG("disconnect complete");
- disconnect_complete(sk, index, ev->data, len);
+ disconnect_complete(sk, index, ev->status, ev->data, len);
break;
case MGMT_OP_GET_CONNECTIONS:
get_connections_complete(sk, index, ev->data, len);
DBG("set_io_capability complete");
break;
case MGMT_OP_PAIR_DEVICE:
- pair_device_complete(sk, index, ev->data, len);
+ pair_device_complete(sk, index, ev->status, ev->data, len);
break;
case MGMT_OP_USER_CONFIRM_REPLY:
DBG("user_confirm_reply complete");