Skip to content

Commit

Permalink
[ccm] Fix discovery response format for CCM networks when non-CCM rou…
Browse files Browse the repository at this point in the history
…ters are not allowed.

For 1.2 certification (specifically "TC 5.2.4 (DISC-TC-04): 1.1/1.2 non-CCM Joiner does not join CCM Network"):
CCM networks are supposed to include AE port and NMKP port, and NOT include the legacy joiner UDP port, so that the non-CCM router that is trying to join can see the discovery response and not proceed with joining.  AE port / NMKP port, and other CCM concepts are now deprecated in the OpenThread stack.  Still, we need some hooks here to pass certification properly.

1. Don't include joiner UDP port when non-CCM routers are not allowed on the network.
2. Non-CCM joiners should not proceed with joining when joiner UDP port is not included.
3. Also following up with test harness implementation to fix the scripting for 1.2 certification test "TC 5.2.4 (DISC-TC-04): 1.1/1.2 non-CCM Joiner does not join CCM Network"
  • Loading branch information
suveshpratapa committed Sep 20, 2023
1 parent 21ac9f5 commit 9e99d8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/core/thread/discover_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ void DiscoverScanner::HandleDiscoveryResponse(Mle::RxInfo &aRxInfo) const
uint16_t offset;
uint16_t end;
bool didCheckSteeringData = false;
bool joinerUdpPortTlvPresent = false;

Mle::Log(Mle::kMessageReceive, Mle::kTypeDiscoveryResponse, aRxInfo.mMessageInfo.GetPeerAddr());

Expand Down Expand Up @@ -375,6 +376,7 @@ void DiscoverScanner::HandleDiscoveryResponse(Mle::RxInfo &aRxInfo) const
case MeshCoP::Tlv::kJoinerUdpPort:
SuccessOrExit(error =
Tlv::Read<MeshCoP::JoinerUdpPortTlv>(aRxInfo.mMessage, offset, result.mJoinerUdpPort));
joinerUdpPortTlvPresent = true;
break;

default:
Expand All @@ -386,6 +388,8 @@ void DiscoverScanner::HandleDiscoveryResponse(Mle::RxInfo &aRxInfo) const

VerifyOrExit(!mEnableFiltering || didCheckSteeringData);

VerifyOrExit(joinerUdpPortTlvPresent, error = kErrorDrop);

mCallback.InvokeIfSet(&result);

exit:
Expand Down
8 changes: 6 additions & 2 deletions src/core/thread/mle_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2909,8 +2909,12 @@ Error MleRouter::SendDiscoveryResponse(const Ip6::Address &aDestination, const M
}
}

SuccessOrExit(
error = Tlv::Append<MeshCoP::JoinerUdpPortTlv>(*message, Get<MeshCoP::JoinerRouter>().GetJoinerUdpPort()));
if (! Get<KeyManager>().GetSecurityPolicy().mCommercialCommissioningEnabled
|| Get<KeyManager>().GetSecurityPolicy().mNonCcmRoutersEnabled)
{
SuccessOrExit(
error = Tlv::Append<MeshCoP::JoinerUdpPortTlv>(*message, Get<MeshCoP::JoinerRouter>().GetJoinerUdpPort()));
}

tlv.SetLength(static_cast<uint8_t>(message->GetLength() - startOffset));
message->Write(startOffset - sizeof(tlv), tlv);
Expand Down

0 comments on commit 9e99d8c

Please sign in to comment.