From 0c6fba9fb692aad4e4d52ffaf1efdbd3064cfb7b Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Wed, 21 Feb 2024 14:56:29 +0100 Subject: [PATCH 01/34] Refs #20493: Add Builtin config options Signed-off-by: cferreiragonz --- .../rtps/attributes/BuiltinTransports.hpp | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/include/fastdds/rtps/attributes/BuiltinTransports.hpp b/include/fastdds/rtps/attributes/BuiltinTransports.hpp index 6f297d77567..13e36d1c9fb 100644 --- a/include/fastdds/rtps/attributes/BuiltinTransports.hpp +++ b/include/fastdds/rtps/attributes/BuiltinTransports.hpp @@ -22,10 +22,67 @@ #include #include +#include + namespace eprosima { namespace fastdds { namespace rtps { + +/** + * @brief Options for configuring the built-in transports when using LARGE_DATA mode. + */ +struct RTPS_DllAPI BuiltinTransportsOptions +{ + //! Whether to use non-blocking send operation. + bool non_blocking_send = false; + + /** + * @brief The maximum message size to be used. + * + * It specifies the maximum message size that will be used by the Network Factory + * to register every transport. + * + */ + uint32_t maxMessageSize = 65500; + + /** + * @brief The value used to configure the send and receive fuffer sizes of the sockets. + * + * It specifies the value that will be used to configure the send and receive buffer sizes of the sockets + * used by the transports created with the builtin transports. + * + */ + uint32_t sockets_buffer_size = 0; +}; + +/** + * @brief Equal to operator. + * + * @param bto1 Left hand side BuiltinTransportsOptions being compared. + * @param bto2 Right hand side BuiltinTransportsOptions being compared. + * @return true if \c bto1 is equal to \c bto2. + * @return false otherwise. + */ + inline bool operator ==( + const BuiltinTransportsOptions& bto1, + const BuiltinTransportsOptions& bto2) + { + if (bto1.non_blocking_send != bto2.non_blocking_send) + { + return false; + } + if (bto1.maxMessageSize != bto2.maxMessageSize) + { + return false; + } + if (bto1.sockets_buffer_size != bto2.sockets_buffer_size) + { + return false; + } + return true; + } + /** * Defines the kind of transports automatically instantiated upon the creation of a participant */ From e790c71093eca25acc8c64ba7728da3e75dcb5a4 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Wed, 21 Feb 2024 14:54:45 +0100 Subject: [PATCH 02/34] Refs #20493: Overload of RTPS API Signed-off-by: cferreiragonz --- .../attributes/RTPSParticipantAttributes.h | 13 +++++-- .../attributes/RTPSParticipantAttributes.cpp | 34 ++++++++++++++----- .../attributes/RTPSParticipantAttributes.h | 22 ++++++++++++ 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h index fe8415c139b..32440e0a6dc 100644 --- a/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/include/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -487,12 +487,15 @@ class RTPSParticipantAttributes } /** - * Provides a way of easily configuring transport related configuration on certain pre-defined scenarios. + * Provides a way of easily configuring transport related configuration on certain pre-defined scenarios with + * certain options. * * @param transports Defines the transport configuration scenario to setup. + * @param options Defines the options to be used in the transport configuration. */ RTPS_DllAPI void setup_transports( - fastdds::rtps::BuiltinTransports transports); + fastdds::rtps::BuiltinTransports transports, + const fastdds::rtps::BuiltinTransportsOptions& options = fastdds::rtps::BuiltinTransportsOptions()); /** * Default list of Unicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the case @@ -600,6 +603,12 @@ class RTPSParticipantAttributes fastdds::rtps::ThreadSettings security_log_thread; #endif // if HAVE_SECURITY + /*! Maximum message size used to avoid fragmentation, setted ONLY in LARGE_DATA. If this value is + * not zero, the network factory will allow the initialization of UDP transports with maxMessageSize + * higher than 65500K. + */ + uint32_t max_msg_size_no_frag = 0; + private: //! Name of the participant. diff --git a/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp b/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp index afde927e27c..4a3bfff8af5 100644 --- a/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp +++ b/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp @@ -269,41 +269,59 @@ static void setup_transports_large_datav6( } void RTPSParticipantAttributes::setup_transports( - fastdds::rtps::BuiltinTransports transports) + fastdds::rtps::BuiltinTransports transports, + const fastdds::rtps::BuiltinTransportsOptions& options) { + if (options.maxMessageSize > 65500 && + (transports != fastdds::rtps::BuiltinTransports::NONE && + transports != fastdds::rtps::BuiltinTransports::SHM && + transports != fastdds::rtps::BuiltinTransports::LARGE_DATA && + transports != fastdds::rtps::BuiltinTransports::LARGE_DATAv6)) + { + EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, + "Max message size of UDP cannot be greater than 65500. Will use DEFAULT transports."); + return; + } bool intraprocess_only = is_intraprocess_only(*this); + sendSocketBufferSize = options.sockets_buffer_size; + listenSocketBufferSize = options.sockets_buffer_size; + switch (transports) { case fastdds::rtps::BuiltinTransports::NONE: break; case fastdds::rtps::BuiltinTransports::DEFAULT: - setup_transports_default(*this, intraprocess_only); + setup_transports_default(*this, intraprocess_only, options); break; case fastdds::rtps::BuiltinTransports::DEFAULTv6: - setup_transports_defaultv6(*this, intraprocess_only); + setup_transports_defaultv6(*this, intraprocess_only, options); break; case fastdds::rtps::BuiltinTransports::SHM: - setup_transports_shm(*this); + setup_transports_shm(*this, options); break; case fastdds::rtps::BuiltinTransports::UDPv4: - setup_transports_udpv4(*this, intraprocess_only); + setup_transports_udpv4(*this, intraprocess_only, options); break; case fastdds::rtps::BuiltinTransports::UDPv6: - setup_transports_udpv6(*this, intraprocess_only); + setup_transports_udpv6(*this, intraprocess_only, options); break; case fastdds::rtps::BuiltinTransports::LARGE_DATA: - setup_transports_large_data(*this, intraprocess_only); + // This parameter will allow allow the initialization of UDP transports with maxMessageSize > 65500 KB + max_msg_size_no_frag = options.maxMessageSize; + setup_transports_large_data(*this, intraprocess_only, options); break; case fastdds::rtps::BuiltinTransports::LARGE_DATAv6: - setup_transports_large_datav6(*this, intraprocess_only); + // This parameter will allow allow the initialization of UDP transports with maxMessageSize > 65500 KB + max_msg_size_no_frag = options.maxMessageSize; + setup_transports_large_datav6(*this, intraprocess_only, options); break; default: diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h index b78b00af769..74bc0a0c9e3 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -500,6 +500,21 @@ class RTPSParticipantAttributes useBuiltinTransports = false; } + /** + * Provides a way of easily configuring transport related configuration on certain pre-defined scenarios with + * certain options. Options only take effect if the selected builtin transport is LARGE_DATA. + * + * @param transports Defines the transport configuration scenario to setup. + * @param options Defines the options to be used in the transport configuration. + */ + void setup_transports( + fastdds::rtps::BuiltinTransports /*transports*/, fastdds::rtps::BuiltinTransportsOptions& /*options*/) + { + // Only include UDPv4 behavior for mock tests, ignore options + setup_transports_default(*this); + useBuiltinTransports = false; + } + static void setup_transports_default( RTPSParticipantAttributes& att) { @@ -625,10 +640,17 @@ class RTPSParticipantAttributes fastdds::rtps::ThreadSettings security_log_thread; #endif // if HAVE_SECURITY + /*! Maximum message size used to avoid fragmentation, setted ONLY in LARGE_DATA. If this value is + * not zero, the network factory will allow the initialization of UDP transports with maxMessageSize + * higher than 65500K. + */ + uint32_t max_msg_size_no_frag = 0; + private: //! Name of the participant. string_255 name{"RTPSParticipant"}; + }; } // namespace rtps From 087cd02e281ebbe9cbdb687742318601e629597d Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Wed, 21 Feb 2024 14:55:23 +0100 Subject: [PATCH 03/34] Refs #20493: Update old methods with options parameter Signed-off-by: cferreiragonz --- .../attributes/RTPSParticipantAttributes.cpp | 72 ++++++++++++------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp b/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp index 4a3bfff8af5..80560f2ab6b 100644 --- a/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp +++ b/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp @@ -44,7 +44,8 @@ static bool is_intraprocess_only( } static std::shared_ptr create_shm_transport( - const RTPSParticipantAttributes& att) + const RTPSParticipantAttributes& att, + const fastdds::rtps::BuiltinTransportsOptions& options) { auto descriptor = std::make_shared(); @@ -53,17 +54,22 @@ static std::shared_ptr create_shm_t auto segment_size_udp_equivalent = std::max(att.sendSocketBufferSize, att.listenSocketBufferSize) * 2; descriptor->segment_size(segment_size_udp_equivalent); + // Needed for the maxMessageSizeBetweenTransports + descriptor->maxMessageSize = options.maxMessageSize; descriptor->default_reception_threads(att.builtin_transports_reception_threads); return descriptor; } static std::shared_ptr create_udpv4_transport( const RTPSParticipantAttributes& att, - bool intraprocess_only) + bool intraprocess_only, + const fastdds::rtps::BuiltinTransportsOptions& options) { auto descriptor = std::make_shared(); + descriptor->maxMessageSize = options.maxMessageSize; descriptor->sendBufferSize = att.sendSocketBufferSize; descriptor->receiveBufferSize = att.listenSocketBufferSize; + descriptor->non_blocking_send = options.non_blocking_send; descriptor->default_reception_threads(att.builtin_transports_reception_threads); if (intraprocess_only) { @@ -75,11 +81,14 @@ static std::shared_ptr create_udpv4_tra static std::shared_ptr create_udpv6_transport( const RTPSParticipantAttributes& att, - bool intraprocess_only) + bool intraprocess_only, + const fastdds::rtps::BuiltinTransportsOptions& options) { auto descriptor = std::make_shared(); + descriptor->maxMessageSize = options.maxMessageSize; descriptor->sendBufferSize = att.sendSocketBufferSize; descriptor->receiveBufferSize = att.listenSocketBufferSize; + descriptor->non_blocking_send = options.non_blocking_send; descriptor->default_reception_threads(att.builtin_transports_reception_threads); if (intraprocess_only) { @@ -90,12 +99,15 @@ static std::shared_ptr create_udpv6_tra } static std::shared_ptr create_tcpv4_transport( - const RTPSParticipantAttributes& att) + const RTPSParticipantAttributes& att, + const fastdds::rtps::BuiltinTransportsOptions& options) { auto descriptor = std::make_shared(); descriptor->add_listener_port(0); + descriptor->maxMessageSize = options.maxMessageSize; descriptor->sendBufferSize = att.sendSocketBufferSize; descriptor->receiveBufferSize = att.listenSocketBufferSize; + descriptor->non_blocking_send = options.non_blocking_send; descriptor->calculate_crc = false; descriptor->check_crc = false; @@ -110,12 +122,15 @@ static std::shared_ptr create_tcpv4_tra } static std::shared_ptr create_tcpv6_transport( - const RTPSParticipantAttributes& att) + const RTPSParticipantAttributes& att, + const fastdds::rtps::BuiltinTransportsOptions& options) { auto descriptor = std::make_shared(); descriptor->add_listener_port(0); + descriptor->maxMessageSize = options.maxMessageSize; descriptor->sendBufferSize = att.sendSocketBufferSize; descriptor->receiveBufferSize = att.listenSocketBufferSize; + descriptor->non_blocking_send = options.non_blocking_send; descriptor->calculate_crc = false; descriptor->check_crc = false; @@ -131,14 +146,15 @@ static std::shared_ptr create_tcpv6_tra static void setup_transports_default( RTPSParticipantAttributes& att, - bool intraprocess_only) + bool intraprocess_only, + const fastdds::rtps::BuiltinTransportsOptions& options) { - auto descriptor = create_udpv4_transport(att, intraprocess_only); + auto descriptor = create_udpv4_transport(att, intraprocess_only, options); #ifdef SHM_TRANSPORT_BUILTIN if (!intraprocess_only) { - auto shm_transport = create_shm_transport(att); + auto shm_transport = create_shm_transport(att, options); // Use same default max_message_size on both UDP and SHM shm_transport->max_message_size(descriptor->max_message_size()); att.userTransports.push_back(shm_transport); @@ -150,14 +166,15 @@ static void setup_transports_default( static void setup_transports_defaultv6( RTPSParticipantAttributes& att, - bool intraprocess_only) + bool intraprocess_only, + const fastdds::rtps::BuiltinTransportsOptions& options) { - auto descriptor = create_udpv6_transport(att, intraprocess_only); + auto descriptor = create_udpv6_transport(att, intraprocess_only, options); #ifdef SHM_TRANSPORT_BUILTIN if (!intraprocess_only) { - auto shm_transport = create_shm_transport(att); + auto shm_transport = create_shm_transport(att, options); // Use same default max_message_size on both UDP and SHM shm_transport->max_message_size(descriptor->max_message_size()); att.userTransports.push_back(shm_transport); @@ -168,47 +185,51 @@ static void setup_transports_defaultv6( } static void setup_transports_shm( - RTPSParticipantAttributes& att) + RTPSParticipantAttributes& att, + const fastdds::rtps::BuiltinTransportsOptions& options) { #ifdef FASTDDS_SHM_TRANSPORT_DISABLED static_cast(att); EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, "Trying to configure SHM transport only, " << "but Fast DDS was built without SHM transport support."); #else - auto descriptor = create_shm_transport(att); + auto descriptor = create_shm_transport(att, options); att.userTransports.push_back(descriptor); #endif // FASTDDS_SHM_TRANSPORT_DISABLED } static void setup_transports_udpv4( RTPSParticipantAttributes& att, - bool intraprocess_only) + bool intraprocess_only, + const fastdds::rtps::BuiltinTransportsOptions& options) { - auto descriptor = create_udpv4_transport(att, intraprocess_only); + auto descriptor = create_udpv4_transport(att, intraprocess_only, options); att.userTransports.push_back(descriptor); } static void setup_transports_udpv6( RTPSParticipantAttributes& att, - bool intraprocess_only) + bool intraprocess_only, + const fastdds::rtps::BuiltinTransportsOptions& options) { - auto descriptor = create_udpv6_transport(att, intraprocess_only); + auto descriptor = create_udpv6_transport(att, intraprocess_only, options); att.userTransports.push_back(descriptor); } static void setup_transports_large_data( RTPSParticipantAttributes& att, - bool intraprocess_only) + bool intraprocess_only, + const fastdds::rtps::BuiltinTransportsOptions& options) { if (!intraprocess_only) { - auto shm_transport = create_shm_transport(att); + auto shm_transport = create_shm_transport(att, options); att.userTransports.push_back(shm_transport); auto shm_loc = fastdds::rtps::SHMLocator::create_locator(0, fastdds::rtps::SHMLocator::Type::UNICAST); att.defaultUnicastLocatorList.push_back(shm_loc); - auto tcp_transport = create_tcpv4_transport(att); + auto tcp_transport = create_tcpv4_transport(att, options); att.userTransports.push_back(tcp_transport); Locator_t tcp_loc; @@ -220,7 +241,7 @@ static void setup_transports_large_data( att.defaultUnicastLocatorList.push_back(tcp_loc); } - auto udp_descriptor = create_udpv4_transport(att, intraprocess_only); + auto udp_descriptor = create_udpv4_transport(att, intraprocess_only, options); att.userTransports.push_back(udp_descriptor); if (!intraprocess_only) @@ -234,17 +255,18 @@ static void setup_transports_large_data( static void setup_transports_large_datav6( RTPSParticipantAttributes& att, - bool intraprocess_only) + bool intraprocess_only, + const fastdds::rtps::BuiltinTransportsOptions& options) { if (!intraprocess_only) { - auto shm_transport = create_shm_transport(att); + auto shm_transport = create_shm_transport(att, options); att.userTransports.push_back(shm_transport); auto shm_loc = fastdds::rtps::SHMLocator::create_locator(0, fastdds::rtps::SHMLocator::Type::UNICAST); att.defaultUnicastLocatorList.push_back(shm_loc); - auto tcp_transport = create_tcpv6_transport(att); + auto tcp_transport = create_tcpv6_transport(att, options); att.userTransports.push_back(tcp_transport); Locator_t tcp_loc; @@ -256,7 +278,7 @@ static void setup_transports_large_datav6( att.defaultUnicastLocatorList.push_back(tcp_loc); } - auto udp_descriptor = create_udpv6_transport(att, intraprocess_only); + auto udp_descriptor = create_udpv6_transport(att, intraprocess_only, options); att.userTransports.push_back(udp_descriptor); if (!intraprocess_only) From 13f9349e5dd57b249f7252eed42479fece852056 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Wed, 21 Feb 2024 14:56:01 +0100 Subject: [PATCH 04/34] Refs #20493: Overload of DomainParticipantQos API Signed-off-by: cferreiragonz --- include/fastdds/dds/domain/qos/DomainParticipantQos.hpp | 7 +++++-- src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp b/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp index 65519c81f8d..4397791390e 100644 --- a/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp +++ b/include/fastdds/dds/domain/qos/DomainParticipantQos.hpp @@ -350,12 +350,15 @@ class DomainParticipantQos } /** - * Provides a way of easily configuring transport related configuration on certain pre-defined scenarios. + * Provides a way of easily configuring transport related configuration on certain pre-defined scenarios with + * certain options. * * @param transports Defines the transport configuration scenario to setup. + * @param options Defines the options to be used in the transport configuration. */ RTPS_DllAPI void setup_transports( - rtps::BuiltinTransports transports); + rtps::BuiltinTransports transports, + const rtps::BuiltinTransportsOptions& options = rtps::BuiltinTransportsOptions()); /** * Setter for the builtin flow controllers sender threads ThreadSettings diff --git a/src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp b/src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp index 296182cb360..a1951aba2bd 100644 --- a/src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp +++ b/src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp @@ -30,12 +30,13 @@ namespace dds { const DomainParticipantQos PARTICIPANT_QOS_DEFAULT; void DomainParticipantQos::setup_transports( - rtps::BuiltinTransports transports) + rtps::BuiltinTransports transports, + const rtps::BuiltinTransportsOptions& options) { fastrtps::rtps::RTPSParticipantAttributes attr; utils::set_attributes_from_qos(attr, *this); - attr.setup_transports(transports); + attr.setup_transports(transports, options); utils::set_qos_from_attributes(*this, attr); } From d9c52e9b7c346997981e0fbdf8f10f606e1b50b2 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Wed, 21 Feb 2024 16:02:15 +0100 Subject: [PATCH 05/34] Refs #20493: Make builtin-options const Signed-off-by: cferreiragonz --- .../fastdds/rtps/attributes/RTPSParticipantAttributes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h index 74bc0a0c9e3..24b1014a77c 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -508,7 +508,7 @@ class RTPSParticipantAttributes * @param options Defines the options to be used in the transport configuration. */ void setup_transports( - fastdds::rtps::BuiltinTransports /*transports*/, fastdds::rtps::BuiltinTransportsOptions& /*options*/) + fastdds::rtps::BuiltinTransports /*transports*/, const fastdds::rtps::BuiltinTransportsOptions& /*options*/) { // Only include UDPv4 behavior for mock tests, ignore options setup_transports_default(*this); From b00155350d16e179b47661a1ac5c2840e7c25d96 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Thu, 22 Feb 2024 15:51:47 +0100 Subject: [PATCH 06/34] Refs #20493: Add Env.var. parser Signed-off-by: cferreiragonz --- .../rtps/participant/RTPSParticipantImpl.cpp | 75 +++++++++++++++++-- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index da7b2da2476..089541cebb4 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include @@ -86,9 +87,10 @@ using SharedMemTransportDescriptor = fastdds::rtps::SharedMemTransportDescriptor using BuiltinTransports = fastdds::rtps::BuiltinTransports; /** - * Parse the environment variable specifying the transports to instantiate + * Parse the environment variable specifying the transports to instantiate and optional configuration options + * if the transport selected is LARGE_DATA. */ -static BuiltinTransports get_builtin_transports_from_env_var() +static void set_builtin_transports_from_env_var(RTPSParticipantAttributes& attr) { static constexpr const char* env_var_name = "FASTDDS_BUILTIN_TRANSPORTS"; @@ -96,7 +98,14 @@ static BuiltinTransports get_builtin_transports_from_env_var() std::string env_value; if (SystemInfo::get_env(env_var_name, env_value) == ReturnCode_t::RETCODE_OK) { - if (!get_element_enum_value(env_value.c_str(), ret_val, + std::regex COMMON_REGEX(R"((\w+))"); + std::regex OPTIONS_REGEX(R"((\w+)\?((max_msg_size|non_blocking|sockets_size)=(\d+)?(\w+)&?){0,3})"); + std::smatch mr; + + if (std::regex_match(env_value, COMMON_REGEX, std::regex_constants::match_not_null)) + { + // Only transport mode is specified + if (!get_element_enum_value(env_value.c_str(), ret_val, "NONE", BuiltinTransports::NONE, "DEFAULT", BuiltinTransports::DEFAULT, "DEFAULTv6", BuiltinTransports::DEFAULTv6, @@ -105,12 +114,68 @@ static BuiltinTransports get_builtin_transports_from_env_var() "UDPv6", BuiltinTransports::UDPv6, "LARGE_DATA", BuiltinTransports::LARGE_DATA, "LARGE_DATAv6", BuiltinTransports::LARGE_DATAv6)) + { + EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, "Wrong value '" << env_value << "' for environment variable '" << + env_var_name << "'. Leaving as DEFAULT"); + } + } + else if (std::regex_match(env_value, mr, OPTIONS_REGEX, std::regex_constants::match_not_null)) + { + std::regex msg_size_regex(R"((max_msg_size)=(\d+)(\w*))"); + std::regex sockets_size_regex(R"((sockets_size)=(\d+)(\w*))"); + std::regex non_blocking_regex(R"((non_blocking)=(true|false))"); + + fastdds::rtps::BuiltinTransportsOptions options; + + try + { + if (!get_element_enum_value(mr[1].str().c_str(), ret_val, + "NONE", BuiltinTransports::NONE, + "DEFAULT", BuiltinTransports::DEFAULT, + "DEFAULTv6", BuiltinTransports::DEFAULTv6, + "SHM", BuiltinTransports::SHM, + "UDPv4", BuiltinTransports::UDPv4, + "UDPv6", BuiltinTransports::UDPv6, + "LARGE_DATA", BuiltinTransports::LARGE_DATA, + "LARGE_DATAv6", BuiltinTransports::LARGE_DATAv6)) + { + EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, "Wrong value '" << env_value << "' for environment variable '" << + env_var_name << "'. Leaving as DEFAULT"); + } + // Max_msg_size parser + if (std::regex_search(env_value, mr, msg_size_regex, std::regex_constants::match_not_null)) + { + std::string value = mr[2]; + std::string unit = (mr[3] == "") ? "B" : mr[3].str(); + options.maxMessageSize = eprosima::fastdds::dds::utils::parse_value_and_units(value, unit); + } + if (std::regex_search(env_value, mr, sockets_size_regex, std::regex_constants::match_not_null)) + { + std::string value = mr[2]; + std::string unit = (mr[3] == "") ? "B" : mr[3].str(); + options.sockets_buffer_size = eprosima::fastdds::dds::utils::parse_value_and_units(value, unit); + } + if (std::regex_search(env_value, mr, non_blocking_regex, std::regex_constants::match_not_null)) + { + options.non_blocking_send = mr[2] == "true"; + } + attr.setup_transports(ret_val, options); + return; + } + catch (std::exception& e) + { + EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, "Exception parsing environment variable: " << e.what() << " Leaving LARGE_DATA with default options."); + attr.setup_transports(ret_val); + return; + } + } + else { EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, "Wrong value '" << env_value << "' for environment variable '" << env_var_name << "'. Leaving as DEFAULT"); } } - return ret_val; + attr.setup_transports(ret_val); } static EntityId_t TrustedWriter( @@ -201,7 +266,7 @@ RTPSParticipantImpl::RTPSParticipantImpl( // Setup builtin transports if (m_att.useBuiltinTransports) { - m_att.setup_transports(get_builtin_transports_from_env_var()); + set_builtin_transports_from_env_var(m_att); } // BACKUP servers guid is its persistence one From f94cea320c0c3e09e335de358a1e98b033419431 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Thu, 22 Feb 2024 15:52:14 +0100 Subject: [PATCH 07/34] Refs #20493: Increase maximum msg_size of TCP Signed-off-by: cferreiragonz --- src/cpp/rtps/transport/TCPTransportInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpp/rtps/transport/TCPTransportInterface.cpp b/src/cpp/rtps/transport/TCPTransportInterface.cpp index bc82b04f907..2360e18f815 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.cpp +++ b/src/cpp/rtps/transport/TCPTransportInterface.cpp @@ -485,9 +485,9 @@ bool TCPTransportInterface::init( } } - if (configuration()->maxMessageSize > s_maximumMessageSize) + if (configuration()->maxMessageSize > std::numeric_limits::max()) { - EPROSIMA_LOG_ERROR(RTCP_MSG_OUT, "maxMessageSize cannot be greater than 65000"); + EPROSIMA_LOG_ERROR(RTCP_MSG_OUT, "maxMessageSize cannot be greater than 4.29 MB"); return false; } From 22b29f43580a6a3dc101b260097f675ba51efdd7 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Thu, 22 Feb 2024 10:58:06 +0100 Subject: [PATCH 08/34] Refs #20493: Add blackbox tests Signed-off-by: cferreiragonz --- test/blackbox/api/dds-pim/PubSubReader.hpp | 8 +++ test/blackbox/api/dds-pim/PubSubWriter.hpp | 8 +++ .../api/fastrtps_deprecated/PubSubReader.hpp | 8 +++ .../api/fastrtps_deprecated/PubSubWriter.hpp | 8 +++ .../common/BlackboxTestsTransportCustom.cpp | 61 +++++++++++++++++-- 5 files changed, 88 insertions(+), 5 deletions(-) diff --git a/test/blackbox/api/dds-pim/PubSubReader.hpp b/test/blackbox/api/dds-pim/PubSubReader.hpp index 0a494845aa7..15ce38cca70 100644 --- a/test/blackbox/api/dds-pim/PubSubReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubReader.hpp @@ -967,6 +967,14 @@ class PubSubReader return *this; } + PubSubReader& setup_transports( + eprosima::fastdds::rtps::BuiltinTransports transports, + const eprosima::fastdds::rtps::BuiltinTransportsOptions& options) + { + participant_qos_.setup_transports(transports, options); + return *this; + } + PubSubReader& setup_large_data_tcp( bool v6 = false, const uint16_t& port = 0, diff --git a/test/blackbox/api/dds-pim/PubSubWriter.hpp b/test/blackbox/api/dds-pim/PubSubWriter.hpp index 27c027233a2..1a55e0e2acc 100644 --- a/test/blackbox/api/dds-pim/PubSubWriter.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriter.hpp @@ -955,6 +955,14 @@ class PubSubWriter return *this; } + PubSubWriter& setup_transports( + eprosima::fastdds::rtps::BuiltinTransports transports, + const eprosima::fastdds::rtps::BuiltinTransportsOptions& options) + { + participant_qos_.setup_transports(transports, options); + return *this; + } + PubSubWriter& setup_large_data_tcp( bool v6 = false, const uint16_t& port = 0, diff --git a/test/blackbox/api/fastrtps_deprecated/PubSubReader.hpp b/test/blackbox/api/fastrtps_deprecated/PubSubReader.hpp index 18f450e5ac1..89cff7338a1 100644 --- a/test/blackbox/api/fastrtps_deprecated/PubSubReader.hpp +++ b/test/blackbox/api/fastrtps_deprecated/PubSubReader.hpp @@ -742,6 +742,14 @@ class PubSubReader return *this; } + PubSubReader& setup_transports( + eprosima::fastdds::rtps::BuiltinTransports transports, + const eprosima::fastdds::rtps::BuiltinTransportsOptions& options) + { + participant_attr_.rtps.setup_transports(transports, options); + return *this; + } + PubSubReader& setup_large_data_tcp( bool v6 = false, const uint16_t& port = 0, diff --git a/test/blackbox/api/fastrtps_deprecated/PubSubWriter.hpp b/test/blackbox/api/fastrtps_deprecated/PubSubWriter.hpp index af0070f9a99..25cfb9a1be1 100644 --- a/test/blackbox/api/fastrtps_deprecated/PubSubWriter.hpp +++ b/test/blackbox/api/fastrtps_deprecated/PubSubWriter.hpp @@ -754,6 +754,14 @@ class PubSubWriter return *this; } + PubSubWriter& setup_transports( + eprosima::fastdds::rtps::BuiltinTransports transports, + const eprosima::fastdds::rtps::BuiltinTransportsOptions& options) + { + participant_attr_.rtps.setup_transports(transports, options); + return *this; + } + PubSubWriter& setup_large_data_tcp( bool v6 = false, const uint16_t& port = 0, diff --git a/test/blackbox/common/BlackboxTestsTransportCustom.cpp b/test/blackbox/common/BlackboxTestsTransportCustom.cpp index 3680b0041f9..b98cd9d69fe 100644 --- a/test/blackbox/common/BlackboxTestsTransportCustom.cpp +++ b/test/blackbox/common/BlackboxTestsTransportCustom.cpp @@ -27,6 +27,7 @@ #include "PubSubWriter.hpp" using BuiltinTransports = eprosima::fastdds::rtps::BuiltinTransports; +using BuiltinTransportsOptions = eprosima::fastdds::rtps::BuiltinTransportsOptions; class TestChainingTransportDescriptor : public eprosima::fastdds::rtps::ChainingTransportDescriptor { @@ -155,7 +156,8 @@ class BuiltinTransportsTest } static void test_api( - const BuiltinTransports& builtin_transports) + const BuiltinTransports& builtin_transports, + const BuiltinTransportsOptions* const builtin_transports_options = nullptr) { if (builtin_transports == BuiltinTransports::NONE) { @@ -170,7 +172,7 @@ class BuiltinTransportsTest } else { - run_test("", "", "", builtin_transports); + run_test("", "", "", builtin_transports, builtin_transports_options); } } @@ -180,14 +182,16 @@ class BuiltinTransportsTest const std::string& profiles_file, const std::string& participant_profile, const std::string& env_var_value, - const BuiltinTransports& builtin_transports) + const BuiltinTransports& builtin_transports, + const BuiltinTransportsOptions* const builtin_transports_options = nullptr) { enum class BuiltinTransportsTestCase : uint8_t { NONE, XML, ENV, - API + API, + API_OPTIONS }; BuiltinTransportsTestCase test_case = BuiltinTransportsTestCase::NONE; @@ -198,6 +202,7 @@ class BuiltinTransportsTest ASSERT_NE(participant_profile, ""); ASSERT_EQ(builtin_transports, BuiltinTransports::NONE); ASSERT_EQ(env_var_value, ""); + ASSERT_EQ(builtin_transports_options, nullptr); test_case = BuiltinTransportsTestCase::XML; } else if (env_var_value != "") @@ -205,6 +210,7 @@ class BuiltinTransportsTest ASSERT_EQ(profiles_file, ""); ASSERT_EQ(participant_profile, ""); ASSERT_EQ(builtin_transports, BuiltinTransports::NONE); + ASSERT_EQ(builtin_transports_options, nullptr); test_case = BuiltinTransportsTestCase::ENV; } else if (builtin_transports != BuiltinTransports::NONE) @@ -212,7 +218,7 @@ class BuiltinTransportsTest ASSERT_EQ(profiles_file, ""); ASSERT_EQ(participant_profile, ""); ASSERT_EQ(env_var_value, ""); - test_case = BuiltinTransportsTestCase::API; + test_case = (builtin_transports_options != nullptr) ? BuiltinTransportsTestCase::API_OPTIONS : BuiltinTransportsTestCase::API; } ASSERT_NE(test_case, BuiltinTransportsTestCase::NONE); @@ -255,6 +261,12 @@ class BuiltinTransportsTest reader.setup_transports(builtin_transports); break; } + case BuiltinTransportsTestCase::API_OPTIONS: + { + writer.setup_transports(builtin_transports, *builtin_transports_options); + reader.setup_transports(builtin_transports, *builtin_transports_options); + break; + } default: { FAIL(); @@ -521,6 +533,30 @@ TEST(ChainingTransportTests, builtin_transports_api_large_data) BuiltinTransportsTest::test_api(BuiltinTransports::LARGE_DATA); } +TEST(ChainingTransportTests, builtin_transports_api_large_data_with_max_msg_size) +{ + BuiltinTransportsOptions options; + options.maxMessageSize = 70000; + options.sockets_buffer_size = 70000; + BuiltinTransportsTest::test_api(BuiltinTransports::LARGE_DATA, &options); +} + +TEST(ChainingTransportTests, builtin_transports_api_large_data_with_non_blocking_send) +{ + BuiltinTransportsOptions options; + options.non_blocking_send = true; + BuiltinTransportsTest::test_api(BuiltinTransports::LARGE_DATA, &options); +} + +TEST(ChainingTransportTests, builtin_transports_api_large_data_with_all_options) +{ + BuiltinTransportsOptions options; + options.maxMessageSize = 70000; + options.sockets_buffer_size = 70000; + options.non_blocking_send = true; + BuiltinTransportsTest::test_api(BuiltinTransports::LARGE_DATA, &options); +} + #ifndef __APPLE__ TEST(ChainingTransportTests, builtin_transports_api_large_datav6) { @@ -563,6 +599,21 @@ TEST(ChainingTransportTests, builtin_transports_env_large_data) BuiltinTransportsTest::test_env("LARGE_DATA"); } +TEST(ChainingTransportTests, builtin_transports_env_large_data_with_max_msg_size) +{ + BuiltinTransportsTest::test_env("LARGE_DATA?max_msg_size=70KB&sockets_size=70KB"); +} + +TEST(ChainingTransportTests, builtin_transports_env_large_data_with_non_blocking_send) +{ + BuiltinTransportsTest::test_env("LARGE_DATA?non_blocking=true"); +} + +TEST(ChainingTransportTests, builtin_transports_env_large_data_with_all_options) +{ + BuiltinTransportsTest::test_env("LARGE_DATA?max_msg_size=70KB&sockets_size=70KB&non_blocking=true"); +} + #ifndef __APPLE__ TEST(ChainingTransportTests, builtin_transports_env_large_datav6) { From 91d7fe1a74752246d0855743f6ffd6b202aac9b3 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Thu, 22 Feb 2024 10:58:38 +0100 Subject: [PATCH 09/34] Refs #20493: Add Participant unittests Signed-off-by: cferreiragonz --- .../dds/participant/ParticipantTests.cpp | 232 ++++++++++++++++++ 1 file changed, 232 insertions(+) diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index 98a24b7b4a4..4bb09b67fc0 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -4301,7 +4301,239 @@ TEST(ParticipantTests, ParticipantCreationWithBuiltinTransport) } } +class BuiltinTransportsOptionsTest +{ +public: + + static void test_correct_participant_with_env( + const std::string& options_str, + const rtps::BuiltinTransportsOptions& options) + { + apply_option_to_env(options_str); + DomainParticipantQos qos; + DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, qos); + ASSERT_NE(nullptr, participant_); + + fastrtps::rtps::RTPSParticipantAttributes attr; + get_rtps_attributes(participant_, attr); + EXPECT_TRUE(check_options_attr(attr, options)); + EXPECT_EQ(ReturnCode_t::RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant_)); + } + + static void test_wrong_participant_with_env( + const std::string& options_str) + { + apply_option_to_env(options_str); + DomainParticipantQos qos; + DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, qos); + ASSERT_NE(nullptr, participant_); + + fastrtps::rtps::RTPSParticipantAttributes attr; + get_rtps_attributes(participant_, attr); + EXPECT_TRUE(check_default_participant(attr)); + EXPECT_EQ(ReturnCode_t::RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant_)); + } + static void apply_option_to_env( + const std::string& options) + { + set_env(env_var_large_data_ + options); + } + + static bool check_options_attr( + const fastrtps::rtps::RTPSParticipantAttributes& attr, + const rtps::BuiltinTransportsOptions& options) + { + bool udp_ok = false; + bool tcp_ok = false; + for (auto& transportDescriptor : attr.userTransports) + { + if ( fastdds::rtps::UDPv4TransportDescriptor* udp_ptr = + dynamic_cast(transportDescriptor.get())) + { + if (udp_ptr && + udp_ptr->maxMessageSize == 65500 && // LARGE_DATA config does not affect UDP maxMessageSize + udp_ptr->sendBufferSize == options.sockets_buffer_size && + udp_ptr->receiveBufferSize == options.sockets_buffer_size && + udp_ptr->non_blocking_send == options.non_blocking_send) + { + udp_ok = true; + } + } + else if ( fastdds::rtps::TCPv4TransportDescriptor* tcp_ptr = + dynamic_cast(transportDescriptor.get())) + { + if (tcp_ptr && + tcp_ptr->maxMessageSize == options.maxMessageSize && + tcp_ptr->sendBufferSize == options.sockets_buffer_size && + tcp_ptr->receiveBufferSize == options.sockets_buffer_size && + tcp_ptr->non_blocking_send == options.non_blocking_send) + { + tcp_ok = true; + } + } + } + EXPECT_EQ(attr.userTransports.size(), 3u); + return (udp_ok && tcp_ok); + }; + + static bool check_options_qos( + const DomainParticipantQos& qos, + const rtps::BuiltinTransportsOptions& options) + { + bool udp_ok = false; + bool tcp_ok = false; + for (auto& transportDescriptor : qos.transport().user_transports) + { + if ( fastdds::rtps::UDPv4TransportDescriptor* udp_ptr = + dynamic_cast(transportDescriptor.get())) + { + if (udp_ptr && + udp_ptr->maxMessageSize == 65500 && // LARGE_DATA config does not affect UDP maxMessageSize + udp_ptr->sendBufferSize == options.sockets_buffer_size && + udp_ptr->receiveBufferSize == options.sockets_buffer_size && + udp_ptr->non_blocking_send == options.non_blocking_send) + { + udp_ok = true; + } + } + else if ( fastdds::rtps::TCPv4TransportDescriptor* tcp_ptr = + dynamic_cast(transportDescriptor.get())) + { + if (tcp_ptr && + tcp_ptr->maxMessageSize == options.maxMessageSize && + tcp_ptr->sendBufferSize == options.sockets_buffer_size && + tcp_ptr->receiveBufferSize == options.sockets_buffer_size && + tcp_ptr->non_blocking_send == options.non_blocking_send) + { + tcp_ok = true; + } + } + } + EXPECT_EQ(qos.transport().user_transports.size(), 3u); + return (udp_ok && tcp_ok); + }; + + static bool check_default_participant( + const fastrtps::rtps::RTPSParticipantAttributes& attr) + { + bool udp_ok = false; + bool shm_ok = false; + for (auto& transportDescriptor : attr.userTransports) + { + if ( nullptr != + dynamic_cast(transportDescriptor.get())) + { + shm_ok = true; + } + else if ( nullptr != + dynamic_cast(transportDescriptor.get())) + { + udp_ok = true; + } + } + EXPECT_EQ(attr.userTransports.size(), 2u); + return (udp_ok && shm_ok); + }; + +private: + + static const std::string env_var_name_; + static const std::string env_var_large_data_; + + static void set_env( + const std::string& value) + { +#ifdef _WIN32 + ASSERT_EQ(0, _putenv_s(env_var_name_.c_str(), value.c_str())); +#else + ASSERT_EQ(0, setenv(env_var_name_.c_str(), value.c_str(), 1)); +#endif // _WIN32 + }; +}; + +// Static const member of non-integral types cannot be in-class initialized +const std::string BuiltinTransportsOptionsTest::env_var_name_ = "FASTDDS_BUILTIN_TRANSPORTS"; +const std::string BuiltinTransportsOptionsTest::env_var_large_data_ = "LARGE_DATA"; + +TEST(ParticipantTests, ParticipantCreationWithLargeDataOptions) +{ + // Default configuration + DomainParticipantQos qos; + rtps::BuiltinTransportsOptions options; + + qos.setup_transports(rtps::BuiltinTransports::LARGE_DATA); + EXPECT_TRUE(BuiltinTransportsOptionsTest::check_options_qos(qos, options)); + + // Custom configuration + options.maxMessageSize = 40000; + options.sockets_buffer_size = 60000; + options.non_blocking_send = true; + qos = DomainParticipantQos(); + qos.setup_transports(rtps::BuiltinTransports::LARGE_DATA, options); + EXPECT_TRUE(BuiltinTransportsOptionsTest::check_options_qos(qos, options)); + + // Check participant is correctly created + DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, qos); + ASSERT_NE(nullptr, participant_); + + fastrtps::rtps::RTPSParticipantAttributes attr; + get_rtps_attributes(participant_, attr); + + EXPECT_TRUE(BuiltinTransportsOptionsTest::check_options_attr(attr, options)); + EXPECT_EQ(ReturnCode_t::RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant_)); +} + +TEST(ParticipantTests, ParticipantCreationWithLargeDataOptionsThroughEnvVar) +{ + // Default configuration + rtps::BuiltinTransportsOptions options; + std::string config_options = ""; + BuiltinTransportsOptionsTest::test_correct_participant_with_env(config_options, options); + + // Custom configurations + // 1. Only max_msg_size + config_options = "?max_msg_size=40KB"; + options.maxMessageSize = 40000; + BuiltinTransportsOptionsTest::test_correct_participant_with_env(config_options, options); + + // 2. Only sockets_buffers_size + config_options = "?sockets_size=70KB"; + options = rtps::BuiltinTransportsOptions(); + options.sockets_buffer_size = 70000; + BuiltinTransportsOptionsTest::test_correct_participant_with_env(config_options, options); + + // 3. Only non_blocking_send + config_options = "?non_blocking=true"; + options = rtps::BuiltinTransportsOptions(); + options.non_blocking_send = true; + BuiltinTransportsOptionsTest::test_correct_participant_with_env(config_options, options); + + // 4. All options + config_options = "?max_msg_size=70KB&non_blocking=true&sockets_size=70KB"; + options = rtps::BuiltinTransportsOptions(); + options.maxMessageSize = 70000; + options.sockets_buffer_size = 70000; + options.non_blocking_send = true; + BuiltinTransportsOptionsTest::test_correct_participant_with_env(config_options, options); + + // 5. Wrong units defaults to LARGE_DATA with default config options + config_options = "?max_msg_size=70TB&non_blocking=true&sockets_size=70Byte"; + options = rtps::BuiltinTransportsOptions(); + BuiltinTransportsOptionsTest::test_correct_participant_with_env(config_options, options); + + // 6. Exceed maximum defaults to LARGE_DATA with default config options + config_options = "?max_msg_size=5000000000&non_blocking=false&sockets_size=5000000000"; + options = rtps::BuiltinTransportsOptions(); + BuiltinTransportsOptionsTest::test_correct_participant_with_env(config_options, options); + + // 7. Wrong spelling defaults to DEFAULT builtin transports + config_options = "?max_message_size=70TB&no_blokcing=true&sokcets_saze=70Byte"; + BuiltinTransportsOptionsTest::test_wrong_participant_with_env(config_options); +} } // namespace dds } // namespace fastdds From b1f19a18b82436bdf43d2a15c432a0e62f88b12b Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Fri, 23 Feb 2024 09:36:37 +0100 Subject: [PATCH 10/34] Refs #20493: Add units parser to utils Signed-off-by: cferreiragonz --- include/fastrtps/utils/UnitsParser.hpp | 61 +++++++++++++++++ src/cpp/CMakeLists.txt | 1 + src/cpp/utils/UnitsParser.cpp | 76 +++++++++++++++++++++ test/unittest/dds/publisher/CMakeLists.txt | 1 + test/unittest/dds/status/CMakeLists.txt | 1 + test/unittest/dynamic_types/CMakeLists.txt | 1 + test/unittest/statistics/dds/CMakeLists.txt | 2 + test/unittest/xmlparser/CMakeLists.txt | 3 + 8 files changed, 146 insertions(+) create mode 100644 include/fastrtps/utils/UnitsParser.hpp create mode 100644 src/cpp/utils/UnitsParser.cpp diff --git a/include/fastrtps/utils/UnitsParser.hpp b/include/fastrtps/utils/UnitsParser.hpp new file mode 100644 index 00000000000..022aad4dff1 --- /dev/null +++ b/include/fastrtps/utils/UnitsParser.hpp @@ -0,0 +1,61 @@ +// 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 UnitsParser.hpp + */ + +#ifndef _FASTDDS_UTILS_UNITS_PARSER_HPP_ +#define _FASTDDS_UTILS_UNITS_PARSER_HPP_ +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace eprosima { +namespace fastdds { +namespace dds { +namespace utils { + +/** + * Converts the string to uppercase. + * + * @param[in] st String to convert + */ +inline void to_uppercase( + std::string& st) noexcept; + +/** + * Converts a numeric value with units to bytes. + * + * @param[in] value Numeric value to convert + * @param[in] st Units to use for the conversion + * @return The value in bytes + */ +uint32_t parse_value_and_units( + std::string& value, + std::string units); + +} /* namespace utils */ +} /* namespace dds */ +} /* namespace fastdds */ +} /* namespace eprosima */ +#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC +#endif /* _FASTDDS_UTILS_UNITS_PARSER_HPP_ */ diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 94d6b578bed..aa616d869ce 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -239,6 +239,7 @@ set(${PROJECT_NAME}_source_files utils/SystemInfo.cpp utils/TimedConditionVariable.cpp utils/string_convert.cpp + utils/UnitsParser.cpp dds/core/types.cpp dds/core/Exception.cpp diff --git a/src/cpp/utils/UnitsParser.cpp b/src/cpp/utils/UnitsParser.cpp new file mode 100644 index 00000000000..500639764f9 --- /dev/null +++ b/src/cpp/utils/UnitsParser.cpp @@ -0,0 +1,76 @@ +// 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. + +/* + * UnitsParser.cpp + * + */ + +#include + +namespace eprosima { +namespace fastdds { +namespace dds { +namespace utils { + +void to_uppercase( + std::string& st) noexcept +{ + std::transform(st.begin(), st.end(), st.begin(), + [](unsigned char c) + { + return std::toupper(c); + }); +} + +uint32_t parse_value_and_units(std::string& value, std::string units) +{ + static const std::map magnitudes = { + {"B", 1}, + {"KB", 1000}, + {"MB", 1000 * 1000}, + {"GB", 1000 * 1000 * 1000}, + {"KIB", 1024}, + {"MIB", 1024 * 1024}, + {"GIB", 1024 * 1024 * 1024}, + }; + + uint64_t num = std::stoull(value); + to_uppercase(units); + + std::regex pattern(R"(([kibmgKIBMG]{1,3})|(\d+))"); + if (!std::regex_match(units, pattern)) + { + throw std::invalid_argument( + "The units are not in the expected format. Use: {B, KB, MG, GB, KIB, MIB, GIB})."); + } + const auto magnitude = magnitudes.at(units); + + // Check whether the product of number * magnitude overflows + if (num > std::numeric_limits::max() / magnitude) + { + throw std::invalid_argument("The number is too large to be converted to bytes (Max: 2^32-1 Bytes)."); + } + + // The explicit cast to uint32_t is safe since the number has already been checked to fit. + // The product is also safe since the possible overflow has also been checked. + const std::uint32_t bytes = static_cast(num) * magnitude; + + return bytes; +} + +} /* namespace utils */ +} /* namespace dds */ +} /* namespace fastdds */ +} /* namespace eprosima */ diff --git a/test/unittest/dds/publisher/CMakeLists.txt b/test/unittest/dds/publisher/CMakeLists.txt index 3bd42f2e22d..394c7d62a39 100644 --- a/test/unittest/dds/publisher/CMakeLists.txt +++ b/test/unittest/dds/publisher/CMakeLists.txt @@ -206,6 +206,7 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp ) if(SQLITE3_SUPPORT) diff --git a/test/unittest/dds/status/CMakeLists.txt b/test/unittest/dds/status/CMakeLists.txt index bba6bb8d8c2..00f64c70ebc 100644 --- a/test/unittest/dds/status/CMakeLists.txt +++ b/test/unittest/dds/status/CMakeLists.txt @@ -106,6 +106,7 @@ set(LISTENERTESTS_SOURCE ListenerTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/string_convert.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp ) if (FASTDDS_STATISTICS) diff --git a/test/unittest/dynamic_types/CMakeLists.txt b/test/unittest/dynamic_types/CMakeLists.txt index 405e5d8f44e..9db6cde841a 100644 --- a/test/unittest/dynamic_types/CMakeLists.txt +++ b/test/unittest/dynamic_types/CMakeLists.txt @@ -89,6 +89,7 @@ set(DYNAMIC_TYPES_TEST_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLParser.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLParserCommon.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLProfileManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp ) set(DYNAMIC_COMPLEX_TYPES_TEST_SOURCE diff --git a/test/unittest/statistics/dds/CMakeLists.txt b/test/unittest/statistics/dds/CMakeLists.txt index eace6ddeb7e..28de782ea78 100644 --- a/test/unittest/statistics/dds/CMakeLists.txt +++ b/test/unittest/statistics/dds/CMakeLists.txt @@ -296,6 +296,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp ) set(STATISTICS_DOMAINPARTICIPANT_STATUS_QUERYABLE_TESTS_SOURCE @@ -490,6 +491,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp ) # SHM Transport diff --git a/test/unittest/xmlparser/CMakeLists.txt b/test/unittest/xmlparser/CMakeLists.txt index 71340f67106..96166c56af2 100644 --- a/test/unittest/xmlparser/CMakeLists.txt +++ b/test/unittest/xmlparser/CMakeLists.txt @@ -118,6 +118,7 @@ set(XMLPROFILEPARSER_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/string_convert.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp ) # External sources @@ -226,6 +227,7 @@ set(XMLPARSER_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/string_convert.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp ) # External sources @@ -353,6 +355,7 @@ set(XMLENDPOINTPARSERTESTS_SOURCE ${PROJECT_SOURCE_DIR}/src/cpp/rtps/xmlparser/XMLParserCommon.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/string_convert.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp # locators ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp From d51ff94f19ed71222d0cd0fd1c2c12c333584f3c Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Fri, 23 Feb 2024 12:34:06 +0100 Subject: [PATCH 11/34] Refs #20493: Update xsd shcema Signed-off-by: cferreiragonz --- resources/xsd/fastRTPS_profiles.xsd | 44 ++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/resources/xsd/fastRTPS_profiles.xsd b/resources/xsd/fastRTPS_profiles.xsd index 81e2b317189..ad414295651 100644 --- a/resources/xsd/fastRTPS_profiles.xsd +++ b/resources/xsd/fastRTPS_profiles.xsd @@ -164,20 +164,7 @@ - - - - - - - - - - - - - - + @@ -195,6 +182,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + └ mode [string]--> - + @@ -206,9 +206,9 @@ - - - + + + @@ -209,6 +210,7 @@ + - - - - - - - - - - - - - - - - - - - - - - + └ (raw_data) [string]--> + + + + + + + + + + + + + + + + + + + + + + + + From ece2aea8ea1d363b40bba41062d5a430623618fb Mon Sep 17 00:00:00 2001 From: JesusPoderoso Date: Mon, 4 Mar 2024 14:37:44 +0100 Subject: [PATCH 30/34] Refs #20493: Update test XML according to XSD update Signed-off-by: JesusPoderoso --- test/blackbox/builtin_transports_profile.xml | 48 +++++--------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/test/blackbox/builtin_transports_profile.xml b/test/blackbox/builtin_transports_profile.xml index be876f3708f..750e4391f5e 100644 --- a/test/blackbox/builtin_transports_profile.xml +++ b/test/blackbox/builtin_transports_profile.xml @@ -12,9 +12,7 @@ 0 Participant.builtin_transports_none - - NONE - + NONE - + - - + + diff --git a/src/cpp/rtps/xmlparser/XMLElementParser.cpp b/src/cpp/rtps/xmlparser/XMLElementParser.cpp index a9dbd7f1f44..ff7d2fc2f41 100644 --- a/src/cpp/rtps/xmlparser/XMLElementParser.cpp +++ b/src/cpp/rtps/xmlparser/XMLElementParser.cpp @@ -4717,29 +4717,31 @@ XMLP_ret XMLParser::getXMLBuiltinTransports( tinyxml2::XMLElement* elem, eprosima::fastdds::rtps::BuiltinTransports* bt, eprosima::fastdds::rtps::BuiltinTransportsOptions* bt_opts, - uint8_t ident) + uint8_t /*ident*/) { /* - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + */ @@ -4873,50 +4875,28 @@ XMLP_ret XMLParser::getXMLBuiltinTransports( } } - std::set tags_present; + std::string mode = get_element_text(elem); - for (tinyxml2::XMLElement* current_elem = elem->FirstChildElement(); - current_elem != nullptr && ret != XMLP_ret::XML_ERROR; - current_elem = current_elem->NextSiblingElement()) + if (mode.empty()) { - const char* name = current_elem->Name(); - if (tags_present.count(name) != 0) - { - EPROSIMA_LOG_ERROR(XMLPARSER, "Duplicated element found in 'builtinTransports'. Tag: " << name); - ret = XMLP_ret::XML_ERROR; - break; - } - tags_present.emplace(name); + EPROSIMA_LOG_ERROR(XMLPARSER, "Node '" << KIND << "' without content"); + return XMLP_ret::XML_ERROR; + } - if (strcmp(current_elem->Name(), BT_MODE) == 0) - { - // Builtin transports selected - stringType - std::string s = ""; - if (XMLP_ret::XML_OK != getXMLString(current_elem, &s, ident)) - { - return XMLP_ret::XML_ERROR; - } - if (!get_element_enum_value(s.c_str(), *bt, - NONE, eprosima::fastdds::rtps::BuiltinTransports::NONE, - DEFAULT_C, eprosima::fastdds::rtps::BuiltinTransports::DEFAULT, - DEFAULTv6, eprosima::fastdds::rtps::BuiltinTransports::DEFAULTv6, - SHM, eprosima::fastdds::rtps::BuiltinTransports::SHM, - UDPv4, eprosima::fastdds::rtps::BuiltinTransports::UDPv4, - UDPv6, eprosima::fastdds::rtps::BuiltinTransports::UDPv6, - LARGE_DATA, eprosima::fastdds::rtps::BuiltinTransports::LARGE_DATA, - LARGE_DATAv6, eprosima::fastdds::rtps::BuiltinTransports::LARGE_DATAv6)) - { - EPROSIMA_LOG_ERROR(XMLPARSER, "Node '" << KIND << "' bad content"); - ret = XMLP_ret::XML_ERROR; - } - } - else - { - EPROSIMA_LOG_ERROR(XMLPARSER, "Found incorrect tag '" << current_elem->Name() << "'"); - ret = XMLP_ret::XML_ERROR; - break; - } + if (!get_element_enum_value(mode.c_str(), *bt, + NONE, eprosima::fastdds::rtps::BuiltinTransports::NONE, + DEFAULT_C, eprosima::fastdds::rtps::BuiltinTransports::DEFAULT, + DEFAULTv6, eprosima::fastdds::rtps::BuiltinTransports::DEFAULTv6, + SHM, eprosima::fastdds::rtps::BuiltinTransports::SHM, + UDPv4, eprosima::fastdds::rtps::BuiltinTransports::UDPv4, + UDPv6, eprosima::fastdds::rtps::BuiltinTransports::UDPv6, + LARGE_DATA, eprosima::fastdds::rtps::BuiltinTransports::LARGE_DATA, + LARGE_DATAv6, eprosima::fastdds::rtps::BuiltinTransports::LARGE_DATAv6)) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Node '" << KIND << "' bad content"); + ret = XMLP_ret::XML_ERROR; } + return ret; } diff --git a/src/cpp/rtps/xmlparser/XMLParserCommon.cpp b/src/cpp/rtps/xmlparser/XMLParserCommon.cpp index 8af34dcd586..ebd8c7de583 100644 --- a/src/cpp/rtps/xmlparser/XMLParserCommon.cpp +++ b/src/cpp/rtps/xmlparser/XMLParserCommon.cpp @@ -123,7 +123,6 @@ const char* THROUGHPUT_CONT = "throughputController"; const char* USER_TRANS = "userTransports"; const char* USE_BUILTIN_TRANS = "useBuiltinTransports"; const char* BUILTIN_TRANS = "builtinTransports"; -const char* BT_MODE = "mode"; const char* MAX_MSG_SIZE_LARGE_DATA = "max_msg_size"; const char* SOCKETS_SIZE_LARGE_DATA = "sockets_size"; const char* NON_BLOCKING_LARGE_DATA = "non_blocking"; From 4ee3a4364563085dc391ac93acb1fa3adcdcf1ac Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Mon, 4 Mar 2024 16:25:16 +0100 Subject: [PATCH 33/34] Refs #20493: Apply suggestions Signed-off-by: cferreiragonz --- include/fastdds/rtps/attributes/BuiltinTransports.hpp | 4 +++- include/fastrtps/utils/UnitsParser.hpp | 2 -- src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp | 9 +++++---- src/cpp/rtps/network/NetworkFactory.h | 2 +- src/cpp/utils/UnitsParser.cpp | 4 ++-- .../fastdds/rtps/attributes/RTPSParticipantAttributes.h | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/fastdds/rtps/attributes/BuiltinTransports.hpp b/include/fastdds/rtps/attributes/BuiltinTransports.hpp index 00ba4864432..c3038cb618e 100644 --- a/include/fastdds/rtps/attributes/BuiltinTransports.hpp +++ b/include/fastdds/rtps/attributes/BuiltinTransports.hpp @@ -21,6 +21,7 @@ #include #include +#include #include @@ -44,13 +45,14 @@ struct RTPS_DllAPI BuiltinTransportsOptions * to register every transport. * */ - uint32_t maxMessageSize = 65500; + uint32_t maxMessageSize = fastdds::rtps::s_maximumMessageSize; /** * @brief The value used to configure the send and receive fuffer sizes of the sockets. * * It specifies the value that will be used to configure the send and receive buffer sizes of the sockets * used by the transports created with the builtin transports. + * Zero value indicates to use default system buffer size. * */ uint32_t sockets_buffer_size = 0; diff --git a/include/fastrtps/utils/UnitsParser.hpp b/include/fastrtps/utils/UnitsParser.hpp index 7f478f8ef89..4fa2e1b0b0b 100644 --- a/include/fastrtps/utils/UnitsParser.hpp +++ b/include/fastrtps/utils/UnitsParser.hpp @@ -18,7 +18,6 @@ #ifndef _FASTDDS_UTILS_UNITS_PARSER_HPP_ #define _FASTDDS_UTILS_UNITS_PARSER_HPP_ -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #include @@ -50,5 +49,4 @@ uint32_t parse_value_and_units( } /* namespace dds */ } /* namespace fastdds */ } /* namespace eprosima */ -#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #endif /* _FASTDDS_UTILS_UNITS_PARSER_HPP_ */ diff --git a/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp b/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp index 89a5dbe3d0d..88a7f1dc389 100644 --- a/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp +++ b/src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp @@ -294,14 +294,15 @@ void RTPSParticipantAttributes::setup_transports( fastdds::rtps::BuiltinTransports transports, const fastdds::rtps::BuiltinTransportsOptions& options) { - if (options.maxMessageSize > 65500 && + if (options.maxMessageSize > fastdds::rtps::s_maximumMessageSize && (transports != fastdds::rtps::BuiltinTransports::NONE && transports != fastdds::rtps::BuiltinTransports::SHM && transports != fastdds::rtps::BuiltinTransports::LARGE_DATA && transports != fastdds::rtps::BuiltinTransports::LARGE_DATAv6)) { EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, - "Max message size of UDP cannot be greater than 65500. Will use DEFAULT transports."); + "Max message size of UDP cannot be greater than " << std::to_string( + fastdds::rtps::s_maximumMessageSize) << "."); return; } bool intraprocess_only = is_intraprocess_only(*this); @@ -335,13 +336,13 @@ void RTPSParticipantAttributes::setup_transports( break; case fastdds::rtps::BuiltinTransports::LARGE_DATA: - // This parameter will allow allow the initialization of UDP transports with maxMessageSize > 65500 KB + // This parameter will allow allow the initialization of UDP transports with maxMessageSize > 65500 KB (s_maximumMessageSize) max_msg_size_no_frag = options.maxMessageSize; setup_transports_large_data(*this, intraprocess_only, options); break; case fastdds::rtps::BuiltinTransports::LARGE_DATAv6: - // This parameter will allow allow the initialization of UDP transports with maxMessageSize > 65500 KB + // This parameter will allow allow the initialization of UDP transports with maxMessageSize > 65500 KB (s_maximumMessageSize) max_msg_size_no_frag = options.maxMessageSize; setup_transports_large_datav6(*this, intraprocess_only, options); break; diff --git a/src/cpp/rtps/network/NetworkFactory.h b/src/cpp/rtps/network/NetworkFactory.h index cdbbf2daed1..21d21334028 100644 --- a/src/cpp/rtps/network/NetworkFactory.h +++ b/src/cpp/rtps/network/NetworkFactory.h @@ -67,7 +67,7 @@ class NetworkFactory * * @param descriptor Structure that defines all initial configuration for a given transport. * @param properties Optional policy to specify additional parameters for the created transport. - * @param max_msg_size_no_frag Optional parameter that will allow to skip 65500 KB maxMessageSize limit. + * @param max_msg_size_no_frag Optional parameter that will allow to skip 65500 KB (s_maximumMessageSize) maxMessageSize limit. * during the transport initialization. */ bool RegisterTransport( diff --git a/src/cpp/utils/UnitsParser.cpp b/src/cpp/utils/UnitsParser.cpp index 2b2cc2cf98d..46fd736847e 100644 --- a/src/cpp/utils/UnitsParser.cpp +++ b/src/cpp/utils/UnitsParser.cpp @@ -63,14 +63,14 @@ uint32_t parse_value_and_units( if (!std::regex_match(units, pattern)) { throw std::invalid_argument( - "The units are not in the expected format. Use: {B, KB, MG, GB, KIB, MIB, GIB})."); + "The units are not in the expected format. Use: {B, KB, MG, GB, KIB, MIB, GIB}."); } const auto magnitude = magnitudes.at(units); // Check whether the product of number * magnitude overflows if (num > std::numeric_limits::max() / magnitude) { - throw std::invalid_argument("The number is too large to be converted to bytes (Max: 2^32-1 Bytes)."); + throw std::invalid_argument("The number is too large to be converted to bytes (Max: (2^32)-1 Bytes)."); } // The explicit cast to uint32_t is safe since the number has already been checked to fit. diff --git a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h index 0e411d6acf4..4d2040b1193 100644 --- a/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h +++ b/test/mock/rtps/RTPSParticipantAttributes/fastdds/rtps/attributes/RTPSParticipantAttributes.h @@ -643,7 +643,7 @@ class RTPSParticipantAttributes /*! Maximum message size used to avoid fragmentation, setted ONLY in LARGE_DATA. If this value is * not zero, the network factory will allow the initialization of UDP transports with maxMessageSize - * higher than 65500K. + * higher than 65500 KB (s_maximumMessageSize). */ uint32_t max_msg_size_no_frag = 0; From a72bc9a1618fd7e20f10e328d1a72704abbf6a56 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Wed, 6 Mar 2024 11:59:56 +0100 Subject: [PATCH 34/34] Refs #20493: Abort use of std::toupper() Signed-off-by: cferreiragonz --- src/cpp/utils/UnitsParser.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cpp/utils/UnitsParser.cpp b/src/cpp/utils/UnitsParser.cpp index 46fd736847e..7c46d2fb460 100644 --- a/src/cpp/utils/UnitsParser.cpp +++ b/src/cpp/utils/UnitsParser.cpp @@ -36,9 +36,17 @@ void to_uppercase( std::string& st) noexcept { std::transform(st.begin(), st.end(), st.begin(), - [](int c) + [](char c) { - return static_cast(std::toupper(c)); + //TODO Carlos: use std::toupper after update VS2019 + if (c >= 'a' && c <= 'z') + { + return static_cast(c - 'a' + 'A'); + } + else + { + return static_cast(c); + } }); }