Skip to content

Commit 05ad980

Browse files
authored
[nexus] add 1.4 PIC-TC-1 test for DHCPv6-PD and DNS (openthread#12859)
This commit adds a new Nexus test that implements the test specification in test-1-4-PIC-TC-1.md. The test verifies Border Router functionality including: - DHCPv6-PD client to obtain OMR prefix - Advertising route to OMR prefix on AIL (Stub Router) - DNS recursive resolver for public internet addresses - Connectivity (ICMPv6, UDP, TCP/HTTP) to internet and local servers New files: - tests/nexus/test_1_4_PIC_TC_1.cpp: C++ test execution - tests/nexus/verify_1_4_PIC_TC_1.py: Python pcap verification Nexus platform enhancements: - Enabled DHCPv6-PD client in openthread-core-nexus-config.h - Implemented DHCPv6-PD platform APIs in nexus_infra_if.cpp - Added RDNSS option to RA in nexus_infra_if.cpp - Improved packet delivery on infrastructure interface in nexus_core.cpp - Fixed upstream DNS query matching in nexus_dns.cpp
1 parent b3ab4df commit 05ad980

10 files changed

Lines changed: 910 additions & 8 deletions

File tree

tests/nexus/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ ot_nexus_test(1_4_TREL_TC_6 "cert;nexus")
296296
ot_nexus_test(1_4_DNS_TC_1 "cert;nexus")
297297
ot_nexus_test(1_4_DNS_TC_3 "cert;nexus")
298298
ot_nexus_test(1_4_DNS_TC_5 "cert;nexus")
299+
ot_nexus_test(1_4_PIC_TC_1 "cert;nexus")
299300
ot_nexus_test(1_4_CS_TC_3 "cert;nexus")
300301

301302
# Misc tests

tests/nexus/openthread-core-nexus-config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#define OPENTHREAD_CONFIG_BORDER_AGENT_TXT_DATA_PARSER_ENABLE 1
5454
#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 1
5555
#define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE 1
56-
#define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE 0
56+
#define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE 1
5757
#define OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE 1
5858
#define OPENTHREAD_CONFIG_BORDER_ROUTING_TESTING_API_ENABLE 1
5959
#define OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE 1

tests/nexus/platform/nexus_core.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,10 @@ void Core::ProcessInfraIf(Node &aNode)
648648

649649
if (!header.GetDestination().IsMulticast())
650650
{
651-
targetNode = FindNodeByInfraIfAddress(header.GetDestination());
651+
if (!IsThreadAddress(header.GetDestination()))
652+
{
653+
targetNode = FindNodeByAddress(header.GetDestination());
654+
}
652655
}
653656

654657
for (Node &rxNode : mNodes)

tests/nexus/platform/nexus_dns.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ void UpstreamDns::StartUpstreamQuery(UpstreamQueryTransaction &aTxn, const Messa
110110
ot::Dns::Header dnsHeader;
111111
PendingQuery *pendingQuery;
112112
Message *message = nullptr;
113+
113114
// We use kDnsPort (53) as both source and destination port for upstream queries to simplify interception
114115
// and response matching in this simulation environment.
115116

tests/nexus/platform/nexus_infra_if.cpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
#include "nexus_infra_if.hpp"
3030

31-
#include "nexus_core.hpp"
31+
#include <openthread/platform/infra_if.h>
32+
3233
#include "nexus_node.hpp"
3334

3435
namespace ot {
@@ -39,6 +40,8 @@ InfraIf::InfraIf(Instance &aInstance)
3940
, mIfIndex(0)
4041
, mUdpHook(nullptr)
4142
, mHasRioPrefix(false)
43+
, mDhcp6PdListening(false)
44+
, mIsDnsServer(false)
4245
, mRaTimer(aInstance)
4346
{
4447
}
@@ -196,6 +199,13 @@ void InfraIf::SendRouterAdvertisement(const Ip6::Address &aDestination,
196199
SuccessOrQuit(ra.AppendRouteInfoOption(*aRioPrefix, 1800, NetworkData::kRoutePreferenceMedium));
197200
}
198201

202+
// ETH_2 (Node 4) acts as DNS server
203+
if (mIsDnsServer)
204+
{
205+
const Ip6::Address dnsServerAddr = GetLinkLocalAddress();
206+
SuccessOrQuit(ra.AppendRecursiveDnsServerOption(&dnsServerAddr, 1, 1800));
207+
}
208+
199209
ra.GetAsPacket(packet);
200210

201211
SendIcmp6Nd(aDestination, packet.GetBytes(), packet.GetLength());
@@ -406,13 +416,30 @@ void InfraIf::SendUdp(const Ip6::Address &aSrcAddress,
406416
mPendingTxQueue.Enqueue(aPayload);
407417
}
408418

419+
void InfraIf::SetDhcp6ListeningEnabled(bool aEnable) { mDhcp6PdListening = aEnable; }
420+
421+
void InfraIf::SendDhcp6(Message &aMessage, const Ip6::Address &aDestAddress)
422+
{
423+
SendUdp(SelectSourceAddress(aDestAddress), aDestAddress, Dhcp6::kDhcpClientPort, Dhcp6::kDhcpServerPort, aMessage);
424+
}
425+
409426
void InfraIf::Receive(Message &aMessage)
410427
{
411428
Ip6::Headers headers;
412429

413430
aMessage.SetOffset(0);
414431
SuccessOrExit(headers.ParseFrom(aMessage));
415432

433+
if (mDhcp6PdListening && headers.IsUdp() && headers.GetDestinationPort() == Dhcp6::kDhcpClientPort)
434+
{
435+
Message *payload = aMessage.Clone<kNoReservedHeader>();
436+
437+
VerifyOrQuit(payload != nullptr);
438+
payload->RemoveHeader(sizeof(Ip6::Header) + sizeof(Ip6::Udp::Header));
439+
otPlatInfraIfDhcp6PdClientHandleReceived(&GetInstance(), payload, mIfIndex);
440+
ExitNow();
441+
}
442+
416443
if (headers.IsIcmp6() && (headers.GetDestinationAddress() == Ip6::Address::GetLinkLocalAllNodesMulticast() ||
417444
headers.GetDestinationAddress() == Ip6::Address::GetLinkLocalAllRoutersMulticast() ||
418445
HasAddress(headers.GetDestinationAddress())))
@@ -648,6 +675,18 @@ otError otPlatGetInfraIfLinkLayerAddress(otInstance *aInstanc
648675
return OT_ERROR_NONE;
649676
}
650677

678+
void otPlatInfraIfDhcp6PdClientSetListeningEnabled(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex)
679+
{
680+
OT_UNUSED_VARIABLE(aInfraIfIndex);
681+
AsNode(aInstance).mInfraIf.SetDhcp6ListeningEnabled(aEnable);
682+
}
683+
684+
void otPlatInfraIfDhcp6PdClientSend(otInstance *aInstance, otMessage *aMessage, otIp6Address *aDest, uint32_t aIfIndex)
685+
{
686+
OT_UNUSED_VARIABLE(aIfIndex);
687+
AsNode(aInstance).mInfraIf.SendDhcp6(AsCoreType(aMessage), AsCoreType(aDest));
688+
}
689+
651690
} // extern "C"
652691

653692
} // namespace Nexus

tests/nexus/platform/nexus_infra_if.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ class InfraIf : public InstanceLocator
8585

8686
void SetEchoReplyHandler(EchoReplyHandler aHandler, void *aContext) { mEchoReplyCallback.Set(aHandler, aContext); }
8787

88+
void SetDhcp6ListeningEnabled(bool aEnable);
89+
void SetIsDnsServer(bool aEnable) { mIsDnsServer = aEnable; }
90+
void SendDhcp6(Message &aMessage, const Ip6::Address &aDestAddress);
91+
8892
typedef bool (*UdpHook)(Instance &aInstance, Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
8993
void SetUdpHook(UdpHook aHook) { mUdpHook = aHook; }
9094

@@ -108,6 +112,8 @@ class InfraIf : public InstanceLocator
108112
Ip6::Prefix mPioPrefix;
109113
Ip6::Prefix mRioPrefix;
110114
bool mHasRioPrefix;
115+
bool mDhcp6PdListening;
116+
bool mIsDnsServer;
111117

112118
using RaTimer = TimerMilliIn<InfraIf, &InfraIf::HandleRaTimer>;
113119

tests/nexus/run_nexus_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ DEFAULT_TESTS=(
229229
"1_4_DNS_TC_1"
230230
"1_4_DNS_TC_3"
231231
"1_4_DNS_TC_5"
232+
"1_4_PIC_TC_1"
232233
"1_4_CS_TC_3"
233234
)
234235

0 commit comments

Comments
 (0)