Skip to content

Commit

Permalink
[mac-frame] remove unused Set{Src/Dst}{Addr/PanId}() methods (opent…
Browse files Browse the repository at this point in the history
…hread#10779)

Recent changes updated `Mac::Frame` to use `FrameBuilder` for
preparing frame headers. With the adoption of this model, the
previously defined `Set` methods for setting source/destination
address or PAN ID are no longer used or needed. This commit removes
them.
  • Loading branch information
abtink authored Oct 3, 2024
1 parent f0cb5a3 commit 262b998
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 168 deletions.
100 changes: 0 additions & 100 deletions src/core/mac/mac_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,6 @@ Error Frame::GetDstPanId(PanId &aPanId) const
return error;
}

void Frame::SetDstPanId(PanId aPanId)
{
uint8_t index = FindDstPanIdIndex();

OT_ASSERT(index != kInvalidIndex);
LittleEndian::WriteUint16(aPanId, &mPsdu[index]);
}

uint8_t Frame::GetSequence(void) const
{
OT_ASSERT(IsSequencePresent());
Expand Down Expand Up @@ -500,40 +492,6 @@ Error Frame::GetDstAddr(Address &aAddress) const
return error;
}

void Frame::SetDstAddr(ShortAddress aShortAddress)
{
OT_ASSERT(GetFcfDstAddr(GetFrameControlField()) == kFcfAddrShort);
LittleEndian::WriteUint16(aShortAddress, &mPsdu[FindDstAddrIndex()]);
}

void Frame::SetDstAddr(const ExtAddress &aExtAddress)
{
uint8_t index = FindDstAddrIndex();

OT_ASSERT(GetFcfDstAddr(GetFrameControlField()) == kFcfAddrExt);
OT_ASSERT(index != kInvalidIndex);

aExtAddress.CopyTo(&mPsdu[index], ExtAddress::kReverseByteOrder);
}

void Frame::SetDstAddr(const Address &aAddress)
{
switch (aAddress.GetType())
{
case Address::kTypeShort:
SetDstAddr(aAddress.GetShort());
break;

case Address::kTypeExtended:
SetDstAddr(aAddress.GetExtended());
break;

default:
OT_ASSERT(false);
OT_UNREACHABLE_CODE(break);
}
}

uint8_t Frame::FindSrcPanIdIndex(void) const
{
uint16_t fcf = GetFrameControlField();
Expand Down Expand Up @@ -627,18 +585,6 @@ Error Frame::GetSrcPanId(PanId &aPanId) const
return error;
}

Error Frame::SetSrcPanId(PanId aPanId)
{
Error error = kErrorNone;
uint8_t index = FindSrcPanIdIndex();

VerifyOrExit(index != kInvalidIndex, error = kErrorParse);
LittleEndian::WriteUint16(aPanId, &mPsdu[index]);

exit:
return error;
}

uint8_t Frame::FindSrcAddrIndex(void) const
{
uint16_t fcf = GetFrameControlField();
Expand Down Expand Up @@ -700,43 +646,6 @@ Error Frame::GetSrcAddr(Address &aAddress) const
return error;
}

void Frame::SetSrcAddr(ShortAddress aShortAddress)
{
uint8_t index = FindSrcAddrIndex();

OT_ASSERT(GetFcfSrcAddr(GetFrameControlField()) == kFcfAddrShort);
OT_ASSERT(index != kInvalidIndex);

LittleEndian::WriteUint16(aShortAddress, &mPsdu[index]);
}

void Frame::SetSrcAddr(const ExtAddress &aExtAddress)
{
uint8_t index = FindSrcAddrIndex();

OT_ASSERT(GetFcfSrcAddr(GetFrameControlField()) == kFcfAddrExt);
OT_ASSERT(index != kInvalidIndex);

aExtAddress.CopyTo(&mPsdu[index], ExtAddress::kReverseByteOrder);
}

