mirror of
https://github.com/espressif/openthread.git
synced 2026-08-21 18:09:52 +00:00
[simulation] support transmit security at simulation radio (#5118)
This commit adds transmit security support for simulation radio so that security Enh-ACK could be handled at radio layer. This commit also fixes issue #5041.
This commit is contained in:
@@ -159,3 +159,46 @@ void otMacFrameSetCslIe(otRadioFrame *aFrame, uint16_t aCslPeriod, uint16_t aCsl
|
||||
static_cast<Mac::Frame *>(aFrame)->SetCslIe(aCslPeriod, aCslPhase);
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
|
||||
bool otMacFrameIsSecurityEnabled(otRadioFrame *aFrame)
|
||||
{
|
||||
return static_cast<const Mac::Frame *>(aFrame)->GetSecurityEnabled();
|
||||
}
|
||||
|
||||
bool otMacFrameIsKeyIdMode1(otRadioFrame *aFrame)
|
||||
{
|
||||
uint8_t keyIdMode;
|
||||
otError error;
|
||||
|
||||
error = static_cast<const Mac::Frame *>(aFrame)->GetKeyIdMode(keyIdMode);
|
||||
|
||||
return (error == OT_ERROR_NONE) ? (keyIdMode == Mac::Frame::kKeyIdMode1) : false;
|
||||
}
|
||||
|
||||
uint8_t otMacFrameGetKeyId(otRadioFrame *aFrame)
|
||||
{
|
||||
uint8_t keyId = 0;
|
||||
|
||||
IgnoreError(static_cast<const Mac::Frame *>(aFrame)->GetKeyId(keyId));
|
||||
|
||||
return keyId;
|
||||
}
|
||||
|
||||
void otMacFrameSetKeyId(otRadioFrame *aFrame, uint8_t aKeyId)
|
||||
{
|
||||
static_cast<Mac::Frame *>(aFrame)->SetKeyId(aKeyId);
|
||||
}
|
||||
|
||||
uint32_t otMacFrameGetFrameCounter(otRadioFrame *aFrame)
|
||||
{
|
||||
uint32_t frameCounter = UINT32_MAX;
|
||||
|
||||
IgnoreError(static_cast<Mac::Frame *>(aFrame)->GetFrameCounter(frameCounter));
|
||||
|
||||
return frameCounter;
|
||||
}
|
||||
|
||||
void otMacFrameSetFrameCounter(otRadioFrame *aFrame, uint32_t aFrameCounter)
|
||||
{
|
||||
static_cast<Mac::Frame *>(aFrame)->SetFrameCounter(aFrameCounter);
|
||||
}
|
||||
|
||||
@@ -211,6 +211,66 @@ otError otMacFrameGenerateEnhAck(const otRadioFrame *aFrame,
|
||||
*/
|
||||
void otMacFrameSetCslIe(otRadioFrame *aFrame, uint16_t aCslPeriod, uint16_t aCslPhase);
|
||||
|
||||
/**
|
||||
* Tell if the security of @p aFrame is enabled.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @retval true The frame has security enabled.
|
||||
* @retval false The frame does not have security enabled.
|
||||
*
|
||||
*/
|
||||
bool otMacFrameIsSecurityEnabled(otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Tell if the key ID mode of @p aFrame is 1.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @retval true The frame key ID mode is 1.
|
||||
* @retval false The frame security is not enabled or key ID mode is not 1.
|
||||
*
|
||||
*/
|
||||
bool otMacFrameIsKeyIdMode1(otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Get the key ID of @p aFrame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @returns The key ID of the frame with key ID mode 1. Returns 0 if failed.
|
||||
*
|
||||
*/
|
||||
uint8_t otMacFrameGetKeyId(otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Set key ID to @p aFrame with key ID mode 1.
|
||||
*
|
||||
* @param[inout] aFrame A pointer to the frame to be modified.
|
||||
* @param[in] aKeyId Key ID to be set to the frame.
|
||||
*
|
||||
*/
|
||||
void otMacFrameSetKeyId(otRadioFrame *aFrame, uint8_t aKeyId);
|
||||
|
||||
/**
|
||||
* Get the frame counter of @p aFrame.
|
||||
*
|
||||
* @param[in] aFrame A pointer to the frame.
|
||||
*
|
||||
* @returns The frame counter of the frame. Returns UINT32_MAX if failed.
|
||||
*
|
||||
*/
|
||||
uint32_t otMacFrameGetFrameCounter(otRadioFrame *aFrame);
|
||||
|
||||
/**
|
||||
* Set frame counter to @p aFrame.
|
||||
*
|
||||
* @param[inout] aFrame A pointer to the frame to be modified.
|
||||
* @param[in] aFrameCounter Frame counter to be set to the frame.
|
||||
*
|
||||
*/
|
||||
void otMacFrameSetFrameCounter(otRadioFrame *aFrame, uint32_t aFrameCounter);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user