Skip to contentSkip to conversation

shared/util: Add bt_uuid128_to_str

PATCH In review Luiz Augusto von Dentz 2 participants 5 messages May 18, 2021 – May 19, 2021 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/3 shared/util: Add bt_uuid128_to_str

From: Luiz Augusto von Dentz <[email protected]>

This adds bt_uuid128_to_str which can be used to convert UUID 128 bit binary format into string.

---
 src/shared/util.c | 12 ++++++++++++
 src/shared/util.h |  1 +
 2 files changed, 13 insertions(+)
src/shared/util.c +12 -0
index 9c2054211..7fb1c01dc 100644
@@ -1042,6 +1042,18 @@ const char *bt_uuid32_to_str(uint32_t uuid)
 	return "Unknown";
 }
 
+const char *bt_uuid128_to_str(const uint8_t uuid[16])
+{
+	char uuidstr[37];
+
+	sprintf(uuidstr, "%8.8x-%4.4x-%4.4x-%4.4x-%8.8x%4.4x",
+				get_le32(&uuid[12]), get_le16(&uuid[10]),
+				get_le16(&uuid[8]), get_le16(&uuid[6]),
+				get_le32(&uuid[2]), get_le16(&uuid[0]));
+
+	return bt_uuidstr_to_str(uuidstr);
+}
+
 const char *bt_uuidstr_to_str(const char *uuid)
 {
 	uint32_t val;
src/shared/util.h +1 -0
index d6de55885..9920b7f76 100644
@@ -107,6 +107,7 @@ void util_clear_uid(unsigned int *bitmap, uint8_t id);
 
 const char *bt_uuid16_to_str(uint16_t uuid);
 const char *bt_uuid32_to_str(uint32_t uuid);
+const char *bt_uuid128_to_str(const uint8_t uuid[16]);
 const char *bt_uuidstr_to_str(const char *uuid);
 const char *bt_appear_to_str(uint16_t appearance);
 
Signature · 1 line
2.30.2
author maintainer
#1 lore raw

PATCH 2/3 shared/util: Decode BlueZ experimental UUIDs

From: Luiz Augusto von Dentz <[email protected]>

This adds BlueZ experimental UUIDs to uuid128_table so they are decoded by the likes of btmon.

---
 src/shared/util.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/shared/util.c +6 -0
index 7fb1c01dc..8c216f936 100644
@@ -1019,6 +1019,12 @@ static const struct {
 	{ "6e400001-b5a3-f393-e0a9-e50e24dcca9e", "Nordic UART Service" },
 	{ "6e400002-b5a3-f393-e0a9-e50e24dcca9e", "Nordic UART TX"	},
 	{ "6e400003-b5a3-f393-e0a9-e50e24dcca9e", "Nordic UART RX"	},
+	/* BlueZ Experimental Features */
+	{ "d4992530-b9ec-469f-ab01-6c481c47da1c", "BlueZ Experimental Debug" },
+	{ "671b10b5-42c0-4696-9227-eb28d1b049d6",
+		"BlueZ Experimental Simultaneous Central and Peripheral" },
+	{ "15c0a148-c273-11ea-b3de-0242ac130004",
+		"BlueZ Experimental LL privacy" },
 	{ }
 };
 
Signature · 1 line
2.30.2
author maintainer
#2 lore raw

PATCH 3/3 btmon: Use bt_uuid128_to_str when printing UUIDs of 128 bits

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This ensures that know UUIDs names are printed including those used by experimental features.

---
 monitor/packet.c | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)
monitor/packet.c +6 -21
index d729a01cc..82513a63c 100644
@@ -3282,18 +3282,13 @@ static void print_uuid128_list(const char *label, const void *data,
 {
 	uint8_t count = data_len / 16;
 	unsigned int i;
-	char uuidstr[MAX_LEN_UUID_STR];
 
 	print_field("%s: %u entr%s", label, count, count == 1 ? "y" : "ies");
 
 	for (i = 0; i < count; i++) {
 		const uint8_t *uuid = data + (i * 16);
 
-		sprintf(uuidstr, "%8.8x-%4.4x-%4.4x-%4.4x-%8.8x%4.4x",
-				get_le32(&uuid[12]), get_le16(&uuid[10]),
-				get_le16(&uuid[8]), get_le16(&uuid[6]),
-				get_le32(&uuid[2]), get_le16(&uuid[0]));
-		print_field("  %s (%s)", bt_uuidstr_to_str(uuidstr), uuidstr);
+		print_field("  %s", bt_uuid128_to_str(uuid));
 	}
 }
 
@@ -12006,16 +12001,6 @@ static void mgmt_print_name(const void *data)
 	print_field("Short name: %s", (char *) (data + 249));
 }
 