void Frame::SetSrcAddr(const Address &aAddress)
{
switch (aAddress.GetType())
{
case Address::kTypeShort:
SetSrcAddr(aAddress.GetShort());
break;

case Address::kTypeExtended:
SetSrcAddr(aAddress.GetExtended());
break;

default:
OT_ASSERT(false);
}
}

Error Frame::GetSecurityControlField(uint8_t &aSecurityControlField) const
{
Error error = kErrorNone;
Expand All @@ -750,15 +659,6 @@ Error Frame::GetSecurityControlField(uint8_t &aSecurityControlField) const
return error;
}

void Frame::SetSecurityControlField(uint8_t aSecurityControlField)
{
uint8_t index = FindSecurityHeaderIndex();

OT_ASSERT(index != kInvalidIndex);

mPsdu[index] = aSecurityControlField;
}

uint8_t Frame::FindSecurityHeaderIndex(void) const
{
uint8_t index;
Expand Down
65 changes: 0 additions & 65 deletions src/core/mac/mac_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,6 @@ class Frame : public otRadioFrame
*/
Error GetDstPanId(PanId &aPanId) const;

/**
* Sets the Destination PAN Identifier.
*
* @param[in] aPanId The Destination PAN Identifier.
*/
void SetDstPanId(PanId aPanId);

/**
* Indicates whether or not the Destination Address is present for this object.
*
Expand All @@ -371,27 +364,6 @@ class Frame : public otRadioFrame
*/
Error GetDstAddr(Address &aAddress) const;

/**
* Sets the Destination Address.
*
* @param[in] aShortAddress The Destination Address.
*/
void SetDstAddr(ShortAddress aShortAddress);

/**
* Sets the Destination Address.
*
* @param[in] aExtAddress The Destination Address.
*/
void SetDstAddr(const ExtAddress &aExtAddress);

/**
* Sets the Destination Address.
*
* @param[in] aAddress The Destination Address.
*/
void SetDstAddr(const Address &aAddress);

/**
* Indicates whether or not the Source Address is present for this object.
*
Expand All @@ -409,15 +381,6 @@ class Frame : public otRadioFrame
*/
Error GetSrcPanId(PanId &aPanId) const;

/**
* Sets the Source PAN Identifier.
*
* @param[in] aPanId The Source PAN Identifier.
*
* @retval kErrorNone Successfully set the Source PAN Identifier.
*/
Error SetSrcPanId(PanId aPanId);

/**
* Indicates whether or not the Source Address is present for this object.
*
Expand All @@ -435,27 +398,6 @@ class Frame : public otRadioFrame
*/
Error GetSrcAddr(Address &aAddress) const;

/**
* Sets the Source Address.
*
* @param[in] aShortAddress The Source Address.
*/
void SetSrcAddr(ShortAddress aShortAddress);

/**
* Sets the Source Address.
*
* @param[in] aExtAddress The Source Address.
*/
void SetSrcAddr(const ExtAddress &aExtAddress);

/**
* Sets the Source Address.
*
* @param[in] aAddress The Source Address.
*/
void SetSrcAddr(const Address &aAddress);

/**
* Gets the Security Control Field.
*
Expand All @@ -466,13 +408,6 @@ class Frame : public otRadioFrame
*/
Error GetSecurityControlField(uint8_t &aSecurityControlField) const;

/**
* Sets the Security Control Field.
*
* @param[in] aSecurityControlField The Security Control Field.
*/
void SetSecurityControlField(uint8_t aSecurityControlField);

/**
* Gets the Security Level Identifier.
*
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/test_mac_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,6 @@ void TestMacFrameApi(void)
VerifyOrQuit(frame.IsSrcAddrPresent());
SuccessOrQuit(frame.GetSecurityControlField(scf));
VerifyOrQuit(scf == 0x0d);
frame.SetSecurityControlField(0xff);
SuccessOrQuit(frame.GetSecurityControlField(scf));
VerifyOrQuit(scf == 0xff);
#endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2

// IEEE 802.15.4-2006 Mac Command
Expand Down

0 comments on commit 262b998

Please sign in to comment.