core/device: Fix attempting to connect to random address over BR/EDR
Luiz Augusto von Dentz
maintainerPATCH 1/2 core/device: Fix attempting to connect to random address over BR/EDR
From: Luiz Augusto von Dentz <[email protected]>
BR/EDR don't have the concept of random addresses so the only option is to over LE in that case.
--- src/device.c | 4 ++++ 1 file changed, 4 insertions(+)
src/device.c +4 -0
@@ -1748,6 +1748,10 @@ static uint8_t select_conn_bearer(struct btd_device *dev)else if (!dev->bredr_state.bonded && dev->le_state.bonded)return dev->bdaddr_type; +/* If the address is private it can only be connected over LE */ +if (device_address_is_private (dev)) +return dev->bdaddr_type; +if (dev->bredr_seen) { bredr_last = current - dev->bredr_seen;if (bredr_last >SEEN_TRESHHOLD )
Signature · 1 line
2.7.4
Luiz Augusto von Dentz
maintainerPATCH 2/2 core/gatt-client: Fix not return empty array for ReadValue
From: Luiz Augusto von Dentz <[email protected]>
The response to ReadValue shall be an array which can be empty.
--- src/gatt-client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
src/gatt-client.c +4 -4
@@ -297,7 +297,7 @@ static void write_descriptor_cb(struct gatt_db_attribute *attr, int err, }static void async_dbus_op_reply (struct async_dbus_op *op,int err, -const uint8_t *value,size_t length) +const uint8_t *value,ssize_t length) {const struct queue_entry *entry;DBusMessage *reply;
@@ -319,7 +319,7 @@ static void async_dbus_op_reply(struct async_dbus_op *op, int err,return ; } -if (value) +if (length >=0 )message_append_byte_array (reply, value, length); send_reply:
@@ -489,7 +489,7 @@ static void write_result_cb(bool success, bool reliable_error, } done: -async_dbus_op_reply (op, err,NULL ,0 ); +async_dbus_op_reply (op, err,NULL ,-1 ); }static void write_cb (bool success,uint8_t att_ecode,void *user_data)
@@ -1126,7 +1126,7 @@ static void create_notify_reply(struct async_dbus_op *op, bool success,else err = att_ecode ? att_ecode : -ENOENT ; -async_dbus_op_reply (op, err,NULL ,0 ); +async_dbus_op_reply (op, err,NULL ,-1 ); }static void register_notify_cb (uint16_t att_ecode,void *user_data)
Signature · 1 line
2.7.4
Hi,
Quoted 24 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
BR/EDR don't have the concept of random addresses so the only option is to over LE in that case.
--- src/device.c | 4 ++++ 1 file changed, 4 insertions(+)src/device.c +4
-1@@ -1748,6 +1748,10 @@ static uint8_t select_conn_bearer(struct btd_device *dev)else if (!dev->bredr_state.bonded && dev->le_state.bonded)return dev->bdaddr_type; +/* If the address is private it can only be connected over LE */ +if (device_address_is_private (dev)) +return dev->bdaddr_type; +if (dev->bredr_seen) { bredr_last = current - dev->bredr_seen;if (bredr_last >SEEN_TRESHHOLD ) --
Quoted 1 line
2.7.4
Applied.
Signature · 1 line
Luiz Augusto von Dentz
Hi Luiz,
Quoted 11 lines · Luiz Augusto von Dentz
BR/EDR don't have the concept of random addresses so the only option is to over LE in that case.
--- src/device.c | 4 ++++ 1 file changed, 4 insertions(+)src/device.c +0
-0
src/device.c static uint8_t select_conn_bearer(struct btd_device *dev) · line 1754
Quoted 7 lines
src/device.c +4
-0@@ -1748,6 +1748,10 @@ static uint8_t select_conn_bearer(struct btd_device *dev)else if (!dev->bredr_state.bonded && dev->le_state.bonded)return dev->bdaddr_type; +/* If the address is private it can only be connected over LE */ +if (device_address_is_private (dev)) +return dev->bdaddr_type; +
This doesn't look right to me. The comment also isn't correct since a dual mode device may use a resolvable private address for LE, i.e. device_address_is_private(dev) would return true. IIRC the dev->bdaddr_type value tells the LE address type when LE is supported. If LE is not supported then dev->bdaddr_type is BDADDR_BREDR.
Johan
Luiz Augusto von Dentz
maintainerHi Johan,
Quoted 17 lines · Johan Hedberg
Hi Luiz,
Quoted 14 lines · Luiz Augusto von Dentz
BR/EDR don't have the concept of random addresses so the only option is to over LE in that case.
--- src/device.c | 4 ++++ 1 file changed, 4 insertions(+)src/device.c +0
-0@@ -1748,6 +1748,10 @@ static uint8_t select_conn_bearer(struct btd_device *dev)else if (!dev->bredr_state.bonded && dev->le_state.bonded)return dev->bdaddr_type;
Quoted 9 lines
src/device.c static uint8_t select_conn_bearer(struct btd_device *dev) · line 1754
Quoted 4 lines
src/device.c +4
-0+/* If the address is private it can only be connected over LE */ +if (device_address_is_private (dev)) +return dev->bdaddr_type; +This doesn't look right to me. The comment also isn't correct since a dual mode device may use a resolvable private address for LE, i.e.
device_address_is_private(dev)would return true. IIRC thedev->bdaddr_typevalue tells the LE address type when LE is supported.
This is evaluated after checking if device is bonded, but it doesn't actually matter because this device object can only use the random address until it is resolved, if we later on resolve the address I suppose the object is updated with its identity address and the address type is changed to public.
Quoted 1 line
If LE is not supported then
dev->bdaddr_typeisBDADDR_BREDR.
But private addresses can only be used in LE, so device_address_is_private will only return true for LE.
Signature · 1 line
Luiz Augusto von Dentz
Hi Luiz,
Quoted 28 lines · Luiz Augusto von Dentz
Quoted 17 lines · Johan Hedberg
Hi Luiz,
Quoted 14 lines · Luiz Augusto von Dentz
BR/EDR don't have the concept of random addresses so the only option is to over LE in that case.
--- src/device.c | 4 ++++ 1 file changed, 4 insertions(+)src/device.c +0
-0@@ -1748,6 +1748,10 @@ static uint8_t select_conn_bearer(struct btd_device *dev)else if (!dev->bredr_state.bonded && dev->le_state.bonded)return dev->bdaddr_type;Quoted 9 lines
src/device.c static uint8_t select_conn_bearer(struct btd_device *dev) · line 1754
Quoted 4 lines
src/device.c +4
-0+/* If the address is private it can only be connected over LE */ +if (device_address_is_private (dev)) +return dev->bdaddr_type; +This doesn't look right to me. The comment also isn't correct since a dual mode device may use a resolvable private address for LE, i.e.
device_address_is_private(dev)would return true. IIRC thedev->bdaddr_typevalue tells the LE address type when LE is supported.
Quoted 5 lines
This is evaluated after checking if device is bonded, but it doesn't actually matter because this device object can only use the random address until it is resolved, if we later on resolve the address I suppose the object is updated with its identity address and the address type is changed to public.
If that's the case then you're right that the patch shouldn't break anything. The comment is still confusing though.
Quoted 4 lines
Quoted 1 line
If LE is not supported then
dev->bdaddr_typeisBDADDR_BREDR.But private addresses can only be used in LE, so
device_address_is_privatewill only return true for LE.
Why specifically private addresses and not random addresses in general? The latter can be checked with dev->bdaddr_type == BDADDR_LE_RANDOM, which is more lightweight than calling device_address_is_private(). Also, if your intention is to check for devices not supporting BR/EDR then why don't you just check for !dev->bredr?
Johan