From 2e8a88a9e8fdc642eb519faddeeab0f7702f1b09 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Tue, 30 Jan 2024 15:56:44 -0600 Subject: [PATCH] `SedpLocalAddress` does not respect `DCPSDefaultAddress` Problem ------- `SedpLocalAddress` does not use `DCPSDefaultAddress` as a default. This prevents restricting all RTPS traffic to a specific network interface by setting `DCPSDefaultAddress`. The user can set the local address for everyting if they can't use `DCPSDefaultAddress`. Solution -------- Update `SedpLocalAddress` to work like `SpdpLocalAddress`. --- dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp | 11 ++++------- dds/DCPS/Service_Participant.h | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp b/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp index 230b96bfad9..3e146190b7e 100644 --- a/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp +++ b/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp @@ -322,8 +322,8 @@ DCPS::NetworkAddress RtpsDiscoveryConfig::sedp_local_address() const { return TheServiceParticipant->config_store()->get(config_key("SEDP_LOCAL_ADDRESS").c_str(), - DCPS::NetworkAddress::default_IPV4, - DCPS::ConfigStoreImpl::Format_Required_Port, + TheServiceParticipant->default_address(), + DCPS::ConfigStoreImpl::Format_Optional_Port, DCPS::ConfigStoreImpl::Kind_IPV4); } @@ -332,7 +332,7 @@ RtpsDiscoveryConfig::sedp_local_address(const DCPS::NetworkAddress& mi) { TheServiceParticipant->config_store()->set(config_key("SEDP_LOCAL_ADDRESS").c_str(), mi, - DCPS::ConfigStoreImpl::Format_Required_Port, + DCPS::ConfigStoreImpl::Format_Optional_Port, DCPS::ConfigStoreImpl::Kind_IPV4); } @@ -357,11 +357,8 @@ RtpsDiscoveryConfig::sedp_advertised_local_address(const DCPS::NetworkAddress& m DCPS::NetworkAddress RtpsDiscoveryConfig::spdp_local_address() const { - const DCPS::NetworkAddress d1(TheServiceParticipant->default_address()); - const DCPS::NetworkAddress d2("0.0.0.0:0"); - return TheServiceParticipant->config_store()->get(config_key("SPDP_LOCAL_ADDRESS").c_str(), - d1 ? d1 : d2, + TheServiceParticipant->default_address(), DCPS::ConfigStoreImpl::Format_Optional_Port, DCPS::ConfigStoreImpl::Kind_IPV4); } diff --git a/dds/DCPS/Service_Participant.h b/dds/DCPS/Service_Participant.h index 5c8bfbfce39..0b38deb2f23 100644 --- a/dds/DCPS/Service_Participant.h +++ b/dds/DCPS/Service_Participant.h @@ -87,6 +87,7 @@ const String OPENDDS_COMMON_DCPS_CONFIG_FILE_default = ""; const char OPENDDS_COMMON_DCPS_DEBUG_LEVEL[] = "OPENDDS_COMMON_DCPS_DEBUG_LEVEL"; const char OPENDDS_COMMON_DCPS_DEFAULT_ADDRESS[] = "OPENDDS_COMMON_DCPS_DEFAULT_ADDRESS"; +// Can't use NetworkAddress::default_IPV4 due to static initialization. const NetworkAddress OPENDDS_COMMON_DCPS_DEFAULT_ADDRESS_default = NetworkAddress("0.0.0.0:0"); const char OPENDDS_COMMON_DCPS_DEFAULT_DISCOVERY[] = "OPENDDS_COMMON_DCPS_DEFAULT_DISCOVERY";