Skip to content

Commit ea7e265

Browse files
kapi-norlubos
authored andcommitted
[nrf fromtree] mgmt: mcumgr: transport: bluetooth: add all gatt permission levels
Added new Kconfigs for defining permission level of GATT characteristics that are part of the Bluetooth SMP service in the MCUmgr subsys. Removed the CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN as the new Kconfig options are mutually exclusive and need to be groupa as the Kconfig choice option. Signed-off-by: Kamil Piszczek <[email protected]> (cherry picked from commit 8c0bc54)
1 parent 96c36f7 commit ea7e265

File tree

6 files changed

+48
-16
lines changed

6 files changed

+48
-16
lines changed

doc/releases/migration-guide-4.0.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ hawkBit
283283
MCUmgr
284284
======
285285

286+
* The ``MCUMGR_TRANSPORT_BT_AUTHEN`` Kconfig option from the :kconfig:option:`CONFIG_MCUMGR_TRANSPORT_BT` MCUmgr transport has been replaced with the :kconfig:option:`CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW` Kconfig choice.
287+
The requirement for Bluetooth authentication is now indicated by the :kconfig:option:`CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW_AUTHEN` Kconfig option.
288+
To remove the default requirement for Bluetooth authentication it is necessary to enable the :kconfig:option:`CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW` Kconfig option in the project configuration.
289+
286290
Modem
287291
=====
288292

samples/subsys/mgmt/mcumgr/smp_svr/overlay-bt.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
99

1010
# Enable the Bluetooth mcumgr transport (unauthenticated).
1111
CONFIG_MCUMGR_TRANSPORT_BT=y
12-
CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n
1312
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y
1413

1514
# Enable the Shell mcumgr transport.

scripts/utils/migrate_mcumgr_kconfigs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
"MCUMGR_BUF_SIZE" : "MCUMGR_TRANSPORT_NETBUF_SIZE",
8383
"MCUMGR_BUF_USER_DATA_SIZE" : "MCUMGR_TRANSPORT_NETBUF_USER_DATA_SIZE",
8484
"MCUMGR_SMP_BT" : "MCUMGR_TRANSPORT_BT",
85-
"MCUMGR_SMP_BT_AUTHEN" : "MCUMGR_TRANSPORT_BT_AUTHEN",
85+
"MCUMGR_SMP_BT_AUTHEN" : "MCUMGR_TRANSPORT_BT_PERM_RW_AUTHEN",
86+
"MCUMGR_TRANSPORT_BT_AUTHEN" : "MCUMGR_TRANSPORT_BT_PERM_RW_AUTHEN",
8687
"MCUMGR_SMP_BT_CONN_PARAM_CONTROL" : "MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL",
8788
"MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MIN_INT" : "MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MIN_INT",
8889
"MCUMGR_SMP_BT_CONN_PARAM_CONTROL_MAX_INT" : "MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL_MAX_INT",

subsys/mgmt/mcumgr/transport/Kconfig.bluetooth

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,25 @@ config MCUMGR_TRANSPORT_BT_REASSEMBLY
2424
When enabled, the SMP BT transport will buffer and reassemble received
2525
packet fragments before passing it for further processing.
2626

27-
config MCUMGR_TRANSPORT_BT_AUTHEN
28-
bool "Authenticated requirement for Bluetooth mcumgr SMP transport"
29-
depends on BT_SMP
30-
default y
27+
choice MCUMGR_TRANSPORT_BT_PERM
28+
prompt "Permission used for the SMP service"
29+
default MCUMGR_TRANSPORT_BT_PERM_RW_AUTHEN if BT_SMP
30+
default MCUMGR_TRANSPORT_BT_PERM_RW
3131
help
32-
Enables encrypted and authenticated connection requirement to
33-
Bluetooth SMP transport.
32+
Permission settings for GATT characteristics of the SMP service.
33+
34+
config MCUMGR_TRANSPORT_BT_PERM_RW
35+
bool "Read and write allowed"
36+
37+
config MCUMGR_TRANSPORT_BT_PERM_RW_ENCRYPT
38+
bool "Require encryption for access"
39+
depends on BT_SMP
40+
41+
config MCUMGR_TRANSPORT_BT_PERM_RW_AUTHEN
42+
bool "Require encryption and authentication for access"
43+
depends on BT_SMP
44+
45+
endchoice
3446

