mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 01:47:47 +00:00
[mesh-forwarder] add Mac::Addresses (src and dst address) (#7990)
This commit adds a new struct `Mac::Addresses` which represents two MAC addresses corresponding to source and destination. This type is then used in `MeshForwarder` and `Lowpan` methods allowing us to pass both source and destination addresses as one parameter.
This commit is contained in:
@@ -411,6 +411,16 @@ private:
|
||||
Type mType; ///< The address type (Short, Extended, or none).
|
||||
};
|
||||
|
||||
/**
|
||||
* This structure represents two MAC addresses corresponding to source and destination.
|
||||
*
|
||||
*/
|
||||
struct Addresses
|
||||
{
|
||||
Address mSource; ///< Source address.
|
||||
Address mDestination; ///< Destination address.
|
||||
};
|
||||
|
||||
/**
|
||||
* This class represents a MAC key.
|
||||
*
|
||||
|
||||
+4
-10
@@ -1527,10 +1527,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error Headers::DecompressFrom(const Message & aMessage,
|
||||
uint16_t aOffset,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest)
|
||||
Error Headers::DecompressFrom(const Message &aMessage, uint16_t aOffset, const Mac::Addresses &aMacAddrs)
|
||||
{
|
||||
static constexpr uint16_t kReadLength = sizeof(Lowpan::FragmentHeader::NextFrag) + sizeof(Headers);
|
||||
|
||||
@@ -1541,13 +1538,10 @@ Error Headers::DecompressFrom(const Message & aMessage,
|
||||
frameLength = aMessage.ReadBytes(aOffset, frameBuffer, sizeof(frameBuffer));
|
||||
frameData.Init(frameBuffer, frameLength);
|
||||
|
||||
return DecompressFrom(frameData, aMacSource, aMacDest, aMessage.GetInstance());
|
||||
return DecompressFrom(frameData, aMacAddrs, aMessage.GetInstance());
|
||||
}
|
||||
|
||||
Error Headers::DecompressFrom(const FrameData & aFrameData,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
Instance & aInstance)
|
||||
Error Headers::DecompressFrom(const FrameData &aFrameData, const Mac::Addresses &aMacAddrs, Instance &aInstance)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
FrameData frameData = aFrameData;
|
||||
@@ -1563,7 +1557,7 @@ Error Headers::DecompressFrom(const FrameData & aFrameData,
|
||||
VerifyOrExit(Lowpan::Lowpan::IsLowpanHc(frameData), error = kErrorNotFound);
|
||||
|
||||
SuccessOrExit(error = aInstance.Get<Lowpan::Lowpan>().DecompressBaseHeader(mIp6Header, nextHeaderCompressed,
|
||||
aMacSource, aMacDest, frameData));
|
||||
aMacAddrs, frameData));
|
||||
|
||||
switch (mIp6Header.GetNextHeader())
|
||||
{
|
||||
|
||||
+4
-12
@@ -401,25 +401,20 @@ public:
|
||||
*
|
||||
* @param[in] aMessage The message from which to read the lowpan frame.
|
||||
* @param[in] aOffset The offset in @p aMessage to start reading the frame.
|
||||
* @param[in] aMacSource The MAC source address.
|
||||
* @param[in] aMacDest The MAC destination address.
|
||||
* @param[in] aMacAddrs The MAC source and destination addresses.
|
||||
*
|
||||
* @retval kErrorNone Successfully decompressed and parsed IPv6 and UDP/TCP/ICMP6 headers.
|
||||
* @retval kErrorNotFound Lowpan frame is a next fragment and does not contain IPv6 headers.
|
||||
* @retval kErrorParse Failed to parse the headers.
|
||||
*
|
||||
*/
|
||||
Error DecompressFrom(const Message & aMessage,
|
||||
uint16_t aOffset,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest);
|
||||
Error DecompressFrom(const Message &aMessage, uint16_t aOffset, const Mac::Addresses &aMacAddrs);
|
||||
|
||||
/**
|
||||
* This method decompresses lowpan frame and parses the IPv6 and UDP/TCP/ICMP6 headers.
|
||||
*
|
||||
* @param[in] aFrameData The lowpan frame data.
|
||||
* @param[in] aMacSource The MAC source address.
|
||||
* @param[in] aMacDest The MAC destination address.
|
||||
* @param[in] aMacAddrs The MAC source and destination addresses.
|
||||
* @param[in] aInstance The OpenThread instance.
|
||||
*
|
||||
* @retval kErrorNone Successfully decompressed and parsed IPv6 and UDP/TCP/ICMP6 headers.
|
||||
@@ -427,10 +422,7 @@ public:
|
||||
* @retval kErrorParse Failed to parse the headers.
|
||||
*
|
||||
*/
|
||||
Error DecompressFrom(const FrameData & aFrameData,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
Instance & aInstance);
|
||||
Error DecompressFrom(const FrameData &aFrameData, const Mac::Addresses &aMacAddrs, Instance &aInstance);
|
||||
|
||||
/**
|
||||
* This method returns the IPv6 header.
|
||||
|
||||
@@ -360,24 +360,24 @@ exit:
|
||||
|
||||
uint16_t IndirectSender::PrepareDataFrame(Mac::TxFrame &aFrame, Child &aChild, Message &aMessage)
|
||||
{
|
||||
Ip6::Header ip6Header;
|
||||
Mac::Address macSource, macDest;
|
||||
uint16_t directTxOffset;
|
||||
uint16_t nextOffset;
|
||||
Ip6::Header ip6Header;
|
||||
Mac::Addresses macAddrs;
|
||||
uint16_t directTxOffset;
|
||||
uint16_t nextOffset;
|
||||
|
||||
// Determine the MAC source and destination addresses.
|
||||
|
||||
IgnoreError(aMessage.Read(0, ip6Header));
|
||||
|
||||
Get<MeshForwarder>().GetMacSourceAddress(ip6Header.GetSource(), macSource);
|
||||
Get<MeshForwarder>().GetMacSourceAddress(ip6Header.GetSource(), macAddrs.mSource);
|
||||
|
||||
if (ip6Header.GetDestination().IsLinkLocal())
|
||||
{
|
||||
Get<MeshForwarder>().GetMacDestinationAddress(ip6Header.GetDestination(), macDest);
|
||||
Get<MeshForwarder>().GetMacDestinationAddress(ip6Header.GetDestination(), macAddrs.mDestination);
|
||||
}
|
||||
else
|
||||
{
|
||||
aChild.GetMacAddress(macDest);
|
||||
aChild.GetMacAddress(macAddrs.mDestination);
|
||||
}
|
||||
|
||||
// Prepare the data frame from previous child's indirect offset.
|
||||
@@ -385,7 +385,7 @@ uint16_t IndirectSender::PrepareDataFrame(Mac::TxFrame &aFrame, Child &aChild, M
|
||||
directTxOffset = aMessage.GetOffset();
|
||||
aMessage.SetOffset(aChild.GetIndirectFragmentOffset());
|
||||
|
||||
nextOffset = Get<MeshForwarder>().PrepareDataFrame(aFrame, aMessage, macSource, macDest);
|
||||
nextOffset = Get<MeshForwarder>().PrepareDataFrame(aFrame, aMessage, macAddrs);
|
||||
|
||||
aMessage.SetOffset(directTxOffset);
|
||||
|
||||
|
||||
+27
-31
@@ -211,10 +211,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error Lowpan::Compress(Message & aMessage,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
FrameBuilder & aFrameBuilder)
|
||||
Error Lowpan::Compress(Message &aMessage, const Mac::Addresses &aMacAddrs, FrameBuilder &aFrameBuilder)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
uint8_t headerDepth = 0xff;
|
||||
@@ -223,7 +220,7 @@ Error Lowpan::Compress(Message & aMessage,
|
||||
{
|
||||
FrameBuilder frameBuilder = aFrameBuilder;
|
||||
|
||||
error = Compress(aMessage, aMacSource, aMacDest, aFrameBuilder, headerDepth);
|
||||
error = Compress(aMessage, aMacAddrs, aFrameBuilder, headerDepth);
|
||||
|
||||
// We exit if `Compress()` is successful. Otherwise we reset
|
||||
// the `aFrameBuidler` to its earlier state (remove all
|
||||
@@ -238,11 +235,10 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error Lowpan::Compress(Message & aMessage,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
FrameBuilder & aFrameBuilder,
|
||||
uint8_t & aHeaderDepth)
|
||||
Error Lowpan::Compress(Message & aMessage,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
FrameBuilder & aFrameBuilder,
|
||||
uint8_t & aHeaderDepth)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
uint16_t startOffset = aMessage.GetOffset();
|
||||
@@ -353,12 +349,14 @@ Error Lowpan::Compress(Message & aMessage,
|
||||
}
|
||||
else if (ip6Header.GetSource().IsLinkLocal())
|
||||
{
|
||||
SuccessOrExit(error = CompressSourceIid(aMacSource, ip6Header.GetSource(), srcContext, hcCtl, aFrameBuilder));
|
||||
SuccessOrExit(
|
||||
error = CompressSourceIid(aMacAddrs.mSource, ip6Header.GetSource(), srcContext, hcCtl, aFrameBuilder));
|
||||
}
|
||||
else if (srcContext.mIsValid)
|
||||
{
|
||||
hcCtl |= kHcSrcAddrContext;
|
||||
SuccessOrExit(error = CompressSourceIid(aMacSource, ip6Header.GetSource(), srcContext, hcCtl, aFrameBuilder));
|
||||
SuccessOrExit(
|
||||
error = CompressSourceIid(aMacAddrs.mSource, ip6Header.GetSource(), srcContext, hcCtl, aFrameBuilder));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -372,14 +370,14 @@ Error Lowpan::Compress(Message & aMessage,
|
||||
}
|
||||
else if (ip6Header.GetDestination().IsLinkLocal())
|
||||
{
|
||||
SuccessOrExit(
|
||||
error = CompressDestinationIid(aMacDest, ip6Header.GetDestination(), dstContext, hcCtl, aFrameBuilder));
|
||||
SuccessOrExit(error = CompressDestinationIid(aMacAddrs.mDestination, ip6Header.GetDestination(), dstContext,
|
||||
hcCtl, aFrameBuilder));
|
||||
}
|
||||
else if (dstContext.mIsValid)
|
||||
{
|
||||
hcCtl |= kHcDstAddrContext;
|
||||
SuccessOrExit(
|
||||
error = CompressDestinationIid(aMacDest, ip6Header.GetDestination(), dstContext, hcCtl, aFrameBuilder));
|
||||
SuccessOrExit(error = CompressDestinationIid(aMacAddrs.mDestination, ip6Header.GetDestination(), dstContext,
|
||||
hcCtl, aFrameBuilder));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -408,7 +406,7 @@ Error Lowpan::Compress(Message & aMessage,
|
||||
// For IP-in-IP the NH bit of the LOWPAN_NHC encoding MUST be set to zero.
|
||||
SuccessOrExit(error = aFrameBuilder.AppendUint8(kExtHdrDispatch | kExtHdrEidIp6));
|
||||
|
||||
error = Compress(aMessage, aMacSource, aMacDest, aFrameBuilder);
|
||||
error = Compress(aMessage, aMacAddrs, aFrameBuilder);
|
||||
|
||||
OT_FALL_THROUGH;
|
||||
|
||||
@@ -611,11 +609,10 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error Lowpan::DecompressBaseHeader(Ip6::Header & aIp6Header,
|
||||
bool & aCompressedNextHeader,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
FrameData & aFrameData)
|
||||
Error Lowpan::DecompressBaseHeader(Ip6::Header & aIp6Header,
|
||||
bool & aCompressedNextHeader,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
FrameData & aFrameData)
|
||||
{
|
||||
Error error = kErrorParse;
|
||||
uint16_t hcCtl;
|
||||
@@ -728,7 +725,7 @@ Error Lowpan::DecompressBaseHeader(Ip6::Header & aIp6Header,
|
||||
break;
|
||||
|
||||
case kHcSrcAddrMode3:
|
||||
IgnoreError(ComputeIid(aMacSource, srcContext, aIp6Header.GetSource().GetIid()));
|
||||
IgnoreError(ComputeIid(aMacAddrs.mSource, srcContext, aIp6Header.GetSource().GetIid()));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -767,7 +764,7 @@ Error Lowpan::DecompressBaseHeader(Ip6::Header & aIp6Header,
|
||||
break;
|
||||
|
||||
case kHcDstAddrMode3:
|
||||
SuccessOrExit(ComputeIid(aMacDest, dstContext, aIp6Header.GetDestination().GetIid()));
|
||||
SuccessOrExit(ComputeIid(aMacAddrs.mDestination, dstContext, aIp6Header.GetDestination().GetIid()));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -998,11 +995,10 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error Lowpan::Decompress(Message & aMessage,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
FrameData & aFrameData,
|
||||
uint16_t aDatagramLength)
|
||||
Error Lowpan::Decompress(Message & aMessage,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
FrameData & aFrameData,
|
||||
uint16_t aDatagramLength)
|
||||
{
|
||||
Error error = kErrorParse;
|
||||
Ip6::Header ip6Header;
|
||||
@@ -1010,7 +1006,7 @@ Error Lowpan::Decompress(Message & aMessage,
|
||||
uint16_t ip6PayloadLength;
|
||||
uint16_t currentOffset = aMessage.GetOffset();
|
||||
|
||||
SuccessOrExit(DecompressBaseHeader(ip6Header, compressed, aMacSource, aMacDest, aFrameData));
|
||||
SuccessOrExit(DecompressBaseHeader(ip6Header, compressed, aMacAddrs, aFrameData));
|
||||
|
||||
SuccessOrExit(aMessage.Append(ip6Header));
|
||||
aMessage.MoveOffset(sizeof(ip6Header));
|
||||
@@ -1030,7 +1026,7 @@ Error Lowpan::Decompress(Message & aMessage,
|
||||
|
||||
aFrameData.SkipOver(sizeof(uint8_t));
|
||||
|
||||
SuccessOrExit(Decompress(aMessage, aMacSource, aMacDest, aFrameData, aDatagramLength));
|
||||
SuccessOrExit(Decompress(aMessage, aMacAddrs, aFrameData, aDatagramLength));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+17
-26
@@ -127,17 +127,13 @@ public:
|
||||
* This method compresses an IPv6 header.
|
||||
*
|
||||
* @param[in] aMessage A reference to the IPv6 message.
|
||||
* @param[in] aMacSource The MAC source address.
|
||||
* @param[in] aMacDest The MAC destination address.
|
||||
* @param[in] aFrameBuilder The `FrameBuilder` to use to append the compressed headers.
|
||||
* @param[in] aMacAddrs The MAC source and destination addresses.
|
||||
* @param[in] aFrameBuilder The `FrameBuilder` to use to append the compressed headers.
|
||||
*
|
||||
* @returns The size of the compressed header in bytes.
|
||||
*
|
||||
*/
|
||||
Error Compress(Message & aMessage,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
FrameBuilder & aFrameBuilder);
|
||||
Error Compress(Message &aMessage, const Mac::Addresses &aMacAddrs, FrameBuilder &aFrameBuilder);
|
||||
|
||||
/**
|
||||
* This method decompresses a LOWPAN_IPHC header.
|
||||
@@ -145,8 +141,7 @@ public:
|
||||
* If the header is parsed successfully the @p aFrameData is updated to skip over the parsed header bytes.
|
||||
*
|
||||
* @param[out] aMessage A reference where the IPv6 header will be placed.
|
||||
* @param[in] aMacSource The MAC source address.
|
||||
* @param[in] aMacDest The MAC destination address.
|
||||
* @param[in] aMacAddrs The MAC source and destination addresses.
|
||||
* @param[in,out] aFrameData A frame data containing the LOWPAN_IPHC header.
|
||||
* @param[in] aDatagramLength The IPv6 datagram length.
|
||||
*
|
||||
@@ -155,11 +150,10 @@ public:
|
||||
* @retval kErrorNoBufs Could not grow @p aMessage to write the parsed IPv6 header.
|
||||
*
|
||||
*/
|
||||
Error Decompress(Message & aMessage,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
FrameData & aFrameData,
|
||||
uint16_t aDatagramLength);
|
||||
Error Decompress(Message & aMessage,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
FrameData & aFrameData,
|
||||
uint16_t aDatagramLength);
|
||||
|
||||
/**
|
||||
* This method decompresses a LOWPAN_IPHC header.
|
||||
@@ -168,19 +162,17 @@ public:
|
||||
*
|
||||
* @param[out] aIp6Header A reference where the IPv6 header will be placed.
|
||||
* @param[out] aCompressedNextHeader A boolean reference to output whether next header is compressed or not.
|
||||
* @param[in] aMacSource The MAC source address.
|
||||
* @param[in] aMacDest The MAC destination address.
|
||||
* @param[in] aMacAddrs The MAC source and destination addresses
|
||||
* @param[in,out] aFrameData A frame data containing the LOWPAN_IPHC header.
|
||||
*
|
||||
* @retval kErrorNone The header was decompressed successfully. @p aIp6Headre and @p aFrameData are updated.
|
||||
* @retval kErrorParse Failed to parse the lowpan header.
|
||||
*
|
||||
*/
|
||||
Error DecompressBaseHeader(Ip6::Header & aIp6Header,
|
||||
bool & aCompressedNextHeader,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
FrameData & aFrameData);
|
||||
Error DecompressBaseHeader(Ip6::Header & aIp6Header,
|
||||
bool & aCompressedNextHeader,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
FrameData & aFrameData);
|
||||
|
||||
/**
|
||||
* This method decompresses a LOWPAN_NHC UDP header.
|
||||
@@ -272,11 +264,10 @@ private:
|
||||
|
||||
void FindContextForId(uint8_t aContextId, Context &aContext) const;
|
||||
void FindContextToCompressAddress(const Ip6::Address &aIp6Address, Context &aContext) const;
|
||||
Error Compress(Message & aMessage,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
FrameBuilder & aFrameBuilder,
|
||||
uint8_t & aHeaderDepth);
|
||||
Error Compress(Message & aMessage,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
FrameBuilder & aFrameBuilder,
|
||||
uint8_t & aHeaderDepth);
|
||||
|
||||
Error CompressExtensionHeader(Message &aMessage, FrameBuilder &aFrameBuilder, uint8_t &aNextHeader);
|
||||
Error CompressSourceIid(const Mac::Address &aMacAddr,
|
||||
|
||||
@@ -639,13 +639,13 @@ Error MeshForwarder::UpdateIp6Route(Message &aMessage)
|
||||
|
||||
VerifyOrExit(!ip6Header.GetSource().IsMulticast(), error = kErrorDrop);
|
||||
|
||||
GetMacSourceAddress(ip6Header.GetSource(), mMacSource);
|
||||
GetMacSourceAddress(ip6Header.GetSource(), mMacAddrs.mSource);
|
||||
|
||||
if (mle.IsDisabled() || mle.IsDetached())
|
||||
{
|
||||
if (ip6Header.GetDestination().IsLinkLocal() || ip6Header.GetDestination().IsLinkLocalMulticast())
|
||||
{
|
||||
GetMacDestinationAddress(ip6Header.GetDestination(), mMacDest);
|
||||
GetMacDestinationAddress(ip6Header.GetDestination(), mMacAddrs.mDestination);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -663,20 +663,20 @@ Error MeshForwarder::UpdateIp6Route(Message &aMessage)
|
||||
|
||||
if (mle.IsChild() && aMessage.IsLinkSecurityEnabled() && !aMessage.IsSubTypeMle())
|
||||
{
|
||||
mMacDest.SetShort(mle.GetNextHop(Mac::kShortAddrBroadcast));
|
||||
mMacAddrs.mDestination.SetShort(mle.GetNextHop(Mac::kShortAddrBroadcast));
|
||||
}
|
||||
else
|
||||
{
|
||||
mMacDest.SetShort(Mac::kShortAddrBroadcast);
|
||||
mMacAddrs.mDestination.SetShort(Mac::kShortAddrBroadcast);
|
||||
}
|
||||
}
|
||||
else if (ip6Header.GetDestination().IsLinkLocal())
|
||||
{
|
||||
GetMacDestinationAddress(ip6Header.GetDestination(), mMacDest);
|
||||
GetMacDestinationAddress(ip6Header.GetDestination(), mMacAddrs.mDestination);
|
||||
}
|
||||
else if (mle.IsMinimalEndDevice())
|
||||
{
|
||||
mMacDest.SetShort(mle.GetNextHop(Mac::kShortAddrBroadcast));
|
||||
mMacAddrs.mDestination.SetShort(mle.GetNextHop(Mac::kShortAddrBroadcast));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -750,7 +750,7 @@ Mac::TxFrame *MeshForwarder::HandleFrameRequest(Mac::TxFrames &aTxFrames)
|
||||
VerifyOrExit(mEnabled && (mSendMessage != nullptr));
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTI_RADIO
|
||||
frame = &Get<RadioSelector>().SelectRadio(*mSendMessage, mMacDest, aTxFrames);
|
||||
frame = &Get<RadioSelector>().SelectRadio(*mSendMessage, mMacAddrs.mDestination, aTxFrames);
|
||||
|
||||
// If multi-radio link is supported, when sending frame with link
|
||||
// security enabled, Fragment Header is always included (even if
|
||||
@@ -782,8 +782,8 @@ Mac::TxFrame *MeshForwarder::HandleFrameRequest(Mac::TxFrames &aTxFrames)
|
||||
mSendMessage->SetLinkSecurityEnabled(true);
|
||||
}
|
||||
#endif
|
||||
mMessageNextOffset = PrepareDataFrame(*frame, *mSendMessage, mMacSource, mMacDest, mAddMeshHeader, mMeshSource,
|
||||
mMeshDest, addFragHeader);
|
||||
mMessageNextOffset =
|
||||
PrepareDataFrame(*frame, *mSendMessage, mMacAddrs, mAddMeshHeader, mMeshSource, mMeshDest, addFragHeader);
|
||||
|
||||
if ((mSendMessage->GetSubType() == Message::kSubTypeMleChildIdRequest) && mSendMessage->IsLinkSecurityEnabled())
|
||||
{
|
||||
@@ -843,14 +843,13 @@ exit:
|
||||
// It returns the next offset into the message after the prepared
|
||||
// frame.
|
||||
//
|
||||
uint16_t MeshForwarder::PrepareDataFrame(Mac::TxFrame & aFrame,
|
||||
Message & aMessage,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
bool aAddMeshHeader,
|
||||
uint16_t aMeshSource,
|
||||
uint16_t aMeshDest,
|
||||
bool aAddFragHeader)
|
||||
uint16_t MeshForwarder::PrepareDataFrame(Mac::TxFrame & aFrame,
|
||||
Message & aMessage,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
bool aAddMeshHeader,
|
||||
uint16_t aMeshSource,
|
||||
uint16_t aMeshDest,
|
||||
bool aAddFragHeader)
|
||||
{
|
||||
uint16_t fcf;
|
||||
uint16_t payloadLength;
|
||||
@@ -866,18 +865,18 @@ start:
|
||||
// Initialize MAC header
|
||||
fcf = Mac::Frame::kFcfFrameData;
|
||||
|
||||
fcf |= (aMacDest.IsShort()) ? Mac::Frame::kFcfDstAddrShort : Mac::Frame::kFcfDstAddrExt;
|
||||
fcf |= (aMacSource.IsShort()) ? Mac::Frame::kFcfSrcAddrShort : Mac::Frame::kFcfSrcAddrExt;
|
||||
fcf |= (aMacAddrs.mDestination.IsShort()) ? Mac::Frame::kFcfDstAddrShort : Mac::Frame::kFcfDstAddrExt;
|
||||
fcf |= (aMacAddrs.mSource.IsShort()) ? Mac::Frame::kFcfSrcAddrShort : Mac::Frame::kFcfSrcAddrExt;
|
||||
|
||||
if (iePresent)
|
||||
{
|
||||
fcf |= Mac::Frame::kFcfIePresent;
|
||||
}
|
||||
|
||||
fcf |= CalcFrameVersion(Get<NeighborTable>().FindNeighbor(aMacDest), iePresent);
|
||||
fcf |= CalcFrameVersion(Get<NeighborTable>().FindNeighbor(aMacAddrs.mDestination), iePresent);
|
||||
|
||||
// All unicast frames request ACK
|
||||
if (aMacDest.IsExtended() || !aMacDest.IsBroadcast())
|
||||
if (aMacAddrs.mDestination.IsExtended() || !aMacAddrs.mDestination.IsBroadcast())
|
||||
{
|
||||
fcf |= Mac::Frame::kFcfAckRequest;
|
||||
}
|
||||
@@ -962,8 +961,8 @@ start:
|
||||
}
|
||||
|
||||
IgnoreError(aFrame.SetSrcPanId(Get<Mac::Mac>().GetPanId()));
|
||||
aFrame.SetDstAddr(aMacDest);
|
||||
aFrame.SetSrcAddr(aMacSource);
|
||||
aFrame.SetDstAddr(aMacAddrs.mDestination);
|
||||
aFrame.SetSrcAddr(aMacAddrs.mSource);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
|
||||
if (iePresent)
|
||||
@@ -1049,10 +1048,9 @@ start:
|
||||
// Compress IPv6 Header
|
||||
if (aMessage.GetOffset() == 0)
|
||||
{
|
||||
uint16_t fragHeaderOffset;
|
||||
uint16_t maxFrameLength;
|
||||
Mac::Address meshSource;
|
||||
Mac::Address meshDest;
|
||||
uint16_t fragHeaderOffset;
|
||||
uint16_t maxFrameLength;
|
||||
Mac::Addresses macAddrs;
|
||||
|
||||
// Before performing lowpan header compression, we reduce the
|
||||
// max length on `frameBuilder` to reserve bytes for first
|
||||
@@ -1067,16 +1065,15 @@ start:
|
||||
|
||||
if (aAddMeshHeader)
|
||||
{
|
||||
meshSource.SetShort(aMeshSource);
|
||||
meshDest.SetShort(aMeshDest);
|
||||
macAddrs.mSource.SetShort(aMeshSource);
|
||||
macAddrs.mDestination.SetShort(aMeshDest);
|
||||
}
|
||||
else
|
||||
{
|
||||
meshSource = aMacSource;
|
||||
meshDest = aMacDest;
|
||||
macAddrs = aMacAddrs;
|
||||
}
|
||||
|
||||
SuccessOrAssert(Get<Lowpan::Lowpan>().Compress(aMessage, meshSource, meshDest, frameBuilder));
|
||||
SuccessOrAssert(Get<Lowpan::Lowpan>().Compress(aMessage, macAddrs, frameBuilder));
|
||||
|
||||
frameBuilder.SetMaxLength(maxFrameLength);
|
||||
|
||||
@@ -1403,22 +1400,21 @@ exit:
|
||||
void MeshForwarder::HandleReceivedFrame(Mac::RxFrame &aFrame)
|
||||
{
|
||||
ThreadLinkInfo linkInfo;
|
||||
Mac::Address macDest;
|
||||
Mac::Address macSource;
|
||||
Mac::Addresses macAddrs;
|
||||
FrameData frameData;
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(mEnabled, error = kErrorInvalidState);
|
||||
|
||||
SuccessOrExit(error = aFrame.GetSrcAddr(macSource));
|
||||
SuccessOrExit(error = aFrame.GetDstAddr(macDest));
|
||||
SuccessOrExit(error = aFrame.GetSrcAddr(macAddrs.mSource));
|
||||
SuccessOrExit(error = aFrame.GetDstAddr(macAddrs.mDestination));
|
||||
|
||||
linkInfo.SetFrom(aFrame);
|
||||
|
||||
frameData.Init(aFrame.GetPayload(), aFrame.GetPayloadLength());
|
||||
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
Get<Utils::SupervisionListener>().UpdateOnReceive(macSource, linkInfo.IsLinkSecurityEnabled());
|
||||
Get<Utils::SupervisionListener>().UpdateOnReceive(macAddrs.mSource, linkInfo.IsLinkSecurityEnabled());
|
||||
#endif
|
||||
|
||||
switch (aFrame.GetType())
|
||||
@@ -1427,16 +1423,16 @@ void MeshForwarder::HandleReceivedFrame(Mac::RxFrame &aFrame)
|
||||
if (Lowpan::MeshHeader::IsMeshHeader(frameData))
|
||||
{
|
||||
#if OPENTHREAD_FTD
|
||||
HandleMesh(frameData, macSource, linkInfo);
|
||||
HandleMesh(frameData, macAddrs.mSource, linkInfo);
|
||||
#endif
|
||||
}
|
||||
else if (Lowpan::FragmentHeader::IsFragmentHeader(frameData))
|
||||
{
|
||||
HandleFragment(frameData, macSource, macDest, linkInfo);
|
||||
HandleFragment(frameData, macAddrs, linkInfo);
|
||||
}
|
||||
else if (Lowpan::Lowpan::IsLowpanHc(frameData))
|
||||
{
|
||||
HandleLowpanHC(frameData, macSource, macDest, linkInfo);
|
||||
HandleLowpanHC(frameData, macAddrs, linkInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1464,8 +1460,7 @@ exit:
|
||||
}
|
||||
|
||||
void MeshForwarder::HandleFragment(FrameData & aFrameData,
|
||||
const Mac::Address & aMacSource,
|
||||
const Mac::Address & aMacDest,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
const ThreadLinkInfo &aLinkInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
@@ -1478,7 +1473,7 @@ void MeshForwarder::HandleFragment(FrameData & aFrameData,
|
||||
|
||||
if (aLinkInfo.mLinkSecurity)
|
||||
{
|
||||
Neighbor *neighbor = Get<NeighborTable>().FindNeighbor(aMacSource, Neighbor::kInStateAnyExceptInvalid);
|
||||
Neighbor *neighbor = Get<NeighborTable>().FindNeighbor(aMacAddrs.mSource, Neighbor::kInStateAnyExceptInvalid);
|
||||
|
||||
if (neighbor != nullptr)
|
||||
{
|
||||
@@ -1514,10 +1509,10 @@ void MeshForwarder::HandleFragment(FrameData & aFrameData,
|
||||
uint16_t datagramSize = fragmentHeader.GetDatagramSize();
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
UpdateRoutes(aFrameData, aMacSource, aMacDest);
|
||||
UpdateRoutes(aFrameData, aMacAddrs);
|
||||
#endif
|
||||
|
||||
SuccessOrExit(error = FrameToMessage(aFrameData, datagramSize, aMacSource, aMacDest, message));
|
||||
SuccessOrExit(error = FrameToMessage(aFrameData, datagramSize, aMacAddrs, message));
|
||||
|
||||
VerifyOrExit(datagramSize >= message->GetLength(), error = kErrorParse);
|
||||
SuccessOrExit(error = message->SetLength(datagramSize));
|
||||
@@ -1529,7 +1524,7 @@ void MeshForwarder::HandleFragment(FrameData & aFrameData,
|
||||
VerifyOrExit(Get<Ip6::Filter>().Accept(*message), error = kErrorDrop);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
SendIcmpErrorIfDstUnreach(*message, aMacSource, aMacDest);
|
||||
SendIcmpErrorIfDstUnreach(*message, aMacAddrs);
|
||||
#endif
|
||||
|
||||
// Allow re-assembly of only one message at a time on a SED by clearing
|
||||
@@ -1590,12 +1585,12 @@ exit:
|
||||
if (message->GetOffset() >= message->GetLength())
|
||||
{
|
||||
mReassemblyList.Dequeue(*message);
|
||||
IgnoreError(HandleDatagram(*message, aLinkInfo, aMacSource));
|
||||
IgnoreError(HandleDatagram(*message, aLinkInfo, aMacAddrs.mSource));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFragmentFrameDrop(error, aFrameData.GetLength(), aMacSource, aMacDest, fragmentHeader,
|
||||
LogFragmentFrameDrop(error, aFrameData.GetLength(), aMacAddrs, fragmentHeader,
|
||||
aLinkInfo.IsLinkSecurityEnabled());
|
||||
FreeMessage(message);
|
||||
}
|
||||
@@ -1654,22 +1649,21 @@ bool MeshForwarder::UpdateReassemblyList(void)
|
||||
return mReassemblyList.GetHead() != nullptr;
|
||||
}
|
||||
|
||||
Error MeshForwarder::FrameToMessage(const FrameData & aFrameData,
|
||||
uint16_t aDatagramSize,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
Message *& aMessage)
|
||||
Error MeshForwarder::FrameToMessage(const FrameData & aFrameData,
|
||||
uint16_t aDatagramSize,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
Message *& aMessage)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
FrameData frameData = aFrameData;
|
||||
Message::Priority priority;
|
||||
|
||||
SuccessOrExit(error = GetFramePriority(frameData, aMacSource, aMacDest, priority));
|
||||
SuccessOrExit(error = GetFramePriority(frameData, aMacAddrs, priority));
|
||||
|
||||
aMessage = Get<MessagePool>().Allocate(Message::kTypeIp6, /* aReserveHeader */ 0, Message::Settings(priority));
|
||||
VerifyOrExit(aMessage, error = kErrorNoBufs);
|
||||
|
||||
SuccessOrExit(error = Get<Lowpan::Lowpan>().Decompress(*aMessage, aMacSource, aMacDest, frameData, aDatagramSize));
|
||||
SuccessOrExit(error = Get<Lowpan::Lowpan>().Decompress(*aMessage, aMacAddrs, frameData, aDatagramSize));
|
||||
|
||||
SuccessOrExit(error = aMessage->AppendData(frameData));
|
||||
aMessage->MoveOffset(frameData.GetLength());
|
||||
@@ -1679,36 +1673,35 @@ exit:
|
||||
}
|
||||
|
||||
void MeshForwarder::HandleLowpanHC(const FrameData & aFrameData,
|
||||
const Mac::Address & aMacSource,
|
||||
const Mac::Address & aMacDest,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
const ThreadLinkInfo &aLinkInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Message *message = nullptr;
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
UpdateRoutes(aFrameData, aMacSource, aMacDest);
|
||||
UpdateRoutes(aFrameData, aMacAddrs);
|
||||
#endif
|
||||
|
||||
SuccessOrExit(error = FrameToMessage(aFrameData, 0, aMacSource, aMacDest, message));
|
||||
SuccessOrExit(error = FrameToMessage(aFrameData, 0, aMacAddrs, message));
|
||||
|
||||
message->SetLinkInfo(aLinkInfo);
|
||||
|
||||
VerifyOrExit(Get<Ip6::Filter>().Accept(*message), error = kErrorDrop);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
SendIcmpErrorIfDstUnreach(*message, aMacSource, aMacDest);
|
||||
SendIcmpErrorIfDstUnreach(*message, aMacAddrs);
|
||||
#endif
|
||||
|
||||
exit:
|
||||
|
||||
if (error == kErrorNone)
|
||||
{
|
||||
IgnoreError(HandleDatagram(*message, aLinkInfo, aMacSource));
|
||||
IgnoreError(HandleDatagram(*message, aLinkInfo, aMacAddrs.mSource));
|
||||
}
|
||||
else
|
||||
{
|
||||
LogLowpanHcFrameDrop(error, aFrameData.GetLength(), aMacSource, aMacDest, aLinkInfo.IsLinkSecurityEnabled());
|
||||
LogLowpanHcFrameDrop(error, aFrameData.GetLength(), aMacAddrs, aLinkInfo.IsLinkSecurityEnabled());
|
||||
FreeMessage(message);
|
||||
}
|
||||
}
|
||||
@@ -1731,15 +1724,14 @@ Error MeshForwarder::HandleDatagram(Message &aMessage, const ThreadLinkInfo &aLi
|
||||
return Get<Ip6::Ip6>().HandleDatagram(aMessage, &netif, &aLinkInfo, false);
|
||||
}
|
||||
|
||||
Error MeshForwarder::GetFramePriority(const FrameData & aFrameData,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
Message::Priority & aPriority)
|
||||
Error MeshForwarder::GetFramePriority(const FrameData & aFrameData,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
Message::Priority & aPriority)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Ip6::Headers headers;
|
||||
|
||||
SuccessOrExit(error = headers.DecompressFrom(aFrameData, aMacSource, aMacDest, GetInstance()));
|
||||
SuccessOrExit(error = headers.DecompressFrom(aFrameData, aMacAddrs, GetInstance()));
|
||||
|
||||
aPriority = Ip6::Ip6::DscpToPriority(headers.GetIp6Header().GetDscp());
|
||||
|
||||
@@ -2058,25 +2050,24 @@ void MeshForwarder::LogFrame(const char *aActionText, const Mac::Frame &aFrame,
|
||||
|
||||
void MeshForwarder::LogFragmentFrameDrop(Error aError,
|
||||
uint16_t aFrameLength,
|
||||
const Mac::Address & aMacSource,
|
||||
const Mac::Address & aMacDest,
|
||||
const Mac::Addresses & aMacAddrs,
|
||||
const Lowpan::FragmentHeader &aFragmentHeader,
|
||||
bool aIsSecure)
|
||||
{
|
||||
LogNote("Dropping rx frag frame, error:%s, len:%d, src:%s, dst:%s, tag:%d, offset:%d, dglen:%d, sec:%s",
|
||||
ErrorToString(aError), aFrameLength, aMacSource.ToString().AsCString(), aMacDest.ToString().AsCString(),
|
||||
aFragmentHeader.GetDatagramTag(), aFragmentHeader.GetDatagramOffset(), aFragmentHeader.GetDatagramSize(),
|
||||
ToYesNo(aIsSecure));
|
||||
ErrorToString(aError), aFrameLength, aMacAddrs.mSource.ToString().AsCString(),
|
||||
aMacAddrs.mDestination.ToString().AsCString(), aFragmentHeader.GetDatagramTag(),
|
||||
aFragmentHeader.GetDatagramOffset(), aFragmentHeader.GetDatagramSize(), ToYesNo(aIsSecure));
|
||||
}
|
||||
|
||||
void MeshForwarder::LogLowpanHcFrameDrop(Error aError,
|
||||
uint16_t aFrameLength,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
bool aIsSecure)
|
||||
void MeshForwarder::LogLowpanHcFrameDrop(Error aError,
|
||||
uint16_t aFrameLength,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
bool aIsSecure)
|
||||
{
|
||||
LogNote("Dropping rx lowpan HC frame, error:%s, len:%d, src:%s, dst:%s, sec:%s", ErrorToString(aError),
|
||||
aFrameLength, aMacSource.ToString().AsCString(), aMacDest.ToString().AsCString(), ToYesNo(aIsSecure));
|
||||
aFrameLength, aMacAddrs.mSource.ToString().AsCString(), aMacAddrs.mDestination.ToString().AsCString(),
|
||||
ToYesNo(aIsSecure));
|
||||
}
|
||||
|
||||
#else // #if OT_SHOULD_LOG_AT( OT_LOG_LEVEL_NOTE)
|
||||
@@ -2089,16 +2080,11 @@ void MeshForwarder::LogFrame(const char *, const Mac::Frame &, Error)
|
||||
{
|
||||
}
|
||||
|
||||
void MeshForwarder::LogFragmentFrameDrop(Error,
|
||||
uint16_t,
|
||||
const Mac::Address &,
|
||||
const Mac::Address &,
|
||||
const Lowpan::FragmentHeader &,
|
||||
bool)
|
||||
void MeshForwarder::LogFragmentFrameDrop(Error, uint16_t, const Mac::Addresses &, const Lowpan::FragmentHeader &, bool)
|
||||
{
|
||||
}
|
||||
|
||||
void MeshForwarder::LogLowpanHcFrameDrop(Error, uint16_t, const Mac::Address &, const Mac::Address &, bool)
|
||||
void MeshForwarder::LogLowpanHcFrameDrop(Error, uint16_t, const Mac::Addresses &, bool)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -426,38 +426,26 @@ private:
|
||||
};
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
void SendIcmpErrorIfDstUnreach(const Message & aMessage,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest);
|
||||
Error CheckReachability(const FrameData & aFrameData,
|
||||
const Mac::Address &aMeshSource,
|
||||
const Mac::Address &aMeshDest);
|
||||
void UpdateRoutes(const FrameData &aFrameData, const Mac::Address &aMeshSource, const Mac::Address &aMeshDest);
|
||||
Error FrameToMessage(const FrameData & aFrameData,
|
||||
uint16_t aDatagramSize,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
Message *& aMessage);
|
||||
void SendIcmpErrorIfDstUnreach(const Message &aMessage, const Mac::Addresses &aMacAddrs);
|
||||
Error CheckReachability(const FrameData &aFrameData, const Mac::Addresses &aMeshAddrs);
|
||||
void UpdateRoutes(const FrameData &aFrameData, const Mac::Addresses &aMeshAddrs);
|
||||
Error FrameToMessage(const FrameData & aFrameData,
|
||||
uint16_t aDatagramSize,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
Message *& aMessage);
|
||||
void GetMacDestinationAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr);
|
||||
void GetMacSourceAddress(const Ip6::Address &aIp6Addr, Mac::Address &aMacAddr);
|
||||
Message *PrepareNextDirectTransmission(void);
|
||||
void HandleMesh(FrameData &aFrameData, const Mac::Address &aMacSource, const ThreadLinkInfo &aLinkInfo);
|
||||
void HandleFragment(FrameData & aFrameData,
|
||||
const Mac::Address & aMacSource,
|
||||
const Mac::Address & aMacDest,
|
||||
const ThreadLinkInfo &aLinkInfo);
|
||||
void HandleLowpanHC(const FrameData & aFrameData,
|
||||
const Mac::Address & aMacSource,
|
||||
const Mac::Address & aMacDest,
|
||||
const ThreadLinkInfo &aLinkInfo);
|
||||
uint16_t PrepareDataFrame(Mac::TxFrame & aFrame,
|
||||
Message & aMessage,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
bool aAddMeshHeader = false,
|
||||
uint16_t aMeshSource = 0xffff,
|
||||
uint16_t aMeshDest = 0xffff,
|
||||
bool aAddFragHeader = false);
|
||||
void HandleFragment(FrameData &aFrameData, const Mac::Addresses &aMacAddrs, const ThreadLinkInfo &aLinkInfo);
|
||||
void HandleLowpanHC(const FrameData &aFrameData, const Mac::Addresses &aMacAddrs, const ThreadLinkInfo &aLinkInfo);
|
||||
uint16_t PrepareDataFrame(Mac::TxFrame & aFrame,
|
||||
Message & aMessage,
|
||||
const Mac::Addresses &aMacAddrs,
|
||||
bool aAddMeshHeader = false,
|
||||
uint16_t aMeshSource = 0xffff,
|
||||
uint16_t aMeshDest = 0xffff,
|
||||
bool aAddFragHeader = false);
|
||||
void PrepareEmptyFrame(Mac::TxFrame &aFrame, const Mac::Address &aMacDest, bool aAckRequest);
|
||||
|
||||
#if OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE
|
||||
@@ -503,17 +491,13 @@ private:
|
||||
static void ScheduleTransmissionTask(Tasklet &aTasklet);
|
||||
void ScheduleTransmissionTask(void);
|
||||
|
||||
Error GetFramePriority(const FrameData & aFrameData,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
Message::Priority & aPriority);
|
||||
Error GetFramePriority(const FrameData &aFrameData, const Mac::Addresses &aMacAddrs, Message::Priority &aPriority);
|
||||
Error GetFragmentPriority(Lowpan::FragmentHeader &aFragmentHeader,
|
||||
uint16_t aSrcRloc16,
|
||||
Message::Priority & aPriority);
|
||||
void GetForwardFramePriority(const FrameData & aFrameData,
|
||||
const Mac::Address &aMeshSource,
|
||||
const Mac::Address &aMeshDest,
|
||||
Message::Priority & aPriority);
|
||||
void GetForwardFramePriority(const FrameData & aFrameData,
|
||||
const Mac::Addresses &aMeshAddrs,
|
||||
Message::Priority & aPriority);
|
||||
|
||||
bool CalcIePresent(const Message *aMessage);
|
||||
uint16_t CalcFrameVersion(const Neighbor *aNeighbor, bool aIePresent);
|
||||
@@ -536,15 +520,10 @@ private:
|
||||
void LogFrame(const char *aActionText, const Mac::Frame &aFrame, Error aError);
|
||||
void LogFragmentFrameDrop(Error aError,
|
||||
uint16_t aFrameLength,
|
||||
const Mac::Address & aMacSource,
|
||||
const Mac::Address & aMacDest,
|
||||
const Mac::Addresses & aMacAddrs,
|
||||
const Lowpan::FragmentHeader &aFragmentHeader,
|
||||
bool aIsSecure);
|
||||
void LogLowpanHcFrameDrop(Error aError,
|
||||
uint16_t aFrameLength,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest,
|
||||
bool aIsSecure);
|
||||
void LogLowpanHcFrameDrop(Error aError, uint16_t aFrameLength, const Mac::Addresses &aMacAddrs, bool aIsSecure);
|
||||
|
||||
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_NOTE)
|
||||
const char *MessageActionToString(MessageAction aAction, Error aError);
|
||||
@@ -556,14 +535,12 @@ private:
|
||||
const Mac::Address *aMacAddress,
|
||||
Error aError,
|
||||
uint16_t & aOffset,
|
||||
Mac::Address & aMeshSource,
|
||||
Mac::Address & aMeshDest,
|
||||
Mac::Addresses & aMeshAddrs,
|
||||
LogLevel aLogLevel);
|
||||
void LogMeshIpHeader(const Message & aMessage,
|
||||
uint16_t aOffset,
|
||||
const Mac::Address &aMeshSource,
|
||||
const Mac::Address &aMeshDest,
|
||||
LogLevel aLogLevel);
|
||||
void LogMeshIpHeader(const Message & aMessage,
|
||||
uint16_t aOffset,
|
||||
const Mac::Addresses &aMeshAddrs,
|
||||
LogLevel aLogLevel);
|
||||
void LogMeshMessage(MessageAction aAction,
|
||||
const Message & aMessage,
|
||||
const Mac::Address *aAddress,
|
||||
@@ -585,14 +562,13 @@ private:
|
||||
|
||||
Message *mSendMessage;
|
||||
|
||||
Mac::Address mMacSource;
|
||||
Mac::Address mMacDest;
|
||||
uint16_t mMeshSource;
|
||||
uint16_t mMeshDest;
|
||||
bool mAddMeshHeader : 1;
|
||||
bool mEnabled : 1;
|
||||
bool mTxPaused : 1;
|
||||
bool mSendBusy : 1;
|
||||
Mac::Addresses mMacAddrs;
|
||||
uint16_t mMeshSource;
|
||||
uint16_t mMeshDest;
|
||||
bool mAddMeshHeader : 1;
|
||||
bool mEnabled : 1;
|
||||
bool mTxPaused : 1;
|
||||
bool mSendBusy : 1;
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_MAC_COLLISION_AVOIDANCE_DELAY_ENABLE
|
||||
bool mDelayNextTx : 1;
|
||||
TimerMilli mTxDelayTimer;
|
||||
|
||||
@@ -358,12 +358,12 @@ void MeshForwarder::SendMesh(Message &aMessage, Mac::TxFrame &aFrame)
|
||||
fcf |= Mac::Frame::kFcfIePresent;
|
||||
}
|
||||
|
||||
fcf |= CalcFrameVersion(Get<NeighborTable>().FindNeighbor(mMacDest), iePresent);
|
||||
fcf |= CalcFrameVersion(Get<NeighborTable>().FindNeighbor(mMacAddrs.mDestination), iePresent);
|
||||
|
||||
aFrame.InitMacHeader(fcf, Mac::Frame::kKeyIdMode1 | Mac::Frame::kSecEncMic32);
|
||||
aFrame.SetDstPanId(Get<Mac::Mac>().GetPanId());
|
||||
aFrame.SetDstAddr(mMacDest.GetShort());
|
||||
aFrame.SetSrcAddr(mMacSource.GetShort());
|
||||
aFrame.SetDstAddr(mMacAddrs.mDestination.GetShort());
|
||||
aFrame.SetSrcAddr(mMacAddrs.mSource);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
|
||||
if (iePresent)
|
||||
@@ -405,15 +405,15 @@ Error MeshForwarder::UpdateMeshRoute(Message &aMessage)
|
||||
ExitNow(error = kErrorDrop);
|
||||
}
|
||||
|
||||
mMacDest.SetShort(neighbor->GetRloc16());
|
||||
mMacSource.SetShort(Get<Mac::Mac>().GetShortAddress());
|
||||
mMacAddrs.mDestination.SetShort(neighbor->GetRloc16());
|
||||
mMacAddrs.mSource.SetShort(Get<Mac::Mac>().GetShortAddress());
|
||||
|
||||
mAddMeshHeader = true;
|
||||
mMeshDest = meshHeader.GetDestination();
|
||||
mMeshSource = meshHeader.GetSource();
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_COLLISION_AVOIDANCE_DELAY_ENABLE
|
||||
if (mMacDest.GetShort() != mMeshDest)
|
||||
if (mMacAddrs.mDestination.GetShort() != mMeshDest)
|
||||
{
|
||||
mDelayNextTx = true;
|
||||
}
|
||||
@@ -625,12 +625,12 @@ Error MeshForwarder::UpdateIp6RouteFtd(Ip6::Header &ip6Header, Message &aMessage
|
||||
|
||||
SuccessOrExit(error = mle.CheckReachability(mMeshDest, ip6Header));
|
||||
aMessage.SetMeshDest(mMeshDest);
|
||||
mMacDest.SetShort(mle.GetNextHop(mMeshDest));
|
||||
mMacAddrs.mDestination.SetShort(mle.GetNextHop(mMeshDest));
|
||||
|
||||
if (mMacDest.GetShort() != mMeshDest)
|
||||
if (mMacAddrs.mDestination.GetShort() != mMeshDest)
|
||||
{
|
||||
// destination is not neighbor
|
||||
mMacSource.SetShort(mMeshSource);
|
||||
mMacAddrs.mSource.SetShort(mMeshSource);
|
||||
mAddMeshHeader = true;
|
||||
#if OPENTHREAD_CONFIG_MAC_COLLISION_AVOIDANCE_DELAY_ENABLE
|
||||
mDelayNextTx = true;
|
||||
@@ -641,17 +641,15 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MeshForwarder::SendIcmpErrorIfDstUnreach(const Message & aMessage,
|
||||
const Mac::Address &aMacSource,
|
||||
const Mac::Address &aMacDest)
|
||||
void MeshForwarder::SendIcmpErrorIfDstUnreach(const Message &aMessage, const Mac::Addresses &aMacAddrs)
|
||||
{
|
||||
Error error;
|
||||
Ip6::Headers ip6Headers;
|
||||
Child * child;
|
||||
|
||||
VerifyOrExit(aMacSource.IsShort() && aMacDest.IsShort());
|
||||
VerifyOrExit(aMacAddrs.mSource.IsShort() && aMacAddrs.mDestination.IsShort());
|
||||
|
||||
child = Get<ChildTable>().FindChild(aMacSource.GetShort(), Child::kInStateAnyExceptInvalid);
|
||||
child = Get<ChildTable>().FindChild(aMacAddrs.mSource.GetShort(), Child::kInStateAnyExceptInvalid);
|
||||
VerifyOrExit((child == nullptr) || child->IsFullThreadDevice());
|
||||
|
||||
SuccessOrExit(ip6Headers.ParseFrom(aMessage));
|
||||
@@ -659,25 +657,23 @@ void MeshForwarder::SendIcmpErrorIfDstUnreach(const Message & aMessage,
|
||||
VerifyOrExit(!ip6Headers.GetDestinationAddress().IsMulticast() &&
|
||||
Get<NetworkData::Leader>().IsOnMesh(ip6Headers.GetDestinationAddress()));
|
||||
|
||||
error = Get<Mle::MleRouter>().CheckReachability(aMacDest.GetShort(), ip6Headers.GetIp6Header());
|
||||
error = Get<Mle::MleRouter>().CheckReachability(aMacAddrs.mDestination.GetShort(), ip6Headers.GetIp6Header());
|
||||
|
||||
if (error == kErrorNoRoute)
|
||||
{
|
||||
SendDestinationUnreachable(aMacSource.GetShort(), ip6Headers);
|
||||
SendDestinationUnreachable(aMacAddrs.mSource.GetShort(), ip6Headers);
|
||||
}
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
Error MeshForwarder::CheckReachability(const FrameData & aFrameData,
|
||||
const Mac::Address &aMeshSource,
|
||||
const Mac::Address &aMeshDest)
|
||||
Error MeshForwarder::CheckReachability(const FrameData &aFrameData, const Mac::Addresses &aMeshAddrs)
|
||||
{
|
||||
Error error;
|
||||
Ip6::Headers ip6Headers;
|
||||
|
||||
error = ip6Headers.DecompressFrom(aFrameData, aMeshSource, aMeshDest, GetInstance());
|
||||
error = ip6Headers.DecompressFrom(aFrameData, aMeshAddrs, GetInstance());
|
||||
|
||||
if (error == kErrorNotFound)
|
||||
{
|
||||
@@ -685,11 +681,11 @@ Error MeshForwarder::CheckReachability(const FrameData & aFrameData,
|
||||
ExitNow(error = kErrorNone);
|
||||
}
|
||||
|
||||
error = Get<Mle::MleRouter>().CheckReachability(aMeshDest.GetShort(), ip6Headers.GetIp6Header());
|
||||
error = Get<Mle::MleRouter>().CheckReachability(aMeshAddrs.mDestination.GetShort(), ip6Headers.GetIp6Header());
|
||||
|
||||
if (error == kErrorNoRoute)
|
||||
{
|
||||
SendDestinationUnreachable(aMeshSource.GetShort(), ip6Headers);
|
||||
SendDestinationUnreachable(aMeshAddrs.mSource.GetShort(), ip6Headers);
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -711,8 +707,7 @@ void MeshForwarder::HandleMesh(FrameData &aFrameData, const Mac::Address &aMacSo
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Message * message = nullptr;
|
||||
Mac::Address meshDest;
|
||||
Mac::Address meshSource;
|
||||
Mac::Addresses meshAddrs;
|
||||
Lowpan::MeshHeader meshHeader;
|
||||
|
||||
// Security Check: only process Mesh Header frames that had security enabled.
|
||||
@@ -720,21 +715,21 @@ void MeshForwarder::HandleMesh(FrameData &aFrameData, const Mac::Address &aMacSo
|
||||
|
||||
SuccessOrExit(error = meshHeader.ParseFrom(aFrameData));
|
||||
|
||||
meshSource.SetShort(meshHeader.GetSource());
|
||||
meshDest.SetShort(meshHeader.GetDestination());
|
||||
meshAddrs.mSource.SetShort(meshHeader.GetSource());
|
||||
meshAddrs.mDestination.SetShort(meshHeader.GetDestination());
|
||||
|
||||
UpdateRoutes(aFrameData, meshSource, meshDest);
|
||||
UpdateRoutes(aFrameData, meshAddrs);
|
||||
|
||||
if (meshDest.GetShort() == Get<Mac::Mac>().GetShortAddress() ||
|
||||
Get<Mle::MleRouter>().IsMinimalChild(meshDest.GetShort()))
|
||||
if (meshAddrs.mDestination.GetShort() == Get<Mac::Mac>().GetShortAddress() ||
|
||||
Get<Mle::MleRouter>().IsMinimalChild(meshAddrs.mDestination.GetShort()))
|
||||
{
|
||||
if (Lowpan::FragmentHeader::IsFragmentHeader(aFrameData))
|
||||
{
|
||||
HandleFragment(aFrameData, meshSource, meshDest, aLinkInfo);
|
||||
HandleFragment(aFrameData, meshAddrs, aLinkInfo);
|
||||
}
|
||||
else if (Lowpan::Lowpan::IsLowpanHc(aFrameData))
|
||||
{
|
||||
HandleLowpanHC(aFrameData, meshSource, meshDest, aLinkInfo);
|
||||
HandleLowpanHC(aFrameData, meshAddrs, aLinkInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -745,13 +740,13 @@ void MeshForwarder::HandleMesh(FrameData &aFrameData, const Mac::Address &aMacSo
|
||||
{
|
||||
Message::Priority priority = Message::kPriorityNormal;
|
||||
|
||||
Get<Mle::MleRouter>().ResolveRoutingLoops(aMacSource.GetShort(), meshDest.GetShort());
|
||||
Get<Mle::MleRouter>().ResolveRoutingLoops(aMacSource.GetShort(), meshAddrs.mDestination.GetShort());
|
||||
|
||||
SuccessOrExit(error = CheckReachability(aFrameData, meshSource, meshDest));
|
||||
SuccessOrExit(error = CheckReachability(aFrameData, meshAddrs));
|
||||
|
||||
meshHeader.DecrementHopsLeft();
|
||||
|
||||
GetForwardFramePriority(aFrameData, meshSource, meshDest, priority);
|
||||
GetForwardFramePriority(aFrameData, meshAddrs, priority);
|
||||
message =
|
||||
Get<MessagePool>().Allocate(Message::kType6lowpan, /* aReserveHeader */ 0, Message::Settings(priority));
|
||||
VerifyOrExit(message != nullptr, error = kErrorNoBufs);
|
||||
@@ -790,16 +785,14 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
void MeshForwarder::UpdateRoutes(const FrameData & aFrameData,
|
||||
const Mac::Address &aMeshSource,
|
||||
const Mac::Address &aMeshDest)
|
||||
void MeshForwarder::UpdateRoutes(const FrameData &aFrameData, const Mac::Addresses &aMeshAddrs)
|
||||
{
|
||||
Ip6::Headers ip6Headers;
|
||||
Neighbor * neighbor;
|
||||
|
||||
VerifyOrExit(!aMeshDest.IsBroadcast() && aMeshSource.IsShort());
|
||||
VerifyOrExit(!aMeshAddrs.mDestination.IsBroadcast() && aMeshAddrs.mSource.IsShort());
|
||||
|
||||
SuccessOrExit(ip6Headers.DecompressFrom(aFrameData, aMeshSource, aMeshDest, GetInstance()));
|
||||
SuccessOrExit(ip6Headers.DecompressFrom(aFrameData, aMeshAddrs, GetInstance()));
|
||||
|
||||
if (!ip6Headers.GetSourceAddress().GetIid().IsLocator() &&
|
||||
Get<NetworkData::Leader>().IsOnMesh(ip6Headers.GetSourceAddress()))
|
||||
@@ -808,14 +801,14 @@ void MeshForwarder::UpdateRoutes(const FrameData & aFrameData,
|
||||
// inspecting packets being received only for on mesh
|
||||
// addresses.
|
||||
|
||||
Get<AddressResolver>().UpdateSnoopedCacheEntry(ip6Headers.GetSourceAddress(), aMeshSource.GetShort(),
|
||||
aMeshDest.GetShort());
|
||||
Get<AddressResolver>().UpdateSnoopedCacheEntry(ip6Headers.GetSourceAddress(), aMeshAddrs.mSource.GetShort(),
|
||||
aMeshAddrs.mDestination.GetShort());
|
||||
}
|
||||
|
||||
neighbor = Get<NeighborTable>().FindNeighbor(ip6Headers.GetSourceAddress());
|
||||
VerifyOrExit(neighbor != nullptr && !neighbor->IsFullThreadDevice());
|
||||
|
||||
if (!Mle::Mle::RouterIdMatch(aMeshSource.GetShort(), Get<Mac::Mac>().GetShortAddress()))
|
||||
if (!Mle::Mle::RouterIdMatch(aMeshAddrs.mSource.GetShort(), Get<Mac::Mac>().GetShortAddress()))
|
||||
{
|
||||
Get<Mle::MleRouter>().RemoveNeighbor(*neighbor);
|
||||
}
|
||||
@@ -938,10 +931,9 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MeshForwarder::GetForwardFramePriority(const FrameData & aFrameData,
|
||||
const Mac::Address &aMeshSource,
|
||||
const Mac::Address &aMeshDest,
|
||||
Message::Priority & aPriority)
|
||||
void MeshForwarder::GetForwardFramePriority(const FrameData & aFrameData,
|
||||
const Mac::Addresses &aMeshAddrs,
|
||||
Message::Priority & aPriority)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
FrameData frameData = aFrameData;
|
||||
@@ -955,22 +947,23 @@ void MeshForwarder::GetForwardFramePriority(const FrameData & aFrameData,
|
||||
if (fragmentHeader.GetDatagramOffset() > 0)
|
||||
{
|
||||
// Get priority from the pre-buffered info
|
||||
ExitNow(error = GetFragmentPriority(fragmentHeader, aMeshSource.GetShort(), aPriority));
|
||||
ExitNow(error = GetFragmentPriority(fragmentHeader, aMeshAddrs.mSource.GetShort(), aPriority));
|
||||
}
|
||||
}
|
||||
|
||||
// Get priority from IPv6 header or UDP destination port directly
|
||||
error = GetFramePriority(frameData, aMeshSource, aMeshDest, aPriority);
|
||||
error = GetFramePriority(frameData, aMeshAddrs, aPriority);
|
||||
|
||||
exit:
|
||||
if (error != kErrorNone)
|
||||
{
|
||||
LogNote("Failed to get forwarded frame priority, error:%s, len:%d, src:%d, dst:%s", ErrorToString(error),
|
||||
frameData.GetLength(), aMeshSource.ToString().AsCString(), aMeshDest.ToString().AsCString());
|
||||
frameData.GetLength(), aMeshAddrs.mSource.ToString().AsCString(),
|
||||
aMeshAddrs.mDestination.ToString().AsCString());
|
||||
}
|
||||
else if (isFragment)
|
||||
{
|
||||
UpdateFragmentPriority(fragmentHeader, frameData.GetLength(), aMeshSource.GetShort(), aPriority);
|
||||
UpdateFragmentPriority(fragmentHeader, frameData.GetLength(), aMeshAddrs.mSource.GetShort(), aPriority);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -983,8 +976,7 @@ Error MeshForwarder::LogMeshFragmentHeader(MessageAction aAction,
|
||||
const Mac::Address *aMacAddress,
|
||||
Error aError,
|
||||
uint16_t & aOffset,
|
||||
Mac::Address & aMeshSource,
|
||||
Mac::Address & aMeshDest,
|
||||
Mac::Addresses & aMeshAddrs,
|
||||
LogLevel aLogLevel)
|
||||
{
|
||||
Error error = kErrorFailed;
|
||||
@@ -998,8 +990,8 @@ Error MeshForwarder::LogMeshFragmentHeader(MessageAction aAction,
|
||||
|
||||
SuccessOrExit(meshHeader.ParseFrom(aMessage, headerLength));
|
||||
|
||||
aMeshSource.SetShort(meshHeader.GetSource());
|
||||
aMeshDest.SetShort(meshHeader.GetDestination());
|
||||
aMeshAddrs.mSource.SetShort(meshHeader.GetSource());
|
||||
aMeshAddrs.mDestination.SetShort(meshHeader.GetDestination());
|
||||
|
||||
aOffset = headerLength;
|
||||
|
||||
@@ -1019,9 +1011,10 @@ Error MeshForwarder::LogMeshFragmentHeader(MessageAction aAction,
|
||||
LogAt(aLogLevel, "%s mesh frame, len:%d%s%s, msrc:%s, mdst:%s, hops:%d, frag:%s, sec:%s%s%s%s%s%s%s",
|
||||
MessageActionToString(aAction, aError), aMessage.GetLength(),
|
||||
(aMacAddress == nullptr) ? "" : ((aAction == kMessageReceive) ? ", from:" : ", to:"),
|
||||
(aMacAddress == nullptr) ? "" : aMacAddress->ToString().AsCString(), aMeshSource.ToString().AsCString(),
|
||||
aMeshDest.ToString().AsCString(), meshHeader.GetHopsLeft() + ((aAction == kMessageReceive) ? 1 : 0),
|
||||
ToYesNo(hasFragmentHeader), ToYesNo(aMessage.IsLinkSecurityEnabled()),
|
||||
(aMacAddress == nullptr) ? "" : aMacAddress->ToString().AsCString(),
|
||||
aMeshAddrs.mSource.ToString().AsCString(), aMeshAddrs.mDestination.ToString().AsCString(),
|
||||
meshHeader.GetHopsLeft() + ((aAction == kMessageReceive) ? 1 : 0), ToYesNo(hasFragmentHeader),
|
||||
ToYesNo(aMessage.IsLinkSecurityEnabled()),
|
||||
(aError == kErrorNone) ? "" : ", error:", (aError == kErrorNone) ? "" : ErrorToString(aError),
|
||||
shouldLogRss ? ", rss:" : "", shouldLogRss ? aMessage.GetRssAverager().ToString().AsCString() : "",
|
||||
shouldLogRadio ? ", radio:" : "", radioString);
|
||||
@@ -1040,15 +1033,14 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MeshForwarder::LogMeshIpHeader(const Message & aMessage,
|
||||
uint16_t aOffset,
|
||||
const Mac::Address &aMeshSource,
|
||||
const Mac::Address &aMeshDest,
|
||||
LogLevel aLogLevel)
|
||||
void MeshForwarder::LogMeshIpHeader(const Message & aMessage,
|
||||
uint16_t aOffset,
|
||||
const Mac::Addresses &aMeshAddrs,
|
||||
LogLevel aLogLevel)
|
||||
{
|
||||
Ip6::Headers headers;
|
||||
|
||||
SuccessOrExit(headers.DecompressFrom(aMessage, aOffset, aMeshSource, aMeshDest));
|
||||
SuccessOrExit(headers.DecompressFrom(aMessage, aOffset, aMeshAddrs));
|
||||
|
||||
LogAt(aLogLevel, " IPv6 %s msg, chksum:%04x, ecn:%s, prio:%s", Ip6::Ip6::IpProtoToString(headers.GetIpProto()),
|
||||
headers.GetChecksum(), Ip6::Ip6::EcnToString(headers.GetEcn()), MessagePriorityToString(aMessage));
|
||||
@@ -1065,12 +1057,10 @@ void MeshForwarder::LogMeshMessage(MessageAction aAction,
|
||||
Error aError,
|
||||
LogLevel aLogLevel)
|
||||
{
|
||||
uint16_t offset;
|
||||
Mac::Address meshSource;
|
||||
Mac::Address meshDest;
|
||||
uint16_t offset;
|
||||
Mac::Addresses meshAddrs;
|
||||
|
||||
SuccessOrExit(
|
||||
LogMeshFragmentHeader(aAction, aMessage, aMacAddress, aError, offset, meshSource, meshDest, aLogLevel));
|
||||
SuccessOrExit(LogMeshFragmentHeader(aAction, aMessage, aMacAddress, aError, offset, meshAddrs, aLogLevel));
|
||||
|
||||
// When log action is `kMessageTransmit` we do not include
|
||||
// the IPv6 header info in the logs, as the same info is
|
||||
@@ -1079,7 +1069,7 @@ void MeshForwarder::LogMeshMessage(MessageAction aAction,
|
||||
|
||||
VerifyOrExit(aAction != kMessageTransmit);
|
||||
|
||||
LogMeshIpHeader(aMessage, offset, meshSource, meshDest, aLogLevel);
|
||||
LogMeshIpHeader(aMessage, offset, meshAddrs, aLogLevel);
|
||||
|
||||
exit:
|
||||
return;
|
||||
|
||||
@@ -181,8 +181,7 @@ static void Test(TestIphcVector &aVector, bool aCompress, bool aDecompress)
|
||||
|
||||
aVector.GetUncompressedStream(*message);
|
||||
|
||||
VerifyOrQuit(sLowpan->Compress(*message, aVector.mMacSource, aVector.mMacDestination, frameBuilder) ==
|
||||
aVector.mError);
|
||||
VerifyOrQuit(sLowpan->Compress(*message, aVector.mMacAddrs, frameBuilder) == aVector.mError);
|
||||
|
||||
if (aVector.mError == kErrorNone)
|
||||
{
|
||||
@@ -229,7 +228,7 @@ static void Test(TestIphcVector &aVector, bool aCompress, bool aDecompress)
|
||||
|
||||
frameData.Init(iphc, iphcLength);
|
||||
|
||||
error = sLowpan->Decompress(*message, aVector.mMacSource, aVector.mMacDestination, frameData, 0);
|
||||
error = sLowpan->Decompress(*message, aVector.mMacAddrs, frameData, 0);
|
||||
|
||||
message->ReadBytes(0, result, message->GetLength());
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
* @param aAddress Pointer to the long MAC address.
|
||||
*
|
||||
*/
|
||||
void SetMacSource(const uint8_t *aAddress) { mMacSource.SetExtended(aAddress); }
|
||||
void SetMacSource(const uint8_t *aAddress) { mMacAddrs.mSource.SetExtended(aAddress); }
|
||||
|
||||
/**
|
||||
* This method sets short MAC source address.
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
* @param aAddress Short MAC address.
|
||||
*
|
||||
*/
|
||||
void SetMacSource(uint16_t aAddress) { mMacSource.SetShort(aAddress); }
|
||||
void SetMacSource(uint16_t aAddress) { mMacAddrs.mSource.SetShort(aAddress); }
|
||||
|
||||
/**
|
||||
* This method sets long MAC destination address.
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
* @param aAddress Pointer to the long MAC address.
|
||||
*
|
||||
*/
|
||||
void SetMacDestination(const uint8_t *aAddress) { mMacDestination.SetExtended(aAddress); }
|
||||
void SetMacDestination(const uint8_t *aAddress) { mMacAddrs.mDestination.SetExtended(aAddress); }
|
||||
|
||||
/**
|
||||
* This method sets short MAC destination address.
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
* @param aAddress Short MAC address.
|
||||
*
|
||||
*/
|
||||
void SetMacDestination(uint16_t aAddress) { mMacDestination.SetShort(aAddress); }
|
||||
void SetMacDestination(uint16_t aAddress) { mMacAddrs.mDestination.SetShort(aAddress); }
|
||||
|
||||
/**
|
||||
* This method gets the IPv6 header
|
||||
@@ -261,8 +261,7 @@ public:
|
||||
* This fields represent uncompressed IPv6 packet.
|
||||
*
|
||||
*/
|
||||
Mac::Address mMacSource;
|
||||
Mac::Address mMacDestination;
|
||||
Mac::Addresses mMacAddrs;
|
||||
Ip6::Header mIpHeader;
|
||||
Payload mExtHeader;
|
||||
Ip6::Header mIpTunneledHeader;
|
||||
|
||||
Reference in New Issue
Block a user