diff mbox series

[v2] Add pattern matching for service UUIDs

Message ID 20240825205817.70066-1-uhrmar@gmail.com
State New
Headers show
Series [v2] Add pattern matching for service UUIDs | expand

Commit Message

Markus Uhr Aug. 25, 2024, 8:58 p.m. UTC
This commit extends the pattern matching capabilities of advertisement
monitors with matching for service UUIDs. This functionality was lost
with bc2ab4b (see #652) and not added with b0656c2.
---
 src/shared/ad.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

Comments

bluez.test.bot@gmail.com Aug. 25, 2024, 10:42 p.m. UTC | #1
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=883075

---Test result---

Test Summary:
CheckPatch                    PASS      0.49 seconds
GitLint                       PASS      0.33 seconds
BuildEll                      PASS      24.72 seconds
BluezMake                     PASS      1703.42 seconds
MakeCheck                     PASS      12.88 seconds
MakeDistcheck                 PASS      181.22 seconds
CheckValgrind                 PASS      254.17 seconds
CheckSmatch                   PASS      358.38 seconds
bluezmakeextell               PASS      121.75 seconds
IncrementalBuild              PASS      1588.75 seconds
ScanBuild                     PASS      1048.78 seconds



---
Regards,
Linux Bluetooth
Markus Uhr Nov. 9, 2024, 9:35 a.m. UTC | #2
Hi,

I submitted below patch in August. I'm interested in getting it merged,
but I have not received any feedback on it.

If there are any issues with this patch, please let me know. I'm happy
to work on it if more iteration is required.

Best,
Markus

On Sun, 25 Aug 2024 22:58:17 +0200
Markus Uhr <uhrmar@gmail.com> wrote:

> This commit extends the pattern matching capabilities of advertisement
> monitors with matching for service UUIDs. This functionality was lost
> with bc2ab4b (see #652) and not added with b0656c2.
> ---
>  src/shared/ad.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>
diff mbox series

Patch

diff --git a/src/shared/ad.c b/src/shared/ad.c
index d08ce7af9..53c4628b6 100644
--- a/src/shared/ad.c
+++ b/src/shared/ad.c
@@ -1362,6 +1362,46 @@  static bool match_manufacturer(const void *data, const void *user_data)
 	return false;
 }
 
+static bool match_uuid(const void *data, const void *user_data)
+{
+	const bt_uuid_t *uuid = data;
+	const struct pattern_match_info *info = user_data;
+	const struct bt_ad_pattern *pattern;
+
+	if (!uuid || !info)
+		return false;
+
+	if (info->matched_pattern)
+		return false;
+
+	pattern = info->current_pattern;
+
+	if (!pattern)
+		return false;
+
+	switch (pattern->type) {
+	case BT_AD_UUID16_ALL:
+	case BT_AD_UUID16_SOME:
+		if (pattern->offset != 0 || pattern->len != sizeof(uint16_t))
+			return false;
+		break;
+	case BT_AD_UUID32_ALL:
+	case BT_AD_UUID32_SOME:
+		if (pattern->offset != 0 || pattern->len != sizeof(uint32_t))
+			return false;
+		break;
+	case BT_AD_UUID128_ALL:
+	case BT_AD_UUID128_SOME:
+		if (pattern->offset != 0 || pattern->len != sizeof(uint128_t))
+			return false;
+		break;
+	default:
+		return false;
+	}
+
+	return !memcmp(&uuid->value, pattern->data, pattern->len);
+}
+
 static bool match_service(const void *data, const void *user_data)
 {
 	const struct bt_ad_service_data *service_data = data;
@@ -1451,6 +1491,14 @@  static void pattern_match(void *data, void *user_data)
 		matched = queue_find(ad->manufacturer_data, match_manufacturer,
 				user_data);
 		break;
+	case BT_AD_UUID16_ALL:
+	case BT_AD_UUID16_SOME:
+	case BT_AD_UUID32_ALL:
+	case BT_AD_UUID32_SOME:
+	case BT_AD_UUID128_ALL:
+	case BT_AD_UUID128_SOME:
+		matched = queue_find(ad->service_uuids, match_uuid, user_data);
+		break;
 	case BT_AD_SERVICE_DATA16:
 	case BT_AD_SERVICE_DATA32:
 	case BT_AD_SERVICE_DATA128: