aboutsummaryrefslogtreecommitdiffstats
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
parent559e6476a17f8bfaff7ad79e0bfc04a87edc044b (diff)
downloadbluez-0f26327986cf2a0aae3b3e30faf3728dfb36f6d5.tar.gz
bluez-0f26327986cf2a0aae3b3e30faf3728dfb36f6d5.tar.xz
bluez-0f26327986cf2a0aae3b3e30faf3728dfb36f6d5.zip
Add read_remote_eir function
-rw-r--r--src/storage.c32
-rw-r--r--src/storage.h1
2 files changed, 33 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)
diff --git a/src/storage.h b/src/storage.h
index ce3a22e5..e3b3846e 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -39,6 +39,7 @@ int read_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t *class);
int write_device_name(bdaddr_t *local, bdaddr_t *peer, char *name);
int read_device_name(const char *src, const char *dst, char *name);
int write_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data);
+int read_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data);
int write_l2cap_info(bdaddr_t *local, bdaddr_t *peer,
uint16_t mtu_result, uint16_t mtu,
uint16_t mask_result, uint32_t mask);