[PATCH BlueZ v2 07/12] storage: Store address type in "profiles" file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/adapter.c |    9 +++++++--
 src/device.c  |    5 +++--
 src/storage.c |   11 +++++++----
 src/storage.h |    3 ++-
 4 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index f6095ed..32412a8 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1712,15 +1712,20 @@ static const GDBusSignalTable adapter_signals[] = {
 static void create_stored_device_from_profiles(char *key, char *value,
 						void *user_data)
 {
+	char address[18];
+	uint8_t bdaddr_type;
 	struct btd_adapter *adapter = user_data;
 	GSList *list, *uuids = bt_string2list(value);
 	struct btd_device *device;
 
+	if (sscanf(key, "%17s#%hhu", address, &bdaddr_type) < 2)
+		bdaddr_type = BDADDR_BREDR;
+
 	if (g_slist_find_custom(adapter->devices,
-				key, (GCompareFunc) device_address_cmp))
+				address, (GCompareFunc) device_address_cmp))
 		return;
 
-	device = device_create(connection, adapter, key, BDADDR_BREDR);
+	device = device_create(connection, adapter, address, bdaddr_type);
 	if (!device)
 		return;
 
diff --git a/src/device.c b/src/device.c
index c61cfc9..685db89 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1539,12 +1539,13 @@ static void store_profiles(struct btd_device *device)
 	adapter_get_address(adapter, &src);
 
 	if (!device->uuids) {
-		write_device_profiles(&src, &device->bdaddr, "");
+		write_device_profiles(&src, &device->bdaddr,
+				      device->bdaddr_type, "");
 		return;
 	}
 
 	str = bt_list2string(device->uuids);
-	write_device_profiles(&src, &device->bdaddr, str);
+	write_device_profiles(&src, &device->bdaddr, device->bdaddr_type, str);
 	g_free(str);
 }
 
diff --git a/src/storage.c b/src/storage.c
index 8776cb8..f7a573f 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -807,9 +807,10 @@ gboolean read_trust(const bdaddr_t *local, const char *addr, const char *service
 	return ret;
 }
 
-int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles)
+int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
+							const char *profiles)
 {
-	char filename[PATH_MAX + 1], addr[18];
+	char filename[PATH_MAX + 1], key[20];
 
 	if (!profiles)
 		return -EINVAL;
@@ -818,8 +819,10 @@ int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles)
 
 	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
-	ba2str(dst, addr);
-	return textfile_put(filename, addr, profiles);
+	ba2str(dst, key);
+	sprintf(&key[17], "#%hhu", dst_type);
+
+	return textfile_put(filename, key, profiles);
 }
 
 int delete_entry(bdaddr_t *src, const char *storage, const char *key)
diff --git a/src/storage.h b/src/storage.h
index f56726c..a196f04 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -63,7 +63,8 @@ int read_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key, uint8_t *
 ssize_t read_pin_code(bdaddr_t *local, bdaddr_t *peer, char *pin);
 gboolean read_trust(const bdaddr_t *local, const char *addr, const char *service);
 int write_trust(const char *src, const char *addr, const char *service, gboolean trust);
-int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles);
+int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
+							const char *profiles);
 int delete_entry(bdaddr_t *src, const char *storage, const char *key);
 int store_record(const gchar *src, const gchar *dst, sdp_record_t *rec);
 sdp_record_t *record_from_string(const gchar *str);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux