[nexus] add helpers for sending and validating ICMPv6 echo exchange (#12408)

This commit adds helper methods in Nexus to simplify ICMPv6 echo
exchanges:
- `Node::SendEchoRequest()`: sends an ICMPv6 Echo Request with
  configurable parameters such as payload size and hop limit.
- `Core::SendAndVerifyEchoRequest()`: sends an Echo Request and
  validates the matching Echo Reply within a timeout.

This commit also update various certification tests to use these
helpers, removing duplicate local utility functions.
This commit is contained in:
Abtin Keshavarzian
2026-02-10 16:57:48 -08:00
committed by GitHub
parent 348b2f671e
commit b347195b15
12 changed files with 132 additions and 231 deletions
+22
View File
@@ -103,6 +103,28 @@ void Node::AllowList(Node &aNode)
void Node::UnallowList(Node &aNode) { Get<Mac::Filter>().RemoveAddress(aNode.Get<Mac::Mac>().GetExtAddress()); }
void Node::SendEchoRequest(const Ip6::Address &aDestination,
uint16_t aIdentifier,
uint16_t aPayloadSize,
uint8_t aHopLimit)
{
Message *message;
Ip6::MessageInfo messageInfo;
message = Get<Ip6::Icmp>().NewMessage();
VerifyOrQuit(message != nullptr);
SuccessOrQuit(message->SetLength(aPayloadSize));
messageInfo.SetPeerAddr(aDestination);
messageInfo.SetHopLimit(aHopLimit);
Log("Sending Echo Request from Node %lu (%s) to %s (payload-size:%u)", ToUlong(GetId()), GetName(),
aDestination.ToString().AsCString(), aPayloadSize);
SuccessOrQuit(Get<Ip6::Icmp>().SendEchoRequest(*message, messageInfo, aIdentifier));
}
void Node::SetName(const char *aPrefix, uint16_t aIndex) { mName.Clear().Append("%s %u", aPrefix, aIndex); }
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE