Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get WAN address API in TCPv4 transport descriptors #2877

Merged
merged 3 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions include/fastdds/rtps/transport/TCPv4TransportDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ struct TCPv4TransportDescriptor : public TCPTransportDescriptor
wan_addr[3] = (fastrtps::rtps::octet)d;
}

//! Get the public IP address
std::string get_WAN_address()
{
std::stringstream ss;
ss << static_cast<int>(wan_addr[0]) << "."
<< static_cast<int>(wan_addr[1]) << "."
<< static_cast<int>(wan_addr[2]) << "."
<< static_cast<int>(wan_addr[3]);
return ss.str();
}

//! Constructor
RTPS_DllAPI TCPv4TransportDescriptor();

Expand Down
9 changes: 9 additions & 0 deletions test/blackbox/common/BlackboxTestsTransportTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,15 @@ TEST_P(TransportTCP, TCPv4_copy)
EXPECT_EQ(tcpv4_transport_copy, tcpv4_transport);
}

// Test get_WAN_address member function
TEST_P(TransportTCP, TCPv4_get_WAN_address)
{
// TCPv4TransportDescriptor
TCPv4TransportDescriptor tcpv4_transport;
tcpv4_transport.set_WAN_address("80.80.99.45");
ASSERT_EQ(tcpv4_transport.get_WAN_address(), "80.80.99.45");
}

// Test == operator for TCPv6
TEST_P(TransportTCP, TCPv6_equal_operator)
{
Expand Down
2 changes: 2 additions & 0 deletions versions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Forthcoming
-----------

* Added API get the WAN address of TCPv4 transport descriptors (API extension)

Version 2.7.1
-------------

Expand Down