diff --git a/include/fastdds/dds/core/policy/ParameterTypes.hpp b/include/fastdds/dds/core/policy/ParameterTypes.hpp index 9e2e14c2791..e583831acdf 100644 --- a/include/fastdds/dds/core/policy/ParameterTypes.hpp +++ b/include/fastdds/dds/core/policy/ParameterTypes.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -165,11 +166,12 @@ enum ParameterId_t : uint16_t PID_RELATED_SAMPLE_IDENTITY = 0x0083, /* eProsima Fast DDS extensions */ + PID_PRODUCT_VERSION = 0x8000, PID_PERSISTENCE_GUID = 0x8002, - PID_CUSTOM_RELATED_SAMPLE_IDENTITY = 0x800f, PID_DISABLE_POSITIVE_ACKS = 0x8005, PID_DATASHARING = 0x8006, PID_NETWORK_CONFIGURATION_SET = 0x8007, + PID_CUSTOM_RELATED_SAMPLE_IDENTITY = 0x800f, }; /*! @@ -632,6 +634,39 @@ class ParameterVendorId_t : public Parameter_t #define PARAMETER_VENDOR_LENGTH 4 +/** + * @ingroup PARAMETER_MODULE + */ +class ParameterProductVersion_t : public Parameter_t +{ +public: + + rtps::ProductVersion_t version; + + /** + * @brief Constructor without parameters + */ + ParameterProductVersion_t() + { + } + + /** + * Constructor using a parameter PID and the parameter length + * + * @param pid Pid of the parameter + * @param in_length Its associated length + */ + ParameterProductVersion_t( + ParameterId_t pid, + uint16_t in_length) + : Parameter_t(pid, in_length) + { + } + +}; + +#define PARAMETER_PRODUCT_VERSION_LENGTH 4 + /** * @ingroup PARAMETER_MODULE */ @@ -1883,6 +1918,7 @@ using ParameterGuid_t = fastdds::dds::ParameterGuid_t; using ParameterDomainId_t = fastdds::dds::ParameterDomainId_t; using ParameterProtocolVersion_t = fastdds::dds::ParameterProtocolVersion_t; using ParameterVendorId_t = fastdds::dds::ParameterVendorId_t; +using ParameterProductVersion_t = fastdds::dds::ParameterProductVersion_t; using ParameterIP4Address_t = fastdds::dds::ParameterIP4Address_t; using ParameterBool_t = fastdds::dds::ParameterBool_t; using ParameterStatusInfo_t = fastdds::dds::ParameterStatusInfo_t; diff --git a/include/fastdds/rtps/builtin/data/ParticipantBuiltinTopicData.hpp b/include/fastdds/rtps/builtin/data/ParticipantBuiltinTopicData.hpp index 479490fb4d7..98ed5e49499 100644 --- a/include/fastdds/rtps/builtin/data/ParticipantBuiltinTopicData.hpp +++ b/include/fastdds/rtps/builtin/data/ParticipantBuiltinTopicData.hpp @@ -22,6 +22,7 @@ #include #include +#include #include namespace eprosima { @@ -57,6 +58,9 @@ struct ParticipantBuiltinTopicData /// Vendor id VendorId_t vendor_id; + /// Product version + ProductVersion_t product_version; + /// Participant domain id dds::DomainId_t domain_id; }; diff --git a/include/fastdds/rtps/common/ProductVersion_t.hpp b/include/fastdds/rtps/common/ProductVersion_t.hpp new file mode 100644 index 00000000000..331c888d107 --- /dev/null +++ b/include/fastdds/rtps/common/ProductVersion_t.hpp @@ -0,0 +1,59 @@ +// 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 ProductVersion_t.hpp + */ + +#ifndef FASTDDS_RTPS_COMMON__PRODUCTVERSION_T_HPP +#define FASTDDS_RTPS_COMMON__PRODUCTVERSION_T_HPP + +#include +#include +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { + +struct ProductVersion_t +{ + uint8_t major {0}; + uint8_t minor {0}; + uint8_t patch {0}; + uint8_t tweak {0}; +}; + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima + +/** + * @brief ostream operator<< for ProductVersion_t + * + * @param output: the output stream + * @param product_version: the product version to append to the output stream + */ +inline std::ostream& operator <<( + std::ostream& output, + eprosima::fastdds::rtps::ProductVersion_t product_version) +{ + output << static_cast(product_version.major) + << "." << static_cast(product_version.minor) + << "." << static_cast(product_version.patch) + << "." << static_cast(product_version.tweak); + return output; +} + +#endif /* FASTDDS_RTPS_COMMON__PRODUCTVERSION_T_HPP */ diff --git a/include/fastdds/rtps/common/Types.hpp b/include/fastdds/rtps/common/Types.hpp index 2e1105a0837..18c3335ca3d 100644 --- a/include/fastdds/rtps/common/Types.hpp +++ b/include/fastdds/rtps/common/Types.hpp @@ -26,6 +26,7 @@ #include +#include #include namespace eprosima { diff --git a/src/cpp/fastdds/core/policy/ParameterSerializer.hpp b/src/cpp/fastdds/core/policy/ParameterSerializer.hpp index 5f687bb7464..64d5fb509ff 100644 --- a/src/cpp/fastdds/core/policy/ParameterSerializer.hpp +++ b/src/cpp/fastdds/core/policy/ParameterSerializer.hpp @@ -433,6 +433,36 @@ inline bool ParameterSerializer::read_content_from_cdr_mess return valid; } +template<> +inline bool ParameterSerializer::add_content_to_cdr_message( + const ParameterProductVersion_t& parameter, + rtps::CDRMessage_t* cdr_message) +{ + bool valid = rtps::CDRMessage::addOctet(cdr_message, parameter.version.major); + valid &= rtps::CDRMessage::addOctet(cdr_message, parameter.version.minor); + valid &= rtps::CDRMessage::addOctet(cdr_message, parameter.version.patch); + valid &= rtps::CDRMessage::addOctet(cdr_message, parameter.version.tweak); + return valid; +} + +template<> +inline bool ParameterSerializer::read_content_from_cdr_message( + ParameterProductVersion_t& parameter, + rtps::CDRMessage_t* cdr_message, + const uint16_t parameter_length) +{ + if (parameter_length != PARAMETER_PRODUCT_VERSION_LENGTH) + { + return false; + } + parameter.length = parameter_length; + bool valid = rtps::CDRMessage::readOctet(cdr_message, ¶meter.version.major); + valid &= rtps::CDRMessage::readOctet(cdr_message, ¶meter.version.minor); + valid &= rtps::CDRMessage::readOctet(cdr_message, ¶meter.version.patch); + valid &= rtps::CDRMessage::readOctet(cdr_message, ¶meter.version.tweak); + return valid; +} + template<> inline bool ParameterSerializer::add_content_to_cdr_message( const ParameterDomainId_t& parameter, diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp index 4ecd0e37a88..b9746004f03 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -55,9 +56,11 @@ ParticipantProxyData::ParticipantProxyData( , m_expectsInlineQos(false) , m_availableBuiltinEndpoints(0) , m_networkConfiguration(0) - , metatraffic_locators(allocation.locators.max_unicast_locators, allocation.locators.max_multicast_locators) - , default_locators(allocation.locators.max_unicast_locators, allocation.locators.max_multicast_locators) - , m_manualLivelinessCount () + , metatraffic_locators(allocation.locators.max_unicast_locators, + allocation.locators.max_multicast_locators) + , default_locators(allocation.locators.max_unicast_locators, + allocation.locators.max_multicast_locators) + , m_manualLivelinessCount() #if HAVE_SECURITY , security_attributes_(0UL) , plugin_security_attributes_(0UL) @@ -78,13 +81,14 @@ ParticipantProxyData::ParticipantProxyData( : m_protocolVersion(pdata.m_protocolVersion) , m_guid(pdata.m_guid) , m_VendorId(pdata.m_VendorId) + , product_version(pdata.product_version) , m_domain_id(pdata.m_domain_id) , m_expectsInlineQos(pdata.m_expectsInlineQos) , m_availableBuiltinEndpoints(pdata.m_availableBuiltinEndpoints) , m_networkConfiguration(pdata.m_networkConfiguration) , metatraffic_locators(pdata.metatraffic_locators) , default_locators(pdata.default_locators) - , m_manualLivelinessCount () + , m_manualLivelinessCount() , m_participantName(pdata.m_participantName) , m_key(pdata.m_key) , m_leaseDuration(pdata.m_leaseDuration) @@ -147,10 +151,13 @@ uint32_t ParticipantProxyData::get_serialized_size( uint32_t ret_val = include_encapsulation ? 4 : 0; // PID_PROTOCOL_VERSION - ret_val += 4 + 4; + ret_val += 4 + PARAMETER_PROTOCOL_LENGTH; // PID_VENDORID - ret_val += 4 + 4; + ret_val += 4 + PARAMETER_VENDOR_LENGTH; + + // PID_PRODUCT_VERSION + ret_val += 4 + PARAMETER_PRODUCT_VERSION_LENGTH; // PID_DOMAIN_ID ret_val += 4 + PARAMETER_DOMAINID_LENGTH; @@ -168,16 +175,22 @@ uint32_t ParticipantProxyData::get_serialized_size( ret_val += 4 + PARAMETER_NETWORKCONFIGSET_LENGTH; // PID_METATRAFFIC_MULTICAST_LOCATOR - ret_val += static_cast((4 + PARAMETER_LOCATOR_LENGTH) * metatraffic_locators.multicast.size()); + ret_val += + static_cast((4 + PARAMETER_LOCATOR_LENGTH) * + metatraffic_locators.multicast.size()); // PID_METATRAFFIC_UNICAST_LOCATOR - ret_val += static_cast((4 + PARAMETER_LOCATOR_LENGTH) * metatraffic_locators.unicast.size()); + ret_val += + static_cast((4 + PARAMETER_LOCATOR_LENGTH) * + metatraffic_locators.unicast.size()); // PID_DEFAULT_UNICAST_LOCATOR - ret_val += static_cast((4 + PARAMETER_LOCATOR_LENGTH) * default_locators.unicast.size()); + ret_val += + static_cast((4 + PARAMETER_LOCATOR_LENGTH) * default_locators.unicast.size()); // PID_DEFAULT_MULTICAST_LOCATOR - ret_val += static_cast((4 + PARAMETER_LOCATOR_LENGTH) * default_locators.multicast.size()); + ret_val += + static_cast((4 + PARAMETER_LOCATOR_LENGTH) * default_locators.multicast.size()); // PID_PARTICIPANT_LEASE_DURATION ret_val += 4 + PARAMETER_TIME_LENGTH; @@ -188,19 +201,22 @@ uint32_t ParticipantProxyData::get_serialized_size( if (m_participantName.size() > 0) { // PID_ENTITY_NAME - ret_val += fastdds::dds::ParameterSerializer::cdr_serialized_size(m_participantName); + ret_val += + fastdds::dds::ParameterSerializer::cdr_serialized_size(m_participantName); } if (m_userData.size() > 0) { // PID_USER_DATA - ret_val += fastdds::dds::QosPoliciesSerializer::cdr_serialized_size(m_userData); + ret_val += fastdds::dds::QosPoliciesSerializer::cdr_serialized_size( + m_userData); } if (m_properties.size() > 0) { // PID_PROPERTY_LIST - ret_val += fastdds::dds::ParameterSerializer::cdr_serialized_size(m_properties); + ret_val += fastdds::dds::ParameterSerializer::cdr_serialized_size( + m_properties); } #if HAVE_SECURITY @@ -213,7 +229,8 @@ uint32_t ParticipantProxyData::get_serialized_size( if (!permissions_token_.class_id().empty()) { // PID_PERMISSIONS_TOKEN - ret_val += fastdds::dds::ParameterSerializer::cdr_serialized_size(permissions_token_); + ret_val += fastdds::dds::ParameterSerializer::cdr_serialized_size( + permissions_token_); } if ((security_attributes_ != 0UL) || (plugin_security_attributes_ != 0UL)) @@ -240,15 +257,17 @@ bool ParticipantProxyData::writeToCDRMessage( } { - ParameterProtocolVersion_t p(fastdds::dds::PID_PROTOCOL_VERSION, 4); + ParameterProtocolVersion_t p(fastdds::dds::PID_PROTOCOL_VERSION, PARAMETER_PROTOCOL_LENGTH); p.protocolVersion = this->m_protocolVersion; - if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg)) + if (!fastdds::dds::ParameterSerializer::add_to_cdr_message( + p, + msg)) { return false; } } { - ParameterVendorId_t p(fastdds::dds::PID_VENDORID, 4); + ParameterVendorId_t p(fastdds::dds::PID_VENDORID, PARAMETER_VENDOR_LENGTH); p.vendorId[0] = this->m_VendorId[0]; p.vendorId[1] = this->m_VendorId[1]; if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg)) @@ -256,6 +275,18 @@ bool ParticipantProxyData::writeToCDRMessage( return false; } } + { + ParameterProductVersion_t p(fastdds::dds::PID_PRODUCT_VERSION, + PARAMETER_PRODUCT_VERSION_LENGTH); + p.version.major = this->product_version.major; + p.version.minor = this->product_version.minor; + p.version.patch = this->product_version.patch; + p.version.tweak = this->product_version.tweak; + if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg)) + { + return false; + } + } { ParameterDomainId_t p(fastdds::dds::PID_DOMAIN_ID, 4); p.domain_id = this->m_domain_id; @@ -266,7 +297,8 @@ bool ParticipantProxyData::writeToCDRMessage( } if (this->m_expectsInlineQos) { - ParameterBool_t p(fastdds::dds::PID_EXPECTS_INLINE_QOS, PARAMETER_BOOL_LENGTH, m_expectsInlineQos); + ParameterBool_t p(fastdds::dds::PID_EXPECTS_INLINE_QOS, PARAMETER_BOOL_LENGTH, + m_expectsInlineQos); if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg)) { return false; @@ -280,16 +312,20 @@ bool ParticipantProxyData::writeToCDRMessage( } } { - ParameterNetworkConfigSet_t p(fastdds::dds::PID_NETWORK_CONFIGURATION_SET, PARAMETER_NETWORKCONFIGSET_LENGTH); + ParameterNetworkConfigSet_t p(fastdds::dds::PID_NETWORK_CONFIGURATION_SET, + PARAMETER_NETWORKCONFIGSET_LENGTH); p.netconfigSet = m_networkConfiguration; - if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg)) + if (!fastdds::dds::ParameterSerializer::add_to_cdr_message( + p, + msg)) { return false; } } for (const Locator_t& it : metatraffic_locators.multicast) { - ParameterLocator_t p(fastdds::dds::PID_METATRAFFIC_MULTICAST_LOCATOR, PARAMETER_LOCATOR_LENGTH, it); + ParameterLocator_t p(fastdds::dds::PID_METATRAFFIC_MULTICAST_LOCATOR, PARAMETER_LOCATOR_LENGTH, + it); if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg)) { return false; @@ -297,7 +333,8 @@ bool ParticipantProxyData::writeToCDRMessage( } for (const Locator_t& it : metatraffic_locators.unicast) { - ParameterLocator_t p(fastdds::dds::PID_METATRAFFIC_UNICAST_LOCATOR, PARAMETER_LOCATOR_LENGTH, it); + ParameterLocator_t p(fastdds::dds::PID_METATRAFFIC_UNICAST_LOCATOR, PARAMETER_LOCATOR_LENGTH, + it); if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg)) { return false; @@ -328,9 +365,12 @@ bool ParticipantProxyData::writeToCDRMessage( } } { - ParameterBuiltinEndpointSet_t p(fastdds::dds::PID_BUILTIN_ENDPOINT_SET, PARAMETER_BUILTINENDPOINTSET_LENGTH); + ParameterBuiltinEndpointSet_t p(fastdds::dds::PID_BUILTIN_ENDPOINT_SET, + PARAMETER_BUILTINENDPOINTSET_LENGTH); p.endpointSet = m_availableBuiltinEndpoints; - if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg)) + if (!fastdds::dds::ParameterSerializer::add_to_cdr_message( + p, + msg)) { return false; } @@ -347,8 +387,9 @@ bool ParticipantProxyData::writeToCDRMessage( if (m_userData.size() > 0) { - if (!fastdds::dds::QosPoliciesSerializer::add_to_cdr_message(m_userData, - msg)) + if (!fastdds::dds::QosPoliciesSerializer::add_to_cdr_message( + m_userData, + msg)) { return false; } @@ -356,7 +397,9 @@ bool ParticipantProxyData::writeToCDRMessage( if (m_properties.size() > 0) { - if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(m_properties, msg)) + if (!fastdds::dds::ParameterSerializer::add_to_cdr_message( + m_properties, + msg)) { return false; } @@ -388,7 +431,9 @@ bool ParticipantProxyData::writeToCDRMessage( ParameterParticipantSecurityInfo_t p; p.security_attributes = security_attributes_; p.plugin_security_attributes = plugin_security_attributes_; - if (!fastdds::dds::ParameterSerializer::add_to_cdr_message(p, msg)) + if (!fastdds::dds::ParameterSerializer::add_to_cdr_message( + p, + msg)) { return false; } @@ -406,15 +451,18 @@ bool ParticipantProxyData::readFromCDRMessage( bool should_filter_locators, fastdds::rtps::VendorId_t source_vendor_id) { - auto param_process = [this, &network, &is_shm_transport_available, &should_filter_locators, source_vendor_id]( + auto param_process = + [this, &network, &is_shm_transport_available, &should_filter_locators, source_vendor_id]( CDRMessage_t* msg, const ParameterId_t& pid, uint16_t plength) { - switch (pid) - { + static_cast(source_vendor_id); + switch (pid){ case fastdds::dds::PID_KEY_HASH: { ParameterKey_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } @@ -428,8 +476,10 @@ bool ParticipantProxyData::readFromCDRMessage( case fastdds::dds::PID_PROTOCOL_VERSION: { ParameterProtocolVersion_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, - msg, plength)) + if (!fastdds::dds::ParameterSerializer:: + read_from_cdr_message( + p, + msg, plength)) { return false; } @@ -444,8 +494,9 @@ bool ParticipantProxyData::readFromCDRMessage( case fastdds::dds::PID_VENDORID: { ParameterVendorId_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, - plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } @@ -455,11 +506,34 @@ bool ParticipantProxyData::readFromCDRMessage( is_shm_transport_available &= (m_VendorId == c_VendorId_eProsima); break; } + case fastdds::dds::PID_PRODUCT_VERSION: + { + // Ignore custom PID when coming from other vendors + if (c_VendorId_eProsima != m_VendorId) + { + EPROSIMA_LOG_INFO( + RTPS_PROXY_DATA, + "Ignoring custom PID" << pid << " from vendor " << source_vendor_id); + return true; + } + + ParameterProductVersion_t p(pid, plength); + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, + msg, plength)) + { + return false; + } + + product_version = p.version; + break; + } case fastdds::dds::PID_DOMAIN_ID: { ParameterDomainId_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, - plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } @@ -470,7 +544,9 @@ bool ParticipantProxyData::readFromCDRMessage( case fastdds::dds::PID_EXPECTS_INLINE_QOS: { ParameterBool_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } @@ -481,7 +557,9 @@ bool ParticipantProxyData::readFromCDRMessage( case fastdds::dds::PID_PARTICIPANT_GUID: { ParameterGuid_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } @@ -492,23 +570,20 @@ bool ParticipantProxyData::readFromCDRMessage( } case fastdds::dds::PID_NETWORK_CONFIGURATION_SET: { - VendorId_t local_vendor_id = source_vendor_id; - if (c_VendorId_Unknown == local_vendor_id) - { - local_vendor_id = ((c_VendorId_Unknown == m_VendorId) ? c_VendorId_eProsima : m_VendorId); - } - // Ignore custom PID when coming from other vendors - if (c_VendorId_eProsima != local_vendor_id) + if (c_VendorId_eProsima != m_VendorId) { - EPROSIMA_LOG_INFO(RTPS_PROXY_DATA, - "Ignoring custom PID" << pid << " from vendor " << local_vendor_id); + EPROSIMA_LOG_INFO( + RTPS_PROXY_DATA, + "Ignoring custom PID" << pid << " from vendor " << source_vendor_id); return true; } ParameterNetworkConfigSet_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, - msg, plength)) + if (!fastdds::dds::ParameterSerializer:: + read_from_cdr_message( + p, + msg, plength)) { return false; } @@ -519,8 +594,9 @@ bool ParticipantProxyData::readFromCDRMessage( case fastdds::dds::PID_METATRAFFIC_MULTICAST_LOCATOR: { ParameterLocator_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, - plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } @@ -532,8 +608,9 @@ bool ParticipantProxyData::readFromCDRMessage( else { Locator_t temp_locator; - if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) + if (network.transform_remote_locator( + p.locator, temp_locator, m_networkConfiguration, + m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( is_shm_transport_available, @@ -547,8 +624,9 @@ bool ParticipantProxyData::readFromCDRMessage( case fastdds::dds::PID_METATRAFFIC_UNICAST_LOCATOR: { ParameterLocator_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, - plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } @@ -560,8 +638,9 @@ bool ParticipantProxyData::readFromCDRMessage( else { Locator_t temp_locator; - if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) + if (network.transform_remote_locator( + p.locator, temp_locator, m_networkConfiguration, + m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( is_shm_transport_available, @@ -575,8 +654,9 @@ bool ParticipantProxyData::readFromCDRMessage( case fastdds::dds::PID_DEFAULT_UNICAST_LOCATOR: { ParameterLocator_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, - plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } @@ -588,8 +668,9 @@ bool ParticipantProxyData::readFromCDRMessage( else { Locator_t temp_locator; - if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) + if (network.transform_remote_locator( + p.locator, temp_locator, m_networkConfiguration, + m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( is_shm_transport_available, @@ -603,8 +684,9 @@ bool ParticipantProxyData::readFromCDRMessage( case fastdds::dds::PID_DEFAULT_MULTICAST_LOCATOR: { ParameterLocator_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, - plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } @@ -616,8 +698,9 @@ bool ParticipantProxyData::readFromCDRMessage( else { Locator_t temp_locator; - if (network.transform_remote_locator(p.locator, temp_locator, m_networkConfiguration, - m_guid.is_from_this_host())) + if (network.transform_remote_locator( + p.locator, temp_locator, m_networkConfiguration, + m_guid.is_from_this_host())) { ProxyDataFilters::filter_locators( is_shm_transport_available, @@ -631,22 +714,27 @@ bool ParticipantProxyData::readFromCDRMessage( case fastdds::dds::PID_PARTICIPANT_LEASE_DURATION: { ParameterTime_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } m_leaseDuration = p.time.to_duration_t(); lease_duration_ = - std::chrono::microseconds(fastdds::rtps::TimeConv::Duration_t2MicroSecondsInt64( - m_leaseDuration)); + std::chrono::microseconds( + fastdds::rtps::TimeConv::Duration_t2MicroSecondsInt64( + m_leaseDuration)); break; } case fastdds::dds::PID_BUILTIN_ENDPOINT_SET: { ParameterBuiltinEndpointSet_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, - msg, plength)) + if (!fastdds::dds::ParameterSerializer:: + read_from_cdr_message( + p, + msg, plength)) { return false; } @@ -657,8 +745,9 @@ bool ParticipantProxyData::readFromCDRMessage( case fastdds::dds::PID_ENTITY_NAME: { ParameterString_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, - plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } @@ -689,15 +778,18 @@ bool ParticipantProxyData::readFromCDRMessage( { #if HAVE_SECURITY ParameterToken_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, - plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } identity_token_ = std::move(p.token); #else - EPROSIMA_LOG_WARNING(RTPS_PARTICIPANT, "Received PID_IDENTITY_TOKEN but security is disabled"); + EPROSIMA_LOG_WARNING( + RTPS_PARTICIPANT, + "Received PID_IDENTITY_TOKEN but security is disabled"); #endif // if HAVE_SECURITY break; } @@ -705,16 +797,18 @@ bool ParticipantProxyData::readFromCDRMessage( { #if HAVE_SECURITY ParameterToken_t p(pid, plength); - if (!fastdds::dds::ParameterSerializer::read_from_cdr_message(p, msg, - plength)) + if (!fastdds::dds::ParameterSerializer::read_from_cdr_message( + p, msg, + plength)) { return false; } permissions_token_ = std::move(p.token); #else - EPROSIMA_LOG_WARNING(RTPS_PARTICIPANT, - "Received PID_PERMISSIONS_TOKEN but security is disabled"); + EPROSIMA_LOG_WARNING( + RTPS_PARTICIPANT, + "Received PID_PERMISSIONS_TOKEN but security is disabled"); #endif // if HAVE_SECURITY break; } @@ -732,8 +826,9 @@ bool ParticipantProxyData::readFromCDRMessage( security_attributes_ = p.security_attributes; plugin_security_attributes_ = p.plugin_security_attributes; #else - EPROSIMA_LOG_WARNING(RTPS_PARTICIPANT, - "Received PID_PARTICIPANT_SECURITY_INFO but security is disabled"); + EPROSIMA_LOG_WARNING( + RTPS_PARTICIPANT, + "Received PID_PARTICIPANT_SECURITY_INFO but security is disabled"); #endif // if HAVE_SECURITY break; } @@ -750,7 +845,9 @@ bool ParticipantProxyData::readFromCDRMessage( clear(); try { - return ParameterList::readParameterListfromCDRMsg(*msg, param_process, use_encapsulation, qos_size); + return ParameterList::readParameterListfromCDRMsg( + *msg, param_process, use_encapsulation, + qos_size); } catch (std::bad_alloc& ba) { @@ -765,6 +862,7 @@ void ParticipantProxyData::clear() m_guid = GUID_t(); //set_VendorId_Unknown(m_VendorId); m_VendorId = c_VendorId_Unknown; + product_version = {}; m_domain_id = fastdds::dds::DOMAIN_ID_UNKNOWN; m_expectsInlineQos = false; m_availableBuiltinEndpoints = 0; @@ -797,6 +895,7 @@ void ParticipantProxyData::copy( m_guid = pdata.m_guid; m_VendorId[0] = pdata.m_VendorId[0]; m_VendorId[1] = pdata.m_VendorId[1]; + product_version = pdata.product_version; m_domain_id = pdata.m_domain_id; m_availableBuiltinEndpoints = pdata.m_availableBuiltinEndpoints; m_networkConfiguration = pdata.m_networkConfiguration; @@ -805,8 +904,9 @@ void ParticipantProxyData::copy( m_participantName = pdata.m_participantName; m_leaseDuration = pdata.m_leaseDuration; lease_duration_ = - std::chrono::microseconds(fastdds::rtps::TimeConv::Duration_t2MicroSecondsInt64( - pdata.m_leaseDuration)); + std::chrono::microseconds( + fastdds::rtps::TimeConv::Duration_t2MicroSecondsInt64( + pdata.m_leaseDuration)); m_key = pdata.m_key; isAlive = pdata.isAlive; m_userData = pdata.m_userData; @@ -889,7 +989,8 @@ void ParticipantProxyData::set_persistence_guid( { if (!it->modify(persistent_guid)) { - EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT, "Failed to change property <" + EPROSIMA_LOG_ERROR( + RTPS_PARTICIPANT, "Failed to change property <" << it->first() << " | " << it->second() << "> to <" << persistent_guid.first << " | " << persistent_guid.second << ">"); } diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp index 5f7906746ce..540c80010f6 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace eprosima { @@ -76,6 +77,8 @@ class ParticipantProxyData GUID_t m_guid; //!Vendor ID fastdds::rtps::VendorId_t m_VendorId; + //! Product version + fastdds::rtps::ProductVersion_t product_version; //!Domain ID fastdds::dds::DomainId_t m_domain_id; //!Expects Inline QOS. diff --git a/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp b/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp index d5f2d5dc002..13ea8d41455 100644 --- a/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp +++ b/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp @@ -113,6 +113,7 @@ void from_proxy_to_builtin( builtin_data.properties = proxy_data.m_properties; builtin_data.lease_duration = proxy_data.m_leaseDuration; builtin_data.vendor_id = proxy_data.m_VendorId; + builtin_data.product_version = proxy_data.product_version; builtin_data.domain_id = proxy_data.m_domain_id; } diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 2f869880689..3bf1b376783 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -306,6 +307,9 @@ void PDP::initializeParticipantProxyData( participant_data->m_leaseDuration = attributes.builtin.discovery_config.leaseDuration; //set_VendorId_eProsima(participant_data->m_VendorId); participant_data->m_VendorId = c_VendorId_eProsima; + participant_data->product_version.major = FASTDDS_VERSION_MAJOR; + participant_data->product_version.minor = FASTDDS_VERSION_MINOR; + participant_data->product_version.patch = FASTDDS_VERSION_MICRO; // TODO: participant_data->m_availableBuiltinEndpoints |= mp_builtin->available_builtin_endpoints(); diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index aac619c3510..706c955a72e 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -140,6 +141,61 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) } } +TEST(BuiltinDataSerializationTests, msg_with_product_version) +{ + /* Convenient functions to group code */ + auto participant_read = [](octet* buffer, uint32_t buffer_length, ParticipantProxyData& out) -> void + { + CDRMessage_t msg(0); + msg.init(buffer, buffer_length); + msg.length = msg.max_size; + + EXPECT_NO_THROW(EXPECT_TRUE(out.readFromCDRMessage(&msg, true, network, false, false, + c_VendorId_eProsima))); + }; + + auto update_cache_change = + [](CacheChange_t& change, octet* buffer, uint32_t buffer_length, uint32_t qos_size) -> void + { + CDRMessage_t msg(0); + msg.init(buffer, buffer_length); + msg.length = msg.max_size; + + EXPECT_TRUE(fastdds::dds::ParameterList::updateCacheChangeFromInlineQos(change, &msg, qos_size)); + }; + + // PID_PRODUCT_VERSION + { + octet data_buffer[] = + { + // Encapsulation + 0x00, 0x03, 0x00, 0x00, + // PID_VENDORID + 0x16, 0x00, 0x04, 0x00, + 0x01, 0x0f, 0x00, 0x00, + // PID_PRODUCT_VERSION + 0x00, 0x80, 0x04, 0x00, + FASTDDS_VERSION_MAJOR, FASTDDS_VERSION_MINOR, FASTDDS_VERSION_MICRO, 0, + // PID_SENTINEL + 0x01, 0x00, 0x00, 0x00 + }; + + uint32_t buffer_length = static_cast(sizeof(data_buffer)); + + // ParticipantProxyData check + ParticipantProxyData participant_pdata(RTPSParticipantAllocationAttributes{}); + participant_read(data_buffer, buffer_length, participant_pdata); + EXPECT_EQ(FASTDDS_VERSION_MAJOR, participant_pdata.product_version.major); + EXPECT_EQ(FASTDDS_VERSION_MINOR, participant_pdata.product_version.minor); + EXPECT_EQ(FASTDDS_VERSION_MICRO, participant_pdata.product_version.patch); + EXPECT_EQ(0, participant_pdata.product_version.tweak); + + // CacheChange_t check + CacheChange_t change; + update_cache_change(change, data_buffer, buffer_length, 0); + } +} + TEST(BuiltinDataSerializationTests, msg_without_datasharing) { { @@ -773,6 +829,34 @@ TEST(BuiltinDataSerializationTests, other_vendor_parameter_list_with_custom_pids CacheChange_t change; update_cache_change(change, data_buffer, buffer_length, 0); } + + // PID_PRODUCT_VERSION + { + octet data_buffer[] = + { + // Encapsulation + 0x00, 0x03, 0x00, 0x00, + // PID_PRODUCT_VERSION + 0x00, 0x80, 4, 0, + 7, 1, 0, 0, + // PID_SENTINEL + 0x01, 0, 0, 0 + }; + + uint32_t buffer_length = static_cast(sizeof(data_buffer)); + + // ParticipantProxyData check + ParticipantProxyData participant_pdata(RTPSParticipantAllocationAttributes{}); + participant_read(data_buffer, buffer_length, participant_pdata); + EXPECT_EQ(0, participant_pdata.product_version.major); + EXPECT_EQ(0, participant_pdata.product_version.minor); + EXPECT_EQ(0, participant_pdata.product_version.patch); + EXPECT_EQ(0, participant_pdata.product_version.tweak); + + // CacheChange_t check + CacheChange_t change; + update_cache_change(change, data_buffer, buffer_length, 0); + } } // Check interoperability of compatible custom PIDs when vendor ID is RTI Connext diff --git a/versions.md b/versions.md index 0ca525af25d..1dcb33e8b0a 100644 --- a/versions.md +++ b/versions.md @@ -102,6 +102,7 @@ Forthcoming * Added new DynamicType to IDL serializer (`idl_serialize`). * DDS implementation of `eprosima::fastdds::Time_t` moved to `eprosima::fastdds::dds::Time_t`. * `TopicDataType::auto_fill_type_information` has been removed in favor of `fastdds.type_propagation` participant property. +* Add new custom pid PID_PRODUCT_VERSION. Version 2.14.0 --------------