3547
config MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL
3648
bool "Request specific connection parameters for SMP packet exchange"

subsys/mgmt/mcumgr/transport/src/smp_bt.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,27 @@ LOG_MODULE_DECLARE(mcumgr_smp, CONFIG_MCUMGR_TRANSPORT_LOG_LEVEL);
4949
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT), \
5050
(NULL))
5151

52+
/* Permission levels for GATT characteristics of the SMP service. */
53+
#ifndef CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW_AUTHEN
54+
#define CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW_AUTHEN 0
55+
#endif
56+
#ifndef CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW_ENCRYPT
57+
#define CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW_ENCRYPT 0
58+
#endif
59+
#ifndef CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW
60+
#define CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW 0
61+
#endif
62+
63+
#define SMP_GATT_PERM ( \
64+
CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW_AUTHEN ? \
65+
(BT_GATT_PERM_READ_AUTHEN | BT_GATT_PERM_WRITE_AUTHEN) : \
66+
CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW_ENCRYPT ? \
67+
(BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT) : \
68+
(BT_GATT_PERM_READ | BT_GATT_PERM_WRITE)) \
69+
70+
#define SMP_GATT_PERM_WRITE_MASK \
71+
(BT_GATT_PERM_WRITE | BT_GATT_PERM_WRITE_ENCRYPT | BT_GATT_PERM_WRITE_AUTHEN)
72+
5273
/* Minimum number of bytes that must be able to be sent with a notification to a target device
5374
* before giving up
5475
*/
@@ -358,14 +379,10 @@ static void smp_bt_ccc_changed(const struct bt_gatt_attr *attr, uint16_t value)
358379
BT_GATT_CHARACTERISTIC(&smp_bt_chr_uuid.uuid, \
359380
BT_GATT_CHRC_WRITE_WITHOUT_RESP | \
360381
BT_GATT_CHRC_NOTIFY, \
361-
COND_CODE_1(CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN, \
362-
(BT_GATT_PERM_WRITE_AUTHEN), \
363-
(BT_GATT_PERM_WRITE)), \
382+
SMP_GATT_PERM & SMP_GATT_PERM_WRITE_MASK, \
364383
NULL, smp_bt_chr_write, NULL), \
365384
BT_GATT_CCC(smp_bt_ccc_changed, \
366-
COND_CODE_1(CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN, \
367-
(BT_GATT_PERM_READ_AUTHEN | BT_GATT_PERM_WRITE_AUTHEN), \
368-
(BT_GATT_PERM_READ | BT_GATT_PERM_WRITE))),
385+
SMP_GATT_PERM),
369386

370387

371388
#ifdef CONFIG_MCUMGR_TRANSPORT_BT_DYNAMIC_SVC_REGISTRATION

tests/subsys/mgmt/mcumgr/all_options/prj.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ CONFIG_STREAM_FLASH=y
1717
CONFIG_IMG_MANAGER=y
1818
CONFIG_MCUMGR=y
1919
CONFIG_MCUMGR_TRANSPORT_BT=y
20-
CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n
2120
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y
2221
CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
23-
CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=y
22+
CONFIG_MCUMGR_TRANSPORT_BT_PERM_RW_AUTHEN=y
2423
CONFIG_MCUMGR_TRANSPORT_DUMMY=y
2524
CONFIG_MCUMGR_TRANSPORT_DUMMY_RX_BUF_SIZE=512
2625
CONFIG_MCUMGR_TRANSPORT_SHELL=y

0 commit comments

Comments
 (0)