[nexus] add test 9.2.1 Commissioner - MGMT_COMMISSIONER_GET (#12510)

This commit adds a new Nexus test case for 'Commissioner -
MGMT_COMMISSIONER_GET.req & rsp' (9.2.1) as specified in the Thread
test specification.

Summary of changes:
- Implemented Nexus test 9.2.1:
    - Added tests/nexus/test_9_2_1.cpp: Implements the test execution
      for both Topology A (DUT as Leader) and Topology B (DUT as
      Commissioner). The test verifies that MGMT_COMMISSIONER_GET
      requests can retrieve the entire Commissioner Dataset or specific
      TLVs.
    - Added tests/nexus/verify_9_2_1.py: PCAP verification script.
      Uses custom monkey-patching to correctly parse and verify MeshCoP
      TLVs within CoAP payloads.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 9_2_1 in the
      default list and handle its A/B topologies.
This commit is contained in:
Jonathan Hui
2026-02-20 11:38:40 -06:00
committed by GitHub
parent 382e486c65
commit 525d9e6250
4 changed files with 602 additions and 1 deletions
+1
View File
@@ -185,6 +185,7 @@ ot_nexus_test(6_6_2 "cert;nexus")
ot_nexus_test(7_1_1 "cert;nexus")
ot_nexus_test(7_1_2 "cert;nexus")
ot_nexus_test(7_1_3 "cert;nexus")
ot_nexus_test(9_2_1 "cert;nexus")
# Misc tests
ot_nexus_test(border_admitter "core;nexus")
+2 -1
View File
@@ -121,6 +121,7 @@ DEFAULT_TESTS=(
"7_1_1"
"7_1_2"
"7_1_3"
"9_2_1"
)
# Use provided arguments or the default test list
@@ -210,7 +211,7 @@ run_test()
expanded_tests=()
for t in "${TESTS_TO_RUN[@]}"; do
case "$t" in
6_1_1 | 6_1_2 | 6_1_3 | 6_1_6 | 6_2_1 | 6_2_2 | 6_3_1 | 6_3_2 | 6_4_1 | 6_4_2 | 6_5_1 | 6_5_2 | 6_5_3 | 6_6_1 | 6_6_2)
6_1_1 | 6_1_2 | 6_1_3 | 6_1_6 | 6_2_1 | 6_2_2 | 6_3_1 | 6_3_2 | 6_4_1 | 6_4_2 | 6_5_1 | 6_5_2 | 6_5_3 | 6_6_1 | 6_6_2 | 9_2_1)
expanded_tests+=("${t}_A" "${t}_B")
;;
*)
+330
View File
@@ -0,0 +1,330 @@
/*
* 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 "meshcop/commissioner.hpp"
#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 kJoinTime = 10 * 1000;
/**
* Time to advance for a commissioner to become active, in milliseconds.
*/
static constexpr uint32_t kPetitionTime = 5 * 1000;
/**
* Time to wait for a response, in milliseconds.
*/
static constexpr uint32_t kResponseTime = 1000;
/**
* Time to wait for ICMPv6 Echo response, in milliseconds.
*/
static constexpr uint32_t kEchoTimeout = 5000;
enum Topology
{
kTopologyA,
kTopologyB,
};
void RunTest9_2_1(Topology aTopology, const char *aJsonFile)
{
/**
* 9.2.1 Commissioner MGMT_COMMISSIONER_GET.req & rsp
*
* 9.2.1.1 Topology
* - Topology A: DUT as Leader, Commissioner (Non-DUT)
* - Topology B: Leader (Non-DUT), DUT as Commissioner
*
* 9.2.1.2 Purpose & Description
* - DUT as Leader (Topology A): The purpose of this test case is to verify Leaders behavior when receiving
* MGMT_COMMISSIONER_GET.req direct from the active Commissioner.
* - DUT as Commissioner (Topology B): The purpose of this test case is to verify that the active Commissioner can
* read Commissioner Dataset parameters direct from the Leader using MGMT_COMMISSIONER_GET.req command.
*
* Spec Reference | V1.1 Section | V1.3.0 Section
* ----------------------------------|--------------|---------------
* Updating the Commissioner Dataset | 8.7.3 | 8.7.3
*/
Core nexus;
Node &leader = nexus.CreateNode();
Node &commissioner = nexus.CreateNode();
leader.SetName("LEADER");
commissioner.SetName("COMMISSIONER");
Node &dut = (aTopology == kTopologyA) ? leader : commissioner;
nexus.AdvanceTime(0);
Instance::SetLogLevel(kLogLevelNote);
Log("---------------------------------------------------------------------------------------");
Log("Step 1: All");
/**
* Step 1: All
* - Description: Ensure topology is formed correctly.
* - Pass Criteria: N/A.
*/
leader.AllowList(commissioner);
commissioner.AllowList(leader);
leader.Form();
nexus.AdvanceTime(kFormNetworkTime);
VerifyOrQuit(leader.Get<Mle::Mle>().IsLeader());
commissioner.Join(leader);
nexus.AdvanceTime(kJoinTime);
VerifyOrQuit(commissioner.Get<Mle::Mle>().IsAttached());
SuccessOrQuit(commissioner.Get<MeshCoP::Commissioner>().Start(nullptr, nullptr, nullptr));
nexus.AdvanceTime(kPetitionTime);
VerifyOrQuit(commissioner.Get<MeshCoP::Commissioner>().IsActive());
Log("---------------------------------------------------------------------------------------");
Log("Step 2: Topology B Commissioner DUT / Topology A Leader DUT");
/**
* Step 2: Topology B Commissioner DUT / Topology A Leader DUT
* - Description:
* - Topology B: User instructs DUT to send MGMT_COMMISSIONER_GET.req to Leader.
* - Topology A: Harness instructs Commissioner to send MGMT_COMMISSIONER_GET.req to DUTs Anycast or Routing
* Locator.
* - Pass Criteria:
* - Topology B: Verify MGMT_COMMISSIONER_GET.req frame has the following format:
* - CoAP Request URI: coap://[<L>]:MM/c/cg
* - CoAP Payload: <empty> - get all Commissioner Dataset parameters
* - Verify Destination Address of MGMT_COMMISSIONER_GET.req frame is DUTs Anycast or Routing Locator (ALOC or
* RLOC):
* - ALOC: Mesh Local prefix with an IID of 0000:00FF:FE00:FC00.
* - RLOC: Mesh Local prefix with and IID of 0000:00FF:FE00:xxxx where xxxx is a 16-bit value that embeds the
* Router ID.
* - Topology A: CoAP Request URI: coap://[<L>]:MM/c/cg. CoAP Payload: <empty> - get all Commissioner Dataset
* parameters.
*/
SuccessOrQuit(commissioner.Get<MeshCoP::Commissioner>().SendMgmtCommissionerGetRequest(nullptr, 0));
nexus.AdvanceTime(kResponseTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 3: Leader");
/**
* Step 3: Leader
* - Description: Automatically sends MGMT_COMMISSIONER_GET.rsp to Commissioner.
* - Pass Criteria: For DUT = Leader: The DUT MUST send MGMT_COMMISSIONER_GET.rsp to the Commissioner with the
* following format:
* - CoAP Response Code: 2.04 Changed
* - CoAP Payload: (entire Commissioner Dataset)
* - Border Agent Locator TLV
* - Commissioner Session ID TLV
* - Steering Data TLV.
*/
Log("---------------------------------------------------------------------------------------");
Log("Step 4: Topology B Commissioner DUT / Topology A Leader DUT");
/**
* Step 4: Topology B Commissioner DUT / Topology A Leader DUT
* - Description:
* - Topology B: User instructs DUT to send MGMT_COMMISSIONER_GET.req to Leader.
* - Topology A: Harness instructs Commissioner to send MGMT_COMMISSIONER_GET.req to DUTs Anycast or Routing
* Locator.
* - Pass Criteria:
* - Topology B: Verify MGMT_COMMISSIONER_GET.req frame has the following format:
* - CoAP Request URI: coap://[<L>]:MM/c/cg
* - CoAP Payload: Get TLV specifying: Commissioner Session ID TLV, Steering Data TLV
* - Verify Destination Address of MGMT_COMMISSIONER_GET.req frame is DUTs Anycast or Routing Locator (ALOC or
* RLOC):
* - ALOC: Mesh Local prefix with an IID of 0000:00FF:FE00:FC00.
* - RLOC: Mesh Local prefix with and IID of 0000:00FF:FE00:xxxx where xxxx is a 16-bit value that embeds the
* Router ID.
* - Topology A: CoAP Request URI: coap://[<L>]:MM/c/cg. CoAP Payload: Get TLV specifying: Commissioner Session ID
* TLV, Steering Data TLV.
*/
{
uint8_t tlvs[] = {MeshCoP::Tlv::kCommissionerSessionId, MeshCoP::Tlv::kSteeringData};
SuccessOrQuit(commissioner.Get<MeshCoP::Commissioner>().SendMgmtCommissionerGetRequest(tlvs, sizeof(tlvs)));
}
nexus.AdvanceTime(kResponseTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 5: Leader");
/**
* Step 5: Leader
* - Description: Automatically sends MGMT_COMMISSIONER_GET.rsp to the Commissioner.
* - Pass Criteria: For DUT = Leader: The DUT MUST send MGMT_COMMISSIONER_GET.rsp to the Commissioner with the
* following format:
* - CoAP Response Code: 2.04 Changed
* - CoAP Payload: Encoded values for the requested Commissioner Dataset parameters:
* - Commissioner Session ID TLV
* - Steering Data TLV.
*/
Log("---------------------------------------------------------------------------------------");
Log("Step 6: Topology B Commissioner DUT / Topology A Leader DUT");
/**
* Step 6: Topology B Commissioner DUT / Topology A Leader DUT
* - Description:
* - Topology B: User instructs Commissioner DUT to send MGMT_COMMISSIONER_GET.req to Leader.
* - Topology A: Harness instructs Commissioner to send MGMT_COMMISSIONER_GET.req to DUTs Anycast or Routing
* Locator.
* - Pass Criteria:
* - Topology B: Verify MGMT_COMMISSIONER_GET.req frame has the following format:
* - CoAP Request URI: coap://[<L>]:MM/c/cg
* - CoAP Payload: Get TLV specifying: Commissioner Session ID TLV (parameter in Commissioner Dataset), PAN ID
* TLV (parameter not in Commissioner Dataset)
* - Verify Destination Address of MGMT_COMMISSIONER_GET.req frame is DUTs Anycast or Routing Locator (ALOC or
* RLOC).
* - Topology A: CoAP Request URI: coap://[<L>]:MM/c/cg. CoAP Payload: Get TLV specifying: Commissioner Session ID
* TLV (parameter in Commissioner Dataset), PAN ID TLV (parameter not in Commissioner Dataset).
*/
{
uint8_t tlvs[] = {MeshCoP::Tlv::kCommissionerSessionId, MeshCoP::Tlv::kPanId};
SuccessOrQuit(commissioner.Get<MeshCoP::Commissioner>().SendMgmtCommissionerGetRequest(tlvs, sizeof(tlvs)));
}
nexus.AdvanceTime(kResponseTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 7: Leader");
/**
* Step 7: Leader
* - Description: Automatically sends MGMT_COMMISSIONER_GET.rsp to the Commissioner.
* - Pass Criteria: For DUT = Leader: The DUT MUST send MGMT_COMMISSIONER_GET.rsp to the Commissioner with the
* following format:
* - CoAP Response Code: 2.04 Changed
* - CoAP Payload: Encoded value for the requested Commissioner Dataset parameters:
* - Commissioner Session ID TLV
* - (PAN ID TLV in Get TLV is ignored).
*/
Log("---------------------------------------------------------------------------------------");
Log("Step 8: Topology B Commissioner DUT / Topology A Leader DUT");
/**
* Step 8: Topology B Commissioner DUT / Topology A Leader DUT
* - Description:
* - Topology B: User instructs Commissioner DUT to send MGMT_COMMISSIONER_GET.req to Leader.
* - Topology A: Harness instructs Commissioner to send MGMT_COMMISSIONER_GET.req to DUTs Anycast or Routing
* Locator.
* - Pass Criteria:
* - Topology B: Verify MGMT_COMMISSIONER_GET.req frame has the following format:
* - CoAP Request URI: coap://[<L>]:MM/c/cg
* - CoAP Payload: Get TLV specifying: Border Agent Locator TLV, Network Name TLV
* - Verify Destination Address of MGMT_COMMISSIONER_GET.req frame is DUTs Anycast OR Routing Locator (ALOC or
* RLOC).
* - Topology A: CoAP Request URI: coap://[<L>]:MM/c/cg. CoAP Payload: Get TLV specifying: Border Agent Locator
* TLV, Network Name TLV.
*/
{
uint8_t tlvs[] = {MeshCoP::Tlv::kBorderAgentLocator, MeshCoP::Tlv::kNetworkName};
SuccessOrQuit(commissioner.Get<MeshCoP::Commissioner>().SendMgmtCommissionerGetRequest(tlvs, sizeof(tlvs)));
}
nexus.AdvanceTime(kResponseTime);
Log("---------------------------------------------------------------------------------------");
Log("Step 9: Leader");
/**
* Step 9: Leader
* - Description: Automatically sends MGMT_COMMISSIONER_GET.rsp to the Commissioner.
* - Pass Criteria: For DUT = Leader: The DUT MUST send MGMT_COMMISSIONER_GET.rsp to the Commissioner with the
* following format:
* - CoAP Response Code: 2.04 Changed
* - CoAP Payload: Encoded value for the requested Commissioner Dataset parameters:
* - Border Agent Locator TLV
* - (Network Name TLV is ignored).
*/
Log("---------------------------------------------------------------------------------------");
Log("Step 10: All");
/**
* Step 10: All
* - Description: Verify connectivity by sending an ICMPv6 Echo Request to the DUT mesh local address.
* - Pass Criteria: The DUT MUST respond with an ICMPv6 Echo Reply.
*/
nexus.SendAndVerifyEchoRequest(aTopology == kTopologyA ? commissioner : leader,
dut.Get<Mle::Mle>().GetMeshLocalEid(), 0, 64, kEchoTimeout);
nexus.SaveTestInfo(aJsonFile);
}
} // namespace Nexus
} // namespace ot
int main(int argc, char *argv[])
{
if (argc < 2)
{
ot::Nexus::RunTest9_2_1(ot::Nexus::kTopologyA, "test_9_2_1_A.json");
ot::Nexus::RunTest9_2_1(ot::Nexus::kTopologyB, "test_9_2_1_B.json");
}
else if (strcmp(argv[1], "A") == 0)
{
ot::Nexus::RunTest9_2_1(ot::Nexus::kTopologyA, (argc > 2) ? argv[2] : "test_9_2_1_A.json");
}
else if (strcmp(argv[1], "B") == 0)
{
ot::Nexus::RunTest9_2_1(ot::Nexus::kTopologyB, (argc > 2) ? argv[2] : "test_9_2_1_B.json");
}
else
{
fprintf(stderr, "Error: Invalid topology '%s'. Must be 'A' or 'B'.\n", argv[1]);
return 1;
}
printf("All tests passed\n");
return 0;
}
+269
View File
@@ -0,0 +1,269 @@
#!/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.null_field import nullField
# Monkey-patch CoapTlvParser to parse MeshCoP TLVs in CoAP payload
def meshcop_coap_tlv_parse(t, v):
kvs = []
if t == consts.NM_COMMISSIONER_SESSION_ID_TLV:
kvs.append(('commissioner_session_id', str(struct.unpack('>H', v)[0])))
elif t == consts.NM_STEERING_DATA_TLV:
kvs.append(('steering_data', v.hex()))
elif t == consts.NM_BORDER_AGENT_LOCATOR_TLV:
kvs.append(('border_agent_locator', str(struct.unpack('>H', v)[0])))
elif t == consts.TLV_REQUEST_TLV:
kvs.append(('tlv_request', v.hex()))
return kvs
def verify(pv):
# 9.2.1 Commissioner MGMT_COMMISSIONER_GET.req & rsp
#
# 9.2.1.1 Topology
# - Topology A: DUT as Leader, Commissioner (Non-DUT)
# - Topology B: Leader (Non-DUT), DUT as Commissioner
#
# 9.2.1.2 Purpose & Description
# - DUT as Leader (Topology A): The purpose of this test case is to verify Leaders behavior when receiving
# MGMT_COMMISSIONER_GET.req direct from the active Commissioner.
# - DUT as Commissioner (Topology B): The purpose of this test case is to verify that the active Commissioner can
# read Commissioner Dataset parameters direct from the Leader using MGMT_COMMISSIONER_GET.req command.
#
# Spec Reference | V1.1 Section | V1.3.0 Section
# ----------------------------------|--------------|---------------
# Updating the Commissioner Dataset | 8.7.3 | 8.7.3
# Add MeshCoP TLVs to CoapTlvParser
old_parse = verify_utils.CoapTlvParser.parse
from pktverify import layer_fields
layer_fields._LAYER_FIELDS['coap.tlv.tlv_request'] = layer_fields._bytes
def new_parse(t, v):
if t in (consts.NM_COMMISSIONER_SESSION_ID_TLV, consts.NM_STEERING_DATA_TLV,
consts.NM_BORDER_AGENT_LOCATOR_TLV, consts.TLV_REQUEST_TLV):
return meshcop_coap_tlv_parse(t, v)
return old_parse(t, v)
verify_utils.CoapTlvParser.parse = staticmethod(new_parse)
pkts = pv.pkts
pv.summary.show()
LEADER = pv.vars['LEADER']
COMMISSIONER = pv.vars['COMMISSIONER']
# Step 1: All
# - Description: Ensure topology is formed correctly.
# - Pass Criteria: N/A.
print("Step 1: Ensure topology is formed correctly.")
# Step 2: Topology B Commissioner DUT / Topology A Leader DUT
# - Description:
# - Topology B: User instructs DUT to send MGMT_COMMISSIONER_GET.req to Leader.
# - Topology A: Harness instructs Commissioner to send MGMT_COMMISSIONER_GET.req to DUTs Anycast or Routing
# Locator.
# - Pass Criteria:
# - Topology B: Verify MGMT_COMMISSIONER_GET.req frame has the following format:
# - CoAP Request URI: coap://[<L>]:MM/c/cg
# - CoAP Payload: <empty> - get all Commissioner Dataset parameters
# - Verify Destination Address of MGMT_COMMISSIONER_GET.req frame is DUTs Anycast or Routing Locator (ALOC or
# RLOC):
# - ALOC: Mesh Local prefix with an IID of 0000:00FF:FE00:FC00.
# - RLOC: Mesh Local prefix with and IID of 0000:00FF:FE00:xxxx where xxxx is a 16-bit value that embeds the
# Router ID.
# - Topology A: CoAP Request URI: coap://[<L>]:MM/c/cg. CoAP Payload: <empty> - get all Commissioner Dataset
# parameters.
print("Step 2: Commissioner sends MGMT_COMMISSIONER_GET.req with empty payload.")
pkts.filter_coap_request(consts.MGMT_COMMISSIONER_GET_URI).\
filter(lambda p: p.coap.payload is nullField).\
must_next()
# Step 3: Leader
# - Description: Automatically sends MGMT_COMMISSIONER_GET.rsp to Commissioner.
# - Pass Criteria: For DUT = Leader: The DUT MUST send MGMT_COMMISSIONER_GET.rsp to the Commissioner with the
# following format:
# - CoAP Response Code: 2.04 Changed
# - CoAP Payload: (entire Commissioner Dataset)
# - Border Agent Locator TLV
# - Commissioner Session ID TLV
# - Steering Data TLV.
print("Step 3: Leader sends MGMT_COMMISSIONER_GET.rsp with entire Commissioner Dataset.")
pkts.filter_coap_ack(consts.MGMT_COMMISSIONER_GET_URI).\
filter(lambda p: {
consts.NM_BORDER_AGENT_LOCATOR_TLV,
consts.NM_COMMISSIONER_SESSION_ID_TLV,
consts.NM_STEERING_DATA_TLV
} <= set(p.coap.tlv.type)).\
must_next()
# Step 4: Topology B Commissioner DUT / Topology A Leader DUT
# - Description:
# - Topology B: User instructs DUT to send MGMT_COMMISSIONER_GET.req to Leader.
# - Topology A: Harness instructs Commissioner to send MGMT_COMMISSIONER_GET.req to DUTs Anycast or Routing
# Locator.
# - Pass Criteria:
# - Topology B: Verify MGMT_COMMISSIONER_GET.req frame has the following format:
# - CoAP Request URI: coap://[<L>]:MM/c/cg
# - CoAP Payload: Get TLV specifying: Commissioner Session ID TLV, Steering Data TLV
# - Verify Destination Address of MGMT_COMMISSIONER_GET.req frame is DUTs Anycast or Routing Locator (ALOC or
# RLOC):
# - ALOC: Mesh Local prefix with an IID of 0000:00FF:FE00:FC00.
# - RLOC: Mesh Local prefix with and IID of 0000:00FF:FE00:xxxx where xxxx is a 16-bit value that embeds the
# Router ID.
# - Topology A: CoAP Request URI: coap://[<L>]:MM/c/cg. CoAP Payload: Get TLV specifying: Commissioner Session ID
# TLV, Steering Data TLV.
print("Step 4: Commissioner sends MGMT_COMMISSIONER_GET.req with Get TLV (Session ID, Steering Data).")
pkts.filter_coap_request(consts.MGMT_COMMISSIONER_GET_URI).\
filter(lambda p: consts.TLV_REQUEST_TLV in p.coap.tlv.type and\
p.coap.tlv.tlv_request == bytes([consts.NM_COMMISSIONER_SESSION_ID_TLV, consts.NM_STEERING_DATA_TLV]).hex()).\
must_next()
# Step 5: Leader
# - Description: Automatically sends MGMT_COMMISSIONER_GET.rsp to the Commissioner.
# - Pass Criteria: For DUT = Leader: The DUT MUST send MGMT_COMMISSIONER_GET.rsp to the Commissioner with the
# following format:
# - CoAP Response Code: 2.04 Changed
# - CoAP Payload: Encoded values for the requested Commissioner Dataset parameters:
# - Commissioner Session ID TLV
# - Steering Data TLV.
print("Step 5: Leader sends MGMT_COMMISSIONER_GET.rsp with Session ID and Steering Data.")
pkts.filter_coap_ack(consts.MGMT_COMMISSIONER_GET_URI).\
filter(lambda p: {
consts.NM_COMMISSIONER_SESSION_ID_TLV,
consts.NM_STEERING_DATA_TLV
} <= set(p.coap.tlv.type)).\
must_next()
# Step 6: Topology B Commissioner DUT / Topology A Leader DUT
# - Description:
# - Topology B: User instructs Commissioner DUT to send MGMT_COMMISSIONER_GET.req to Leader.
# - Topology A: Harness instructs Commissioner to send MGMT_COMMISSIONER_GET.req to DUTs Anycast or Routing
# Locator.
# - Pass Criteria:
# - Topology B: Verify MGMT_COMMISSIONER_GET.req frame has the following format:
# - CoAP Request URI: coap://[<L>]:MM/c/cg
# - CoAP Payload: Get TLV specifying: Commissioner Session ID TLV (parameter in Commissioner Dataset), PAN ID
# TLV (parameter not in Commissioner Dataset)
# - Verify Destination Address of MGMT_COMMISSIONER_GET.req frame is DUTs Anycast or Routing Locator (ALOC or
# RLOC).
# - Topology A: CoAP Request URI: coap://[<L>]:MM/c/cg. CoAP Payload: Get TLV specifying: Commissioner Session ID
# TLV (parameter in Commissioner Dataset), PAN ID TLV (parameter not in Commissioner Dataset).
print("Step 6: Commissioner sends MGMT_COMMISSIONER_GET.req with Get TLV (Session ID, PAN ID).")
pkts.filter_coap_request(consts.MGMT_COMMISSIONER_GET_URI).\
filter(lambda p: consts.TLV_REQUEST_TLV in p.coap.tlv.type and\
p.coap.tlv.tlv_request == bytes([consts.NM_COMMISSIONER_SESSION_ID_TLV, consts.NM_PAN_ID_TLV]).hex()).\
must_next()
# Step 7: Leader
# - Description: Automatically sends MGMT_COMMISSIONER_GET.rsp to the Commissioner.
# - Pass Criteria: For DUT = Leader: The DUT MUST send MGMT_COMMISSIONER_GET.rsp to the Commissioner with the
# following format:
# - CoAP Response Code: 2.04 Changed
# - CoAP Payload: Encoded value for the requested Commissioner Dataset parameters:
# - Commissioner Session ID TLV
# - (PAN ID TLV in Get TLV is ignored).
print("Step 7: Leader sends MGMT_COMMISSIONER_GET.rsp with Session ID.")
pkts.filter_coap_ack(consts.MGMT_COMMISSIONER_GET_URI).\
filter(lambda p: set(p.coap.tlv.type) == {consts.NM_COMMISSIONER_SESSION_ID_TLV}).\
must_next()
# Step 8: Topology B Commissioner DUT / Topology A Leader DUT
# - Description:
# - Topology B: User instructs Commissioner DUT to send MGMT_COMMISSIONER_GET.req to Leader.
# - Topology A: Harness instructs Commissioner to send MGMT_COMMISSIONER_GET.req to DUTs Anycast or Routing
# Locator.
# - Pass Criteria:
# - Topology B: Verify MGMT_COMMISSIONER_GET.req frame has the following format:
# - CoAP Request URI: coap://[<L>]:MM/c/cg
# - CoAP Payload: Get TLV specifying: Border Agent Locator TLV, Network Name TLV
# - Verify Destination Address of MGMT_COMMISSIONER_GET.req frame is DUTs Anycast OR Routing Locator (ALOC or
# RLOC).
# - Topology A: CoAP Request URI: coap://[<L>]:MM/c/cg. CoAP Payload: Get TLV specifying: Border Agent Locator
# TLV, Network Name TLV.
print("Step 8: Commissioner sends MGMT_COMMISSIONER_GET.req with Get TLV (BA Locator, Network Name).")
pkts.filter_coap_request(consts.MGMT_COMMISSIONER_GET_URI).\
filter(lambda p: consts.TLV_REQUEST_TLV in p.coap.tlv.type and\
p.coap.tlv.tlv_request == bytes([consts.NM_BORDER_AGENT_LOCATOR_TLV, consts.NM_NETWORK_NAME_TLV]).hex()).\
must_next()
# Step 9: Leader
# - Description: Automatically sends MGMT_COMMISSIONER_GET.rsp to the Commissioner.
# - Pass Criteria: For DUT = Leader: The DUT MUST send MGMT_COMMISSIONER_GET.rsp to the Commissioner with the
# following format:
# - CoAP Response Code: 2.04 Changed
# - CoAP Payload: Encoded value for the requested Commissioner Dataset parameters:
# - Border Agent Locator TLV
# - (Network Name TLV is ignored).
print("Step 9: Leader sends MGMT_COMMISSIONER_GET.rsp with BA Locator.")
pkts.filter_coap_ack(consts.MGMT_COMMISSIONER_GET_URI).\
filter(lambda p: set(p.coap.tlv.type) == {consts.NM_BORDER_AGENT_LOCATOR_TLV}).\
must_next()
# Step 10: All
# - Description: Verify connectivity by sending an ICMPv6 Echo Request to the DUT mesh local address.
# - Pass Criteria: The DUT MUST respond with an ICMPv6 Echo Reply.
print("Step 10: Verify connectivity by sending an ICMPv6 Echo Request to the DUT mesh local address.")
if pv.test_info.testcase == 'test_9_2_1_A':
src_ext = COMMISSIONER
dst_addr = pv.vars['LEADER_MLEID']
else:
src_ext = LEADER
dst_addr = pv.vars['COMMISSIONER_MLEID']
_pkt = pkts.filter_ping_request().\
filter_wpan_src64(src_ext).\
filter_ipv6_dst(dst_addr).\
must_next()
if pv.test_info.testcase == 'test_9_2_1_A':
requester_addr = pv.vars['COMMISSIONER_MLEID']
else:
requester_addr = pv.vars['LEADER_MLEID']
pkts.filter_ping_reply(identifier=_pkt.icmpv6.echo.identifier).\
filter_ipv6_src(dst_addr).\
filter_ipv6_dst(requester_addr).\
must_next()
if __name__ == '__main__':
verify_utils.run_main(verify)