diff --git a/include/fastdds/dds/core/policy/QosPolicies.hpp b/include/fastdds/dds/core/policy/QosPolicies.hpp index df11cd9f05f..5ac318e57db 100644 --- a/include/fastdds/dds/core/policy/QosPolicies.hpp +++ b/include/fastdds/dds/core/policy/QosPolicies.hpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h index a0010e79108..9a826b3933c 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/fastdds/rtps/common/Guid.h b/include/fastdds/rtps/common/Guid.h index 7cfb3c7ff91..b82caac24bc 100644 --- a/include/fastdds/rtps/common/Guid.h +++ b/include/fastdds/rtps/common/Guid.h @@ -78,6 +78,8 @@ struct RTPS_DllAPI GUID_t /** * Checks whether this guid is from an entity on the same host as another guid. * + * @note This method assumes the value of \c other_guid was originally assigned by Fast-DDS vendor. + * * @param other_guid GUID_t to compare to. * * @return true when this guid is on the same host, false otherwise. @@ -85,13 +87,13 @@ struct RTPS_DllAPI GUID_t bool is_on_same_host_as( const GUID_t& other_guid) const { - return memcmp(guidPrefix.value, other_guid.guidPrefix.value, 4) == 0; + return guidPrefix.is_on_same_host_as(other_guid.guidPrefix); } /** - * Checks whether this guid is from an entity created on this host (from where this method is called). + * Checks whether this guid is from a (Fast-DDS) entity created on this host (from where this method is called). * - * @return true when this guid is from an entity created on this host, false otherwise. + * @return true when this guid is from a (Fast-DDS) entity created on this host, false otherwise. */ bool is_from_this_host() const { @@ -101,6 +103,8 @@ struct RTPS_DllAPI GUID_t /** * Checks whether this guid is for an entity on the same host and process as another guid. * + * @note This method assumes the value of \c other_guid was originally assigned by Fast-DDS vendor. + * * @param other_guid GUID_t to compare to. * * @return true when this guid is on the same host and process, false otherwise. @@ -108,7 +112,17 @@ struct RTPS_DllAPI GUID_t bool is_on_same_process_as( const GUID_t& other_guid) const { - return memcmp(guidPrefix.value, other_guid.guidPrefix.value, 8) == 0; + return guidPrefix.is_on_same_process_as(other_guid.guidPrefix); + } + + /** + * Checks whether this guid is from a (Fast-DDS) entity created on this process (from where this method is called). + * + * @return true when this guid is from a (Fast-DDS) entity created on this process, false otherwise. + */ + bool is_from_this_process() const + { + return guidPrefix.is_from_this_process(); } /** diff --git a/include/fastdds/rtps/common/GuidPrefix_t.hpp b/include/fastdds/rtps/common/GuidPrefix_t.hpp index 744741e985e..b7a0be73d4e 100644 --- a/include/fastdds/rtps/common/GuidPrefix_t.hpp +++ b/include/fastdds/rtps/common/GuidPrefix_t.hpp @@ -45,12 +45,43 @@ struct RTPS_DllAPI GuidPrefix_t } /** - * Checks whether this guid prefix is from an entity created on this host (from where this method is called). + * Checks whether this guid prefix is from an entity on the same host as another guid prefix. * - * @return true when this guid prefix is from an entity created on this host, false otherwise. + * @note This method assumes the value of \c other_guid_prefix was originally assigned by Fast-DDS vendor. + * + * @param other_guid_prefix GuidPrefix_t to compare to. + * + * @return true when this guid prefix is on the same host, false otherwise. + */ + bool is_on_same_host_as( + const GuidPrefix_t& other_guid_prefix) const; + + /** + * Checks whether this guid prefix is from a (Fast-DDS) entity created on this host (from where this method is called). + * + * @return true when this guid prefix is from a (Fast-DDS) entity created on this host, false otherwise. */ bool is_from_this_host() const; + /** + * Checks whether this guid prefix is for an entity on the same host and process as another guid prefix. + * + * @note This method assumes the value of \c other_guid_prefix was originally assigned by Fast-DDS vendor. + * + * @param other_guid_prefix GuidPrefix_t to compare to. + * + * @return true when this guid prefix is on the same host and process, false otherwise. + */ + bool is_on_same_process_as( + const GuidPrefix_t& other_guid_prefix) const; + + /** + * Checks whether this guid prefix is from a (Fast-DDS) entity created on this host and process (from where this method is called). + * + * @return true when this guid prefix is from a (Fast-DDS) entity created on this host and process, false otherwise. + */ + bool is_from_this_process() const; + static GuidPrefix_t unknown() { return GuidPrefix_t(); diff --git a/include/fastdds/rtps/participant/RTPSParticipant.h b/include/fastdds/rtps/participant/RTPSParticipant.h index 06ea42d2ba9..4918f9fbcde 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.h +++ b/include/fastdds/rtps/participant/RTPSParticipant.h @@ -299,6 +299,11 @@ class RTPS_DllAPI RTPSParticipant bool ignore_reader( const GUID_t& reader_guid); + /** + * Returns registered transports' netmask filter information (transport's netmask filter kind and allowlist). + */ + std::vector netmask_filter_info() const; + #if HAVE_SECURITY /** diff --git a/include/fastdds/rtps/transport/ChainingTransport.h b/include/fastdds/rtps/transport/ChainingTransport.h index 27151c60c36..da3094ab958 100644 --- a/include/fastdds/rtps/transport/ChainingTransport.h +++ b/include/fastdds/rtps/transport/ChainingTransport.h @@ -173,7 +173,7 @@ class ChainingTransport : public TransportInterface /*! * Call the low-level transport `netmask_filter_info()`. - * Return netmask filter information (transport's netmask filter kind and allowlist) + * Returns netmask filter information (transport's netmask filter kind and allowlist) */ RTPS_DllAPI NetmaskFilterInfo netmask_filter_info() const override { diff --git a/include/fastdds/rtps/transport/SocketTransportDescriptor.h b/include/fastdds/rtps/transport/SocketTransportDescriptor.h index 80439f3ec57..80c5a3a6a19 100644 --- a/include/fastdds/rtps/transport/SocketTransportDescriptor.h +++ b/include/fastdds/rtps/transport/SocketTransportDescriptor.h @@ -19,7 +19,9 @@ #include #include -#include +#include +#include +#include #include namespace eprosima { @@ -95,9 +97,9 @@ struct SocketTransportDescriptor : public PortBasedTransportDescriptor //! Transport's netmask filter configuration. NetmaskFilterKind netmask_filter; //! Allowed interfaces in an IP or device name string format, each with a specific netmask filter configuration. - std::vector> interface_allowlist; + std::vector interface_allowlist; //! Blocked interfaces in an IP or device name string format. - std::vector interface_blocklist; + std::vector interface_blocklist; //! Specified time to live (8bit - 255 max TTL) uint8_t TTL; }; diff --git a/include/fastdds/rtps/transport/TransportDescriptorInterface.h b/include/fastdds/rtps/transport/TransportDescriptorInterface.h index 47a9fbfd609..f1b5c05cb24 100644 --- a/include/fastdds/rtps/transport/TransportDescriptorInterface.h +++ b/include/fastdds/rtps/transport/TransportDescriptorInterface.h @@ -16,6 +16,7 @@ #define _FASTDDS_TRANSPORT_DESCRIPTOR_INTERFACE_H_ #include +#include #include #include @@ -51,11 +52,20 @@ struct TransportDescriptorInterface //! Copy constructor RTPS_DllAPI TransportDescriptorInterface( - const TransportDescriptorInterface& t) = default; + const TransportDescriptorInterface& t) + : maxMessageSize(t.maxMessageSize) + , maxInitialPeersRange(t.maxInitialPeersRange) + { + } //! Copy assignment RTPS_DllAPI TransportDescriptorInterface& operator =( - const TransportDescriptorInterface& t) = default; + const TransportDescriptorInterface& t) + { + maxMessageSize = t.maxMessageSize; + maxInitialPeersRange = t.maxInitialPeersRange; + return *this; + } //! Destructor virtual RTPS_DllAPI ~TransportDescriptorInterface() = default; @@ -92,11 +102,27 @@ struct TransportDescriptorInterface this->maxInitialPeersRange == t.max_initial_peers_range()); } + //! Lock internal mutex (for Fast-DDS internal use) + RTPS_DllAPI void lock() + { + mtx_.lock(); + } + + //! Unlock internal mutex (for Fast-DDS internal use) + RTPS_DllAPI void unlock() + { + mtx_.unlock(); + } + //! Maximum size of a single message in the transport uint32_t maxMessageSize; //! Number of channels opened with each initial remote peer. uint32_t maxInitialPeersRange; + +private: + + mutable std::mutex mtx_; }; } // namespace rtps diff --git a/include/fastdds/rtps/transport/TransportInterface.h b/include/fastdds/rtps/transport/TransportInterface.h index d6f513af10d..8ff96ee76f7 100644 --- a/include/fastdds/rtps/transport/TransportInterface.h +++ b/include/fastdds/rtps/transport/TransportInterface.h @@ -24,7 +24,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -45,7 +46,8 @@ static const std::string s_IPv4AddressAny = "0.0.0.0"; static const std::string s_IPv6AddressAny = "::"; using SendResourceList = std::vector>; -using NetmaskFilterInfo = std::pair>>; +using NetmaskFilterInfo = std::pair>; +using TransportNetmaskFilterInfo = std::pair; /** * Interface against which to implement a transport layer, decoupled from FastRTPS internals. @@ -168,9 +170,9 @@ class RTPS_DllAPI TransportInterface * If there is an existing channel it registers the receiver interface. */ virtual bool OpenInputChannel( - const Locator&, - TransportReceiverInterface*, - uint32_t) = 0; + const Locator&, + TransportReceiverInterface*, + uint32_t) = 0; /** * Must close the channel that maps to/from the given locator. @@ -305,7 +307,7 @@ class RTPS_DllAPI TransportInterface return true; } - //! Return netmask filter information (transport's netmask filter kind and allowlist) + //! Returns netmask filter information (transport's netmask filter kind and allowlist) virtual NetmaskFilterInfo netmask_filter_info() const { return {NetmaskFilterKind::AUTO, {}}; diff --git a/include/fastdds/rtps/transport/network/AllowedNetworkInterface.hpp b/include/fastdds/rtps/transport/network/AllowedNetworkInterface.hpp new file mode 100644 index 00000000000..6e38eb5e26b --- /dev/null +++ b/include/fastdds/rtps/transport/network/AllowedNetworkInterface.hpp @@ -0,0 +1,63 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file AllowedNetworkInterface.hpp + */ + +#ifndef _FASTDDS_RTPS_TRANSPORT_NETWORK_ALLOWEDNETWORKINTERFACE_HPP_ +#define _FASTDDS_RTPS_TRANSPORT_NETWORK_ALLOWEDNETWORKINTERFACE_HPP_ + +#include +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { + +/** + * Structure extending \c NetworkInterfaceWithFilter with information specific to allowed interfaces. + * + * @note When using this structure to interact with Fast-DDS, \c name is the only attribute the user needs to provide. + * The rest of the attributes are internally filled, and are in fact ignored even if already provided by the user. + */ +struct RTPS_DllAPI AllowedNetworkInterface : public NetworkInterfaceWithFilter +{ + using NetworkInterfaceWithFilter::NetworkInterfaceWithFilter; + + //! Destructor + virtual ~AllowedNetworkInterface() = default; + + //! Copy constructor + AllowedNetworkInterface( + const AllowedNetworkInterface& iface) = default; + + //! Copy assignment + AllowedNetworkInterface& operator =( + const AllowedNetworkInterface& iface) = default; + + //! Move constructor + AllowedNetworkInterface( + AllowedNetworkInterface&& iface) = default; + + //! Move assignment + AllowedNetworkInterface& operator =( + AllowedNetworkInterface&& iface) = default; +}; + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima + +#endif // _FASTDDS_RTPS_TRANSPORT_NETWORK_ALLOWEDNETWORKINTERFACE_HPP_ diff --git a/include/fastdds/rtps/transport/network/BlockedNetworkInterface.hpp b/include/fastdds/rtps/transport/network/BlockedNetworkInterface.hpp new file mode 100644 index 00000000000..743fa30e84c --- /dev/null +++ b/include/fastdds/rtps/transport/network/BlockedNetworkInterface.hpp @@ -0,0 +1,63 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file BlockedNetworkInterface.hpp + */ + +#ifndef _FASTDDS_RTPS_TRANSPORT_NETWORK_BLOCKEDNETWORKINTERFACE_HPP_ +#define _FASTDDS_RTPS_TRANSPORT_NETWORK_BLOCKEDNETWORKINTERFACE_HPP_ + +#include +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { + +/** + * Structure extending \c NetworkInterface with information specific to blocked interfaces. + * + * @note When using this structure to interact with Fast-DDS, \c name is the only attribute the user needs to provide. + * The rest of the attributes are internally filled, and are in fact ignored even if already provided by the user. + */ +struct RTPS_DllAPI BlockedNetworkInterface : public NetworkInterface +{ + using NetworkInterface::NetworkInterface; + + //! Destructor + virtual ~BlockedNetworkInterface() = default; + + //! Copy constructor + BlockedNetworkInterface( + const BlockedNetworkInterface& iface) = default; + + //! Copy assignment + BlockedNetworkInterface& operator =( + const BlockedNetworkInterface& iface) = default; + + //! Move constructor + BlockedNetworkInterface( + BlockedNetworkInterface&& iface) = default; + + //! Move assignment + BlockedNetworkInterface& operator =( + BlockedNetworkInterface&& iface) = default; +}; + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima + +#endif // _FASTDDS_RTPS_TRANSPORT_NETWORK_BLOCKEDNETWORKINTERFACE_HPP_ diff --git a/include/fastdds/rtps/transport/network/NetmaskFilterKind.hpp b/include/fastdds/rtps/transport/network/NetmaskFilterKind.hpp new file mode 100644 index 00000000000..643b6123544 --- /dev/null +++ b/include/fastdds/rtps/transport/network/NetmaskFilterKind.hpp @@ -0,0 +1,45 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file NetmaskFilterKind.hpp + */ + +#ifndef _FASTDDS_RTPS_TRANSPORT_NETWORK_NETMASKFILTER_HPP_ +#define _FASTDDS_RTPS_TRANSPORT_NETWORK_NETMASKFILTER_HPP_ + +#include + +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { + +enum class NetmaskFilterKind +{ + OFF, + AUTO, + ON +}; + +std::ostream& operator <<( + std::ostream& output, + const NetmaskFilterKind& netmask_filter_kind); + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima + +#endif // _FASTDDS_RTPS_TRANSPORT_NETWORK_NETMASKFILTER_HPP_ diff --git a/include/fastdds/rtps/transport/network/NetworkInterface.hpp b/include/fastdds/rtps/transport/network/NetworkInterface.hpp new file mode 100644 index 00000000000..ab8bd02424c --- /dev/null +++ b/include/fastdds/rtps/transport/network/NetworkInterface.hpp @@ -0,0 +1,96 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file NetworkInterface.hpp + */ + +#ifndef _FASTDDS_RTPS_TRANSPORT_NETWORK_NETWORKINTERFACE_HPP_ +#define _FASTDDS_RTPS_TRANSPORT_NETWORK_NETWORKINTERFACE_HPP_ + +#include + +#include +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { + +/** + * Structure encapsulating relevant network interface information. + * + * @note When using this structure to interact with Fast-DDS, \c name is the only attribute the user needs to provide. + * The rest of the attributes are internally filled, and are in fact ignored even if already provided by the user. + */ +struct RTPS_DllAPI NetworkInterface +{ + //! Constructor by name + NetworkInterface( + const std::string& name) + : name(name) + { + } + + //! Constructor by device name and IP address + NetworkInterface( + const std::string& device, + const LocatorWithMask& locator) + : device(device) + , locator(locator) + { + } + + //! Destructor + virtual ~NetworkInterface() = default; + + //! Copy constructor + NetworkInterface( + const NetworkInterface& iface) = default; + + //! Copy assignment + NetworkInterface& operator =( + const NetworkInterface& iface) = default; + + //! Move constructor + NetworkInterface( + NetworkInterface&& iface) = default; + + //! Move assignment + NetworkInterface& operator =( + NetworkInterface&& iface) = default; + + //! Comparison operator + bool operator ==( + const NetworkInterface& iface) const + { + return (this->name == iface.name && + this->device == iface.device && + this->locator == iface.locator); + } + + //! Interface device name or IP address in string format (to be filled by the user) + std::string name; + + //! Interface device name + std::string device; + //! IP address with network mask + LocatorWithMask locator; +}; + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima + +#endif // _FASTDDS_RTPS_TRANSPORT_NETWORK_NETWORKINTERFACE_HPP_ diff --git a/include/fastdds/rtps/transport/network/NetworkInterfaceWithFilter.hpp b/include/fastdds/rtps/transport/network/NetworkInterfaceWithFilter.hpp new file mode 100644 index 00000000000..47906f099c7 --- /dev/null +++ b/include/fastdds/rtps/transport/network/NetworkInterfaceWithFilter.hpp @@ -0,0 +1,109 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file NetworkInterfaceWithFilter.hpp + */ + +#ifndef _FASTDDS_RTPS_TRANSPORT_NETWORK_NETWORKINTERFACEWITHFILTER_HPP_ +#define _FASTDDS_RTPS_TRANSPORT_NETWORK_NETWORKINTERFACEWITHFILTER_HPP_ + +#include + +#include +#include +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { + +/** + * Structure extending \c NetworkInterface with netmask filter information. + * + * @note When using this structure to interact with Fast-DDS, \c name is the only attribute the user needs to provide. + * The rest of the attributes are internally filled, and are in fact ignored even if already provided by the user. + */ +struct RTPS_DllAPI NetworkInterfaceWithFilter : public NetworkInterface +{ + //! Constructor by name and netmask filter + NetworkInterfaceWithFilter( + const std::string& name, + NetmaskFilterKind netmask_filter) + : NetworkInterface(name) + , netmask_filter(netmask_filter) + { + } + + //! Constructor by name + NetworkInterfaceWithFilter( + const std::string& name) + : NetworkInterfaceWithFilter(name, NetmaskFilterKind::AUTO) + { + } + + //! Constructor by device name, IP address and netmask filter + NetworkInterfaceWithFilter( + const std::string& device, + const LocatorWithMask& locator, + NetmaskFilterKind netmask_filter) + : NetworkInterface(device, locator) + , netmask_filter(netmask_filter) + { + } + + //! Constructor by device name and IP address + NetworkInterfaceWithFilter( + const std::string& device, + const LocatorWithMask& locator) + : NetworkInterfaceWithFilter(device, locator, NetmaskFilterKind::AUTO) + { + } + + //! Destructor + virtual ~NetworkInterfaceWithFilter() = default; + + //! Copy constructor + NetworkInterfaceWithFilter( + const NetworkInterfaceWithFilter& iface) = default; + + //! Copy assignment + NetworkInterfaceWithFilter& operator =( + const NetworkInterfaceWithFilter& iface) = default; + + //! Move constructor + NetworkInterfaceWithFilter( + NetworkInterfaceWithFilter&& iface) = default; + + //! Move assignment + NetworkInterfaceWithFilter& operator =( + NetworkInterfaceWithFilter&& iface) = default; + + //! Comparison operator + bool operator ==( + const NetworkInterfaceWithFilter& iface) const + { + return (this->netmask_filter == iface.netmask_filter && + NetworkInterface::operator ==(iface)); + } + + //! Netmask filter configuration + NetmaskFilterKind netmask_filter; +}; + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima + +#endif // _FASTDDS_RTPS_TRANSPORT_NETWORK_NETWORKINTERFACEWITHFILTER_HPP_ diff --git a/include/fastrtps/utils/collections/ResourceLimitedVector.hpp b/include/fastrtps/utils/collections/ResourceLimitedVector.hpp index 03374869e93..cbdcb387622 100644 --- a/include/fastrtps/utils/collections/ResourceLimitedVector.hpp +++ b/include/fastrtps/utils/collections/ResourceLimitedVector.hpp @@ -285,7 +285,7 @@ class ResourceLimitedVector * * Checks whether the given element is present in the collection (at least once). * - * @param val Value to be looked for. + * @param val Value to look for. * * @return true if the element is present in the collection (at least once), false otherwise. */ diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 3f8d64b1585..2a42880408d 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -77,10 +77,11 @@ set(${PROJECT_NAME}_source_files rtps/messages/submessages/DataMsg.hpp rtps/messages/submessages/GapMsg.hpp rtps/messages/submessages/HeartbeatMsg.hpp - rtps/network/ExternalLocatorsProcessor.cpp - rtps/network/NetmaskFilterUtils.cpp rtps/network/NetworkFactory.cpp rtps/network/ReceiverResource.cpp + rtps/network/utils/external_locators.cpp + rtps/network/utils/netmask_filter.cpp + rtps/network/utils/network.cpp rtps/attributes/RTPSParticipantAttributes.cpp rtps/participant/RTPSParticipant.cpp rtps/participant/RTPSParticipantImpl.cpp @@ -130,6 +131,7 @@ set(${PROJECT_NAME}_source_files rtps/transport/TransportInterface.cpp rtps/transport/ChainingTransport.cpp rtps/transport/ChannelResource.cpp + rtps/transport/network/NetmaskFilterKind.cpp rtps/transport/PortBasedTransportDescriptor.cpp rtps/transport/shared_mem/SharedMemTransportDescriptor.cpp rtps/transport/tcp/RTCPMessageManager.cpp diff --git a/src/cpp/fastdds/publisher/PublisherImpl.cpp b/src/cpp/fastdds/publisher/PublisherImpl.cpp index 8a46c23fe08..f2086682b8c 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.cpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.cpp @@ -33,8 +33,8 @@ #include #include -#include #include +#include #include #include @@ -247,23 +247,18 @@ DataWriter* PublisherImpl::create_datawriter( // Check netmask filtering preconditions if (nullptr != rtps_participant()) { - fastrtps::rtps::RTPSParticipantImpl* rtps_impl = fastrtps::rtps::RTPSDomainImpl::find_local_participant( - rtps_participant()->getGuid()); - if (nullptr != rtps_impl) + std::vector netmask_filter_info = + rtps_participant()->netmask_filter_info(); + std::string error_msg; + if (!fastdds::rtps::network::netmask_filter::check_preconditions(netmask_filter_info, + qos.endpoint().ignore_non_matching_locators, + error_msg) || + !fastdds::rtps::network::netmask_filter::check_preconditions(netmask_filter_info, + qos.endpoint().external_unicast_locators, error_msg)) { - std::vector netmask_filter_info = - rtps_impl->network_factory().netmask_filter_info(); - std::string error_msg; - if (!fastdds::rtps::NetmaskFilterUtils::check_preconditions(netmask_filter_info, - qos.endpoint().ignore_non_matching_locators, - error_msg) || - !fastdds::rtps::NetmaskFilterUtils::check_preconditions(netmask_filter_info, - qos.endpoint().external_unicast_locators, error_msg)) - { - EPROSIMA_LOG_ERROR(PUBLISHER, - "Failed to create publisher -> " << error_msg); - return nullptr; - } + EPROSIMA_LOG_ERROR(PUBLISHER, + "Failed to create writer -> " << error_msg); + return nullptr; } } diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp index ed4d2b1dfb4..9b2d91d4c83 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp @@ -34,8 +34,8 @@ #include #include #include -#include #include +#include #include #include @@ -216,23 +216,18 @@ DataReader* SubscriberImpl::create_datareader( // Check netmask filtering preconditions if (nullptr != rtps_participant()) { - fastrtps::rtps::RTPSParticipantImpl* rtps_impl = fastrtps::rtps::RTPSDomainImpl::find_local_participant( - rtps_participant()->getGuid()); - if (nullptr != rtps_impl) + std::vector netmask_filter_info = + rtps_participant()->netmask_filter_info(); + std::string error_msg; + if (!fastdds::rtps::network::netmask_filter::check_preconditions(netmask_filter_info, + qos.endpoint().ignore_non_matching_locators, + error_msg) || + !fastdds::rtps::network::netmask_filter::check_preconditions(netmask_filter_info, + qos.endpoint().external_unicast_locators, error_msg)) { - std::vector netmask_filter_info = - rtps_impl->network_factory().netmask_filter_info(); - std::string error_msg; - if (!fastdds::rtps::NetmaskFilterUtils::check_preconditions(netmask_filter_info, - qos.endpoint().ignore_non_matching_locators, - error_msg) || - !fastdds::rtps::NetmaskFilterUtils::check_preconditions(netmask_filter_info, - qos.endpoint().external_unicast_locators, error_msg)) - { - EPROSIMA_LOG_ERROR(SUBSCRIBER, - "Failed to create subscriber -> " << error_msg); - return nullptr; - } + EPROSIMA_LOG_ERROR(SUBSCRIBER, + "Failed to create reader -> " << error_msg); + return nullptr; } } diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index 3483a803a84..20e48e89e5f 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include @@ -189,7 +189,7 @@ RTPSParticipant* RTPSDomainImpl::createParticipant( { fastdds::rtps::LocatorList locators; fastrtps::rtps::IPFinder::getIP4Address(&locators); - fastdds::rtps::ExternalLocatorsProcessor::add_external_locators(locators, + fastdds::rtps::network::external_locators::add_external_locators(locators, PParam.builtin.metatraffic_external_unicast_locators); uint16_t host_id = Host::compute_id(locators); guidP.value[2] = static_cast(host_id & 0xFF); diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 05c697afa75..2bd7584f9f6 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include @@ -129,7 +129,7 @@ bool EDP::newLocalReaderProxyData( { rpd->set_multicast_locators(ratt.multicastLocatorList, network); rpd->set_announced_unicast_locators(ratt.unicastLocatorList); - fastdds::rtps::ExternalLocatorsProcessor::add_external_locators(*rpd, + fastdds::rtps::network::external_locators::add_external_locators(*rpd, ratt.external_unicast_locators); } rpd->RTPSParticipantKey() = mp_RTPSParticipant->getGuid(); @@ -284,7 +284,7 @@ bool EDP::newLocalWriterProxyData( { wpd->set_multicast_locators(watt.multicastLocatorList, network); wpd->set_announced_unicast_locators(watt.unicastLocatorList); - fastdds::rtps::ExternalLocatorsProcessor::add_external_locators(*wpd, + fastdds::rtps::network::external_locators::add_external_locators(*wpd, watt.external_unicast_locators); } wpd->RTPSParticipantKey() = mp_RTPSParticipant->getGuid(); diff --git a/src/cpp/rtps/builtin/discovery/participant/DS/PDPSecurityInitiatorListener.cpp b/src/cpp/rtps/builtin/discovery/participant/DS/PDPSecurityInitiatorListener.cpp index cd538f0d58d..cb7bb49ffd6 100644 --- a/src/cpp/rtps/builtin/discovery/participant/DS/PDPSecurityInitiatorListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/DS/PDPSecurityInitiatorListener.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 5bfc9177b2d..96d862ea5cf 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -61,7 +61,7 @@ #include #include -#include +#include #include #include @@ -341,7 +341,7 @@ void PDP::initializeParticipantProxyData( } } - fastdds::rtps::ExternalLocatorsProcessor::add_external_locators(*participant_data, + fastdds::rtps::network::external_locators::add_external_locators(*participant_data, attributes.builtin.metatraffic_external_unicast_locators, attributes.default_external_unicast_locators); } diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index 924e738d352..3d18053da8b 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include @@ -120,7 +120,7 @@ void PDPListener::onNewCacheChangeAdded( // Filter locators const auto& pattr = parent_pdp_->getRTPSParticipant()->getAttributes(); - fastdds::rtps::ExternalLocatorsProcessor::filter_remote_locators(temp_participant_data_, + fastdds::rtps::network::external_locators::filter_remote_locators(temp_participant_data_, pattr.builtin.metatraffic_external_unicast_locators, pattr.default_external_unicast_locators, pattr.ignore_non_matching_locators); diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp index a89b2886020..45eacebf8b9 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include namespace eprosima { @@ -149,7 +149,7 @@ void PDPServerListener::onNewCacheChangeAdded( } const auto& pattr = pdp_server()->getRTPSParticipant()->getAttributes(); - fastdds::rtps::ExternalLocatorsProcessor::filter_remote_locators(participant_data, + fastdds::rtps::network::external_locators::filter_remote_locators(participant_data, pattr.builtin.metatraffic_external_unicast_locators, pattr.default_external_unicast_locators, pattr.ignore_non_matching_locators); diff --git a/src/cpp/rtps/common/GuidPrefix_t.cpp b/src/cpp/rtps/common/GuidPrefix_t.cpp index 3c9aa92922e..100c07912ee 100644 --- a/src/cpp/rtps/common/GuidPrefix_t.cpp +++ b/src/cpp/rtps/common/GuidPrefix_t.cpp @@ -16,8 +16,7 @@ * @file GuidPrefix_t.cpp */ -#include -#include +#include #include @@ -25,11 +24,26 @@ namespace eprosima { namespace fastrtps { namespace rtps { +bool GuidPrefix_t::is_on_same_host_as( + const GuidPrefix_t& other_guid_prefix) const +{ + return memcmp(value, other_guid_prefix.value, 4) == 0; +} + bool GuidPrefix_t::is_from_this_host() const { - uint16_t host_id = SystemInfo::instance().host_id(); - return (value[2] == static_cast(host_id & 0xFF) && - (value[3]) == static_cast((host_id >> 8) & 0xFF)); + return is_on_same_host_as(fastdds::rtps::GuidUtils::instance().prefix()); +} + +bool GuidPrefix_t::is_on_same_process_as( + const GuidPrefix_t& other_guid_prefix) const +{ + return memcmp(value, other_guid_prefix.value, 8) == 0; +} + +bool GuidPrefix_t::is_from_this_process() const +{ + return is_on_same_process_as(fastdds::rtps::GuidUtils::instance().prefix()); } } // namsepace rtps diff --git a/src/cpp/rtps/common/GuidUtils.hpp b/src/cpp/rtps/common/GuidUtils.hpp index 30b68fc3f8d..e76d46440f2 100644 --- a/src/cpp/rtps/common/GuidUtils.hpp +++ b/src/cpp/rtps/common/GuidUtils.hpp @@ -62,6 +62,16 @@ class GuidUtils guid_prefix.value[11] = static_cast((participant_id >> 24) & 0xFF); } + /** + * Get a copy of \c prefix_ attribute. + * + * @return copy of \c prefix_ attribute. + */ + GuidPrefix_t prefix() const + { + return prefix_; + } + /** * Get a reference to the singleton instance. * diff --git a/src/cpp/rtps/common/LocatorWithMask.cpp b/src/cpp/rtps/common/LocatorWithMask.cpp index 0f933ba70ac..1496c9d4765 100644 --- a/src/cpp/rtps/common/LocatorWithMask.cpp +++ b/src/cpp/rtps/common/LocatorWithMask.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include @@ -50,13 +50,13 @@ bool LocatorWithMask::matches( case LOCATOR_KIND_UDPv4: case LOCATOR_KIND_TCPv4: assert(32 >= mask()); - return NetmaskFilterUtils::address_matches(loc.address + 12, address + 12, mask()); + return network::address_matches(loc.address + 12, address + 12, mask()); case LOCATOR_KIND_UDPv6: case LOCATOR_KIND_TCPv6: case LOCATOR_KIND_SHM: assert(128 >= mask()); - return NetmaskFilterUtils::address_matches(loc.address, address, mask()); + return network::address_matches(loc.address, address, mask()); } } diff --git a/src/cpp/rtps/network/NetworkFactory.h b/src/cpp/rtps/network/NetworkFactory.h index 674a3fbc054..9c394cd60ce 100644 --- a/src/cpp/rtps/network/NetworkFactory.h +++ b/src/cpp/rtps/network/NetworkFactory.h @@ -33,8 +33,6 @@ namespace rtps { class RTPSParticipantAttributes; -using TransportNetmaskFilterInfo = std::pair; - /** * Provides the FastRTPS library with abstract resources, which * in turn manage the SEND and RECEIVE operations over some transport. @@ -108,7 +106,7 @@ class NetworkFactory * to the corresponding local address if allowed by both local and remote transports. * * @param [in] remote_locator Locator to be converted. - * @param [out] result_locator Converted locator. + * @param [in, out] result_locator Converted locator. * @param [in] remote_network_config Remote network configuration. * * @return false if the input locator is not supported/allowed by any of the registered transports, @@ -126,7 +124,7 @@ class NetworkFactory * and if allowed by both local and remote transports. * * @param [in] remote_locator Locator to be converted. - * @param [out] result_locator Converted locator. + * @param [in, out] result_locator Converted locator. * @param [in] remote_network_config Remote network configuration. * @param [in] is_fastdds_local Whether the remote locator is from a Fast-DDS entity * created in this host (from where this method is called). @@ -311,9 +309,9 @@ class NetworkFactory const LocatorList_t& participant_initial_peers) const; /** - * Return transports' netmask filter information (transport's netmask filter kind and allowlist). + * Returns transports' netmask filter information (transport's netmask filter kind and allowlist). */ - std::vector netmask_filter_info() const; + std::vector netmask_filter_info() const; private: diff --git a/src/cpp/rtps/network/ExternalLocatorsProcessor.cpp b/src/cpp/rtps/network/utils/external_locators.cpp similarity index 96% rename from src/cpp/rtps/network/ExternalLocatorsProcessor.cpp rename to src/cpp/rtps/network/utils/external_locators.cpp index 5f2bce68de7..bee1ac324a6 100644 --- a/src/cpp/rtps/network/ExternalLocatorsProcessor.cpp +++ b/src/cpp/rtps/network/utils/external_locators.cpp @@ -1,4 +1,4 @@ -// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,12 +13,13 @@ // limitations under the License. /** - * @file ExternalLocatorsProcessor.cpp + * @file external_locators.cpp */ -#include - #include +#include +#include +#include #include #include @@ -26,14 +27,17 @@ #include #include #include +#include #include -#include #include +#include + namespace eprosima { namespace fastdds { namespace rtps { -namespace ExternalLocatorsProcessor { +namespace network { +namespace external_locators { static uint8_t get_locator_mask( const Locator& locator) @@ -41,7 +45,7 @@ static uint8_t get_locator_mask( uint8_t ret = 24; std::vector infoIPs; - SystemInfo::get_ips(infoIPs, true); + SystemInfo::get_ips(infoIPs, true, false); for (const fastrtps::rtps::IPFinder::info_IP& infoIP : infoIPs) { if (infoIP.locator.kind == locator.kind && @@ -337,7 +341,8 @@ void filter_remote_locators( filter_remote_locators(locators.unicast, external_locators, ignore_non_matching); } -} // namespace ExternalLocatorsProcessor +} // namespace external_locators +} // namespace network } // namespace rtps } // namespace fastdds } // namespace eprosima diff --git a/src/cpp/rtps/network/ExternalLocatorsProcessor.hpp b/src/cpp/rtps/network/utils/external_locators.hpp similarity index 93% rename from src/cpp/rtps/network/ExternalLocatorsProcessor.hpp rename to src/cpp/rtps/network/utils/external_locators.hpp index 3be22995b69..fc86d863d97 100644 --- a/src/cpp/rtps/network/ExternalLocatorsProcessor.hpp +++ b/src/cpp/rtps/network/utils/external_locators.hpp @@ -1,4 +1,4 @@ -// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,11 +13,11 @@ // limitations under the License. /** - * @file ExternalLocatorsProcessor.hpp + * @file external_locators.hpp */ -#ifndef _RTPS_NETWORK_EXTERNALLOCATORSPROCESSOR_HPP_ -#define _RTPS_NETWORK_EXTERNALLOCATORSPROCESSOR_HPP_ +#ifndef _RTPS_NETWORK_UTILS_EXTERNAL_LOCATORS_HPP_ +#define _RTPS_NETWORK_UTILS_EXTERNAL_LOCATORS_HPP_ #include #include @@ -29,7 +29,8 @@ namespace eprosima { namespace fastdds { namespace rtps { -namespace ExternalLocatorsProcessor { +namespace network { +namespace external_locators { using eprosima::fastrtps::rtps::LocatorSelectorEntry; using eprosima::fastrtps::rtps::ParticipantProxyData; @@ -120,9 +121,10 @@ void filter_remote_locators( const ExternalLocators& external_locators, bool ignore_non_matching); -} // namespace ExternalLocatorsProcessor +} // namespace external_locators +} // namespace network } // namespace rtps } // namespace fastdds } // namespace eprosima -#endif // _RTPS_NETWORK_EXTERNALLOCATORSPROCESSOR_HPP_ +#endif // _RTPS_NETWORK_UTILS_EXTERNAL_LOCATORS_HPP_ diff --git a/src/cpp/rtps/network/NetmaskFilterUtils.cpp b/src/cpp/rtps/network/utils/netmask_filter.cpp similarity index 81% rename from src/cpp/rtps/network/NetmaskFilterUtils.cpp rename to src/cpp/rtps/network/utils/netmask_filter.cpp index f0ec4d58825..d145f6c19e9 100644 --- a/src/cpp/rtps/network/NetmaskFilterUtils.cpp +++ b/src/cpp/rtps/network/utils/netmask_filter.cpp @@ -13,24 +13,29 @@ // limitations under the License. /** - * @file NetmaskFilterUtils.cpp + * @file netmask_filter.cpp */ -#include -#include #include #include +#include #include +#include +#include #include -#include +#include +#include +#include +#include -#include +#include namespace eprosima { namespace fastdds { namespace rtps { -namespace NetmaskFilterUtils { +namespace network { +namespace netmask_filter { NetmaskFilterKind string_to_netmask_filter_kind( const std::string& netmask_filter_str) @@ -77,27 +82,6 @@ bool validate_and_transform( } } -bool address_matches( - const uint8_t* addr1, - const uint8_t* addr2, - uint64_t num_bits) -{ - uint64_t full_bytes = num_bits / 8; - if ((0 == full_bytes) || std::equal(addr1, addr1 + full_bytes, addr2)) - { - uint64_t rem_bits = num_bits % 8; - if (rem_bits == 0) - { - return true; - } - - uint8_t mask = 0xFF << (8 - rem_bits); - return (addr1[full_bytes] & mask) == (addr2[full_bytes] & mask); - } - - return false; -} - bool check_preconditions( const std::vector& factory_netmask_filter_info, bool ignore_non_matching_locators, @@ -107,7 +91,7 @@ bool check_preconditions( { const NetmaskFilterInfo& netmask_filter_info = transport_netmask_filter_info.second; const fastdds::rtps::NetmaskFilterKind& netmask_filter = netmask_filter_info.first; - const std::vector>& allowlist = netmask_filter_info.second; + const std::vector& allowlist = netmask_filter_info.second; if (netmask_filter == fastdds::rtps::NetmaskFilterKind::ON && allowlist.empty() && !ignore_non_matching_locators) @@ -141,8 +125,7 @@ bool check_preconditions( { const int32_t& transport_kind = transport_netmask_filter_info.first; const NetmaskFilterInfo& netmask_filter_info = transport_netmask_filter_info.second; - const std::vector>& allowlist = netmask_filter_info.second; + const std::vector& allowlist = netmask_filter_info.second; if (locator.kind != transport_kind) { @@ -156,8 +139,8 @@ bool check_preconditions( for (const auto& allowed_interface : allowlist) { - if (allowed_interface.second != fastdds::rtps::NetmaskFilterKind::ON || - allowed_interface.first.matches(locator)) + if (allowed_interface.netmask_filter != fastdds::rtps::NetmaskFilterKind::ON || + allowed_interface.locator.matches(locator)) { return true; } @@ -180,7 +163,8 @@ bool check_preconditions( return true; } -} // namespace NetmaskFilterUtils +} // namespace netmask_filter +} // namespace network } // namespace rtps } // namespace fastdds } // namespace eprosima diff --git a/src/cpp/rtps/network/NetmaskFilterUtils.hpp b/src/cpp/rtps/network/utils/netmask_filter.hpp similarity index 79% rename from src/cpp/rtps/network/NetmaskFilterUtils.hpp rename to src/cpp/rtps/network/utils/netmask_filter.hpp index a7a07105a06..c8624df9abf 100644 --- a/src/cpp/rtps/network/NetmaskFilterUtils.hpp +++ b/src/cpp/rtps/network/utils/netmask_filter.hpp @@ -13,25 +13,24 @@ // limitations under the License. /** - * @file NetmaskFilterUtils.hpp + * @file netmask_filter.hpp */ -#ifndef _RTPS_NETWORK_NETMASKFILTERUTILS_HPP_ -#define _RTPS_NETWORK_NETMASKFILTERUTILS_HPP_ +#ifndef _RTPS_NETWORK_UTILS_NETMASK_FILTER_HPP_ +#define _RTPS_NETWORK_UTILS_NETMASK_FILTER_HPP_ -#include #include +#include #include -#include +#include +#include namespace eprosima { namespace fastdds { namespace rtps { -namespace NetmaskFilterUtils { - -using NetmaskFilterInfo = std::pair>>; -using TransportNetmaskFilterInfo = std::pair; +namespace network { +namespace netmask_filter { /** * Convert string to \c NetmaskFilterKind if possible. @@ -54,7 +53,7 @@ NetmaskFilterKind string_to_netmask_filter_kind( * * The contained netmask filter value will adopt the container's one if the former is AUTO (and the latter is not). * - * @param [in] contained_netmask_filter Contained netmask filter value. + * @param [in, out] contained_netmask_filter Contained netmask filter value. * @param [in] container_netmask_filter Container netmask filter value. * * @return true if container and contained netmask filter configurations are compatible, false otherwise. @@ -63,20 +62,6 @@ bool validate_and_transform( NetmaskFilterKind& contained_netmask_filter, const NetmaskFilterKind& container_netmask_filter); -/** - * Checks whether two given addresses are equal in their first \c num_bits bits. - * - * @param [in] addr1 First address to compare. - * @param [in] addr2 Second address to compare. - * @param [in] num_bits Number of bits to be taken into consideration. - * - * @return true if they match, false otherwise. - */ -bool address_matches( - const uint8_t* addr1, - const uint8_t* addr2, - uint64_t num_bits); - /** * Check whether netmask filtering configuration is consistent with \c ignore_non_matching_locators parameter. * @@ -115,9 +100,10 @@ bool check_preconditions( const ExternalLocators& external_locators, std::string& error_msg); -} // namespace NetmaskFilterUtils +} // namespace netmask_filter +} // namespace network } // namespace rtps } // namespace fastdds } // namespace eprosima -#endif // _RTPS_NETWORK_NETMASKFILTERUTILS_HPP_ +#endif // _RTPS_NETWORK_UTILS_NETMASK_FILTER_HPP_ diff --git a/src/cpp/rtps/network/utils/network.cpp b/src/cpp/rtps/network/utils/network.cpp new file mode 100644 index 00000000000..10b4f0421db --- /dev/null +++ b/src/cpp/rtps/network/utils/network.cpp @@ -0,0 +1,53 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file network.cpp + */ + +#include +#include + +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { +namespace network { + +bool address_matches( + const uint8_t* addr1, + const uint8_t* addr2, + uint64_t num_bits) +{ + uint64_t full_bytes = num_bits / 8; + if ((0 == full_bytes) || std::equal(addr1, addr1 + full_bytes, addr2)) + { + uint64_t rem_bits = num_bits % 8; + if (rem_bits == 0) + { + return true; + } + + uint8_t mask = 0xFF << (8 - rem_bits); + return (addr1[full_bytes] & mask) == (addr2[full_bytes] & mask); + } + + return false; +} + +} // namespace network +} // namespace rtps +} // namespace fastdds +} // namespace eprosima diff --git a/src/cpp/rtps/network/utils/network.hpp b/src/cpp/rtps/network/utils/network.hpp new file mode 100644 index 00000000000..c90dca75e73 --- /dev/null +++ b/src/cpp/rtps/network/utils/network.hpp @@ -0,0 +1,48 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file network.hpp + */ + +#ifndef _RTPS_NETWORK_UTILS_NETWORK_HPP_ +#define _RTPS_NETWORK_UTILS_NETWORK_HPP_ + +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { +namespace network { + +/** + * Checks whether two given addresses are equal in their first \c num_bits bits. + * + * @param [in] addr1 First address to compare. + * @param [in] addr2 Second address to compare. + * @param [in] num_bits Number of bits to be taken into consideration. + * + * @return true if they match, false otherwise. + */ +bool address_matches( + const uint8_t* addr1, + const uint8_t* addr2, + uint64_t num_bits); + +} // namespace network +} // namespace rtps +} // namespace fastdds +} // namespace eprosima + +#endif // _RTPS_NETWORK_UTILS_NETWORK_HPP_ diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index de6f01323ba..7c0f91da455 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -196,6 +196,11 @@ bool RTPSParticipant::ignore_reader( return false; } +std::vector RTPSParticipant::netmask_filter_info() const +{ + return mp_impl->netmask_filter_info(); +} + #if HAVE_SECURITY bool RTPSParticipant::is_security_enabled_for_writer( diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 4fc042320e2..1006ceb4873 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -61,8 +61,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -319,23 +319,40 @@ RTPSParticipantImpl::RTPSParticipantImpl( // User defined transports for (const auto& transportDescriptor : m_att.userTransports) { + bool register_transport = true; + + // Lock user's transport descriptor since it could be modified during registration + transportDescriptor->lock(); + auto socket_descriptor = std::dynamic_pointer_cast(transportDescriptor); + fastdds::rtps::NetmaskFilterKind socket_descriptor_netmask_filter; if (socket_descriptor != nullptr) { - if (!fastdds::rtps::NetmaskFilterUtils::validate_and_transform(socket_descriptor->netmask_filter, + // Copy original netmask filter value to restore it after registration + socket_descriptor_netmask_filter = socket_descriptor->netmask_filter; + if (!fastdds::rtps::network::netmask_filter::validate_and_transform(socket_descriptor->netmask_filter, m_att.netmaskFilter)) { EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, "User transport failed to register. Provided descriptor's netmask filter (" << socket_descriptor->netmask_filter << ") is incompatible with participant's (" << m_att.netmaskFilter << ")."); - continue; + register_transport = false; } } - if (m_network_Factory.RegisterTransport(transportDescriptor.get(), &m_att.properties, - m_att.max_msg_size_no_frag)) + bool transport_registered = register_transport && m_network_Factory.RegisterTransport(transportDescriptor.get(), &m_att.properties, m_att.max_msg_size_no_frag); + + if (socket_descriptor != nullptr) + { + // Restore original netmask filter value prior to unlock + socket_descriptor->netmask_filter = socket_descriptor_netmask_filter; + } + + transportDescriptor->unlock(); + + if (transport_registered) { has_shm_transport_ |= (dynamic_cast(transportDescriptor.get()) != nullptr); @@ -369,14 +386,14 @@ RTPSParticipantImpl::RTPSParticipantImpl( } // Check netmask filtering preconditions - std::vector netmask_filter_info = m_network_Factory.netmask_filter_info(); + std::vector netmask_filter_info = m_network_Factory.netmask_filter_info(); std::string error_msg; - if (!fastdds::rtps::NetmaskFilterUtils::check_preconditions(netmask_filter_info, m_att.ignore_non_matching_locators, + if (!fastdds::rtps::network::netmask_filter::check_preconditions(netmask_filter_info, m_att.ignore_non_matching_locators, error_msg) || - !fastdds::rtps::NetmaskFilterUtils::check_preconditions(netmask_filter_info, + !fastdds::rtps::network::netmask_filter::check_preconditions(netmask_filter_info, m_att.builtin.metatraffic_external_unicast_locators, error_msg) || - !fastdds::rtps::NetmaskFilterUtils::check_preconditions(netmask_filter_info, + !fastdds::rtps::network::netmask_filter::check_preconditions(netmask_filter_info, m_att.default_external_unicast_locators, error_msg)) { EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, error_msg); @@ -495,11 +512,13 @@ RTPSParticipantImpl::RTPSParticipantImpl( createReceiverResources(m_att.defaultUnicastLocatorList, true, false, true); createReceiverResources(m_att.defaultMulticastLocatorList, true, false, true); - namespace ExternalLocatorsProcessor = fastdds::rtps::ExternalLocatorsProcessor; - ExternalLocatorsProcessor::set_listening_locators(m_att.builtin.metatraffic_external_unicast_locators, - m_att.builtin.metatrafficUnicastLocatorList); - ExternalLocatorsProcessor::set_listening_locators(m_att.default_external_unicast_locators, - m_att.defaultUnicastLocatorList); + { + using namespace fastdds::rtps::network::external_locators; + set_listening_locators(m_att.builtin.metatraffic_external_unicast_locators, + m_att.builtin.metatrafficUnicastLocatorList); + set_listening_locators(m_att.default_external_unicast_locators, + m_att.defaultUnicastLocatorList); + } // Check metatraffic multicast port if (0 < m_att.builtin.metatrafficMulticastLocatorList.size() && @@ -1456,15 +1475,15 @@ void RTPSParticipantImpl::update_attributes( // Update listening locators on external locators { - namespace ExternalLocatorsProcessor = fastdds::rtps::ExternalLocatorsProcessor; + using namespace fastdds::rtps::network::external_locators; if (local_interfaces_changed && internal_metatraffic_locators_) { - ExternalLocatorsProcessor::set_listening_locators(m_att.builtin.metatraffic_external_unicast_locators, + set_listening_locators(m_att.builtin.metatraffic_external_unicast_locators, m_att.builtin.metatrafficUnicastLocatorList); } if (local_interfaces_changed && internal_default_locators_) { - ExternalLocatorsProcessor::set_listening_locators(m_att.default_external_unicast_locators, + set_listening_locators(m_att.default_external_unicast_locators, m_att.defaultUnicastLocatorList); } } @@ -1749,7 +1768,7 @@ bool RTPSParticipantImpl::createAndAssociateReceiverswithEndpoint( createReceiverResources(attributes.multicastLocatorList, false, true, true); } - fastdds::rtps::ExternalLocatorsProcessor::set_listening_locators(attributes.external_unicast_locators, + fastdds::rtps::network::external_locators::set_listening_locators(attributes.external_unicast_locators, attributes.unicastLocatorList); // Associate the Endpoint with ReceiverControlBlock @@ -2738,6 +2757,11 @@ bool RTPSParticipantImpl::ignore_reader( return false; } +std::vector RTPSParticipantImpl::netmask_filter_info() const +{ + return m_network_Factory.netmask_filter_info(); +} + #ifdef FASTDDS_STATISTICS bool RTPSParticipantImpl::register_in_writer( diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index 951fa092948..a844e16ae9a 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -1101,6 +1101,11 @@ class RTPSParticipantImpl bool ignore_reader( const GUID_t& reader_guid); + /** + * Returns registered transports' netmask filter information (transport's netmask filter kind and allowlist). + */ + std::vector netmask_filter_info() const; + template static bool preprocess_endpoint_attributes( const EntityId_t& entity_id, diff --git a/src/cpp/rtps/reader/WriterProxy.cpp b/src/cpp/rtps/reader/WriterProxy.cpp index 471a0e718aa..be9e927b19d 100644 --- a/src/cpp/rtps/reader/WriterProxy.cpp +++ b/src/cpp/rtps/reader/WriterProxy.cpp @@ -28,7 +28,7 @@ #include -#include +#include #include #include "rtps/RTPSDomainImpl.hpp" @@ -123,7 +123,7 @@ void WriterProxy::start( const SequenceNumber_t& initial_sequence, bool is_datasharing) { - using fastdds::rtps::ExternalLocatorsProcessor::filter_remote_locators; + using fastdds::rtps::network::external_locators::filter_remote_locators; #ifdef SHOULD_DEBUG_LINUX assert(get_mutex_owner() == get_thread_id()); @@ -154,7 +154,7 @@ void WriterProxy::start( void WriterProxy::update( const WriterProxyData& attributes) { - using fastdds::rtps::ExternalLocatorsProcessor::filter_remote_locators; + using fastdds::rtps::network::external_locators::filter_remote_locators; #ifdef SHOULD_DEBUG_LINUX assert(get_mutex_owner() == get_thread_id()); diff --git a/src/cpp/rtps/transport/TCPTransportInterface.cpp b/src/cpp/rtps/transport/TCPTransportInterface.cpp index f4aded887f5..c54580b3d0c 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.cpp +++ b/src/cpp/rtps/transport/TCPTransportInterface.cpp @@ -130,12 +130,7 @@ TCPTransportDescriptor::TCPTransportDescriptor( TCPTransportDescriptor& TCPTransportDescriptor::operator =( const TCPTransportDescriptor& t) { - - maxMessageSize = t.maxMessageSize; - maxInitialPeersRange = t.maxInitialPeersRange; - sendBufferSize = t.sendBufferSize; - receiveBufferSize = t.receiveBufferSize; - TTL = t.TTL; + SocketTransportDescriptor::operator=(t); listening_ports = t.listening_ports; keep_alive_frequency_ms = t.keep_alive_frequency_ms; keep_alive_timeout_ms = t.keep_alive_timeout_ms; @@ -818,7 +813,7 @@ bool TCPTransportInterface::OpenOutputChannel( { std::vector list; std::vector local_interfaces; - get_ips(local_interfaces); + get_ips(local_interfaces, false, false); for (const auto& interface_it : local_interfaces) { Locator interface_loc(interface_it.locator); diff --git a/src/cpp/rtps/transport/TCPTransportInterface.h b/src/cpp/rtps/transport/TCPTransportInterface.h index 35d32a6b2e3..abcb8db88b8 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.h +++ b/src/cpp/rtps/transport/TCPTransportInterface.h @@ -24,7 +24,8 @@ #include #include -#include +#include +#include #include #include #include @@ -116,7 +117,7 @@ class TCPTransportInterface : public TransportInterface std::mutex channel_pending_logical_ports_mutex_; NetmaskFilterKind netmask_filter_; - std::vector> allowed_interfaces_; + std::vector allowed_interfaces_; TCPTransportInterface( int32_t transport_kind); @@ -159,8 +160,8 @@ class TCPTransportInterface : public TransportInterface virtual bool get_ips( std::vector& loc_names, - bool return_loopback = false, - bool force_lookup = false) const = 0; + bool return_loopback, + bool force_lookup) const = 0; bool is_input_port_open( uint16_t port) const; diff --git a/src/cpp/rtps/transport/TCPv4Transport.cpp b/src/cpp/rtps/transport/TCPv4Transport.cpp index 4a8bfb7fbd4..00270fd7856 100644 --- a/src/cpp/rtps/transport/TCPv4Transport.cpp +++ b/src/cpp/rtps/transport/TCPv4Transport.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include using namespace std; @@ -39,8 +39,8 @@ using Log = fastdds::dds::Log; static bool get_ipv4s( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) + bool return_loopback, + bool force_lookup) { if (!SystemInfo::get_ips(locNames, return_loopback, force_lookup)) { @@ -109,12 +109,12 @@ TCPv4Transport::TCPv4Transport( } std::vector local_interfaces; - get_ipv4s(local_interfaces, true); + get_ipv4s(local_interfaces, true, false); for (const IPFinder::info_IP& infoIP : local_interfaces) { - if (std::find_if(block_begin, block_end, [infoIP](const std::string& blocklist_element) + if (std::find_if(block_begin, block_end, [infoIP](const BlockedNetworkInterface& blocklist_element) { - return blocklist_element == infoIP.dev || blocklist_element == infoIP.name; + return blocklist_element.name == infoIP.dev || blocklist_element.name == infoIP.name; }) != block_end ) { // Before skipping this interface, check if present in whitelist/allowlist and warn the user if found @@ -123,9 +123,9 @@ TCPv4Transport::TCPv4Transport( return whitelist_element == infoIP.dev || whitelist_element == infoIP.name; }) != white_end ) || (std::find_if(allow_begin, allow_end, - [infoIP](const std::pair& allowlist_element) + [infoIP](const AllowedNetworkInterface& allowlist_element) { - return allowlist_element.first == infoIP.dev || allowlist_element.first == infoIP.name; + return allowlist_element.name == infoIP.dev || allowlist_element.name == infoIP.name; }) != allow_end )) { EPROSIMA_LOG_WARNING(TRANSPORT_TCPV4, @@ -138,25 +138,25 @@ TCPv4Transport::TCPv4Transport( else if (descriptor.interfaceWhiteList.empty() && descriptor.interface_allowlist.empty()) { interface_whitelist_.emplace_back(ip::address_v4::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, descriptor.netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, descriptor.netmask_filter); } else if (!descriptor.interface_allowlist.empty()) { auto allow_it = std::find_if( allow_begin, allow_end, - [&infoIP](const std::pair& allowlist_element) + [&infoIP](const AllowedNetworkInterface& allowlist_element) { - return allowlist_element.first == infoIP.dev || allowlist_element.first == infoIP.name; + return allowlist_element.name == infoIP.dev || allowlist_element.name == infoIP.name; }); if (allow_it != allow_end) { - NetmaskFilterKind netmask_filter = allow_it->second; - if (NetmaskFilterUtils::validate_and_transform(netmask_filter, + NetmaskFilterKind netmask_filter = allow_it->netmask_filter; + if (network::netmask_filter::validate_and_transform(netmask_filter, descriptor.netmask_filter)) { interface_whitelist_.emplace_back(ip::address_v4::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, netmask_filter); } else { @@ -176,7 +176,7 @@ TCPv4Transport::TCPv4Transport( }) != white_end ) { interface_whitelist_.emplace_back(ip::address_v4::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, descriptor.netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, descriptor.netmask_filter); } } } @@ -347,7 +347,7 @@ LocatorList TCPv4Transport::NormalizeLocator( if (IPLocator::isAny(locator)) { std::vector locNames; - get_ipv4s(locNames); + get_ipv4s(locNames, false, false); for (const auto& infoIP : locNames) { auto ip = asio::ip::address_v4::from_string(infoIP.name); @@ -402,7 +402,7 @@ bool TCPv4Transport::is_local_locator( * Check case: Address is one of our addresses. */ std::vector current_interfaces; - if (!get_ips(current_interfaces)) + if (!get_ips(current_interfaces, false, false)) { EPROSIMA_LOG_WARNING(TRANSPORT_TCPV4, "Could not retrieve IPs information to check if locator " << locator << " is local."); diff --git a/src/cpp/rtps/transport/TCPv4Transport.h b/src/cpp/rtps/transport/TCPv4Transport.h index 34d45923fa5..8dca1b8b085 100644 --- a/src/cpp/rtps/transport/TCPv4Transport.h +++ b/src/cpp/rtps/transport/TCPv4Transport.h @@ -84,8 +84,8 @@ class TCPv4Transport : public TCPTransportInterface virtual bool get_ips( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) const override; + bool return_loopback, + bool force_lookup) const override; /** * Method to get a list of interfaces to bind the socket associated to the given locator. diff --git a/src/cpp/rtps/transport/TCPv6Transport.cpp b/src/cpp/rtps/transport/TCPv6Transport.cpp index 5d2fb27c5b6..491416a6e9f 100644 --- a/src/cpp/rtps/transport/TCPv6Transport.cpp +++ b/src/cpp/rtps/transport/TCPv6Transport.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include using namespace std; @@ -40,8 +40,8 @@ using Log = fastdds::dds::Log; static bool get_ipv6s( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) + bool return_loopback, + bool force_lookup) { if (!SystemInfo::get_ips(locNames, return_loopback, force_lookup)) { @@ -113,12 +113,12 @@ TCPv6Transport::TCPv6Transport( } std::vector local_interfaces; - get_ipv6s(local_interfaces, true); + get_ipv6s(local_interfaces, true, false); for (const IPFinder::info_IP& infoIP : local_interfaces) { - if (std::find_if(block_begin, block_end, [infoIP](const std::string& blocklist_element) + if (std::find_if(block_begin, block_end, [infoIP](const BlockedNetworkInterface& blocklist_element) { - return blocklist_element == infoIP.dev || compare_ips(blocklist_element, infoIP.name); + return blocklist_element.name == infoIP.dev || compare_ips(blocklist_element.name, infoIP.name); }) != block_end ) { // Before skipping this interface, check if present in whitelist/allowlist and warn the user if found @@ -127,10 +127,10 @@ TCPv6Transport::TCPv6Transport( return whitelist_element == infoIP.dev || compare_ips(whitelist_element, infoIP.name); }) != white_end ) || (std::find_if(allow_begin, allow_end, - [infoIP](const std::pair& allowlist_element) + [infoIP](const AllowedNetworkInterface& allowlist_element) { - return allowlist_element.first == infoIP.dev || - compare_ips(allowlist_element.first, infoIP.name); + return allowlist_element.name == infoIP.dev || + compare_ips(allowlist_element.name, infoIP.name); }) != allow_end )) { EPROSIMA_LOG_WARNING(TRANSPORT_TCPV6, @@ -143,26 +143,26 @@ TCPv6Transport::TCPv6Transport( else if (descriptor.interfaceWhiteList.empty() && descriptor.interface_allowlist.empty()) { interface_whitelist_.emplace_back(ip::address_v6::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, descriptor.netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, descriptor.netmask_filter); } else if (!descriptor.interface_allowlist.empty()) { auto allow_it = std::find_if( allow_begin, allow_end, - [&infoIP](const std::pair& allowlist_element) + [&infoIP](const AllowedNetworkInterface& allowlist_element) { - return allowlist_element.first == infoIP.dev || compare_ips(allowlist_element.first, + return allowlist_element.name == infoIP.dev || compare_ips(allowlist_element.name, infoIP.name); }); if (allow_it != allow_end) { - NetmaskFilterKind netmask_filter = allow_it->second; - if (NetmaskFilterUtils::validate_and_transform(netmask_filter, + NetmaskFilterKind netmask_filter = allow_it->netmask_filter; + if (network::netmask_filter::validate_and_transform(netmask_filter, descriptor.netmask_filter)) { interface_whitelist_.emplace_back(ip::address_v6::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, netmask_filter); } else { @@ -182,7 +182,7 @@ TCPv6Transport::TCPv6Transport( }) != white_end ) { interface_whitelist_.emplace_back(ip::address_v6::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, descriptor.netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, descriptor.netmask_filter); } } } @@ -359,7 +359,7 @@ LocatorList TCPv6Transport::NormalizeLocator( if (IPLocator::isAny(locator)) { std::vector locNames; - get_ipv6s(locNames); + get_ipv6s(locNames, false, false); for (const auto& infoIP : locNames) { if (is_interface_allowed(infoIP.name)) @@ -396,7 +396,7 @@ bool TCPv6Transport::is_local_locator( } std::vector current_interfaces; - if (!get_ips(current_interfaces)) + if (!get_ips(current_interfaces, false, false)) { EPROSIMA_LOG_WARNING(TRANSPORT_TCPV6, "Could not retrieve IPs information to check if locator " << locator << " is local."); diff --git a/src/cpp/rtps/transport/TCPv6Transport.h b/src/cpp/rtps/transport/TCPv6Transport.h index 1a5d6b34a7b..a33b4f5453d 100644 --- a/src/cpp/rtps/transport/TCPv6Transport.h +++ b/src/cpp/rtps/transport/TCPv6Transport.h @@ -86,8 +86,8 @@ class TCPv6Transport : public TCPTransportInterface virtual bool get_ips( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) const override; + bool return_loopback, + bool force_lookup) const override; /** * Method to get a list of interfaces to bind the socket associated to the given locator. diff --git a/src/cpp/rtps/transport/UDPChannelResource.h b/src/cpp/rtps/transport/UDPChannelResource.h index b5b846a0097..56949e2c869 100644 --- a/src/cpp/rtps/transport/UDPChannelResource.h +++ b/src/cpp/rtps/transport/UDPChannelResource.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include diff --git a/src/cpp/rtps/transport/UDPTransportInterface.cpp b/src/cpp/rtps/transport/UDPTransportInterface.cpp index db91e0290cd..bcf835b2d29 100644 --- a/src/cpp/rtps/transport/UDPTransportInterface.cpp +++ b/src/cpp/rtps/transport/UDPTransportInterface.cpp @@ -271,15 +271,14 @@ eProsimaUDPSocket UDPTransportInterface::OpenAndBindUnicastOutputSocket( auto it = std::find_if( allowed_interfaces_.begin(), allowed_interfaces_.end(), - [&locator](const std::pair& entry) + [&locator](const AllowedNetworkInterface& entry) { - return locator == entry.first; + return locator == entry.locator; }); if (it != allowed_interfaces_.end()) { - socket.netmask_filter = it->second; + socket.netmask_filter = it->netmask_filter; } else { @@ -744,7 +743,7 @@ void UDPTransportInterface::get_unknown_network_interfaces( locNames.clear(); if (rescan_interfaces_) { - get_ips(locNames, return_loopback); + get_ips(locNames, return_loopback, false); for (auto& sender_resource : sender_resource_list) { UDPSenderResource* udp_sender_resource = UDPSenderResource::cast(*this, sender_resource.get()); diff --git a/src/cpp/rtps/transport/UDPTransportInterface.h b/src/cpp/rtps/transport/UDPTransportInterface.h index ad71aac04de..37485a85e17 100644 --- a/src/cpp/rtps/transport/UDPTransportInterface.h +++ b/src/cpp/rtps/transport/UDPTransportInterface.h @@ -23,7 +23,8 @@ #include #include -#include +#include +#include #include #include #include @@ -195,7 +196,7 @@ class UDPTransportInterface : public TransportInterface bool first_time_open_output_channel_; NetmaskFilterKind netmask_filter_; - std::vector> allowed_interfaces_; + std::vector allowed_interfaces_; UDPTransportInterface( int32_t transport_kind); @@ -229,8 +230,8 @@ class UDPTransportInterface : public TransportInterface virtual asio::ip::udp generate_protocol() const = 0; virtual bool get_ips( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) const = 0; + bool return_loopback, + bool force_lookup) const = 0; virtual const std::string& localhost_name() = 0; //! Checks if the interfaces white list is empty. diff --git a/src/cpp/rtps/transport/UDPv4Transport.cpp b/src/cpp/rtps/transport/UDPv4Transport.cpp index a2f20a3f230..6b6bd4b8cdd 100644 --- a/src/cpp/rtps/transport/UDPv4Transport.cpp +++ b/src/cpp/rtps/transport/UDPv4Transport.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -42,8 +42,8 @@ using Log = fastdds::dds::Log; static bool get_ipv4s( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) + bool return_loopback, + bool force_lookup) { if (!SystemInfo::get_ips(locNames, return_loopback, force_lookup)) { @@ -67,8 +67,8 @@ static bool get_ipv4s( static bool get_ipv4s_unique_interfaces( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) + bool return_loopback, + bool force_lookup) { if (!get_ipv4s(locNames, return_loopback, force_lookup)) { @@ -139,24 +139,23 @@ UDPv4Transport::UDPv4Transport( } std::vector local_interfaces; - get_ipv4s(local_interfaces, true); + get_ipv4s(local_interfaces, true, false); for (const IPFinder::info_IP& infoIP : local_interfaces) { - if (std::find_if(block_begin, block_end, [infoIP](const std::string& blocklist_element) + if (std::find_if(block_begin, block_end, [infoIP](const BlockedNetworkInterface& blocklist_element) { - return blocklist_element == infoIP.dev || blocklist_element == infoIP.name; + return blocklist_element.name == infoIP.dev || blocklist_element.name == infoIP.name; }) != block_end ) { - std::cout << "BLOCKED" << std::endl; // Before skipping this interface, check if present in whitelist/allowlist and warn the user if found if ((std::find_if(white_begin, white_end, [infoIP](const std::string& whitelist_element) { return whitelist_element == infoIP.dev || whitelist_element == infoIP.name; }) != white_end ) || (std::find_if(allow_begin, allow_end, - [infoIP](const std::pair& allowlist_element) + [infoIP](const AllowedNetworkInterface& allowlist_element) { - return allowlist_element.first == infoIP.dev || allowlist_element.first == infoIP.name; + return allowlist_element.name == infoIP.dev || allowlist_element.name == infoIP.name; }) != allow_end )) { EPROSIMA_LOG_WARNING(TRANSPORT_UDPV4, @@ -169,25 +168,25 @@ UDPv4Transport::UDPv4Transport( else if (descriptor.interfaceWhiteList.empty() && descriptor.interface_allowlist.empty()) { interface_whitelist_.emplace_back(ip::address_v4::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, descriptor.netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, descriptor.netmask_filter); } else if (!descriptor.interface_allowlist.empty()) { auto allow_it = std::find_if( allow_begin, allow_end, - [&infoIP](const std::pair& allowlist_element) + [&infoIP](const AllowedNetworkInterface& allowlist_element) { - return allowlist_element.first == infoIP.dev || allowlist_element.first == infoIP.name; + return allowlist_element.name == infoIP.dev || allowlist_element.name == infoIP.name; }); if (allow_it != allow_end) { - NetmaskFilterKind netmask_filter = allow_it->second; - if (NetmaskFilterUtils::validate_and_transform(netmask_filter, + NetmaskFilterKind netmask_filter = allow_it->netmask_filter; + if (network::netmask_filter::validate_and_transform(netmask_filter, descriptor.netmask_filter)) { interface_whitelist_.emplace_back(ip::address_v4::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, netmask_filter); } else { @@ -207,7 +206,7 @@ UDPv4Transport::UDPv4Transport( }) != white_end ) { interface_whitelist_.emplace_back(ip::address_v4::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, descriptor.netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, descriptor.netmask_filter); } } } @@ -492,7 +491,7 @@ bool UDPv4Transport::OpenInputChannel( if (channelResource->iface() == s_IPv4AddressAny) { std::vector locNames; - get_ipv4s_unique_interfaces(locNames, true); + get_ipv4s_unique_interfaces(locNames, true, false); for (const auto& infoIP : locNames) { auto ip = asio::ip::address_v4::from_string(infoIP.name); @@ -596,7 +595,7 @@ LocatorList UDPv4Transport::NormalizeLocator( if (IPLocator::isAny(locator)) { std::vector locNames; - get_ipv4s(locNames); + get_ipv4s(locNames, false, false); for (const auto& infoIP : locNames) { auto ip = asio::ip::address_v4::from_string(infoIP.name); @@ -633,7 +632,7 @@ bool UDPv4Transport::is_local_locator( } std::vector currentInterfaces; - if (!get_ips(currentInterfaces)) + if (!get_ips(currentInterfaces, false, false)) { EPROSIMA_LOG_WARNING(TRANSPORT_UDPV4, "Could not retrieve IPs information to check if locator " << locator << " is local."); @@ -680,7 +679,7 @@ void UDPv4Transport::update_network_interfaces() { // WARNING: SystemInfo::update_interfaces() should have been called prior to this point std::vector locNames; - get_ipv4s_unique_interfaces(locNames, true); + get_ipv4s_unique_interfaces(locNames, true, false); for (const auto& infoIP : locNames) { auto ip = asio::ip::address_v4::from_string(infoIP.name); diff --git a/src/cpp/rtps/transport/UDPv4Transport.h b/src/cpp/rtps/transport/UDPv4Transport.h index 2b9fe4b5d25..d132b031cde 100644 --- a/src/cpp/rtps/transport/UDPv4Transport.h +++ b/src/cpp/rtps/transport/UDPv4Transport.h @@ -125,8 +125,8 @@ class UDPv4Transport : public UDPTransportInterface asio::ip::udp generate_protocol() const override; bool get_ips( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) const override; + bool return_loopback, + bool force_lookup) const override; const std::string& localhost_name() override; eProsimaUDPSocket OpenAndBindInputSocket( const std::string& sIp, diff --git a/src/cpp/rtps/transport/UDPv6Transport.cpp b/src/cpp/rtps/transport/UDPv6Transport.cpp index 28c0b1b2495..007f414db90 100644 --- a/src/cpp/rtps/transport/UDPv6Transport.cpp +++ b/src/cpp/rtps/transport/UDPv6Transport.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include using namespace std; @@ -40,8 +40,8 @@ using Log = fastdds::dds::Log; static bool get_ipv6s( vector& locNames, - bool return_loopback = false, - bool force_lookup = false) + bool return_loopback, + bool force_lookup) { if (!SystemInfo::get_ips(locNames, return_loopback, force_lookup)) { @@ -65,8 +65,8 @@ static bool get_ipv6s( static bool get_ipv6s_unique_interfaces( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) + bool return_loopback, + bool force_lookup) { if (!get_ipv6s(locNames, return_loopback, force_lookup)) { @@ -140,12 +140,12 @@ UDPv6Transport::UDPv6Transport( } std::vector local_interfaces; - get_ipv6s(local_interfaces, true); + get_ipv6s(local_interfaces, true, false); for (const IPFinder::info_IP& infoIP : local_interfaces) { - if (std::find_if(block_begin, block_end, [infoIP](const std::string& blocklist_element) + if (std::find_if(block_begin, block_end, [infoIP](const BlockedNetworkInterface& blocklist_element) { - return blocklist_element == infoIP.dev || compare_ips(blocklist_element, infoIP.name); + return blocklist_element.name == infoIP.dev || compare_ips(blocklist_element.name, infoIP.name); }) != block_end ) { // Before skipping this interface, check if present in whitelist/allowlist and warn the user if found @@ -154,10 +154,10 @@ UDPv6Transport::UDPv6Transport( return whitelist_element == infoIP.dev || compare_ips(whitelist_element, infoIP.name); }) != white_end ) || (std::find_if(allow_begin, allow_end, - [infoIP](const std::pair& allowlist_element) + [infoIP](const AllowedNetworkInterface& allowlist_element) { - return allowlist_element.first == infoIP.dev || - compare_ips(allowlist_element.first, infoIP.name); + return allowlist_element.name == infoIP.dev || + compare_ips(allowlist_element.name, infoIP.name); }) != allow_end )) { EPROSIMA_LOG_WARNING(TRANSPORT_UDPV6, @@ -169,26 +169,26 @@ UDPv6Transport::UDPv6Transport( else if (descriptor.interfaceWhiteList.empty() && descriptor.interface_allowlist.empty()) { interface_whitelist_.emplace_back(ip::address_v6::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, descriptor.netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, descriptor.netmask_filter); } else if (!descriptor.interface_allowlist.empty()) { auto allow_it = std::find_if( allow_begin, allow_end, - [&infoIP](const std::pair& allowlist_element) + [&infoIP](const AllowedNetworkInterface& allowlist_element) { - return allowlist_element.first == infoIP.dev || compare_ips(allowlist_element.first, + return allowlist_element.name == infoIP.dev || compare_ips(allowlist_element.name, infoIP.name); }); if (allow_it != allow_end) { - NetmaskFilterKind netmask_filter = allow_it->second; - if (NetmaskFilterUtils::validate_and_transform(netmask_filter, + NetmaskFilterKind netmask_filter = allow_it->netmask_filter; + if (network::netmask_filter::validate_and_transform(netmask_filter, descriptor.netmask_filter)) { interface_whitelist_.emplace_back(ip::address_v6::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, netmask_filter); } else { @@ -208,7 +208,7 @@ UDPv6Transport::UDPv6Transport( }) != white_end ) { interface_whitelist_.emplace_back(ip::address_v6::from_string(infoIP.name)); - allowed_interfaces_.emplace_back(std::make_pair(infoIP.masked_locator, descriptor.netmask_filter)); + allowed_interfaces_.emplace_back(infoIP.dev, infoIP.masked_locator, descriptor.netmask_filter); } } } @@ -495,7 +495,7 @@ bool UDPv6Transport::OpenInputChannel( if (channelResource->iface() == s_IPv6AddressAny) { std::vector locNames; - get_ipv6s_unique_interfaces(locNames, true); + get_ipv6s_unique_interfaces(locNames, true, false); for (const auto& infoIP : locNames) { auto ip = asio::ip::address_v6::from_string(infoIP.name); @@ -600,7 +600,7 @@ LocatorList UDPv6Transport::NormalizeLocator( if (IPLocator::isAny(locator)) { std::vector locNames; - get_ipv6s(locNames); + get_ipv6s(locNames, false, false); for (const auto& infoIP : locNames) { if (is_interface_allowed(infoIP.name)) @@ -637,7 +637,7 @@ bool UDPv6Transport::is_local_locator( } std::vector currentInterfaces; - if (!get_ips(currentInterfaces)) + if (!get_ips(currentInterfaces, false, false)) { EPROSIMA_LOG_WARNING(TRANSPORT_UDPV6, "Could not retrieve IPs information to check if locator " << locator << " is local."); diff --git a/src/cpp/rtps/transport/UDPv6Transport.h b/src/cpp/rtps/transport/UDPv6Transport.h index f6b72db0880..721f001ca20 100644 --- a/src/cpp/rtps/transport/UDPv6Transport.h +++ b/src/cpp/rtps/transport/UDPv6Transport.h @@ -122,8 +122,8 @@ class UDPv6Transport : public UDPTransportInterface asio::ip::udp generate_protocol() const override; bool get_ips( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) const override; + bool return_loopback, + bool force_lookup) const override; const std::string& localhost_name() override; eProsimaUDPSocket OpenAndBindInputSocket( const std::string& sIp, diff --git a/include/fastdds/rtps/transport/NetmaskFilterKind.hpp b/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp similarity index 79% rename from include/fastdds/rtps/transport/NetmaskFilterKind.hpp rename to src/cpp/rtps/transport/network/NetmaskFilterKind.cpp index 1794477e919..143b7b8c5d9 100644 --- a/include/fastdds/rtps/transport/NetmaskFilterKind.hpp +++ b/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp @@ -12,31 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -/** - * @file NetmaskFilterKind.hpp +/*! + * @file NetmaskFilterKind.cpp */ -#ifndef _FASTDDS_RTPS_TRANSPORT_NETMASKFILTER_HPP_ -#define _FASTDDS_RTPS_TRANSPORT_NETMASKFILTER_HPP_ - #include +#include +#include #include #include -#include +#include namespace eprosima { namespace fastdds { namespace rtps { -enum RTPS_DllAPI NetmaskFilterKind -{ - OFF, - AUTO, - ON -}; - -inline std::ostream& operator <<( +std::ostream& operator <<( std::ostream& output, const NetmaskFilterKind& netmask_filter_kind) { @@ -57,8 +49,6 @@ inline std::ostream& operator <<( return output << netmask_filter_kind_str; } -} // namespace rtps +} // namsepace rtps } // namespace fastdds } // namespace eprosima - -#endif // _FASTDDS_RTPS_TRANSPORT_NETMASKFILTER_HPP_ diff --git a/src/cpp/rtps/transport/test_UDPv4Transport.h b/src/cpp/rtps/transport/test_UDPv4Transport.h index 32eeb987aa4..9ef1df6398d 100644 --- a/src/cpp/rtps/transport/test_UDPv4Transport.h +++ b/src/cpp/rtps/transport/test_UDPv4Transport.h @@ -66,8 +66,8 @@ class test_UDPv4Transport : public UDPv4Transport virtual bool get_ips( std::vector& locNames, - bool return_loopback = false, - bool force_lookup = false) const override; + bool return_loopback, + bool force_lookup) const override; private: diff --git a/src/cpp/rtps/writer/StatefulWriter.cpp b/src/cpp/rtps/writer/StatefulWriter.cpp index 36742c085df..88b8f9006c9 100644 --- a/src/cpp/rtps/writer/StatefulWriter.cpp +++ b/src/cpp/rtps/writer/StatefulWriter.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include @@ -1015,7 +1015,7 @@ void StatefulWriter::select_all_readers_nts( bool StatefulWriter::matched_reader_add( const ReaderProxyData& rdata) { - using fastdds::rtps::ExternalLocatorsProcessor::filter_remote_locators; + using fastdds::rtps::network::external_locators::filter_remote_locators; if (rdata.guid() == c_Guid_Unknown) { diff --git a/src/cpp/rtps/writer/StatelessWriter.cpp b/src/cpp/rtps/writer/StatelessWriter.cpp index 70aee73a06a..8c7a770b709 100644 --- a/src/cpp/rtps/writer/StatelessWriter.cpp +++ b/src/cpp/rtps/writer/StatelessWriter.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include "../flowcontrol/FlowController.hpp" @@ -461,7 +461,7 @@ bool StatelessWriter::wait_for_acknowledgement( bool StatelessWriter::matched_reader_add( const ReaderProxyData& data) { - using fastdds::rtps::ExternalLocatorsProcessor::filter_remote_locators; + using fastdds::rtps::network::external_locators::filter_remote_locators; std::unique_lock guard(mp_mutex); std::unique_lock locator_selector_guard(locator_selector_); diff --git a/src/cpp/rtps/xmlparser/XMLParser.cpp b/src/cpp/rtps/xmlparser/XMLParser.cpp index 9b243df4533..e8ff6e227a4 100644 --- a/src/cpp/rtps/xmlparser/XMLParser.cpp +++ b/src/cpp/rtps/xmlparser/XMLParser.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -35,7 +35,7 @@ #include #include -#include +#include #include namespace eprosima { @@ -630,7 +630,7 @@ XMLP_ret XMLParser::parseXMLSocketTransportData( try { - p_transport->netmask_filter = fastdds::rtps::NetmaskFilterUtils::string_to_netmask_filter_kind( + p_transport->netmask_filter = fastdds::rtps::network::netmask_filter::string_to_netmask_filter_kind( netmask_filter_str); } catch (const std::invalid_argument& e) @@ -748,7 +748,7 @@ XMLP_ret XMLParser::parseXMLAllowlist( { try { - netmask_filter = fastdds::rtps::NetmaskFilterUtils::string_to_netmask_filter_kind( + netmask_filter = fastdds::rtps::network::netmask_filter::string_to_netmask_filter_kind( netmask_filter_attr->Value()); } catch (const std::invalid_argument& e) @@ -766,7 +766,7 @@ XMLP_ret XMLParser::parseXMLAllowlist( return XMLP_ret::XML_ERROR; } // Add valid item to allowlist - p_transport->interface_allowlist.push_back({iface_name, netmask_filter}); + p_transport->interface_allowlist.emplace_back(iface_name, netmask_filter); } else { @@ -2373,7 +2373,7 @@ XMLP_ret XMLParser::fillDataNode( try { participant_node.get()->rtps.netmaskFilter = - fastdds::rtps::NetmaskFilterUtils::string_to_netmask_filter_kind(netmask_filter_str); + fastdds::rtps::network::netmask_filter::string_to_netmask_filter_kind(netmask_filter_str); } catch (const std::invalid_argument& e) { diff --git a/src/cpp/utils/IPFinder.cpp b/src/cpp/utils/IPFinder.cpp index 5f76508e928..17e2fe2e25d 100644 --- a/src/cpp/utils/IPFinder.cpp +++ b/src/cpp/utils/IPFinder.cpp @@ -138,7 +138,7 @@ bool IPFinder::getIPs( } // Parse IP - bool success; + bool success = false; if (info.type == IP4) { success = parseIP4(info); @@ -181,13 +181,87 @@ bool IPFinder::getIPs( #else +bool parseIfaddr( + const ifaddrs* ifaddr, + IPFinder::info_IP& info, + bool return_loopback) +{ + int family, s; + char host[NI_MAXHOST]; + + IPFinder::IPTYPE ip_type; + bool ipv4; // Binary discriminator to distinguish between IP4/IP4_LOCAL and IP6/IP6_LOCAL types + family = ifaddr->ifa_addr->sa_family; + if (family == AF_INET) + { + ip_type = IPFinder::IP4; + ipv4 = true; + } + else if (family == AF_INET6) + { + ip_type = IPFinder::IP6; + ipv4 = false; + } + else + { + // Not an IP address -> abort + return false; + } + + info.type = ip_type; + info.dev = std::string(ifaddr->ifa_name); + + // Get interface name + s = getnameinfo(ifaddr->ifa_addr, ipv4 ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), + host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); + if (s != 0) + { + EPROSIMA_LOG_WARNING(UTILS, "getnameinfo() failed: " << gai_strerror(s)); + return false; + } + info.name = std::string(host); + + // Get interface network mask + s = getnameinfo(ifaddr->ifa_netmask, ipv4 ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), + host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); + if (s != 0) + { + EPROSIMA_LOG_WARNING(UTILS, "getnameinfo() failed: " << gai_strerror(s)); + return false; + } + auto netmask_str = std::string(host); + + IPFinder::IPTYPE local_ip_type = ipv4 ? IPFinder::IP4_LOCAL : IPFinder::IP6_LOCAL; + if (ipv4 ? IPFinder::parseIP4(info) : IPFinder::parseIP6(info)) + { + if (return_loopback || info.type != local_ip_type) + { + // Convert parsed netmask string to locator + Locator_t netmask_locator; + netmask_locator.kind = ipv4 ? LOCATOR_KIND_UDPv4 : LOCATOR_KIND_UDPv6; + netmask_locator.port = 0; + ipv4 ? IPLocator::setIPv4(netmask_locator, netmask_str) : IPLocator::setIPv6(netmask_locator, netmask_str); + + // Get netmask length from locator + uint8_t netmask = 0; + for (const auto& addr_octet: netmask_locator.address) + { + netmask += static_cast(std::bitset<8>(addr_octet).count()); + } + info.masked_locator.mask(netmask); + info.masked_locator = info.locator; // NOTE: copy (kind and address) after parsing IP + + return true; + } + } + return false; +} + bool IPFinder::getIPs( std::vector* vec_name, bool return_loopback) { struct ifaddrs* ifaddr, * ifa; - int family, s; - char host[NI_MAXHOST]; // TODO arm64 doesn't seem to support getifaddrs if (getifaddrs(&ifaddr) == -1) @@ -203,105 +277,10 @@ bool IPFinder::getIPs( continue; } - family = ifa->ifa_addr->sa_family; - - if (family == AF_INET) + info_IP info; + if (parseIfaddr(ifa, info, return_loopback)) { - info_IP info; - info.type = IP4; - info.dev = std::string(ifa->ifa_name); - - // Get interface name - s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), - host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); - if (s != 0) - { - EPROSIMA_LOG_WARNING(UTILS, "getnameinfo() failed: " << gai_strerror(s)); - continue; - } - info.name = std::string(host); - - // Get interface network mask - s = getnameinfo(ifa->ifa_netmask, sizeof(struct sockaddr_in), - host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); - if (s != 0) - { - EPROSIMA_LOG_WARNING(UTILS, "getnameinfo() failed: " << gai_strerror(s)); - continue; - } - auto netmask_str = std::string(host); - - if (parseIP4(info)) - { - if (return_loopback || info.type != IP4_LOCAL) - { - // Convert parsed netmask string to locator - Locator_t netmask_locator; - netmask_locator.kind = LOCATOR_KIND_UDPv4; - netmask_locator.port = 0; - IPLocator::setIPv4(netmask_locator, netmask_str); - - // Get netmask length from locator - uint8_t netmask = 0; - for (const auto& addr_octet: netmask_locator.address) - { - netmask += static_cast(std::bitset<8>(addr_octet).count()); - } - info.masked_locator.mask(netmask); - info.masked_locator = info.locator; // NOTE: copy (kind and address) after parseIP4 - - vec_name->push_back(info); - } - } - } - else if (family == AF_INET6) - { - info_IP info; - info.type = IP6; - info.dev = std::string(ifa->ifa_name); - - // Get interface name - s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), - host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); - if (s != 0) - { - EPROSIMA_LOG_WARNING(UTILS, "getnameinfo() failed: " << gai_strerror(s)); - continue; - } - info.name = std::string(host); - - // Get interface network mask - s = getnameinfo(ifa->ifa_netmask, sizeof(struct sockaddr_in6), - host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); - if (s != 0) - { - EPROSIMA_LOG_WARNING(UTILS, "getnameinfo() failed: " << gai_strerror(s)); - continue; - } - auto netmask_str = std::string(host); - - if (parseIP6(info)) - { - if (return_loopback || info.type != IP6_LOCAL) - { - // Convert parsed netmask string to locator - Locator_t netmask_locator; - netmask_locator.kind = LOCATOR_KIND_UDPv6; - netmask_locator.port = 0; - IPLocator::setIPv6(netmask_locator, netmask_str); - - // Get netmask length from locator - uint8_t netmask = 0; - for (const auto& addr_octet: netmask_locator.address) - { - netmask += static_cast(std::bitset<8>(addr_octet).count()); - } - info.masked_locator.mask(netmask); - info.masked_locator = info.locator; // NOTE: copy (kind and address) after parseIP6 - - vec_name->push_back(info); - } - } + vec_name->push_back(info); } } diff --git a/src/cpp/utils/SystemInfo.hpp b/src/cpp/utils/SystemInfo.hpp index 867b75799f1..51f7a5fa5ab 100644 --- a/src/cpp/utils/SystemInfo.hpp +++ b/src/cpp/utils/SystemInfo.hpp @@ -256,7 +256,7 @@ class SystemInfo static bool get_ips( std::vector& vec_name, bool return_loopback, - bool force_lookup = false); + bool force_lookup); private: diff --git a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h index 1306f2734b3..8871da212a1 100644 --- a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h +++ b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h @@ -31,8 +31,6 @@ namespace rtps { class RTPSParticipantAttributes; -using TransportNetmaskFilterInfo = std::pair; - /** * Provides the FastRTPS library with abstract resources, which * in turn manage the SEND and RECEIVE operations over some transport. @@ -103,8 +101,7 @@ class NetworkFactory return true; } - // TODO - std::vector netmask_filter_info() const + std::vector netmask_filter_info() const { return {}; } diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h index 58372c47cdd..71a702aa83b 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h @@ -219,6 +219,11 @@ class RTPS_DllAPI RTPSParticipant const ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter)); + std::vector netmask_filter_info() const + { + return {}; + } + const RTPSParticipantAttributes& getRTPSParticipantAttributes() { return attributes_; diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h index ccf1e10eade..95188a863e0 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/mock/rtps/ExternalLocatorsProcessor/rtps/network/ExternalLocatorsProcessor.hpp b/test/mock/rtps/external_locators/rtps/network/utils/external_locators.hpp similarity index 94% rename from test/mock/rtps/ExternalLocatorsProcessor/rtps/network/ExternalLocatorsProcessor.hpp rename to test/mock/rtps/external_locators/rtps/network/utils/external_locators.hpp index 4c90757691c..32ba8cbb65e 100644 --- a/test/mock/rtps/ExternalLocatorsProcessor/rtps/network/ExternalLocatorsProcessor.hpp +++ b/test/mock/rtps/external_locators/rtps/network/utils/external_locators.hpp @@ -13,11 +13,11 @@ // limitations under the License. /** - * @file ExternalLocatorsProcessor.hpp + * @file external_locators.hpp */ -#ifndef _RTPS_NETWORK_EXTERNALLOCATORSPROCESSOR_HPP_ -#define _RTPS_NETWORK_EXTERNALLOCATORSPROCESSOR_HPP_ +#ifndef _RTPS_NETWORK_UTILS_EXTERNAL_LOCATORS_HPP_ +#define _RTPS_NETWORK_UTILS_EXTERNAL_LOCATORS_HPP_ #include #include @@ -29,7 +29,8 @@ namespace eprosima { namespace fastdds { namespace rtps { -namespace ExternalLocatorsProcessor { +namespace network { +namespace external_locators { using eprosima::fastrtps::rtps::LocatorSelectorEntry; using eprosima::fastrtps::rtps::ParticipantProxyData; @@ -122,9 +123,10 @@ void filter_remote_locators( { } -} // namespace ExternalLocatorsProcessor +} // namespace external_locators +} // namespace network } // namespace rtps } // namespace fastdds } // namespace eprosima -#endif // _RTPS_NETWORK_EXTERNALLOCATORSPROCESSOR_HPP_ +#endif // _RTPS_NETWORK_UTILS_EXTERNAL_LOCATORS_HPP_ diff --git a/test/unittest/dds/collections/CMakeLists.txt b/test/unittest/dds/collections/CMakeLists.txt index b8b45ba6604..42254e05a60 100644 --- a/test/unittest/dds/collections/CMakeLists.txt +++ b/test/unittest/dds/collections/CMakeLists.txt @@ -22,7 +22,10 @@ set(LOANABLE_SEQUENCE_TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp diff --git a/test/unittest/dds/core/condition/CMakeLists.txt b/test/unittest/dds/core/condition/CMakeLists.txt index a4feecd4925..66ba6560c32 100644 --- a/test/unittest/dds/core/condition/CMakeLists.txt +++ b/test/unittest/dds/core/condition/CMakeLists.txt @@ -34,7 +34,9 @@ set(CONDITION_TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/condition/WaitSetImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${LOG_SOURCES} @@ -58,7 +60,10 @@ set(CONDITION_NOTIFIER_TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/condition/Condition.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/condition/ConditionNotifier.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${LOG_SOURCES} @@ -86,7 +91,9 @@ set(STATUS_CONDITION_IMPL_TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/condition/StatusConditionImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${LOG_SOURCES} @@ -113,7 +120,9 @@ set(WAITSET_IMPL_TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/condition/WaitSetImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${LOG_SOURCES} diff --git a/test/unittest/dds/core/entity/CMakeLists.txt b/test/unittest/dds/core/entity/CMakeLists.txt index de3c6a76509..37aa489cb27 100644 --- a/test/unittest/dds/core/entity/CMakeLists.txt +++ b/test/unittest/dds/core/entity/CMakeLists.txt @@ -30,7 +30,9 @@ set(ENTITY_TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp diff --git a/test/unittest/dds/publisher/CMakeLists.txt b/test/unittest/dds/publisher/CMakeLists.txt index 10b84599399..17b830855cd 100644 --- a/test/unittest/dds/publisher/CMakeLists.txt +++ b/test/unittest/dds/publisher/CMakeLists.txt @@ -152,10 +152,11 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageCreator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageGroup.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/SendBuffersManager.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/ExternalLocatorsProcessor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/ReceiverResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/external_locators.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/participant/RTPSParticipant.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/participant/RTPSParticipantImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/PersistenceFactory.cpp @@ -169,8 +170,8 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/RTPSDomain.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp @@ -182,6 +183,7 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv4Transport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv6Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv4Transport.cpp diff --git a/test/unittest/dds/status/CMakeLists.txt b/test/unittest/dds/status/CMakeLists.txt index bdb5038b53d..95188d5e9b0 100644 --- a/test/unittest/dds/status/CMakeLists.txt +++ b/test/unittest/dds/status/CMakeLists.txt @@ -92,7 +92,9 @@ set(LISTENERTESTS_SOURCE ListenerTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/CacheChangePool.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/TopicPayloadPool.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/TopicPayloadPoolRegistry.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LocatorSelectorSender.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp diff --git a/test/unittest/dds/subscriber/CMakeLists.txt b/test/unittest/dds/subscriber/CMakeLists.txt index b98f6d6545a..3f83b5aedbd 100644 --- a/test/unittest/dds/subscriber/CMakeLists.txt +++ b/test/unittest/dds/subscriber/CMakeLists.txt @@ -33,7 +33,9 @@ set(DATAREADERHISTORYTESTS_SOURCE DataReaderHistoryTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/History.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/ReaderHistory.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp diff --git a/test/unittest/dds/topic/DDSSQLFilter/CMakeLists.txt b/test/unittest/dds/topic/DDSSQLFilter/CMakeLists.txt index d5a8b9c9dd0..0b7dc030406 100644 --- a/test/unittest/dds/topic/DDSSQLFilter/CMakeLists.txt +++ b/test/unittest/dds/topic/DDSSQLFilter/CMakeLists.txt @@ -25,7 +25,9 @@ file(GLOB DDSSQLFILTER_LIB_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp diff --git a/test/unittest/dynamic_types/CMakeLists.txt b/test/unittest/dynamic_types/CMakeLists.txt index d7628491507..e21bd46f8e9 100644 --- a/test/unittest/dynamic_types/CMakeLists.txt +++ b/test/unittest/dynamic_types/CMakeLists.txt @@ -50,7 +50,9 @@ set(DYNAMIC_TYPES_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp diff --git a/test/unittest/logging/CMakeLists.txt b/test/unittest/logging/CMakeLists.txt index ec1e2d72396..d9c0ba60acf 100644 --- a/test/unittest/logging/CMakeLists.txt +++ b/test/unittest/logging/CMakeLists.txt @@ -24,7 +24,10 @@ set(LOG_COMMON_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp diff --git a/test/unittest/logging/log_macros/CMakeLists.txt b/test/unittest/logging/log_macros/CMakeLists.txt index cce50e33a04..f95889fbb8c 100644 --- a/test/unittest/logging/log_macros/CMakeLists.txt +++ b/test/unittest/logging/log_macros/CMakeLists.txt @@ -22,7 +22,10 @@ set(LOG_COMMON_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp diff --git a/test/unittest/rtps/builtin/CMakeLists.txt b/test/unittest/rtps/builtin/CMakeLists.txt index bd1d4e3fc2f..bc63d2f3bde 100644 --- a/test/unittest/rtps/builtin/CMakeLists.txt +++ b/test/unittest/rtps/builtin/CMakeLists.txt @@ -51,10 +51,12 @@ set(BUILTIN_DATA_SERIALIZATION_TESTS_SOURCE BuiltinDataSerializationTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp diff --git a/test/unittest/rtps/common/CMakeLists.txt b/test/unittest/rtps/common/CMakeLists.txt index 37ecccd9d98..6df9067abd0 100644 --- a/test/unittest/rtps/common/CMakeLists.txt +++ b/test/unittest/rtps/common/CMakeLists.txt @@ -19,8 +19,12 @@ set(GUID_UTILS_TESTS_SOURCE GuidUtilsTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/OStreamConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/GuidPrefix_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -46,7 +50,10 @@ set(PORTPARAMETERSTESTS_SOURCE PortParametersTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) diff --git a/test/unittest/rtps/discovery/CMakeLists.txt b/test/unittest/rtps/discovery/CMakeLists.txt index 951c8194118..731b6970db8 100644 --- a/test/unittest/rtps/discovery/CMakeLists.txt +++ b/test/unittest/rtps/discovery/CMakeLists.txt @@ -49,7 +49,9 @@ set(EDPTESTS_SOURCE EdpTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -71,7 +73,7 @@ target_compile_definitions(EdpTests PRIVATE ) target_include_directories(EdpTests PRIVATE ${PROJECT_SOURCE_DIR}/test/mock/rtps/PDP - ${PROJECT_SOURCE_DIR}/test/mock/rtps/ExternalLocatorsProcessor + ${PROJECT_SOURCE_DIR}/test/mock/rtps/external_locators ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderProxyData @@ -168,8 +170,10 @@ set(PDPTESTS_SOURCE PDPTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -189,7 +193,7 @@ target_compile_definitions(PDPTests PRIVATE FASTRTPS_NO_LIB ) target_include_directories(PDPTests PRIVATE ${PROJECT_SOURCE_DIR}/test/mock/rtps/BuiltinProtocols - ${PROJECT_SOURCE_DIR}/test/mock/rtps/ExternalLocatorsProcessor + ${PROJECT_SOURCE_DIR}/test/mock/rtps/external_locators ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/EDP diff --git a/test/unittest/rtps/flowcontrol/CMakeLists.txt b/test/unittest/rtps/flowcontrol/CMakeLists.txt index af55ebf2122..d378dce10fc 100644 --- a/test/unittest/rtps/flowcontrol/CMakeLists.txt +++ b/test/unittest/rtps/flowcontrol/CMakeLists.txt @@ -25,7 +25,9 @@ set(FLOWCONTROLLER_COMMON_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LocatorSelectorSender.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp diff --git a/test/unittest/rtps/history/CMakeLists.txt b/test/unittest/rtps/history/CMakeLists.txt index 018a9f50e2a..c1fec50635b 100644 --- a/test/unittest/rtps/history/CMakeLists.txt +++ b/test/unittest/rtps/history/CMakeLists.txt @@ -22,7 +22,9 @@ set(READERHISTORYTESTS_SOURCE ReaderHistoryTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/CacheChangePool.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/History.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/ReaderHistory.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) @@ -35,7 +37,9 @@ set(BASICPOOLSTESTS_SOURCE BasicPoolsTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/CacheChangePool.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) @@ -48,7 +52,9 @@ set(CACHECHANGEPOOLTESTS_SOURCE CacheChangePoolTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/CacheChangePool.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) @@ -63,7 +69,9 @@ set(TOPICPAYLOADPOOLTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/TopicPayloadPool.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/TopicPayloadPoolRegistry.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) diff --git a/test/unittest/rtps/network/CMakeLists.txt b/test/unittest/rtps/network/CMakeLists.txt index 76324e2548a..6cd0b2dbd7c 100644 --- a/test/unittest/rtps/network/CMakeLists.txt +++ b/test/unittest/rtps/network/CMakeLists.txt @@ -27,13 +27,14 @@ set(NETWORKFACTORYTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageCreator.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/TCPControlMessage.cpp @@ -44,6 +45,7 @@ set(NETWORKFACTORYTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv4Transport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv6Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv4Transport.cpp @@ -99,8 +101,8 @@ target_link_libraries(NetworkFactoryTests fastcdr foonathan_memory if(QNX) target_link_libraries(NetworkFactoryTests socket) endif() -add_executable(ExternalLocatorsProcessorTests - ExternalLocatorsProcessorTests.cpp +add_executable(ExternalLocatorsTests + ExternalLocatorsTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/AnnotationParameterValue.cpp ${PROJECT_SOURCE_DIR}/src/cpp/dynamic-types/BuiltinAnnotationsTypeObject.cpp @@ -133,8 +135,10 @@ add_executable(ExternalLocatorsProcessorTests ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/ExternalLocatorsProcessor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/external_locators.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -142,13 +146,13 @@ add_executable(ExternalLocatorsProcessorTests ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ) -target_compile_definitions(ExternalLocatorsProcessorTests PRIVATE +target_compile_definitions(ExternalLocatorsTests PRIVATE BOOST_ASIO_STANDALONE ASIO_STANDALONE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) -target_include_directories(ExternalLocatorsProcessorTests PRIVATE +target_include_directories(ExternalLocatorsTests PRIVATE ${Asio_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/test/mock/rtps/ParticipantProxyData ${PROJECT_SOURCE_DIR}/test/mock/rtps/ReaderProxyData @@ -156,18 +160,18 @@ target_include_directories(ExternalLocatorsProcessorTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ) -target_link_libraries(ExternalLocatorsProcessorTests fastcdr +target_link_libraries(ExternalLocatorsTests fastcdr GTest::gtest ${MOCKS} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) if(QNX) - target_link_libraries(ExternalLocatorsProcessorTests socket) + target_link_libraries(ExternalLocatorsTests socket) endif() if(WIN32) add_definitions(-D_WIN32_WINNT=0x0601) target_link_libraries(NetworkFactoryTests IPHLPAPI shlwapi) # Later so mocks have precedence - target_link_libraries(ExternalLocatorsProcessorTests IPHLPAPI shlwapi) # Later so mocks have precedence + target_link_libraries(ExternalLocatorsTests IPHLPAPI shlwapi) # Later so mocks have precedence endif() gtest_discover_tests(NetworkFactoryTests) -gtest_discover_tests(ExternalLocatorsProcessorTests) +gtest_discover_tests(ExternalLocatorsTests) diff --git a/test/unittest/rtps/network/ExternalLocatorsProcessorTests.cpp b/test/unittest/rtps/network/ExternalLocatorsTests.cpp similarity index 96% rename from test/unittest/rtps/network/ExternalLocatorsProcessorTests.cpp rename to test/unittest/rtps/network/ExternalLocatorsTests.cpp index 1ceab253075..cf643b0f1a5 100644 --- a/test/unittest/rtps/network/ExternalLocatorsProcessorTests.cpp +++ b/test/unittest/rtps/network/ExternalLocatorsTests.cpp @@ -17,9 +17,10 @@ #include #include -#include +#include using namespace eprosima::fastdds::rtps; +using namespace eprosima::fastdds::rtps::network; using namespace eprosima::fastrtps::rtps; // -------------------- Auxiliary methods to compare locator lists -------------------- @@ -68,7 +69,7 @@ void single_participant_check( const RemoteLocatorList& def_check_locators, const RemoteLocatorList& meta_check_locators) { - ExternalLocatorsProcessor::add_external_locators(pdata, meta_ext_locators, def_ext_locators); + external_locators::add_external_locators(pdata, meta_ext_locators, def_ext_locators); ASSERT_TRUE(pdata.default_locators == def_check_locators); ASSERT_TRUE(pdata.metatraffic_locators == meta_check_locators); } @@ -174,7 +175,7 @@ void test_add_external_locators_participant( } } -TEST(ExternalLocatorsProcessorTests, add_external_locators_participant) +TEST(ExternalLocatorsTests, add_external_locators_participant) { Locator multicast_loc; { @@ -240,7 +241,7 @@ void single_endpoint_check( const ExternalLocators& ext_locators, const RemoteLocatorList& check_locators) { - ExternalLocatorsProcessor::add_external_locators(rdata, ext_locators); + external_locators::add_external_locators(rdata, ext_locators); ASSERT_TRUE(rdata.remote_locators() == check_locators); } @@ -332,12 +333,12 @@ void test_add_external_locators_endpoint() } } -TEST(ExternalLocatorsProcessorTests, add_external_locators_reader) +TEST(ExternalLocatorsTests, add_external_locators_reader) { test_add_external_locators_endpoint(); } -TEST(ExternalLocatorsProcessorTests, add_external_locators_writer) +TEST(ExternalLocatorsTests, add_external_locators_writer) { test_add_external_locators_endpoint(); } @@ -582,14 +583,14 @@ void test_matching_locators_scenario( entry.multicast = discovered_data.metatraffic_locators.multicast; entry.unicast = discovered_data.metatraffic_locators.unicast; - ExternalLocatorsProcessor::filter_remote_locators(entry, meta_ext_locators, ignore_non_matching); + external_locators::filter_remote_locators(entry, meta_ext_locators, ignore_non_matching); ASSERT_TRUE(entry.multicast == discovered_data.metatraffic_locators.multicast); ASSERT_EQ(entry.unicast.size(), 1u); ASSERT_EQ(entry.unicast[0], expected_result.metatraffic); ParticipantProxyData filtered_data = discovered_data; - ExternalLocatorsProcessor::filter_remote_locators( + external_locators::filter_remote_locators( filtered_data, meta_ext_locators, user_ext_locators, ignore_non_matching); @@ -623,7 +624,7 @@ void test_matching_locators_scenario( entry.multicast = filtered_data.metatraffic_locators.multicast; entry.unicast = filtered_data.metatraffic_locators.unicast; - ExternalLocatorsProcessor::filter_remote_locators(entry, meta_ext_locators, ignore_non_matching); + external_locators::filter_remote_locators(entry, meta_ext_locators, ignore_non_matching); ASSERT_TRUE(entry.multicast == zz_discovered_data.metatraffic_locators.multicast); if (ignore_non_matching) @@ -636,7 +637,7 @@ void test_matching_locators_scenario( ASSERT_EQ(entry.unicast[0], zz_address.metatraffic); } - ExternalLocatorsProcessor::filter_remote_locators( + external_locators::filter_remote_locators( filtered_data, meta_ext_locators, user_ext_locators, ignore_non_matching); ASSERT_TRUE( @@ -662,7 +663,7 @@ void test_matching_locators_scenario( entry.multicast = filtered_data.metatraffic_locators.multicast; entry.unicast = filtered_data.metatraffic_locators.unicast; - ExternalLocatorsProcessor::filter_remote_locators(entry, zz_meta_locators, ignore_non_matching); + external_locators::filter_remote_locators(entry, zz_meta_locators, ignore_non_matching); ASSERT_TRUE(entry.multicast == node.announced_data.metatraffic_locators.multicast); if (ignore_non_matching) @@ -674,7 +675,7 @@ void test_matching_locators_scenario( ASSERT_TRUE(entry.unicast == node.announced_data.metatraffic_locators.unicast); } - ExternalLocatorsProcessor::filter_remote_locators( + external_locators::filter_remote_locators( filtered_data, zz_meta_locators, zz_user_locators, ignore_non_matching); ASSERT_TRUE( @@ -696,13 +697,13 @@ void test_matching_locators_scenario( } } -TEST(ExternalLocatorsProcessorTests, matching_locators_scenario) +TEST(ExternalLocatorsTests, matching_locators_scenario) { test_matching_locators_scenario(true); test_matching_locators_scenario(false); } -TEST(ExternalLocatorsProcessorTests, matching_locators_mask_test) +TEST(ExternalLocatorsTests, matching_locators_mask_test) { struct TestCase { @@ -796,7 +797,7 @@ TEST(ExternalLocatorsProcessorTests, matching_locators_mask_test) LocatorSelectorEntry remote(4u, 1u); remote.unicast.push_back(remote_locator); - ExternalLocatorsProcessor::filter_remote_locators(remote, local, true); + external_locators::filter_remote_locators(remote, local, true); if (test.should_match) { ASSERT_EQ(remote.unicast.size(), 1u); diff --git a/test/unittest/rtps/persistence/CMakeLists.txt b/test/unittest/rtps/persistence/CMakeLists.txt index f9ee9b35f5d..1db8d9a10a0 100644 --- a/test/unittest/rtps/persistence/CMakeLists.txt +++ b/test/unittest/rtps/persistence/CMakeLists.txt @@ -26,10 +26,12 @@ if(SQLITE3_SUPPORT) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/CacheChangePool.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/PersistenceFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/sqlite3.c ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/SQLite3PersistenceService.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp diff --git a/test/unittest/rtps/reader/CMakeLists.txt b/test/unittest/rtps/reader/CMakeLists.txt index 4acb26b2eb4..80241b460e2 100644 --- a/test/unittest/rtps/reader/CMakeLists.txt +++ b/test/unittest/rtps/reader/CMakeLists.txt @@ -24,7 +24,9 @@ set(WRITERPROXYTESTS_SOURCE WriterProxyTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp @@ -42,7 +44,7 @@ target_compile_definitions(WriterProxyTests PRIVATE target_include_directories(WriterProxyTests PRIVATE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint - ${PROJECT_SOURCE_DIR}/test/mock/rtps/ExternalLocatorsProcessor + ${PROJECT_SOURCE_DIR}/test/mock/rtps/external_locators ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSWriter ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl @@ -71,10 +73,12 @@ set(WRITERPROXYSTOPTEST_SOURCE WriterProxyStopTest.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp @@ -93,7 +97,7 @@ target_compile_definitions(WriterProxyStopTest PRIVATE target_include_directories(WriterProxyStopTest PRIVATE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint - ${PROJECT_SOURCE_DIR}/test/mock/rtps/ExternalLocatorsProcessor + ${PROJECT_SOURCE_DIR}/test/mock/rtps/external_locators ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSWriter ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl @@ -120,9 +124,11 @@ set(WRITERPROXYACKNACKTESTS_SOURCE WriterProxyAcknackTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp @@ -140,7 +146,7 @@ target_compile_definitions(WriterProxyAcknackTests PRIVATE target_include_directories(WriterProxyAcknackTests PRIVATE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint - ${PROJECT_SOURCE_DIR}/test/mock/rtps/ExternalLocatorsProcessor + ${PROJECT_SOURCE_DIR}/test/mock/rtps/external_locators ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSReader ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSWriter ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl diff --git a/test/unittest/rtps/resources/timedevent/CMakeLists.txt b/test/unittest/rtps/resources/timedevent/CMakeLists.txt index 691fd515995..09c62349a23 100644 --- a/test/unittest/rtps/resources/timedevent/CMakeLists.txt +++ b/test/unittest/rtps/resources/timedevent/CMakeLists.txt @@ -20,10 +20,12 @@ set(TIMEDEVENTTESTS_SOURCE mock/MockEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp diff --git a/test/unittest/rtps/security/CMakeLists.txt b/test/unittest/rtps/security/CMakeLists.txt index afae2b3da90..b69d1082dc1 100644 --- a/test/unittest/rtps/security/CMakeLists.txt +++ b/test/unittest/rtps/security/CMakeLists.txt @@ -32,13 +32,15 @@ set(SOURCES_SECURITY_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/TopicPayloadPool.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/TopicPayloadPoolRegistry.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/exceptions/SecurityException.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/logging/Logging.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/SecurityManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LocatorSelectorSender.cpp ${PROJECT_SOURCE_DIR}/src/cpp/security/cryptography/AESGCMGMAC_Types.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp diff --git a/test/unittest/rtps/writer/CMakeLists.txt b/test/unittest/rtps/writer/CMakeLists.txt index 7bf179d17af..fe5b87abee8 100644 --- a/test/unittest/rtps/writer/CMakeLists.txt +++ b/test/unittest/rtps/writer/CMakeLists.txt @@ -23,7 +23,9 @@ set(WRITERPROXYTESTS_SOURCE ReaderProxyTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LocatorSelectorSender.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/ReaderProxy.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp @@ -74,10 +76,12 @@ set(LIVELINESSMANAGERTESTS_SOURCE LivelinessManagerTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LivelinessManager.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp diff --git a/test/unittest/security/accesscontrol/CMakeLists.txt b/test/unittest/security/accesscontrol/CMakeLists.txt index aa162831a09..3395b01042e 100644 --- a/test/unittest/security/accesscontrol/CMakeLists.txt +++ b/test/unittest/security/accesscontrol/CMakeLists.txt @@ -31,13 +31,15 @@ set(COMMON_SOURCES_ACCESS_CONTROL_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Token.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/exceptions/Exception.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/common/SharedSecretHandle.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/exceptions/SecurityException.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/logging/Logging.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp ) @@ -132,7 +134,10 @@ add_executable( # src files ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/security/accesscontrol/DistinguishedName.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp diff --git a/test/unittest/security/authentication/CMakeLists.txt b/test/unittest/security/authentication/CMakeLists.txt index 4b7c1907aad..dc52d74a3e8 100644 --- a/test/unittest/security/authentication/CMakeLists.txt +++ b/test/unittest/security/authentication/CMakeLists.txt @@ -33,13 +33,15 @@ set(COMMON_SOURCES_AUTH_PLUGIN_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Token.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/exceptions/Exception.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/common/SharedSecretHandle.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/exceptions/SecurityException.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/logging/Logging.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp ) diff --git a/test/unittest/security/cryptography/CMakeLists.txt b/test/unittest/security/cryptography/CMakeLists.txt index a3bbc684c66..0c963d3fcee 100644 --- a/test/unittest/security/cryptography/CMakeLists.txt +++ b/test/unittest/security/cryptography/CMakeLists.txt @@ -26,9 +26,11 @@ set(COMMON_SOURCES_CRYPTO_PLUGIN_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Token.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/exceptions/Exception.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/common/SharedSecretHandle.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/exceptions/SecurityException.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/security/cryptography/AESGCMGMAC_KeyExchange.cpp ${PROJECT_SOURCE_DIR}/src/cpp/security/cryptography/AESGCMGMAC_KeyFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/security/cryptography/AESGCMGMAC_Transform.cpp diff --git a/test/unittest/security/logging/CMakeLists.txt b/test/unittest/security/logging/CMakeLists.txt index e8d03ec820d..83ae18ba4a0 100644 --- a/test/unittest/security/logging/CMakeLists.txt +++ b/test/unittest/security/logging/CMakeLists.txt @@ -26,8 +26,10 @@ set(COMMON_SOURCES_LOGGING_PLUGIN_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Token.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/exceptions/Exception.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/exceptions/SecurityException.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp diff --git a/test/unittest/statistics/dds/CMakeLists.txt b/test/unittest/statistics/dds/CMakeLists.txt index 1f9cc930239..2a4c12dd566 100644 --- a/test/unittest/statistics/dds/CMakeLists.txt +++ b/test/unittest/statistics/dds/CMakeLists.txt @@ -225,10 +225,11 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageCreator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageGroup.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/SendBuffersManager.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/ExternalLocatorsProcessor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/ReceiverResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/external_locators.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/participant/RTPSParticipant.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/participant/RTPSParticipantImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/PersistenceFactory.cpp @@ -244,8 +245,8 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/RTPSDomain.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp @@ -257,6 +258,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv4Transport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv6Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv4Transport.cpp @@ -422,10 +424,11 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageCreator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageGroup.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/SendBuffersManager.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/ExternalLocatorsProcessor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/ReceiverResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/external_locators.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/participant/RTPSParticipant.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/participant/RTPSParticipantImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/PersistenceFactory.cpp @@ -442,6 +445,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/RTPSDomain.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp diff --git a/test/unittest/statistics/rtps/CMakeLists.txt b/test/unittest/statistics/rtps/CMakeLists.txt index f66c7cde181..c834f541111 100644 --- a/test/unittest/statistics/rtps/CMakeLists.txt +++ b/test/unittest/statistics/rtps/CMakeLists.txt @@ -111,11 +111,13 @@ set(STATISTICS_RTPS_MONITORSERVICETESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/TopicPayloadPool.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/TopicPayloadPoolRegistry.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LocatorSelectorSender.cpp ${PROJECT_SOURCE_DIR}/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp ${PROJECT_SOURCE_DIR}/src/cpp/statistics/rtps/monitor-service/MonitorServiceListener.cpp @@ -144,7 +146,7 @@ target_compile_definitions(MonitorServiceTests PRIVATE FASTRTPS_NO_LIB target_include_directories(MonitorServiceTests PRIVATE mock/StatisticsBase ${PROJECT_SOURCE_DIR}/test/mock/rtps/BuiltinProtocols - ${PROJECT_SOURCE_DIR}/test/mock/rtps/ExternalLocatorsProcessor + ${PROJECT_SOURCE_DIR}/test/mock/rtps/external_locators ${PROJECT_SOURCE_DIR}/test/mock/rtps/RTPSParticipantImpl ${PROJECT_SOURCE_DIR}/test/mock/rtps/Endpoint ${PROJECT_SOURCE_DIR}/test/mock/rtps/EDP diff --git a/test/unittest/transport/CMakeLists.txt b/test/unittest/transport/CMakeLists.txt index c574e304580..3e92b63a9c5 100644 --- a/test/unittest/transport/CMakeLists.txt +++ b/test/unittest/transport/CMakeLists.txt @@ -77,20 +77,21 @@ set(UDPV4TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv4Transport.cpp - ${TCPTransportInterface_SOURCE} ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp + ${TCPTransportInterface_SOURCE} ) set(UDPV6TESTS_SOURCE @@ -106,21 +107,22 @@ set(UDPV6TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPChannelResource.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv4Transport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv6Transport.cpp - ${TCPTransportInterface_SOURCE} + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp + ${TCPTransportInterface_SOURCE} ) set(TCPV4TESTS_SOURCE @@ -139,14 +141,14 @@ set(TCPV4TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageCreator.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/TCPControlMessage.cpp @@ -156,6 +158,7 @@ set(TCPV4TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv4Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -187,14 +190,14 @@ set(TCPV6TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageCreator.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/TCPControlMessage.cpp @@ -204,6 +207,7 @@ set(TCPV6TESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv6Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp @@ -233,19 +237,20 @@ set(SHAREDMEMTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransportDescriptor.cpp - ${TCPTransportInterface_SOURCE} + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp + ${TCPTransportInterface_SOURCE} ) if(ANDROID) diff --git a/test/unittest/utils/CMakeLists.txt b/test/unittest/utils/CMakeLists.txt index 99abc53842e..8cacc49d627 100644 --- a/test/unittest/utils/CMakeLists.txt +++ b/test/unittest/utils/CMakeLists.txt @@ -23,7 +23,10 @@ set(STRINGMATCHINGTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp @@ -45,7 +48,10 @@ set(LOCATORTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) @@ -60,7 +66,10 @@ set(SYSTEMINFOTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/log/StdoutErrConsumer.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp) diff --git a/test/unittest/xmlparser/CMakeLists.txt b/test/unittest/xmlparser/CMakeLists.txt index 7775fc29615..b583b524d43 100644 --- a/test/unittest/xmlparser/CMakeLists.txt +++ b/test/unittest/xmlparser/CMakeLists.txt @@ -108,7 +108,9 @@ set(XMLPROFILEPARSER_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLElementParser.cpp @@ -219,7 +221,9 @@ set(XMLPARSER_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/ThroughputControllerDescriptor.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLElementParser.cpp @@ -354,7 +358,9 @@ set(XMLENDPOINTPARSERTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLElementParser.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLEndpointParser.cpp diff --git a/test/unittest/xmlparser/XMLParserTests.cpp b/test/unittest/xmlparser/XMLParserTests.cpp index aa8fe355741..ec2c085250b 100644 --- a/test/unittest/xmlparser/XMLParserTests.cpp +++ b/test/unittest/xmlparser/XMLParserTests.cpp @@ -23,7 +23,9 @@ #include #include #include -#include +#include +#include +#include #include #include #include @@ -868,7 +870,9 @@ TEST_F(XMLParserTests, loadXMLProfiles) */ TEST_F(XMLParserTests, parseXMLTransportData) { - eprosima::fastdds::rtps::ThreadSettings modified_thread_settings; + using namespace eprosima::fastdds::rtps; + + ThreadSettings modified_thread_settings; modified_thread_settings.scheduling_policy = 12; modified_thread_settings.priority = 12; modified_thread_settings.affinity = 12; @@ -968,10 +972,10 @@ TEST_F(XMLParserTests, parseXMLTransportData) EXPECT_EQ(pUDPv4Desc->interfaceWhiteList[1], "127.0.0.1"); EXPECT_EQ(pUDPv4Desc->interfaceWhiteList[2], "wlp0s20f3"); EXPECT_EQ(pUDPv4Desc->interfaceWhiteList[3], "lo"); - EXPECT_EQ(pUDPv4Desc->netmask_filter, eprosima::fastdds::rtps::NetmaskFilterKind::ON); - EXPECT_EQ(pUDPv4Desc->interface_allowlist[0], std::make_pair(std::string("wlp59s0"), eprosima::fastdds::rtps::NetmaskFilterKind::ON)); - EXPECT_EQ(pUDPv4Desc->interface_allowlist[1], std::make_pair(std::string("127.0.0.1"), eprosima::fastdds::rtps::NetmaskFilterKind::AUTO)); - EXPECT_EQ(pUDPv4Desc->interface_blocklist[0], "docker0"); + EXPECT_EQ(pUDPv4Desc->netmask_filter, NetmaskFilterKind::ON); + EXPECT_EQ(pUDPv4Desc->interface_allowlist[0], AllowedNetworkInterface("wlp59s0", NetmaskFilterKind::ON)); + EXPECT_EQ(pUDPv4Desc->interface_allowlist[1], AllowedNetworkInterface("127.0.0.1", NetmaskFilterKind::AUTO)); + EXPECT_EQ(pUDPv4Desc->interface_blocklist[0], BlockedNetworkInterface("docker0")); EXPECT_EQ(pUDPv4Desc->m_output_udp_socket, 5101u); EXPECT_EQ(pUDPv4Desc->default_reception_threads(), modified_thread_settings); EXPECT_EQ(pUDPv4Desc->get_thread_config_for_port(12345), modified_thread_settings); @@ -997,10 +1001,10 @@ TEST_F(XMLParserTests, parseXMLTransportData) EXPECT_EQ(pUDPv6Desc->interfaceWhiteList[1], "127.0.0.1"); EXPECT_EQ(pUDPv6Desc->interfaceWhiteList[2], "wlp0s20f3"); EXPECT_EQ(pUDPv6Desc->interfaceWhiteList[3], "lo"); - EXPECT_EQ(pUDPv6Desc->netmask_filter, eprosima::fastdds::rtps::NetmaskFilterKind::ON); - EXPECT_EQ(pUDPv6Desc->interface_allowlist[0], std::make_pair(std::string("wlp59s0"), eprosima::fastdds::rtps::NetmaskFilterKind::ON)); - EXPECT_EQ(pUDPv6Desc->interface_allowlist[1], std::make_pair(std::string("127.0.0.1"), eprosima::fastdds::rtps::NetmaskFilterKind::AUTO)); - EXPECT_EQ(pUDPv6Desc->interface_blocklist[0], "docker0"); + EXPECT_EQ(pUDPv6Desc->netmask_filter, NetmaskFilterKind::ON); + EXPECT_EQ(pUDPv6Desc->interface_allowlist[0], AllowedNetworkInterface("wlp59s0", NetmaskFilterKind::ON)); + EXPECT_EQ(pUDPv6Desc->interface_allowlist[1], AllowedNetworkInterface("127.0.0.1", NetmaskFilterKind::AUTO)); + EXPECT_EQ(pUDPv6Desc->interface_blocklist[0], BlockedNetworkInterface("docker0")); EXPECT_EQ(pUDPv6Desc->m_output_udp_socket, 5101u); EXPECT_EQ(pUDPv6Desc->default_reception_threads(), modified_thread_settings); EXPECT_EQ(pUDPv6Desc->get_thread_config_for_port(12345), modified_thread_settings); @@ -1087,7 +1091,7 @@ TEST_F(XMLParserTests, parseXMLTransportData) \ \ "; - constexpr size_t xml_len {3500}; + constexpr size_t xml_len {4000}; char xml[xml_len]; // TCPv4 @@ -1105,10 +1109,10 @@ TEST_F(XMLParserTests, parseXMLTransportData) EXPECT_EQ(pTCPv4Desc->max_initial_peers_range(), 100u); EXPECT_EQ(pTCPv4Desc->interfaceWhiteList[0], "192.168.1.41"); EXPECT_EQ(pTCPv4Desc->interfaceWhiteList[1], "lo"); - EXPECT_EQ(pTCPv4Desc->netmask_filter, eprosima::fastdds::rtps::NetmaskFilterKind::ON); - EXPECT_EQ(pTCPv4Desc->interface_allowlist[0], std::make_pair(std::string("wlp59s0"), eprosima::fastdds::rtps::NetmaskFilterKind::ON)); - EXPECT_EQ(pTCPv4Desc->interface_allowlist[1], std::make_pair(std::string("127.0.0.1"), eprosima::fastdds::rtps::NetmaskFilterKind::AUTO)); - EXPECT_EQ(pTCPv4Desc->interface_blocklist[0], "docker0"); + EXPECT_EQ(pTCPv4Desc->netmask_filter, NetmaskFilterKind::ON); + EXPECT_EQ(pTCPv4Desc->interface_allowlist[0], AllowedNetworkInterface("wlp59s0", NetmaskFilterKind::ON)); + EXPECT_EQ(pTCPv4Desc->interface_allowlist[1], AllowedNetworkInterface("127.0.0.1", NetmaskFilterKind::AUTO)); + EXPECT_EQ(pTCPv4Desc->interface_blocklist[0], BlockedNetworkInterface("docker0")); EXPECT_EQ(pTCPv4Desc->wan_addr[0], (octet)80); EXPECT_EQ(pTCPv4Desc->wan_addr[1], (octet)80); EXPECT_EQ(pTCPv4Desc->wan_addr[2], (octet)55); @@ -1145,10 +1149,10 @@ TEST_F(XMLParserTests, parseXMLTransportData) EXPECT_EQ(pTCPv6Desc->max_initial_peers_range(), 100u); EXPECT_EQ(pTCPv6Desc->interfaceWhiteList[0], "192.168.1.41"); EXPECT_EQ(pTCPv6Desc->interfaceWhiteList[1], "lo"); - EXPECT_EQ(pTCPv6Desc->netmask_filter, eprosima::fastdds::rtps::NetmaskFilterKind::ON); - EXPECT_EQ(pTCPv6Desc->interface_allowlist[0], std::make_pair(std::string("wlp59s0"), eprosima::fastdds::rtps::NetmaskFilterKind::ON)); - EXPECT_EQ(pTCPv6Desc->interface_allowlist[1], std::make_pair(std::string("127.0.0.1"), eprosima::fastdds::rtps::NetmaskFilterKind::AUTO)); - EXPECT_EQ(pTCPv6Desc->interface_blocklist[0], "docker0"); + EXPECT_EQ(pTCPv6Desc->netmask_filter, NetmaskFilterKind::ON); + EXPECT_EQ(pTCPv6Desc->interface_allowlist[0], AllowedNetworkInterface("wlp59s0", NetmaskFilterKind::ON)); + EXPECT_EQ(pTCPv6Desc->interface_allowlist[1], AllowedNetworkInterface("127.0.0.1", NetmaskFilterKind::AUTO)); + EXPECT_EQ(pTCPv6Desc->interface_blocklist[0], BlockedNetworkInterface("docker0")); EXPECT_EQ(pTCPv6Desc->keep_alive_frequency_ms, 5000u); EXPECT_EQ(pTCPv6Desc->keep_alive_timeout_ms, 25000u); EXPECT_EQ(pTCPv6Desc->max_logical_port, 9000u); @@ -1215,8 +1219,8 @@ TEST_F(XMLParserTests, parseXMLTransportData) ASSERT_EQ(tinyxml2::XMLError::XML_SUCCESS, xml_doc.Parse(xml)); titleElement = xml_doc.RootElement(); EXPECT_EQ(XMLP_ret::XML_OK, XMLParserTest::parseXMLTransportData_wrapper(titleElement)); - std::shared_ptr pSHMDesc = - std::dynamic_pointer_cast( + std::shared_ptr pSHMDesc = + std::dynamic_pointer_cast( xmlparser::XMLProfileManager::getTransportById("TransportId1")); EXPECT_EQ(pSHMDesc->segment_size(), 262144u); EXPECT_EQ(pSHMDesc->port_queue_capacity(), 512u); diff --git a/test/unittest/xmlparser/XMLProfileParserTests.cpp b/test/unittest/xmlparser/XMLProfileParserTests.cpp index 260d98088e1..74de575eab8 100644 --- a/test/unittest/xmlparser/XMLProfileParserTests.cpp +++ b/test/unittest/xmlparser/XMLProfileParserTests.cpp @@ -28,7 +28,9 @@ #include #include #include -#include +#include +#include +#include #include #include #include @@ -1713,6 +1715,8 @@ TEST_F(XMLProfileParserBasicTests, tls_config) TEST_F(XMLProfileParserBasicTests, UDP_transport_descriptors_config) { + using namespace eprosima::fastdds::rtps; + ASSERT_EQ( xmlparser::XMLP_ret::XML_OK, xmlparser::XMLProfileManager::loadXMLFile("UDP_transport_descriptors_config_profile.xml")); @@ -1731,10 +1735,10 @@ TEST_F(XMLProfileParserBasicTests, UDP_transport_descriptors_config) EXPECT_EQ(descriptor->interfaceWhiteList.size(), 2u); EXPECT_EQ(descriptor->interfaceWhiteList[0], "192.168.1.41"); EXPECT_EQ(descriptor->interfaceWhiteList[1], "lo"); - EXPECT_EQ(descriptor->netmask_filter, eprosima::fastdds::rtps::NetmaskFilterKind::ON); - EXPECT_EQ(descriptor->interface_allowlist[0], std::make_pair(std::string("wlp59s0"), eprosima::fastdds::rtps::NetmaskFilterKind::ON)); - EXPECT_EQ(descriptor->interface_allowlist[1], std::make_pair(std::string("127.0.0.1"), eprosima::fastdds::rtps::NetmaskFilterKind::AUTO)); - EXPECT_EQ(descriptor->interface_blocklist[0], "docker0"); + EXPECT_EQ(descriptor->netmask_filter, NetmaskFilterKind::ON); + EXPECT_EQ(descriptor->interface_allowlist[0], AllowedNetworkInterface("wlp59s0", NetmaskFilterKind::ON)); + EXPECT_EQ(descriptor->interface_allowlist[1], AllowedNetworkInterface("127.0.0.1", NetmaskFilterKind::AUTO)); + EXPECT_EQ(descriptor->interface_blocklist[0], BlockedNetworkInterface("docker0")); EXPECT_EQ(descriptor->m_output_udp_socket, 5101u); } diff --git a/test/unittest/xtypes/CMakeLists.txt b/test/unittest/xtypes/CMakeLists.txt index 0bfefd554b6..6516e3004b1 100644 --- a/test/unittest/xtypes/CMakeLists.txt +++ b/test/unittest/xtypes/CMakeLists.txt @@ -49,7 +49,9 @@ set(XTYPES_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetmaskFilterUtils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp