From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 1/2] main.conf: Introduce MaxControllers
Date: Thu, 17 Feb 2022 15:39:01 -0800 [thread overview]
Message-ID: <20220217233902.3093404-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This introduces MaxControllers which can be used to limit the number of
adapters exposed in the system.
---
src/adapter.c | 7 +++++++
src/btd.h | 1 +
src/main.c | 9 +++++++++
src/main.conf | 4 ++++
4 files changed, 21 insertions(+)
diff --git a/src/adapter.c b/src/adapter.c
index 2071cf8db..1551011a8 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -10078,6 +10078,13 @@ static void index_added(uint16_t index, uint16_t length, const void *param,
return;
}
+ /* Check if at maximum adapters allowed in the system then ignore the
+ * adapter.
+ */
+ if (btd_opts.max_adapters &&
+ btd_opts.max_adapters == g_slist_length(adapters))
+ return;
+
reset_adv_monitors(index);
adapter = btd_adapter_new(index);
diff --git a/src/btd.h b/src/btd.h
index a805a40d7..d13646889 100644
--- a/src/btd.h
+++ b/src/btd.h
@@ -121,6 +121,7 @@ struct btd_opts {
uint16_t did_version;
bt_mode_t mode;
+ uint16_t max_adapters;
bt_gatt_cache_t gatt_cache;
uint16_t gatt_mtu;
uint8_t gatt_channels;
diff --git a/src/main.c b/src/main.c
index 8cc2dfca6..bf9d398e4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -77,6 +77,7 @@ static const char *supported_options[] = {
"NameResolving",
"DebugKeys",
"ControllerMode",
+ "MaxControllers"
"MultiProfile",
"FastConnectable",
"Privacy",
@@ -779,6 +780,14 @@ static void parse_config(GKeyFile *config)
g_free(str);
}
+ val = g_key_file_get_integer(config, "General", "MaxControllers", &err);
+ if (err) {
+ g_clear_error(&err);
+ } else {
+ DBG("MaxControllers=%d", val);
+ btd_opts.max_adapters = val;
+ }
+
str = g_key_file_get_string(config, "General", "MultiProfile", &err);
if (err) {
g_clear_error(&err);
diff --git a/src/main.conf b/src/main.conf
index 49b9e6755..401796235 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -51,6 +51,10 @@
# Possible values: "dual", "bredr", "le"
#ControllerMode = dual
+# Maximum number of controllers allowed to be exposed to the system.
+# Default=0 (unlimited)
+#MaxControllers=0
+
# Enables Multi Profile Specification support. This allows to specify if
# system supports only Multiple Profiles Single Device (MPSD) configuration
# or both Multiple Profiles Single Device (MPSD) and Multiple Profiles Multiple
--
2.35.1
next reply other threads:[~2022-02-17 23:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 23:39 Luiz Augusto von Dentz [this message]
2022-02-17 23:39 ` [PATCH BlueZ 2/2] adapter: Fix allowing multiple adapters with the same address Luiz Augusto von Dentz
2022-02-18 3:20 ` [BlueZ,1/2] main.conf: Introduce MaxControllers bluez.test.bot
2022-02-18 21:22 ` Luiz Augusto von Dentz
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=20220217233902.3093404-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