[nexus] add SRP_TC_5 for key record inclusion/omission (#12764)

This commit adds the Nexus test case 1_3_SRP_TC_5 which verifies SRP
KEY record inclusion and omission behavior according to the Thread 1.3
test specification (SRP TC-5).

The implementation includes:
- Adding mHostKeyRecordEnabled flag to Srp::Client to control host
  KEY record inclusion in SRP Updates. This is enabled only when
  OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE is defined.
- Implementing SetHostKeyRecordEnabled() and IsHostKeyRecordEnabled()
  methods in Srp::Client.
- Modifying AppendHostDescriptionInstruction() in srp_client.cpp
  to conditionally include the KEY record.
- Creating tests/nexus/test_1_3_SRP_TC_5.cpp to execute the test
  sequence across multiple simulated nodes (BR_1, ED_1, Eth_1).
- Creating tests/nexus/verify_1_3_SRP_TC_5.py to perform automated
  verification of the captured traffic.
- Updating tests/nexus/CMakeLists.txt and
  tests/nexus/run_nexus_tests.sh to include the new test.

The test ensures that the SRP server correctly handles updates with
and without service KEY records, omits KEY records in DNS/mDNS
responses, and rejects updates that omit all KEY records.
This commit is contained in:
Jonathan Hui
2026-03-26 15:12:24 -05:00
committed by GitHub
parent 94dca41a86
commit 274c47ab10
6 changed files with 723 additions and 1 deletions
+7 -1
View File
@@ -332,6 +332,7 @@ Client::Client(Instance &aInstance)
, mShouldRemoveKeyLease(false)
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
, mServiceKeyRecordEnabled(false)
, mHostKeyRecordEnabled(true)
, mUseShortLeaseOption(false)
#endif
, mCurMessageId(0)
@@ -1545,7 +1546,12 @@ Error Client::AppendHostDescriptionInstruction(MsgInfo &aInfo)
// KEY RR
SuccessOrExit(error = AppendHostName(aInfo));
SuccessOrExit(error = AppendKeyRecord(aInfo));
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
if (mHostKeyRecordEnabled)
#endif
{
SuccessOrExit(error = AppendKeyRecord(aInfo));
}
exit:
return error;
+22
View File
@@ -714,6 +714,27 @@ public:
*/
bool IsServiceKeyRecordEnabled(void) const { return mServiceKeyRecordEnabled; }
/**
* Enables/disables "host key record inclusion" mode.
*
* When enabled (default), SRP client will include KEY record in Host Description Instruction.
*
* @note Host KEY record is required in Host Description Instruction. The default behavior of the SRP client is to
* include it. This method is added under the `REFERENCE_DEVICE` config and is intended to override the default
* behavior for testing only. `SetHostKeyRecordEnabled(false)` makes the SRP client non-functional and non-compliant
* and is used solely for testing to validate SRP server behavior.
*
* @param[in] aEnabled TRUE to enable, FALSE to disable the "host key record inclusion" mode.
*/
void SetHostKeyRecordEnabled(bool aEnabled) { mHostKeyRecordEnabled = aEnabled; }
/**
* Indicates whether the "host key record inclusion" mode is enabled or disabled.
*
* @returns TRUE if "host key record inclusion" mode is enabled, FALSE otherwise.
*/
bool IsHostKeyRecordEnabled(void) const { return mHostKeyRecordEnabled; }
/**
* Enables/disables "use short Update Lease Option" behavior.
*
@@ -1079,6 +1100,7 @@ private:
bool mShouldRemoveKeyLease : 1;
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
bool mServiceKeyRecordEnabled : 1;
bool mHostKeyRecordEnabled : 1;
bool mUseShortLeaseOption : 1;
#endif
+1
View File
@@ -268,6 +268,7 @@ 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")
ot_nexus_test(1_3_SRP_TC_4 "cert;nexus")
ot_nexus_test(1_3_SRP_TC_5 "cert;nexus")
# Misc tests
ot_nexus_test(border_admitter "core;nexus")
+1
View File
@@ -203,6 +203,7 @@ DEFAULT_TESTS=(
"1_3_SRP_TC_2"
"1_3_SRP_TC_3"
"1_3_SRP_TC_4"
"1_3_SRP_TC_5"
)
# Use provided arguments or the default test list
+400
View File
@@ -0,0 +1,400 @@
/*
* 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 DNS query processing, in milliseconds.
*/
static constexpr uint32_t kDnsQueryTime = 10 * 1000;
/**
* Infrastructure interface index.
*/
static constexpr uint32_t kInfraIfIndex = 1;
/**
* SRP service registration parameters.
*/
static const char kSrpServiceType[] = "_thread-test._udp";
static const char kSrpInstanceName[] = "service test 1";
static const char kSrpHostName[] = "host-test-1";
static const char kDnsQueryServiceType[] = "_thread-test._udp.default.service.arpa.";
static constexpr uint16_t kSrpServicePort = 1500;
void Test_1_3_SRP_TC_5(const char *aJsonFileName)
{
Srp::Client::Service service;
/**
* 2.5. [1.3] [CERT] KEY record inclusion/omission
*
* 2.5.1. Purpose
* To test the following:
* - 1. Handle Service Description Instructions that include the KEY RR.
* - 2. Handle Service Description Instructions that omit the KEY RR.
* - 3. Report error on Host Description Instructions that omit the KEY RR.
*
* 2.5.2. Topology
* - BR_1 (DUT) - Thread Border Router and the Leader
* - ED_1 - Test Bed device operating as a Thread End Device, attached to BR_1
* - Eth_1 - Test Bed border router device on an Adjacent Infrastructure Link
*
* Spec Reference | V1.1 Section | V1.3.0 Section
* -----------------|--------------|---------------
* SRP Server | N/A | 1.3
*/
Core nexus;
Node &br1 = nexus.CreateNode();
Node &ed1 = nexus.CreateNode();
Node &eth1 = 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.5): Enable: switch on.
* - Pass Criteria:
* - N/A
*/
Log("Step 1: BR_1 (DUT) Enable: switch on.");
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.5): 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 ED to get an OMR address
*/
nexus.AdvanceTime(kBrActionTime);
/**
* Step 3
* - Device: BR_1 (DUT)
* - Description (SRP-2.5): Automatically adds SRP Server information in the Thread Network Data; and configures
* OMR prefix.
* - Pass Criteria:
* - The DUT's SRP Server information MUST appear in the Thread Network Data, as DNS/SRP Unicast Dataset, or
* DNS/SRP Anycast Dataset, or both.
* - ULA OMR prefix MUST appear in the Thread Network Data.
*/
Log("Step 3: BR_1 (DUT) Automatically adds SRP Server information in the Thread Network Data.");
nexus.AdvanceTime(kSrpServerInfoUpdateTime);
/**
* Step 4
* - Device: ED_1
* - Description (SRP-2.5): Harness instructs the device to send SRP Update to the DUT with service KEY records
* enabled:
* $ORIGIN default.service.arpa.
* _thread-test._udp PTR service test 1._thread-test._udp
* service test 1._thread-test._udp ( SRV 0 0 1500 host-test-1 ) KEY <public key of ED_1>
* host-test-1 AAAA <ML-EID address of ED_1> AAAA <OMR address of ED_1> KEY <public key of ED_1>
* with the following options: Update Lease Option Lease: 20 minutes Key Lease: 20 minutes
* Note: normally a client will not register the ML-EID address in this situation. For testing purposes, the
* harness will configure/force this.
* Note: including service KEY records is not typically done by default. Reference device is configured for
* this.
* - Pass Criteria:
* - N/A
*/
Log("Step 4: ED_1 sends SRP Update to the DUT with service KEY records enabled.");
{
ed1.Get<Srp::Client>().EnableAutoStartMode(nullptr, nullptr);
SuccessOrQuit(ed1.Get<Srp::Client>().SetHostName(kSrpHostName));
SuccessOrQuit(ed1.Get<Srp::Client>().EnableAutoHostAddress());
ClearAllBytes(service);
service.mName = kSrpServiceType;
service.mInstanceName = kSrpInstanceName;
service.mPort = kSrpServicePort;
ed1.Get<Srp::Client>().SetServiceKeyRecordEnabled(true);
SuccessOrQuit(ed1.Get<Srp::Client>().AddService(service));
}
nexus.AdvanceTime(kBrActionTime);
/**
* Step 5
* - Device: BR_1 (DUT)
* - Description (SRP-2.5): Automatically sends success SRP Update Response.
* - Pass Criteria:
* - The DUT MUST send a valid SRP Update Response with RCODE=0 (NoError).
*/
Log("Step 5: BR_1 (DUT) Automatically sends success SRP Update Response.");
nexus.AdvanceTime(kBrActionTime);
/**
* Step 6
* - Device: ED_1
* - Description (SRP-2.5): Harness instructs the device to unicast DNS QType=PTR query to the DUT for all
* services of type _thread-test._udp.local..
* - Pass Criteria:
* - N/A
*/
Log("Step 6: ED_1 unicast DNS QType=PTR query to the DUT.");
{
SuccessOrQuit(ed1.Get<Dns::Client>().Browse(kDnsQueryServiceType, nullptr, nullptr));
}
nexus.AdvanceTime(kDnsQueryTime);
/**
* Step 7
* - Device: BR_1 (DUT)
* - Description (SRP-2.5): Automatically sends DNS response.
* - Pass Criteria:
* - The DUT MUST send a valid DNS Response containing Answer record: $ORIGIN default.service.arpa.
* _thread-test._udp PTR service test 1._thread-test._udp
* - It MAY contain in the Additional records section: $ORIGIN default.service.arpa.
* service test 1._thread-test._udp ( SRV 0 0 1500 host-test-1 ) host-test-1 AAAA <ML-EID address of ED_1>
* AAAA <OMR address of ED_1>
* - The DNS Response MUST NOT contain any RRType=KEY records.
*/
Log("Step 7: BR_1 (DUT) Automatically sends DNS response.");
nexus.AdvanceTime(kDnsQueryTime);
/**
* Step 8
* - Device: Eth_1
* - Description (SRP-2.5): Harness instructs the device to send mDNS QType=PTR query for services of type
* _thread-test._udp.local.
* - Pass Criteria:
* - N/A
*/
Log("Step 8: Eth_1 send mDNS QType=PTR query.");
{
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);
IgnoreError(eth1.Get<Dns::Multicast::Core>().StopBrowser(browser));
}
/**
* Step 9
* - Device: BR_1 (DUT)
* - Description (SRP-2.5): Automatically sends mDNS Response.
* - Pass Criteria:
* - The DUT MUST send a valid mDNS Response containing Answer record: $ORIGIN local.
* _thread-test._udp PTR service test 1._thread-test._udp
* - It MAY contain in the Additional records section: Service test 1._thread-test._udp ( SRV 0 0 1500
* host-test-1 ) host-test-1 AAAA <OMR address of ED_1>
* - The DNS Response MUST NOT contain any RRType=KEY records.
* - The DNS Response MAY also contain in the Additional records section: host-test-1.local AAAA
* <ML-EID address of ED_1>
*/
Log("Step 9: BR_1 (DUT) Automatically sends mDNS Response.");
nexus.AdvanceTime(kDnsQueryTime);
/**
* Step 10
* - Device: N/A
* - Description (SRP-2.5): Repeat Steps 4 through 9 with KEY record omitted from Service Description
* Instruction in step 4, i.e. the following record is omitted in step 4: service test 1._thread-test._udp KEY
* <pubkey of ED_1>. The host KEY records are kept.
* - Pass Criteria:
* - Same as Steps 4 through 9.
*/
Log("Step 10: Repeat Steps 4 through 9 with KEY record omitted from Service Description Instruction.");
/**
* Implementation of Step 10 (Repeat 4-9)
*/
Log("Step 10.4: ED_1 sends SRP Update with service KEY record disabled.");
{
ed1.Get<Srp::Client>().SetServiceKeyRecordEnabled(false);
IgnoreError(ed1.Get<Srp::Client>().ClearService(service));
SuccessOrQuit(ed1.Get<Srp::Client>().AddService(service));
}
nexus.AdvanceTime(kBrActionTime);
Log("Step 10.5: BR_1 (DUT) Automatically sends success SRP Update Response.");
nexus.AdvanceTime(kBrActionTime);
Log("Step 10.6: ED_1 unicast DNS QType=PTR query.");
{
SuccessOrQuit(ed1.Get<Dns::Client>().Browse(kDnsQueryServiceType, nullptr, nullptr));
}
nexus.AdvanceTime(kDnsQueryTime);
Log("Step 10.7: BR_1 (DUT) Automatically sends DNS response.");
nexus.AdvanceTime(kDnsQueryTime);
Log("Step 10.8: Eth_1 send mDNS QType=PTR query.");
{
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 * 2);
IgnoreError(eth1.Get<Dns::Multicast::Core>().StopBrowser(browser));
}
Log("Step 10.9: BR_1 (DUT) Automatically sends mDNS Response.");
nexus.AdvanceTime(kDnsQueryTime);
/**
* Step 11
* - Device: ED_1
* - Description (SRP-2.5): Repeat Step 4 with service KEY records omitted, while keeping host KEY records.
* - Pass Criteria:
* - Repeat Step 4
*/
Log("Step 11: Repeat Step 4 with service KEY records omitted.");
/**
* This seems redundant with Step 10's repeat of Step 4, but I will follow the spec.
*/
{
ed1.Get<Srp::Client>().SetServiceKeyRecordEnabled(false);
IgnoreError(ed1.Get<Srp::Client>().ClearService(service));
SuccessOrQuit(ed1.Get<Srp::Client>().AddService(service));
}
nexus.AdvanceTime(kBrActionTime);
/**
* Step 12
* - Device: BR_1 (DUT)
* - Description (SRP-2.5): Automatically sends success SRP Update Response.
* - Pass Criteria:
* - Repeat Step 5
*/
Log("Step 12: BR_1 (DUT) Automatically sends success SRP Update Response.");
nexus.AdvanceTime(kBrActionTime);
/**
* Step 13
* - Device: ED_1
* - Description (SRP-2.5): Repeat Step 4 with all KEY records omitted. Note: currently (2022-07) this is not yet
* supported in reference devices. It could be implemented using a "UDP send" API with a manually constructed
* sequence of bytes that forms the invalid SRP Update message. To be considered for the future.
* - Pass Criteria:
* - N/A (TBD to be added in the future)
*/
Log("Step 13: ED_1 Repeat Step 4 with all KEY records omitted.");
{
ed1.Get<Srp::Client>().SetServiceKeyRecordEnabled(false);
ed1.Get<Srp::Client>().SetHostKeyRecordEnabled(false);
IgnoreError(ed1.Get<Srp::Client>().ClearService(service));
SuccessOrQuit(ed1.Get<Srp::Client>().AddService(service));
}
nexus.AdvanceTime(kBrActionTime);
/**
* Step 14
* - Device: BR_1 (DUT)
* - Description (SRP-2.5): Automatically responds with error SRP Update Response.
* - Pass Criteria:
* - N/A (TBD-add in the future verify that RCODE=5, Refused)
*/
Log("Step 14: BR_1 (DUT) Automatically responds with error SRP Update Response.");
nexus.AdvanceTime(kBrActionTime);
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());
}
nexus.SaveTestInfo(aJsonFileName);
}
} // namespace Nexus
} // namespace ot
int main(int argc, char *argv[])
{
ot::Nexus::Test_1_3_SRP_TC_5((argc > 2) ? argv[2] : "test_1_3_SRP_TC_5.json");
printf("All tests passed\n");
return 0;
}
+292
View File
@@ -0,0 +1,292 @@
#!/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
# 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
def verify(pv):
# 2.5. [1.3] [CERT] KEY record inclusion/omission
#
# 2.5.1. Purpose
# To test the following:
# 1. Handle Service Description Instructions that include the KEY RR.
# 2. Handle Service Description Instructions that omit the KEY RR.
# 3. Report error on Host Description Instructions that omit the KEY RR.
#
# 2.5.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
pkts = pv.pkts
pv.summary.show()
ED_1_MLEID = Ipv6Addr(pv.vars['ED_1_MLEID_ADDR'])
BR_1_MLEID = Ipv6Addr(pv.vars['BR_1_MLEID_ADDR'])
br1_srp_port = int(pv.vars['BR_1_SRP_PORT'])
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
DNS_QUERY_NAME = '_thread-test._udp.default.service.arpa'
SRP_SERVICE_PORT = 1500
RR_TYPE_KEY = 25
# Step 1
# - Device: BR_1 (DUT)
# - Description (SRP-2.5): Enable: switch on.
print("Step 1: BR_1 (DUT) Enable: switch on.")
# Step 2
# - Device: Eth_1, ED_1
# - Description (SRP-2.5): Enable
print("Step 2: Eth_1, ED_1 Enable.")
# Step 3
# - Device: BR_1 (DUT)
# - Description (SRP-2.5): Automatically adds SRP Server information in the Thread Network Data; and
# configures OMR prefix.
print("Step 3: BR_1 (DUT) Automatically adds SRP Server information in the Thread Network Data.")
pkts.\
filter_mle_cmd(consts.MLE_DATA_RESPONSE).\
filter(lambda p: 93 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.5): Harness instructs the device to send SRP Update to the DUT with service
# KEY records enabled.
print("Step 4: ED_1 sends SRP Update to the DUT with service KEY records enabled.")
pkts.\
filter_ipv6_dst(BR_1_MLEID).\
filter_ipv6_src(ED_1_MLEID).\
filter(lambda p: p.udp.dstport == br1_srp_port).\
filter(lambda p: p.dns.flags.opcode == 5).\
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)).\
filter(lambda p: verify_utils.as_list(p.dns.resp.type).count(RR_TYPE_KEY) >= 2).\
must_next()
# Step 5
# - Device: BR_1 (DUT)
# - Description (SRP-2.5): Automatically sends success SRP Update Response.
print("Step 5: BR_1 (DUT) Automatically sends success 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.5): Harness instructs the device to unicast DNS QType=PTR query to the DUT for
# all services of type _thread-test._udp.local..
print("Step 6: ED_1 unicast DNS QType=PTR query to the DUT.")
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: DNS_QUERY_NAME in verify_utils.as_list(p.dns.qry.name)).\
must_next()
# Step 7
# - Device: BR_1 (DUT)
# - Description (SRP-2.5): Automatically sends DNS response.
print("Step 7: BR_1 (DUT) Automatically sends DNS response.")
# The DNS Response MUST NOT contain any RRType=KEY records.
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.ptr.domain_name)).\
filter(lambda p: RR_TYPE_KEY not in verify_utils.as_list(p.dns.resp.type)).\
must_next()
# Step 8
# - Device: Eth_1
# - Description (SRP-2.5): Harness instructs the device to send mDNS QType=PTR query for services of
# type _thread-test._udp.local.
print("Step 8: Eth_1 send mDNS QType=PTR query.")
pkts.\
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 9
# - Device: BR_1 (DUT)
# - Description (SRP-2.5): Automatically sends mDNS Response.
print("Step 9: BR_1 (DUT) Automatically sends mDNS Response.")
# The DNS Response MUST NOT contain any RRType=KEY records.
pkts.\
filter(lambda p: p.udp.srcport == 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)).\
filter(lambda p: RR_TYPE_KEY not in verify_utils.as_list(p.mdns.resp.type)).\
must_next()
# Step 10
# - Device: N/A
# - Description (SRP-2.5): Repeat Steps 4 through 9 with KEY record omitted from Service Description
# Instruction.
print("Step 10: Repeat Steps 4 through 9 with KEY record omitted from Service Description Instruction.")
# Step 10.4
print("Step 10.4: ED_1 sends SRP Update with service KEY record disabled.")
pkts.\
filter_ipv6_dst(BR_1_MLEID).\
filter_ipv6_src(ED_1_MLEID).\
filter(lambda p: p.udp.dstport == br1_srp_port).\
filter(lambda p: p.dns.flags.opcode == 5).\
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: verify_utils.as_list(p.dns.resp.type).count(RR_TYPE_KEY) == 1).\
must_next()
# Step 10.5
print("Step 10.5: BR_1 (DUT) Automatically sends success 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 10.6
print("Step 10.6: ED_1 unicast DNS QType=PTR query.")
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: DNS_QUERY_NAME in verify_utils.as_list(p.dns.qry.name)).\
must_next()
# Step 10.7
print("Step 10.7: BR_1 (DUT) Automatically 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.ptr.domain_name)).\
filter(lambda p: RR_TYPE_KEY not in verify_utils.as_list(p.dns.resp.type)).\
must_next()
# Step 10.8
print("Step 10.8: Eth_1 send mDNS QType=PTR query.")
pkts.\
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 10.9
print("Step 10.9: BR_1 (DUT) Automatically sends mDNS Response.")
pkts.\
filter(lambda p: p.udp.srcport == 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)).\
filter(lambda p: RR_TYPE_KEY not in verify_utils.as_list(p.mdns.resp.type)).\
must_next()
# Step 11
# - Device: ED_1
# - Description (SRP-2.5): Repeat Step 4 with service KEY records omitted, while keeping host KEY
# records.
print("Step 11: Repeat Step 4 with service KEY records omitted.")
pkts.\
filter_ipv6_dst(BR_1_MLEID).\
filter_ipv6_src(ED_1_MLEID).\
filter(lambda p: p.udp.dstport == br1_srp_port).\
filter(lambda p: p.dns.flags.opcode == 5).\
filter(lambda p: SRP_INSTANCE_NAME in verify_utils.as_list(p.dns.resp.name)).\
filter(lambda p: verify_utils.as_list(p.dns.resp.type).count(RR_TYPE_KEY) == 1).\
must_next()
# Step 12
# - Device: BR_1 (DUT)
# - Description (SRP-2.5): Automatically sends success SRP Update Response.
print("Step 12: BR_1 (DUT) Automatically sends success 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: ED_1
# - Description (SRP-2.5): Repeat Step 4 with all KEY records omitted.
print("Step 13: ED_1 Repeat Step 4 with all KEY records omitted.")
pkts.\
filter_ipv6_dst(BR_1_MLEID).\
filter_ipv6_src(ED_1_MLEID).\
filter(lambda p: p.udp.dstport == br1_srp_port).\
filter(lambda p: p.dns.flags.opcode == 5).\
filter(lambda p: SRP_INSTANCE_NAME in verify_utils.as_list(p.dns.resp.name)).\
filter(lambda p: RR_TYPE_KEY not in verify_utils.as_list(p.dns.resp.type)).\
must_next()
# Step 14
# - Device: BR_1 (DUT)
# - Description (SRP-2.5): Automatically responds with error SRP Update Response.
print("Step 14: BR_1 (DUT) Automatically responds with error 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 == 5).\
must_next()
if __name__ == '__main__':
verify_utils.run_main(verify)