summaryrefslogtreecommitdiffstats
path: root/hcid/storage.c
diff options
context:
space:
mode:
Diffstat (limited to 'hcid/storage.c')
-rw-r--r--hcid/storage.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/hcid/storage.c b/hcid/storage.c
index 4dbf8a94..595e9a22 100644
--- a/hcid/storage.c
+++ b/hcid/storage.c
@@ -433,7 +433,7 @@ int write_lastused_info(bdaddr_t *local, bdaddr_t *peer, struct tm *tm)
return textfile_put(filename, addr, str);
}
-int write_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key, int type, int length)
+int write_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key, uint8_t type, int length)
{
char filename[PATH_MAX + 1], addr[18], str[38];
int i;
@@ -461,7 +461,7 @@ int write_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key, int type
return textfile_put(filename, addr, str);
}
-int read_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key)
+int read_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key, uint8_t *type)
{
char filename[PATH_MAX + 1], addr[18], tmp[3], *str;
int i;
@@ -479,6 +479,11 @@ int read_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key)
key[i] = (uint8_t) strtol(tmp, NULL, 16);
}
+ if (type) {
+ memcpy(tmp, str + 33, 2);
+ *type = (uint8_t) strtol(tmp, NULL, 10);
+ }
+
free(str);
return 0;