mirror of
https://github.com/espressif/openthread.git
synced 2026-07-31 08:07:47 +00:00
[mac-frame] simplify FCF flag changes using UpdateFcfFlag (#13282)
This commit introduces a private helper method `UpdateFcfFlag()` in `Mac::Frame` to consolidate repetitive Frame Control Field (FCF) flag modification logic across MAC frame setters.
This commit is contained in:
@@ -288,52 +288,17 @@ bool Frame::IsWakeupFrame(void) const
|
||||
}
|
||||
#endif
|
||||
|
||||
void Frame::SetAckRequest(bool aAckRequest)
|
||||
void Frame::UpdateFcfFlag(bool aSet, uint16_t aBitFlag)
|
||||
{
|
||||
uint16_t fcf = GetFrameControlField();
|
||||
uint16_t mask = kFcfAckRequest;
|
||||
uint16_t fcf = GetFrameControlField();
|
||||
|
||||
if (aAckRequest)
|
||||
if (aSet)
|
||||
{
|
||||
fcf |= mask;
|
||||
fcf |= aBitFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
fcf &= ~mask;
|
||||
}
|
||||
|
||||
SetFrameControlField(fcf);
|
||||
}
|
||||
|
||||
void Frame::SetFramePending(bool aFramePending)
|
||||
{
|
||||
uint16_t fcf = GetFrameControlField();
|
||||
uint16_t mask = kFcfFramePending;
|
||||
|
||||
if (aFramePending)
|
||||
{
|
||||
fcf |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
fcf &= ~mask;
|
||||
}
|
||||
|
||||
SetFrameControlField(fcf);
|
||||
}
|
||||
|
||||
void Frame::SetIePresent(bool aIePresent)
|
||||
{
|
||||
uint16_t fcf = GetFrameControlField();
|
||||
uint16_t mask = kFcfIePresent;
|
||||
|
||||
if (aIePresent)
|
||||
{
|
||||
fcf |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
fcf &= ~mask;
|
||||
fcf &= ~aBitFlag;
|
||||
}
|
||||
|
||||
SetFrameControlField(fcf);
|
||||
|
||||
@@ -233,7 +233,7 @@ public:
|
||||
*
|
||||
* @param[in] aFramePending The Frame Pending bit.
|
||||
*/
|
||||
void SetFramePending(bool aFramePending);
|
||||
void SetFramePending(bool aFramePending) { UpdateFcfFlag(aFramePending, kFcfFramePending); }
|
||||
|
||||
/**
|
||||
* Indicates whether or not the Ack Request bit is set.
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
*
|
||||
* @param[in] aAckRequest The Ack Request bit.
|
||||
*/
|
||||
void SetAckRequest(bool aAckRequest);
|
||||
void SetAckRequest(bool aAckRequest) { UpdateFcfFlag(aAckRequest, kFcfAckRequest); }
|
||||
|
||||
/**
|
||||
* Indicates whether or not the PanId Compression bit is set.
|
||||
@@ -271,7 +271,7 @@ public:
|
||||
*
|
||||
* @param[in] aIePresent The IE Present bit.
|
||||
*/
|
||||
void SetIePresent(bool aIePresent);
|
||||
void SetIePresent(bool aIePresent) { UpdateFcfFlag(aIePresent, kFcfIePresent); }
|
||||
|
||||
/**
|
||||
* Returns the Sequence Number value.
|
||||
@@ -744,6 +744,7 @@ protected:
|
||||
static constexpr uint8_t kMaxPsduSize = kInvalidSize - 1;
|
||||
|
||||
void SetFrameControlField(uint16_t aFcf) { LittleEndian::WriteUint16(aFcf, mPsdu); }
|
||||
void UpdateFcfFlag(bool aSet, uint16_t aBitFlag);
|
||||
uint8_t SkipSequenceIndex(void) const;
|
||||
uint8_t FindDstPanIdIndex(void) const;
|
||||
uint8_t FindDstAddrIndex(void) const;
|
||||
|
||||
Reference in New Issue
Block a user