mirror of
https://github.com/espressif/openthread.git
synced 2026-10-25 08:43:48 +00:00
[mac-frame] add util functions to generate ack (#4884)
This commit adds mac frame util functions to generate acks (both Imm and Enh acks) from a received frame. These funtions are utils APIs for platforms which don't provide ack generation. This commit also introduces compile options for CSL to control the CSL IE related part.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "mac_frame.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include "mac/mac_frame.hpp"
|
||||
|
||||
using namespace ot;
|
||||
@@ -125,3 +126,36 @@ void otMacFrameProcessTransmitAesCcm(otRadioFrame *aFrame, const otExtAddress *a
|
||||
{
|
||||
static_cast<Mac::TxFrame *>(aFrame)->ProcessTransmitAesCcm(*static_cast<const Mac::ExtAddress *>(aExtAddress));
|
||||
}
|
||||
|
||||
bool otMacFrameIsVersion2015(const otRadioFrame *aFrame)
|
||||
{
|
||||
return static_cast<const Mac::Frame *>(aFrame)->IsVersion2015();
|
||||
}
|
||||
|
||||
void otMacFrameGenerateImmAck(const otRadioFrame *aFrame, bool aIsFramePending, otRadioFrame *aAckFrame)
|
||||
{
|
||||
assert(aFrame != NULL && aAckFrame != NULL);
|
||||
|
||||
static_cast<Mac::TxFrame *>(aAckFrame)->GenerateImmAck(*static_cast<const Mac::RxFrame *>(aFrame), aIsFramePending);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
|
||||
otError otMacFrameGenerateEnhAck(const otRadioFrame *aFrame,
|
||||
bool aIsFramePending,
|
||||
const uint8_t * aIeData,
|
||||
uint8_t aIeLength,
|
||||
otRadioFrame * aAckFrame)
|
||||
{
|
||||
assert(aFrame != NULL && aAckFrame != NULL);
|
||||
|
||||
return static_cast<Mac::TxFrame *>(aAckFrame)->GenerateEnhAck(*static_cast<const Mac::RxFrame *>(aFrame),
|
||||
aIsFramePending, aIeData, aIeLength);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_CSL_RECEIVER_ENABLE
|
||||
void otMacFrameSetCslIe(otRadioFrame *aFrame, uint16_t aCslPeriod, uint16_t aCslPhase)
|
||||
{
|
||||
static_cast<Mac::Frame *>(aFrame)->SetCslIe(aCslPeriod, aCslPhase);
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_CSL_RECEIVER_ENABLE
|
||||
#endif // OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
|
||||
|
||||
@@ -161,6 +161,56 @@ uint8_t otMacFrameGetSequence(const otRadioFrame *aFrame);
|
||||
*/
|
||||
void otMacFrameProcessTransmitAesCcm(otRadioFrame *aFrame, const otExtAddress *aExtAddress);
|
||||
|
||||
/**
|
||||
* Tell if the version of @p aFrame is 2015.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @retval true It is a version 2015 frame.
|
||||
* @retval false It is not a version 2015 frame.
|
||||
*
|
||||
*/
|
||||
bool otMacFrameIsVersion2015(const otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Generate Imm-Ack for @p aFrame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
* @param[in] aIsFramePending Value of the ACK's frame pending bit.
|
||||
* @param[out] aAckFrame A pointer to the ack frame to be generated.
|
||||
*
|
||||
*/
|
||||
void otMacFrameGenerateImmAck(const otRadioFrame *aFrame, bool aIsFramePending, otRadioFrame *aAckFrame);
|
||||
|
||||
/**
|
||||
* Generate Enh-Ack for @p aFrame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
* @param[in] aIsFramePending Value of the ACK's frame pending bit.
|
||||
* @param[in] aIeData A pointer to the IE data portion of the ACK to be sent.
|
||||
* @param[in] aIeLength The length of IE data portion of the ACK to be sent.
|
||||
* @param[out] aAckFrame A pointer to the ack frame to be generated.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully generated Enh Ack in @p aAckFrame.
|
||||
* @retval OT_ERROR_PARSE @p aFrame has incorrect format.
|
||||
*
|
||||
*/
|
||||
otError otMacFrameGenerateEnhAck(const otRadioFrame *aFrame,
|
||||
bool aIsFramePending,
|
||||
const uint8_t * aIeData,
|
||||
uint8_t aIeLength,
|
||||
otRadioFrame * aAckFrame);
|
||||
|
||||
/**
|
||||
* Set CSL IE content into the frame.
|
||||
*
|
||||
* @param[inout] aFrame A pointer to the frame to be modified.
|
||||
* @param[in] aCslPeriod CSL Period in CSL IE.
|
||||
* @param[in] aCslPhase CSL Phase in CSL IE.
|
||||
*
|
||||
*/
|
||||
void otMacFrameSetCslIe(otRadioFrame *aFrame, uint16_t aCslPeriod, uint16_t aCslPhase);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user