diff --git a/include/fastdds/rtps/transport/TCPv4TransportDescriptor.h b/include/fastdds/rtps/transport/TCPv4TransportDescriptor.h index 7af8491166a..f6f3c8e2c4f 100644 --- a/include/fastdds/rtps/transport/TCPv4TransportDescriptor.h +++ b/include/fastdds/rtps/transport/TCPv4TransportDescriptor.h @@ -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(wan_addr[0]) << "." + << static_cast(wan_addr[1]) << "." + << static_cast(wan_addr[2]) << "." + << static_cast(wan_addr[3]); + return ss.str(); + } + //! Constructor RTPS_DllAPI TCPv4TransportDescriptor(); diff --git a/test/blackbox/common/BlackboxTestsTransportTCP.cpp b/test/blackbox/common/BlackboxTestsTransportTCP.cpp index f104dbd22e3..2bc09611160 100644 --- a/test/blackbox/common/BlackboxTestsTransportTCP.cpp +++ b/test/blackbox/common/BlackboxTestsTransportTCP.cpp @@ -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) { diff --git a/versions.md b/versions.md index 87c47b550c8..2c9fb7b1517 100644 --- a/versions.md +++ b/versions.md @@ -1,6 +1,8 @@ Forthcoming ----------- +* Added API get the WAN address of TCPv4 transport descriptors (API extension) + Version 2.7.1 -------------