mirror of
https://github.com/espressif/openthread.git
synced 2026-08-08 03:37:46 +00:00
[nexus] add SRP-TC-3 for lease renewal and automatic removal (#12759)
This commit adds a new Nexus test case 1_3_SRP_TC_3 which implements the test specification for service instance lease renewal and automatic service/host removal. The test covers: - SRP service registration and discovery via DNS and mDNS. - SRP lease renewal before expiration. - Automatic removal of SRP services and hosts after lease expiration. - Verification of DNS and mDNS responses after lease expiration, ensuring that expired records are no longer returned. Changes: - Add tests/nexus/test_1_3_SRP_TC_3.cpp for test execution. - Add tests/nexus/verify_1_3_SRP_TC_3.py for pcap verification. - Update tests/nexus/CMakeLists.txt to include the new test. - Update tests/nexus/run_nexus_tests.sh to add it to DEFAULT_TESTS.
This commit is contained in:
@@ -265,6 +265,7 @@ ot_nexus_test(1_3_DBR_TC_8 "cert;nexus")
|
||||
ot_nexus_test(1_3_DBR_TC_10 "cert;nexus")
|
||||
ot_nexus_test(1_3_SRP_TC_1 "cert;nexus")
|
||||
ot_nexus_test(1_3_SRP_TC_2 "cert;nexus")
|
||||
ot_nexus_test(1_3_SRP_TC_3 "cert;nexus")
|
||||
|
||||
# Misc tests
|
||||
ot_nexus_test(border_admitter "core;nexus")
|
||||
|
||||
@@ -201,6 +201,7 @@ DEFAULT_TESTS=(
|
||||
"1_3_DBR_TC_10"
|
||||
"1_3_SRP_TC_1"
|
||||
"1_3_SRP_TC_2"
|
||||
"1_3_SRP_TC_3"
|
||||
)
|
||||
|
||||
# Use provided arguments or the default test list
|
||||
|
||||
@@ -0,0 +1,578 @@
|
||||
/*
|
||||
* Copyright (c) 2026, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "platform/nexus_core.hpp"
|
||||
#include "platform/nexus_node.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace Nexus {
|
||||
|
||||
/**
|
||||
* Time to advance for a node to form a network and become leader, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kFormNetworkTime = 13 * 1000;
|
||||
|
||||
/**
|
||||
* Time to advance for a node to join a network, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kJoinNetworkTime = 10 * 1000;
|
||||
|
||||
/**
|
||||
* Time to advance for the BR to perform automatic actions (RA, Network Data), in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kBrActionTime = 20 * 1000;
|
||||
|
||||
/**
|
||||
* Time to advance for SRP server information to be updated in Network Data.
|
||||
*/
|
||||
static constexpr uint32_t kSrpServerInfoUpdateTime = 20 * 1000;
|
||||
|
||||
/**
|
||||
* Time to advance for SRP registration, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kSrpRegistrationTime = 10 * 1000;
|
||||
|
||||
/**
|
||||
* Time to advance for DNS query processing, in milliseconds.
|
||||
*/
|
||||
static constexpr uint32_t kDnsQueryTime = 5 * 1000;
|
||||
|
||||
/**
|
||||
* Infrastructure interface index.
|
||||
*/
|
||||
static constexpr uint32_t kInfraIfIndex = 1;
|
||||
|
||||
/**
|
||||
* SRP service registration parameters.
|
||||
*/
|
||||
static const char kSrpServiceType[] = "_thread-test._udp";
|
||||
static const char kSrpInstance1[] = "service-test-1";
|
||||
static const char kSrpHost1[] = "host-test-1";
|
||||
static const char kSrpFullServiceType[] = "_thread-test._udp.default.service.arpa.";
|
||||
static constexpr uint16_t kSrpServicePort = 55555;
|
||||
static constexpr uint32_t kSrpLease = 30;
|
||||
static constexpr uint32_t kSrpKeyLease = 600;
|
||||
static constexpr uint32_t kWaitTime15s = 15 * 1000;
|
||||
static constexpr uint32_t kWaitTime16s = 16 * 1000;
|
||||
|
||||
void Test_1_3_SRP_TC_3(const char *aJsonFileName)
|
||||
{
|
||||
Srp::Client::Service service;
|
||||
|
||||
/**
|
||||
* 2.3. [1.3] [CERT] Service Instance Lease - Renewal and Automatic Service/Host Removal
|
||||
*
|
||||
* 2.3.1. Purpose
|
||||
* To test the following:
|
||||
* - Handle lease renewal before lease expiration.
|
||||
* - Handle service/host lease expiration and removal of the service/host.
|
||||
*
|
||||
* 2.3.2. Topology
|
||||
* - 1. BR_1 (DUT)-Thread Border Router and the Leader
|
||||
* - 2. ED_1-Test Bed device operating as a Thread End Device, attached to BR_1
|
||||
* - 3. Eth 1-Test Bed border router device on an Adjacent Infrastructure Link
|
||||
*
|
||||
* Spec Reference | V1.3.0 Section
|
||||
* -------------------------|---------------
|
||||
* DNS-SD Unicast Dataset | 14.3.2.2
|
||||
*/
|
||||
|
||||
Core nexus;
|
||||
|
||||
Node &br1 = nexus.CreateNode();
|
||||
Node &ed1 = nexus.CreateNode();
|
||||
Node ð1 = nexus.CreateNode();
|
||||
|
||||
br1.SetName("BR_1");
|
||||
ed1.SetName("ED_1");
|
||||
eth1.SetName("Eth_1");
|
||||
|
||||
br1.Form();
|
||||
nexus.AdvanceTime(0);
|
||||
|
||||
Instance::SetLogLevel(kLogLevelNote);
|
||||
|
||||
Log("---------------------------------------------------------------------------------------");
|
||||
|
||||
/**
|
||||
* Step 1
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Enable: switch on.
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 1: BR 1 (DUT) switch on.");
|
||||
{
|
||||
Srp::Server::LeaseConfig leaseConfig;
|
||||
br1.Get<Srp::Server>().GetLeaseConfig(leaseConfig);
|
||||
leaseConfig.mMaxLease = kSrpLease;
|
||||
leaseConfig.mMinLease = kSrpLease;
|
||||
SuccessOrQuit(br1.Get<Srp::Server>().SetLeaseConfig(leaseConfig));
|
||||
}
|
||||
SuccessOrQuit(br1.Get<Srp::Server>().SetAddressMode(Srp::Server::kAddressModeUnicast));
|
||||
br1.Get<Srp::Server>().SetEnabled(true);
|
||||
br1.Get<BorderRouter::InfraIf>().Init(kInfraIfIndex, true);
|
||||
br1.Get<BorderRouter::RoutingManager>().Init();
|
||||
SuccessOrQuit(br1.Get<BorderRouter::RoutingManager>().SetEnabled(true));
|
||||
nexus.AdvanceTime(kFormNetworkTime);
|
||||
|
||||
/**
|
||||
* Step 2
|
||||
* - Device: Eth 1, ED 1
|
||||
* - Description (SRP-2.3): Enable
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 2: Eth 1, ED 1 Enable.");
|
||||
ed1.Join(br1, Node::kAsFed);
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().SetEnabled(true, kInfraIfIndex));
|
||||
nexus.AdvanceTime(kJoinNetworkTime);
|
||||
|
||||
// Wait for BR to advertise prefixes and EDs to get OMR addresses
|
||||
nexus.AdvanceTime(kBrActionTime);
|
||||
|
||||
/**
|
||||
* Step 3
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Automatically adds SRP Server information in the Thread Network Data. Automatically
|
||||
* provides an OMR prefix to the Thread Network.
|
||||
* - Pass Criteria:
|
||||
* - The DUT's SRP Server information MUST appear in the Thread Network Data. This can be verified as specified
|
||||
* in test case 2.1 step 3.
|
||||
* - Specifically, it MUST include a DNS-SD Unicast Dataset as per [ThreadSpec] 14.3.2.2.
|
||||
* - S_service_data Length MUST be 1 or 19
|
||||
*/
|
||||
Log("Step 3: BR 1 (DUT) adds SRP Server information in the Thread Network Data.");
|
||||
nexus.AdvanceTime(kSrpServerInfoUpdateTime);
|
||||
|
||||
/**
|
||||
* Step 4
|
||||
* - Device: ED 1
|
||||
* - Description (SRP-2.3): Harness instructs the device to send SRP Update to DUT: $ORIGIN default.service.arpa.
|
||||
* service-test-1._thread-test._udp ( SRV 0 0 55555 host-test-1 ) host-test-1 AAAA <OMR address of ED_1> with the
|
||||
* following options: Update Lease Option, Lease: 30 seconds, Key Lease: 10 minutes. Harness
|
||||
* instructs/configures device to avoid automatic renewal or resending of this SRP Update.
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 4: ED 1 sends SRP Update to DUT.");
|
||||
{
|
||||
ed1.Get<Srp::Client>().SetLeaseInterval(kSrpLease);
|
||||
ed1.Get<Srp::Client>().SetKeyLeaseInterval(kSrpKeyLease);
|
||||
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().SetHostName(kSrpHost1));
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().EnableAutoHostAddress());
|
||||
|
||||
ClearAllBytes(service);
|
||||
service.mName = kSrpServiceType;
|
||||
service.mInstanceName = kSrpInstance1;
|
||||
service.mPort = kSrpServicePort;
|
||||
service.mTxtEntries = nullptr;
|
||||
service.mNumTxtEntries = 0;
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().AddService(service));
|
||||
|
||||
ed1.Get<Srp::Client>().EnableAutoStartMode(nullptr, nullptr);
|
||||
}
|
||||
nexus.AdvanceTime(kSrpRegistrationTime);
|
||||
ed1.Get<Srp::Client>().Stop();
|
||||
|
||||
/**
|
||||
* Step 5
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Automatically sends SRP Update Response.
|
||||
* - Pass Criteria:
|
||||
* - The DUT MUST send a valid SRP Update Response, with RCODE=0 (NoError).
|
||||
*/
|
||||
Log("Step 5: BR 1 (DUT) sends SRP Update Response.");
|
||||
|
||||
/**
|
||||
* Step 6
|
||||
* - Device: ED 1
|
||||
* - Description (SRP-2.3): Harness instructs the device to unicast DNS query QType SRV to the DUT for service
|
||||
* "service-test-1._thread-test._udp.default.service.arpa"
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 6: ED 1 sends unicast DNS query QType SRV.");
|
||||
{
|
||||
SuccessOrQuit(ed1.Get<Dns::Client>().ResolveService(kSrpInstance1, kSrpFullServiceType, nullptr, nullptr));
|
||||
}
|
||||
nexus.AdvanceTime(kDnsQueryTime);
|
||||
|
||||
/**
|
||||
* Step 7
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Automatically sends DNS response.
|
||||
* - Pass Criteria:
|
||||
* - The DUT MUST send a valid DNS Response and contain in Answers section: $ORIGIN default.service.arpa.
|
||||
* service-test-1._thread-test._udp ( SRV 0 0 55555 host-test-1 )
|
||||
* - The DNS Response MAY contain in Additional records section: $ORIGIN default.service.arpa. host-test-1 AAAA
|
||||
* <OMR address of ED_1>
|
||||
*/
|
||||
Log("Step 7: BR 1 (DUT) sends DNS response.");
|
||||
|
||||
/**
|
||||
* Step 8
|
||||
* - Device: Eth_1
|
||||
* - Description (SRP-2.3): Harness instructs the device to send mDNS query QType SRV for
|
||||
* "service-test-1._thread-test._udp.local."
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 8: Eth 1 sends mDNS query QType SRV.");
|
||||
{
|
||||
Dns::Multicast::Core::SrvResolver resolver;
|
||||
ClearAllBytes(resolver);
|
||||
resolver.mCallback = [](otInstance *, const otPlatDnssdSrvResult *) {};
|
||||
resolver.mServiceInstance = kSrpInstance1;
|
||||
resolver.mServiceType = kSrpServiceType;
|
||||
resolver.mInfraIfIndex = kInfraIfIndex;
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().StartSrvResolver(resolver));
|
||||
nexus.AdvanceTime(kDnsQueryTime);
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().StopSrvResolver(resolver));
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 9
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Automatically sends mDNS Response.
|
||||
* - Pass Criteria:
|
||||
* - The DUT MUST send a valid mDNS Response and contain in Answers section: $ORIGIN local.
|
||||
* Service-test-1._thread-test._udp ( SRV 0 0 55555 host-test-1 )
|
||||
* - The DNS Response MAY contain in Additional records section: $ORIGIN local. Host-test-1 AAAA <OMR address of
|
||||
* ED_1>
|
||||
*/
|
||||
Log("Step 9: BR 1 (DUT) sends mDNS Response.");
|
||||
|
||||
/**
|
||||
* Step 10
|
||||
* - Device: N/A
|
||||
* - Description (SRP-2.3): Harness waits for 15 seconds.
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 10: Harness waits for 15 seconds.");
|
||||
nexus.AdvanceTime(kWaitTime15s);
|
||||
|
||||
/**
|
||||
* Step 11
|
||||
* - Device: ED 1
|
||||
* - Description (SRP-2.3): Harness instructs the device to send SRP Update to the DUT to renew the service lease:
|
||||
* $ORIGIN default.service.arpa. service-test-1._thread-test._udp ( SRV 0 0 55555 host-test-1 ) host-test-1 AAAA
|
||||
* <OMR address of ED_1> with the following options: Update Lease Option, Lease: 30 seconds, Key Lease: 10
|
||||
* minutes. Harness instructs/configures the device to avoid automatic renewal or resending of this SRP Update.
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 11: ED 1 sends SRP Update to renew the service lease.");
|
||||
{
|
||||
ed1.Get<Srp::Client>().ClearHostAndServices();
|
||||
ed1.Get<Srp::Client>().SetLeaseInterval(kSrpLease);
|
||||
ed1.Get<Srp::Client>().SetKeyLeaseInterval(kSrpKeyLease);
|
||||
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().SetHostName(kSrpHost1));
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().EnableAutoHostAddress());
|
||||
|
||||
ClearAllBytes(service);
|
||||
service.mName = kSrpServiceType;
|
||||
service.mInstanceName = kSrpInstance1;
|
||||
service.mPort = kSrpServicePort;
|
||||
service.mTxtEntries = nullptr;
|
||||
service.mNumTxtEntries = 0;
|
||||
SuccessOrQuit(ed1.Get<Srp::Client>().AddService(service));
|
||||
|
||||
ed1.Get<Srp::Client>().EnableAutoStartMode(nullptr, nullptr);
|
||||
}
|
||||
nexus.AdvanceTime(kSrpRegistrationTime);
|
||||
ed1.Get<Srp::Client>().Stop();
|
||||
|
||||
/**
|
||||
* Step 12
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Automatically sends SRP Update Response.
|
||||
* - Pass Criteria:
|
||||
* - The DUT MUST send a valid SRP Update Response, with RCODE=0 (NoError).
|
||||
*/
|
||||
Log("Step 12: BR 1 (DUT) sends SRP Update Response.");
|
||||
|
||||
/**
|
||||
* Step 13
|
||||
* - Device: N/A
|
||||
* - Description (SRP-2.3): Harness waits for 16 seconds.
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 13: Harness waits for 16 seconds.");
|
||||
nexus.AdvanceTime(kWaitTime16s);
|
||||
|
||||
/**
|
||||
* Step 14
|
||||
* - Device: ED 1
|
||||
* - Description (SRP-2.3): Harness instructs the device to unicast DNS query QType SRV to the DUT for service
|
||||
* "service-test-1._thread-test._udp.default.service.arpa"
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 14: ED 1 sends unicast DNS query QType SRV.");
|
||||
{
|
||||
SuccessOrQuit(ed1.Get<Dns::Client>().ResolveService(kSrpInstance1, kSrpFullServiceType, nullptr, nullptr));
|
||||
}
|
||||
nexus.AdvanceTime(kDnsQueryTime);
|
||||
|
||||
/**
|
||||
* Step 15
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Automatically sends DNS response.
|
||||
* - Pass Criteria:
|
||||
* - The DUT MUST send a valid DNS Response and contain answer record: $ORIGIN default.service.arpa.
|
||||
* service-test-1._thread-test._udp ( SRV 0 0 55555 host-test-1 )
|
||||
* - The DNS Response MAY contain in Additional records section: $ORIGIN default.service.arpa. host-test-1 AAAA
|
||||
* <OMR address of ED_1>
|
||||
*/
|
||||
Log("Step 15: BR 1 (DUT) sends DNS response.");
|
||||
|
||||
/**
|
||||
* Step 16
|
||||
* - Device: Eth 1
|
||||
* - Description (SRP-2.3): Harness instructs the device to send mDNS query QType PTR for any services of type
|
||||
* "_thread-test._udp.local."
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 16: Eth 1 sends mDNS query QType PTR.");
|
||||
{
|
||||
Dns::Multicast::Core::Browser browser;
|
||||
ClearAllBytes(browser);
|
||||
browser.mCallback = [](otInstance *, const otPlatDnssdBrowseResult *) {};
|
||||
browser.mServiceType = kSrpServiceType;
|
||||
browser.mInfraIfIndex = kInfraIfIndex;
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().StartBrowser(browser));
|
||||
nexus.AdvanceTime(kDnsQueryTime);
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().StopBrowser(browser));
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 17
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Automatically sends mDNS Response.
|
||||
* - Pass Criteria:
|
||||
* - The DUT MUST send a valid mDNS Response and contain answer record: $ORIGIN local. _thread-test._udp ( PTR
|
||||
* service-test-1._thread-test._udp )
|
||||
* - THe DNS Response MAY contain in Additional records section: $ORIGIN local. Service-test-1_thread-test._udp (
|
||||
* SRV 0 0 55555 host-test-1 ) host-test-1 AAAA <OMR address of ED_1>
|
||||
*/
|
||||
Log("Step 17: BR 1 (DUT) sends mDNS Response.");
|
||||
|
||||
/**
|
||||
* Step 18
|
||||
* - Device: N/A
|
||||
* - Description (SRP-2.3): Harness waits 15 seconds for the service lease to expire. Note: Both service and host
|
||||
* entries should expire now, after >= 31 seconds after last registration update. But the KEY record registration
|
||||
* remains active for both names.
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 18: Harness waits 15 seconds for the service lease to expire.");
|
||||
nexus.AdvanceTime(kWaitTime15s);
|
||||
|
||||
/**
|
||||
* Step 19
|
||||
* - Device: ED 1
|
||||
* - Description (SRP-2.3): Harness instructs the device to unicast DNS query QType SRV to the DUT for service
|
||||
* instance name "service-test-1._thread-test._udp.default.service.arpa"
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 19: ED 1 sends unicast DNS query QType SRV.");
|
||||
{
|
||||
SuccessOrQuit(ed1.Get<Dns::Client>().ResolveService(kSrpInstance1, kSrpFullServiceType, nullptr, nullptr));
|
||||
}
|
||||
nexus.AdvanceTime(kDnsQueryTime);
|
||||
|
||||
/**
|
||||
* Step 20
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Automatically sends DNS response but no matching SRV records. Note: only the key lease
|
||||
* is still active on the service instance name. The DUT's response may vary as shown on the right, depending on
|
||||
* implementation.
|
||||
* - Pass Criteria:
|
||||
* - The DUT MUST send a valid DNS Response and MUST be one of the below:
|
||||
* - 1. RCODE=0 (NoError) with 0 answer records.
|
||||
* - 2. RCODE=3 (NxDomain) with 0 answer records.
|
||||
*/
|
||||
Log("Step 20: BR 1 (DUT) sends DNS response (no SRV).");
|
||||
|
||||
/**
|
||||
* Step 21
|
||||
* - Device: ED 1
|
||||
* - Description (SRP-2.3): (Reserved for TBD future unicast DNS query QTYPE=ANY to the DUT for records for name
|
||||
* "host-test-1.default.service.arpa".)
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 21: ED 1 reserved step.");
|
||||
|
||||
/**
|
||||
* Step 22
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): (Reserved for TBD future: Automatically sends DNS response.) Note: because the key
|
||||
* lease is still active, the KEY record is optionally returned in response to the "ANY" query.
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 22: BR 1 (DUT) reserved step.");
|
||||
|
||||
/**
|
||||
* Step 23
|
||||
* - Device: Eth 1
|
||||
* - Description (SRP-2.3): Harness instructs device to send mDNS query QType=SRV for
|
||||
* "service-test-1._thread-test_udp.local."
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 23: Eth 1 sends mDNS query QType SRV.");
|
||||
{
|
||||
Dns::Multicast::Core::SrvResolver resolver;
|
||||
ClearAllBytes(resolver);
|
||||
resolver.mCallback = [](otInstance *, const otPlatDnssdSrvResult *) {};
|
||||
resolver.mServiceInstance = kSrpInstance1;
|
||||
resolver.mServiceType = kSrpServiceType;
|
||||
resolver.mInfraIfIndex = kInfraIfIndex;
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().StartSrvResolver(resolver));
|
||||
nexus.AdvanceTime(kDnsQueryTime);
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().StopSrvResolver(resolver));
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 24
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Does not respond to mDNS query, or automatically responds NSEC, or no-error-no-answer.
|
||||
* - Pass Criteria:
|
||||
* - The DUT MUST perform one of below options:
|
||||
* - 1. Sends RCODE=0 (NoError) and NSEC Answer record.
|
||||
* - 2. MUST NOT send any mDNS response.
|
||||
* - 3. Sends RCODE=0 (NoError) and 0 Answer records.
|
||||
*/
|
||||
Log("Step 24: BR 1 (DUT) mDNS verification for Step 23.");
|
||||
|
||||
/**
|
||||
* Step 25
|
||||
* - Device: Eth_1
|
||||
* - Description (SRP-2.3): Harness instructs the device to send mDNS query QType=PTR for any services of type
|
||||
* "_thread-test._udp.local."
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 25: Eth 1 sends mDNS query QType PTR.");
|
||||
{
|
||||
Dns::Multicast::Core::Browser browser;
|
||||
ClearAllBytes(browser);
|
||||
browser.mCallback = [](otInstance *, const otPlatDnssdBrowseResult *) {};
|
||||
browser.mServiceType = kSrpServiceType;
|
||||
browser.mInfraIfIndex = kInfraIfIndex;
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().StartBrowser(browser));
|
||||
nexus.AdvanceTime(kDnsQueryTime);
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().StopBrowser(browser));
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 26
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Does not respond to mDNS query, or automatically responds NSEC, or no-error-no-answer.
|
||||
* - Pass Criteria:
|
||||
* - The DUT MUST perform one of below options:
|
||||
* - 1. Sends RCODE=0 (NoError) and NSEC Answer record.
|
||||
* - 2. MUST NOT send any mDNS response.
|
||||
* - 3. Sends RCODE=0 (NoError) and 0 Answer records.
|
||||
*/
|
||||
Log("Step 26: BR 1 (DUT) mDNS verification for Step 25.");
|
||||
|
||||
/**
|
||||
* Step 27
|
||||
* - Device: Eth 1
|
||||
* - Description (SRP-2.3): Harness instructs device to send mDNS query for Qtype AAAA for name "host-test-1.local."
|
||||
* - Pass Criteria:
|
||||
* - N/A
|
||||
*/
|
||||
Log("Step 27: Eth 1 sends mDNS query for QType AAAA.");
|
||||
{
|
||||
Dns::Multicast::Core::AddressResolver resolver;
|
||||
ClearAllBytes(resolver);
|
||||
resolver.mCallback = [](otInstance *, const otPlatDnssdAddressResult *) {};
|
||||
resolver.mHostName = kSrpHost1;
|
||||
resolver.mInfraIfIndex = kInfraIfIndex;
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().StartIp6AddressResolver(resolver));
|
||||
nexus.AdvanceTime(kDnsQueryTime);
|
||||
SuccessOrQuit(eth1.Get<Dns::Multicast::Core>().StopIp6AddressResolver(resolver));
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 28
|
||||
* - Device: BR 1 (DUT)
|
||||
* - Description (SRP-2.3): Does not respond to mDNS query, or automatically responds NSEC, or no-error-no-answer.
|
||||
* Note: this indicates the DUT is authoritative for the host name, but has no AAAA records to answer for the
|
||||
* name.
|
||||
* - Pass Criteria:
|
||||
* - The DUT MUST perform one of below options:
|
||||
* - 1. Sends RCODE=0 (NoError) and NSEC Answer record.
|
||||
* - 2. MUST NOT send any mDNS response.
|
||||
* - 3. Sends RCODE=0 (NoError) and 0 Answer records.
|
||||
*/
|
||||
Log("Step 28: BR 1 (DUT) mDNS verification for Step 27.");
|
||||
|
||||
Log("All steps completed.");
|
||||
|
||||
nexus.AddTestVar("BR_1_MLEID_ADDR", br1.Get<Mle::Mle>().GetMeshLocalEid().ToString().AsCString());
|
||||
nexus.AddTestVar("ED_1_MLEID_ADDR", ed1.Get<Mle::Mle>().GetMeshLocalEid().ToString().AsCString());
|
||||
|
||||
{
|
||||
String<10> srpPortString;
|
||||
srpPortString.Append("%u", br1.Get<Srp::Server>().GetPort());
|
||||
nexus.AddTestVar("BR_1_SRP_PORT", srpPortString.AsCString());
|
||||
}
|
||||
|
||||
Ip6::Prefix omrPrefix;
|
||||
SuccessOrQuit(br1.Get<BorderRouter::RoutingManager>().GetOmrPrefix(omrPrefix));
|
||||
nexus.AddTestVar("ED_1_OMR_ADDR", ed1.FindMatchingAddress(omrPrefix.ToString().AsCString()).ToString().AsCString());
|
||||
|
||||
nexus.SaveTestInfo(aJsonFileName);
|
||||
}
|
||||
|
||||
} // namespace Nexus
|
||||
} // namespace ot
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ot::Nexus::Test_1_3_SRP_TC_3((argc > 2) ? argv[2] : "test_1_3_SRP_TC_3.json");
|
||||
|
||||
printf("All tests passed\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -189,6 +189,29 @@ def verify(pv):
|
||||
assert MDNS_INSTANCE_2 not in verify_utils.as_list(
|
||||
p.mdns.resp.name), f"Packet {p.index} contains MDNS_INSTANCE_2 in resp.name"
|
||||
|
||||
def verify_mdns_ptr_response(pkts, instance_name):
|
||||
return pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: instance_name in verify_utils.as_list(p.mdns.ptr.domain_name)). \
|
||||
must_next()
|
||||
|
||||
def verify_mdns_srv_response(pkts, instance_name, port):
|
||||
return pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: instance_name in verify_utils.as_list(p.mdns.resp.name)). \
|
||||
filter(lambda p: port in verify_utils.as_list(p.mdns.srv.port)). \
|
||||
must_next()
|
||||
|
||||
def verify_mdns_aaaa_response(pkts, host_name, omr_addr):
|
||||
return pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: host_name in verify_utils.as_list(p.mdns.resp.name)). \
|
||||
filter(lambda p: omr_addr in verify_utils.as_list(p.mdns.aaaa)). \
|
||||
must_next()
|
||||
|
||||
# Step 8 era
|
||||
index_step8 = pkts.index
|
||||
|
||||
@@ -222,11 +245,7 @@ def verify(pv):
|
||||
print("Step 9: BR 1 (DUT) sends mDNS response with initial registered service.")
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
res = pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_INSTANCE_1 in verify_utils.as_list(p.mdns.ptr.domain_name)). \
|
||||
must_next()
|
||||
res = verify_mdns_ptr_response(pkts, MDNS_INSTANCE_1)
|
||||
verify_no_ed2_info(res)
|
||||
|
||||
# Step 9b
|
||||
@@ -239,12 +258,7 @@ def verify(pv):
|
||||
print("Step 9b: Eth 1 sends mDNS query QTYPE SRV.")
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_INSTANCE_1 in verify_utils.as_list(p.mdns.resp.name)). \
|
||||
filter(lambda p: SRP_PORT_33333 in verify_utils.as_list(p.mdns.srv.port)). \
|
||||
must_next()
|
||||
verify_mdns_srv_response(pkts, MDNS_INSTANCE_1, SRP_PORT_33333)
|
||||
|
||||
# Step 9c
|
||||
# - Device: Eth 1
|
||||
@@ -256,12 +270,7 @@ def verify(pv):
|
||||
print("Step 9c: Eth 1 sends mDNS query QTYPE AAAA.")
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_HOST_1 in verify_utils.as_list(p.mdns.resp.name)). \
|
||||
filter(lambda p: ED_1_OMR in verify_utils.as_list(p.mdns.aaaa)). \
|
||||
must_next()
|
||||
verify_mdns_aaaa_response(pkts, MDNS_HOST_1, ED_1_OMR)
|
||||
|
||||
# Step 10
|
||||
# - Device: ED 2
|
||||
@@ -312,31 +321,17 @@ def verify(pv):
|
||||
print("Step 13: BR 1 (DUT) repeats mDNS response verification.")
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
res = pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_INSTANCE_1 in verify_utils.as_list(p.mdns.ptr.domain_name)). \
|
||||
must_next()
|
||||
res = verify_mdns_ptr_response(pkts, MDNS_INSTANCE_1)
|
||||
assert ED_1_OMR in verify_utils.as_list(res.mdns.aaaa)
|
||||
verify_no_ed2_info(res)
|
||||
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_INSTANCE_1 in verify_utils.as_list(p.mdns.resp.name)). \
|
||||
filter(lambda p: SRP_PORT_33333 in verify_utils.as_list(p.mdns.srv.port)). \
|
||||
must_next()
|
||||
verify_mdns_srv_response(pkts, MDNS_INSTANCE_1, SRP_PORT_33333)
|
||||
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_HOST_1 in verify_utils.as_list(p.mdns.resp.name)). \
|
||||
filter(lambda p: ED_1_OMR in verify_utils.as_list(p.mdns.aaaa)). \
|
||||
must_next()
|
||||
verify_mdns_aaaa_response(pkts, MDNS_HOST_1, ED_1_OMR)
|
||||
|
||||
# Step 14
|
||||
# - Device: ED 2
|
||||
@@ -401,18 +396,10 @@ def verify(pv):
|
||||
print("Step 17: BR 1 (DUT) sends mDNS response with both registered services.")
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_INSTANCE_1 in verify_utils.as_list(p.mdns.ptr.domain_name)). \
|
||||
must_next()
|
||||
verify_mdns_ptr_response(pkts, MDNS_INSTANCE_1)
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_INSTANCE_2 in verify_utils.as_list(p.mdns.ptr.domain_name)). \
|
||||
must_next()
|
||||
verify_mdns_ptr_response(pkts, MDNS_INSTANCE_2)
|
||||
|
||||
# Step 17b
|
||||
# - Device: Eth 1
|
||||
@@ -424,12 +411,7 @@ def verify(pv):
|
||||
print("Step 17b: Eth 1 sends mDNS query QTYPE SRV instance 1.")
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_INSTANCE_1 in verify_utils.as_list(p.mdns.resp.name)). \
|
||||
filter(lambda p: SRP_PORT_33333 in verify_utils.as_list(p.mdns.srv.port)). \
|
||||
must_next()
|
||||
verify_mdns_srv_response(pkts, MDNS_INSTANCE_1, SRP_PORT_33333)
|
||||
|
||||
# Step 17c
|
||||
# - Device: Eth_1
|
||||
@@ -441,12 +423,7 @@ def verify(pv):
|
||||
print("Step 17c: Eth 1 sends mDNS query QTYPE SRV instance 2.")
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_INSTANCE_2 in verify_utils.as_list(p.mdns.resp.name)). \
|
||||
filter(lambda p: SRP_PORT_44444 in verify_utils.as_list(p.mdns.srv.port)). \
|
||||
must_next()
|
||||
verify_mdns_srv_response(pkts, MDNS_INSTANCE_2, SRP_PORT_44444)
|
||||
|
||||
# Step 17d
|
||||
# - Device: Eth 1
|
||||
@@ -458,12 +435,7 @@ def verify(pv):
|
||||
print("Step 17d: Eth 1 sends mDNS query QTYPE AAAA host 1.")
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_HOST_1 in verify_utils.as_list(p.mdns.resp.name)). \
|
||||
filter(lambda p: ED_1_OMR in verify_utils.as_list(p.mdns.aaaa)). \
|
||||
must_next()
|
||||
verify_mdns_aaaa_response(pkts, MDNS_HOST_1, ED_1_OMR)
|
||||
|
||||
# Step 17e
|
||||
# - Device: Eth_1
|
||||
@@ -475,12 +447,7 @@ def verify(pv):
|
||||
print("Step 17e: Eth 1 sends mDNS query QTYPE AAAA host 2.")
|
||||
with pkts.save_index():
|
||||
pkts.index = index_step8
|
||||
pkts.\
|
||||
filter(lambda p: p.udp.dstport == 5353). \
|
||||
filter(lambda p: p.mdns.flags.response == 1). \
|
||||
filter(lambda p: MDNS_HOST_2 in verify_utils.as_list(p.mdns.resp.name)). \
|
||||
filter(lambda p: ED_2_OMR in verify_utils.as_list(p.mdns.aaaa)). \
|
||||
must_next()
|
||||
verify_mdns_aaaa_response(pkts, MDNS_HOST_2, ED_2_OMR)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -0,0 +1,474 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (c) 2026, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import sys
|
||||
import os
|
||||
import struct
|
||||
|
||||
# Add the current directory to sys.path to find verify_utils
|
||||
CUR_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(CUR_DIR)
|
||||
|
||||
import verify_utils
|
||||
from pktverify import consts
|
||||
from pktverify.addrs import Ipv6Addr, EthAddr
|
||||
from pktverify.bytes import Bytes
|
||||
|
||||
|
||||
def verify(pv):
|
||||
#
|
||||
# 2.3. [1.3] [CERT] Service Instance Lease - Renewal and Automatic Service/Host Removal
|
||||
#
|
||||
# 2.3.1. Purpose
|
||||
# To test the following:
|
||||
# - Handle lease renewal before lease expiration.
|
||||
# - Handle service/host lease expiration and removal of the service/host.
|
||||
#
|
||||
# 2.3.2. Topology
|
||||
# - 1. BR_1 (DUT)-Thread Border Router and the Leader
|
||||
# - 2. ED_1-Test Bed device operating as a Thread End Device, attached to BR_1
|
||||
# - 3. Eth 1-Test Bed border router device on an Adjacent Infrastructure Link
|
||||
#
|
||||
# Spec Reference | V1.3.0 Section
|
||||
# -------------------------|---------------
|
||||
# DNS-SD Unicast Dataset | 14.3.2.2
|
||||
|
||||
pkts = pv.pkts
|
||||
pv.summary.show()
|
||||
|
||||
ED_1_MLEID = Ipv6Addr(pv.vars['ED_1_MLEID_ADDR'])
|
||||
ED_1_OMR = Ipv6Addr(pv.vars['ED_1_OMR_ADDR'])
|
||||
BR_1_MLEID = Ipv6Addr(pv.vars['BR_1_MLEID_ADDR'])
|
||||
br1_srp_port = int(pv.vars['BR_1_SRP_PORT'])
|
||||
BR_1_ETH = EthAddr(pv.vars['BR_1_ETH'])
|
||||
|
||||
SRP_SERVICE_NAME = '_thread-test._udp.default.service.arpa'
|
||||
SRP_INSTANCE_NAME = 'service-test-1.' + SRP_SERVICE_NAME
|
||||
SRP_HOST_NAME = 'host-test-1.default.service.arpa'
|
||||
MDNS_SERVICE_NAME = '_thread-test._udp.local'
|
||||
MDNS_INSTANCE_NAME = 'service-test-1.' + MDNS_SERVICE_NAME
|
||||
MDNS_HOST_NAME = 'host-test-1.local'
|
||||
|
||||
SRP_SERVICE_PORT = 55555
|
||||
|
||||
SERVICE_ID_SRP_SERVER = 93
|
||||
SRP_LEASE = 30
|
||||
SRP_KEY_LEASE = 600
|
||||
SRP_LEASE_DATA = Bytes(struct.pack('>II', SRP_LEASE, SRP_KEY_LEASE).hex())
|
||||
|
||||
def verify_srp_update(pkts, dst, src, srp_port, instance_name, service_port, host_name, omr_addr, lease_data):
|
||||
return pkts.\
|
||||
filter_ipv6_dst(dst).\
|
||||
filter_ipv6_src(src).\
|
||||
filter(lambda p: p.udp.dstport == srp_port).\
|
||||
filter(lambda p: p.dns.flags.opcode == 5).\
|
||||
filter(lambda p: instance_name in verify_utils.as_list(p.dns.resp.name)).\
|
||||
filter(lambda p: service_port is None or service_port in verify_utils.as_list(p.dns.srv.port)).\
|
||||
filter(lambda p: host_name is None or host_name in verify_utils.as_list(p.dns.srv.target)).\
|
||||
filter(lambda p: omr_addr in verify_utils.as_list(p.dns.aaaa)).\
|
||||
filter(lambda p: lease_data in verify_utils.as_list(p.dns.opt.data)).\
|
||||
must_next()
|
||||
|
||||
# Step 1
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Enable: switch on.
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 1: BR 1 (DUT) switch on.")
|
||||
|
||||
# Step 2
|
||||
# - Device: Eth 1, ED 1
|
||||
# - Description (SRP-2.3): Enable
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 2: Eth 1, ED 1 Enable.")
|
||||
|
||||
# Step 3
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Automatically adds SRP Server information in the Thread Network Data. Automatically
|
||||
# provides an OMR prefix to the Thread Network.
|
||||
# - Pass Criteria:
|
||||
# - The DUT's SRP Server information MUST appear in the Thread Network Data. This can be verified as specified
|
||||
# in test case 2.1 step 3.
|
||||
# - Specifically, it MUST include a DNS-SD Unicast Dataset as per [ThreadSpec] 14.3.2.2.
|
||||
# - S_service_data Length MUST be 1 or 19
|
||||
print("Step 3: BR 1 (DUT) adds SRP Server information in the Thread Network Data.")
|
||||
pkts.\
|
||||
filter_mle_cmd(consts.MLE_DATA_RESPONSE).\
|
||||
filter(lambda p: SERVICE_ID_SRP_SERVER in verify_utils.as_list(p.thread_nwd.tlv.service.srp_dataset_identifier)).\
|
||||
filter(lambda p: any(l in (1, 19) for l in verify_utils.as_list(p.thread_nwd.tlv.service.s_data_len))).\
|
||||
must_next()
|
||||
|
||||
# Step 4
|
||||
# - Device: ED 1
|
||||
# - Description (SRP-2.3): Harness instructs the device to send SRP Update to DUT: $ORIGIN default.service.arpa.
|
||||
# service-test-1._thread-test._udp ( SRV 0 0 55555 host-test-1 ) host-test-1 AAAA <OMR address of ED_1> with the
|
||||
# following options: Update Lease Option, Lease: 30 seconds, Key Lease: 10 minutes. Harness
|
||||
# instructs/configures device to avoid automatic renewal or resending of this SRP Update.
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 4: ED 1 sends SRP Update to DUT.")
|
||||
verify_srp_update(pkts, BR_1_MLEID, ED_1_MLEID, br1_srp_port, SRP_INSTANCE_NAME, SRP_SERVICE_PORT, SRP_HOST_NAME,
|
||||
ED_1_OMR, SRP_LEASE_DATA)
|
||||
|
||||
# Step 5
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Automatically sends SRP Update Response.
|
||||
# - Pass Criteria:
|
||||
# - The DUT MUST send a valid SRP Update Response, with RCODE=0 (NoError).
|
||||
print("Step 5: BR 1 (DUT) sends SRP Update Response.")
|
||||
pkts.\
|
||||
filter_ipv6_dst(ED_1_MLEID).\
|
||||
filter_ipv6_src(BR_1_MLEID).\
|
||||
filter(lambda p: p.udp.srcport == br1_srp_port).\
|
||||
filter(lambda p: p.dns.flags.response == 1).\
|
||||
filter(lambda p: p.dns.flags.rcode == 0).\
|
||||
must_next()
|
||||
|
||||
# Step 6
|
||||
# - Device: ED 1
|
||||
# - Description (SRP-2.3): Harness instructs the device to unicast DNS query QType SRV to the DUT for service
|
||||
# "service-test-1._thread-test._udp.default.service.arpa"
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 6: ED 1 sends unicast DNS query QType SRV.")
|
||||
pkts.\
|
||||
filter_ipv6_dst(BR_1_MLEID).\
|
||||
filter_ipv6_src(ED_1_MLEID).\
|
||||
filter(lambda p: p.udp.dstport == 53).\
|
||||
filter(lambda p: p.dns.flags.response == 0).\
|
||||
filter(lambda p: SRP_INSTANCE_NAME in verify_utils.as_list(p.dns.qry.name)).\
|
||||
must_next()
|
||||
|
||||
# Step 7
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Automatically sends DNS response.
|
||||
# - Pass Criteria:
|
||||
# - The DUT MUST send a valid DNS Response and contain in Answers section: $ORIGIN default.service.arpa.
|
||||
# service-test-1._thread-test._udp ( SRV 0 0 55555 host-test-1 )
|
||||
# - The DNS Response MAY contain in Additional records section: $ORIGIN default.service.arpa. host-test-1 AAAA
|
||||
# <OMR address of ED_1>
|
||||
print("Step 7: BR 1 (DUT) sends DNS response.")
|
||||
pkts.\
|
||||
filter_ipv6_dst(ED_1_MLEID).\
|
||||
filter_ipv6_src(BR_1_MLEID).\
|
||||
filter(lambda p: p.udp.srcport == 53).\
|
||||
filter(lambda p: p.dns.flags.response == 1).\
|
||||
filter(lambda p: p.dns.flags.rcode == 0).\
|
||||
filter(lambda p: SRP_INSTANCE_NAME in verify_utils.as_list(p.dns.resp.name)).\
|
||||
filter(lambda p: SRP_SERVICE_PORT in verify_utils.as_list(p.dns.srv.port)).\
|
||||
filter(lambda p: SRP_HOST_NAME in verify_utils.as_list(p.dns.srv.target)).\
|
||||
must_next()
|
||||
|
||||
# Step 8
|
||||
# - Device: Eth_1
|
||||
# - Description (SRP-2.3): Harness instructs the device to send mDNS query QType SRV for
|
||||
# "service-test-1._thread-test._udp.local."
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 8: Eth 1 sends mDNS query QType SRV.")
|
||||
pkts.\
|
||||
filter_ipv6_dst('ff02::fb').\
|
||||
filter(lambda p: p.udp.dstport == 5353).\
|
||||
filter(lambda p: p.mdns.flags.response == 0).\
|
||||
filter(lambda p: MDNS_INSTANCE_NAME in verify_utils.as_list(p.mdns.qry.name)).\
|
||||
must_next()
|
||||
|
||||
# Step 9
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Automatically sends mDNS Response.
|
||||
# - Pass Criteria:
|
||||
# - The DUT MUST send a valid mDNS Response and contain in Answers section: $ORIGIN local.
|
||||
# Service-test-1._thread-test._udp ( SRV 0 0 55555 host-test-1 )
|
||||
# - The DNS Response MAY contain in Additional records section: $ORIGIN local. Host-test-1 AAAA <OMR address of
|
||||
# ED_1>
|
||||
print("Step 9: BR 1 (DUT) sends mDNS Response.")
|
||||
pkts.\
|
||||
filter(lambda p: p.eth.src == BR_1_ETH).\
|
||||
filter(lambda p: p.udp.dstport == 5353).\
|
||||
filter(lambda p: p.mdns.flags.response == 1).\
|
||||
filter(lambda p: MDNS_INSTANCE_NAME in verify_utils.as_list(p.mdns.resp.name)).\
|
||||
filter(lambda p: SRP_SERVICE_PORT in verify_utils.as_list(p.mdns.srv.port)).\
|
||||
filter(lambda p: MDNS_HOST_NAME in verify_utils.as_list(p.mdns.srv.target)).\
|
||||
must_next()
|
||||
|
||||
# Step 10
|
||||
# - Device: N/A
|
||||
# - Description (SRP-2.3): Harness waits for 15 seconds.
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 10: Harness waits for 15 seconds.")
|
||||
|
||||
# Step 11
|
||||
# - Device: ED 1
|
||||
# - Description (SRP-2.3): Harness instructs the device to send SRP Update to the DUT to renew the service lease:
|
||||
# $ORIGIN default.service.arpa. service-test-1._thread-test._udp ( SRV 0 0 55555 host-test-1 ) host-test-1 AAAA
|
||||
# <OMR address of ED_1> with the following options: Update Lease Option, Lease: 30 seconds, Key Lease: 10
|
||||
# minutes. Harness instructs/configures the device to avoid automatic renewal or resending of this SRP Update.
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 11: ED 1 sends SRP Update to renew the service lease.")
|
||||
verify_srp_update(pkts, BR_1_MLEID, ED_1_MLEID, br1_srp_port, SRP_INSTANCE_NAME, None, None, ED_1_OMR,
|
||||
SRP_LEASE_DATA)
|
||||
|
||||
# Step 12
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Automatically sends SRP Update Response.
|
||||
# - Pass Criteria:
|
||||
# - The DUT MUST send a valid SRP Update Response, with RCODE=0 (NoError).
|
||||
print("Step 12: BR 1 (DUT) sends SRP Update Response.")
|
||||
pkts.\
|
||||
filter_ipv6_dst(ED_1_MLEID).\
|
||||
filter_ipv6_src(BR_1_MLEID).\
|
||||
filter(lambda p: p.udp.srcport == br1_srp_port).\
|
||||
filter(lambda p: p.dns.flags.response == 1).\
|
||||
filter(lambda p: p.dns.flags.rcode == 0).\
|
||||
must_next()
|
||||
|
||||
# Step 13
|
||||
# - Device: N/A
|
||||
# - Description (SRP-2.3): Harness waits for 16 seconds.
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 13: Harness waits for 16 seconds.")
|
||||
|
||||
# Step 14
|
||||
# - Device: ED 1
|
||||
# - Description (SRP-2.3): Harness instructs the device to unicast DNS query QType SRV to the DUT for service
|
||||
# "service-test-1._thread-test._udp.default.service.arpa"
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 14: ED 1 sends unicast DNS query QType SRV.")
|
||||
pkts.\
|
||||
filter_ipv6_dst(BR_1_MLEID).\
|
||||
filter_ipv6_src(ED_1_MLEID).\
|
||||
filter(lambda p: p.udp.dstport == 53).\
|
||||
filter(lambda p: p.dns.flags.response == 0).\
|
||||
filter(lambda p: SRP_INSTANCE_NAME in verify_utils.as_list(p.dns.qry.name)).\
|
||||
must_next()
|
||||
|
||||
# Step 15
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Automatically sends DNS response.
|
||||
# - Pass Criteria:
|
||||
# - The DUT MUST send a valid DNS Response and contain answer record: $ORIGIN default.service.arpa.
|
||||
# service-test-1._thread-test._udp ( SRV 0 0 55555 host-test-1 )
|
||||
# - The DNS Response MAY contain in Additional records section: $ORIGIN default.service.arpa. host-test-1 AAAA
|
||||
# <OMR address of ED_1>
|
||||
print("Step 15: BR 1 (DUT) sends DNS response.")
|
||||
pkts.\
|
||||
filter_ipv6_dst(ED_1_MLEID).\
|
||||
filter_ipv6_src(BR_1_MLEID).\
|
||||
filter(lambda p: p.udp.srcport == 53).\
|
||||
filter(lambda p: p.dns.flags.response == 1).\
|
||||
filter(lambda p: p.dns.flags.rcode == 0).\
|
||||
filter(lambda p: SRP_INSTANCE_NAME in verify_utils.as_list(p.dns.resp.name)).\
|
||||
filter(lambda p: SRP_SERVICE_PORT in verify_utils.as_list(p.dns.srv.port)).\
|
||||
filter(lambda p: SRP_HOST_NAME in verify_utils.as_list(p.dns.srv.target)).\
|
||||
must_next()
|
||||
|
||||
# Step 16
|
||||
# - Device: Eth 1
|
||||
# - Description (SRP-2.3): Harness instructs the device to send mDNS query QType PTR for any services of type
|
||||
# "_thread-test._udp.local."
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 16: Eth 1 sends mDNS query QType PTR.")
|
||||
pkts.\
|
||||
filter_ipv6_dst('ff02::fb').\
|
||||
filter(lambda p: p.udp.dstport == 5353).\
|
||||
filter(lambda p: p.mdns.flags.response == 0).\
|
||||
filter(lambda p: MDNS_SERVICE_NAME in verify_utils.as_list(p.mdns.qry.name)).\
|
||||
must_next()
|
||||
|
||||
# Step 17
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Automatically sends mDNS Response.
|
||||
# - Pass Criteria:
|
||||
# - The DUT MUST send a valid mDNS Response and contain answer record: $ORIGIN local. _thread-test._udp ( PTR
|
||||
# service-test-1._thread-test._udp )
|
||||
# - THe DNS Response MAY contain in Additional records section: $ORIGIN local. Service-test-1_thread-test._udp (
|
||||
# SRV 0 0 55555 host-test-1 ) host-test-1 AAAA <OMR address of ED_1>
|
||||
print("Step 17: BR 1 (DUT) sends mDNS Response.")
|
||||
pkts.\
|
||||
filter(lambda p: p.eth.src == BR_1_ETH).\
|
||||
filter(lambda p: p.udp.dstport == 5353).\
|
||||
filter(lambda p: p.mdns.flags.response == 1).\
|
||||
filter(lambda p: MDNS_INSTANCE_NAME in verify_utils.as_list(p.mdns.ptr.domain_name)).\
|
||||
must_next()
|
||||
|
||||
# Step 18
|
||||
# - Device: N/A
|
||||
# - Description (SRP-2.3): Harness waits 15 seconds for the service lease to expire. Note: Both service and host
|
||||
# entries should expire now, after >= 31 seconds after last registration update. But the KEY record registration
|
||||
# remains active for both names.
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 18: Harness waits 15 seconds for the service lease to expire.")
|
||||
|
||||
# Step 19
|
||||
# - Device: ED 1
|
||||
# - Description (SRP-2.3): Harness instructs the device to unicast DNS query QType SRV to the DUT for service
|
||||
# instance name "service-test-1._thread-test._udp.default.service.arpa"
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 19: ED 1 sends unicast DNS query QType SRV.")
|
||||
pkts.\
|
||||
filter_ipv6_dst(BR_1_MLEID).\
|
||||
filter_ipv6_src(ED_1_MLEID).\
|
||||
filter(lambda p: p.udp.dstport == 53).\
|
||||
filter(lambda p: p.dns.flags.response == 0).\
|
||||
filter(lambda p: SRP_INSTANCE_NAME in verify_utils.as_list(p.dns.qry.name)).\
|
||||
must_next()
|
||||
|
||||
# Step 20
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Automatically sends DNS response but no matching SRV records. Note: only the key lease
|
||||
# is still active on the service instance name. The DUT's response may vary as shown on the right, depending on
|
||||
# implementation.
|
||||
# - Pass Criteria:
|
||||
# - The DUT MUST send a valid DNS Response and MUST be one of the below:
|
||||
# - 1. RCODE=0 (NoError) with 0 answer records.
|
||||
# - 2. RCODE=3 (NxDomain) with 0 answer records.
|
||||
print("Step 20: BR 1 (DUT) sends DNS response (no SRV).")
|
||||
pkts.\
|
||||
filter_ipv6_dst(ED_1_MLEID).\
|
||||
filter_ipv6_src(BR_1_MLEID).\
|
||||
filter(lambda p: p.udp.srcport == 53).\
|
||||
filter(lambda p: p.dns.flags.response == 1).\
|
||||
filter(lambda p: p.dns.flags.rcode in (0, 3)).\
|
||||
filter(lambda p: p.dns.count.answers == 0).\
|
||||
must_next()
|
||||
|
||||
# Step 21
|
||||
# - Device: ED 1
|
||||
# - Description (SRP-2.3): (Reserved for TBD future unicast DNS query QTYPE=ANY to the DUT for records for name
|
||||
# "host-test-1.default.service.arpa".)
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 21: ED 1 reserved step.")
|
||||
|
||||
# Step 22
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): (Reserved for TBD future: Automatically sends DNS response.) Note: because the key
|
||||
# lease is still active, the KEY record is optionally returned in response to the "ANY" query.
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 22: BR 1 (DUT) reserved step.")
|
||||
|
||||
# Step 23
|
||||
# - Device: Eth 1
|
||||
# - Description (SRP-2.3): Harness instructs device to send mDNS query QType=SRV for
|
||||
# "service-test-1._thread-test_udp.local."
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 23: Eth 1 sends mDNS query QType SRV.")
|
||||
pkts.\
|
||||
filter_ipv6_dst('ff02::fb').\
|
||||
filter(lambda p: p.udp.dstport == 5353).\
|
||||
filter(lambda p: p.mdns.flags.response == 0).\
|
||||
filter(lambda p: MDNS_INSTANCE_NAME in verify_utils.as_list(p.mdns.qry.name)).\
|
||||
must_next()
|
||||
|
||||
def verify_optional_mdns_no_answer_response():
|
||||
with pkts.save_index():
|
||||
responses = pkts.\
|
||||
filter(lambda p: p.eth.src == BR_1_ETH).\
|
||||
filter(lambda p: p.udp.dstport == 5353).\
|
||||
filter(lambda p: p.mdns.flags.response == 1)
|
||||
p = responses.next()
|
||||
if p:
|
||||
p.must_verify(lambda p: p.mdns.flags.rcode == 0 and
|
||||
(p.mdns.count.answers == 0 or hasattr(p.mdns, 'nsec')))
|
||||
|
||||
# Step 24
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Does not respond to mDNS query, or automatically responds NSEC, or no-error-no-answer.
|
||||
# - Pass Criteria:
|
||||
# - The DUT MUST perform one of below options:
|
||||
# - 1. Sends RCODE=0 (NoError) and NSEC Answer record.
|
||||
# - 2. MUST NOT send any mDNS response.
|
||||
# - 3. Sends RCODE=0 (NoError) and 0 Answer records.
|
||||
print("Step 24: BR 1 (DUT) mDNS verification for Step 23.")
|
||||
verify_optional_mdns_no_answer_response()
|
||||
|
||||
# Step 25
|
||||
# - Device: Eth_1
|
||||
# - Description (SRP-2.3): Harness instructs the device to send mDNS query QType=PTR for any services of type
|
||||
# "_thread-test._udp.local."
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 25: Eth 1 sends mDNS query QType PTR.")
|
||||
pkts.\
|
||||
filter_ipv6_dst('ff02::fb').\
|
||||
filter(lambda p: p.udp.dstport == 5353).\
|
||||
filter(lambda p: p.mdns.flags.response == 0).\
|
||||
filter(lambda p: MDNS_SERVICE_NAME in verify_utils.as_list(p.mdns.qry.name)).\
|
||||
must_next()
|
||||
|
||||
# Step 26
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Does not respond to mDNS query, or automatically responds NSEC, or no-error-no-answer.
|
||||
# - Pass Criteria:
|
||||
# - The DUT MUST perform one of below options:
|
||||
# - 1. Sends RCODE=0 (NoError) and NSEC Answer record.
|
||||
# - 2. MUST NOT send any mDNS response.
|
||||
# - 3. Sends RCODE=0 (NoError) and 0 Answer records.
|
||||
print("Step 26: BR 1 (DUT) mDNS verification for Step 25.")
|
||||
verify_optional_mdns_no_answer_response()
|
||||
|
||||
# Step 27
|
||||
# - Device: Eth 1
|
||||
# - Description (SRP-2.3): Harness instructs device to send mDNS query for Qtype AAAA for name "host-test-1.local."
|
||||
# - Pass Criteria:
|
||||
# - N/A
|
||||
print("Step 27: Eth 1 sends mDNS query for QType AAAA.")
|
||||
pkts.\
|
||||
filter_ipv6_dst('ff02::fb').\
|
||||
filter(lambda p: p.udp.dstport == 5353).\
|
||||
filter(lambda p: p.mdns.flags.response == 0).\
|
||||
filter(lambda p: MDNS_HOST_NAME in verify_utils.as_list(p.mdns.qry.name)).\
|
||||
must_next()
|
||||
|
||||
# Step 28
|
||||
# - Device: BR 1 (DUT)
|
||||
# - Description (SRP-2.3): Does not respond to mDNS query, or automatically responds NSEC, or no-error-no-answer.
|
||||
# Note: this indicates the DUT is authoritative for the host name, but has no AAAA records to answer for the
|
||||
# name.
|
||||
# - Pass Criteria:
|
||||
# - The DUT MUST perform one of below options:
|
||||
# - 1. Sends RCODE=0 (NoError) and NSEC Answer record.
|
||||
# - 2. MUST NOT send any mDNS response.
|
||||
# - 3. Sends RCODE=0 (NoError) and 0 Answer records.
|
||||
print("Step 28: BR 1 (DUT) mDNS verification for Step 27.")
|
||||
verify_optional_mdns_no_answer_response()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
verify_utils.run_main(verify)
|
||||
@@ -605,6 +605,9 @@ def apply_patches():
|
||||
layer_fields._LAYER_FIELDS['coap.tlv.bbr_seqno'] = layer_fields._auto
|
||||
layer_fields._LAYER_FIELDS['thread_meshcop.tlv.delay_timer'] = layer_fields._auto
|
||||
layer_fields._LAYER_FIELDS['mle.tlv.link_query_options'] = layer_fields._bytes
|
||||
layer_fields._LAYER_FIELDS['dns.opt.data'] = layer_fields._list(layer_fields._bytes)
|
||||
layer_fields._layer_containers.add('dns.opt')
|
||||
layer_fields._LAYER_FIELDS['mdns.nsec'] = layer_fields._list(layer_fields._bytes)
|
||||
|
||||
def which_tshark_patch():
|
||||
default_path = '/tmp/thread-wireshark/tshark'
|
||||
|
||||
Reference in New Issue
Block a user