Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20933] Set DataSharing in Writer|ReaderProxyData (backport #4761) #4803

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ inline bool QosPoliciesSerializer<DataSharingQosPolicy>::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);
Expand Down
2 changes: 2 additions & 0 deletions src/cpp/rtps/builtin/data/ReaderProxyData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ bool ReaderProxyData::readFromCDRMessage(
"Received with error.");
return false;
}

break;
}

Expand All @@ -999,6 +1000,7 @@ bool ReaderProxyData::readFromCDRMessage(

uint32_t qos_size;
clear();
m_qos.data_sharing.off();
try
{
if (ParameterList::readParameterListfromCDRMsg(*msg, param_process, true, qos_size))
Expand Down
1 change: 1 addition & 0 deletions src/cpp/rtps/builtin/data/WriterProxyData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ bool WriterProxyData::readFromCDRMessage(

uint32_t qos_size;
clear();
m_qos.data_sharing.off();
try
{
if (ParameterList::readParameterListfromCDRMsg(*msg, param_process, true, qos_size))
Expand Down
80 changes: 80 additions & 0 deletions test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,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<uint32_t>(sizeof(data_r_buffer)));
msg.length = msg.max_size;

ReaderProxyData out(max_unicast_locators, max_multicast_locators);
out.readFromCDRMessage(&msg, network, 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<uint32_t>(sizeof(data_w_buffer)));
msg.length = msg.max_size;

ReaderProxyData out(max_unicast_locators, max_multicast_locators);
out.readFromCDRMessage(&msg, network, 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<uint32_t>(sizeof(data_r_buffer)));
msg.length = msg.max_size;

ReaderProxyData out(max_unicast_locators, max_multicast_locators);
out.readFromCDRMessage(&msg, network, 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<uint32_t>(sizeof(data_w_buffer)));
msg.length = msg.max_size;

ReaderProxyData out(max_unicast_locators, max_multicast_locators);
out.readFromCDRMessage(&msg, network, true);
ASSERT_EQ(out.m_qos.data_sharing.kind(), ON);
}
}


// Regression test for redmine issue #10547
TEST(BuiltinDataSerializationTests, ignore_unsupported_type_info)
{
Expand Down
Loading