Diff between f0962acb9d133ac3295c4dac5205950029903ddf and 15e2f4b74088bf3658326ee2d55d58e1e3e20a57

Changed Files

File Additions Deletions Status
src/adapter.c +16 -1 modified
src/mgmt.c +0 -24 modified
src/mgmt.h +0 -2 modified

Full Patch

diff --git a/src/adapter.c b/src/adapter.c
index 030a64b..40679bf 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -4241,7 +4241,22 @@ int adapter_create_bonding(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
 int adapter_cancel_bonding(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
 							 uint8_t addr_type)
 {
-	return mgmt_cancel_bonding(adapter->dev_id, bdaddr, addr_type);
+	struct mgmt_addr_info cp;
+	char addr[18];
+
+	ba2str(bdaddr, addr);
+	DBG("hci%u bdaddr %s type %u", adapter->dev_id, addr, addr_type);
+
+	memset(&cp, 0, sizeof(cp));
+	bacpy(&cp.bdaddr, bdaddr);
+	cp.type = addr_type;
+
+	if (mgmt_send(adapter->mgmt, MGMT_OP_CANCEL_PAIR_DEVICE,
+				adapter->dev_id, sizeof(cp), &cp,
+				NULL, NULL, NULL) > 0)
+		return 0;
+
+	return -EIO;
 }
 
 static void check_oob_bonding_complete(struct btd_adapter *adapter,
diff --git a/src/mgmt.c b/src/mgmt.c
index c71cea4..4e4dbb1 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -957,27 +957,3 @@ void mgmt_cleanup(void)
 		mgmt_watch = 0;
 	}
 }
-
-int mgmt_cancel_bonding(int index, const bdaddr_t *bdaddr, uint8_t addr_type)
-{
-	char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_addr_info)];
-	struct mgmt_hdr *hdr = (void *) buf;
-	struct mgmt_addr_info *cp = (void *) &buf[sizeof(*hdr)];
-	char addr[18];
-
-	ba2str(bdaddr, addr);
-	DBG("hci%d bdaddr %s type %d", index, addr, addr_type);
-
-	memset(buf, 0, sizeof(buf));
-	hdr->opcode = htobs(MGMT_OP_CANCEL_PAIR_DEVICE);
-	hdr->len = htobs(sizeof(*cp));
-	hdr->index = htobs(index);
-
-	bacpy(&cp->bdaddr, bdaddr);
-	cp->type = addr_type;
-
-	if (write(mgmt_sock, &buf, sizeof(buf)) < 0)
-		return -errno;
-
-	return 0;
-}
diff --git a/src/mgmt.h b/src/mgmt.h
index 86dd842..fe5cd03 100644
--- a/src/mgmt.h
+++ b/src/mgmt.h
@@ -25,8 +25,6 @@
 int mgmt_setup(void);
 void mgmt_cleanup(void);
 
-int mgmt_cancel_bonding(int index, const bdaddr_t *bdaddr, uint8_t addr_type);
-
 int mgmt_pincode_reply(int index, const bdaddr_t *bdaddr, const char *pin,
 								size_t pin_len);
 int mgmt_confirm_reply(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type,