OSDN Git Service

mgmtops: Implement mgmt_cancel_bonding
authorJohan Hedberg <johan.hedberg@intel.com>
Thu, 2 Feb 2012 01:58:11 +0000 (03:58 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 2 Feb 2012 01:58:11 +0000 (03:58 +0200)
plugins/mgmtops.c

index 8f6788e..5c6ff29 100644 (file)
@@ -1979,12 +1979,25 @@ static int mgmt_create_bonding(int index, bdaddr_t *bdaddr, uint8_t addr_type, u
 
 static int mgmt_cancel_bonding(int index, bdaddr_t *bdaddr)
 {
+       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", index, addr);
 
-       return -ENOSYS;
+       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);
+
+       if (write(mgmt_sock, &buf, sizeof(buf)) < 0)
+               return -errno;
+
+       return 0;
 }
 
 static int mgmt_read_local_oob_data(int index)