mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ble_mesh: stack: Fix exceptional list parameters check issue
This commit is contained in:
parent
310571138e
commit
0f95a31589
@ -1959,17 +1959,20 @@ int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16],
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info)
|
||||
int bt_mesh_update_exceptional_list(uint8_t sub_code, uint32_t type, void *info)
|
||||
{
|
||||
BD_ADDR value = {0};
|
||||
|
||||
if ((sub_code > BLE_MESH_EXCEP_LIST_CLEAN) ||
|
||||
(type > BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV)) {
|
||||
if ((sub_code > BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN) ||
|
||||
(sub_code < BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN &&
|
||||
type > BLE_MESH_EXCEP_LIST_TYPE_MESH_PROXY_ADV) ||
|
||||
(sub_code == BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN &&
|
||||
!(type & BLE_MESH_EXCEP_LIST_CLEAN_ALL_LIST))) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (type == BLE_MESH_EXCEP_INFO_MESH_LINK_ID) {
|
||||
if (type == BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID) {
|
||||
if (!info) {
|
||||
BT_ERR("Invalid Provisioning Link ID");
|
||||
return -EINVAL;
|
||||
@ -1977,7 +1980,7 @@ int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info)
|
||||
sys_memcpy_swap(value, info, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
BT_DBG("%s exceptional list, type 0x%02x", sub_code ? "Remove" : "Add", type);
|
||||
BT_DBG("%s exceptional list, type 0x%08x", sub_code ? "Remove" : "Add", type);
|
||||
|
||||
/* The parameter "device_info" can't be NULL in the API */
|
||||
BLE_MESH_BTM_CHECK_STATUS(BTM_UpdateBleDuplicateExceptionalList(sub_code, type, value, NULL));
|
||||
|
@ -776,29 +776,28 @@ int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16],
|
||||
uint8_t enc_data[16]);
|
||||
|
||||
enum {
|
||||
BLE_MESH_EXCEP_LIST_ADD = 0,
|
||||
BLE_MESH_EXCEP_LIST_REMOVE,
|
||||
BLE_MESH_EXCEP_LIST_CLEAN,
|
||||
BLE_MESH_EXCEP_LIST_SUB_CODE_ADD = 0,
|
||||
BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE,
|
||||
BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN,
|
||||
};
|
||||
|
||||
enum {
|
||||
BLE_MESH_EXCEP_INFO_ADV_ADDR = 0,
|
||||
BLE_MESH_EXCEP_INFO_MESH_LINK_ID,
|
||||
BLE_MESH_EXCEP_INFO_MESH_BEACON,
|
||||
BLE_MESH_EXCEP_INFO_MESH_PROV_ADV,
|
||||
BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_ADV_ADDR = 0,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_BEACON,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_PROV_ADV,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_PROXY_ADV,
|
||||
};
|
||||
|
||||
enum {
|
||||
BLE_MESH_EXCEP_CLEAN_ADDR_LIST = BIT(0),
|
||||
BLE_MESH_EXCEP_CLEAN_MESH_LINK_ID_LIST = BIT(1),
|
||||
BLE_MESH_EXCEP_CLEAN_MESH_BEACON_LIST = BIT(2),
|
||||
BLE_MESH_EXCEP_CLEAN_MESH_PROV_ADV_LIST = BIT(3),
|
||||
BLE_MESH_EXCEP_CLEAN_MESH_PROXY_ADV_LIST = BIT(4),
|
||||
BLE_MESH_EXCEP_CLEAN_ALL_LIST = 0xFFFF,
|
||||
};
|
||||
#define BLE_MESH_EXCEP_LIST_CLEAN_ADDR_LIST BIT(0)
|
||||
#define BLE_MESH_EXCEP_LIST_CLEAN_MESH_LINK_ID_LIST BIT(1)
|
||||
#define BLE_MESH_EXCEP_LIST_CLEAN_MESH_BEACON_LIST BIT(2)
|
||||
#define BLE_MESH_EXCEP_LIST_CLEAN_MESH_PROV_ADV_LIST BIT(3)
|
||||
#define BLE_MESH_EXCEP_LIST_CLEAN_MESH_PROXY_ADV_LIST BIT(4)
|
||||
#define BLE_MESH_EXCEP_LIST_CLEAN_ALL_LIST (BIT(0) | BIT(1) | \
|
||||
BIT(2) | BIT(3) | BIT(4))
|
||||
|
||||
int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info);
|
||||
int bt_mesh_update_exceptional_list(uint8_t sub_code, uint32_t type, void *info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -613,14 +613,14 @@ int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers)
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
|
||||
(bearers & BLE_MESH_PROV_ADV)) {
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD,
|
||||
BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_BEACON, NULL);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
(bearers & BLE_MESH_PROV_GATT)) {
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD,
|
||||
BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, NULL);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_PROV_ADV, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -668,8 +668,8 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers)
|
||||
(bearers & BLE_MESH_PROV_GATT)) {
|
||||
bt_mesh_proxy_client_prov_disable();
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE,
|
||||
BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, NULL);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_PROV_ADV, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -680,8 +680,8 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers)
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
|
||||
(enable & BLE_MESH_PROV_ADV)) {
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE,
|
||||
BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_BEACON, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1550,8 +1550,8 @@ void bt_mesh_net_start(void)
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
/* Add Mesh beacon type (Secure Network Beacon) to the exceptional list */
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD,
|
||||
BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_BEACON, NULL);
|
||||
#endif
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER)) {
|
||||
|
@ -311,8 +311,8 @@ static void reset_adv_link(void)
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
/* Remove the link id from exceptional list */
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE,
|
||||
BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link.id);
|
||||
#endif
|
||||
|
||||
reset_state();
|
||||
@ -1380,8 +1380,8 @@ static void link_open(struct prov_rx *rx, struct net_buf_simple *buf)
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
/* Add the link id into exceptional list */
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD,
|
||||
BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link.id);
|
||||
#endif
|
||||
|
||||
bearer_ctl_send(LINK_ACK, NULL, 0);
|
||||
@ -1837,8 +1837,8 @@ int bt_mesh_prov_deinit(void)
|
||||
k_delayed_work_free(&link.tx.retransmit);
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
/* Remove the link id from exceptional list */
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE,
|
||||
BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link.id);
|
||||
#endif /* CONFIG_BLE_MESH_USE_DUPLICATE_SCAN */
|
||||
#endif /* CONFIG_BLE_MESH_PB_ADV */
|
||||
|
||||
|
@ -1326,8 +1326,8 @@ static void reset_link(const uint8_t idx, uint8_t reason)
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
/* Remove the link id from exceptional list */
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE,
|
||||
BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link[idx].link_id);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link[idx].link_id);
|
||||
#endif
|
||||
|
||||
/* Clear everything except the retransmit delayed work config */
|
||||
@ -1486,8 +1486,8 @@ static void send_link_open(const uint8_t idx)
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
/* Add the link id into exceptional list */
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD,
|
||||
BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link[idx].link_id);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link[idx].link_id);
|
||||
#endif
|
||||
|
||||
bearer_ctl_send(idx, LINK_OPEN, link[idx].uuid, 16);
|
||||
@ -3346,8 +3346,8 @@ int bt_mesh_provisioner_prov_reset(bool erase)
|
||||
#if CONFIG_BLE_MESH_PB_ADV
|
||||
prov_clear_tx(i);
|
||||
#if CONFIG_BLE_MESH_USE_DUPLICATE_SCAN
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE,
|
||||
BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link[i].link_id);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_LINK_ID, &link[i].link_id);
|
||||
#endif
|
||||
memset(&link[i], 0, offsetof(struct prov_link, tx.retransmit));
|
||||
link[i].pending_ack = XACT_NVAL;
|
||||
|
@ -991,8 +991,8 @@ int bt_mesh_proxy_client_init(void)
|
||||
bt_mesh_gattc_conn_cb_register(&conn_callbacks);
|
||||
|
||||
#if CONFIG_BLE_MESH_USE_DUPLICATE_SCAN && CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD,
|
||||
BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV, NULL);
|
||||
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD,
|
||||
BLE_MESH_EXCEP_LIST_TYPE_MESH_PROXY_ADV, NULL);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -711,7 +711,7 @@ int ble_mesh_node_enable_bearer(int argc, char **argv)
|
||||
int ble_mesh_exceptional_list_test(int argc, char **argv)
|
||||
{
|
||||
esp_err_t err = ESP_FAIL;
|
||||
uint32_t type = BLE_MESH_EXCEP_INFO_MESH_BEACON;
|
||||
uint32_t type = BLE_MESH_EXCEP_LIST_TYPE_MESH_BEACON;
|
||||
uint8_t *info = NULL;
|
||||
|
||||
int nerrors = arg_parse(argc, argv, (void **) &exceptional_list_test);
|
||||
@ -733,11 +733,11 @@ int ble_mesh_exceptional_list_test(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (strcmp(exceptional_list_test.action_type->sval[0], "add") == 0) {
|
||||
err = bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, type, info);
|
||||
err = bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_ADD, type, info);
|
||||
} else if (strcmp(exceptional_list_test.action_type->sval[0], "remove") == 0) {
|
||||
err = bt_mesh_update_exceptional_list( BLE_MESH_EXCEP_LIST_REMOVE, type, info);
|
||||
err = bt_mesh_update_exceptional_list( BLE_MESH_EXCEP_LIST_SUB_CODE_REMOVE, type, info);
|
||||
} else if (strcmp(exceptional_list_test.action_type->sval[0], "clean") == 0) {
|
||||
err = bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_CLEAN, type, NULL);
|
||||
err = bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_SUB_CODE_CLEAN, type, NULL);
|
||||
}
|
||||
|
||||
if (err == ESP_OK) {
|
||||
|
Loading…
Reference in New Issue
Block a user