From 74b43ba833c425c1b37357c57403b9b929661117 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 10 Nov 2011 14:17:24 +0200 Subject: [PATCH] mgmt: Add status parameter to disconnect response --- doc/mgmt-api.txt | 1 + lib/mgmt.h | 1 + mgmt/main.c | 9 +++++++-- plugins/mgmtops.c | 6 ++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 66df98880..7dfae60ed 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -202,6 +202,7 @@ Disconnect Command Controller Index: Command Parameters: Address (6 Octets) Return Parameters: Address (6 Octets) + Status (6 Octets) Get Connections Command diff --git a/lib/mgmt.h b/lib/mgmt.h index 10a4bd64a..9eb6d2d02 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -140,6 +140,7 @@ struct mgmt_cp_disconnect { } __packed; struct mgmt_rp_disconnect { bdaddr_t bdaddr; + uint8_t status; } __packed; #define MGMT_ADDR_BREDR 0x00 diff --git a/mgmt/main.c b/mgmt/main.c index 3e0302837..ee1b88f42 100644 --- a/mgmt/main.c +++ b/mgmt/main.c @@ -807,6 +807,11 @@ static void disconnect_rsp(int mgmt_sk, uint16_t op, uint16_t id, struct mgmt_rp_disconnect *rp = rsp; char addr[18]; + if (status != 0) { + fprintf(stderr, "Disconnect failed with status %u\n", status); + exit(EXIT_FAILURE); + } + if (len != sizeof(*rp)) { fprintf(stderr, "Invalid disconnect response length (%u)\n", len); @@ -815,12 +820,12 @@ static void disconnect_rsp(int mgmt_sk, uint16_t op, uint16_t id, ba2str(&rp->bdaddr, addr); - if (status == 0) { + if (rp->status == 0) { printf("%s disconnected\n", addr); exit(EXIT_SUCCESS); } else { fprintf(stderr, "Disconnecting %s failed with status %u\n", - addr, status); + addr, rp->status); exit(EXIT_FAILURE); } } diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c index 9ba7ccb8b..160bbd43c 100644 --- a/plugins/mgmtops.c +++ b/plugins/mgmtops.c @@ -978,6 +978,12 @@ static void disconnect_complete(int sk, uint16_t index, void *buf, size_t len) ba2str(&rp->bdaddr, addr); + if (rp->status != 0) { + error("Disconnecting %s failed with status %u", + addr, rp->status); + return; + } + DBG("hci%d %s disconnected", index, addr); if (index > max_index) { -- 2.47.3