[nat64] update Mapping::ToString() to include translated ports (#11886)

When `OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` is enabled,
multiple `Mapping` entries can exist for the same IPv6 and IPv4
addresses, differing only by their protocol ports.

To distinguish between these entries in logs and diagnostics, this
change updates `Mapping::ToString()` to include the source and
translated port numbers in the generated string output.
This commit is contained in:
Abtin Keshavarzian
2025-09-02 08:05:22 -07:00
committed by GitHub
parent aeba105a6f
commit fcfe442082
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -348,7 +348,12 @@ Translator::Mapping::InfoString Translator::Mapping::ToString(void) const
{
InfoString string;
#if OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE
string.Append("%s,%u -> %s,%u", mIp6Address.ToString().AsCString(), mSrcPortOrId,
mIp4Address.ToString().AsCString(), mTranslatedPortOrId);
#else
string.Append("%s -> %s", mIp6Address.ToString().AsCString(), mIp4Address.ToString().AsCString());
#endif
return string;
}
+1 -1
View File
@@ -323,7 +323,7 @@ private:
struct Mapping : public InstanceLocatorInit, public LinkedListEntry<Mapping>
{
static constexpr uint16_t kInfoStringSize = 70;
static constexpr uint16_t kInfoStringSize = 80;
typedef String<kInfoStringSize> InfoString;