* [PATCH BlueZ 01/12] client/mgmt: fix compiler error
@ 2026-02-25 16:17 Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 02/12] tools: btgatt-client/-server: replace ATT_CID with 'shared' BT_ATT_CID Christian Eggers
` (12 more replies)
0 siblings, 13 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
client/mgmt.c: In function ‘str2bytearray’:
client/mgmt.c:2385:23: error: comparison of integer expressions of
different signedness: ‘unsigned int’ and ‘long int’
[-Werror=sign-compare]
2385 | if (i >= *val_len) {
| ^~
---
client/mgmt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/mgmt.c b/client/mgmt.c
index 4e68547ed33c..1d3a842afd55 100644
--- a/client/mgmt.c
+++ b/client/mgmt.c
@@ -2373,7 +2373,7 @@ static void cmd_set_flags(int argc, char **argv)
static uint8_t *str2bytearray(char *arg, uint8_t *val, long *val_len)
{
char *entry;
- unsigned int i;
+ long i;
for (i = 0; (entry = strsep(&arg, " \t")) != NULL; i++) {
long v;
@@ -2389,7 +2389,7 @@ static uint8_t *str2bytearray(char *arg, uint8_t *val, long *val_len)
v = strtol(entry, &endptr, 0);
if (!endptr || *endptr != '\0' || v > UINT8_MAX) {
- bt_shell_printf("Invalid value at index %d\n", i);
+ bt_shell_printf("Invalid value at index %ld\n", i);
return NULL;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 02/12] tools: btgatt-client/-server: replace ATT_CID with 'shared' BT_ATT_CID
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 03/12] src: " Christian Eggers
` (11 subsequent siblings)
12 siblings, 0 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
Avoid multiple definitions of the same value.
---
tools/btgatt-client.c | 6 ++----
tools/btgatt-server.c | 4 +---
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c
index 54a3cc8763f2..667b3d651616 100644
--- a/tools/btgatt-client.c
+++ b/tools/btgatt-client.c
@@ -35,8 +35,6 @@
#include "src/shared/gatt-client.h"
#include "src/shared/gatt-helpers.h"
-#define ATT_CID 4
-
#define PRLOG(...) \
printf(__VA_ARGS__); print_prompt();
@@ -1660,7 +1658,7 @@ static int l2cap_le_att_connect(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
/* Set up source address */
memset(&srcaddr, 0, sizeof(srcaddr));
srcaddr.l2_family = AF_BLUETOOTH;
- srcaddr.l2_cid = htobs(ATT_CID);
+ srcaddr.l2_cid = htobs(BT_ATT_CID);
srcaddr.l2_bdaddr_type = 0;
bacpy(&srcaddr.l2_bdaddr, src);
@@ -1683,7 +1681,7 @@ static int l2cap_le_att_connect(bdaddr_t *src, bdaddr_t *dst, uint8_t dst_type,
/* Set up destination address */
memset(&dstaddr, 0, sizeof(dstaddr));
dstaddr.l2_family = AF_BLUETOOTH;
- dstaddr.l2_cid = htobs(ATT_CID);
+ dstaddr.l2_cid = htobs(BT_ATT_CID);
dstaddr.l2_bdaddr_type = dst_type;
bacpy(&dstaddr.l2_bdaddr, dst);
diff --git a/tools/btgatt-server.c b/tools/btgatt-server.c
index 66523c1b3306..1690b0dd059f 100644
--- a/tools/btgatt-server.c
+++ b/tools/btgatt-server.c
@@ -42,8 +42,6 @@
#define UUID_HEART_RATE_BODY 0x2a38
#define UUID_HEART_RATE_CTRL 0x2a39
-#define ATT_CID 4
-
#define PRLOG(...) \
do { \
printf(__VA_ARGS__); \
@@ -663,7 +661,7 @@ static int l2cap_le_att_listen_and_accept(bdaddr_t *src, int sec,
/* Set up source address */
memset(&srcaddr, 0, sizeof(srcaddr));
srcaddr.l2_family = AF_BLUETOOTH;
- srcaddr.l2_cid = htobs(ATT_CID);
+ srcaddr.l2_cid = htobs(BT_ATT_CID);
srcaddr.l2_bdaddr_type = src_type;
bacpy(&srcaddr.l2_bdaddr, src);
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 03/12] src: replace ATT_CID with 'shared' BT_ATT_CID
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 02/12] tools: btgatt-client/-server: replace ATT_CID with 'shared' BT_ATT_CID Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 04/12] peripheral: replace ATT_CID with shared BT_ATT_CID Christian Eggers
` (10 subsequent siblings)
12 siblings, 0 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
Avoid multiple definitions of the same value.
---
src/adapter.c | 2 +-
src/device.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 6aa7c0ed0df4..9bb1950a9f7d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3768,7 +3768,7 @@ static void device_connect(struct btd_adapter *adapter, const bdaddr_t *dst,
BT_IO_OPT_SOURCE_TYPE, adapter->bdaddr_type,
BT_IO_OPT_DEST_BDADDR, dst,
BT_IO_OPT_DEST_TYPE, dst_type,
- BT_IO_OPT_CID, ATT_CID,
+ BT_IO_OPT_CID, BT_ATT_CID,
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
BT_IO_OPT_INVALID);
diff --git a/src/device.c b/src/device.c
index af8df5f29b97..2efbc1e148a8 100644
--- a/src/device.c
+++ b/src/device.c
@@ -6453,7 +6453,7 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io)
dev->att_mtu = MIN(mtu, btd_opts.gatt_mtu);
attrib = g_attrib_new(io,
- cid == ATT_CID ? BT_ATT_DEFAULT_LE_MTU : dev->att_mtu,
+ cid == BT_ATT_CID ? BT_ATT_DEFAULT_LE_MTU : dev->att_mtu,
false);
if (!attrib) {
error("Unable to create new GAttrib instance");
@@ -6610,7 +6610,7 @@ int device_connect_le(struct btd_device *dev)
btd_adapter_get_address_type(adapter),
BT_IO_OPT_DEST_BDADDR, &dev->bdaddr,
BT_IO_OPT_DEST_TYPE, dev->bdaddr_type,
- BT_IO_OPT_CID, ATT_CID,
+ BT_IO_OPT_CID, BT_ATT_CID,
BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
@@ -6705,7 +6705,7 @@ static int device_browse_gatt(struct btd_device *device, DBusMessage *msg)
btd_adapter_get_address_type(adapter),
BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
BT_IO_OPT_DEST_TYPE, device->bdaddr_type,
- BT_IO_OPT_CID, ATT_CID,
+ BT_IO_OPT_CID, BT_ATT_CID,
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
BT_IO_OPT_INVALID);
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 04/12] peripheral: replace ATT_CID with shared BT_ATT_CID
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 02/12] tools: btgatt-client/-server: replace ATT_CID with 'shared' BT_ATT_CID Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 03/12] src: " Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 05/12] attrib: replace ATT_CID with 'shared' BT_ATT_CID Christian Eggers
` (9 subsequent siblings)
12 siblings, 0 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
Avoid multiple definitions of the same value.
---
peripheral/gatt.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/peripheral/gatt.c b/peripheral/gatt.c
index e3dd24632c12..d1ddf0c97516 100644
--- a/peripheral/gatt.c
+++ b/peripheral/gatt.c
@@ -30,8 +30,6 @@
#include "src/shared/gatt-client.h"
#include "peripheral/gatt.h"
-#define ATT_CID 4
-
#define UUID_GAP 0x1800
struct gatt_conn {
@@ -243,7 +241,7 @@ void gatt_server_start(void)
memset(&addr, 0, sizeof(addr));
addr.l2_family = AF_BLUETOOTH;
- addr.l2_cid = htobs(ATT_CID);
+ addr.l2_cid = htobs(BT_ATT_CID);
memcpy(&addr.l2_bdaddr, static_addr, 6);
addr.l2_bdaddr_type = BDADDR_LE_RANDOM;
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 05/12] attrib: replace ATT_CID with 'shared' BT_ATT_CID
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
` (2 preceding siblings ...)
2026-02-25 16:17 ` [PATCH BlueZ 04/12] peripheral: replace ATT_CID with shared BT_ATT_CID Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 06/12] src: replace ATT_PSM with 'shared' BT_ATT_PSM Christian Eggers
` (8 subsequent siblings)
12 siblings, 0 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
Avoid multiple definitions of the same value.
---
attrib/att.h | 1 -
attrib/gatttool.c | 3 ++-
attrib/interactive.c | 3 ++-
attrib/utils.c | 3 ++-
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/attrib/att.h b/attrib/att.h
index 13a0c3a31f1f..613a018ba2c6 100644
--- a/attrib/att.h
+++ b/attrib/att.h
@@ -71,7 +71,6 @@
#define ATT_DEFAULT_L2CAP_MTU 48
#define ATT_DEFAULT_LE_MTU 23
-#define ATT_CID 4
#define ATT_PSM 31
/* Flags for Execute Write Request Operation */
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 4fae9d41f44f..c984bef9dd39 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -25,6 +25,7 @@
#include "bluetooth/sdp.h"
#include "bluetooth/uuid.h"
+#include "src/shared/att-types.h"
#include "src/shared/util.h"
#include "att.h"
#include "btio/btio.h"
@@ -132,7 +133,7 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
mtu = ATT_DEFAULT_LE_MTU;
}
- if (cid == ATT_CID)
+ if (cid == BT_ATT_CID)
mtu = ATT_DEFAULT_LE_MTU;
attrib = g_attrib_new(io, mtu, false);
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 4329685c4f7a..07d6cafc57ba 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -30,6 +30,7 @@
#include "bluetooth/sdp.h"
#include "bluetooth/uuid.h"
+#include "src/shared/att-types.h"
#include "src/shared/util.h"
#include "btio/btio.h"
#include "att.h"
@@ -159,7 +160,7 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
mtu = ATT_DEFAULT_LE_MTU;
}
- if (cid == ATT_CID)
+ if (cid == BT_ATT_CID)
mtu = ATT_DEFAULT_LE_MTU;
attrib = g_attrib_new(iochannel, mtu, false);
diff --git a/attrib/utils.c b/attrib/utils.c
index e48bf4ea5cd3..ca05baaa1e8a 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
@@ -22,6 +22,7 @@
#include "bluetooth/sdp.h"
#include "bluetooth/uuid.h"
+#include "src/shared/att-types.h"
#include "btio/btio.h"
#include "att.h"
#include "gattrib.h"
@@ -69,7 +70,7 @@ GIOChannel *gatt_connect(const char *src, const char *dst,
BT_IO_OPT_SOURCE_TYPE, BDADDR_LE_PUBLIC,
BT_IO_OPT_DEST_BDADDR, &dba,
BT_IO_OPT_DEST_TYPE, dest_type,
- BT_IO_OPT_CID, ATT_CID,
+ BT_IO_OPT_CID, BT_ATT_CID,
BT_IO_OPT_SEC_LEVEL, sec,
BT_IO_OPT_INVALID);
else
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 06/12] src: replace ATT_PSM with 'shared' BT_ATT_PSM
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
` (3 preceding siblings ...)
2026-02-25 16:17 ` [PATCH BlueZ 05/12] attrib: replace ATT_CID with 'shared' BT_ATT_CID Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 07/12] tools: btgatt-server: remove unused member 'fd' Christian Eggers
` (7 subsequent siblings)
12 siblings, 0 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
Avoid multiple definitions of the same value.
---
attrib/att.h | 2 --
src/device.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/attrib/att.h b/attrib/att.h
index 613a018ba2c6..8d6ca5930859 100644
--- a/attrib/att.h
+++ b/attrib/att.h
@@ -71,8 +71,6 @@
#define ATT_DEFAULT_L2CAP_MTU 48
#define ATT_DEFAULT_LE_MTU 23
-#define ATT_PSM 31
-
/* Flags for Execute Write Request Operation */
#define ATT_CANCEL_ALL_PREP_WRITES 0x00
#define ATT_WRITE_ALL_PREP_WRITES 0x01
diff --git a/src/device.c b/src/device.c
index 2efbc1e148a8..0ef7dcc244d2 100644
--- a/src/device.c
+++ b/src/device.c
@@ -6097,7 +6097,7 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
primaries = device_services_from_record(device, req->profiles_added);
if (primaries)
- device_register_primaries(device, primaries, ATT_PSM);
+ device_register_primaries(device, primaries, BT_ATT_PSM);
/*
* TODO: The btd_service instances for GATT services need to be
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 07/12] tools: btgatt-server: remove unused member 'fd'
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
` (4 preceding siblings ...)
2026-02-25 16:17 ` [PATCH BlueZ 06/12] src: replace ATT_PSM with 'shared' BT_ATT_PSM Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 08/12] l2test: add comment to -F <fcs> option Christian Eggers
` (6 subsequent siblings)
12 siblings, 0 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
---
tools/btgatt-server.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/tools/btgatt-server.c b/tools/btgatt-server.c
index 1690b0dd059f..449c342031a5 100644
--- a/tools/btgatt-server.c
+++ b/tools/btgatt-server.c
@@ -66,7 +66,6 @@ static const char test_device_name[] = "Very Long Test Device Name For Testing "
static bool verbose = false;
struct server {
- int fd;
struct bt_att *att;
struct gatt_db *db;
struct bt_gatt_server *gatt;
@@ -570,7 +569,6 @@ static struct server *server_create(int fd, uint16_t mtu, bool hr_visible)
memcpy(server->device_name, test_device_name, name_len);
server->device_name[name_len] = '\0';
- server->fd = fd;
server->db = gatt_db_new();
if (!server->db) {
fprintf(stderr, "Failed to create GATT database\n");
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 08/12] l2test: add comment to -F <fcs> option
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
` (5 preceding siblings ...)
2026-02-25 16:17 ` [PATCH BlueZ 07/12] tools: btgatt-server: remove unused member 'fd' Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 09/12] l2test: add comment to -O <omtu> option Christian Eggers
` (5 subsequent siblings)
12 siblings, 0 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
Clarify that this option has affect for BR/EDR sockets only. Use defines
instead of magic numbers.
---
lib/bluetooth/l2cap.h | 3 +++
tools/l2test.c | 4 ++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/bluetooth/l2cap.h b/lib/bluetooth/l2cap.h
index 62cc04b57ae9..8b54233ef9c2 100644
--- a/lib/bluetooth/l2cap.h
+++ b/lib/bluetooth/l2cap.h
@@ -187,6 +187,9 @@ typedef struct {
#define L2CAP_MODE_LE_FLOWCTL 0x80
#define L2CAP_MODE_ECRED 0x81
+#define L2CAP_FCS_NONE 0x00
+#define L2CAP_FCS_CRC16 0x01
+
#define L2CAP_SERVTYPE_NOTRAFFIC 0x00
#define L2CAP_SERVTYPE_BESTEFFORT 0x01
#define L2CAP_SERVTYPE_GUARANTEED 0x02
diff --git a/tools/l2test.c b/tools/l2test.c
index 2cf3a47e7cdf..e49289a4c774 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -72,7 +72,7 @@ static int imtu = 672;
static int omtu = 0;
/* Default FCS option */
-static int fcs = 0x01;
+static int fcs = L2CAP_FCS_CRC16;
/* Default Transmission Window */
static int txwin_size = 63;
@@ -1349,7 +1349,7 @@ static void usage(void)
"\t[-g milliseconds] delay before disconnecting (default = 0)\n"
"\t[-X mode] l2cap mode (help for list, default = basic)\n"
"\t[-a policy] chan policy (help for list, default = bredr)\n"
- "\t[-F fcs] use CRC16 check (default = 1)\n"
+ "\t[-F fcs] use CRC16 check (default = 1, affects BR/EDR only)\n"
"\t[-Q num] Max Transmit value (default = 3)\n"
"\t[-Z size] Transmission Window size (default = 63)\n"
"\t[-Y priority] socket priority\n"
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 09/12] l2test: add comment to -O <omtu> option
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
` (6 preceding siblings ...)
2026-02-25 16:17 ` [PATCH BlueZ 08/12] l2test: add comment to -F <fcs> option Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 16:40 ` Luiz Augusto von Dentz
2026-02-25 16:17 ` [PATCH BlueZ 10/12] l2test: small improvements for deferred setup Christian Eggers
` (4 subsequent siblings)
12 siblings, 1 reply; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
Clarify that this option has affect for BR/EDR sockets only.
---
tools/l2test.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/l2test.c b/tools/l2test.c
index e49289a4c774..7bdf58f0e776 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -1338,7 +1338,8 @@ static void usage(void)
printf("Options:\n"
"\t[-b bytes] [-i device] [-P psm] [-J cid]\n"
- "\t[-I imtu] [-O omtu]\n"
+ "\t[-I imtu]\n"
+ "\t[-O omtu] (affects BR/EDR sockets only)\n"
"\t[-L seconds] enable SO_LINGER\n"
"\t[-W seconds] enable deferred setup\n"
"\t[-B filename] use data packets from file\n"
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 10/12] l2test: small improvements for deferred setup
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
` (7 preceding siblings ...)
2026-02-25 16:17 ` [PATCH BlueZ 09/12] l2test: add comment to -O <omtu> option Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt Christian Eggers
` (3 subsequent siblings)
12 siblings, 0 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
- don't pass arbitrary option values to the kernel (the kernel only
checks for zero / non-zero)
- centralize authorization of new connections in listen()
- improve documentation of command line option
---
tools/l2test.c | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/tools/l2test.c b/tools/l2test.c
index 7bdf58f0e776..3351f2e0feb9 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -658,7 +658,7 @@ static void do_listen(void (*handler)(int sk))
}
/* Enable deferred setup */
- opt = defer_setup;
+ opt = !!defer_setup;
if (opt && setsockopt(sk, SOL_BLUETOOTH, BT_DEFER_SETUP,
&opt, sizeof(opt)) < 0) {
@@ -768,6 +768,8 @@ static void do_listen(void (*handler)(int sk))
/* Handle deferred setup */
if (defer_setup) {
+ int len;
+
syslog(LOG_INFO, "Waiting for %d seconds",
abs(defer_setup) - 1);
sleep(abs(defer_setup) - 1);
@@ -776,6 +778,13 @@ static void do_listen(void (*handler)(int sk))
close(nsk);
goto error;
}
+
+ len = read(sk, buf, buffer_size);
+ if (len < 0)
+ syslog(LOG_ERR, "Initial read error: %s (%d)",
+ strerror(errno), errno);
+ else
+ syslog(LOG_INFO, "Initial bytes %d", len);
}
handler(nsk);
@@ -798,15 +807,6 @@ static void dump_mode(int sk)
if (data_size < 0)
data_size = imtu;
- if (defer_setup) {
- len = read(sk, buf, data_size);
- if (len < 0)
- syslog(LOG_ERR, "Initial read error: %s (%d)",
- strerror(errno), errno);
- else
- syslog(LOG_INFO, "Initial bytes %d", len);
- }
-
syslog(LOG_INFO, "Receiving ...");
while (1) {
fd_set rset;
@@ -858,15 +858,6 @@ static void recv_mode(int sk)
if (data_size < 0)
data_size = imtu;
- if (defer_setup) {
- len = read(sk, buf, data_size);
- if (len < 0)
- syslog(LOG_ERR, "Initial read error: %s (%d)",
- strerror(errno), errno);
- else
- syslog(LOG_INFO, "Initial bytes %d", len);
- }
-
if (recv_delay)
usleep(recv_delay);
@@ -1342,6 +1333,9 @@ static void usage(void)
"\t[-O omtu] (affects BR/EDR sockets only)\n"
"\t[-L seconds] enable SO_LINGER\n"
"\t[-W seconds] enable deferred setup\n"
+ "\t 0: don't enable (default)\n"
+ "\t >0: authorize after <seconds>\n"
+ "\t <0: deny after abs(<seconds>)\n"
"\t[-B filename] use data packets from file\n"
"\t[-N num] send num frames (default = infinite)\n"
"\t[-C num] send num frames before delay (default = 1)\n"
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
` (8 preceding siblings ...)
2026-02-25 16:17 ` [PATCH BlueZ 10/12] l2test: small improvements for deferred setup Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 16:38 ` Luiz Augusto von Dentz
2026-02-25 16:17 ` [PATCH BlueZ 12/12] client/mgmt: align implementation cmd_io_cap with its documentation Christian Eggers
` (2 subsequent siblings)
12 siblings, 1 reply; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
Allow reusing in client/mgmt.c (next commit)
---
src/adapter.c | 6 +++---
src/agent.c | 24 ++++--------------------
src/agent.h | 7 -------
src/device.c | 7 ++++---
src/shared/mgmt.c | 32 ++++++++++++++++++++++++++++++++
src/shared/mgmt.h | 10 ++++++++++
6 files changed, 53 insertions(+), 33 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 9bb1950a9f7d..bfabdf9a62ef 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -9156,7 +9156,7 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
struct mgmt_cp_set_io_capability cp;
if (!btd_opts.pairable) {
- if (io_cap == IO_CAPABILITY_INVALID) {
+ if (io_cap == MGMT_IO_CAPABILITY_INVALID) {
if (adapter->current_settings & MGMT_SETTING_BONDABLE)
set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x00);
@@ -9165,8 +9165,8 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
if (!(adapter->current_settings & MGMT_SETTING_BONDABLE))
set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01);
- } else if (io_cap == IO_CAPABILITY_INVALID)
- io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
+ } else if (io_cap == MGMT_IO_CAPABILITY_INVALID)
+ io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
memset(&cp, 0, sizeof(cp));
cp.io_capability = io_cap;
diff --git a/src/agent.c b/src/agent.c
index 3696575b83e6..794f81ebf18a 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -35,6 +35,7 @@
#include "adapter.h"
#include "device.h"
#include "agent.h"
+#include "shared/mgmt.h"
#include "shared/queue.h"
#define REQUEST_TIMEOUT (60 * 1000) /* 60 seconds */
@@ -131,7 +132,7 @@ static void set_io_cap(struct btd_adapter *adapter, gpointer user_data)
if (agent)
io_cap = agent->capability;
else
- io_cap = IO_CAPABILITY_INVALID;
+ io_cap = MGMT_IO_CAPABILITY_INVALID;
adapter_set_io_capability(adapter, io_cap);
}
@@ -944,23 +945,6 @@ static void agent_destroy(gpointer data)
agent_unref(agent);
}
-static uint8_t parse_io_capability(const char *capability)
-{
- if (g_str_equal(capability, ""))
- return IO_CAPABILITY_KEYBOARDDISPLAY;
- if (g_str_equal(capability, "DisplayOnly"))
- return IO_CAPABILITY_DISPLAYONLY;
- if (g_str_equal(capability, "DisplayYesNo"))
- return IO_CAPABILITY_DISPLAYYESNO;
- if (g_str_equal(capability, "KeyboardOnly"))
- return IO_CAPABILITY_KEYBOARDONLY;
- if (g_str_equal(capability, "NoInputNoOutput"))
- return IO_CAPABILITY_NOINPUTNOOUTPUT;
- if (g_str_equal(capability, "KeyboardDisplay"))
- return IO_CAPABILITY_KEYBOARDDISPLAY;
- return IO_CAPABILITY_INVALID;
-}
-
static DBusMessage *register_agent(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -979,8 +963,8 @@ static DBusMessage *register_agent(DBusConnection *conn,
DBUS_TYPE_INVALID) == FALSE)
return btd_error_invalid_args(msg);
- cap = parse_io_capability(capability);
- if (cap == IO_CAPABILITY_INVALID)
+ cap = mgmt_parse_io_capability(capability);
+ if (cap == MGMT_IO_CAPABILITY_INVALID)
return btd_error_invalid_args(msg);
agent = agent_create(sender, path, cap);
diff --git a/src/agent.h b/src/agent.h
index bd0502030fa0..03731756849c 100644
--- a/src/agent.h
+++ b/src/agent.h
@@ -9,13 +9,6 @@
*
*/
-#define IO_CAPABILITY_DISPLAYONLY 0x00
-#define IO_CAPABILITY_DISPLAYYESNO 0x01
-#define IO_CAPABILITY_KEYBOARDONLY 0x02
-#define IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
-#define IO_CAPABILITY_KEYBOARDDISPLAY 0x04
-#define IO_CAPABILITY_INVALID 0xFF
-
struct agent;
typedef void (*agent_cb) (struct agent *agent, DBusError *err,
diff --git a/src/device.c b/src/device.c
index 0ef7dcc244d2..f7a84b807878 100644
--- a/src/device.c
+++ b/src/device.c
@@ -43,6 +43,7 @@
#include "src/shared/gatt-client.h"
#include "src/shared/gatt-server.h"
#include "src/shared/ad.h"
+#include "src/shared/mgmt.h"
#include "src/shared/timeout.h"
#include "btio/btio.h"
#include "bluetooth/mgmt.h"
@@ -3375,7 +3376,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
if (agent)
io_cap = agent_get_io_capability(agent);
else
- io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
+ io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
bonding = bonding_request_new(msg, device, bdaddr_type, agent);
@@ -6544,7 +6545,7 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
if (device->bonding->agent)
io_cap = agent_get_io_capability(device->bonding->agent);
else
- io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
+ io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
err = adapter_create_bonding(device->adapter, &device->bdaddr,
device->bdaddr_type, io_cap);
@@ -7452,7 +7453,7 @@ static gboolean device_bonding_retry(gpointer data)
if (bonding->agent)
io_cap = agent_get_io_capability(bonding->agent);
else
- io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
+ io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
err = adapter_bonding_attempt(adapter, &device->bdaddr,
device->bdaddr_type, io_cap);
diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
index 6a7eb5798cb8..300abbae1c50 100644
--- a/src/shared/mgmt.c
+++ b/src/shared/mgmt.c
@@ -81,6 +81,20 @@ struct mgmt_tlv_list {
uint16_t size;
};
+struct arg_table {
+ const char *name;
+ unsigned value;
+};
+
+static const struct arg_table iocap_arguments[] = {
+ { "DisplayOnly", MGMT_IO_CAPABILITY_DISPLAYONLY },
+ { "DisplayYesNo", MGMT_IO_CAPABILITY_DISPLAYYESNO },
+ { "KeyboardOnly", MGMT_IO_CAPABILITY_KEYBOARDONLY },
+ { "NoInputNoOutput", MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT },
+ { "KeyboardDisplay", MGMT_IO_CAPABILITY_KEYBOARDDISPLAY },
+ { NULL, 0}
+};
+
static void destroy_request(void *data)
{
struct mgmt_request *request = data;
@@ -1039,3 +1053,21 @@ uint16_t mgmt_get_mtu(struct mgmt *mgmt)
return mgmt->mtu;
}
+
+uint8_t mgmt_parse_io_capability(const char *capability)
+{
+ const char *arg;
+ int index = 0;
+
+ if (!strcmp(capability, ""))
+ return MGMT_IO_CAPABILITY_KEYBOARDDISPLAY;
+
+ while ((arg = iocap_arguments[index].name)) {
+ if (!strncmp(arg, capability, strlen(capability)))
+ return iocap_arguments[index].value;
+
+ index++;
+ }
+
+ return MGMT_IO_CAPABILITY_INVALID;
+}
diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
index 2629fbd59cf6..a4c30075f7b7 100644
--- a/src/shared/mgmt.h
+++ b/src/shared/mgmt.h
@@ -13,6 +13,14 @@
#define MGMT_VERSION(v, r) (((v) << 16) + (r))
+#define MGMT_IO_CAPABILITY_DISPLAYONLY 0x00
+#define MGMT_IO_CAPABILITY_DISPLAYYESNO 0x01
+#define MGMT_IO_CAPABILITY_KEYBOARDONLY 0x02
+#define MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
+#define MGMT_IO_CAPABILITY_KEYBOARDDISPLAY 0x04
+#define MGMT_IO_CAPABILITY_INVALID 0xFF
+
+
typedef void (*mgmt_destroy_func_t)(void *user_data);
struct mgmt;
@@ -89,3 +97,5 @@ bool mgmt_unregister_index(struct mgmt *mgmt, uint16_t index);
bool mgmt_unregister_all(struct mgmt *mgmt);
uint16_t mgmt_get_mtu(struct mgmt *mgmt);
+
+uint8_t mgmt_parse_io_capability(const char *capability);
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH BlueZ 12/12] client/mgmt: align implementation cmd_io_cap with its documentation
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
` (9 preceding siblings ...)
2026-02-25 16:17 ` [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt Christian Eggers
@ 2026-02-25 16:17 ` Christian Eggers
2026-02-25 18:07 ` [BlueZ,01/12] client/mgmt: fix compiler error bluez.test.bot
2026-02-25 18:50 ` [PATCH BlueZ 01/12] " patchwork-bot+bluetooth
12 siblings, 0 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 16:17 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Christian Eggers
Documentation of io-cap in doc/bluetootctl-mgmt.rst states that the IO
capability has to passed as string instead of an integer. Additionally
improve error checking after calling strtol().
---
client/mgmt.c | 18 +++++++++++++++---
src/shared/mgmt.c | 20 ++++++++++++++++++++
src/shared/mgmt.h | 1 +
3 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/client/mgmt.c b/client/mgmt.c
index 1d3a842afd55..430a96a9e4b7 100644
--- a/client/mgmt.c
+++ b/client/mgmt.c
@@ -4226,14 +4226,25 @@ static void io_cap_rsp(uint8_t status, uint16_t len, const void *param,
static void cmd_io_cap(int argc, char **argv)
{
struct mgmt_cp_set_io_capability cp;
- uint8_t cap;
+ long cap;
uint16_t index;
index = mgmt_index;
if (index == MGMT_INDEX_NONE)
index = 0;
- cap = strtol(argv[1], NULL, 0);
+ cap = mgmt_parse_io_capability(argv[1]);
+ if (cap == MGMT_IO_CAPABILITY_INVALID) {
+ char *endptr;
+
+ errno = 0;
+ cap = strtol(argv[1], &endptr, 0);
+ if (errno || (cap < 0) || (cap > UINT8_MAX) || *endptr) {
+ bt_shell_printf("Invalid argument %s\n", argv[1]);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+ }
+
memset(&cp, 0, sizeof(cp));
cp.io_capability = cap;
@@ -6149,7 +6160,8 @@ static const struct bt_shell_menu mgmt_menu = {
{ "conn-info", "[-t type] <remote address>",
cmd_conn_info, "Get connection information" },
{ "io-cap", "<cap>",
- cmd_io_cap, "Set IO Capability" },
+ cmd_io_cap, "Set IO Capability",
+ mgmt_iocap_generator },
{ "scan-params", "<interval> <window>",
cmd_scan_params, "Set Scan Parameters" },
{ "get-clock", "[address]",
diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
index 300abbae1c50..618bd349fa1c 100644
--- a/src/shared/mgmt.c
+++ b/src/shared/mgmt.c
@@ -1054,6 +1054,26 @@ uint16_t mgmt_get_mtu(struct mgmt *mgmt)
return mgmt->mtu;
}
+char *mgmt_iocap_generator(const char *text, int state)
+{
+ static int index, len;
+ const char *arg;
+
+ if (!state) {
+ index = 0;
+ len = strlen(text);
+ }
+
+ while ((arg = iocap_arguments[index].name)) {
+ index++;
+
+ if (!strncmp(arg, text, len))
+ return strdup(arg);
+ }
+
+ return NULL;
+}
+
uint8_t mgmt_parse_io_capability(const char *capability)
{
const char *arg;
diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
index a4c30075f7b7..58db09308c51 100644
--- a/src/shared/mgmt.h
+++ b/src/shared/mgmt.h
@@ -98,4 +98,5 @@ bool mgmt_unregister_all(struct mgmt *mgmt);
uint16_t mgmt_get_mtu(struct mgmt *mgmt);
+char *mgmt_iocap_generator(const char *text, int state);
uint8_t mgmt_parse_io_capability(const char *capability);
--
2.51.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt
2026-02-25 16:17 ` [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt Christian Eggers
@ 2026-02-25 16:38 ` Luiz Augusto von Dentz
2026-02-25 18:38 ` Christian Eggers
0 siblings, 1 reply; 21+ messages in thread
From: Luiz Augusto von Dentz @ 2026-02-25 16:38 UTC (permalink / raw)
To: Christian Eggers; +Cc: linux-bluetooth
Hi Christian,
On Wed, Feb 25, 2026 at 11:22 AM Christian Eggers <ceggers@arri.de> wrote:
>
> Allow reusing in client/mgmt.c (next commit)
> ---
> src/adapter.c | 6 +++---
> src/agent.c | 24 ++++--------------------
> src/agent.h | 7 -------
> src/device.c | 7 ++++---
Shared changed should be sent separately since its license (LGPL) is
different than the daemon (GPL).
> src/shared/mgmt.c | 32 ++++++++++++++++++++++++++++++++
> src/shared/mgmt.h | 10 ++++++++++
> 6 files changed, 53 insertions(+), 33 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 9bb1950a9f7d..bfabdf9a62ef 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -9156,7 +9156,7 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
> struct mgmt_cp_set_io_capability cp;
>
> if (!btd_opts.pairable) {
> - if (io_cap == IO_CAPABILITY_INVALID) {
> + if (io_cap == MGMT_IO_CAPABILITY_INVALID) {
> if (adapter->current_settings & MGMT_SETTING_BONDABLE)
> set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x00);
>
> @@ -9165,8 +9165,8 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
>
> if (!(adapter->current_settings & MGMT_SETTING_BONDABLE))
> set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01);
> - } else if (io_cap == IO_CAPABILITY_INVALID)
> - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> + } else if (io_cap == MGMT_IO_CAPABILITY_INVALID)
> + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
>
> memset(&cp, 0, sizeof(cp));
> cp.io_capability = io_cap;
> diff --git a/src/agent.c b/src/agent.c
> index 3696575b83e6..794f81ebf18a 100644
> --- a/src/agent.c
> +++ b/src/agent.c
> @@ -35,6 +35,7 @@
> #include "adapter.h"
> #include "device.h"
> #include "agent.h"
> +#include "shared/mgmt.h"
> #include "shared/queue.h"
>
> #define REQUEST_TIMEOUT (60 * 1000) /* 60 seconds */
> @@ -131,7 +132,7 @@ static void set_io_cap(struct btd_adapter *adapter, gpointer user_data)
> if (agent)
> io_cap = agent->capability;
> else
> - io_cap = IO_CAPABILITY_INVALID;
> + io_cap = MGMT_IO_CAPABILITY_INVALID;
>
> adapter_set_io_capability(adapter, io_cap);
> }
> @@ -944,23 +945,6 @@ static void agent_destroy(gpointer data)
> agent_unref(agent);
> }
>
> -static uint8_t parse_io_capability(const char *capability)
> -{
> - if (g_str_equal(capability, ""))
> - return IO_CAPABILITY_KEYBOARDDISPLAY;
> - if (g_str_equal(capability, "DisplayOnly"))
> - return IO_CAPABILITY_DISPLAYONLY;
> - if (g_str_equal(capability, "DisplayYesNo"))
> - return IO_CAPABILITY_DISPLAYYESNO;
> - if (g_str_equal(capability, "KeyboardOnly"))
> - return IO_CAPABILITY_KEYBOARDONLY;
> - if (g_str_equal(capability, "NoInputNoOutput"))
> - return IO_CAPABILITY_NOINPUTNOOUTPUT;
> - if (g_str_equal(capability, "KeyboardDisplay"))
> - return IO_CAPABILITY_KEYBOARDDISPLAY;
> - return IO_CAPABILITY_INVALID;
> -}
> -
> static DBusMessage *register_agent(DBusConnection *conn,
> DBusMessage *msg, void *user_data)
> {
> @@ -979,8 +963,8 @@ static DBusMessage *register_agent(DBusConnection *conn,
> DBUS_TYPE_INVALID) == FALSE)
> return btd_error_invalid_args(msg);
>
> - cap = parse_io_capability(capability);
> - if (cap == IO_CAPABILITY_INVALID)
> + cap = mgmt_parse_io_capability(capability);
> + if (cap == MGMT_IO_CAPABILITY_INVALID)
> return btd_error_invalid_args(msg);
>
> agent = agent_create(sender, path, cap);
> diff --git a/src/agent.h b/src/agent.h
> index bd0502030fa0..03731756849c 100644
> --- a/src/agent.h
> +++ b/src/agent.h
> @@ -9,13 +9,6 @@
> *
> */
>
> -#define IO_CAPABILITY_DISPLAYONLY 0x00
> -#define IO_CAPABILITY_DISPLAYYESNO 0x01
> -#define IO_CAPABILITY_KEYBOARDONLY 0x02
> -#define IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
> -#define IO_CAPABILITY_KEYBOARDDISPLAY 0x04
> -#define IO_CAPABILITY_INVALID 0xFF
> -
> struct agent;
>
> typedef void (*agent_cb) (struct agent *agent, DBusError *err,
> diff --git a/src/device.c b/src/device.c
> index 0ef7dcc244d2..f7a84b807878 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -43,6 +43,7 @@
> #include "src/shared/gatt-client.h"
> #include "src/shared/gatt-server.h"
> #include "src/shared/ad.h"
> +#include "src/shared/mgmt.h"
> #include "src/shared/timeout.h"
> #include "btio/btio.h"
> #include "bluetooth/mgmt.h"
> @@ -3375,7 +3376,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
> if (agent)
> io_cap = agent_get_io_capability(agent);
> else
> - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
>
> bonding = bonding_request_new(msg, device, bdaddr_type, agent);
>
> @@ -6544,7 +6545,7 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
> if (device->bonding->agent)
> io_cap = agent_get_io_capability(device->bonding->agent);
> else
> - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
>
> err = adapter_create_bonding(device->adapter, &device->bdaddr,
> device->bdaddr_type, io_cap);
> @@ -7452,7 +7453,7 @@ static gboolean device_bonding_retry(gpointer data)
> if (bonding->agent)
> io_cap = agent_get_io_capability(bonding->agent);
> else
> - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
>
> err = adapter_bonding_attempt(adapter, &device->bdaddr,
> device->bdaddr_type, io_cap);
> diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
> index 6a7eb5798cb8..300abbae1c50 100644
> --- a/src/shared/mgmt.c
> +++ b/src/shared/mgmt.c
> @@ -81,6 +81,20 @@ struct mgmt_tlv_list {
> uint16_t size;
> };
>
> +struct arg_table {
> + const char *name;
> + unsigned value;
> +};
> +
> +static const struct arg_table iocap_arguments[] = {
> + { "DisplayOnly", MGMT_IO_CAPABILITY_DISPLAYONLY },
> + { "DisplayYesNo", MGMT_IO_CAPABILITY_DISPLAYYESNO },
> + { "KeyboardOnly", MGMT_IO_CAPABILITY_KEYBOARDONLY },
> + { "NoInputNoOutput", MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT },
> + { "KeyboardDisplay", MGMT_IO_CAPABILITY_KEYBOARDDISPLAY },
> + { NULL, 0}
> +};
> +
> static void destroy_request(void *data)
> {
> struct mgmt_request *request = data;
> @@ -1039,3 +1053,21 @@ uint16_t mgmt_get_mtu(struct mgmt *mgmt)
>
> return mgmt->mtu;
> }
> +
> +uint8_t mgmt_parse_io_capability(const char *capability)
> +{
> + const char *arg;
> + int index = 0;
> +
> + if (!strcmp(capability, ""))
> + return MGMT_IO_CAPABILITY_KEYBOARDDISPLAY;
> +
> + while ((arg = iocap_arguments[index].name)) {
> + if (!strncmp(arg, capability, strlen(capability)))
> + return iocap_arguments[index].value;
> +
> + index++;
> + }
> +
> + return MGMT_IO_CAPABILITY_INVALID;
> +}
> diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
> index 2629fbd59cf6..a4c30075f7b7 100644
> --- a/src/shared/mgmt.h
> +++ b/src/shared/mgmt.h
> @@ -13,6 +13,14 @@
>
> #define MGMT_VERSION(v, r) (((v) << 16) + (r))
>
> +#define MGMT_IO_CAPABILITY_DISPLAYONLY 0x00
> +#define MGMT_IO_CAPABILITY_DISPLAYYESNO 0x01
> +#define MGMT_IO_CAPABILITY_KEYBOARDONLY 0x02
> +#define MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
> +#define MGMT_IO_CAPABILITY_KEYBOARDDISPLAY 0x04
> +#define MGMT_IO_CAPABILITY_INVALID 0xFF
Perhaps this should be an enum to ensure things like switch statements
do check for unhandled values.
> +
> +
> typedef void (*mgmt_destroy_func_t)(void *user_data);
>
> struct mgmt;
> @@ -89,3 +97,5 @@ bool mgmt_unregister_index(struct mgmt *mgmt, uint16_t index);
> bool mgmt_unregister_all(struct mgmt *mgmt);
>
> uint16_t mgmt_get_mtu(struct mgmt *mgmt);
> +
> +uint8_t mgmt_parse_io_capability(const char *capability);
> --
> 2.51.0
>
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH BlueZ 09/12] l2test: add comment to -O <omtu> option
2026-02-25 16:17 ` [PATCH BlueZ 09/12] l2test: add comment to -O <omtu> option Christian Eggers
@ 2026-02-25 16:40 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 21+ messages in thread
From: Luiz Augusto von Dentz @ 2026-02-25 16:40 UTC (permalink / raw)
To: Christian Eggers; +Cc: linux-bluetooth
Hi Christian,
On Wed, Feb 25, 2026 at 11:22 AM Christian Eggers <ceggers@arri.de> wrote:
>
> Clarify that this option has affect for BR/EDR sockets only.
> ---
> tools/l2test.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/l2test.c b/tools/l2test.c
> index e49289a4c774..7bdf58f0e776 100644
> --- a/tools/l2test.c
> +++ b/tools/l2test.c
> @@ -1338,7 +1338,8 @@ static void usage(void)
>
> printf("Options:\n"
> "\t[-b bytes] [-i device] [-P psm] [-J cid]\n"
> - "\t[-I imtu] [-O omtu]\n"
> + "\t[-I imtu]\n"
> + "\t[-O omtu] (affects BR/EDR sockets only)\n"
Actually this is no longer the case since:
https://github.com/bluez/bluez/commit/290f9973c9069f293367284e95fd338a221ab90d
> "\t[-L seconds] enable SO_LINGER\n"
> "\t[-W seconds] enable deferred setup\n"
> "\t[-B filename] use data packets from file\n"
> --
> 2.51.0
>
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: [BlueZ,01/12] client/mgmt: fix compiler error
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
` (10 preceding siblings ...)
2026-02-25 16:17 ` [PATCH BlueZ 12/12] client/mgmt: align implementation cmd_io_cap with its documentation Christian Eggers
@ 2026-02-25 18:07 ` bluez.test.bot
2026-02-25 18:50 ` [PATCH BlueZ 01/12] " patchwork-bot+bluetooth
12 siblings, 0 replies; 21+ messages in thread
From: bluez.test.bot @ 2026-02-25 18:07 UTC (permalink / raw)
To: linux-bluetooth, ceggers
[-- Attachment #1: Type: text/plain, Size: 1680 bytes --]
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=1057897
---Test result---
Test Summary:
CheckPatch PENDING 0.54 seconds
GitLint PENDING 0.35 seconds
BuildEll PASS 21.40 seconds
BluezMake PASS 682.28 seconds
MakeCheck PASS 19.42 seconds
MakeDistcheck PASS 255.54 seconds
CheckValgrind PASS 304.40 seconds
CheckSmatch WARNING 371.58 seconds
bluezmakeextell PASS 185.95 seconds
IncrementalBuild PENDING 0.36 seconds
ScanBuild PASS 1058.84 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
attrib/gatttool.c:236:23: warning: Variable length array is used.attrib/interactive.c: note: in included file (through /usr/include/readline/readline.h):attrib/interactive.c:175:27: warning: non-ANSI function declaration of function 'disconnect_io'attrib/interactive.c:300:23: warning: Variable length array is used.
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt
2026-02-25 16:38 ` Luiz Augusto von Dentz
@ 2026-02-25 18:38 ` Christian Eggers
2026-02-25 18:42 ` Luiz Augusto von Dentz
2026-02-26 9:48 ` Bastien Nocera
0 siblings, 2 replies; 21+ messages in thread
From: Christian Eggers @ 2026-02-25 18:38 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Wednesday, 25 February 2026, 17:38:49 CET, Luiz Augusto von Dentz wrote:
> Hi Christian,
>
> On Wed, Feb 25, 2026 at 11:22 AM Christian Eggers <ceggers@arri.de> wrote:
> >
> > Allow reusing in client/mgmt.c (next commit)
> > ---
> > src/adapter.c | 6 +++---
> > src/agent.c | 24 ++++--------------------
> > src/agent.h | 7 -------
> > src/device.c | 7 ++++---
>
> Shared changed should be sent separately since its license (LGPL) is
> different than the daemon (GPL).
done
>
> > src/shared/mgmt.c | 32 ++++++++++++++++++++++++++++++++
> > src/shared/mgmt.h | 10 ++++++++++
> > 6 files changed, 53 insertions(+), 33 deletions(-)
> >
> > diff --git a/src/adapter.c b/src/adapter.c
> > index 9bb1950a9f7d..bfabdf9a62ef 100644
> > --- a/src/adapter.c
> > +++ b/src/adapter.c
> > @@ -9156,7 +9156,7 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
> > struct mgmt_cp_set_io_capability cp;
> >
> > if (!btd_opts.pairable) {
> > - if (io_cap == IO_CAPABILITY_INVALID) {
> > + if (io_cap == MGMT_IO_CAPABILITY_INVALID) {
> > if (adapter->current_settings & MGMT_SETTING_BONDABLE)
> > set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x00);
> >
> > @@ -9165,8 +9165,8 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
> >
> > if (!(adapter->current_settings & MGMT_SETTING_BONDABLE))
> > set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01);
> > - } else if (io_cap == IO_CAPABILITY_INVALID)
> > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > + } else if (io_cap == MGMT_IO_CAPABILITY_INVALID)
> > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> >
> > memset(&cp, 0, sizeof(cp));
> > cp.io_capability = io_cap;
> > diff --git a/src/agent.c b/src/agent.c
> > index 3696575b83e6..794f81ebf18a 100644
> > --- a/src/agent.c
> > +++ b/src/agent.c
> > @@ -35,6 +35,7 @@
> > #include "adapter.h"
> > #include "device.h"
> > #include "agent.h"
> > +#include "shared/mgmt.h"
> > #include "shared/queue.h"
> >
> > #define REQUEST_TIMEOUT (60 * 1000) /* 60 seconds */
> > @@ -131,7 +132,7 @@ static void set_io_cap(struct btd_adapter *adapter, gpointer user_data)
> > if (agent)
> > io_cap = agent->capability;
> > else
> > - io_cap = IO_CAPABILITY_INVALID;
> > + io_cap = MGMT_IO_CAPABILITY_INVALID;
> >
> > adapter_set_io_capability(adapter, io_cap);
> > }
> > @@ -944,23 +945,6 @@ static void agent_destroy(gpointer data)
> > agent_unref(agent);
> > }
> >
> > -static uint8_t parse_io_capability(const char *capability)
> > -{
> > - if (g_str_equal(capability, ""))
> > - return IO_CAPABILITY_KEYBOARDDISPLAY;
> > - if (g_str_equal(capability, "DisplayOnly"))
> > - return IO_CAPABILITY_DISPLAYONLY;
> > - if (g_str_equal(capability, "DisplayYesNo"))
> > - return IO_CAPABILITY_DISPLAYYESNO;
> > - if (g_str_equal(capability, "KeyboardOnly"))
> > - return IO_CAPABILITY_KEYBOARDONLY;
> > - if (g_str_equal(capability, "NoInputNoOutput"))
> > - return IO_CAPABILITY_NOINPUTNOOUTPUT;
> > - if (g_str_equal(capability, "KeyboardDisplay"))
> > - return IO_CAPABILITY_KEYBOARDDISPLAY;
> > - return IO_CAPABILITY_INVALID;
> > -}
> > -
> > static DBusMessage *register_agent(DBusConnection *conn,
> > DBusMessage *msg, void *user_data)
> > {
> > @@ -979,8 +963,8 @@ static DBusMessage *register_agent(DBusConnection *conn,
> > DBUS_TYPE_INVALID) == FALSE)
> > return btd_error_invalid_args(msg);
> >
> > - cap = parse_io_capability(capability);
> > - if (cap == IO_CAPABILITY_INVALID)
> > + cap = mgmt_parse_io_capability(capability);
> > + if (cap == MGMT_IO_CAPABILITY_INVALID)
> > return btd_error_invalid_args(msg);
> >
> > agent = agent_create(sender, path, cap);
> > diff --git a/src/agent.h b/src/agent.h
> > index bd0502030fa0..03731756849c 100644
> > --- a/src/agent.h
> > +++ b/src/agent.h
> > @@ -9,13 +9,6 @@
> > *
> > */
> >
> > -#define IO_CAPABILITY_DISPLAYONLY 0x00
> > -#define IO_CAPABILITY_DISPLAYYESNO 0x01
> > -#define IO_CAPABILITY_KEYBOARDONLY 0x02
> > -#define IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
> > -#define IO_CAPABILITY_KEYBOARDDISPLAY 0x04
> > -#define IO_CAPABILITY_INVALID 0xFF
> > -
> > struct agent;
> >
> > typedef void (*agent_cb) (struct agent *agent, DBusError *err,
> > diff --git a/src/device.c b/src/device.c
> > index 0ef7dcc244d2..f7a84b807878 100644
> > --- a/src/device.c
> > +++ b/src/device.c
> > @@ -43,6 +43,7 @@
> > #include "src/shared/gatt-client.h"
> > #include "src/shared/gatt-server.h"
> > #include "src/shared/ad.h"
> > +#include "src/shared/mgmt.h"
> > #include "src/shared/timeout.h"
> > #include "btio/btio.h"
> > #include "bluetooth/mgmt.h"
> > @@ -3375,7 +3376,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
> > if (agent)
> > io_cap = agent_get_io_capability(agent);
> > else
> > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> >
> > bonding = bonding_request_new(msg, device, bdaddr_type, agent);
> >
> > @@ -6544,7 +6545,7 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
> > if (device->bonding->agent)
> > io_cap = agent_get_io_capability(device->bonding->agent);
> > else
> > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> >
> > err = adapter_create_bonding(device->adapter, &device->bdaddr,
> > device->bdaddr_type, io_cap);
> > @@ -7452,7 +7453,7 @@ static gboolean device_bonding_retry(gpointer data)
> > if (bonding->agent)
> > io_cap = agent_get_io_capability(bonding->agent);
> > else
> > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> >
> > err = adapter_bonding_attempt(adapter, &device->bdaddr,
> > device->bdaddr_type, io_cap);
> > diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
> > index 6a7eb5798cb8..300abbae1c50 100644
> > --- a/src/shared/mgmt.c
> > +++ b/src/shared/mgmt.c
> > @@ -81,6 +81,20 @@ struct mgmt_tlv_list {
> > uint16_t size;
> > };
> >
> > +struct arg_table {
> > + const char *name;
> > + unsigned value;
> > +};
> > +
> > +static const struct arg_table iocap_arguments[] = {
> > + { "DisplayOnly", MGMT_IO_CAPABILITY_DISPLAYONLY },
> > + { "DisplayYesNo", MGMT_IO_CAPABILITY_DISPLAYYESNO },
> > + { "KeyboardOnly", MGMT_IO_CAPABILITY_KEYBOARDONLY },
> > + { "NoInputNoOutput", MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT },
> > + { "KeyboardDisplay", MGMT_IO_CAPABILITY_KEYBOARDDISPLAY },
> > + { NULL, 0}
> > +};
> > +
> > static void destroy_request(void *data)
> > {
> > struct mgmt_request *request = data;
> > @@ -1039,3 +1053,21 @@ uint16_t mgmt_get_mtu(struct mgmt *mgmt)
> >
> > return mgmt->mtu;
> > }
> > +
> > +uint8_t mgmt_parse_io_capability(const char *capability)
> > +{
> > + const char *arg;
> > + int index = 0;
> > +
> > + if (!strcmp(capability, ""))
> > + return MGMT_IO_CAPABILITY_KEYBOARDDISPLAY;
> > +
> > + while ((arg = iocap_arguments[index].name)) {
> > + if (!strncmp(arg, capability, strlen(capability)))
> > + return iocap_arguments[index].value;
> > +
> > + index++;
> > + }
> > +
> > + return MGMT_IO_CAPABILITY_INVALID;
> > +}
> > diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
> > index 2629fbd59cf6..a4c30075f7b7 100644
> > --- a/src/shared/mgmt.h
> > +++ b/src/shared/mgmt.h
> > @@ -13,6 +13,14 @@
> >
> > #define MGMT_VERSION(v, r) (((v) << 16) + (r))
> >
> > +#define MGMT_IO_CAPABILITY_DISPLAYONLY 0x00
> > +#define MGMT_IO_CAPABILITY_DISPLAYYESNO 0x01
> > +#define MGMT_IO_CAPABILITY_KEYBOARDONLY 0x02
> > +#define MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
> > +#define MGMT_IO_CAPABILITY_KEYBOARDDISPLAY 0x04
> > +#define MGMT_IO_CAPABILITY_INVALID 0xFF
>
> Perhaps this should be an enum to ensure things like switch statements
> do check for unhandled values.
also done. But now using an enum in src/adapter.h requires also including
"src/shared/mgmt.h" in every file where src/adapter.h is used. I've made
all these changes, but maybe we should really think about include guards.
Shall I resubmit the whole series or do you want to pick the fine commits
first?
regards,
Christian
>
> > +
> > +
> > typedef void (*mgmt_destroy_func_t)(void *user_data);
> >
> > struct mgmt;
> > @@ -89,3 +97,5 @@ bool mgmt_unregister_index(struct mgmt *mgmt, uint16_t index);
> > bool mgmt_unregister_all(struct mgmt *mgmt);
> >
> > uint16_t mgmt_get_mtu(struct mgmt *mgmt);
> > +
> > +uint8_t mgmt_parse_io_capability(const char *capability);
> > --
> > 2.51.0
> >
> >
>
>
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt
2026-02-25 18:38 ` Christian Eggers
@ 2026-02-25 18:42 ` Luiz Augusto von Dentz
2026-02-26 9:36 ` Christian Eggers
2026-02-26 9:48 ` Bastien Nocera
1 sibling, 1 reply; 21+ messages in thread
From: Luiz Augusto von Dentz @ 2026-02-25 18:42 UTC (permalink / raw)
To: Christian Eggers; +Cc: linux-bluetooth
Hi Christian,
On Wed, Feb 25, 2026 at 1:38 PM Christian Eggers <ceggers@arri.de> wrote:
>
> Hi Luiz,
>
> On Wednesday, 25 February 2026, 17:38:49 CET, Luiz Augusto von Dentz wrote:
> > Hi Christian,
> >
> > On Wed, Feb 25, 2026 at 11:22 AM Christian Eggers <ceggers@arri.de> wrote:
> > >
> > > Allow reusing in client/mgmt.c (next commit)
> > > ---
> > > src/adapter.c | 6 +++---
> > > src/agent.c | 24 ++++--------------------
> > > src/agent.h | 7 -------
> > > src/device.c | 7 ++++---
> >
> > Shared changed should be sent separately since its license (LGPL) is
> > different than the daemon (GPL).
>
> done
>
> >
> > > src/shared/mgmt.c | 32 ++++++++++++++++++++++++++++++++
> > > src/shared/mgmt.h | 10 ++++++++++
> > > 6 files changed, 53 insertions(+), 33 deletions(-)
> > >
> > > diff --git a/src/adapter.c b/src/adapter.c
> > > index 9bb1950a9f7d..bfabdf9a62ef 100644
> > > --- a/src/adapter.c
> > > +++ b/src/adapter.c
> > > @@ -9156,7 +9156,7 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
> > > struct mgmt_cp_set_io_capability cp;
> > >
> > > if (!btd_opts.pairable) {
> > > - if (io_cap == IO_CAPABILITY_INVALID) {
> > > + if (io_cap == MGMT_IO_CAPABILITY_INVALID) {
> > > if (adapter->current_settings & MGMT_SETTING_BONDABLE)
> > > set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x00);
> > >
> > > @@ -9165,8 +9165,8 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
> > >
> > > if (!(adapter->current_settings & MGMT_SETTING_BONDABLE))
> > > set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01);
> > > - } else if (io_cap == IO_CAPABILITY_INVALID)
> > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > + } else if (io_cap == MGMT_IO_CAPABILITY_INVALID)
> > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > >
> > > memset(&cp, 0, sizeof(cp));
> > > cp.io_capability = io_cap;
> > > diff --git a/src/agent.c b/src/agent.c
> > > index 3696575b83e6..794f81ebf18a 100644
> > > --- a/src/agent.c
> > > +++ b/src/agent.c
> > > @@ -35,6 +35,7 @@
> > > #include "adapter.h"
> > > #include "device.h"
> > > #include "agent.h"
> > > +#include "shared/mgmt.h"
> > > #include "shared/queue.h"
> > >
> > > #define REQUEST_TIMEOUT (60 * 1000) /* 60 seconds */
> > > @@ -131,7 +132,7 @@ static void set_io_cap(struct btd_adapter *adapter, gpointer user_data)
> > > if (agent)
> > > io_cap = agent->capability;
> > > else
> > > - io_cap = IO_CAPABILITY_INVALID;
> > > + io_cap = MGMT_IO_CAPABILITY_INVALID;
> > >
> > > adapter_set_io_capability(adapter, io_cap);
> > > }
> > > @@ -944,23 +945,6 @@ static void agent_destroy(gpointer data)
> > > agent_unref(agent);
> > > }
> > >
> > > -static uint8_t parse_io_capability(const char *capability)
> > > -{
> > > - if (g_str_equal(capability, ""))
> > > - return IO_CAPABILITY_KEYBOARDDISPLAY;
> > > - if (g_str_equal(capability, "DisplayOnly"))
> > > - return IO_CAPABILITY_DISPLAYONLY;
> > > - if (g_str_equal(capability, "DisplayYesNo"))
> > > - return IO_CAPABILITY_DISPLAYYESNO;
> > > - if (g_str_equal(capability, "KeyboardOnly"))
> > > - return IO_CAPABILITY_KEYBOARDONLY;
> > > - if (g_str_equal(capability, "NoInputNoOutput"))
> > > - return IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > - if (g_str_equal(capability, "KeyboardDisplay"))
> > > - return IO_CAPABILITY_KEYBOARDDISPLAY;
> > > - return IO_CAPABILITY_INVALID;
> > > -}
> > > -
> > > static DBusMessage *register_agent(DBusConnection *conn,
> > > DBusMessage *msg, void *user_data)
> > > {
> > > @@ -979,8 +963,8 @@ static DBusMessage *register_agent(DBusConnection *conn,
> > > DBUS_TYPE_INVALID) == FALSE)
> > > return btd_error_invalid_args(msg);
> > >
> > > - cap = parse_io_capability(capability);
> > > - if (cap == IO_CAPABILITY_INVALID)
> > > + cap = mgmt_parse_io_capability(capability);
> > > + if (cap == MGMT_IO_CAPABILITY_INVALID)
> > > return btd_error_invalid_args(msg);
> > >
> > > agent = agent_create(sender, path, cap);
> > > diff --git a/src/agent.h b/src/agent.h
> > > index bd0502030fa0..03731756849c 100644
> > > --- a/src/agent.h
> > > +++ b/src/agent.h
> > > @@ -9,13 +9,6 @@
> > > *
> > > */
> > >
> > > -#define IO_CAPABILITY_DISPLAYONLY 0x00
> > > -#define IO_CAPABILITY_DISPLAYYESNO 0x01
> > > -#define IO_CAPABILITY_KEYBOARDONLY 0x02
> > > -#define IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
> > > -#define IO_CAPABILITY_KEYBOARDDISPLAY 0x04
> > > -#define IO_CAPABILITY_INVALID 0xFF
> > > -
> > > struct agent;
> > >
> > > typedef void (*agent_cb) (struct agent *agent, DBusError *err,
> > > diff --git a/src/device.c b/src/device.c
> > > index 0ef7dcc244d2..f7a84b807878 100644
> > > --- a/src/device.c
> > > +++ b/src/device.c
> > > @@ -43,6 +43,7 @@
> > > #include "src/shared/gatt-client.h"
> > > #include "src/shared/gatt-server.h"
> > > #include "src/shared/ad.h"
> > > +#include "src/shared/mgmt.h"
> > > #include "src/shared/timeout.h"
> > > #include "btio/btio.h"
> > > #include "bluetooth/mgmt.h"
> > > @@ -3375,7 +3376,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
> > > if (agent)
> > > io_cap = agent_get_io_capability(agent);
> > > else
> > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > >
> > > bonding = bonding_request_new(msg, device, bdaddr_type, agent);
> > >
> > > @@ -6544,7 +6545,7 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
> > > if (device->bonding->agent)
> > > io_cap = agent_get_io_capability(device->bonding->agent);
> > > else
> > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > >
> > > err = adapter_create_bonding(device->adapter, &device->bdaddr,
> > > device->bdaddr_type, io_cap);
> > > @@ -7452,7 +7453,7 @@ static gboolean device_bonding_retry(gpointer data)
> > > if (bonding->agent)
> > > io_cap = agent_get_io_capability(bonding->agent);
> > > else
> > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > >
> > > err = adapter_bonding_attempt(adapter, &device->bdaddr,
> > > device->bdaddr_type, io_cap);
> > > diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
> > > index 6a7eb5798cb8..300abbae1c50 100644
> > > --- a/src/shared/mgmt.c
> > > +++ b/src/shared/mgmt.c
> > > @@ -81,6 +81,20 @@ struct mgmt_tlv_list {
> > > uint16_t size;
> > > };
> > >
> > > +struct arg_table {
> > > + const char *name;
> > > + unsigned value;
> > > +};
> > > +
> > > +static const struct arg_table iocap_arguments[] = {
> > > + { "DisplayOnly", MGMT_IO_CAPABILITY_DISPLAYONLY },
> > > + { "DisplayYesNo", MGMT_IO_CAPABILITY_DISPLAYYESNO },
> > > + { "KeyboardOnly", MGMT_IO_CAPABILITY_KEYBOARDONLY },
> > > + { "NoInputNoOutput", MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT },
> > > + { "KeyboardDisplay", MGMT_IO_CAPABILITY_KEYBOARDDISPLAY },
> > > + { NULL, 0}
> > > +};
> > > +
> > > static void destroy_request(void *data)
> > > {
> > > struct mgmt_request *request = data;
> > > @@ -1039,3 +1053,21 @@ uint16_t mgmt_get_mtu(struct mgmt *mgmt)
> > >
> > > return mgmt->mtu;
> > > }
> > > +
> > > +uint8_t mgmt_parse_io_capability(const char *capability)
> > > +{
> > > + const char *arg;
> > > + int index = 0;
> > > +
> > > + if (!strcmp(capability, ""))
> > > + return MGMT_IO_CAPABILITY_KEYBOARDDISPLAY;
> > > +
> > > + while ((arg = iocap_arguments[index].name)) {
> > > + if (!strncmp(arg, capability, strlen(capability)))
> > > + return iocap_arguments[index].value;
> > > +
> > > + index++;
> > > + }
> > > +
> > > + return MGMT_IO_CAPABILITY_INVALID;
> > > +}
> > > diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
> > > index 2629fbd59cf6..a4c30075f7b7 100644
> > > --- a/src/shared/mgmt.h
> > > +++ b/src/shared/mgmt.h
> > > @@ -13,6 +13,14 @@
> > >
> > > #define MGMT_VERSION(v, r) (((v) << 16) + (r))
> > >
> > > +#define MGMT_IO_CAPABILITY_DISPLAYONLY 0x00
> > > +#define MGMT_IO_CAPABILITY_DISPLAYYESNO 0x01
> > > +#define MGMT_IO_CAPABILITY_KEYBOARDONLY 0x02
> > > +#define MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
> > > +#define MGMT_IO_CAPABILITY_KEYBOARDDISPLAY 0x04
> > > +#define MGMT_IO_CAPABILITY_INVALID 0xFF
> >
> > Perhaps this should be an enum to ensure things like switch statements
> > do check for unhandled values.
>
> also done. But now using an enum in src/adapter.h requires also including
> "src/shared/mgmt.h" in every file where src/adapter.h is used. I've made
> all these changes, but maybe we should really think about include guards.
Not following why would adapter.h requires it? Is adapter.h returning the enum?
> Shall I resubmit the whole series or do you want to pick the fine commits
> first?
Ive already applied the changes that I didn't have any comments, so
please rebase and send as a new set.
> regards,
> Christian
>
> >
> > > +
> > > +
> > > typedef void (*mgmt_destroy_func_t)(void *user_data);
> > >
> > > struct mgmt;
> > > @@ -89,3 +97,5 @@ bool mgmt_unregister_index(struct mgmt *mgmt, uint16_t index);
> > > bool mgmt_unregister_all(struct mgmt *mgmt);
> > >
> > > uint16_t mgmt_get_mtu(struct mgmt *mgmt);
> > > +
> > > +uint8_t mgmt_parse_io_capability(const char *capability);
> > > --
> > > 2.51.0
> > >
> > >
> >
> >
> >
>
>
>
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH BlueZ 01/12] client/mgmt: fix compiler error
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
` (11 preceding siblings ...)
2026-02-25 18:07 ` [BlueZ,01/12] client/mgmt: fix compiler error bluez.test.bot
@ 2026-02-25 18:50 ` patchwork-bot+bluetooth
12 siblings, 0 replies; 21+ messages in thread
From: patchwork-bot+bluetooth @ 2026-02-25 18:50 UTC (permalink / raw)
To: Christian Eggers; +Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Wed, 25 Feb 2026 17:17:04 +0100 you wrote:
> client/mgmt.c: In function ‘str2bytearray’:
> client/mgmt.c:2385:23: error: comparison of integer expressions of
> different signedness: ‘unsigned int’ and ‘long int’
> [-Werror=sign-compare]
> 2385 | if (i >= *val_len) {
> | ^~
>
> [...]
Here is the summary with links:
- [BlueZ,01/12] client/mgmt: fix compiler error
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=451fff520c8a
- [BlueZ,02/12] tools: btgatt-client/-server: replace ATT_CID with 'shared' BT_ATT_CID
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=9648dbaa8d01
- [BlueZ,03/12] src: replace ATT_CID with 'shared' BT_ATT_CID
(no matching commit)
- [BlueZ,04/12] peripheral: replace ATT_CID with shared BT_ATT_CID
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5767a7dded4f
- [BlueZ,05/12] attrib: replace ATT_CID with 'shared' BT_ATT_CID
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=cd6a809f7b43
- [BlueZ,06/12] src: replace ATT_PSM with 'shared' BT_ATT_PSM
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=776f9062c845
- [BlueZ,07/12] tools: btgatt-server: remove unused member 'fd'
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=d5c85b052eea
- [BlueZ,08/12] l2test: add comment to -F <fcs> option
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c8a7462f3490
- [BlueZ,09/12] l2test: add comment to -O <omtu> option
(no matching commit)
- [BlueZ,10/12] l2test: small improvements for deferred setup
(no matching commit)
- [BlueZ,11/12] agent: move defines and parsing for I/O capability to shared/mgnt
(no matching commit)
- [BlueZ,12/12] client/mgmt: align implementation cmd_io_cap with its documentation
(no matching commit)
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt
2026-02-25 18:42 ` Luiz Augusto von Dentz
@ 2026-02-26 9:36 ` Christian Eggers
2026-02-26 13:59 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 21+ messages in thread
From: Christian Eggers @ 2026-02-26 9:36 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Wednesday, 25 February 2026, 19:42:26 CET, Luiz Augusto von Dentz wrote:
> Hi Christian,
>
> On Wed, Feb 25, 2026 at 1:38 PM Christian Eggers <ceggers@arri.de> wrote:
> >
> > Hi Luiz,
> >
> > On Wednesday, 25 February 2026, 17:38:49 CET, Luiz Augusto von Dentz wrote:
> > > Hi Christian,
> > >
> > > On Wed, Feb 25, 2026 at 11:22 AM Christian Eggers <ceggers@arri.de> wrote:
> > > >
> > > > Allow reusing in client/mgmt.c (next commit)
> > > > ---
> > > > src/adapter.c | 6 +++---
> > > > src/agent.c | 24 ++++--------------------
> > > > src/agent.h | 7 -------
> > > > src/device.c | 7 ++++---
> > >
> > > Shared changed should be sent separately since its license (LGPL) is
> > > different than the daemon (GPL).
> >
> > done
> >
> > >
> > > > src/shared/mgmt.c | 32 ++++++++++++++++++++++++++++++++
> > > > src/shared/mgmt.h | 10 ++++++++++
> > > > 6 files changed, 53 insertions(+), 33 deletions(-)
> > > >
> > > > diff --git a/src/adapter.c b/src/adapter.c
> > > > index 9bb1950a9f7d..bfabdf9a62ef 100644
> > > > --- a/src/adapter.c
> > > > +++ b/src/adapter.c
> > > > @@ -9156,7 +9156,7 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
> > > > struct mgmt_cp_set_io_capability cp;
> > > >
> > > > if (!btd_opts.pairable) {
> > > > - if (io_cap == IO_CAPABILITY_INVALID) {
> > > > + if (io_cap == MGMT_IO_CAPABILITY_INVALID) {
> > > > if (adapter->current_settings & MGMT_SETTING_BONDABLE)
> > > > set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x00);
> > > >
> > > > @@ -9165,8 +9165,8 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
> > > >
> > > > if (!(adapter->current_settings & MGMT_SETTING_BONDABLE))
> > > > set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01);
> > > > - } else if (io_cap == IO_CAPABILITY_INVALID)
> > > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > + } else if (io_cap == MGMT_IO_CAPABILITY_INVALID)
> > > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > >
> > > > memset(&cp, 0, sizeof(cp));
> > > > cp.io_capability = io_cap;
> > > > diff --git a/src/agent.c b/src/agent.c
> > > > index 3696575b83e6..794f81ebf18a 100644
> > > > --- a/src/agent.c
> > > > +++ b/src/agent.c
> > > > @@ -35,6 +35,7 @@
> > > > #include "adapter.h"
> > > > #include "device.h"
> > > > #include "agent.h"
> > > > +#include "shared/mgmt.h"
> > > > #include "shared/queue.h"
> > > >
> > > > #define REQUEST_TIMEOUT (60 * 1000) /* 60 seconds */
> > > > @@ -131,7 +132,7 @@ static void set_io_cap(struct btd_adapter *adapter, gpointer user_data)
> > > > if (agent)
> > > > io_cap = agent->capability;
> > > > else
> > > > - io_cap = IO_CAPABILITY_INVALID;
> > > > + io_cap = MGMT_IO_CAPABILITY_INVALID;
> > > >
> > > > adapter_set_io_capability(adapter, io_cap);
> > > > }
> > > > @@ -944,23 +945,6 @@ static void agent_destroy(gpointer data)
> > > > agent_unref(agent);
> > > > }
> > > >
> > > > -static uint8_t parse_io_capability(const char *capability)
> > > > -{
> > > > - if (g_str_equal(capability, ""))
> > > > - return IO_CAPABILITY_KEYBOARDDISPLAY;
> > > > - if (g_str_equal(capability, "DisplayOnly"))
> > > > - return IO_CAPABILITY_DISPLAYONLY;
> > > > - if (g_str_equal(capability, "DisplayYesNo"))
> > > > - return IO_CAPABILITY_DISPLAYYESNO;
> > > > - if (g_str_equal(capability, "KeyboardOnly"))
> > > > - return IO_CAPABILITY_KEYBOARDONLY;
> > > > - if (g_str_equal(capability, "NoInputNoOutput"))
> > > > - return IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > - if (g_str_equal(capability, "KeyboardDisplay"))
> > > > - return IO_CAPABILITY_KEYBOARDDISPLAY;
> > > > - return IO_CAPABILITY_INVALID;
> > > > -}
> > > > -
> > > > static DBusMessage *register_agent(DBusConnection *conn,
> > > > DBusMessage *msg, void *user_data)
> > > > {
> > > > @@ -979,8 +963,8 @@ static DBusMessage *register_agent(DBusConnection *conn,
> > > > DBUS_TYPE_INVALID) == FALSE)
> > > > return btd_error_invalid_args(msg);
> > > >
> > > > - cap = parse_io_capability(capability);
> > > > - if (cap == IO_CAPABILITY_INVALID)
> > > > + cap = mgmt_parse_io_capability(capability);
> > > > + if (cap == MGMT_IO_CAPABILITY_INVALID)
> > > > return btd_error_invalid_args(msg);
> > > >
> > > > agent = agent_create(sender, path, cap);
> > > > diff --git a/src/agent.h b/src/agent.h
> > > > index bd0502030fa0..03731756849c 100644
> > > > --- a/src/agent.h
> > > > +++ b/src/agent.h
> > > > @@ -9,13 +9,6 @@
> > > > *
> > > > */
> > > >
> > > > -#define IO_CAPABILITY_DISPLAYONLY 0x00
> > > > -#define IO_CAPABILITY_DISPLAYYESNO 0x01
> > > > -#define IO_CAPABILITY_KEYBOARDONLY 0x02
> > > > -#define IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
> > > > -#define IO_CAPABILITY_KEYBOARDDISPLAY 0x04
> > > > -#define IO_CAPABILITY_INVALID 0xFF
> > > > -
> > > > struct agent;
> > > >
> > > > typedef void (*agent_cb) (struct agent *agent, DBusError *err,
> > > > diff --git a/src/device.c b/src/device.c
> > > > index 0ef7dcc244d2..f7a84b807878 100644
> > > > --- a/src/device.c
> > > > +++ b/src/device.c
> > > > @@ -43,6 +43,7 @@
> > > > #include "src/shared/gatt-client.h"
> > > > #include "src/shared/gatt-server.h"
> > > > #include "src/shared/ad.h"
> > > > +#include "src/shared/mgmt.h"
> > > > #include "src/shared/timeout.h"
> > > > #include "btio/btio.h"
> > > > #include "bluetooth/mgmt.h"
> > > > @@ -3375,7 +3376,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
> > > > if (agent)
> > > > io_cap = agent_get_io_capability(agent);
> > > > else
> > > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > >
> > > > bonding = bonding_request_new(msg, device, bdaddr_type, agent);
> > > >
> > > > @@ -6544,7 +6545,7 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
> > > > if (device->bonding->agent)
> > > > io_cap = agent_get_io_capability(device->bonding->agent);
> > > > else
> > > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > >
> > > > err = adapter_create_bonding(device->adapter, &device->bdaddr,
> > > > device->bdaddr_type, io_cap);
> > > > @@ -7452,7 +7453,7 @@ static gboolean device_bonding_retry(gpointer data)
> > > > if (bonding->agent)
> > > > io_cap = agent_get_io_capability(bonding->agent);
> > > > else
> > > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > >
> > > > err = adapter_bonding_attempt(adapter, &device->bdaddr,
> > > > device->bdaddr_type, io_cap);
> > > > diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
> > > > index 6a7eb5798cb8..300abbae1c50 100644
> > > > --- a/src/shared/mgmt.c
> > > > +++ b/src/shared/mgmt.c
> > > > @@ -81,6 +81,20 @@ struct mgmt_tlv_list {
> > > > uint16_t size;
> > > > };
> > > >
> > > > +struct arg_table {
> > > > + const char *name;
> > > > + unsigned value;
> > > > +};
> > > > +
> > > > +static const struct arg_table iocap_arguments[] = {
> > > > + { "DisplayOnly", MGMT_IO_CAPABILITY_DISPLAYONLY },
> > > > + { "DisplayYesNo", MGMT_IO_CAPABILITY_DISPLAYYESNO },
> > > > + { "KeyboardOnly", MGMT_IO_CAPABILITY_KEYBOARDONLY },
> > > > + { "NoInputNoOutput", MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT },
> > > > + { "KeyboardDisplay", MGMT_IO_CAPABILITY_KEYBOARDDISPLAY },
> > > > + { NULL, 0}
> > > > +};
> > > > +
> > > > static void destroy_request(void *data)
> > > > {
> > > > struct mgmt_request *request = data;
> > > > @@ -1039,3 +1053,21 @@ uint16_t mgmt_get_mtu(struct mgmt *mgmt)
> > > >
> > > > return mgmt->mtu;
> > > > }
> > > > +
> > > > +uint8_t mgmt_parse_io_capability(const char *capability)
> > > > +{
> > > > + const char *arg;
> > > > + int index = 0;
> > > > +
> > > > + if (!strcmp(capability, ""))
> > > > + return MGMT_IO_CAPABILITY_KEYBOARDDISPLAY;
> > > > +
> > > > + while ((arg = iocap_arguments[index].name)) {
> > > > + if (!strncmp(arg, capability, strlen(capability)))
> > > > + return iocap_arguments[index].value;
> > > > +
> > > > + index++;
> > > > + }
> > > > +
> > > > + return MGMT_IO_CAPABILITY_INVALID;
> > > > +}
> > > > diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
> > > > index 2629fbd59cf6..a4c30075f7b7 100644
> > > > --- a/src/shared/mgmt.h
> > > > +++ b/src/shared/mgmt.h
> > > > @@ -13,6 +13,14 @@
> > > >
> > > > #define MGMT_VERSION(v, r) (((v) << 16) + (r))
> > > >
> > > > +#define MGMT_IO_CAPABILITY_DISPLAYONLY 0x00
> > > > +#define MGMT_IO_CAPABILITY_DISPLAYYESNO 0x01
> > > > +#define MGMT_IO_CAPABILITY_KEYBOARDONLY 0x02
> > > > +#define MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
> > > > +#define MGMT_IO_CAPABILITY_KEYBOARDDISPLAY 0x04
> > > > +#define MGMT_IO_CAPABILITY_INVALID 0xFF
> > >
> > > Perhaps this should be an enum to ensure things like switch statements
> > > do check for unhandled values.
> >
> > also done. But now using an enum in src/adapter.h requires also including
> > "src/shared/mgmt.h" in every file where src/adapter.h is used. I've made
> > all these changes, but maybe we should really think about include guards.
>
> Not following why would adapter.h requires it? Is adapter.h returning the enum?
diff --git a/src/adapter.h b/src/adapter.h
index 7a7e5c8f9dfd..377c6a8789fb 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -207,15 +207,18 @@ int btd_adapter_passkey_reply(struct btd_adapter *adapter,
uint32_t passkey);
int adapter_create_bonding(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
- uint8_t addr_type, uint8_t io_cap);
+ uint8_t addr_type,
+ enum mgmt_io_capability io_cap);
int adapter_bonding_attempt(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
- uint8_t addr_type, uint8_t io_cap);
+ uint8_t addr_type,
+ enum mgmt_io_capability io_cap);
int adapter_cancel_bonding(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
uint8_t addr_type);
-int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap);
+int adapter_set_io_capability(struct btd_adapter *adapter,
+ enum mgmt_io_capability io_cap);
int btd_adapter_read_local_oob_data(struct btd_adapter *adapter);
Compiler output:
In file included from plugins/autopair.c:28:
./src/adapter.h:211:54: warning: ‘enum mgmt_io_capability’ declared inside parameter list will not be visible outside of this definition or declaration
211 | enum mgmt_io_capability io_cap);
| ^~~~~~~~~~~~~~~~~~
./src/adapter.h:215:54: warning: ‘enum mgmt_io_capability’ declared inside parameter list will not be visible outside of this definition or declaration
215 | enum mgmt_io_capability io_cap);
| ^~~~~~~~~~~~~~~~~~
./src/adapter.h:221:54: warning: ‘enum mgmt_io_capability’ declared inside parameter list will not be visible outside of this definition or declaration
221 | enum mgmt_io_capability io_cap);
| ^~~~~~~~~~~~~~~~~~
So, `enum mgmt_io_capability` is not used as a return value, but also using it
as function argument requires prior declaration.
AFAIK, forward declaration of C-style enum is not possible. So if
`enum mgmt_io_capability` is declared in shared/mgmt.h, this header must be
included prior src/adapter.h
Currently, src/adapter.h is included by 56 files. In nearly all of them, I had
to add inclusion of src/shared/mgmt.h.
regards,
Christian
>
> > Shall I resubmit the whole series or do you want to pick the fine commits
> > first?
>
> Ive already applied the changes that I didn't have any comments, so
> please rebase and send as a new set.
>
> > regards,
> > Christian
> >
> > >
> > > > +
> > > > +
> > > > typedef void (*mgmt_destroy_func_t)(void *user_data);
> > > >
> > > > struct mgmt;
> > > > @@ -89,3 +97,5 @@ bool mgmt_unregister_index(struct mgmt *mgmt, uint16_t index);
> > > > bool mgmt_unregister_all(struct mgmt *mgmt);
> > > >
> > > > uint16_t mgmt_get_mtu(struct mgmt *mgmt);
> > > > +
> > > > +uint8_t mgmt_parse_io_capability(const char *capability);
> > > > --
> > > > 2.51.0
> > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt
2026-02-25 18:38 ` Christian Eggers
2026-02-25 18:42 ` Luiz Augusto von Dentz
@ 2026-02-26 9:48 ` Bastien Nocera
1 sibling, 0 replies; 21+ messages in thread
From: Bastien Nocera @ 2026-02-26 9:48 UTC (permalink / raw)
To: Christian Eggers, Luiz Augusto von Dentz; +Cc: linux-bluetooth
On Wed, 2026-02-25 at 19:38 +0100, Christian Eggers wrote:
> > Perhaps this should be an enum to ensure things like switch
> > statements
> > do check for unhandled values.
>
> also done. But now using an enum in src/adapter.h requires also
> including
> "src/shared/mgmt.h" in every file where src/adapter.h is used. I've
> made
> all these changes, but maybe we should really think about include
> guards.
#pragma once
should be all that's needed, at the top of the header in question. IMO,
there's really no need to start adding it everywhere, but it's a good
time to set an example on how it can be done when needed.
> Shall I resubmit the whole series or do you want to pick the fine
> commits
> first?
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt
2026-02-26 9:36 ` Christian Eggers
@ 2026-02-26 13:59 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 21+ messages in thread
From: Luiz Augusto von Dentz @ 2026-02-26 13:59 UTC (permalink / raw)
To: Christian Eggers; +Cc: linux-bluetooth
Hi Christian,
On Thu, Feb 26, 2026 at 4:36 AM Christian Eggers <ceggers@arri.de> wrote:
>
> Hi Luiz,
>
> On Wednesday, 25 February 2026, 19:42:26 CET, Luiz Augusto von Dentz wrote:
> > Hi Christian,
> >
> > On Wed, Feb 25, 2026 at 1:38 PM Christian Eggers <ceggers@arri.de> wrote:
> > >
> > > Hi Luiz,
> > >
> > > On Wednesday, 25 February 2026, 17:38:49 CET, Luiz Augusto von Dentz wrote:
> > > > Hi Christian,
> > > >
> > > > On Wed, Feb 25, 2026 at 11:22 AM Christian Eggers <ceggers@arri.de> wrote:
> > > > >
> > > > > Allow reusing in client/mgmt.c (next commit)
> > > > > ---
> > > > > src/adapter.c | 6 +++---
> > > > > src/agent.c | 24 ++++--------------------
> > > > > src/agent.h | 7 -------
> > > > > src/device.c | 7 ++++---
> > > >
> > > > Shared changed should be sent separately since its license (LGPL) is
> > > > different than the daemon (GPL).
> > >
> > > done
> > >
> > > >
> > > > > src/shared/mgmt.c | 32 ++++++++++++++++++++++++++++++++
> > > > > src/shared/mgmt.h | 10 ++++++++++
> > > > > 6 files changed, 53 insertions(+), 33 deletions(-)
> > > > >
> > > > > diff --git a/src/adapter.c b/src/adapter.c
> > > > > index 9bb1950a9f7d..bfabdf9a62ef 100644
> > > > > --- a/src/adapter.c
> > > > > +++ b/src/adapter.c
> > > > > @@ -9156,7 +9156,7 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
> > > > > struct mgmt_cp_set_io_capability cp;
> > > > >
> > > > > if (!btd_opts.pairable) {
> > > > > - if (io_cap == IO_CAPABILITY_INVALID) {
> > > > > + if (io_cap == MGMT_IO_CAPABILITY_INVALID) {
> > > > > if (adapter->current_settings & MGMT_SETTING_BONDABLE)
> > > > > set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x00);
> > > > >
> > > > > @@ -9165,8 +9165,8 @@ int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
> > > > >
> > > > > if (!(adapter->current_settings & MGMT_SETTING_BONDABLE))
> > > > > set_mode(adapter, MGMT_OP_SET_BONDABLE, 0x01);
> > > > > - } else if (io_cap == IO_CAPABILITY_INVALID)
> > > > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > > + } else if (io_cap == MGMT_IO_CAPABILITY_INVALID)
> > > > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > >
> > > > > memset(&cp, 0, sizeof(cp));
> > > > > cp.io_capability = io_cap;
> > > > > diff --git a/src/agent.c b/src/agent.c
> > > > > index 3696575b83e6..794f81ebf18a 100644
> > > > > --- a/src/agent.c
> > > > > +++ b/src/agent.c
> > > > > @@ -35,6 +35,7 @@
> > > > > #include "adapter.h"
> > > > > #include "device.h"
> > > > > #include "agent.h"
> > > > > +#include "shared/mgmt.h"
> > > > > #include "shared/queue.h"
> > > > >
> > > > > #define REQUEST_TIMEOUT (60 * 1000) /* 60 seconds */
> > > > > @@ -131,7 +132,7 @@ static void set_io_cap(struct btd_adapter *adapter, gpointer user_data)
> > > > > if (agent)
> > > > > io_cap = agent->capability;
> > > > > else
> > > > > - io_cap = IO_CAPABILITY_INVALID;
> > > > > + io_cap = MGMT_IO_CAPABILITY_INVALID;
> > > > >
> > > > > adapter_set_io_capability(adapter, io_cap);
> > > > > }
> > > > > @@ -944,23 +945,6 @@ static void agent_destroy(gpointer data)
> > > > > agent_unref(agent);
> > > > > }
> > > > >
> > > > > -static uint8_t parse_io_capability(const char *capability)
> > > > > -{
> > > > > - if (g_str_equal(capability, ""))
> > > > > - return IO_CAPABILITY_KEYBOARDDISPLAY;
> > > > > - if (g_str_equal(capability, "DisplayOnly"))
> > > > > - return IO_CAPABILITY_DISPLAYONLY;
> > > > > - if (g_str_equal(capability, "DisplayYesNo"))
> > > > > - return IO_CAPABILITY_DISPLAYYESNO;
> > > > > - if (g_str_equal(capability, "KeyboardOnly"))
> > > > > - return IO_CAPABILITY_KEYBOARDONLY;
> > > > > - if (g_str_equal(capability, "NoInputNoOutput"))
> > > > > - return IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > > - if (g_str_equal(capability, "KeyboardDisplay"))
> > > > > - return IO_CAPABILITY_KEYBOARDDISPLAY;
> > > > > - return IO_CAPABILITY_INVALID;
> > > > > -}
> > > > > -
> > > > > static DBusMessage *register_agent(DBusConnection *conn,
> > > > > DBusMessage *msg, void *user_data)
> > > > > {
> > > > > @@ -979,8 +963,8 @@ static DBusMessage *register_agent(DBusConnection *conn,
> > > > > DBUS_TYPE_INVALID) == FALSE)
> > > > > return btd_error_invalid_args(msg);
> > > > >
> > > > > - cap = parse_io_capability(capability);
> > > > > - if (cap == IO_CAPABILITY_INVALID)
> > > > > + cap = mgmt_parse_io_capability(capability);
> > > > > + if (cap == MGMT_IO_CAPABILITY_INVALID)
> > > > > return btd_error_invalid_args(msg);
> > > > >
> > > > > agent = agent_create(sender, path, cap);
> > > > > diff --git a/src/agent.h b/src/agent.h
> > > > > index bd0502030fa0..03731756849c 100644
> > > > > --- a/src/agent.h
> > > > > +++ b/src/agent.h
> > > > > @@ -9,13 +9,6 @@
> > > > > *
> > > > > */
> > > > >
> > > > > -#define IO_CAPABILITY_DISPLAYONLY 0x00
> > > > > -#define IO_CAPABILITY_DISPLAYYESNO 0x01
> > > > > -#define IO_CAPABILITY_KEYBOARDONLY 0x02
> > > > > -#define IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
> > > > > -#define IO_CAPABILITY_KEYBOARDDISPLAY 0x04
> > > > > -#define IO_CAPABILITY_INVALID 0xFF
> > > > > -
> > > > > struct agent;
> > > > >
> > > > > typedef void (*agent_cb) (struct agent *agent, DBusError *err,
> > > > > diff --git a/src/device.c b/src/device.c
> > > > > index 0ef7dcc244d2..f7a84b807878 100644
> > > > > --- a/src/device.c
> > > > > +++ b/src/device.c
> > > > > @@ -43,6 +43,7 @@
> > > > > #include "src/shared/gatt-client.h"
> > > > > #include "src/shared/gatt-server.h"
> > > > > #include "src/shared/ad.h"
> > > > > +#include "src/shared/mgmt.h"
> > > > > #include "src/shared/timeout.h"
> > > > > #include "btio/btio.h"
> > > > > #include "bluetooth/mgmt.h"
> > > > > @@ -3375,7 +3376,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
> > > > > if (agent)
> > > > > io_cap = agent_get_io_capability(agent);
> > > > > else
> > > > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > >
> > > > > bonding = bonding_request_new(msg, device, bdaddr_type, agent);
> > > > >
> > > > > @@ -6544,7 +6545,7 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
> > > > > if (device->bonding->agent)
> > > > > io_cap = agent_get_io_capability(device->bonding->agent);
> > > > > else
> > > > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > >
> > > > > err = adapter_create_bonding(device->adapter, &device->bdaddr,
> > > > > device->bdaddr_type, io_cap);
> > > > > @@ -7452,7 +7453,7 @@ static gboolean device_bonding_retry(gpointer data)
> > > > > if (bonding->agent)
> > > > > io_cap = agent_get_io_capability(bonding->agent);
> > > > > else
> > > > > - io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > > + io_cap = MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT;
> > > > >
> > > > > err = adapter_bonding_attempt(adapter, &device->bdaddr,
> > > > > device->bdaddr_type, io_cap);
> > > > > diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
> > > > > index 6a7eb5798cb8..300abbae1c50 100644
> > > > > --- a/src/shared/mgmt.c
> > > > > +++ b/src/shared/mgmt.c
> > > > > @@ -81,6 +81,20 @@ struct mgmt_tlv_list {
> > > > > uint16_t size;
> > > > > };
> > > > >
> > > > > +struct arg_table {
> > > > > + const char *name;
> > > > > + unsigned value;
> > > > > +};
> > > > > +
> > > > > +static const struct arg_table iocap_arguments[] = {
> > > > > + { "DisplayOnly", MGMT_IO_CAPABILITY_DISPLAYONLY },
> > > > > + { "DisplayYesNo", MGMT_IO_CAPABILITY_DISPLAYYESNO },
> > > > > + { "KeyboardOnly", MGMT_IO_CAPABILITY_KEYBOARDONLY },
> > > > > + { "NoInputNoOutput", MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT },
> > > > > + { "KeyboardDisplay", MGMT_IO_CAPABILITY_KEYBOARDDISPLAY },
> > > > > + { NULL, 0}
> > > > > +};
> > > > > +
> > > > > static void destroy_request(void *data)
> > > > > {
> > > > > struct mgmt_request *request = data;
> > > > > @@ -1039,3 +1053,21 @@ uint16_t mgmt_get_mtu(struct mgmt *mgmt)
> > > > >
> > > > > return mgmt->mtu;
> > > > > }
> > > > > +
> > > > > +uint8_t mgmt_parse_io_capability(const char *capability)
> > > > > +{
> > > > > + const char *arg;
> > > > > + int index = 0;
> > > > > +
> > > > > + if (!strcmp(capability, ""))
> > > > > + return MGMT_IO_CAPABILITY_KEYBOARDDISPLAY;
> > > > > +
> > > > > + while ((arg = iocap_arguments[index].name)) {
> > > > > + if (!strncmp(arg, capability, strlen(capability)))
> > > > > + return iocap_arguments[index].value;
> > > > > +
> > > > > + index++;
> > > > > + }
> > > > > +
> > > > > + return MGMT_IO_CAPABILITY_INVALID;
> > > > > +}
> > > > > diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
> > > > > index 2629fbd59cf6..a4c30075f7b7 100644
> > > > > --- a/src/shared/mgmt.h
> > > > > +++ b/src/shared/mgmt.h
> > > > > @@ -13,6 +13,14 @@
> > > > >
> > > > > #define MGMT_VERSION(v, r) (((v) << 16) + (r))
> > > > >
> > > > > +#define MGMT_IO_CAPABILITY_DISPLAYONLY 0x00
> > > > > +#define MGMT_IO_CAPABILITY_DISPLAYYESNO 0x01
> > > > > +#define MGMT_IO_CAPABILITY_KEYBOARDONLY 0x02
> > > > > +#define MGMT_IO_CAPABILITY_NOINPUTNOOUTPUT 0x03
> > > > > +#define MGMT_IO_CAPABILITY_KEYBOARDDISPLAY 0x04
> > > > > +#define MGMT_IO_CAPABILITY_INVALID 0xFF
> > > >
> > > > Perhaps this should be an enum to ensure things like switch statements
> > > > do check for unhandled values.
> > >
> > > also done. But now using an enum in src/adapter.h requires also including
> > > "src/shared/mgmt.h" in every file where src/adapter.h is used. I've made
> > > all these changes, but maybe we should really think about include guards.
> >
> > Not following why would adapter.h requires it? Is adapter.h returning the enum?
>
> diff --git a/src/adapter.h b/src/adapter.h
> index 7a7e5c8f9dfd..377c6a8789fb 100644
> --- a/src/adapter.h
> +++ b/src/adapter.h
> @@ -207,15 +207,18 @@ int btd_adapter_passkey_reply(struct btd_adapter *adapter,
> uint32_t passkey);
>
> int adapter_create_bonding(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
> - uint8_t addr_type, uint8_t io_cap);
> + uint8_t addr_type,
> + enum mgmt_io_capability io_cap);
>
> int adapter_bonding_attempt(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
> - uint8_t addr_type, uint8_t io_cap);
> + uint8_t addr_type,
> + enum mgmt_io_capability io_cap);
>
> int adapter_cancel_bonding(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
> uint8_t addr_type);
>
> -int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap);
> +int adapter_set_io_capability(struct btd_adapter *adapter,
> + enum mgmt_io_capability io_cap);
I'd keep these as `uint8_t` to limit the necessary changes, as the
objective here is fixing the bluetoothctl mgmt command. We can attempt
cleanup in a different set.
> int btd_adapter_read_local_oob_data(struct btd_adapter *adapter);
>
>
> Compiler output:
> In file included from plugins/autopair.c:28:
> ./src/adapter.h:211:54: warning: ‘enum mgmt_io_capability’ declared inside parameter list will not be visible outside of this definition or declaration
> 211 | enum mgmt_io_capability io_cap);
> | ^~~~~~~~~~~~~~~~~~
> ./src/adapter.h:215:54: warning: ‘enum mgmt_io_capability’ declared inside parameter list will not be visible outside of this definition or declaration
> 215 | enum mgmt_io_capability io_cap);
> | ^~~~~~~~~~~~~~~~~~
> ./src/adapter.h:221:54: warning: ‘enum mgmt_io_capability’ declared inside parameter list will not be visible outside of this definition or declaration
> 221 | enum mgmt_io_capability io_cap);
> | ^~~~~~~~~~~~~~~~~~
>
>
> So, `enum mgmt_io_capability` is not used as a return value, but also using it
> as function argument requires prior declaration.
>
> AFAIK, forward declaration of C-style enum is not possible. So if
> `enum mgmt_io_capability` is declared in shared/mgmt.h, this header must be
> included prior src/adapter.h
>
> Currently, src/adapter.h is included by 56 files. In nearly all of them, I had
> to add inclusion of src/shared/mgmt.h.
>
> regards,
> Christian
> >
> > > Shall I resubmit the whole series or do you want to pick the fine commits
> > > first?
> >
> > Ive already applied the changes that I didn't have any comments, so
> > please rebase and send as a new set.
> >
> > > regards,
> > > Christian
> > >
> > > >
> > > > > +
> > > > > +
> > > > > typedef void (*mgmt_destroy_func_t)(void *user_data);
> > > > >
> > > > > struct mgmt;
> > > > > @@ -89,3 +97,5 @@ bool mgmt_unregister_index(struct mgmt *mgmt, uint16_t index);
> > > > > bool mgmt_unregister_all(struct mgmt *mgmt);
> > > > >
> > > > > uint16_t mgmt_get_mtu(struct mgmt *mgmt);
> > > > > +
> > > > > +uint8_t mgmt_parse_io_capability(const char *capability);
> > > > > --
> > > > > 2.51.0
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
>
>
>
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2026-02-26 13:59 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-25 16:17 [PATCH BlueZ 01/12] client/mgmt: fix compiler error Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 02/12] tools: btgatt-client/-server: replace ATT_CID with 'shared' BT_ATT_CID Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 03/12] src: " Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 04/12] peripheral: replace ATT_CID with shared BT_ATT_CID Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 05/12] attrib: replace ATT_CID with 'shared' BT_ATT_CID Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 06/12] src: replace ATT_PSM with 'shared' BT_ATT_PSM Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 07/12] tools: btgatt-server: remove unused member 'fd' Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 08/12] l2test: add comment to -F <fcs> option Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 09/12] l2test: add comment to -O <omtu> option Christian Eggers
2026-02-25 16:40 ` Luiz Augusto von Dentz
2026-02-25 16:17 ` [PATCH BlueZ 10/12] l2test: small improvements for deferred setup Christian Eggers
2026-02-25 16:17 ` [PATCH BlueZ 11/12] agent: move defines and parsing for I/O capability to shared/mgnt Christian Eggers
2026-02-25 16:38 ` Luiz Augusto von Dentz
2026-02-25 18:38 ` Christian Eggers
2026-02-25 18:42 ` Luiz Augusto von Dentz
2026-02-26 9:36 ` Christian Eggers
2026-02-26 13:59 ` Luiz Augusto von Dentz
2026-02-26 9:48 ` Bastien Nocera
2026-02-25 16:17 ` [PATCH BlueZ 12/12] client/mgmt: align implementation cmd_io_cap with its documentation Christian Eggers
2026-02-25 18:07 ` [BlueZ,01/12] client/mgmt: fix compiler error bluez.test.bot
2026-02-25 18:50 ` [PATCH BlueZ 01/12] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox