forked from espressif/esp-idf
fix(802.15.4): fix 15.4 process for unsupported frame
This commit is contained in:
@ -97,6 +97,15 @@ menu "IEEE 802.15.4"
|
||||
Enabling this option allows different kinds of IEEE802154 debug output.
|
||||
All IEEE802154 debug features increase the size of the final binary.
|
||||
|
||||
config IEEE802154_DEBUG_ASSERT_MONITOR
|
||||
bool "Enable IEEE802154 assert monitor"
|
||||
depends on IEEE802154_ENABLED
|
||||
default n
|
||||
help
|
||||
Enabling this option to monitor and detect certain abnormal or unexpected
|
||||
states during the operation of the IEEE 802.15.4. When this option is enabled,
|
||||
it will perform additional runtime checks and assertions.
|
||||
|
||||
config IEEE802154_RX_BUFFER_STATISTIC
|
||||
bool "Rx buffer statistic"
|
||||
depends on IEEE802154_DEBUG
|
||||
|
@ -407,6 +407,15 @@ static IRAM_ATTR void next_operation(void)
|
||||
static IRAM_ATTR void isr_handle_tx_done(void)
|
||||
{
|
||||
event_end_process();
|
||||
#if !CONFIG_IEEE802154_TEST
|
||||
if (!ieee802154_is_supported_frame_type(ieee802154_frame_get_type(s_tx_frame))) {
|
||||
// For unsupported frames, return immediately without any further processing.
|
||||
ieee802154_set_cmd(IEEE802154_CMD_STOP);
|
||||
ieee802154_transmit_done(s_tx_frame, NULL, NULL);
|
||||
NEEDS_NEXT_OPT(true);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (s_ieee802154_state == IEEE802154_STATE_TEST_TX) {
|
||||
ieee802154_transmit_done(s_tx_frame, NULL, NULL);
|
||||
NEEDS_NEXT_OPT(true);
|
||||
@ -430,6 +439,15 @@ static IRAM_ATTR void isr_handle_rx_done(void)
|
||||
event_end_process();
|
||||
ieee802154_rx_frame_info_update();
|
||||
|
||||
#if !CONFIG_IEEE802154_TEST
|
||||
if (!ieee802154_is_supported_frame_type(ieee802154_frame_get_type(s_rx_frame[s_rx_index]))) {
|
||||
// For unsupported frames, return immediately without any further processing.
|
||||
ieee802154_set_cmd(IEEE802154_CMD_STOP);
|
||||
ieee802154_receive_done((uint8_t *)s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]);
|
||||
NEEDS_NEXT_OPT(true);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (s_ieee802154_state == IEEE802154_STATE_RX) {
|
||||
if (ieee802154_frame_is_ack_required(s_rx_frame[s_rx_index]) && ieee802154_frame_get_version(s_rx_frame[s_rx_index]) <= IEEE802154_FRAME_VERSION_1
|
||||
&& ieee802154_ll_get_tx_auto_ack()) {
|
||||
@ -543,19 +561,25 @@ static IRAM_ATTR void isr_handle_tx_ack_phase_rx_abort(ieee802154_ll_rx_abort_re
|
||||
return;
|
||||
case IEEE802154_RX_ABORT_BY_TX_ACK_TIMEOUT:
|
||||
case IEEE802154_RX_ABORT_BY_TX_ACK_COEX_BREAK:
|
||||
#if CONFIG_IEEE802154_DEBUG_ASSERT_MONITOR
|
||||
// Jira TZ-1523
|
||||
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_TX_ACK || s_ieee802154_state == IEEE802154_STATE_TX_ENH_ACK);
|
||||
#if !CONFIG_IEEE802154_TEST
|
||||
ieee802154_receive_done((uint8_t *)s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]);
|
||||
#else
|
||||
#endif
|
||||
#if CONFIG_IEEE802154_TEST
|
||||
esp_ieee802154_receive_failed(rx_status);
|
||||
#else
|
||||
ieee802154_receive_done((uint8_t *)s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]);
|
||||
#endif
|
||||
break;
|
||||
case IEEE802154_RX_ABORT_BY_ENHACK_SECURITY_ERROR:
|
||||
#if CONFIG_IEEE802154_DEBUG_ASSERT_MONITOR
|
||||
// Jira TZ-1523
|
||||
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_TX_ENH_ACK);
|
||||
#if !CONFIG_IEEE802154_TEST
|
||||
ieee802154_receive_done((uint8_t *)s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]);
|
||||
#else
|
||||
#endif
|
||||
#if CONFIG_IEEE802154_TEST
|
||||
esp_ieee802154_receive_failed(rx_status);
|
||||
#else
|
||||
ieee802154_receive_done((uint8_t *)s_rx_frame[s_rx_index], &s_rx_frame_info[s_rx_index]);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
@ -732,11 +756,11 @@ IEEE802154_NOINLINE static void ieee802154_isr(void *arg)
|
||||
}
|
||||
|
||||
if (events & IEEE802154_EVENT_TIMER0_OVERFLOW) {
|
||||
#if !CONFIG_IEEE802154_TEST
|
||||
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_RX_ACK);
|
||||
#else
|
||||
#if CONFIG_IEEE802154_TEST
|
||||
extern bool ieee802154_timer0_test;
|
||||
IEEE802154_ASSERT(ieee802154_timer0_test || s_ieee802154_state == IEEE802154_STATE_RX_ACK);
|
||||
#else
|
||||
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_RX_ACK);
|
||||
#endif
|
||||
isr_handle_timer0_done();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -42,13 +42,6 @@ IEEE802154_STATIC IEEE802154_INLINE bool is_panid_compression(const uint8_t *fra
|
||||
return frame[IEEE802154_FRAME_PANID_COMP_OFFSET] & IEEE802154_FRAME_PANID_COMP_BIT;
|
||||
}
|
||||
|
||||
IEEE802154_STATIC IEEE802154_INLINE bool is_suported_frame_type(uint8_t frame_type)
|
||||
{
|
||||
// HW supports 4 kinds of frame type: Beacon, Ack, Data, Command.
|
||||
return (frame_type == IEEE802154_FRAME_TYPE_BEACON || frame_type == IEEE802154_FRAME_TYPE_DATA ||
|
||||
frame_type == IEEE802154_FRAME_TYPE_ACK || frame_type == IEEE802154_FRAME_TYPE_COMMAND);
|
||||
}
|
||||
|
||||
IEEE802154_STATIC IEEE802154_NOINLINE bool is_dst_panid_present(const uint8_t *frame)
|
||||
{
|
||||
uint8_t dst_mode = dst_addr_mode(frame);
|
||||
@ -162,7 +155,7 @@ IEEE802154_STATIC IRAM_ATTR uint8_t ieee802154_frame_address_size(const uint8_t
|
||||
|
||||
IEEE802154_STATIC IEEE802154_NOINLINE uint8_t ieee802154_frame_security_header_offset(const uint8_t *frame)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE_ISR(is_suported_frame_type(ieee802154_frame_get_type(frame)), IEEE802154_FRAME_INVALID_ADDR_MODE, IEEE802154_TAG, "invalid frame type");
|
||||
ESP_RETURN_ON_FALSE_ISR(ieee802154_is_supported_frame_type(ieee802154_frame_get_type(frame)), IEEE802154_FRAME_INVALID_ADDR_MODE, IEEE802154_TAG, "invalid frame type");
|
||||
uint8_t offset = ieee802154_frame_address_offset(frame);
|
||||
uint8_t address_size = ieee802154_frame_address_size(frame);
|
||||
|
||||
@ -176,7 +169,7 @@ IEEE802154_STATIC IEEE802154_NOINLINE uint8_t ieee802154_frame_security_header_o
|
||||
|
||||
IEEE802154_STATIC IEEE802154_NOINLINE uint8_t ieee802154_frame_get_security_field_len(const uint8_t *frame)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE_ISR(is_suported_frame_type(ieee802154_frame_get_type(frame)), IEEE802154_FRAME_INVALID_OFFSET, IEEE802154_TAG, "invalid frame type");
|
||||
ESP_RETURN_ON_FALSE_ISR(ieee802154_is_supported_frame_type(ieee802154_frame_get_type(frame)), IEEE802154_FRAME_INVALID_OFFSET, IEEE802154_TAG, "invalid frame type");
|
||||
|
||||
uint8_t security_field_len = 0;
|
||||
uint8_t offset = ieee802154_frame_security_header_offset(frame);
|
||||
@ -309,12 +302,12 @@ uint8_t IEEE802154_INLINE ieee802154_frame_get_version(const uint8_t *frame)
|
||||
|
||||
bool IEEE802154_INLINE ieee802154_frame_is_ack_required(const uint8_t *frame)
|
||||
{
|
||||
return (is_suported_frame_type(ieee802154_frame_get_type(frame))) && (frame[IEEE802154_FRAME_AR_OFFSET] & IEEE802154_FRAME_AR_BIT);
|
||||
return (ieee802154_is_supported_frame_type(ieee802154_frame_get_type(frame))) && (frame[IEEE802154_FRAME_AR_OFFSET] & IEEE802154_FRAME_AR_BIT);
|
||||
}
|
||||
|
||||
uint8_t ieee802154_frame_get_dst_addr(const uint8_t *frame, uint8_t *addr)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE_ISR(is_suported_frame_type(ieee802154_frame_get_type(frame)), IEEE802154_FRAME_INVALID_ADDR_MODE, IEEE802154_TAG, "invalid frame type");
|
||||
ESP_RETURN_ON_FALSE_ISR(ieee802154_is_supported_frame_type(ieee802154_frame_get_type(frame)), IEEE802154_FRAME_INVALID_ADDR_MODE, IEEE802154_TAG, "invalid frame type");
|
||||
|
||||
uint8_t offset = ieee802154_frame_address_offset(frame);
|
||||
uint8_t dst_mode = dst_addr_mode(frame);
|
||||
@ -335,7 +328,7 @@ uint8_t ieee802154_frame_get_dst_addr(const uint8_t *frame, uint8_t *addr)
|
||||
|
||||
uint8_t ieee802154_frame_get_src_addr(const uint8_t *frame, uint8_t *addr)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE_ISR(is_suported_frame_type(ieee802154_frame_get_type(frame)), IEEE802154_FRAME_INVALID_ADDR_MODE, IEEE802154_TAG, "invalid frame type");
|
||||
ESP_RETURN_ON_FALSE_ISR(ieee802154_is_supported_frame_type(ieee802154_frame_get_type(frame)), IEEE802154_FRAME_INVALID_ADDR_MODE, IEEE802154_TAG, "invalid frame type");
|
||||
|
||||
uint8_t offset = ieee802154_frame_address_offset(frame);
|
||||
uint8_t dst_mode = dst_addr_mode(frame);
|
||||
|
@ -101,6 +101,13 @@ extern "C" {
|
||||
#define IEEE802154_FRAME_SE_HEAD_SIZE 1
|
||||
#define IEEE802154_FRAME_COMMAND_ID_LEN 1
|
||||
|
||||
static inline bool ieee802154_is_supported_frame_type(uint8_t frame_type)
|
||||
{
|
||||
// HW supports 4 kinds of frame type: Beacon, Ack, Data, Command.
|
||||
return (frame_type == IEEE802154_FRAME_TYPE_BEACON || frame_type == IEEE802154_FRAME_TYPE_DATA ||
|
||||
frame_type == IEEE802154_FRAME_TYPE_ACK || frame_type == IEEE802154_FRAME_TYPE_COMMAND);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the frame type.
|
||||
*
|
||||
|
Reference in New Issue
Block a user