summaryrefslogtreecommitdiff
path: root/emulator/smp.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-12-17 15:18:29 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-12-17 16:12:39 -0800
commit07cc7547602149fbec5eee1a353f48663d5e80c4 (patch)
treeb76d3cf300cf6ac882ef1ce197ba14ba845e0cf3 /emulator/smp.c
parent77d6ee6fbd8c7a38347189f061b27180193b3603 (diff)
downloadbluez-07cc7547602149fbec5eee1a353f48663d5e80c4.tar.gz
bthost: Add support for address types other then public
This properly initialize the address type according to the connection address.
Diffstat (limited to 'emulator/smp.c')
-rw-r--r--emulator/smp.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/emulator/smp.c b/emulator/smp.c
index db0065d7d..ec1baea04 100644
--- a/emulator/smp.c
+++ b/emulator/smp.c
@@ -834,8 +834,22 @@ void smp_conn_encrypted(void *conn_data, uint8_t encrypt)
distribute_keys(conn);
}
-void *smp_conn_add(void *smp_data, uint16_t handle, const uint8_t *ia,
- const uint8_t *ra, uint8_t addr_type, bool conn_init)
+static uint8_t type2hci(uint8_t addr_type)
+{
+ switch (addr_type) {
+ case BDADDR_BREDR:
+ case BDADDR_LE_PUBLIC:
+ return LE_PUBLIC_ADDRESS;
+ case BDADDR_LE_RANDOM:
+ return LE_RANDOM_ADDRESS;
+ }
+
+ return 0x00;
+}
+
+void *smp_conn_add(void *smp_data, uint16_t handle,
+ const uint8_t *ia, uint8_t ia_type,
+ const uint8_t *ra, uint8_t ra_type, bool conn_init)
{
struct smp *smp = smp_data;
struct smp_conn *conn;
@@ -848,11 +862,11 @@ void *smp_conn_add(void *smp_data, uint16_t handle, const uint8_t *ia,
conn->smp = smp;
conn->handle = handle;
- conn->addr_type = addr_type;
conn->out = conn_init;
+ conn->addr_type = conn_init ? ia_type : ra_type;
- conn->ia_type = LE_PUBLIC_ADDRESS;
- conn->ra_type = LE_PUBLIC_ADDRESS;
+ conn->ia_type = type2hci(ia_type);
+ conn->ra_type = type2hci(ra_type);
memcpy(conn->ia, ia, 6);
memcpy(conn->ra, ra, 6);