* [PATCH BlueZ 2/4] monitor/att: Print value when printing descriptors
2023-03-24 23:38 [PATCH BlueZ 1/4] shared/gatt-db: Make gatt_db_attribute_get_value public Luiz Augusto von Dentz
@ 2023-03-24 23:38 ` Luiz Augusto von Dentz
2023-03-24 23:38 ` [PATCH BlueZ 3/4] monitor/att: Fix not loading gatt_db for devices using RPA Luiz Augusto von Dentz
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2023-03-24 23:38 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This prints the value attribute information when print attribute
descriptors:
< ACL Data TX: Handle 3585 flags 0x00 dlen 9
ATT: Write Request (0x12) len 4
Handle: 0x002c Type: Client Characteristic Configuration (0x2902)
Value Handle: 0x002b Type: Battery Level (0x2a19)
Data: 0100
Notification (0x01)
---
monitor/att.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/monitor/att.c b/monitor/att.c
index 9f329370d698..42d1afe701a1 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -122,6 +122,56 @@ static struct att_read *att_get_read(const struct l2cap_frame *frame)
return queue_remove_if(data->reads, match_read_frame, (void *)frame);
}
+static void print_value(struct gatt_db_attribute *attr)
+{
+ uint16_t handle;
+ struct gatt_db_attribute *val;
+ const bt_uuid_t *uuid;
+ bt_uuid_t chrc = {
+ .type = BT_UUID16,
+ .value.u16 = 0x2803,
+ };
+ char label[27];
+
+ uuid = gatt_db_attribute_get_type(attr);
+ if (!uuid)
+ return;
+
+ /* Skip in case of characteristic declaration since it already prints
+ * the value handle and properties.
+ */
+ if (!bt_uuid_cmp(uuid, &chrc))
+ return;
+
+ val = gatt_db_attribute_get_value(attr);
+ if (!val || val == attr)
+ return;
+
+ uuid = gatt_db_attribute_get_type(val);
+ if (!uuid)
+ return;
+
+ handle = gatt_db_attribute_get_handle(val);
+ if (!handle)
+ return;
+
+ switch (uuid->type) {
+ case BT_UUID16:
+ sprintf(label, "Value Handle: 0x%4.4x Type", handle);
+ print_field("%s: %s (0x%4.4x)", label,
+ bt_uuid16_to_str(uuid->value.u16),
+ uuid->value.u16);
+ return;
+ case BT_UUID128:
+ sprintf(label, "Value Handle: 0x%4.4x Type", handle);
+ print_uuid(label, &uuid->value.u128, 16);
+ return;
+ case BT_UUID_UNSPEC:
+ case BT_UUID32:
+ break;
+ }
+}
+
static void print_attribute(struct gatt_db_attribute *attr)
{
uint16_t handle;
@@ -142,10 +192,12 @@ static void print_attribute(struct gatt_db_attribute *attr)
print_field("%s: %s (0x%4.4x)", label,
bt_uuid16_to_str(uuid->value.u16),
uuid->value.u16);
+ print_value(attr);
return;
case BT_UUID128:
sprintf(label, "Handle: 0x%4.4x Type", handle);
print_uuid(label, &uuid->value.u128, 16);
+ print_value(attr);
return;
case BT_UUID_UNSPEC:
case BT_UUID32:
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH BlueZ 3/4] monitor/att: Fix not loading gatt_db for devices using RPA
2023-03-24 23:38 [PATCH BlueZ 1/4] shared/gatt-db: Make gatt_db_attribute_get_value public Luiz Augusto von Dentz
2023-03-24 23:38 ` [PATCH BlueZ 2/4] monitor/att: Print value when printing descriptors Luiz Augusto von Dentz
@ 2023-03-24 23:38 ` Luiz Augusto von Dentz
2023-03-24 23:38 ` [PATCH BlueZ 4/4] monitor: Cache IRK being parsed Luiz Augusto von Dentz
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2023-03-24 23:38 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Device using RPA have its storage using its identity address so this
uses keys_resolve_identity to attempt to resolve the destination
address instead of always using the connection address.
---
monitor/att.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/monitor/att.c b/monitor/att.c
index 42d1afe701a1..cf440c6844c0 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -42,6 +42,7 @@
#include "display.h"
#include "l2cap.h"
#include "att.h"
+#include "keys.h"
struct att_read {
struct gatt_db_attribute *attr;
@@ -2885,9 +2886,14 @@ static void load_gatt_db(struct packet_conn_data *conn)
char filename[PATH_MAX];
char local[18];
char peer[18];
+ uint8_t id[6], id_type;
ba2str((bdaddr_t *)conn->src, local);
- ba2str((bdaddr_t *)conn->dst, peer);
+
+ if (keys_resolve_identity(conn->dst, id, &id_type))
+ ba2str((bdaddr_t *)id, peer);
+ else
+ ba2str((bdaddr_t *)conn->dst, peer);
create_filename(filename, PATH_MAX, "/%s/attributes", local);
gatt_load_db(data->ldb, filename, &data->ldb_mtim);
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH BlueZ 4/4] monitor: Cache IRK being parsed
2023-03-24 23:38 [PATCH BlueZ 1/4] shared/gatt-db: Make gatt_db_attribute_get_value public Luiz Augusto von Dentz
2023-03-24 23:38 ` [PATCH BlueZ 2/4] monitor/att: Print value when printing descriptors Luiz Augusto von Dentz
2023-03-24 23:38 ` [PATCH BlueZ 3/4] monitor/att: Fix not loading gatt_db for devices using RPA Luiz Augusto von Dentz
@ 2023-03-24 23:38 ` Luiz Augusto von Dentz
2023-03-25 2:27 ` [BlueZ,1/4] shared/gatt-db: Make gatt_db_attribute_get_value public bluez.test.bot
2023-03-27 21:20 ` [PATCH BlueZ 1/4] " patchwork-bot+bluetooth
4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2023-03-24 23:38 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This caches any IRK being parsed so they can be used to resolve
addresses later which fixes the problem of only being able to resolve
addresses if the monitor happens to be active while SMP exchange the
keys.
---
monitor/keys.c | 26 ++++++++++++++++++++++++++
monitor/keys.h | 2 ++
monitor/packet.c | 1 +
3 files changed, 29 insertions(+)
diff --git a/monitor/keys.c b/monitor/keys.c
index d2fa3b23ffec..c1eebae82ac2 100644
--- a/monitor/keys.c
+++ b/monitor/keys.c
@@ -112,3 +112,29 @@ bool keys_resolve_identity(const uint8_t addr[6], uint8_t ident[6],
return false;
}
+
+static bool match_key(const void *data, const void *match_data)
+{
+ const struct irk_data *irk = data;
+ const uint8_t *key = match_data;
+
+ return !memcmp(irk->key, key, 16);
+}
+
+bool keys_add_identity(const uint8_t addr[6], uint8_t addr_type,
+ const uint8_t key[16])
+{
+ struct irk_data *irk;
+
+ irk = queue_find(irk_list, match_key, key);
+ if (!irk) {
+ irk = new0(struct irk_data, 1);
+ memcpy(irk->key, key, 16);
+ queue_push_tail(irk_list, irk);
+ }
+
+ memcpy(irk->addr, addr, 6);
+ irk->addr_type = addr_type;
+
+ return true;
+}
diff --git a/monitor/keys.h b/monitor/keys.h
index e40c90fa9c72..f44d33295269 100644
--- a/monitor/keys.h
+++ b/monitor/keys.h
@@ -20,3 +20,5 @@ void keys_update_identity_addr(const uint8_t addr[6], uint8_t addr_type);
bool keys_resolve_identity(const uint8_t addr[6], uint8_t ident[6],
uint8_t *ident_type);
+bool keys_add_identity(const uint8_t addr[6], uint8_t addr_type,
+ const uint8_t key[16]);
diff --git a/monitor/packet.c b/monitor/packet.c
index d9e8abf41fed..c6ff16eda9cf 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -12870,6 +12870,7 @@ static void mgmt_print_identity_resolving_key(const void *data)
mgmt_print_address(data, address_type);
print_hex_field("Key", data + 7, 16);
+ keys_add_identity(data, address_type, data + 7);
}
static void mgmt_print_signature_resolving_key(const void *data)
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* RE: [BlueZ,1/4] shared/gatt-db: Make gatt_db_attribute_get_value public
2023-03-24 23:38 [PATCH BlueZ 1/4] shared/gatt-db: Make gatt_db_attribute_get_value public Luiz Augusto von Dentz
` (2 preceding siblings ...)
2023-03-24 23:38 ` [PATCH BlueZ 4/4] monitor: Cache IRK being parsed Luiz Augusto von Dentz
@ 2023-03-25 2:27 ` bluez.test.bot
2023-03-27 21:20 ` [PATCH BlueZ 1/4] " patchwork-bot+bluetooth
4 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2023-03-25 2:27 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 1589 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=733736
---Test result---
Test Summary:
CheckPatch PASS 2.00 seconds
GitLint PASS 1.35 seconds
BuildEll PASS 26.61 seconds
BluezMake PASS 775.64 seconds
MakeCheck PASS 11.40 seconds
MakeDistcheck PASS 150.29 seconds
CheckValgrind PASS 242.80 seconds
CheckSmatch WARNING 324.85 seconds
bluezmakeextell PASS 98.44 seconds
IncrementalBuild PASS 2446.98 seconds
ScanBuild PASS 960.47 seconds
Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
monitor/att.c: note: in included file:monitor/display.h:82:26: warning: Variable length array is used.monitor/att.c: note: in included file:monitor/display.h:82:26: warning: Variable length array is used.monitor/packet.c: note: in included file:monitor/display.h:82:26: warning: Variable length array is used.monitor/packet.c:1799:26: warning: Variable length array is used.monitor/packet.c: note: in included file:monitor/bt.h:3551:52: warning: array of flexible structuresmonitor/bt.h:3539:40: warning: array of flexible structures
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH BlueZ 1/4] shared/gatt-db: Make gatt_db_attribute_get_value public
2023-03-24 23:38 [PATCH BlueZ 1/4] shared/gatt-db: Make gatt_db_attribute_get_value public Luiz Augusto von Dentz
` (3 preceding siblings ...)
2023-03-25 2:27 ` [BlueZ,1/4] shared/gatt-db: Make gatt_db_attribute_get_value public bluez.test.bot
@ 2023-03-27 21:20 ` patchwork-bot+bluetooth
4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2023-03-27 21:20 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Fri, 24 Mar 2023 16:38:53 -0700 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This makes gatt_db_attribute_get_value public so it can be used by the
> likes of btmon.
> ---
> src/shared/gatt-db.c | 12 ++++++------
> src/shared/gatt-db.h | 2 ++
> 2 files changed, 8 insertions(+), 6 deletions(-)
Here is the summary with links:
- [BlueZ,1/4] shared/gatt-db: Make gatt_db_attribute_get_value public
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7610b9264147
- [BlueZ,2/4] monitor/att: Print value when printing descriptors
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=cf7242815668
- [BlueZ,3/4] monitor/att: Fix not loading gatt_db for devices using RPA
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2719bb5aaf6d
- [BlueZ,4/4] monitor: Cache IRK being parsed
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=011e562a98a8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread