summaryrefslogtreecommitdiff
path: root/src/storage.c
diff options
context:
space:
mode:
authorPaulo Alcantara <paulo.alcantara@openbossa.org>2012-05-26 21:40:49 -0300
committerJohan Hedberg <johan.hedberg@intel.com>2012-05-27 22:30:12 +0300
commit8d43820c8066484421c831665c8687f801b619a7 (patch)
tree03b4cf8c0b8daeea3ffd2d53ac8d7eb1ffd5c4b2 /src/storage.c
parent19accda228b85db0e59201e3df24884e483687b7 (diff)
storage: Store address type in "longtermkeys" file
Addressing types can be either BR/EDR, BLE public or BLE random so the entries in the "longtermkeys" file did not contain enough information to distinguish which addressing type it's supposed to be. Entries will now contain both address number and address type as a single key in every entry in the file.
Diffstat (limited to 'src/storage.c')
-rw-r--r--src/storage.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/storage.c b/src/storage.c
index 3cde9c11..f8e96792 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -1362,9 +1362,10 @@ void delete_device_ccc(bdaddr_t *local, bdaddr_t *peer)
delete_by_pattern(filename, addr);
}
-int write_longtermkeys(bdaddr_t *local, bdaddr_t *peer, const char *key)
+int write_longtermkeys(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
+ const char *key)
{
- char filename[PATH_MAX + 1], addr[18];
+ char filename[PATH_MAX + 1], addr[20];
if (!key)
return -EINVAL;
@@ -1374,18 +1375,21 @@ int write_longtermkeys(bdaddr_t *local, bdaddr_t *peer, const char *key)
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
ba2str(peer, addr);
+ sprintf(&addr[17], "#%hhu", bdaddr_type);
+
return textfile_put(filename, addr, key);
}
-gboolean has_longtermkeys(bdaddr_t *local, bdaddr_t *peer)
+gboolean has_longtermkeys(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type)
{
- char filename[PATH_MAX + 1], addr[18], *str;
+ char filename[PATH_MAX + 1], key[20], *str;
create_filename(filename, PATH_MAX, local, "longtermkeys");
- ba2str(peer, addr);
+ ba2str(peer, key);
+ sprintf(&key[17], "#%hhu", bdaddr_type);
- str = textfile_caseget(filename, addr);
+ str = textfile_caseget(filename, key);
if (str) {
free(str);
return TRUE;