btdev: Add support for LE Set Privacy mode
Luiz Augusto von Dentz
maintainerPATCH 1/2 btdev: Add support for LE Set Privacy mode
From: Luiz Augusto von Dentz <[email protected]>
This adds support for LE Set Privacy mode which is required when using Device Privacy mode:
< HCI Command: LE Set Priva.. (0x08|0x004e) plen 8
Peer Identity address type: Public (0x00)
Peer Identity address: BC:9A:78:56:34:12 (OUI BC-9A-78)
Privacy Mode: Use Device Privacy (0x01)Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4
LE Set Privacy Mode (0x08|0x004e) ncmd 1 --- emulator/btdev.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-)
emulator/btdev.c +45 -1
@@ -72,6 +72,7 @@ struct btdev_al {struct btdev_rl {uint8_t type;bdaddr_t addr; +uint8_t mode;uint8_t peer_irk[16 ];uint8_t local_irk[16 ]; };
@@ -5336,6 +5337,48 @@ static int cmd_read_tx_power(struct btdev *dev, const void *data, uint8_t len)return 0 ; } +static int cmd_set_privacy_mode (struct btdev *dev,const void *data, +uint8_t len) +{ +const struct bt_hci_cmd_le_set_priv_mode *cmd = data; +const struct btdev_rl *rl; +uint8_t status; + +/* This command shall not be used when address resolution is enabled in +* the Controller and: +* • Advertising (other than periodic advertising) is enabled, +* • Scanning is enabled, or +* • an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection, +* or HCI_LE_Periodic_Advertising_Create_Sync command is pending. +*/ +if (dev->le_rl_enable || dev->le_adv_enable || dev->le_scan_enable) { + status =BT_HCI_ERR_COMMAND_DISALLOWED ; + goto done; + } + +/* If the device is not on the resolving list, the Controller shall +* return the error code Unknown Connection Identifier (0x02). +*/ + rl =rl_find (dev, cmd->peer_id_addr_type, cmd->peer_id_addr); +if (!rl) { + status =BT_HCI_ERR_UNKNOWN_CONN_ID ; + goto done; + } + +if (cmd->priv_mode >0x01 ) { + status =BT_HCI_ERR_INVALID_PARAMETERS ; + goto done; + } + + ((struct btdev_rl *)rl)->mode = cmd->priv_mode; + status =BT_HCI_ERR_SUCCESS ; + +done: +cmd_complete (dev,BT_HCI_CMD_LE_SET_PRIV_MODE , &status,sizeof (status)); + +return 0 ; +} +#define CMD_LE_50 \ CMD(BT_HCI_CMD_LE_SET_DEFAULT_PHY, cmd_set_default_phy, NULL), \ CMD(BT_HCI_CMD_LE_SET_ADV_SET_RAND_ADDR, cmd_set_adv_rand_addr, NULL), \
@@ -5372,7 +5415,8 @@ static int cmd_read_tx_power(struct btdev *dev, const void *data, uint8_t len)CMD (BT_HCI_CMD_LE_CLEAR_PERIODIC_ADV_LIST , cmd_per_adv_clear,NULL ), \CMD (BT_HCI_CMD_LE_READ_PERIODIC_ADV_LIST_SIZE , \ cmd_read_per_adv_list_size,NULL ), \ - CMD(BT_HCI_CMD_LE_READ_TX_POWER, cmd_read_tx_power, NULL) +CMD (BT_HCI_CMD_LE_READ_TX_POWER , cmd_read_tx_power,NULL ), \ + CMD(BT_HCI_CMD_LE_SET_PRIV_MODE, cmd_set_privacy_mode, NULL)static const struct btdev_cmd cmd_le_5_0[] = {CMD_COMMON_ALL ,
Signature · 1 line
2.31.1
Luiz Augusto von Dentz
maintainerPATCH 2/2 mgmt-tester: Enable use of limited/device privacy mode
From: Luiz Augusto von Dentz <[email protected]>
This enables use of limited/device privacy mode in some LL Privacy tests that are testing the addition of peer in the resolving list since it does require the use of LE Set Privacy Mode:
< HCI Command: LE Add Devi.. (0x08|0x0027) plen 39
Address type: Public (0x00)
Address: 66:55:44:33:22:11 (OUI 66-55-44)
Peer identity resolving key: 11223344556677881122334455667788
Local identity resolving key: 01020304050607080102030405060708Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4
LE Add Device To Resolving List (0x08|0x0027) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Priva.. (0x08|0x004e) plen 8
Peer Identity address type: Public (0x00)
Peer Identity address: 66:55:44:33:22:11 (OUI 66-55-44)
Privacy Mode: Use Device Privacy (0x01)Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4
LE Set Privacy Mode (0x08|0x004e) ncmd 1
Status: Success (0x00)
< HCI Command: LE Add Devic.. (0x08|0x0011) plen 7
Address type: Public (0x00)
Address: 66:55:44:33:22:11 (OUI 66-55-44)Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4
LE Add Device To Accept List (0x08|0x0011) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Addre.. (0x08|0x002d) plen 1
Address resolution: Enabled (0x01)
---
tools/mgmt-tester.c | 5 +++++
1 file changed, 5 insertions(+)tools/mgmt-tester.c +5 -0
@@ -274,6 +274,7 @@ struct generic_data {const uint16_t *setup_settings;bool setup_nobredr;bool setup_limited_discov; +bool setup_limited_priv;const void *setup_exp_feat_param;uint16_t setup_expect_hci_command;const void *setup_expect_hci_param;
@@ -7160,6 +7161,8 @@ proceed: }if (*cmd ==MGMT_OP_SET_PRIVACY ) { +if (test->setup_limited_priv) + privacy_param[0 ] =0x02 ; param_size =sizeof (privacy_param); param = privacy_param; }
@@ -10185,6 +10188,7 @@ static const struct generic_data ll_privacy_add_device_3 = {static const struct generic_data ll_privacy_add_device_4 = { .setup_settings = settings_le_privacy_ll_privacy, + .setup_limited_priv = true, .setup_exp_feat_param = set_exp_feat_param_ll_privacy, .send_opcode =MGMT_OP_ADD_DEVICE , .send_param = add_device_le_public_param_2,
@@ -10202,6 +10206,7 @@ static const struct generic_data ll_privacy_add_device_4 = {static const struct generic_data ll_privacy_add_device_5 = { .setup_settings = settings_le_privacy_ll_privacy, + .setup_limited_priv = true, .setup_exp_feat_param = set_exp_feat_param_ll_privacy, .send_opcode =MGMT_OP_ADD_DEVICE , .send_param = add_device_le_public_param_2,
Signature · 1 line
2.31.1
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=573885
---Test result---
Test Summary:
CheckPatch PASS 0.90 seconds GitLint PASS 0.56 seconds Prep - Setup ELL PASS 39.92 seconds Build - Prep PASS 0.18 seconds Build - Configure PASS 7.64 seconds Build - Make PASS 168.24 seconds Make Check PASS 9.04 seconds Make Distcheck PASS 204.89 seconds Build w/ext ELL - Configure PASS 7.26 seconds Build w/ext ELL - Make PASS 157.88 seconds
---
Regards,
Linux Bluetooth