summaryrefslogtreecommitdiffstats
path: root/src/storage.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-12-04 15:37:16 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-12-04 15:47:40 +0200
commit0f26327986cf2a0aae3b3e30faf3728dfb36f6d5 (patch)
treeef4b65db01dcb462e34864cea60b1f5bd28948e0 /src/storage.c
parent559e6476a17f8bfaff7ad79e0bfc04a87edc044b (diff)
Add read_remote_eir function
Diffstat (limited to 'src/storage.c')
-rw-r--r--src/storage.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/storage.c b/src/storage.c
index a97a9992..5c1a973d 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -372,6 +372,38 @@ int write_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data)
return textfile_put(filename, addr, str);
}
+int read_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data)
+{
+ char filename[PATH_MAX + 1], addr[18], *str;
+ int i;
+
+ create_filename(filename, PATH_MAX, local, "eir");
+
+ ba2str(peer, addr);
+
+ str = textfile_get(filename, addr);
+ if (!str)
+ return -ENOENT;
+
+ if (!data) {
+ free(str);
+ return 0;
+ }
+
+ if (strlen(str) < 480) {
+ free(str);
+ return -EIO;
+ }
+
+ memset(str, 0, sizeof(str));
+ for (i = 0; i < 240; i++)
+ sscanf(str + (i * 2), "%02hhX", &data[i]);
+
+ free(str);
+
+ return 0;
+}
+
int write_l2cap_info(bdaddr_t *local, bdaddr_t *peer,
uint16_t mtu_result, uint16_t mtu,
uint16_t mask_result, uint32_t mask)