From 3819bf7036703926ed8fa58d939cb94fda2cac95 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 11 Sep 2020 09:51:47 +0200 Subject: [PATCH] Refs #9293. Check after parsing, adding comment on workaround. Signed-off-by: Miguel Company --- src/cpp/rtps/builtin/data/ReaderProxyData.cpp | 19 +++++++++++------- src/cpp/rtps/builtin/data/WriterProxyData.cpp | 20 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp index 9e9eb5d2602..5ac336f93c7 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.cpp @@ -788,13 +788,6 @@ bool ReaderProxyData::readFromCDRMessage( m_guid = p.guid; memcpy(m_key.value, p.guid.guidPrefix.value, 12); memcpy(m_key.value + 12, p.guid.entityId.value, 4); - - if (!m_RTPSParticipantKey.isDefined()) - { - p.guid.entityId = c_EntityId_RTPSParticipant; - memcpy(m_RTPSParticipantKey.value, p.guid.guidPrefix.value, 12); - memcpy(m_RTPSParticipantKey.value + 12, p.guid.entityId.value, 4); - } break; } case fastdds::dds::PID_UNICAST_LOCATOR: @@ -971,6 +964,18 @@ bool ReaderProxyData::readFromCDRMessage( m_topicKind = WITH_KEY; } + /* Some vendors (i.e. CycloneDDS) do not follow DDSI-RTPS and omit PID_PARTICIPANT_GUID + * In that case we use a default value relying on the prefix from m_guid and the default + * participant entity id + */ + if (!m_RTPSParticipantKey.isDefined()) + { + GUID_t tmp_guid = m_guid; + tmp_guid.entityId = c_EntityId_RTPSParticipant; + memcpy(m_RTPSParticipantKey.value, tmp_guid.guidPrefix.value, 12); + memcpy(m_RTPSParticipantKey.value + 12, tmp_guid.entityId.value, 4); + } + return true; } } diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.cpp b/src/cpp/rtps/builtin/data/WriterProxyData.cpp index 20063427ae6..0ea3f82aa55 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.cpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.cpp @@ -804,13 +804,6 @@ bool WriterProxyData::readFromCDRMessage( m_guid = p.guid; memcpy(m_key.value, p.guid.guidPrefix.value, 12); memcpy(m_key.value + 12, p.guid.entityId.value, 4); - - if (!m_RTPSParticipantKey.isDefined()) - { - p.guid.entityId = c_EntityId_RTPSParticipant; - memcpy(m_RTPSParticipantKey.value, p.guid.guidPrefix.value, 12); - memcpy(m_RTPSParticipantKey.value + 12, p.guid.entityId.value, 4); - } break; } case fastdds::dds::PID_PERSISTENCE_GUID: @@ -980,6 +973,19 @@ bool WriterProxyData::readFromCDRMessage( { m_topicKind = WITH_KEY; } + + /* Some vendors (i.e. CycloneDDS) do not follow DDSI-RTPS and omit PID_PARTICIPANT_GUID + * In that case we use a default value relying on the prefix from m_guid and the default + * participant entity id + */ + if (!m_RTPSParticipantKey.isDefined()) + { + GUID_t tmp_guid = m_guid; + tmp_guid.entityId = c_EntityId_RTPSParticipant; + memcpy(m_RTPSParticipantKey.value, tmp_guid.guidPrefix.value, 12); + memcpy(m_RTPSParticipantKey.value + 12, tmp_guid.entityId.value, 4); + } + return true; } }