From 15e2f4b74088bf3658326ee2d55d58e1e3e20a57 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 7 Jan 2013 12:21:33 +0200 Subject: [PATCH] core: Move mgmt cancel pair device command to adapter code --- src/adapter.c | 17 ++++++++++++++++- src/mgmt.c | 24 ------------------------ src/mgmt.h | 2 -- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 030a64b38..40679bf94 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 c71cea4de..4e4dbb1dd 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 86dd8429c..fe5cd03cd 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, -- 2.47.3