[net-diag] implement non-preferred channels mask TLV support (#11367)

This commit adds support for the "non-preferred channels" TLV in
Network Diagnostics. New APIs and their related CLI commands are
added to allow users to get/set this value, which is then used to
respond to Diagnostic Get/Query messages requesting this TLV. This
commit also introduces a mechanism to monitor and notify the caller
when a Network Diagnostic Reset command is received for this TLV.

The `test-020-net-diag` test is updated to validate the new TLV and
its API.
This commit is contained in:
Abtin Keshavarzian
2025-04-01 22:06:48 -07:00
committed by GitHub
parent 7cfae1e05e
commit d2fcf539da
12 changed files with 325 additions and 98 deletions
@@ -70,6 +70,7 @@ VENDOR_SW_VERSION_TLV = 27
THREAD_STACK_VERSION_TLV = 28
MLE_COUNTERS_TLV = 34
VENDOR_APP_URL = 35
NON_PREFERRED_CHANNELS_TLV = 36
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Check setting vendor name, model, ans sw version
@@ -192,9 +193,42 @@ for line in result[1:]:
verify(False)
result = r2.cli('networkdiagnostic get', r1_rloc, MLE_COUNTERS_TLV)
print(len(result) >= 1)
verify(result[1].startswith("MLE Counters:"))
# Test Non-preferred Channels TLV
def verify_non_preferred_channels_query_result(mask):
r1.cli('networkdiagnostic nonpreferredchannels', mask)
result = r1.cli('networkdiagnostic nonpreferredchannels')
verify(len(result) == 1)
verify(int(result[0], 16) == mask)
result = r1.cli('networkdiagnostic nonpreferredchannels')
verify(len(result) == 1)
verify(int(result[0], 16) == 0)
verify_non_preferred_channels_query_result(0)
mask = 1 << 26 # channel 26
r1.cli('networkdiagnostic nonpreferredchannels', mask)
result = r1.cli('networkdiagnostic nonpreferredchannels')
verify(len(result) == 1)
verify(int(result[0], 16) == mask)
verify_non_preferred_channels_query_result(mask)
mask = 0
r1.cli('networkdiagnostic nonpreferredchannels', mask)
result = r1.cli('networkdiagnostic nonpreferredchannels')
verify(len(result) == 1)
verify(int(result[0], 16) == mask)
verify_non_preferred_channels_query_result(mask)
# -----------------------------------------------------------------------------------------------------------------------
# Test finished