main.conf: Fix parsing of CSIS group
Luiz Augusto von Dentz
maintainerPATCH 1/5 main.conf: Fix parsing of CSIS group
From: Luiz Augusto von Dentz <[email protected]>
There was a typo in the group name using CSIP instead of CSIS.
--- src/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
src/main.c +5 -5
@@ -177,7 +177,7 @@ static const struct group_table { { "LE", le_options }, { "Policy", policy_options }, { "GATT", gatt_options }, - { "CSIP", csip_options }, + { "CSIS", csip_options }, { "AVDTP", avdtp_options }, { "AdvMon", advmon_options }, { }
@@ -1015,7 +1015,7 @@ static void parse_config(GKeyFile *config) btd_opts.gatt_channels = val; } - str =g_key_file_get_string (config,"CSIP" ,"SIRK" , &err); + str =g_key_file_get_string (config,"CSIS" ,"SIRK" , &err);if (err) {DBG ("%s" , err->message);g_clear_error (&err);
@@ -1031,7 +1031,7 @@ static void parse_config(GKeyFile *config)g_free (str); } - boolean =g_key_file_get_boolean (config,"CSIP" ,"SIRK" , &err); + boolean =g_key_file_get_boolean (config,"CSIS" ,"Encryption" , &err);if (err) {DBG ("%s" , err->message);g_clear_error (&err);
@@ -1041,7 +1041,7 @@ static void parse_config(GKeyFile *config) btd_opts.csis.encrypt = boolean; } - val =g_key_file_get_integer (config,"CSIP" ,"Size" , &err); + val =g_key_file_get_integer (config,"CSIS" ,"Size" , &err);if (err) {DBG ("%s" , err->message);g_clear_error (&err);
@@ -1052,7 +1052,7 @@ static void parse_config(GKeyFile *config) btd_opts.csis.size = val; } - val =g_key_file_get_integer (config,"CSIP" ,"Rank" , &err); + val =g_key_file_get_integer (config,"CSIS" ,"Rank" , &err);if (err) {DBG ("%s" , err->message);g_clear_error (&err);
Signature · 1 line
2.39.2
Luiz Augusto von Dentz
maintainerPATCH 2/5 shared/ad: Fix bt_ad_has_data not matching when only type is passed
From: Luiz Augusto von Dentz <[email protected]>
bt_ad_has_data attempts to match the data portion even when not set which is useful the user is only interested in actually mataching the type alone.
--- src/shared/ad.c | 3 +++ 1 file changed, 3 insertions(+)
src/shared/ad.c +3 -0
@@ -1028,6 +1028,9 @@ static bool data_match(const void *data, const void *user_data)if (d1->type != d2->type)return false; +if (!d2->len && !d2->data) +return true; +if (d1->len != d2->len)return false;
Signature · 1 line
2.39.2
Luiz Augusto von Dentz
maintainerPATCH 3/5 advertising-api: Add rsi to SupportedIncludes
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds "rsi" as possible value to SupportedIncludes so when it is available it means client and set it on its Includes property so a proper RSI is generated and included as part of the Advertising Data.
--- doc/advertising-api.txt | 1 + 1 file changed, 1 insertion(+)
doc/advertising-api.txt +1 -0
@@ -224,6 +224,7 @@ Properties byte ActiveInstances Possible values: "tx-power" "appearance" "local-name" + "rsi" array{string} SupportedSecondaryChannels [Experimental]
Signature · 1 line
2.39.2
Luiz Augusto von Dentz
maintainerPATCH 4/5 advertising: Add support for rsi as Includes
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds support for "rsi" when a SIRK has been set on main.conf, the clients can then enable it via Includes property which will make the daemon to automatically generate an RSI (hash+random) and include it as part of the advertising data:
< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 15
Handle: 0x01
Operation: Complete extended advertising data (0x03)
Fragment preference: Minimize fragmentation (0x01)
Data length: 0x0b
Resolvable Set Identifier: E2-4E-AA-1B-2B-61
Hash: 0x1b2b61
Random: 0xe24eaa
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported
---
src/advertising.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)src/advertising.c +46 -1
@@ -29,11 +29,13 @@#include "error.h" #include "log.h" #include "eir.h" +#include "btd.h" #include "src/shared/ad.h" #include "src/shared/mgmt.h" #include "src/shared/queue.h" #include "src/shared/timeout.h" #include "src/shared/util.h" +#include "src/shared/crypto.h" #include "advertising.h" #define LE_ADVERTISING_MGR_IFACE "org.bluez.LEAdvertisingManager1"
@@ -459,13 +461,50 @@ fail:return false; } +static bool set_rsi (struct btd_adv_client *client) +{ +struct bt_crypto *crypto; +uint8_t zero[16 ] = {}; +struct bt_ad_data rsi = { .type =BT_AD_CSIP_RSI }; +uint8_t data[6 ]; +bool ret; + +/* Check if a valid SIRK has been set */ +if (!memcmp (btd_opts.csis.sirk, zero,sizeof (zero))) +return false; + +/* Check if RSI needs to be set or data already contains RSI data */ +if (!client ||bt_ad_has_data (client->data, &rsi)) +return true; + + crypto =bt_crypto_new (); +if (!crypto) +return false; + + ret =bt_crypto_random_bytes (crypto, data +3 ,sizeof (data) -3 ); +if (!ret) + goto done; + + ret =bt_crypto_sih (crypto, btd_opts.csis.sirk, data +3 , data); +if (!ret) + goto done; + + ret =bt_ad_add_data (client->data,BT_AD_CSIP_RSI , data,sizeof (data)); + +done: +bt_crypto_unref (crypto); +return ret; +} +static struct adv_include {uint8_t flag;const char *name; +bool (*set)(struct btd_adv_client *client); } includes[] = { {MGMT_ADV_FLAG_TX_POWER ,"tx-power" }, {MGMT_ADV_FLAG_APPEARANCE ,"appearance" }, {MGMT_ADV_FLAG_LOCAL_NAME ,"local-name" }, + {0 ,"rsi" , set_rsi }, { }, };
@@ -497,6 +536,11 @@ static bool parse_includes(DBusMessageIter *iter,if (strcmp (str, inc->name))continue ; +if (inc->set && inc->set (client)) { +DBG ("Including Feature: %s" , str); +continue ; + } +if (!(client->manager->supported_flags & inc->flag))continue ;
@@ -1644,7 +1688,8 @@ static void append_include(struct btd_adv_manager *manager,struct adv_include *inc;for (inc = includes; inc && inc->name; inc++) { -if (manager->supported_flags & inc->flag) +if ((inc->set && inc->set (NULL )) || + (manager->supported_flags & inc->flag))dbus_message_iter_append_basic (iter,DBUS_TYPE_STRING , &inc->name); }
Signature · 1 line
2.39.2
Luiz Augusto von Dentz
maintainerPATCH 5/5 client/advertising: Add support for advertise.rsi command
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds support for advertise.rsi command which can be used to request the generation of RSI and include it as part of advertising data:
[bluetooth]# advertise.rsi --help
Show/Enable/Disable RSI to be advertised
Usage:
rsi [on/off]
[bluetooth]# advertise.rsi
RSI: on
[bluetooth]# advertise on
...
Advertising object registered
Tx Power: off
Name: off
Appearance: off
Discoverable: on
RSI: on
[bluetooth]#
--- client/advertising.c | 28 +++++++++++++++++++++++++++- client/advertising.h | 1 + client/main.c | 17 +++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-)
client/advertising.c +27 -1
@@ -67,9 +67,11 @@ static struct ad {bool tx_power;bool name;bool appearance; +bool rsi; } ad = { .local_appearance = UINT16_MAX, .discoverable = true, + .rsi = true, };static void ad_release (DBusConnection *conn)
@@ -176,6 +178,7 @@ static void print_ad(void) ad.appearance ? "on" : "off");bt_shell_printf ("Discoverable: %s\n" , ad.discoverable ?"on" :"off" ); +bt_shell_printf ("RSI: %s\n" , ad.rsi ?"on" :"off" );if (ad.duration)bt_shell_printf ("Duration: %u sec\n" , ad.duration);
@@ -295,7 +298,7 @@ static gboolean get_manufacturer_data(const GDBusPropertyTable *property,static gboolean includes_exists (const GDBusPropertyTable *property,void *data) { -return ad.tx_power || ad.name || ad.appearance; +return ad.tx_power || ad.name || ad.appearance || ad.rsi; } static gboolean get_includes(const GDBusPropertyTable *property,
@@ -323,6 +326,12 @@ static gboolean get_includes(const GDBusPropertyTable *property,dbus_message_iter_append_basic (&array,DBUS_TYPE_STRING , &str); } +if (ad.rsi) { +const char *str ="rsi" ; + +dbus_message_iter_append_basic (&array,DBUS_TYPE_STRING , &str); + } +dbus_message_iter_close_container (iter, &array);
@@ -1023,3 +1032,20 @@ void ad_advertise_interval(DBusConnection *conn, uint32_t *min, uint32_t *max)return bt_shell_noninteractive_quit (EXIT_SUCCESS ); } + +void ad_advertise_rsi (DBusConnection *conn,dbus_bool_t *value) +{ +if (!value) { +bt_shell_printf ("RSI: %s\n" , ad.rsi ?"on" :"off" ); +return bt_shell_noninteractive_quit (EXIT_SUCCESS ); + } + +if (ad.rsi == *value) +return bt_shell_noninteractive_quit (EXIT_SUCCESS ); + + ad.rsi = *value; + +g_dbus_emit_property_changed (conn,AD_PATH ,AD_IFACE ,"Includes" ); + +return bt_shell_noninteractive_quit (EXIT_SUCCESS ); +}
client/advertising.h +1 -0
@@ -30,3 +30,4 @@ void ad_advertise_discoverable(DBusConnection *conn, dbus_bool_t *value);void ad_advertise_discoverable_timeout (DBusConnection *conn,long int *value);void ad_advertise_secondary (DBusConnection *conn,const char *value);void ad_advertise_interval (DBusConnection *conn,uint32_t *min,uint32_t *max); +void ad_advertise_rsi (DBusConnection *conn,dbus_bool_t *value);
client/main.c +17 -0
@@ -2733,6 +2733,21 @@ static void cmd_advertise_interval(int argc, char *argv[])ad_advertise_interval (dbus_conn, &min, &max); } +static void cmd_advertise_rsi (int argc,char *argv[]) +{ +dbus_bool_t value; + +if (argc <2 ) { +ad_advertise_rsi (dbus_conn,NULL ); +return ; + } + +if (!parse_argument (argc, argv,NULL ,NULL , &value,NULL )) +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + +ad_advertise_rsi (dbus_conn, &value); +} +static void ad_clear_uuids (void ) {ad_disable_uuids (dbus_conn);
@@ -2931,6 +2946,8 @@ static const struct bt_shell_menu advertise_menu = { "Set/Get advertise secondary channel" }, {"interval" ,"[min] [max] " , cmd_advertise_interval, "Set/Get advertise interval range" }, + { "rsi", "[on/off]", cmd_advertise_rsi, + "Show/Enable/Disable RSI to be advertised", NULL }, { "clear", "[uuids/service/manufacturer/config-name...]", cmd_ad_clear, "Clear advertise config" }, { } },
Signature · 1 line
2.39.2
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=737372
---Test result---
Test Summary:
CheckPatch FAIL 2.88 seconds GitLint FAIL 1.96 seconds BuildEll PASS 27.21 seconds BluezMake PASS 987.72 seconds MakeCheck PASS 11.55 seconds MakeDistcheck PASS 149.73 seconds CheckValgrind PASS 247.03 seconds CheckSmatch PASS 333.73 seconds bluezmakeextell PASS 99.93 seconds IncrementalBuild PASS 4208.79 seconds ScanBuild WARNING 1059.51 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,4/5] advertising: Add support for rsi as Includes ERROR:SPACING: space prohibited before that ',' (ctx:WxW) #170: FILE: src/advertising.c:507:
+ { 0 , "rsi", set_rsi },
^
/github/workspace/src/src/13202645.patch total: 1 errors, 0 warnings, 83 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/src/13202645.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
[BlueZ,5/5] client/advertising: Add support for advertise.rsi command ERROR:SPACING: spaces required around that ':' (ctx:VxW) #129: FILE: client/advertising.c:181:
+ bt_shell_printf("RSI: %s\n", ad.rsi ? "on": "off");
^
/github/workspace/src/src/13202647.patch total: 1 errors, 0 warnings, 91 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/src/13202647.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,5/5] client/advertising: Add support for advertise.rsi command
WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
11: B3 Line contains hard tab characters (\t): " rsi [on/off]"
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:src/advertising.c:942:2: warning: Null pointer passed to 2nd parameter expecting 'nonnull'
memcpy(cp->data + adv_data_len, scan_rsp, scan_rsp_len);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1 warning generated.
---
Regards,
Linux Bluetooth
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 6 lines · On Wed, 5 Apr 2023 16:11:07 -0700 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
There was a typo in the group name using CSIP instead of CSIS.
--- src/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Here is the summary with links:
- [BlueZ,1/5] main.conf: Fix parsing of CSIS group
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a1b93db14da6 - [BlueZ,2/5] shared/ad: Fix bt_ad_has_data not matching when only type is passed https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=759d1442a5dc - [BlueZ,3/5] advertising-api: Add rsi to SupportedIncludes https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=23bc47437a35 - [BlueZ,4/5] advertising: Add support for rsi as Includes https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=eef2e62a5bc4
- [BlueZ,5/5] client/advertising: Add support for advertise.rsi command (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html