mirror of
https://github.com/espressif/openthread.git
synced 2026-09-05 08:40:06 +00:00
[mesh-forwarder] use extended address for data poll during parent switch attempt (#2449)
This commit changes the logic for preparing a data poll (802.15.4 MAC Data Request) frame and selecting short/extended address. It ensures that during a parent switch attempt on a sleepy-end-device, the data polls use the extended address as the source MAC address.
This commit is contained in:
committed by
Jonathan Hui
parent
9f49148e7e
commit
eeb24229f0
@@ -615,35 +615,8 @@ Message *MeshForwarder::GetDirectTransmission(void)
|
||||
break;
|
||||
|
||||
case Message::kTypeMacDataPoll:
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
Neighbor *parent = netif.GetMle().GetParentCandidate();
|
||||
|
||||
if ((parent != NULL) && (parent->IsStateValidOrRestoring()))
|
||||
{
|
||||
mMacSource.mShortAddress = netif.GetMac().GetShortAddress();
|
||||
|
||||
if (mMacSource.mShortAddress != Mac::kShortAddrInvalid)
|
||||
{
|
||||
mMacSource.mLength = sizeof(mMacSource.mShortAddress);
|
||||
mMacDest.mLength = sizeof(mMacDest.mShortAddress);
|
||||
mMacDest.mShortAddress = parent->GetRloc16();
|
||||
}
|
||||
else
|
||||
{
|
||||
mMacSource.mLength = sizeof(mMacSource.mExtAddress);
|
||||
mMacSource.mExtAddress = netif.GetMac().GetExtAddress();
|
||||
mMacDest.mLength = sizeof(mMacDest.mExtAddress);
|
||||
mMacDest.mExtAddress = parent->GetExtAddress();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = OT_ERROR_DROP;
|
||||
}
|
||||
|
||||
error = PrepareDataPoll();
|
||||
break;
|
||||
}
|
||||
|
||||
case Message::kTypeSupervision:
|
||||
error = OT_ERROR_DROP;
|
||||
@@ -778,6 +751,36 @@ void MeshForwarder::PrepareIndirectTransmission(Message &aMessage, const Child &
|
||||
}
|
||||
}
|
||||
|
||||
otError MeshForwarder::PrepareDataPoll(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
ThreadNetif &netif = GetNetif();
|
||||
Neighbor *parent = netif.GetMle().GetParentCandidate();
|
||||
uint16_t shortAddress;
|
||||
|
||||
VerifyOrExit((parent != NULL) && parent->IsStateValidOrRestoring(), error = OT_ERROR_DROP);
|
||||
|
||||
shortAddress = netif.GetMac().GetShortAddress();
|
||||
|
||||
if ((shortAddress == Mac::kShortAddrInvalid) || (parent != netif.GetMle().GetParent()))
|
||||
{
|
||||
mMacSource.mLength = sizeof(mMacSource.mExtAddress);
|
||||
mMacSource.mExtAddress = netif.GetMac().GetExtAddress();
|
||||
mMacDest.mLength = sizeof(mMacDest.mExtAddress);
|
||||
mMacDest.mExtAddress = parent->GetExtAddress();
|
||||
}
|
||||
else
|
||||
{
|
||||
mMacSource.mLength = sizeof(mMacSource.mShortAddress);
|
||||
mMacSource.mShortAddress = shortAddress;
|
||||
mMacDest.mLength = sizeof(mMacDest.mShortAddress);
|
||||
mMacDest.mShortAddress = parent->GetRloc16();
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError MeshForwarder::UpdateMeshRoute(Message &aMessage)
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
|
||||
@@ -275,6 +275,7 @@ private:
|
||||
Message *GetIndirectTransmission(Child &aChild);
|
||||
otError PrepareDiscoverRequest(void);
|
||||
void PrepareIndirectTransmission(Message &aMessage, const Child &aChild);
|
||||
otError PrepareDataPoll(void);
|
||||
void HandleMesh(uint8_t *aFrame, uint8_t aPayloadLength, const Mac::Address &aMacSource,
|
||||
const otThreadLinkInfo &aLinkInfo);
|
||||
void HandleFragment(uint8_t *aFrame, uint8_t aPayloadLength,
|
||||
|
||||
Reference in New Issue
Block a user