From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 1/2] shared/ad: Add bt_ad_length
Date: Wed, 15 May 2024 12:12:49 -0400 [thread overview]
Message-ID: <20240515161250.1714375-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds bt_ad_length which can be used to return the current size of
the bt_ad data.
---
src/shared/ad.c | 11 ++++++++---
src/shared/ad.h | 2 ++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/shared/ad.c b/src/shared/ad.c
index f3fb428e25c6..d08ce7af9b85 100644
--- a/src/shared/ad.c
+++ b/src/shared/ad.c
@@ -520,9 +520,14 @@ static size_t data_length(struct queue *queue)
return length;
}
-static size_t calculate_length(struct bt_ad *ad)
+size_t bt_ad_length(struct bt_ad *ad)
{
- size_t length = 0;
+ size_t length;
+
+ if (!ad)
+ return 0;
+
+ length = 0;
length += uuid_list_length(ad->service_uuids);
@@ -698,7 +703,7 @@ uint8_t *bt_ad_generate(struct bt_ad *ad, size_t *length)
if (!ad)
return NULL;
- *length = calculate_length(ad);
+ *length = bt_ad_length(ad);
if (*length > ad->max_len)
return NULL;
diff --git a/src/shared/ad.h b/src/shared/ad.h
index 11900706f9ed..90cc82de9d63 100644
--- a/src/shared/ad.h
+++ b/src/shared/ad.h
@@ -108,6 +108,8 @@ struct bt_ad *bt_ad_ref(struct bt_ad *ad);
void bt_ad_unref(struct bt_ad *ad);
+size_t bt_ad_length(struct bt_ad *ad);
+
uint8_t *bt_ad_generate(struct bt_ad *ad, size_t *length);
bool bt_ad_is_empty(struct bt_ad *ad);
--
2.45.0
next reply other threads:[~2024-05-15 16:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 16:12 Luiz Augusto von Dentz [this message]
2024-05-15 16:12 ` [PATCH BlueZ v1 2/2] advertising: Detect when EA needs to be used Luiz Augusto von Dentz
2024-05-15 17:40 ` [PATCH BlueZ v1 1/2] shared/ad: Add bt_ad_length patchwork-bot+bluetooth
2024-05-15 18:07 ` [BlueZ,v1,1/2] " bluez.test.bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240515161250.1714375-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).