mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 15:47:46 +00:00
[mac-frame] remove Multipurpose frame format support (#13281)
This commit removes the Multipurpose (MP) frame format support (`OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME`) and associated wake-up frame handling. Multipurpose frame support was originally added as a provisional and experimental solution for the Wakeup Coordinator / Wake-up End Device (WED) wake mechanism. However, updated Thread specification designs decided against using the Multipurpose frame format for wake frames. Removing this now obsolete MP frame logic cleans up and simplifies MAC frame parsing and generation ahead of implementing the updated wake mechanism. Key changes: - Removes `OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME` from `mac.h` and adds an `#error` check in `openthread-core-config-check.h`. - Simplifies `Mac::Frame` control field (FCF) parsing and helper methods by removing MP-specific frame handling and template helpers. - Replaces legacy MP wake-up frame helpers in `mac_frame.cpp` with temporary placeholder stubs. - Cleans up unit tests in `test_mac_frame.cpp` related to MP frame format. - Removes the now obsolete `v1_5-cli-p2p-link.exp` test.
This commit is contained in:
@@ -409,16 +409,6 @@
|
||||
#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME
|
||||
*
|
||||
* Define to 1 to enable support for IEEE 802.15.4 MAC Multipurpose frame format.
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME
|
||||
#define OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME \
|
||||
(OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE || OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE
|
||||
*
|
||||
|
||||
@@ -702,4 +702,9 @@
|
||||
#error "OPENTHREAD_CONFIG_MLE_IP_ADDRS_TO_REGISTER is removed. All addresses are now registered."
|
||||
#endif
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME
|
||||
#error "OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME was removed and is no longer supported. " \
|
||||
"It was originally implemented as a provisional solution for the wake mechanism."
|
||||
#endif
|
||||
|
||||
#endif // OT_CORE_CONFIG_OPENTHREAD_CORE_CONFIG_CHECK_H_
|
||||
|
||||
+18
-125
@@ -252,21 +252,6 @@ void TxFrame::Info::PrepareHeadersIn(TxFrame &aTxFrame) const
|
||||
aTxFrame.mLength = builder.GetLength();
|
||||
}
|
||||
|
||||
void Frame::SetFrameControlField(uint16_t aFcf)
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME
|
||||
if (IsShortFcf(aFcf))
|
||||
{
|
||||
OT_ASSERT((aFcf >> 8) == 0);
|
||||
mPsdu[0] = static_cast<uint8_t>(aFcf);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
LittleEndian::WriteUint16(aFcf, mPsdu);
|
||||
}
|
||||
}
|
||||
|
||||
Error Frame::ValidatePsdu(void) const
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
@@ -298,44 +283,15 @@ exit:
|
||||
#if OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE || OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE
|
||||
bool Frame::IsWakeupFrame(void) const
|
||||
{
|
||||
const uint16_t fcf = GetFrameControlField();
|
||||
bool result = false;
|
||||
uint8_t keyIdMode;
|
||||
uint8_t firstIeIndex;
|
||||
Address srcAddress;
|
||||
const ConnectionIe *connectionIe;
|
||||
|
||||
// Wake-up frame is a Multipurpose frame without Ack Request...
|
||||
VerifyOrExit((fcf & kFcfFrameTypeMask) == kTypeMultipurpose);
|
||||
VerifyOrExit((fcf & kMpFcfAckRequest) == 0);
|
||||
|
||||
// ... with extended source address...
|
||||
SuccessOrExit(GetSrcAddr(srcAddress));
|
||||
VerifyOrExit(srcAddress.IsExtended());
|
||||
|
||||
// ... secured with Key Id Mode 2...
|
||||
SuccessOrExit(GetKeyIdMode(keyIdMode));
|
||||
VerifyOrExit(keyIdMode == kKeyIdMode2);
|
||||
|
||||
// ... that has Rendezvous Time IE and Connection IE...
|
||||
VerifyOrExit(Has<RendezvousTimeIe>());
|
||||
VerifyOrExit((connectionIe = Find<ConnectionIe>()) != nullptr);
|
||||
|
||||
// ... but no other IEs nor payload.
|
||||
firstIeIndex = FindHeaderIeIndex();
|
||||
VerifyOrExit(mPsdu + firstIeIndex + sizeof(RendezvousTimeIe) + connectionIe->GetSize() == GetFooter());
|
||||
|
||||
result = true;
|
||||
|
||||
exit:
|
||||
return result;
|
||||
// Placeholder implementation following removal of legacy Multipurpose frame format.
|
||||
return false;
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE || OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE
|
||||
#endif
|
||||
|
||||
void Frame::SetAckRequest(bool aAckRequest)
|
||||
{
|
||||
uint16_t fcf = GetFrameControlField();
|
||||
uint16_t mask = Select<kFcfAckRequest, kMpFcfAckRequest>(fcf);
|
||||
uint16_t mask = kFcfAckRequest;
|
||||
|
||||
if (aAckRequest)
|
||||
{
|
||||
@@ -352,7 +308,7 @@ void Frame::SetAckRequest(bool aAckRequest)
|
||||
void Frame::SetFramePending(bool aFramePending)
|
||||
{
|
||||
uint16_t fcf = GetFrameControlField();
|
||||
uint16_t mask = Select<kFcfFramePending, kMpFcfFramePending>(fcf);
|
||||
uint16_t mask = kFcfFramePending;
|
||||
|
||||
if (aFramePending)
|
||||
{
|
||||
@@ -369,7 +325,7 @@ void Frame::SetFramePending(bool aFramePending)
|
||||
void Frame::SetIePresent(bool aIePresent)
|
||||
{
|
||||
uint16_t fcf = GetFrameControlField();
|
||||
uint16_t mask = Select<kFcfIePresent, kMpFcfIePresent>(fcf);
|
||||
uint16_t mask = kFcfIePresent;
|
||||
|
||||
if (aIePresent)
|
||||
{
|
||||
@@ -386,7 +342,7 @@ void Frame::SetIePresent(bool aIePresent)
|
||||
uint8_t Frame::SkipSequenceIndex(void) const
|
||||
{
|
||||
uint16_t fcf = GetFrameControlField();
|
||||
uint8_t index = GetFcfSize(fcf);
|
||||
uint8_t index = kFcfSize;
|
||||
|
||||
if (IsSequencePresent(fcf))
|
||||
{
|
||||
@@ -412,14 +368,7 @@ bool Frame::IsDstPanIdPresent(uint16_t aFcf)
|
||||
{
|
||||
bool present;
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME
|
||||
if (IsMultipurpose(aFcf))
|
||||
{
|
||||
present = (aFcf & kMpFcfPanidPresent) != 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (IsVersion2015(aFcf))
|
||||
if (IsVersion2015(aFcf))
|
||||
{
|
||||
// Original table at `InitMacHeader()`
|
||||
//
|
||||
@@ -485,14 +434,14 @@ uint8_t Frame::GetSequence(void) const
|
||||
{
|
||||
OT_ASSERT(IsSequencePresent());
|
||||
|
||||
return GetPsdu()[GetFcfSize(GetFrameControlField())];
|
||||
return GetPsdu()[kFcfSize];
|
||||
}
|
||||
|
||||
void Frame::SetSequence(uint8_t aSequence)
|
||||
{
|
||||
OT_ASSERT(IsSequencePresent());
|
||||
|
||||
GetPsdu()[GetFcfSize(GetFrameControlField())] = aSequence;
|
||||
GetPsdu()[kFcfSize] = aSequence;
|
||||
}
|
||||
|
||||
uint8_t Frame::FindDstAddrIndex(void) const { return SkipSequenceIndex() + (IsDstPanIdPresent() ? sizeof(PanId) : 0); }
|
||||
@@ -556,15 +505,7 @@ bool Frame::IsSrcPanIdPresent(uint16_t aFcf)
|
||||
{
|
||||
bool present;
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME
|
||||
if (IsMultipurpose(aFcf))
|
||||
{
|
||||
// Sources PAN ID is implicitly equal to Destination PAN ID in Multipurpose frames
|
||||
present = false;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (IsVersion2015(aFcf) && ((aFcf & (kFcfDstAddrMask | kFcfSrcAddrMask)) == (kFcfDstAddrExt | kFcfSrcAddrExt)))
|
||||
if (IsVersion2015(aFcf) && ((aFcf & (kFcfDstAddrMask | kFcfSrcAddrMask)) == (kFcfDstAddrExt | kFcfSrcAddrExt)))
|
||||
{
|
||||
// Special case for a IEEE 802.15.4-2015 frame: When both
|
||||
// addresses are extended, then the source PAN iD is not present
|
||||
@@ -1004,7 +945,7 @@ exit:
|
||||
|
||||
uint8_t Frame::CalculateAddrFieldSize(uint16_t aFcf)
|
||||
{
|
||||
uint8_t size = GetFcfSize(aFcf) + (IsSequencePresent(aFcf) ? kDsnSize : 0);
|
||||
uint8_t size = kFcfSize + (IsSequencePresent(aFcf) ? kDsnSize : 0);
|
||||
|
||||
// This static method calculates the size (number of bytes) of
|
||||
// Address header field for a given Frame Control `aFcf` value.
|
||||
@@ -1467,56 +1408,14 @@ exit:
|
||||
#if OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE
|
||||
Error TxFrame::GenerateWakeupFrame(PanId aPanId, const WakeupRequest &aWakeupRequest, const Address &aSource)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
uint16_t fcf;
|
||||
uint8_t secCtl;
|
||||
uint8_t wakeupIdLength;
|
||||
FrameBuilder builder;
|
||||
Address dest;
|
||||
// Placeholder implementation following removal of legacy Multipurpose frame format.
|
||||
OT_UNUSED_VARIABLE(aPanId);
|
||||
OT_UNUSED_VARIABLE(aWakeupRequest);
|
||||
OT_UNUSED_VARIABLE(aSource);
|
||||
|
||||
fcf = kTypeMultipurpose | kMpFcfLongFrame | kMpFcfPanidPresent | kMpFcfSecurityEnabled | kMpFcfSequenceSuppression |
|
||||
kMpFcfIePresent;
|
||||
|
||||
VerifyOrExit(!aSource.IsNone(), error = kErrorInvalidArgs);
|
||||
|
||||
if (aWakeupRequest.IsWakeupByExtAddress())
|
||||
{
|
||||
wakeupIdLength = 0;
|
||||
dest.SetExtended(aWakeupRequest.GetExtAddress());
|
||||
}
|
||||
else
|
||||
{
|
||||
wakeupIdLength = GetWakeupIdLength(aWakeupRequest.GetWakeupId());
|
||||
dest.SetNone();
|
||||
}
|
||||
|
||||
fcf |= DetermineFcfAddrType(dest, kMpFcfDstAddrShift);
|
||||
fcf |= DetermineFcfAddrType(aSource, kMpFcfSrcAddrShift);
|
||||
|
||||
builder.Init(mPsdu, GetMtu());
|
||||
|
||||
IgnoreError(builder.AppendUint<kLittleEndian>(fcf));
|
||||
IgnoreError(builder.AppendUint<kLittleEndian>(aPanId));
|
||||
IgnoreError(builder.AppendMacAddress(dest));
|
||||
IgnoreError(builder.AppendMacAddress(aSource));
|
||||
|
||||
secCtl = kKeyIdMode2 | kSecurityEncMic32;
|
||||
IgnoreError(builder.AppendUint8(secCtl));
|
||||
builder.AppendLength(CalculateSecurityHeaderSize(secCtl) - sizeof(secCtl));
|
||||
|
||||
builder.Append<RendezvousTimeIe>()->Init();
|
||||
|
||||
builder.Append<ConnectionIe>()->Init(wakeupIdLength);
|
||||
builder.AppendLength(wakeupIdLength);
|
||||
|
||||
builder.AppendLength(CalculateMicSize(secCtl) + GetFcsSize());
|
||||
|
||||
mLength = builder.GetLength();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
return kErrorFailed;
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE
|
||||
#endif
|
||||
|
||||
bool RxFrame::IsSecuredWith(KeyIdModeFlags aFlags) const
|
||||
{
|
||||
@@ -1644,12 +1543,6 @@ Frame::InfoString Frame::ToInfoString(void) const
|
||||
|
||||
break;
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME
|
||||
case kTypeMultipurpose:
|
||||
string.Append("MP");
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
string.Append("%d", type);
|
||||
break;
|
||||
|
||||
+19
-98
@@ -37,6 +37,7 @@
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include "common/as_core_type.hpp"
|
||||
#include "common/bit_utils.hpp"
|
||||
#include "common/const_cast.hpp"
|
||||
#include "common/encoding.hpp"
|
||||
#include "common/numeric_limits.hpp"
|
||||
@@ -230,8 +231,6 @@ public:
|
||||
/**
|
||||
* Sets the Frame Pending bit.
|
||||
*
|
||||
* @note This method must not be called on a Multipurpose frame with short Frame Control field.
|
||||
*
|
||||
* @param[in] aFramePending The Frame Pending bit.
|
||||
*/
|
||||
void SetFramePending(bool aFramePending);
|
||||
@@ -247,8 +246,6 @@ public:
|
||||
/**
|
||||
* Sets the Ack Request bit.
|
||||
*
|
||||
* @note This method must not be called on a Multipurpose frame with short Frame Control field.
|
||||
*
|
||||
* @param[in] aAckRequest The Ack Request bit.
|
||||
*/
|
||||
void SetAckRequest(bool aAckRequest);
|
||||
@@ -256,8 +253,6 @@ public:
|
||||
/**
|
||||
* Indicates whether or not the PanId Compression bit is set.
|
||||
*
|
||||
* @note This method must not be called on a Multipurpose frame, which lacks this flag.
|
||||
*
|
||||
* @retval TRUE If the PanId Compression bit is set.
|
||||
* @retval FALSE If the PanId Compression bit is not set.
|
||||
*/
|
||||
@@ -274,8 +269,6 @@ public:
|
||||
/**
|
||||
* Sets the IE Present bit.
|
||||
*
|
||||
* @note This method must not be called on a Multipurpose frame with short Frame Control field.
|
||||
*
|
||||
* @param[in] aIePresent The IE Present bit.
|
||||
*/
|
||||
void SetIePresent(bool aIePresent);
|
||||
@@ -698,22 +691,9 @@ public:
|
||||
*
|
||||
* @returns The Frame Control field.
|
||||
*/
|
||||
uint16_t GetFrameControlField(void) const
|
||||
{
|
||||
uint16_t fcf = mPsdu[0];
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME
|
||||
if (!IsShortFcf(fcf))
|
||||
#endif
|
||||
{
|
||||
fcf |= (mPsdu[1] << 8);
|
||||
}
|
||||
|
||||
return fcf;
|
||||
}
|
||||
uint16_t GetFrameControlField(void) const { return LittleEndian::ReadUint16(mPsdu); }
|
||||
|
||||
protected:
|
||||
static constexpr uint8_t kShortFcfSize = sizeof(uint8_t);
|
||||
static constexpr uint8_t kSecurityControlSize = sizeof(uint8_t);
|
||||
static constexpr uint8_t kFrameCounterSize = sizeof(uint32_t);
|
||||
static constexpr uint8_t kCommandIdSize = sizeof(uint8_t);
|
||||
@@ -745,25 +725,6 @@ protected:
|
||||
static constexpr uint16_t kFcfSrcAddrExt = kFcfAddrExt << kFcfSrcAddrShift;
|
||||
static constexpr uint16_t kFcfSrcAddrMask = kFcfAddrMask << kFcfSrcAddrShift;
|
||||
|
||||
// Frame Control field format for MAC Multipurpose frame
|
||||
static constexpr uint16_t kMpFcfLongFrame = 1 << 3;
|
||||
static constexpr uint16_t kMpFcfDstAddrShift = 4;
|
||||
static constexpr uint16_t kMpFcfDstAddrNone = kFcfAddrNone << kMpFcfDstAddrShift;
|
||||
static constexpr uint16_t kMpFcfDstAddrShort = kFcfAddrShort << kMpFcfDstAddrShift;
|
||||
static constexpr uint16_t kMpFcfDstAddrExt = kFcfAddrExt << kMpFcfDstAddrShift;
|
||||
static constexpr uint16_t kMpFcfDstAddrMask = kFcfAddrMask << kMpFcfDstAddrShift;
|
||||
static constexpr uint16_t kMpFcfSrcAddrShift = 6;
|
||||
static constexpr uint16_t kMpFcfSrcAddrNone = kFcfAddrNone << kMpFcfSrcAddrShift;
|
||||
static constexpr uint16_t kMpFcfSrcAddrShort = kFcfAddrShort << kMpFcfSrcAddrShift;
|
||||
static constexpr uint16_t kMpFcfSrcAddrExt = kFcfAddrExt << kMpFcfSrcAddrShift;
|
||||
static constexpr uint16_t kMpFcfSrcAddrMask = kFcfAddrMask << kMpFcfSrcAddrShift;
|
||||
static constexpr uint16_t kMpFcfPanidPresent = 1 << 8;
|
||||
static constexpr uint16_t kMpFcfSecurityEnabled = 1 << 9;
|
||||
static constexpr uint16_t kMpFcfSequenceSuppression = 1 << 10;
|
||||
static constexpr uint16_t kMpFcfFramePending = 1 << 11;
|
||||
static constexpr uint16_t kMpFcfAckRequest = 1 << 14;
|
||||
static constexpr uint16_t kMpFcfIePresent = 1 << 15;
|
||||
|
||||
static constexpr uint8_t kSecLevelMask = 7 << 0;
|
||||
static constexpr uint8_t kKeyIdModeMask = 3 << 3;
|
||||
|
||||
@@ -782,7 +743,7 @@ protected:
|
||||
static constexpr uint8_t kInvalidSize = kInvalidIndex;
|
||||
static constexpr uint8_t kMaxPsduSize = kInvalidSize - 1;
|
||||
|
||||
void SetFrameControlField(uint16_t aFcf);
|
||||
void SetFrameControlField(uint16_t aFcf) { LittleEndian::WriteUint16(aFcf, mPsdu); }
|
||||
uint8_t SkipSequenceIndex(void) const;
|
||||
uint8_t FindDstPanIdIndex(void) const;
|
||||
uint8_t FindDstAddrIndex(void) const;
|
||||
@@ -796,63 +757,23 @@ protected:
|
||||
uint8_t FindHeaderIeIndex(void) const;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME
|
||||
static uint8_t GetFcfSize(uint16_t aFcf) { return IsShortFcf(aFcf) ? kShortFcfSize : kFcfSize; }
|
||||
#else
|
||||
// clang-format off
|
||||
static uint8_t GetFcfSize(uint16_t /* aFcf */) { return kFcfSize; }
|
||||
// clang-format on
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_MULTIPURPOSE_FRAME
|
||||
template <uint16_t kValue, uint16_t kMpValue> static uint16_t Select(uint16_t aFcf)
|
||||
{
|
||||
return IsMultipurpose(aFcf) ? kMpValue : kValue;
|
||||
}
|
||||
#else
|
||||
template <uint16_t kValue, uint16_t kMpValue> static uint16_t Select(uint16_t /* aFcf */) { return kValue; }
|
||||
#endif
|
||||
|
||||
template <uint16_t kValue, uint16_t kMpValue> static uint16_t MaskFcf(uint16_t aFcf)
|
||||
{
|
||||
return aFcf & Select<kValue, kMpValue>(aFcf);
|
||||
}
|
||||
|
||||
static uint16_t GetFcfDstAddr(uint16_t aFcf)
|
||||
{
|
||||
return MaskFcf<kFcfDstAddrMask, kMpFcfDstAddrMask>(aFcf) >> Select<kFcfDstAddrShift, kMpFcfDstAddrShift>(aFcf);
|
||||
}
|
||||
|
||||
static uint16_t GetFcfSrcAddr(uint16_t aFcf)
|
||||
{
|
||||
return MaskFcf<kFcfSrcAddrMask, kMpFcfSrcAddrMask>(aFcf) >> Select<kFcfSrcAddrShift, kMpFcfSrcAddrShift>(aFcf);
|
||||
}
|
||||
|
||||
static bool IsMultipurpose(uint16_t aFcf) { return (aFcf & kFcfFrameTypeMask) == kTypeMultipurpose; }
|
||||
static bool IsShortFcf(uint16_t aFcf)
|
||||
{
|
||||
return (aFcf & (kFcfFrameTypeMask | kMpFcfLongFrame)) == (kTypeMultipurpose | 0);
|
||||
}
|
||||
static bool IsSequencePresent(uint16_t aFcf)
|
||||
{
|
||||
return !MaskFcf<kFcfSequenceSuppression, kMpFcfSequenceSuppression>(aFcf);
|
||||
}
|
||||
static bool IsDstAddrPresent(uint16_t aFcf) { return MaskFcf<kFcfDstAddrMask, kMpFcfDstAddrMask>(aFcf); }
|
||||
static bool IsDstPanIdPresent(uint16_t aFcf);
|
||||
static bool IsSrcAddrPresent(uint16_t aFcf) { return MaskFcf<kFcfSrcAddrMask, kMpFcfSrcAddrMask>(aFcf); }
|
||||
static bool IsSrcPanIdPresent(uint16_t aFcf);
|
||||
static bool IsSecurityEnabled(uint16_t aFcf) { return MaskFcf<kFcfSecurityEnabled, kMpFcfSecurityEnabled>(aFcf); }
|
||||
static bool IsFramePending(uint16_t aFcf) { return MaskFcf<kFcfFramePending, kMpFcfFramePending>(aFcf); }
|
||||
static bool IsIePresent(uint16_t aFcf) { return MaskFcf<kFcfIePresent, kMpFcfIePresent>(aFcf); }
|
||||
static bool IsAckRequest(uint16_t aFcf) { return MaskFcf<kFcfAckRequest, kMpFcfAckRequest>(aFcf); }
|
||||
static bool IsVersion2015(uint16_t aFcf) { return (aFcf & kFcfFrameVersionMask) == kVersion2015; }
|
||||
|
||||
static uint16_t GetFcfDstAddr(uint16_t aFcf) { return ReadBits<uint16_t, kFcfDstAddrMask>(aFcf); }
|
||||
static uint16_t GetFcfSrcAddr(uint16_t aFcf) { return ReadBits<uint16_t, kFcfSrcAddrMask>(aFcf); }
|
||||
static bool IsSequencePresent(uint16_t aFcf) { return (aFcf & kFcfSequenceSuppression) == 0; }
|
||||
static bool IsDstAddrPresent(uint16_t aFcf) { return (aFcf & kFcfDstAddrMask) != 0; }
|
||||
static bool IsSrcAddrPresent(uint16_t aFcf) { return (aFcf & kFcfSrcAddrMask) != 0; }
|
||||
static bool IsSecurityEnabled(uint16_t aFcf) { return (aFcf & kFcfSecurityEnabled) != 0; }
|
||||
static bool IsFramePending(uint16_t aFcf) { return (aFcf & kFcfFramePending) != 0; }
|
||||
static bool IsIePresent(uint16_t aFcf) { return (aFcf & kFcfIePresent) != 0; }
|
||||
static bool IsAckRequest(uint16_t aFcf) { return (aFcf & kFcfAckRequest) != 0; }
|
||||
static bool IsVersion2015(uint16_t aFcf) { return (aFcf & kFcfFrameVersionMask) == kVersion2015; }
|
||||
static bool IsDstPanIdPresent(uint16_t aFcf);
|
||||
static bool IsSrcPanIdPresent(uint16_t aFcf);
|
||||
static uint16_t DetermineFcfAddrType(const Address &aAddress, uint16_t aBitShift);
|
||||
|
||||
static uint8_t CalculateAddrFieldSize(uint16_t aFcf);
|
||||
static uint8_t CalculateSecurityHeaderSize(uint8_t aSecurityControl);
|
||||
static uint8_t CalculateKeySourceSize(uint8_t aSecurityControl);
|
||||
static uint8_t CalculateMicSize(uint8_t aSecurityControl);
|
||||
static uint8_t CalculateAddrFieldSize(uint16_t aFcf);
|
||||
static uint8_t CalculateSecurityHeaderSize(uint8_t aSecurityControl);
|
||||
static uint8_t CalculateKeySourceSize(uint8_t aSecurityControl);
|
||||
static uint8_t CalculateMicSize(uint8_t aSecurityControl);
|
||||
|
||||
private:
|
||||
#if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
#
|
||||
# Copyright (c) 2025, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
source "tests/scripts/expect/_common.exp"
|
||||
source "tests/scripts/expect/_multinode.exp"
|
||||
|
||||
set WL1 1
|
||||
set WL2 2
|
||||
set WC1 3
|
||||
set WC2 4
|
||||
set WL1_EXT_ADDRESS "deadbeefcafe0001"
|
||||
set WL2_EXT_ADDRESS "deadbeefcafe0002"
|
||||
set WC1_EXT_ADDRESS "deadbeefcafe0003"
|
||||
set WC2_EXT_ADDRESS "deadbeefcafe0004"
|
||||
|
||||
|
||||
send_user "\n\n>>> Setup WL1\n"
|
||||
spawn_node $WL1
|
||||
|
||||
setup_default_network
|
||||
|
||||
send "mode rdn\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "extaddr $WL1_EXT_ADDRESS\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "wakeup channel 11\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "routerupgradethreshold 0\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "wakeup listen enable\n"
|
||||
expect_line "Done"
|
||||
|
||||
set wl1_link_local_addr [get_ipaddr linklocal]
|
||||
|
||||
|
||||
send_user "\n\n>>> Setup WL2\n"
|
||||
spawn_node $WL2
|
||||
|
||||
setup_default_network
|
||||
|
||||
send "mode rdn\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "extaddr $WL2_EXT_ADDRESS\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "wakeup channel 11\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "routerupgradethreshold 0\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "wakeup listen enable\n"
|
||||
expect_line "Done"
|
||||
|
||||
set wl2_link_local_addr [get_ipaddr linklocal]
|
||||
|
||||
|
||||
send_user "\n\n>>> Setup WC1\n"
|
||||
spawn_node $WC1
|
||||
setup_default_network
|
||||
|
||||
send "mode rdn\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "extaddr $WC1_EXT_ADDRESS\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "wakeup channel 11\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "routerupgradethreshold 0\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
set wc1_link_local_addr [get_ipaddr linklocal]
|
||||
|
||||
|
||||
send_user "\n\n>>> Setup WC2\n"
|
||||
spawn_node $WC2
|
||||
setup_default_network
|
||||
|
||||
send "mode rdn\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "extaddr $WC2_EXT_ADDRESS\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "wakeup channel 11\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "routerupgradethreshold 0\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "ifconfig up\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "thread start\n"
|
||||
expect_line "Done"
|
||||
|
||||
set wc2_link_local_addr [get_ipaddr linklocal]
|
||||
|
||||
|
||||
send_user "\n\n>>> WC1 establishes a P2P link with WL1\n"
|
||||
switch_node $WC1
|
||||
send "p2p link extaddr $WL1_EXT_ADDRESS\n"
|
||||
expect_line "Done"
|
||||
|
||||
send_user "\n\n>>> WC1 pings WL1\n"
|
||||
send "ping $wl1_link_local_addr 20 5\n"
|
||||
for {set i 1} {$i <= 5} {incr i} {
|
||||
expect "28 bytes from $wl1_link_local_addr: icmp_seq=$i"
|
||||
}
|
||||
|
||||
sleep 1
|
||||
|
||||
|
||||
send_user "\n\n>>> WC1 establishes a P2P link with WL2\n"
|
||||
send "p2p link extaddr $WL2_EXT_ADDRESS\n"
|
||||
expect_line "Done"
|
||||
|
||||
sleep 1
|
||||
|
||||
send_user "\n\n>>> WC1 pings WL2\n"
|
||||
send "ping $wl2_link_local_addr 20 5\n"
|
||||
for {set i 6} {$i <= 10} {incr i} {
|
||||
expect "28 bytes from $wl2_link_local_addr: icmp_seq=$i"
|
||||
}
|
||||
|
||||
|
||||
send_user "\n\n>>> WC2 establishes a P2P link with WL1\n"
|
||||
switch_node $WC2
|
||||
send "p2p link extaddr $WL1_EXT_ADDRESS\n"
|
||||
expect_line "Done"
|
||||
|
||||
sleep 1
|
||||
|
||||
send_user "\n\n>>> WC2 pings WL1\n"
|
||||
send "ping $wl1_link_local_addr 20 5\n"
|
||||
for {set i 1} {$i <= 5} {incr i} {
|
||||
expect "28 bytes from $wl1_link_local_addr: icmp_seq=$i"
|
||||
}
|
||||
|
||||
|
||||
send_user "\n\n>>> WL1 pings WC1\n"
|
||||
switch_node $WL1
|
||||
|
||||
send "ping $wc1_link_local_addr 20 5\n"
|
||||
for {set i 1} {$i <= 5} {incr i} {
|
||||
expect "28 bytes from $wc1_link_local_addr: icmp_seq=$i"
|
||||
}
|
||||
|
||||
|
||||
send_user "\n\n>>> WL1 pings WC2\n"
|
||||
send "ping $wc2_link_local_addr 20 5\n"
|
||||
for {set i 6} {$i <= 10} {incr i} {
|
||||
expect "28 bytes from $wc2_link_local_addr: icmp_seq=$i"
|
||||
}
|
||||
|
||||
|
||||
send_user "\n\n>>> WL2 pings WC1\n"
|
||||
switch_node $WL2
|
||||
|
||||
send "ping $wc1_link_local_addr 20 5\n"
|
||||
for {set i 1} {$i <= 5} {incr i} {
|
||||
expect "28 bytes from $wc1_link_local_addr: icmp_seq=$i"
|
||||
}
|
||||
|
||||
|
||||
send_user "\n\n>>> WC1 tears down the P2P link with WL1\n"
|
||||
switch_node $WC1
|
||||
send "p2p unlink $WL1_EXT_ADDRESS\n"
|
||||
expect_line "Done"
|
||||
|
||||
|
||||
send_user "\n\n>>> WC2 tears down the P2P link with WL1\n"
|
||||
switch_node $WC2
|
||||
send "p2p unlink $WL1_EXT_ADDRESS\n"
|
||||
expect_line "Done"
|
||||
|
||||
|
||||
send_user "\n\n>>> WL2 tears down the P2P link with WC1\n"
|
||||
switch_node $WL2
|
||||
send "p2p unlink $WC1_EXT_ADDRESS\n"
|
||||
expect_line "Done"
|
||||
|
||||
sleep 1
|
||||
|
||||
dispose_all
|
||||
@@ -782,288 +782,6 @@ void TestMacFrameAckGeneration(void)
|
||||
#endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE
|
||||
constexpr uint16_t kMpFcfLongFrame = 1 << 3;
|
||||
constexpr uint16_t kMpFcfDstAddrShift = 4;
|
||||
constexpr uint16_t kMpFcfDstAddrNone = 0 << kMpFcfDstAddrShift;
|
||||
constexpr uint16_t kMpFcfDstAddrExt = 3 << kMpFcfDstAddrShift;
|
||||
constexpr uint16_t kMpFcfSrcAddrShift = 6;
|
||||
constexpr uint16_t kMpFcfSrcAddrShort = 2 << kMpFcfSrcAddrShift;
|
||||
constexpr uint16_t kMpFcfSrcAddrExt = 3 << kMpFcfSrcAddrShift;
|
||||
constexpr uint16_t kMpFcfPanidPresent = 1 << 8;
|
||||
constexpr uint16_t kMpFcfSecurityEnabled = 1 << 9;
|
||||
constexpr uint16_t kMpFcfSequenceSuppression = 1 << 10;
|
||||
constexpr uint16_t kMpFcfAckRequest = 1 << 14;
|
||||
constexpr uint16_t kMpFcfIePresent = 1 << 15;
|
||||
|
||||
void TestMacWakeupFrameGeneration(void)
|
||||
{
|
||||
constexpr static Mac::WakeupId kWakeupId = 0x1020;
|
||||
constexpr static uint8_t kSrcExtaddr[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
|
||||
constexpr static uint8_t kDstExtaddr[] = {0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87};
|
||||
constexpr static uint8_t kKeySource[] = {0, 0, 0, 0x1c};
|
||||
|
||||
constexpr static uint8_t kWakeupPsdu[] = {
|
||||
// Frame Control
|
||||
Mac::Frame::kTypeMultipurpose | kMpFcfLongFrame | kMpFcfDstAddrExt | kMpFcfSrcAddrExt,
|
||||
(kMpFcfPanidPresent | kMpFcfSecurityEnabled | kMpFcfSequenceSuppression | kMpFcfIePresent) >> 8,
|
||||
// PAN ID
|
||||
0xce, 0xfa,
|
||||
// Destination Address
|
||||
0x87, 0x96, 0xa5, 0xb4, 0xc3, 0xd2, 0xe1, 0xf0,
|
||||
// Source Address
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
|
||||
// Security Header
|
||||
Mac::Frame::kKeyIdMode2 | Mac::Frame::kSecurityEncMic32, 0xfc, 0xfc, 0xfc, 0xfc, 0x00, 0x00, 0x00, 0x1c, 0x1d,
|
||||
// Rendezvous Time IE
|
||||
0x82, 0x0e, 0xcd, 0xab,
|
||||
// Connection IE
|
||||
0x05, 0x00, 0x9b, 0xb8, 0xea, 0x01, 0x1c};
|
||||
|
||||
constexpr static uint8_t kWakeupPsdu2[] = {
|
||||
// Frame Control
|
||||
Mac::Frame::kTypeMultipurpose | kMpFcfLongFrame | kMpFcfDstAddrNone | kMpFcfSrcAddrExt,
|
||||
(kMpFcfPanidPresent | kMpFcfSecurityEnabled | kMpFcfSequenceSuppression | kMpFcfIePresent) >> 8,
|
||||
// PAN ID
|
||||
0xce, 0xfa,
|
||||
// No Destination Address
|
||||
// Source Address
|
||||
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
|
||||
// Security Header
|
||||
Mac::Frame::kKeyIdMode2 | Mac::Frame::kSecurityEncMic32, 0xfc, 0xfc, 0xfc, 0xfc, 0x00, 0x00, 0x00, 0x1c, 0x1d,
|
||||
// Rendezvous Time IE
|
||||
0x82, 0x0e, 0xcd, 0xab,
|
||||
// Connection IE
|
||||
0x07, 0x00, 0x9b, 0xb8, 0xea, 0x01, 0x1c, 0x20, 0x10};
|
||||
|
||||
uint8_t psdu[OT_RADIO_FRAME_MAX_SIZE];
|
||||
Mac::Address src;
|
||||
Mac::Address dst;
|
||||
Mac::Address addr;
|
||||
Mac::WakeupId wakeupId;
|
||||
Mac::WakeupRequest wakeupRequest;
|
||||
Mac::TxFrame txFrame;
|
||||
Mac::Frame rxFrame;
|
||||
Mac::ConnectionIe *connectionIe;
|
||||
|
||||
printf("TestMacWakeupFrameGeneration\n");
|
||||
|
||||
src.SetExtended(kSrcExtaddr);
|
||||
dst.SetExtended(kDstExtaddr);
|
||||
wakeupRequest.SetExtAddress(dst.GetExtended());
|
||||
txFrame.mPsdu = psdu;
|
||||
txFrame.mLength = 0;
|
||||
txFrame.mRadioType = 0;
|
||||
|
||||
SuccessOrQuit(txFrame.GenerateWakeupFrame(0xface, wakeupRequest, src));
|
||||
|
||||
// Validate that the frame satisfies the wake-up frame definition
|
||||
VerifyOrQuit(txFrame.GetType() == Mac::Frame::kTypeMultipurpose);
|
||||
VerifyOrQuit(!txFrame.GetAckRequest());
|
||||
VerifyOrQuit(txFrame.Has<Mac::RendezvousTimeIe>());
|
||||
VerifyOrQuit(txFrame.Has<Mac::ConnectionIe>());
|
||||
VerifyOrQuit(txFrame.GetPayloadLength() == 0);
|
||||
SuccessOrQuit(txFrame.GetSrcAddr(addr));
|
||||
VerifyOrQuit(CompareAddresses(src, addr));
|
||||
SuccessOrQuit(txFrame.GetDstAddr(addr));
|
||||
VerifyOrQuit(CompareAddresses(dst, addr));
|
||||
|
||||
// Initialize remaining fields and check if the frame has the expected contents
|
||||
txFrame.SetFrameCounter(0xfcfcfcfc);
|
||||
txFrame.SetKeySource(kKeySource);
|
||||
txFrame.SetKeyId(0x1d);
|
||||
txFrame.Find<Mac::RendezvousTimeIe>()->SetRendezvousTime(0xabcd);
|
||||
connectionIe = txFrame.Find<Mac::ConnectionIe>();
|
||||
connectionIe->SetRetryInterval(1);
|
||||
connectionIe->SetRetryCount(12);
|
||||
VerifyOrQuit(connectionIe->SetWakeupId(kWakeupId) == kErrorParse);
|
||||
|
||||
VerifyOrQuit(txFrame.Find<Mac::RendezvousTimeIe>()->GetRendezvousTime() == 0xabcd);
|
||||
VerifyOrQuit(connectionIe->GetRetryInterval() == 1);
|
||||
VerifyOrQuit(connectionIe->GetRetryCount() == 12);
|
||||
VerifyOrQuit(connectionIe->GetWakeupId(wakeupId) == kErrorParse);
|
||||
VerifyOrQuit(txFrame.GetLength() == sizeof(kWakeupPsdu) + txFrame.GetFooterLength());
|
||||
VerifyOrQuit(memcmp(psdu, kWakeupPsdu, sizeof(kWakeupPsdu)) == 0);
|
||||
|
||||
// Initialize RX Frame with the same PSDU and check if it's recognized as wake-up frame
|
||||
rxFrame.mPsdu = psdu;
|
||||
rxFrame.mLength = txFrame.GetLength();
|
||||
rxFrame.mRadioType = 0;
|
||||
|
||||
SuccessOrQuit(rxFrame.ValidatePsdu());
|
||||
VerifyOrQuit(rxFrame.IsWakeupFrame());
|
||||
|
||||
// Validate the wake-up frame using the wake-up identifier.
|
||||
src.SetExtended(kSrcExtaddr);
|
||||
wakeupRequest.SetWakeupId(kWakeupId);
|
||||
txFrame.mPsdu = psdu;
|
||||
txFrame.mLength = 0;
|
||||
txFrame.mRadioType = 0;
|
||||
|
||||
SuccessOrQuit(txFrame.GenerateWakeupFrame(0xface, wakeupRequest, src));
|
||||
|
||||
// Validate that the frame satisfies the wake-up frame definition
|
||||
VerifyOrQuit(txFrame.GetType() == Mac::Frame::kTypeMultipurpose);
|
||||
VerifyOrQuit(!txFrame.GetAckRequest());
|
||||
VerifyOrQuit(txFrame.Has<Mac::RendezvousTimeIe>());
|
||||
VerifyOrQuit(txFrame.Has<Mac::ConnectionIe>());
|
||||
VerifyOrQuit(txFrame.GetPayloadLength() == 0);
|
||||
SuccessOrQuit(txFrame.GetSrcAddr(addr));
|
||||
VerifyOrQuit(CompareAddresses(src, addr));
|
||||
SuccessOrQuit(txFrame.GetDstAddr(addr));
|
||||
VerifyOrQuit(addr.IsNone());
|
||||
|
||||
// Initialize remaining fields and check if the frame has the expected contents
|
||||
txFrame.SetFrameCounter(0xfcfcfcfc);
|
||||
txFrame.SetKeySource(kKeySource);
|
||||
txFrame.SetKeyId(0x1d);
|
||||
txFrame.Find<Mac::RendezvousTimeIe>()->SetRendezvousTime(0xabcd);
|
||||
connectionIe = txFrame.Find<Mac::ConnectionIe>();
|
||||
connectionIe->SetRetryInterval(1);
|
||||
connectionIe->SetRetryCount(12);
|
||||
SuccessOrQuit(connectionIe->SetWakeupId(kWakeupId));
|
||||
|
||||
VerifyOrQuit(txFrame.Find<Mac::RendezvousTimeIe>()->GetRendezvousTime() == 0xabcd);
|
||||
VerifyOrQuit(connectionIe->GetRetryInterval() == 1);
|
||||
VerifyOrQuit(connectionIe->GetRetryCount() == 12);
|
||||
SuccessOrQuit(connectionIe->GetWakeupId(wakeupId));
|
||||
VerifyOrQuit(wakeupId == kWakeupId);
|
||||
VerifyOrQuit(wakeupRequest.GetWakeupId() == kWakeupId);
|
||||
VerifyOrQuit(txFrame.GetLength() == sizeof(kWakeupPsdu2) + txFrame.GetFooterLength());
|
||||
VerifyOrQuit(memcmp(psdu, kWakeupPsdu2, sizeof(kWakeupPsdu2)) == 0);
|
||||
|
||||
// Initialize RX Frame with the same PSDU and check if it's recognized as wake-up frame
|
||||
rxFrame.mPsdu = psdu;
|
||||
rxFrame.mLength = txFrame.GetLength();
|
||||
rxFrame.mRadioType = 0;
|
||||
|
||||
SuccessOrQuit(rxFrame.ValidatePsdu());
|
||||
VerifyOrQuit(rxFrame.IsWakeupFrame());
|
||||
}
|
||||
|
||||
void TestMacWakeupFrameDetectionNegative(void)
|
||||
{
|
||||
struct TestCase
|
||||
{
|
||||
uint8_t *mPsdu;
|
||||
uint8_t mLength;
|
||||
};
|
||||
|
||||
uint8_t ackRequestedPsdu[] = {
|
||||
// Frame Control
|
||||
Mac::Frame::kTypeMultipurpose | kMpFcfLongFrame | kMpFcfDstAddrExt | kMpFcfSrcAddrExt,
|
||||
(kMpFcfPanidPresent | kMpFcfSecurityEnabled | kMpFcfSequenceSuppression | kMpFcfAckRequest | kMpFcfIePresent) >>
|
||||
8,
|
||||
// PAN ID
|
||||
0xCE, 0xFA,
|
||||
// Destination Address
|
||||
0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
|
||||
// Source Address
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
// Security Header
|
||||
Mac::Frame::kKeyIdMode2 | Mac::Frame::kSecurityEncMic32, 0xFC, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x1C, 0x1D,
|
||||
// Rendezvous Time IE
|
||||
0x82, 0x0E, 0xCD, 0xAB,
|
||||
// Connection IE
|
||||
0x05, 0x00, 0x9B, 0xB8, 0xEA, 0x01, 0x1C,
|
||||
// Footer
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
uint8_t shortAddressPsdu[] = {
|
||||
// Frame Control
|
||||
Mac::Frame::kTypeMultipurpose | kMpFcfLongFrame | kMpFcfDstAddrExt | kMpFcfSrcAddrShort,
|
||||
(kMpFcfPanidPresent | kMpFcfSecurityEnabled | kMpFcfSequenceSuppression | kMpFcfIePresent) >> 8,
|
||||
// PAN ID
|
||||
0xCE, 0xFA,
|
||||
// Destination Address
|
||||
0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
|
||||
// Source Address
|
||||
0x55, 0x55,
|
||||
// Security Header
|
||||
Mac::Frame::kKeyIdMode2 | Mac::Frame::kSecurityEncMic32, 0xFC, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x1C, 0x1D,
|
||||
// Rendezvous Time IE
|
||||
0x82, 0x0E, 0xCD, 0xAB,
|
||||
// Connection IE
|
||||
0x05, 0x00, 0x9B, 0xB8, 0xEA, 0x01, 0x1C,
|
||||
// Footer
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
uint8_t noRendezvousIePsdu[] = {
|
||||
// Frame Control
|
||||
Mac::Frame::kTypeMultipurpose | kMpFcfLongFrame | kMpFcfDstAddrExt | kMpFcfSrcAddrExt,
|
||||
(kMpFcfPanidPresent | kMpFcfSecurityEnabled | kMpFcfSequenceSuppression | kMpFcfIePresent) >> 8,
|
||||
// PAN ID
|
||||
0xCE, 0xFA,
|
||||
// Destination Address
|
||||
0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
|
||||
// Source Address
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
// Security Header
|
||||
Mac::Frame::kKeyIdMode2 | Mac::Frame::kSecurityEncMic32, 0xFC, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x1C, 0x1D,
|
||||
// Connection IE
|
||||
0x05, 0x00, 0x9B, 0xB8, 0xEA, 0x01, 0x1C,
|
||||
// Footer
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
uint8_t noConnectionIePsdu[] = {
|
||||
// Frame Control
|
||||
Mac::Frame::kTypeMultipurpose | kMpFcfLongFrame | kMpFcfDstAddrExt | kMpFcfSrcAddrExt,
|
||||
(kMpFcfPanidPresent | kMpFcfSecurityEnabled | kMpFcfSequenceSuppression | kMpFcfIePresent) >> 8,
|
||||
// PAN ID
|
||||
0xCE, 0xFA,
|
||||
// Destination Address
|
||||
0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
|
||||
// Source Address
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
// Security Header
|
||||
Mac::Frame::kKeyIdMode2 | Mac::Frame::kSecurityEncMic32, 0xFC, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x1C, 0x1D,
|
||||
// Rendezvous Time IE
|
||||
0x82, 0x0E, 0xCD, 0xAB,
|
||||
// Connection IE
|
||||
0x05, 0x00, 0x9B, 0xB8, 0xEA, 0x02, 0x1C,
|
||||
// Footer
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
uint8_t keyIdMode1Psdu[] = {
|
||||
// Frame Control
|
||||
Mac::Frame::kTypeMultipurpose | kMpFcfLongFrame | kMpFcfDstAddrExt | kMpFcfSrcAddrExt,
|
||||
(kMpFcfPanidPresent | kMpFcfSecurityEnabled | kMpFcfSequenceSuppression | kMpFcfIePresent) >> 8,
|
||||
// PAN ID
|
||||
0xCE, 0xFA,
|
||||
// Destination Address
|
||||
0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
|
||||
// Source Address
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
// Security Header
|
||||
Mac::Frame::kKeyIdMode1 | Mac::Frame::kSecurityEncMic32, 0xFC, 0xFC, 0xFC, 0xFC, 0x1D,
|
||||
// Rendezvous Time IE
|
||||
0x82, 0x0E, 0xCD, 0xAB,
|
||||
// Connection IE
|
||||
0x05, 0x00, 0x9B, 0xB8, 0xEA, 0x01, 0x1C,
|
||||
// Footer
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
const TestCase testCases[] = {
|
||||
{ackRequestedPsdu, sizeof(ackRequestedPsdu)}, {shortAddressPsdu, sizeof(shortAddressPsdu)},
|
||||
{noRendezvousIePsdu, sizeof(noRendezvousIePsdu)}, {noConnectionIePsdu, sizeof(noConnectionIePsdu)},
|
||||
{keyIdMode1Psdu, sizeof(keyIdMode1Psdu)},
|
||||
};
|
||||
|
||||
Mac::Frame rxFrame;
|
||||
|
||||
printf("TestMacWakeupFrameDetectionNegative\n");
|
||||
|
||||
for (const TestCase &testCase : testCases)
|
||||
{
|
||||
rxFrame.mPsdu = testCase.mPsdu;
|
||||
rxFrame.mLength = testCase.mLength;
|
||||
rxFrame.mRadioType = 0;
|
||||
|
||||
SuccessOrQuit(rxFrame.ValidatePsdu());
|
||||
VerifyOrQuit(!rxFrame.IsWakeupFrame());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // namespace ot
|
||||
|
||||
int main(void)
|
||||
@@ -1073,10 +791,6 @@ int main(void)
|
||||
ot::TestMacChannelMask();
|
||||
ot::TestMacFrameApi();
|
||||
ot::TestMacFrameAckGeneration();
|
||||
#if OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE
|
||||
ot::TestMacWakeupFrameGeneration();
|
||||
ot::TestMacWakeupFrameDetectionNegative();
|
||||
#endif
|
||||
printf("All tests passed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user