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
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 committed Sep 28, 2023
1 parent 59d2b7e commit d062253
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 8 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,8 @@ int main(int argc, char * argv[])
chip::DeviceLayer::PlatformMgr().RunEventLoop();

gUDPManager.Close();

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 d062253

Please sign in to comment.