[nat64] implement functions for NAT64 on the client side (#8126)

This commit adds the ability for accepting an IPv4 address for {ping,
tcp, udp} CLI commands.
This commit is contained in:
Song GUO
2022-09-15 08:43:36 -07:00
committed by GitHub
parent a7e0516fb2
commit 6973a1b067
13 changed files with 208 additions and 8 deletions
+10 -1
View File
@@ -39,6 +39,7 @@
#include "cli_tcp.hpp"
#include <openthread/nat64.h>
#include <openthread/tcp.h>
#include "cli/cli.hpp"
@@ -175,10 +176,18 @@ otError TcpExample::ProcessConnect(Arg aArgs[])
{
otError error;
otSockAddr sockaddr;
bool nat64SynthesizedAddress;
VerifyOrExit(mInitialized, error = OT_ERROR_INVALID_STATE);
SuccessOrExit(error = aArgs[0].ParseAsIp6Address(sockaddr.mAddress));
SuccessOrExit(
error = Interpreter::ParseToIp6Address(GetInstancePtr(), aArgs[0], sockaddr.mAddress, nat64SynthesizedAddress));
if (nat64SynthesizedAddress)
{
OutputFormat("Connecting to synthesized IPv6 address: ");
OutputIp6AddressLine(sockaddr.mAddress);
}
SuccessOrExit(error = aArgs[1].ParseAsUint16(sockaddr.mPort));
VerifyOrExit(aArgs[2].IsEmpty(), error = OT_ERROR_INVALID_ARGS);