Skip to content

Commit

Permalink
[diag] set mIsSecurityProcessed field before sending frames (openth…
Browse files Browse the repository at this point in the history
…read#11235)

The radio driver will set the `mInfo.mTxInfo.mIsSecurityProcessed` field
to True after the radio driver encrypts the frame. Which causes subsequent
frames to be sent will not be encrypted.

This commit sets the `mInfo.mTxInfo.mIsSecurityProcessed` field before
sending each frame.
  • Loading branch information
zhanglongxia authored Feb 11, 2025
1 parent f7080a9 commit 68a5ce3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/core/diags/factory_diags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ Diags::Diags(Instance &aInstance)
void Diags::ResetTxPacket(void)
{
mIsHeaderUpdated = false;
mIsSecurityProcessed = false;
mTxPacket->mInfo.mTxInfo.mTxDelayBaseTime = 0;
mTxPacket->mInfo.mTxInfo.mTxDelay = 0;
mTxPacket->mInfo.mTxInfo.mMaxCsmaBackoffs = 0;
Expand All @@ -221,7 +222,6 @@ void Diags::ResetTxPacket(void)
mTxPacket->mInfo.mTxInfo.mIsARetx = false;
mTxPacket->mInfo.mTxInfo.mCsmaCaEnabled = false;
mTxPacket->mInfo.mTxInfo.mCslPresent = false;
mTxPacket->mInfo.mTxInfo.mIsSecurityProcessed = false;
}

Error Diags::ProcessFrame(uint8_t aArgsLength, char *aArgs[])
Expand Down Expand Up @@ -312,7 +312,6 @@ Error Diags::ProcessFrame(uint8_t aArgsLength, char *aArgs[])

ResetTxPacket();
mTxPacket->mInfo.mTxInfo.mCsmaCaEnabled = csmaCaEnabled;
mTxPacket->mInfo.mTxInfo.mIsSecurityProcessed = securityProcessed;
mTxPacket->mInfo.mTxInfo.mTxPower = txPower;
mTxPacket->mInfo.mTxInfo.mTxDelayBaseTime = txDelayBaseTime;
mTxPacket->mInfo.mTxInfo.mTxDelay = txDelay;
Expand All @@ -321,6 +320,7 @@ Error Diags::ProcessFrame(uint8_t aArgsLength, char *aArgs[])
mTxPacket->mInfo.mTxInfo.mRxChannelAfterTxDone = rxChannelAfterTxDone;
mTxPacket->mLength = size;
mIsHeaderUpdated = isHeaderUpdated;
mIsSecurityProcessed = securityProcessed;
mIsTxPacketSet = true;

exit:
Expand Down Expand Up @@ -561,9 +561,10 @@ Error Diags::TransmitPacket(void)

if (mIsTxPacketSet)
{
// The `mInfo.mTxInfo.mIsHeaderUpdated` field may be updated by the radio driver after the frame is sent,
// set the `mInfo.mTxInfo.mIsHeaderUpdated` field before transmitting the frame.
mTxPacket->mInfo.mTxInfo.mIsHeaderUpdated = mIsHeaderUpdated;
// The `mInfo.mTxInfo.mIsHeaderUpdated` and `mInfo.mTxInfo.mIsSecurityProcessed` fields may be updated by
// the radio driver after the frame is sent. Here sets these fields field before transmitting the frame.
mTxPacket->mInfo.mTxInfo.mIsHeaderUpdated = mIsHeaderUpdated;
mTxPacket->mInfo.mTxInfo.mIsSecurityProcessed = mIsSecurityProcessed;
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/core/diags/factory_diags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ class Diags : public InstanceLocator, private NonCopyable
uint8_t mTxLen;
TxCmd mCurTxCmd;
bool mIsHeaderUpdated : 1;
bool mIsSecurityProcessed : 1;
bool mIsTxPacketSet : 1;
bool mIsAsyncSend : 1;
bool mDiagSendOn : 1;
Expand Down

0 comments on commit 68a5ce3

Please sign in to comment.