Full End Devices should initiate mesh-under forwarding. (#1870)

This commit is contained in:
Jonathan Hui
2017-06-05 12:31:54 -07:00
committed by GitHub
parent decf6b5cf6
commit 6d470c2fb1
2 changed files with 36 additions and 23 deletions
+25 -23
View File
@@ -696,37 +696,39 @@ otError MeshForwarder::UpdateIp6Route(Message &aMessage)
break;
case OT_DEVICE_ROLE_CHILD:
if (aMessage.IsLinkSecurityEnabled())
case OT_DEVICE_ROLE_ROUTER:
case OT_DEVICE_ROLE_LEADER:
if (mNetif.GetMle().IsMinimalEndDevice())
{
mMacDest.mLength = sizeof(mMacDest.mShortAddress);
if (ip6Header.GetDestination().IsLinkLocalMulticast())
if (aMessage.IsLinkSecurityEnabled())
{
mMacDest.mShortAddress = Mac::kShortAddrBroadcast;
mMacDest.mLength = sizeof(mMacDest.mShortAddress);
if (ip6Header.GetDestination().IsLinkLocalMulticast())
{
mMacDest.mShortAddress = Mac::kShortAddrBroadcast;
}
else
{
mMacDest.mShortAddress = mNetif.GetMle().GetNextHop(Mac::kShortAddrBroadcast);
}
GetMacSourceAddress(ip6Header.GetSource(), mMacSource);
}
else if (ip6Header.GetDestination().IsLinkLocal() || ip6Header.GetDestination().IsLinkLocalMulticast())
{
GetMacDestinationAddress(ip6Header.GetDestination(), mMacDest);
GetMacSourceAddress(ip6Header.GetSource(), mMacSource);
}
else
{
mMacDest.mShortAddress = mNetif.GetMle().GetNextHop(Mac::kShortAddrBroadcast);
ExitNow(error = OT_ERROR_DROP);
}
GetMacSourceAddress(ip6Header.GetSource(), mMacSource);
}
else if (ip6Header.GetDestination().IsLinkLocal() || ip6Header.GetDestination().IsLinkLocalMulticast())
{
GetMacDestinationAddress(ip6Header.GetDestination(), mMacDest);
GetMacSourceAddress(ip6Header.GetSource(), mMacSource);
}
else
{
ExitNow(error = OT_ERROR_DROP);
}
break;
#if OPENTHREAD_FTD
else
{
case OT_DEVICE_ROLE_ROUTER:
case OT_DEVICE_ROLE_LEADER:
uint16_t rloc16;
uint16_t aloc16;
Neighbor *neighbor;
@@ -827,10 +829,10 @@ otError MeshForwarder::UpdateIp6Route(Message &aMessage)
mAddMeshHeader = true;
}
}
break;
}
#endif // OPENTHREAD_FTD
break;
default:
break;
+11
View File
@@ -623,6 +623,17 @@ public:
*/
uint8_t GetDeviceMode(void) const { return mDeviceMode; }
/**
* This method indicates whether or not the device is a Minimal End Device.
*
* @returns TRUE if the device is a Minimal End Device, FALSE otherwise.
*
*/
bool IsMinimalEndDevice(void) const {
return (mDeviceMode & (ModeTlv::kModeFFD | ModeTlv::kModeRxOnWhenIdle)) !=
(ModeTlv::kModeFFD | ModeTlv::kModeRxOnWhenIdle);
}
/**
* This method sets the Device Mode as reported in the Mode TLV.
*