mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
Merge branch 'fix/ieee802154_sec_frame_config_v5.1' into 'release/v5.1'
fix(802.15.4): fixed security frame configuration(v5.1) See merge request espressif/esp-idf!45310
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -121,7 +121,6 @@ static IRAM_ATTR void event_end_process(void)
|
||||
{
|
||||
ieee802154_etm_channel_clear(IEEE802154_ETM_CHANNEL0);
|
||||
ieee802154_etm_channel_clear(IEEE802154_ETM_CHANNEL1);
|
||||
ieee802154_ll_set_transmit_security(false);
|
||||
ieee802154_timer0_stop();
|
||||
ieee802154_timer1_stop();
|
||||
}
|
||||
@@ -219,6 +218,7 @@ IEEE802154_NOINLINE static bool stop_rx(void)
|
||||
IEEE802154_NOINLINE static bool stop_tx_ack(void)
|
||||
{
|
||||
ieee802154_set_cmd(IEEE802154_CMD_STOP);
|
||||
ieee802154_sec_clear();
|
||||
|
||||
ieee802154_receive_done((uint8_t *)s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]);
|
||||
|
||||
@@ -232,6 +232,7 @@ IEEE802154_NOINLINE static bool stop_tx(void)
|
||||
ieee802154_ll_events events;
|
||||
|
||||
ieee802154_set_cmd(IEEE802154_CMD_STOP);
|
||||
ieee802154_sec_clear();
|
||||
|
||||
events = ieee802154_ll_get_events();
|
||||
|
||||
@@ -386,6 +387,7 @@ static IRAM_ATTR void next_operation(void)
|
||||
|
||||
static IRAM_ATTR void isr_handle_tx_done(void)
|
||||
{
|
||||
ieee802154_sec_clear();
|
||||
event_end_process();
|
||||
#if !CONFIG_IEEE802154_TEST
|
||||
if (!ieee802154_is_supported_frame_type(ieee802154_frame_get_type(s_tx_frame))) {
|
||||
@@ -446,7 +448,6 @@ static IRAM_ATTR void isr_handle_rx_done(void)
|
||||
// Send the Enh-Ack frame if generator succeeds.
|
||||
ieee802154_ll_set_tx_addr(s_enh_ack_frame);
|
||||
s_tx_frame = s_enh_ack_frame;
|
||||
ieee802154_sec_update();
|
||||
ieee802154_ll_enhack_generate_done_notify();
|
||||
ieee802154_set_state(IEEE802154_STATE_TX_ENH_ACK);
|
||||
#endif
|
||||
@@ -466,6 +467,7 @@ static IRAM_ATTR void isr_handle_rx_done(void)
|
||||
|
||||
static IRAM_ATTR void isr_handle_ack_tx_done(void)
|
||||
{
|
||||
ieee802154_sec_clear();
|
||||
extcoex_rx_stage_start();
|
||||
ieee802154_receive_done((uint8_t *)s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]);
|
||||
NEEDS_NEXT_OPT(true);
|
||||
@@ -520,13 +522,17 @@ static IRAM_ATTR void isr_handle_rx_phase_rx_abort(ieee802154_ll_rx_abort_reason
|
||||
|
||||
static IRAM_ATTR void isr_handle_tx_ack_phase_rx_abort(ieee802154_ll_rx_abort_reason_t rx_abort_reason)
|
||||
{
|
||||
ieee802154_sec_clear();
|
||||
event_end_process();
|
||||
#if CONFIG_IEEE802154_TEST
|
||||
uint32_t rx_status = ieee802154_ll_get_rx_status();
|
||||
#endif
|
||||
switch (rx_abort_reason) {
|
||||
case IEEE802154_RX_ABORT_BY_RX_STOP:
|
||||
case IEEE802154_RX_ABORT_BY_TX_ACK_STOP:
|
||||
#if CONFIG_IEEE802154_TEST
|
||||
ieee802154_receive_done((uint8_t *)s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]);
|
||||
#endif
|
||||
case IEEE802154_RX_ABORT_BY_RX_STOP:
|
||||
case IEEE802154_RX_ABORT_BY_ED_STOP:
|
||||
case IEEE802154_RX_ABORT_BY_SFD_TIMEOUT:
|
||||
case IEEE802154_RX_ABORT_BY_CRC_ERROR:
|
||||
@@ -570,11 +576,19 @@ static IRAM_ATTR void isr_handle_tx_ack_phase_rx_abort(ieee802154_ll_rx_abort_re
|
||||
|
||||
static IRAM_ATTR void isr_handle_tx_abort(ieee802154_ll_tx_abort_reason_t tx_abort_reason)
|
||||
{
|
||||
ieee802154_sec_clear();
|
||||
event_end_process();
|
||||
switch (tx_abort_reason) {
|
||||
case IEEE802154_TX_ABORT_BY_RX_ACK_STOP:
|
||||
#if CONFIG_IEEE802154_TEST
|
||||
ieee802154_inner_transmit_failed(s_tx_frame, ESP_IEEE802154_TX_ERR_NO_ACK);
|
||||
break;
|
||||
#endif
|
||||
case IEEE802154_TX_ABORT_BY_TX_STOP:
|
||||
// do nothing
|
||||
#if CONFIG_IEEE802154_TEST
|
||||
ieee802154_inner_transmit_failed(s_tx_frame, ESP_IEEE802154_TX_ERR_ABORT);
|
||||
#endif
|
||||
break;
|
||||
case IEEE802154_TX_ABORT_BY_RX_ACK_SFD_TIMEOUT:
|
||||
case IEEE802154_TX_ABORT_BY_RX_ACK_CRC_ERROR:
|
||||
@@ -652,7 +666,6 @@ IEEE802154_NOINLINE static void ieee802154_isr(void *arg)
|
||||
ieee802154_ll_events events = ieee802154_ll_get_events();
|
||||
ieee802154_ll_rx_abort_reason_t rx_abort_reason = ieee802154_ll_get_rx_abort_reason();
|
||||
ieee802154_ll_tx_abort_reason_t tx_abort_reason = ieee802154_ll_get_tx_abort_reason();
|
||||
|
||||
IEEE802154_PROBE(events);
|
||||
|
||||
ieee802154_ll_clear_events(events);
|
||||
@@ -840,7 +853,6 @@ IEEE802154_STATIC void tx_init(const uint8_t *frame)
|
||||
s_tx_frame = (uint8_t *)frame;
|
||||
stop_current_operation();
|
||||
ieee802154_pib_update();
|
||||
ieee802154_sec_update();
|
||||
|
||||
ieee802154_ll_set_tx_addr(s_tx_frame);
|
||||
|
||||
@@ -884,6 +896,7 @@ esp_err_t ieee802154_transmit(const uint8_t *frame, bool cca)
|
||||
} else {
|
||||
ieee802154_inner_transmit_failed(frame, ESP_IEEE802154_TX_ERR_ABORT);
|
||||
}
|
||||
ieee802154_sec_clear();
|
||||
IEEE802154_TX_DEFERRED_NUMS_UPDATE();
|
||||
ieee802154_exit_critical();
|
||||
return ESP_OK;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "esp_ieee802154_frame.h"
|
||||
#include "esp_ieee802154_util.h"
|
||||
|
||||
IEEE802154_STATIC IEEE802154_INLINE bool is_security_enabled(const uint8_t *frame)
|
||||
bool ieee802154_frame_is_security_enabled(const uint8_t *frame)
|
||||
{
|
||||
return frame[IEEE802154_FRAME_SECURITY_OFFSET] & IEEE802154_FRAME_SECURITY_BIT;
|
||||
}
|
||||
@@ -269,7 +269,7 @@ IEEE802154_STATIC uint8_t ieee802154_frame_get_ie_field_len(const uint8_t *frame
|
||||
IEEE802154_STATIC IRAM_ATTR uint8_t ieee802154_frame_payload_offset(const uint8_t *frame)
|
||||
{
|
||||
uint8_t offset = ieee802154_frame_security_header_offset(frame);
|
||||
if (is_security_enabled(frame)) {
|
||||
if (ieee802154_frame_is_security_enabled(frame)) {
|
||||
// skip security field.
|
||||
offset += ieee802154_frame_get_security_field_len(frame);
|
||||
}
|
||||
|
||||
@@ -1,28 +1,31 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include <string.h>
|
||||
#include "esp_err.h"
|
||||
#include "hal/ieee802154_ll.h"
|
||||
#include "esp_ieee802154_frame.h"
|
||||
#include "esp_ieee802154_sec.h"
|
||||
#include "esp_ieee802154_util.h"
|
||||
|
||||
#include "esp_ieee802154.h"
|
||||
static bool s_is_security = false;
|
||||
|
||||
void ieee802154_transmit_security_config(uint8_t *frame, uint8_t *key, uint8_t *addr)
|
||||
{
|
||||
#if !CONFIG_IEEE802154_TEST
|
||||
IEEE802154_ASSERT(ieee802154_frame_is_security_enabled(frame));
|
||||
#endif
|
||||
ieee802154_ll_set_security_addr(addr);
|
||||
ieee802154_ll_set_security_key(key);
|
||||
ieee802154_ll_set_security_offset(ieee802154_frame_get_security_payload_offset(frame));
|
||||
s_is_security = true;
|
||||
ieee802154_ll_set_transmit_security(true);
|
||||
}
|
||||
|
||||
void ieee802154_sec_update(void)
|
||||
void ieee802154_sec_clear(void)
|
||||
{
|
||||
ieee802154_ll_set_transmit_security(s_is_security);
|
||||
s_is_security = false;
|
||||
ieee802154_ll_set_transmit_security(false);
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ entries:
|
||||
esp_ieee802154_frame: ieee802154_frame_get_security_payload_offset (noflash)
|
||||
esp_ieee802154_frame: ieee802154_frame_get_src_addr (noflash)
|
||||
esp_ieee802154_frame: ieee802154_frame_security_header_offset (noflash)
|
||||
esp_ieee802154_frame: ieee802154_frame_is_security_enabled(noflash)
|
||||
esp_ieee802154_frame: is_dst_panid_present (noflash)
|
||||
esp_ieee802154_frame: is_src_panid_present (noflash)
|
||||
esp_ieee802154_pib: ieee802154_pib_get_pending_mode (noflash)
|
||||
esp_ieee802154_pib: ieee802154_pib_get_rx_when_idle (noflash)
|
||||
esp_ieee802154_sec: ieee802154_sec_update (noflash)
|
||||
esp_ieee802154_sec: ieee802154_sec_clear (noflash)
|
||||
esp_ieee802154_sec: ieee802154_transmit_security_config (noflash)
|
||||
esp_ieee802154_timer: ieee802154_timer0_set_threshold (noflash)
|
||||
esp_ieee802154_timer: ieee802154_timer0_start (noflash)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -141,6 +141,16 @@ uint8_t ieee802154_frame_get_version(const uint8_t *frame);
|
||||
*/
|
||||
bool ieee802154_frame_is_ack_required(const uint8_t *frame);
|
||||
|
||||
/**
|
||||
* @brief Is the frame security enabled.
|
||||
*
|
||||
* @param[in] frame The pointer to the frame.
|
||||
*
|
||||
* @return
|
||||
* - True if the frame is security enabled, otherwise false.
|
||||
*
|
||||
*/
|
||||
bool ieee802154_frame_is_security_enabled(const uint8_t *frame);
|
||||
/**
|
||||
* @brief Get the destination address of the frame.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -25,11 +25,10 @@ extern "C" {
|
||||
void ieee802154_transmit_security_config(uint8_t *frame, uint8_t *key, uint8_t *addr);
|
||||
|
||||
/**
|
||||
* @brief Update the encryption enabled configuration of the next transmission.
|
||||
*
|
||||
* @brief Clear the encryption enabled configuration.
|
||||
*
|
||||
*/
|
||||
void ieee802154_sec_update(void);
|
||||
void ieee802154_sec_clear(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user