Diff between 07c33a2dd0149820fa409b570dfc6b05cc932a0a and ea098a5aef730f038a63f4d21401a3e9694ff124

Changed Files

File Additions Deletions Status
plugins/hciops.c +1 -1 modified
plugins/mgmtops.c +21 -5 modified
src/adapter.c +3 -2 modified
src/adapter.h +3 -2 modified
src/device.c +4 -2 modified

Full Patch

diff --git a/plugins/hciops.c b/plugins/hciops.c
index 90106df..c51ddcf 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -3359,7 +3359,7 @@ static int hciops_disconnect(int index, bdaddr_t *bdaddr)
 	return disconnect_addr(index, bdaddr, HCI_OE_USER_ENDED_CONNECTION);
 }
 
-static int hciops_remove_bonding(int index, bdaddr_t *bdaddr)
+static int hciops_remove_bonding(int index, bdaddr_t *bdaddr, addr_type_t type)
 {
 	struct dev_info *dev = &devs[index];
 	delete_stored_link_key_cp cp;
diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index 519e34c..a2df3f7 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -396,7 +396,7 @@ static void mgmt_new_link_key(int sk, uint16_t index, void *buf, size_t len)
 	bonding_complete(info, &ev->key.bdaddr, 0);
 }
 
-static inline addr_type_t mgmt_addr_type(uint8_t mgmt_addr_type)
+static inline addr_type_t addr_type(uint8_t mgmt_addr_type)
 {
 	switch (mgmt_addr_type) {
 	case MGMT_ADDR_BREDR:
@@ -410,6 +410,20 @@ static inline addr_type_t mgmt_addr_type(uint8_t mgmt_addr_type)
 	}
 }
 
+static inline uint8_t mgmt_addr_type(addr_type_t addr_type)
+{
+	switch (addr_type) {
+	case ADDR_TYPE_BREDR:
+		return MGMT_ADDR_BREDR;
+	case ADDR_TYPE_LE_PUBLIC:
+		return MGMT_ADDR_LE_PUBLIC;
+	case ADDR_TYPE_LE_RANDOM:
+		return MGMT_ADDR_LE_RANDOM;
+	default:
+		return MGMT_ADDR_BREDR;
+	}
+}
+
 static void mgmt_device_connected(int sk, uint16_t index, void *buf, size_t len)
 {
 	struct mgmt_ev_device_connected *ev = buf;
@@ -445,8 +459,9 @@ static void mgmt_device_connected(int sk, uint16_t index, void *buf, size_t len)
 		eir_parse(&eir_data, ev->eir, eir_len);
 
 	btd_event_conn_complete(&info->bdaddr, &ev->addr.bdaddr,
-					mgmt_addr_type(ev->addr.type),
-					eir_data.name, eir_data.dev_class);
+						addr_type(ev->addr.type),
+						eir_data.name,
+						eir_data.dev_class);
 
 	eir_data_free(&eir_data);
 }
@@ -1311,7 +1326,7 @@ static void mgmt_device_found(int sk, uint16_t index, void *buf, size_t len)
 					ev->confirm_name, eir_len);
 
 	btd_event_device_found(&info->bdaddr, &ev->addr.bdaddr,
-						mgmt_addr_type(ev->addr.type),
+						addr_type(ev->addr.type),
 						ev->rssi, ev->confirm_name,
 						eir, eir_len);
 }
@@ -1826,7 +1841,7 @@ static int mgmt_disconnect(int index, bdaddr_t *bdaddr)
 	return 0;
 }
 
-static int mgmt_unpair_device(int index, bdaddr_t *bdaddr)
+static int mgmt_unpair_device(int index, bdaddr_t *bdaddr, addr_type_t type)
 {
 	char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_unpair_device)];
 	struct mgmt_hdr *hdr = (void *) buf;
@@ -1842,6 +1857,7 @@ static int mgmt_unpair_device(int index, bdaddr_t *bdaddr)
 	hdr->index = htobs(index);
 
 	bacpy(&cp->addr.bdaddr, bdaddr);
+	cp->addr.type = mgmt_addr_type(type);
 	cp->disconnect = 1;
 
 	if (write(mgmt_sock, buf, sizeof(buf)) < 0)
diff --git a/src/adapter.c b/src/adapter.c
index 89f6ca7..e7c71b0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3514,9 +3514,10 @@ int btd_adapter_disconnect_device(struct btd_adapter *adapter, bdaddr_t *bdaddr)
 	return adapter_ops->disconnect(adapter->dev_id, bdaddr);
 }
 
-int btd_adapter_remove_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr)
+int btd_adapter_remove_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr,
+							addr_type_t type)
 {
-	return adapter_ops->remove_bonding(adapter->dev_id, bdaddr);
+	return adapter_ops->remove_bonding(adapter->dev_id, bdaddr, type);
 }
 
 int btd_adapter_pincode_reply(struct btd_adapter *adapter, bdaddr_t *bdaddr,
diff --git a/src/adapter.h b/src/adapter.h
index 7265d8b..f83e412 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -197,7 +197,7 @@ struct btd_adapter_ops {
 	int (*unblock_device) (int index, bdaddr_t *bdaddr);
 	int (*get_conn_list) (int index, GSList **conns);
 	int (*disconnect) (int index, bdaddr_t *bdaddr);
-	int (*remove_bonding) (int index, bdaddr_t *bdaddr);
+	int (*remove_bonding) (int index, bdaddr_t *bdaddr, addr_type_t type);
 	int (*pincode_reply) (int index, bdaddr_t *bdaddr, const char *pin,
 							size_t pin_len);
 	int (*confirm_reply) (int index, bdaddr_t *bdaddr, gboolean success);
@@ -250,7 +250,8 @@ int btd_adapter_unblock_address(struct btd_adapter *adapter, bdaddr_t *bdaddr);
 int btd_adapter_disconnect_device(struct btd_adapter *adapter,
 							bdaddr_t *bdaddr);
 
-int btd_adapter_remove_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr);
+int btd_adapter_remove_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr,
+							addr_type_t type);
 
 int btd_adapter_pincode_reply(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 					const char *pin, size_t pin_len);
diff --git a/src/device.c b/src/device.c
index ac2a93c..c91e321 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1108,7 +1108,8 @@ static void device_remove_stored(struct btd_device *device)
 		delete_entry(&src, "longtermkeys", addr);
 		device_set_bonded(device, FALSE);
 		device->paired = FALSE;
-		btd_adapter_remove_bonding(device->adapter, &device->bdaddr);
+		btd_adapter_remove_bonding(device->adapter, &device->bdaddr,
+								device->type);
 	}
 	delete_entry(&src, "profiles", addr);
 	delete_entry(&src, "trusts", addr);
@@ -2244,7 +2245,8 @@ void device_set_paired(struct btd_device *device, gboolean value)
 		return;
 
 	if (!value)
-		btd_adapter_remove_bonding(device->adapter, &device->bdaddr);
+		btd_adapter_remove_bonding(device->adapter, &device->bdaddr,
+								device->type);
 
 	device->paired = value;