From 258078dd377e9706ec731aa28789a88d90ce8de6 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Thu, 6 Jun 2024 11:40:46 +0200 Subject: [PATCH] Refs #21120. Fix discovery server tests. Signed-off-by: Miguel Company --- src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp | 6 +++++- src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp | 6 ++++-- src/cpp/rtps/reader/BaseReader.hpp | 5 +++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp index 30d392a02f..0c179ee41c 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -348,7 +349,6 @@ bool PDPClient::create_ds_pdp_reliable_endpoints( ratt.endpoint.reliabilityKind = RELIABLE; ratt.times.heartbeatResponseDelay = pdp_heartbeat_response_delay; #if HAVE_SECURITY - ratt.accept_messages_from_unkown_writers = !is_discovery_protected && mp_RTPSParticipant->is_secure(); if (is_discovery_protected) { ratt.endpoint.security_attributes().is_submessage_protected = true; @@ -460,6 +460,10 @@ bool PDPClient::create_ds_pdp_reliable_endpoints( match_pdp_writer_nts_(it); match_pdp_reader_nts_(it); } + else if (!is_discovery_protected) + { + BaseReader::downcast(endpoints.reader.reader_)->allow_unknown_writers(); + } #else if (!is_discovery_protected) { diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp index 93c9537653..42689c8561 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -401,13 +402,14 @@ bool PDPServer::create_ds_pdp_reliable_endpoints( #else EntityId_t reader_entity = c_EntityId_SPDPReader; #endif // if HAVE_SECURITY - // Enable unknown clients to reach this reader - ratt.accept_messages_from_unkown_writers = true; if (mp_RTPSParticipant->createReader(&reader, ratt, endpoints.reader.history_.get(), endpoints.reader.listener_.get(), reader_entity, true, false)) { endpoints.reader.reader_ = dynamic_cast(reader); + // Enable unknown clients to reach this reader + BaseReader::downcast(endpoints.reader.reader_)->allow_unknown_writers(); + #if HAVE_SECURITY mp_RTPSParticipant->set_endpoint_rtps_protection_supports(reader, false); #endif // if HAVE_SECURITY diff --git a/src/cpp/rtps/reader/BaseReader.hpp b/src/cpp/rtps/reader/BaseReader.hpp index 9694c8221b..fd95cc5ad8 100644 --- a/src/cpp/rtps/reader/BaseReader.hpp +++ b/src/cpp/rtps/reader/BaseReader.hpp @@ -126,6 +126,11 @@ class BaseReader trusted_writer_entity_id_ = writer; } + void allow_unknown_writers() + { + accept_messages_from_unkown_writers_ = true; + } + /** * Whether the reader accepts messages directed to unknown readers. *