From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 1/2] shared/gatt-server: Add bt_gatt_server_set_permissions
Date: Wed, 1 Apr 2026 10:26:26 -0400 [thread overview]
Message-ID: <20260401142627.1944044-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds bt_gatt_server_set_permissions which can be used to
enabled/disable permission checking before operations which can be
useful on testing only environment where encryption/pairing is not
desirable/needed.
---
src/shared/gatt-server.c | 13 +++++++++++++
src/shared/gatt-server.h | 2 ++
2 files changed, 15 insertions(+)
diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
index 27ae7e79ed3d..6273899965c0 100644
--- a/src/shared/gatt-server.c
+++ b/src/shared/gatt-server.c
@@ -93,6 +93,7 @@ struct bt_gatt_server {
struct bt_att *att;
int ref_count;
uint16_t mtu;
+ bool perms;
unsigned int mtu_id;
unsigned int read_by_grp_type_id;
@@ -414,6 +415,9 @@ static uint8_t check_permissions(struct bt_gatt_server *server,
uint32_t perm;
int security;
+ if (!server->perms)
+ return 0;
+
perm = gatt_db_attribute_get_permissions(attr);
if (perm && mask & BT_ATT_PERM_READ && !(perm & BT_ATT_PERM_READ))
@@ -1652,6 +1656,7 @@ struct bt_gatt_server *bt_gatt_server_new(struct gatt_db *db,
server->db = gatt_db_ref(db);
server->att = bt_att_ref(att);
server->mtu = MAX(mtu, BT_ATT_DEFAULT_LE_MTU);
+ server->perms = true;
server->max_prep_queue_len = DEFAULT_MAX_PREP_QUEUE_LEN;
server->prep_queue = queue_new();
server->min_enc_size = min_enc_size;
@@ -1680,6 +1685,14 @@ struct bt_att *bt_gatt_server_get_att(struct bt_gatt_server *server)
return server->att;
}
+void bt_gatt_server_set_permissions(struct bt_gatt_server *server, bool value)
+{
+ if (!server)
+ return;
+
+ server->perms = value;
+}
+
struct bt_gatt_server *bt_gatt_server_ref(struct bt_gatt_server *server)
{
if (!server)
diff --git a/src/shared/gatt-server.h b/src/shared/gatt-server.h
index de98a0d04747..ea49f2960d71 100644
--- a/src/shared/gatt-server.h
+++ b/src/shared/gatt-server.h
@@ -17,6 +17,8 @@ struct bt_gatt_server *bt_gatt_server_new(struct gatt_db *db,
uint8_t min_enc_size);
uint16_t bt_gatt_server_get_mtu(struct bt_gatt_server *server);
struct bt_att *bt_gatt_server_get_att(struct bt_gatt_server *server);
+void bt_gatt_server_set_permissions(struct bt_gatt_server *server,
+ bool value);
struct bt_gatt_server *bt_gatt_server_ref(struct bt_gatt_server *server);
void bt_gatt_server_unref(struct bt_gatt_server *server);
--
2.53.0
next reply other threads:[~2026-04-01 14:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 14:26 Luiz Augusto von Dentz [this message]
2026-04-01 14:26 ` [PATCH BlueZ v1 2/2] main.conf: Add GATT.Security option Luiz Augusto von Dentz
2026-04-01 15:53 ` [BlueZ,v1,1/2] shared/gatt-server: Add bt_gatt_server_set_permissions 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=20260401142627.1944044-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