diff --git a/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp b/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp index 08bd98f598a..f2ed86275c3 100644 --- a/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp +++ b/src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp @@ -855,7 +855,7 @@ inline bool QosPoliciesSerializer::read_content_from_cdr_m uint32_t pos_ref = cdr_message->pos; // If the parameter is sent, the remote endpoint is datasharing compatible - qos_policy.automatic(); + qos_policy.on("."); uint32_t num_domains = 0; bool valid = fastrtps::rtps::CDRMessage::readUInt32(cdr_message, &num_domains); diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index 58cba2aec6f..4d1da335d68 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -1078,6 +1078,7 @@ bool ReaderProxyData::readFromCDRMessage( "Received with error."); return false; } + break; } @@ -1092,6 +1093,7 @@ bool ReaderProxyData::readFromCDRMessage( uint32_t qos_size; clear(); + m_qos.data_sharing.off(); try { if (ParameterList::readParameterListfromCDRMsg(*msg, param_process, true, qos_size)) diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index ceaad38437f..0495ddd8993 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -1075,6 +1075,7 @@ bool WriterProxyData::readFromCDRMessage( uint32_t qos_size; clear(); + m_qos.data_sharing.off(); try { if (ParameterList::readParameterListfromCDRMsg(*msg, param_process, true, qos_size)) diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index 76cd708b1bc..f8f74b4fc4f 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -140,6 +140,86 @@ TEST(BuiltinDataSerializationTests, ok_with_defaults) } } +TEST(BuiltinDataSerializationTests, msg_without_datasharing) +{ + { + uint8_t data_r_buffer[] = + { + // Encapsulation + 0x00, 0x03, 0x00, 0x00 + }; + + CDRMessage_t msg(0); + msg.init(data_r_buffer, static_cast(sizeof(data_r_buffer))); + msg.length = msg.max_size; + + ReaderProxyData out(max_unicast_locators, max_multicast_locators); + out.readFromCDRMessage(&msg, network, false, true); + ASSERT_EQ(out.m_qos.data_sharing.kind(), OFF); + } + + { + uint8_t data_w_buffer[] = + { + // Encapsulation + 0x00, 0x03, 0x00, 0x00 + + }; + + CDRMessage_t msg(0); + msg.init(data_w_buffer, static_cast(sizeof(data_w_buffer))); + msg.length = msg.max_size; + + ReaderProxyData out(max_unicast_locators, max_multicast_locators); + out.readFromCDRMessage(&msg, network, false, true); + ASSERT_EQ(out.m_qos.data_sharing.kind(), OFF); + } +} + +TEST(BuiltinDataSerializationTests, msg_with_datasharing) +{ + { + uint8_t data_r_buffer[] = + { + // Encapsulation + 0x00, 0x03, 0x00, 0x00, + //Data Sharing + 0x06, 0x80, 0x0c, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x9b, 0xf9, 0xbe, 0x1c, 0xb8 + + }; + + CDRMessage_t msg(0); + msg.init(data_r_buffer, static_cast(sizeof(data_r_buffer))); + msg.length = msg.max_size; + + ReaderProxyData out(max_unicast_locators, max_multicast_locators); + out.readFromCDRMessage(&msg, network, false, true); + ASSERT_EQ(out.m_qos.data_sharing.kind(), ON); + } + + { + uint8_t data_w_buffer[] = + { + // Encapsulation + 0x00, 0x03, 0x00, 0x00, + //Data Sharing + 0x06, 0x80, 0x0c, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x9b, 0xf9, 0xbe, 0x1c, 0xb8 + + }; + + CDRMessage_t msg(0); + msg.init(data_w_buffer, static_cast(sizeof(data_w_buffer))); + msg.length = msg.max_size; + + ReaderProxyData out(max_unicast_locators, max_multicast_locators); + out.readFromCDRMessage(&msg, network, false, true); + ASSERT_EQ(out.m_qos.data_sharing.kind(), ON); + } +} + + // Regression test for redmine issue #10547. // Update against OpenDDS 3.27. With this version we can read the remote DATA(w). TEST(BuiltinDataSerializationTests, interoperability_with_opendds_3_27) @@ -641,7 +721,7 @@ TEST(BuiltinDataSerializationTests, other_vendor_parameter_list_with_custom_pids writer_pdata.m_qos.data_sharing.off(); writer_pdata.m_qos.data_sharing.set_max_domains(0); writer_read(data_buffer, buffer_length, writer_pdata); - ASSERT_EQ(writer_pdata.m_qos.data_sharing, DataSharingQosPolicy()); + ASSERT_EQ(writer_pdata.m_qos.data_sharing.kind(), OFF); // ReaderProxyData check ReaderProxyData reader_pdata(max_unicast_locators, max_multicast_locators); @@ -649,7 +729,7 @@ TEST(BuiltinDataSerializationTests, other_vendor_parameter_list_with_custom_pids reader_pdata.m_qos.data_sharing.set_max_domains(0); reader_pdata.m_qos.m_disablePositiveACKs.enabled = false; reader_read(data_buffer, buffer_length, reader_pdata); - ASSERT_EQ(reader_pdata.m_qos.data_sharing, DataSharingQosPolicy()); + ASSERT_EQ(reader_pdata.m_qos.data_sharing.kind(), OFF); // CacheChange_t check CacheChange_t change;