[PATCH v3 2/4] android/bluetooth: Store IRK when storing adapter config

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

 



---
 android/bluetooth.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index e9c5be1..410fa9d 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -257,12 +257,21 @@ static void mgmt_debug(const char *str, void *user_data)
 	info("%s%s", prefix, str);
 }
 
+static bool local_irk_is_valid(void)
+{
+	uint8_t empty_tab[16] = {0};
+
+	return memcmp(adapter.irk, empty_tab, 16);
+}
+
 static void store_adapter_config(void)
 {
 	GKeyFile *key_file;
 	gsize length = 0;
 	char addr[18];
 	char *data;
+	char key_str[33];
+	int i;
 
 	key_file = g_key_file_new();
 
@@ -279,6 +288,13 @@ static void store_adapter_config(void)
 	g_key_file_set_integer(key_file, "General", "DiscoverableTimeout",
 						adapter.discoverable_timeout);
 
+	if (local_irk_is_valid()) {
+		for (i = 0; i < 16; i++)
+			sprintf(key_str + (i * 2), "%2.2X", adapter.irk[i]);
+
+		g_key_file_set_string(key_file, "General", "IRK", key_str);
+	}
+
 	data = g_key_file_to_data(key_file, &length, NULL);
 
 	g_file_set_contents(SETTINGS_FILE, data, length, NULL);
-- 
1.8.4

--
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