Skip to content

Commit

Permalink
Fix IPAddress Type mismatch between echo-requester and echo-responder. (
Browse files Browse the repository at this point in the history
#29419)

When using TCP, the echo-server was listening over IPv4 while the
echo-requester was getting configured for IPv6.

Normalize both sides to always use IPv6 over both TCP or MRP.
  • Loading branch information
pidarped authored Sep 29, 2023
1 parent 475d927 commit 4263ced
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/messaging/tests/echo/echo_requester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ int main(int argc, char * argv[])
ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT);
}

if (gDestAddr.Type() != chip::Inet::IPAddressType::kIPv6)
{
printf("Echo Server IP address: %s is not of type IPv6\n", argv[1]);
ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT);
}

InitializeChip();

if (gUseTCP)
Expand Down Expand Up @@ -264,6 +270,11 @@ int main(int argc, char * argv[])
chip::DeviceLayer::PlatformMgr().RunEventLoop();

gUDPManager.Close();

if (gUseTCP)
{
gTCPManager.Disconnect(chip::Transport::PeerAddress::TCP(gDestAddr));
}
gTCPManager.Close();

Shutdown();
Expand Down
7 changes: 1 addition & 6 deletions src/messaging/tests/echo/echo_responder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ int main(int argc, char * argv[])
if (useTCP)
{
err = gTCPManager.Init(chip::Transport::TcpListenParameters(chip::DeviceLayer::TCPEndPointManager())
#if INET_CONFIG_ENABLE_IPV4
.SetAddressType(chip::Inet::IPAddressType::kIPv4)
#else
.SetAddressType(chip::Inet::IPAddressType::kIPv6)
#endif
);
.SetAddressType(chip::Inet::IPAddressType::kIPv6));
SuccessOrExit(err);

err = gSessionManager.Init(&chip::DeviceLayer::SystemLayer(), &gTCPManager, &gMessageCounterManager, &gStorage,
Expand Down

0 comments on commit 4263ced

Please sign in to comment.