-static void mgmt_print_uuid(const void *data)
-{
-	const uint8_t *uuid = data;
-
-	print_field("UUID: %8.8x-%4.4x-%4.4x-%4.4x-%8.8x%4.4x",
-				get_le32(&uuid[12]), get_le16(&uuid[10]),
-				get_le16(&uuid[8]), get_le16(&uuid[6]),
-				get_le32(&uuid[2]), get_le16(&uuid[0]));
-}
-
 static void mgmt_print_io_capability(uint8_t capability)
 {
 	const char *str;
@@ -12261,7 +12246,7 @@ static void mgmt_print_exp_feature(const void *data)
 	uint32_t flags = get_le32(data + 16);
 	uint32_t mask;
 
-	mgmt_print_uuid(data);
+	print_field("UUID: %s", bt_uuid128_to_str(data));
 	print_field("Flags: 0x%8.8x", flags);
 
 	mask = print_bitfield(2, flags, mgmt_exp_feature_flags_table);
@@ -12457,7 +12442,7 @@ static void mgmt_add_uuid_cmd(const void *data, uint16_t size)
 {
 	uint8_t service_class = get_u8(data + 16);
 
-	mgmt_print_uuid(data);
+	print_field("UUID: %s", bt_uuid128_to_str(data));
 	print_field("Service class: 0x%2.2x", service_class);
 }
 
@@ -12468,7 +12453,7 @@ static void mgmt_add_uuid_rsp(const void *data, uint16_t size)
 
 static void mgmt_remove_uuid_cmd(const void *data, uint16_t size)
 {
-	mgmt_print_uuid(data);
+	print_field("UUID: %s", bt_uuid128_to_str(data));
 }
 
 static void mgmt_remove_uuid_rsp(const void *data, uint16_t size)
@@ -13092,7 +13077,7 @@ static void mgmt_start_service_discovery_cmd(const void *data, uint16_t size)
 	}
 
 	for (i = 0; i < num_uuids; i++)
-		mgmt_print_uuid(data + 4 + (i * 16));
+		print_field("UUID: %s", bt_uuid128_to_str(data + 4 + (i * 16)));
 }
 
 static void mgmt_start_service_discovery_rsp(const void *data, uint16_t size)
@@ -13352,7 +13337,7 @@ static void mgmt_set_exp_feature_cmd(const void *data, uint16_t size)
 {
 	uint8_t enable = get_u8(data + 16);
 
-	mgmt_print_uuid(data);
+	print_field("UUID: %s", bt_uuid128_to_str(data));
 	print_enable("Action", enable);
 }
 
Signature · 1 line
2.30.2
#3 lore raw
In reply to Luiz Augusto von Dentz

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=484525

---Test result---

Test Summary:

CheckPatch                    PASS      1.16 seconds
GitLint                       PASS      0.40 seconds
Prep - Setup ELL              PASS      51.17 seconds
Build - Prep                  PASS      0.11 seconds
Build - Configure             PASS      9.04 seconds
Build - Make                  PASS      217.20 seconds
Make Check                    PASS      9.63 seconds
Make Distcheck                PASS      256.57 seconds
Build w/ext ELL - Configure   PASS      9.17 seconds
Build w/ext ELL - Make        PASS      204.36 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration

---
Regards,
Linux Bluetooth

author maintainer
#4 lore raw

Hi,

Quoted 66 lines · On Tue, May 18, 2021 at 12:04 PM <[email protected]> wrote:

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=484525

---Test result---

Test Summary:

CheckPatch                    PASS      1.16 seconds
GitLint                       PASS      0.40 seconds
Prep - Setup ELL              PASS      51.17 seconds
Build - Prep                  PASS      0.11 seconds
Build - Configure             PASS      9.04 seconds
Build - Make                  PASS      217.20 seconds
Make Check                    PASS      9.63 seconds
Make Distcheck                PASS      256.57 seconds
Build w/ext ELL - Configure   PASS      9.17 seconds
Build w/ext ELL - Make        PASS      204.36 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration

Quoted 3 lines

---
Regards,
Linux Bluetooth

Pushed.

Signature · 1 line
Luiz Augusto von Dentz