Skip to content

Commit

Permalink
Fix simple test scenarios (#3249)
Browse files Browse the repository at this point in the history
* Refs #16880: PDPClient fixes to accomplish simple test scenarios. CMakelists spaces corrected

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #16880: Correction compilation erros WITHOUT_SECURITY

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #16880: Applied suggested changes

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #16880: Uncrustify

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
  • Loading branch information
Mario-DL authored and MiguelCompany committed Feb 8, 2023
1 parent 3691c8f commit d268ee8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
35 changes: 28 additions & 7 deletions src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ bool PDPClient::create_ds_pdp_endpoints()

bool PDPClient::create_ds_pdp_reliable_endpoints(
DiscoveryServerPDPEndpoints& endpoints,
bool secure)
bool is_discovery_protected)
{

EPROSIMA_LOG_INFO(RTPS_PDP, "Beginning PDPClient Endpoints creation");
Expand Down Expand Up @@ -352,7 +352,7 @@ bool PDPClient::create_ds_pdp_reliable_endpoints(
ratt.endpoint.reliabilityKind = RELIABLE;
ratt.times.heartbeatResponseDelay = pdp_heartbeat_response_delay;
#if HAVE_SECURITY
if (secure)
if (is_discovery_protected)
{
ratt.endpoint.security_attributes().is_submessage_protected = true;
ratt.endpoint.security_attributes().plugin_endpoint_attributes =
Expand All @@ -364,7 +364,8 @@ bool PDPClient::create_ds_pdp_reliable_endpoints(

RTPSReader* reader = nullptr;
#if HAVE_SECURITY
EntityId_t reader_entity = secure ? c_EntityId_spdp_reliable_participant_secure_reader : c_EntityId_SPDPReader;
EntityId_t reader_entity =
is_discovery_protected ? c_EntityId_spdp_reliable_participant_secure_reader : c_EntityId_SPDPReader;
#else
EntityId_t reader_entity = c_EntityId_SPDPReader;
#endif // if HAVE_SECURITY
Expand Down Expand Up @@ -409,7 +410,7 @@ bool PDPClient::create_ds_pdp_reliable_endpoints(
watt.times.nackSupressionDuration = pdp_nack_supression_duration;

#if HAVE_SECURITY
if (secure)
if (is_discovery_protected)
{
watt.endpoint.security_attributes().is_submessage_protected = true;
watt.endpoint.security_attributes().plugin_endpoint_attributes =
Expand All @@ -424,7 +425,8 @@ bool PDPClient::create_ds_pdp_reliable_endpoints(

RTPSWriter* wout = nullptr;
#if HAVE_SECURITY
EntityId_t writer_entity = secure ? c_EntityId_spdp_reliable_participant_secure_writer : c_EntityId_SPDPWriter;
EntityId_t writer_entity =
is_discovery_protected ? c_EntityId_spdp_reliable_participant_secure_writer : c_EntityId_SPDPWriter;
#else
EntityId_t writer_entity = c_EntityId_SPDPWriter;
#endif // if HAVE_SECURITY
Expand Down Expand Up @@ -453,11 +455,23 @@ bool PDPClient::create_ds_pdp_reliable_endpoints(
mp_RTPSParticipant->createSenderResources(it.metatrafficMulticastLocatorList);
mp_RTPSParticipant->createSenderResources(it.metatrafficUnicastLocatorList);

if (!secure)
#if HAVE_SECURITY
if (!mp_RTPSParticipant->is_secure())
{
match_pdp_writer_nts_(it);
match_pdp_reader_nts_(it);
}
else if (!is_discovery_protected)
{
endpoints.reader.reader_->enableMessagesFromUnkownWriters(true);
}
#else
if (!is_discovery_protected)
{
match_pdp_writer_nts_(it);
match_pdp_reader_nts_(it);
}
#endif // HAVE_SECURITY
}
}

Expand Down Expand Up @@ -495,7 +509,7 @@ void PDPClient::notifyAboveRemoteEndpoints(
const ParticipantProxyData& pdata)
{
#if HAVE_SECURITY
if (should_protect_discovery())
if (mp_RTPSParticipant->is_secure())
{
eprosima::shared_lock<eprosima::shared_mutex> disc_lock(mp_builtin->getDiscoveryMutex());

Expand All @@ -504,6 +518,13 @@ void PDPClient::notifyAboveRemoteEndpoints(
{
if (data_matches_with_prefix(svr.guidPrefix, pdata))
{
if (nullptr == svr.proxy)
{
//! try to retrieve the participant proxy data from an unmangled prefix in case
//! we could not fill svr.proxy in assignRemoteEndpoints()
svr.proxy = get_participant_proxy_data(svr.guidPrefix);
}

match_pdp_reader_nts_(svr, pdata.m_guid.guidPrefix);
match_pdp_writer_nts_(svr, pdata.m_guid.guidPrefix);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/builtin/discovery/participant/PDPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class PDPClient : public PDP
*/
bool create_ds_pdp_reliable_endpoints(
DiscoveryServerPDPEndpoints& endpoints,
bool secure);
bool is_discovery_protected);

/**
* Performs creation of DS best-effort PDP reader.
Expand Down
3 changes: 2 additions & 1 deletion test/communication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/secure_simple_ds_server_no_discovery_
${CMAKE_CURRENT_BINARY_DIR}/secure_simple_ds_server_no_discovery_no_rtps_protection.xml COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/secure_simple_ds_server_no_discovery_protection.xml
${CMAKE_CURRENT_BINARY_DIR}/secure_simple_ds_server_no_discovery_protection.xml COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/secure_simple_ds_server_no_rtps_protection.xml ${CMAKE_CURRENT_BINARY_DIR}/secure_simple_ds_server_no_rtps_protection.xml COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/secure_simple_ds_server_no_rtps_protection.xml
${CMAKE_CURRENT_BINARY_DIR}/secure_simple_ds_server_no_rtps_protection.xml COPYONLY)

if(SECURITY)
configure_file(${PROJECT_SOURCE_DIR}/test/certs/maincacert.pem
Expand Down

0 comments on commit d268ee8

Please sign in to comment.