diff --git a/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_filter.c b/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_filter.c index 3060766b..f3df07ce 100644 --- a/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_filter.c +++ b/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_filter.c @@ -151,6 +151,31 @@ static nrf_802154_rx_error_t dst_addressing_end_offset_get_2006(const uint8_t * { nrf_802154_rx_error_t result; + if (frame_type == FRAME_TYPE_MULTIPURPOSE) + { + if (nrf_802154_frame_parser_is_mp_long_frame(p_data)) + { + uint8_t end_offset = nrf_802154_frame_parser_mp_dst_addr_end_offset_get(p_data); + + if (end_offset == NRF_802154_FRAME_PARSER_INVALID_OFFSET) + { + result = NRF_802154_RX_ERROR_INVALID_FRAME; + } + else + { + *p_num_bytes = end_offset; + result = NRF_802154_RX_ERROR_NONE; + } + } + else + { + // Do not process short multipurpose frame. + result = NRF_802154_RX_ERROR_INVALID_FRAME; + } + + return result; + } + switch (p_data[DEST_ADDR_TYPE_OFFSET] & DEST_ADDR_TYPE_MASK) { case DEST_ADDR_TYPE_SHORT: diff --git a/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_frame_parser.c b/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_frame_parser.c index 0ad70e2b..8d73993e 100644 --- a/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_frame_parser.c +++ b/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_frame_parser.c @@ -337,6 +337,417 @@ bool nrf_802154_frame_parser_ar_bit_is_set(const uint8_t * p_frame) return (p_frame[ACK_REQUEST_OFFSET] & ACK_REQUEST_BIT) ? true : false; } +static bool is_long_frame(const uint8_t * p_frame) +{ + return (p_frame[MP_LONG_FRAME_OFFSET] & MP_LONG_FRAME_MASK) ? true: false; +} + +static bool is_mp_frame(const uint8_t * p_frame) +{ + return (p_frame[FRAME_TYPE_OFFSET] & FRAME_TYPE_MASK) == FRAME_TYPE_MULTIPURPOSE; +} + +static uint8_t mp_addressing_offset_get(const uint8_t * p_frame) +{ + if (nrf_802154_frame_parser_mp_dsn_suppress_bit_is_set(p_frame)) + { + return PHR_SIZE + FCF_SIZE; + } + else + { + return PHR_SIZE + FCF_SIZE + DSN_SIZE; + } +} + +static bool mp_src_addr_is_present(const uint8_t * p_frame) +{ + return (p_frame[MP_SRC_ADDR_TYPE_OFFSET] & MP_SRC_ADDR_TYPE_MASK) != MP_SRC_ADDR_TYPE_NONE; +} + +static bool mp_dst_addr_is_present(const uint8_t * p_frame) +{ + return (p_frame[MP_DEST_ADDR_TYPE_OFFSET] & MP_DEST_ADDR_TYPE_MASK) != MP_DEST_ADDR_TYPE_NONE; +} + +static uint8_t mp_src_addr_size_get(const uint8_t * p_frame) +{ + switch (p_frame[MP_SRC_ADDR_TYPE_OFFSET] & MP_SRC_ADDR_TYPE_MASK) + { + case MP_SRC_ADDR_TYPE_NONE: + return 0; + + case MP_SRC_ADDR_TYPE_SHORT: + return SHORT_ADDRESS_SIZE; + + case MP_SRC_ADDR_TYPE_EXTENDED: + return EXTENDED_ADDRESS_SIZE; + + default: + return NRF_802154_FRAME_PARSER_INVALID_OFFSET; + } +} + +static uint8_t mp_dst_addr_size_get(const uint8_t * p_frame) +{ + switch (p_frame[MP_DEST_ADDR_TYPE_OFFSET] & MP_DEST_ADDR_TYPE_MASK) + { + case MP_DEST_ADDR_TYPE_NONE: + return 0; + + case MP_DEST_ADDR_TYPE_SHORT: + return SHORT_ADDRESS_SIZE; + + case MP_DEST_ADDR_TYPE_EXTENDED: + return EXTENDED_ADDRESS_SIZE; + + default: + return NRF_802154_FRAME_PARSER_INVALID_OFFSET; + } +} + +static bool mp_dst_panid_is_present(const uint8_t * p_frame) +{ + return (p_frame[MP_DST_PANID_PRESENT_OFFSET] & MP_DST_PANID_PRESENT_BIT) ? true: false; +} + +static bool mp_security_is_enabled(const uint8_t * p_frame) +{ + return p_frame[MP_SECURITY_ENABLED_OFFSET] & MP_SECURITY_ENABLED_BIT ? true : false; +} + +static uint8_t mp_security_offset_get(const uint8_t * p_frame) +{ + uint8_t dst_addr_offset = nrf_802154_frame_parser_mp_dst_addr_offset_get(p_frame); + uint8_t dst_panid_offset = nrf_802154_frame_parser_mp_dst_panid_offset_get(p_frame); + uint8_t dst_addr_size = mp_dst_addr_size_get(p_frame); + uint8_t src_addr_offset = nrf_802154_frame_parser_mp_src_addr_offset_get(p_frame); + uint8_t src_addr_size = src_addr_size_get(p_frame); + + if (mp_src_addr_is_present(p_frame)) + { + if ((src_addr_size == NRF_802154_FRAME_PARSER_INVALID_OFFSET) || + (src_addr_offset == NRF_802154_FRAME_PARSER_INVALID_OFFSET)) + { + return NRF_802154_FRAME_PARSER_INVALID_OFFSET; + } + + return src_addr_offset + src_addr_size; + } + else if (dst_addr_offset) + { + if (dst_addr_size == NRF_802154_FRAME_PARSER_INVALID_OFFSET) + { + return NRF_802154_FRAME_PARSER_INVALID_OFFSET; + } + + return dst_addr_offset + dst_addr_size; + } + else if (dst_panid_offset) + { + return dst_panid_offset + PAN_ID_SIZE; + } + else + { + return mp_addressing_offset_get(p_frame); + } +} + +static uint8_t mp_key_id_size_get(const uint8_t * p_frame) +{ + switch (*nrf_802154_frame_parser_mp_sec_ctrl_get(p_frame) & KEY_ID_MODE_MASK) + { + case KEY_ID_MODE_1: + return KEY_ID_MODE_1_SIZE; + + case KEY_ID_MODE_2: + return KEY_ID_MODE_2_SIZE; + + case KEY_ID_MODE_3: + return KEY_ID_MODE_3_SIZE; + + default: + return 0; + } +} + +static uint8_t mp_ie_offset_get(const uint8_t * p_frame) +{ + uint8_t security_offset = mp_security_offset_get(p_frame); + uint8_t key_id_offset = nrf_802154_frame_parser_mp_key_id_offset_get(p_frame); + + if (!mp_security_is_enabled(p_frame)) + { + if (security_offset == NRF_802154_FRAME_PARSER_INVALID_OFFSET) + { + return NRF_802154_FRAME_PARSER_INVALID_OFFSET; + } + + return security_offset; + } + else + { + if (key_id_offset == NRF_802154_FRAME_PARSER_INVALID_OFFSET) + { + return NRF_802154_FRAME_PARSER_INVALID_OFFSET; + } + + return key_id_offset + mp_key_id_size_get(p_frame); + } +} + +bool nrf_802154_frame_parser_is_mp_frame(const uint8_t * p_frame) +{ + return (p_frame[FRAME_TYPE_OFFSET] & FRAME_TYPE_MASK) == FRAME_TYPE_MULTIPURPOSE; +} + +bool nrf_802154_frame_parser_is_mp_long_frame(const uint8_t * p_frame) +{ + return (p_frame[MP_LONG_FRAME_OFFSET] & MP_LONG_FRAME_MASK) ? true: false; +} + +bool nrf_802154_frame_parser_mp_dst_addr_is_extended(const uint8_t * p_frame) +{ + return (p_frame[MP_DEST_ADDR_TYPE_OFFSET] & MP_DEST_ADDR_TYPE_MASK) == MP_DEST_ADDR_TYPE_EXTENDED; +} + +bool nrf_802154_frame_parser_mp_src_addr_is_extended(const uint8_t * p_frame) +{ + return (p_frame[MP_SRC_ADDR_TYPE_OFFSET] & MP_SRC_ADDR_TYPE_MASK) == MP_SRC_ADDR_TYPE_EXTENDED; +} + +bool nrf_802154_frame_parser_mp_src_addr_is_short(const uint8_t * p_frame) +{ + return (p_frame[MP_SRC_ADDR_TYPE_OFFSET] & MP_SRC_ADDR_TYPE_MASK) == MP_SRC_ADDR_TYPE_SHORT; +} + +bool nrf_802154_frame_parser_mp_dsn_suppress_bit_is_set(const uint8_t * p_frame) +{ + return (p_frame[MP_DSN_SUPPRESS_OFFSET] & MP_DSN_SUPPRESS_BIT) ? true : false; +} + +bool nrf_802154_frame_parser_mp_ie_present_bit_is_set(const uint8_t * p_frame) +{ + return (p_frame[MP_IE_PRESENT_OFFSET] & MP_IE_PRESENT_BIT) ? true : false; +} + +bool nrf_802154_frame_parser_mp_ar_bit_is_set(const uint8_t * p_frame) +{ + return (p_frame[MP_ACK_REQUEST_OFFSET] & MP_ACK_REQUEST_BIT) ? true : false; +} + +uint8_t nrf_802154_frame_parser_mp_dst_panid_offset_get(const uint8_t * p_frame) +{ + if (mp_dst_panid_is_present(p_frame)) + { + return mp_addressing_offset_get(p_frame); + } + else + { + return 0; + } +} + +uint8_t nrf_802154_frame_parser_mp_dst_addr_offset_get(const uint8_t * p_frame) +{ + uint8_t panid_offset = nrf_802154_frame_parser_mp_dst_panid_offset_get(p_frame); + + if (mp_dst_addr_is_present(p_frame)) + { + return (panid_offset == 0) ? mp_addressing_offset_get(p_frame) : panid_offset + PAN_ID_SIZE; + } + else + { + return 0; + } +} + +uint8_t nrf_802154_frame_parser_mp_dst_addr_end_offset_get(const uint8_t * p_frame) +{ + uint8_t offset = mp_addressing_offset_get(p_frame); + uint8_t dst_addr_size = mp_dst_addr_size_get(p_frame); + + if (!is_long_frame(p_frame)) + { + // Do not process the short multipurpose frame. + return NRF_802154_FRAME_PARSER_INVALID_OFFSET; + } + + if (dst_addr_size == NRF_802154_FRAME_PARSER_INVALID_OFFSET) + { + return NRF_802154_FRAME_PARSER_INVALID_OFFSET; + } + + if (mp_dst_panid_is_present(p_frame)) + { + offset += PAN_ID_SIZE; + } + + offset += dst_addr_size; + + return offset; +} + +uint8_t nrf_802154_frame_parser_mp_src_addr_offset_get(const uint8_t * p_frame) +{ + uint8_t dst_panid_offset = nrf_802154_frame_parser_mp_dst_panid_offset_get(p_frame); + uint8_t dst_addr_offset = nrf_802154_frame_parser_mp_dst_addr_offset_get(p_frame); + uint8_t dst_addr_size = dst_addr_size_get(p_frame); + + if (mp_src_addr_is_present(p_frame)) + { + if (dst_addr_offset) + { + if (dst_addr_size == NRF_802154_FRAME_PARSER_INVALID_OFFSET) + { + return NRF_802154_FRAME_PARSER_INVALID_OFFSET; + } + + return dst_addr_offset + dst_addr_size; + } + else if (dst_panid_offset) + { + return dst_panid_offset + PAN_ID_SIZE; + } + else + { + return mp_addressing_offset_get(p_frame); + } + } + else + { + return 0; + } +} + +uint8_t nrf_802154_frame_parser_mp_addressing_end_offset_get(const uint8_t * p_frame) +{ + return mp_security_offset_get(p_frame); +} + +uint8_t nrf_802154_frame_parser_mp_sec_ctrl_offset_get(const uint8_t * p_frame) +{ + if (mp_security_is_enabled(p_frame)) + { + return mp_security_offset_get(p_frame); + } + else + { + return 0; + } +} + +uint8_t nrf_802154_frame_parser_mp_key_id_offset_get(const uint8_t * p_frame) +{ + uint8_t sec_ctrl_offset = nrf_802154_frame_parser_mp_sec_ctrl_offset_get(p_frame); + + if (sec_ctrl_offset == 0) + { + return 0; + } + + if (NRF_802154_FRAME_PARSER_INVALID_OFFSET == sec_ctrl_offset) + { + return NRF_802154_FRAME_PARSER_INVALID_OFFSET; + } + + if (p_frame[sec_ctrl_offset] & FRAME_COUNTER_SUPPRESS_BIT) + { + return sec_ctrl_offset + SECURITY_CONTROL_SIZE; + } + else + { + return sec_ctrl_offset + SECURITY_CONTROL_SIZE + FRAME_COUNTER_SIZE; + } +} + +uint8_t nrf_802154_frame_parser_mp_ie_header_offset_get(const uint8_t * p_frame) +{ + if (nrf_802154_frame_parser_mp_ie_present_bit_is_set(p_frame)) + { + return ie_offset_get(p_frame); + } + else + { + return 0; + } +} + +const uint8_t * nrf_802154_frame_parser_mp_sec_ctrl_get(const uint8_t * p_frame) +{ + uint8_t sec_ctrl_offset = nrf_802154_frame_parser_mp_sec_ctrl_offset_get(p_frame); + + return ((sec_ctrl_offset == 0) || (NRF_802154_FRAME_PARSER_INVALID_OFFSET == sec_ctrl_offset)) ? + NULL : &p_frame[sec_ctrl_offset]; +} + +static bool nrf_802154_frame_parser_mp_mhr_parse(const uint8_t * p_frame, + nrf_802154_frame_parser_mhr_data_t * p_fields) +{ + uint8_t offset = mp_addressing_offset_get(p_frame); + bool is_dst_panid_present = mp_dst_panid_is_present(p_frame); + + if (is_dst_panid_present) + { + p_fields->p_dst_panid = &p_frame[offset]; + offset += PAN_ID_SIZE; + } + else + { + p_fields->p_dst_panid = NULL; + } + + if (mp_dst_addr_is_present(p_frame)) + { + p_fields->p_dst_addr = &p_frame[offset]; + p_fields->dst_addr_size = mp_dst_addr_size_get(p_frame); + offset += (p_fields->dst_addr_size); + + if (p_fields->dst_addr_size == NRF_802154_FRAME_PARSER_INVALID_OFFSET) + { + return false; + } + } + else + { + p_fields->p_dst_addr = NULL; + p_fields->dst_addr_size = 0; + } + + if (is_dst_panid_present) + { + p_fields->p_src_panid = p_fields->p_dst_panid; + } + + if (mp_src_addr_is_present(p_frame)) + { + p_fields->p_src_addr = &p_frame[offset]; + p_fields->src_addr_size = mp_src_addr_size_get(p_frame); + offset += (p_fields->src_addr_size); + + if (p_fields->src_addr_size == NRF_802154_FRAME_PARSER_INVALID_OFFSET) + { + return false; + } + } + else + { + p_fields->p_src_addr = NULL; + p_fields->src_addr_size = 0; + } + + p_fields->addressing_end_offset = offset; + + if (mp_security_is_enabled(p_frame)) + { + p_fields->p_sec_ctrl = &p_frame[offset]; + } + else + { + p_fields->p_sec_ctrl = NULL; + } + + return true; +} /*************************************************************************************************** * @section Offset functions **************************************************************************************************/ @@ -573,8 +984,8 @@ const uint8_t * nrf_802154_frame_parser_src_addr_get(const uint8_t * p_frame, } } -bool nrf_802154_frame_parser_mhr_parse(const uint8_t * p_frame, - nrf_802154_frame_parser_mhr_data_t * p_fields) +static bool nrf_802154_frame_parser_non_mp_mhr_parse(const uint8_t * p_frame, + nrf_802154_frame_parser_mhr_data_t * p_fields) { uint8_t offset = addressing_offset_get(p_frame); bool is_dst_panid_present = dst_panid_is_present(p_frame); @@ -653,6 +1064,19 @@ bool nrf_802154_frame_parser_mhr_parse(const uint8_t * p_fr return true; } +bool nrf_802154_frame_parser_mhr_parse(const uint8_t * p_frame, + nrf_802154_frame_parser_mhr_data_t * p_fields) +{ + if (is_mp_frame(p_frame)) + { + return nrf_802154_frame_parser_mp_mhr_parse(p_frame, p_fields); + } + else + { + return nrf_802154_frame_parser_non_mp_mhr_parse(p_frame, p_fields); + } +} + const uint8_t * nrf_802154_frame_parser_sec_ctrl_get(const uint8_t * p_frame) { uint8_t sec_ctrl_offset = nrf_802154_frame_parser_sec_ctrl_offset_get(p_frame); diff --git a/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_frame_parser.h b/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_frame_parser.h index 0b216d30..85f07b6d 100644 --- a/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_frame_parser.h +++ b/third_party/NordicSemiconductor/drivers/radio/mac_features/nrf_802154_frame_parser.h @@ -314,4 +314,187 @@ const uint8_t * nrf_802154_frame_parser_ie_header_get(const uint8_t * p_frame); */ uint8_t nrf_802154_frame_parser_ie_header_offset_get(const uint8_t * p_frame); +/** + * @brief Determines if the frame is multipurpose frame. + * + * @param[in] p_frame Pointer to a frame to be checked. + * + * @retval true The frame is multipurpose frame. + * @retval false The frame is not multipurpose frame. + * + */ +bool nrf_802154_frame_parser_is_mp_frame(const uint8_t * p_frame); + +/** + * @brief Determines if the multipurpose frame is long frame. + * + * @param[in] p_frame Pointer to a multipurpose frame to be checked. + * + * @retval true The multipurpose frame is long frame. + * @retval false The multipurpose frame is not long frame. + * + */ +bool nrf_802154_frame_parser_is_mp_long_frame(const uint8_t * p_frame); + +/** + * @brief Determines if the destination address in the multipurpose frame is extended. + * + * @param[in] p_frame Pointer to a multipurpose frame to be checked. + * + * @retval true Destination address is extended. + * @retval false Destination address is not extended. + */ +bool nrf_802154_frame_parser_mp_dst_addr_is_extended(const uint8_t * p_frame); + +/** + * @brief Determines if the source address of the multipurpose frame is extended. + * + * @param[in] p_frame Pointer to a multipurpose frame to be checked. + * + * @retval true Source address is extended. + * @retval false Source address is not extended. + */ +bool nrf_802154_frame_parser_mp_src_addr_is_extended(const uint8_t * p_frame); + +/** + * @brief Determines if the source address of the multipurpose frame is short. + * + * @param[in] p_frame Pointer to a multipurpose frame to be checked. + * + * @retval true The source address is short. + * @retval false The source address is not short. + * + */ +bool nrf_802154_frame_parser_mp_src_addr_is_short(const uint8_t * p_frame); + +/** + * @brief Determines if the sequence number suppression bit of the multipurpose frame is set. + * + * @param[in] p_frame Pointer to a multipurpose frame to be checked. + * + * @retval true Sequence number suppression bit is set. + * @retval false Sequence number suppression bit is not set. + * + */ +bool nrf_802154_frame_parser_mp_dsn_suppress_bit_is_set(const uint8_t * p_frame); + +/** + * @brief Determines if the IE present bit of the multipurpose frame is set. + * + * @param[in] p_frame Pointer to a multipurpose frame to be checked. + * + * @retval true IE present bit is set. + * @retval false IE present bit is not set. + * + */ +bool nrf_802154_frame_parser_mp_ie_present_bit_is_set(const uint8_t * p_frame); + +/** + * @brief Determines if the Ack Request (AR) bit of the multipurpose frame is set. + * + * @param[in] p_frame Pointer to a multipurpose frame to be checked. + * + * @retval true AR bit is set. + * @retval false AR bit is not set. + * + */ +bool nrf_802154_frame_parser_mp_ar_bit_is_set(const uint8_t * p_frame); + +/** + * @brief Gets the offset of the destination PAN ID field in the multipurpose frame. + * + * @param[in] p_frame Pointer to a multipurpose frame. + * + * @returns Offset in bytes of the destination PAN ID field, including one byte + * of the frame length. + * @returns Zero in case the destination PAN ID cannot be retrieved. + * + */ +uint8_t nrf_802154_frame_parser_mp_dst_panid_offset_get(const uint8_t * p_frame); + +/** + * @brief Gets the offset of the destination address field in the multipurpose frame. + * + * @param[in] p_frame Pointer to a multipurpose frame. + * + * @returns Offset in bytes of the destination address field, including one byte + * of the frame length. + * @returns Zero if the destination address cannot be retrieved. + * + */ +uint8_t nrf_802154_frame_parser_mp_dst_addr_offset_get(const uint8_t * p_frame); + +/** + * @brief Gets the offset of the end of the destination address fields in the multipurpose frame. + * + * @param[in] p_frame Pointer to a multipurpose frame. + * + * @returns Offset of the first byte following the destination addressing fields in the MHR. + * + */ +uint8_t nrf_802154_frame_parser_mp_dst_addr_end_offset_get(const uint8_t * p_frame); + +/** + * @brief Gets the offset of the source address field in the multipurpose frame. + * + * @param[in] p_frame Pointer to a multipurpose frame. + * + * @returns Offset in bytes of the source address field, including one byte of the frame length. + * @returns Zero if the source address cannot be retrieved. + * + */ +uint8_t nrf_802154_frame_parser_mp_src_addr_offset_get(const uint8_t * p_frame); + +/** + * @brief Gets the offset of the first byte after the addressing fields in MHR. + * + * @param[in] p_frame Pointer to a multipurpose frame. + * + * @returns Offset in bytes of the first byte after the addressing fields in MHR. + */ +uint8_t nrf_802154_frame_parser_mp_addressing_end_offset_get(const uint8_t * p_frame); + +/** + * @brief Gets the offset of the security control field in the multipurpose frame. + * + * @param[in] p_frame Pointer to a multipurpose frame. + * + * @returns Offset in bytes of the security control field, including one byte of the frame length. + * @returns Zero if the security control cannot be retrieved (that is, security is not enabled). + * + */ +uint8_t nrf_802154_frame_parser_mp_sec_ctrl_offset_get(const uint8_t * p_frame); + +/** + * @brief Gets the key identifier field in the multipurpose frame. + * + * @param[in] p_frame Pointer to a multipurpose frame. + * + * @returns Pointer to the first byte of the key identifier field in @p p_frame. + * @returns NULL if the key identifier cannot be retrieved (that is, security is not enabled). + * + */ +uint8_t nrf_802154_frame_parser_mp_key_id_offset_get(const uint8_t * p_frame); + +/** + * @brief Gets the offset of the IE header field in the multipurpose frame. + * + * @param[in] p_frame Pointer to a multipurpose frame. + * + * @returns Offset in bytes of the IE header field, including one byte of the frame length. + * @returns Zero if the IE header cannot be retrieved (that is, the IE header is not present). + * + */ +uint8_t nrf_802154_frame_parser_mp_ie_header_offset_get(const uint8_t * p_frame); + +/** + * @brief Gets the security control field in the multipurpose frame. + * + * @param[in] p_frame Pointer to a multipurpose frame. + * + * @returns Pointer to the first byte of the security control field in @p p_frame. + * @returns NULL if the security control cannot be retrieved (that is, security is not enabled). + * + */ +const uint8_t * nrf_802154_frame_parser_mp_sec_ctrl_get(const uint8_t * p_frame); #endif // NRF_802154_FRAME_PARSER_H diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_const.h b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_const.h index bc324ae4..71ee1489 100644 --- a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_const.h +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_const.h @@ -124,6 +124,39 @@ #define SRC_ADDR_OFFSET_SHORT_DST 8 ///< Offset of the source address in the Data frame if the destination address is short. #define SRC_ADDR_OFFSET_EXTENDED_DST 14 ///< Offset of the source address in the Data frame if the destination address is extended. +#define MP_LONG_FRAME_OFFSET 1 ///< Byte containing the long frame control bit in the multipurpose frame. +#define MP_LONG_FRAME_MASK (1 << 3) ///< Long frame control bit in the multipurpose frame. + +#define MP_DEST_ADDR_TYPE_OFFSET 1 ///< Byte containing the destination address type in the multipurpose frame. +#define MP_DEST_ADDR_TYPE_NONE 0x00 ///< Bits containing a not-present destination address type in the multipurpose frame. +#define MP_DEST_ADDR_TYPE_SHORT (2 << 4) ///< Bits containing the short destination address type in the multipurpose frame. +#define MP_DEST_ADDR_TYPE_EXTENDED (3 << 4) ///< Bits containing the extended destination address type in the multipurpose frame. +#define MP_DEST_ADDR_TYPE_MASK (3 << 4) ///< Mask of bits containing the destination address type in the multipurpose frame. + +#define MP_SRC_ADDR_TYPE_OFFSET 1 ///< Byte containing the source address type in the multipurpose frame. +#define MP_SRC_ADDR_TYPE_NONE 0x00 ///< Bits containing a not-present source address type in the multipurpose frame. +#define MP_SRC_ADDR_TYPE_SHORT (2 << 6) ///< Bits containing the short source address type in the multipurpose frame. +#define MP_SRC_ADDR_TYPE_EXTENDED (3 << 6) ///< Bits containing the extended source address type in the multipurpose frame. +#define MP_SRC_ADDR_TYPE_MASK (3 << 6) ///< Mask of bits containing the source address type in the multipurpose frame. + +#define MP_DST_PANID_PRESENT_OFFSET 2 ///< Byte containing the PAN ID present bit in the multipurpose frame. +#define MP_DST_PANID_PRESENT_BIT (1 << 0) ///< PAN ID present bit in the multipurpose frame. + +#define MP_SECURITY_ENABLED_OFFSET 2 ///< Byte containing the security enabled bit in the multipurpose frame. +#define MP_SECURITY_ENABLED_BIT (1 << 1) ///< Security enabled bit in the multipurpose frame. + +#define MP_DSN_SUPPRESS_OFFSET 2 ///< Byte containing the sequence number suppression bit in the multipurpose frame. +#define MP_DSN_SUPPRESS_BIT (1 << 2) ///< Sequence number suppression bit in the multipurpose frame. + +#define MP_FRAME_PENDING_OFFSET 2 ///< Byte containing the the frame pending bit in the multipurpose frame. +#define MP_FRAME_PENDING_BIT (1 << 3) ///< Frame pending bit in the multipurpose frame. + +#define MP_ACK_REQUEST_OFFSET 2 ///< Byte containing the ACK request bit in the multipurpose frame. +#define MP_ACK_REQUEST_BIT (1 << 6) ///< ACK request bit in the multipurpose frame. + +#define MP_IE_PRESENT_OFFSET 2 ///< Byte containning the IE present bit in the multipurpose frame. +#define MP_IE_PRESENT_BIT (1 << 7) ///< IE present bit in the multipurpose frame. + #define DSN_SIZE 1 ///< Size of the Sequence Number field. #define FCF_SIZE 2 ///< Size of the FCF field. #define FCS_SIZE 2 ///< Size of the FCS field. diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c index b5260845..54da3c3e 100644 --- a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c @@ -533,7 +533,12 @@ static void channel_set(uint8_t channel) */ static bool ack_is_requested(const uint8_t * p_frame) { - return nrf_802154_frame_parser_ar_bit_is_set(p_frame); + if (nrf_802154_frame_parser_is_mp_frame(p_frame)) + { + return nrf_802154_frame_parser_mp_ar_bit_is_set(p_frame); + } else { + return nrf_802154_frame_parser_ar_bit_is_set(p_frame); + } } /***************************************************************************************************