Skip to content

Commit

Permalink
Apply review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: cferreiragonz <[email protected]>
  • Loading branch information
cferreiragonz committed Nov 12, 2024
1 parent c627744 commit 4a9fb4e
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 59 deletions.
2 changes: 1 addition & 1 deletion include/fastdds/dds/core/policy/ParameterTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ enum ParameterId_t : uint16_t
/* eProsima Fast DDS extensions */
PID_PRODUCT_VERSION = 0x8000,
PID_PERSISTENCE_GUID = 0x8002,
PID_HOST_ID = 0x8003,
PID_MACHINE_ID = 0x8003,
PID_DISABLE_POSITIVE_ACKS = 0x8005,
PID_DATASHARING = 0x8006,
PID_NETWORK_CONFIGURATION_SET = 0x8007,
Expand Down
34 changes: 17 additions & 17 deletions src/cpp/rtps/builtin/data/ParticipantProxyData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ParticipantProxyData::ParticipantProxyData(
const ParticipantProxyData& pdata)
: m_protocolVersion(pdata.m_protocolVersion)
, m_guid(pdata.m_guid)
, m_host_id(pdata.m_host_id)
, machine_id(pdata.machine_id)
, m_VendorId(pdata.m_VendorId)
, product_version(pdata.product_version)
, m_domain_id(pdata.m_domain_id)
Expand Down Expand Up @@ -176,11 +176,11 @@ uint32_t ParticipantProxyData::get_serialized_size(
// PID_NETWORK_CONFIGURATION_SET
ret_val += 4 + PARAMETER_NETWORKCONFIGSET_LENGTH;

if (m_host_id.size() > 0)
if (machine_id.size() > 0)
{
// PID_HOST_ID
// PID_MACHINE_ID
ret_val +=
fastdds::dds::ParameterSerializer<Parameter_t>::cdr_serialized_size(m_host_id);
fastdds::dds::ParameterSerializer<Parameter_t>::cdr_serialized_size(machine_id);
}

// PID_METATRAFFIC_MULTICAST_LOCATOR
Expand Down Expand Up @@ -331,9 +331,9 @@ bool ParticipantProxyData::writeToCDRMessage(
return false;
}
}
if (m_host_id.size() > 0)
if (machine_id.size() > 0)
{
ParameterString_t p(fastdds::dds::PID_HOST_ID, 0, m_host_id);
ParameterString_t p(fastdds::dds::PID_MACHINE_ID, 0, machine_id);
if (!fastdds::dds::ParameterSerializer<ParameterString_t>::add_to_cdr_message(p, msg))
{
return false;
Expand Down Expand Up @@ -606,7 +606,7 @@ bool ParticipantProxyData::readFromCDRMessage(
m_networkConfiguration = p.netconfigSet;
break;
}
case fastdds::dds::PID_HOST_ID:
case fastdds::dds::PID_MACHINE_ID:
{
// Ignore custom PID when coming from other vendors
if (c_VendorId_eProsima != m_VendorId)
Expand All @@ -625,7 +625,7 @@ bool ParticipantProxyData::readFromCDRMessage(
return false;
}

m_host_id = p.getName();
machine_id = p.getName();
break;
}
case fastdds::dds::PID_METATRAFFIC_MULTICAST_LOCATOR:
Expand All @@ -647,7 +647,7 @@ bool ParticipantProxyData::readFromCDRMessage(
Locator_t temp_locator;
if (network.transform_remote_locator(
p.locator, temp_locator, m_networkConfiguration,
check_same_host()))
is_from_this_host()))
{
ProxyDataFilters::filter_locators(
network,
Expand Down Expand Up @@ -677,7 +677,7 @@ bool ParticipantProxyData::readFromCDRMessage(
Locator_t temp_locator;
if (network.transform_remote_locator(
p.locator, temp_locator, m_networkConfiguration,
check_same_host()))
is_from_this_host()))
{
ProxyDataFilters::filter_locators(
network,
Expand Down Expand Up @@ -707,7 +707,7 @@ bool ParticipantProxyData::readFromCDRMessage(
Locator_t temp_locator;
if (network.transform_remote_locator(
p.locator, temp_locator, m_networkConfiguration,
check_same_host()))
is_from_this_host()))
{
ProxyDataFilters::filter_locators(
network,
Expand Down Expand Up @@ -737,7 +737,7 @@ bool ParticipantProxyData::readFromCDRMessage(
Locator_t temp_locator;
if (network.transform_remote_locator(
p.locator, temp_locator, m_networkConfiguration,
check_same_host()))
is_from_this_host()))
{
ProxyDataFilters::filter_locators(
network,
Expand Down Expand Up @@ -893,12 +893,12 @@ bool ParticipantProxyData::readFromCDRMessage(
}
}

bool ParticipantProxyData::check_same_host()
bool ParticipantProxyData::is_from_this_host() const
{
bool same_host = false;
if (m_host_id.size() > 0)
if (machine_id.size() > 0)
{
same_host = m_host_id == SystemInfo::instance().machine_id();
same_host = machine_id == SystemInfo::instance().machine_id();
}
else
{
Expand All @@ -911,7 +911,7 @@ void ParticipantProxyData::clear()
{
m_protocolVersion = ProtocolVersion_t();
m_guid = GUID_t();
m_host_id = "";
machine_id = "";
//set_VendorId_Unknown(m_VendorId);
m_VendorId = c_VendorId_Unknown;
product_version = {};
Expand Down Expand Up @@ -945,7 +945,7 @@ void ParticipantProxyData::copy(
{
m_protocolVersion = pdata.m_protocolVersion;
m_guid = pdata.m_guid;
m_host_id = pdata.m_host_id;
machine_id = pdata.machine_id;
m_VendorId[0] = pdata.m_VendorId[0];
m_VendorId[1] = pdata.m_VendorId[1];
product_version = pdata.product_version;
Expand Down
10 changes: 5 additions & 5 deletions src/cpp/rtps/builtin/data/ParticipantProxyData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class ParticipantProxyData
ProtocolVersion_t m_protocolVersion;
//!GUID
GUID_t m_guid;
//!HOST ID
fastcdr::string_255 m_host_id;
//!Machine ID
fastcdr::string_255 machine_id;
//!Vendor ID
fastdds::rtps::VendorId_t m_VendorId;
//! Product version
Expand Down Expand Up @@ -166,11 +166,11 @@ class ParticipantProxyData
fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima);

/**
* Check if the host is the same as the one that sent the data.
* It tries to use the m_host_id. If it is not available, it will compare GUIDs.
* Check if the host where the current process is running is the same as the one that sent the data.
* It tries to use the machine_id. If it is not available, it will compare GUIDs.
* @return True if the host is the same
*/
bool check_same_host();
bool is_from_this_host() const;

//! Clear the data (restore to default state).
void clear();
Expand Down
18 changes: 9 additions & 9 deletions src/cpp/rtps/builtin/data/ReaderProxyData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,12 +1193,12 @@ bool ReaderProxyData::readFromCDRMessage(
return false;
}

bool ReaderProxyData::check_same_host()
bool ReaderProxyData::is_from_this_host()
{
bool same_host = false;
if (m_host_id.size() > 0)
if (machine_id.size() > 0)
{
same_host = m_host_id == SystemInfo::instance().machine_id();
same_host = machine_id == SystemInfo::instance().machine_id();
}
else
{
Expand All @@ -1215,7 +1215,7 @@ void ReaderProxyData::clear()
plugin_security_attributes_ = 0UL;
#endif // if HAVE_SECURITY
m_guid = c_Guid_Unknown;
m_host_id = "";
machine_id = "";
m_networkConfiguration = 0;
remote_locators_.unicast.clear();
remote_locators_.multicast.clear();
Expand Down Expand Up @@ -1280,7 +1280,7 @@ void ReaderProxyData::copy(
ReaderProxyData* rdata)
{
m_guid = rdata->m_guid;
m_host_id = rdata->m_host_id;
machine_id = rdata->machine_id;
m_networkConfiguration = rdata->m_networkConfiguration;
remote_locators_ = rdata->remote_locators_;
m_key = rdata->m_key;
Expand Down Expand Up @@ -1349,7 +1349,7 @@ void ReaderProxyData::set_remote_unicast_locators(
remote_locators_.unicast.clear();
for (const Locator_t& locator : locators)
{
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
{
remote_locators_.add_unicast_locator(locator);
}
Expand All @@ -1369,7 +1369,7 @@ void ReaderProxyData::set_multicast_locators(
remote_locators_.multicast.clear();
for (const Locator_t& locator : locators)
{
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
{
remote_locators_.add_multicast_locator(locator);
}
Expand All @@ -1392,7 +1392,7 @@ void ReaderProxyData::set_remote_locators(

for (const Locator_t& locator : locators.unicast)
{
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
{
remote_locators_.add_unicast_locator(locator);
}
Expand All @@ -1402,7 +1402,7 @@ void ReaderProxyData::set_remote_locators(
{
for (const Locator_t& locator : locators.multicast)
{
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
{
remote_locators_.add_multicast_locator(locator);
}
Expand Down
6 changes: 3 additions & 3 deletions src/cpp/rtps/builtin/data/ReaderProxyData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,10 @@ class ReaderProxyData

/**
* Check if the host is the same as the one that sent the data.
* It tries to use the m_host_id. If it is not available, it will compare GUIDs.
* It tries to use the machine_id. If it is not available, it will compare GUIDs.
* @return True if the host is the same
*/
bool check_same_host();
bool is_from_this_host();

//!
bool m_expectsInlineQos;
Expand Down Expand Up @@ -486,7 +486,7 @@ class ReaderProxyData
//!GUID
GUID_t m_guid;
//!HOST ID
fastcdr::string_255 m_host_id;
fastcdr::string_255 machine_id;
//!Network configuration
NetworkConfigSet_t m_networkConfiguration;
//!Holds locator information
Expand Down
16 changes: 8 additions & 8 deletions src/cpp/rtps/builtin/data/WriterProxyData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,9 +1137,9 @@ bool WriterProxyData::readFromCDRMessage(
bool WriterProxyData::check_same_host()
{
bool same_host = false;
if (m_host_id.size() > 0)
if (machine_id.size() > 0)
{
same_host = m_host_id == SystemInfo::instance().machine_id();
same_host = machine_id == SystemInfo::instance().machine_id();
}
else
{
Expand All @@ -1155,7 +1155,7 @@ void WriterProxyData::clear()
plugin_security_attributes_ = 0UL;
#endif // if HAVE_SECURITY
m_guid = c_Guid_Unknown;
m_host_id = "";
machine_id = "";
m_networkConfiguration = 0;
remote_locators_.unicast.clear();
remote_locators_.multicast.clear();
Expand Down Expand Up @@ -1189,7 +1189,7 @@ void WriterProxyData::copy(
WriterProxyData* wdata)
{
m_guid = wdata->m_guid;
m_host_id = wdata->m_host_id;
machine_id = wdata->machine_id;
m_networkConfiguration = wdata->m_networkConfiguration;
remote_locators_ = wdata->remote_locators_;
m_key = wdata->m_key;
Expand Down Expand Up @@ -1283,7 +1283,7 @@ void WriterProxyData::set_remote_unicast_locators(
remote_locators_.unicast.clear();
for (const Locator_t& locator : locators)
{
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
{
remote_locators_.add_unicast_locator(locator);
}
Expand All @@ -1303,7 +1303,7 @@ void WriterProxyData::set_multicast_locators(
remote_locators_.multicast.clear();
for (const Locator_t& locator : locators)
{
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
{
remote_locators_.add_multicast_locator(locator);
}
Expand All @@ -1326,7 +1326,7 @@ void WriterProxyData::set_remote_locators(

for (const Locator_t& locator : locators.unicast)
{
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
{
remote_locators_.add_unicast_locator(locator);
}
Expand All @@ -1336,7 +1336,7 @@ void WriterProxyData::set_remote_locators(
{
for (const Locator_t& locator : locators.multicast)
{
if (network.is_locator_remote_or_allowed(locator, check_same_host()))
if (network.is_locator_remote_or_allowed(locator, is_from_this_host()))
{
remote_locators_.add_multicast_locator(locator);
}
Expand Down
6 changes: 3 additions & 3 deletions src/cpp/rtps/builtin/data/WriterProxyData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,18 +457,18 @@ class WriterProxyData

/**
* Check if the host is the same as the one that sent the data.
* It tries to use the m_host_id. If it is not available, it will compare GUIDs.
* It tries to use the machine_id. If it is not available, it will compare GUIDs.
* @return True if the host is the same
*/
bool check_same_host();
bool is_from_this_host();

private:

//!GUID
GUID_t m_guid;

//!HOST ID
fastcdr::string_255 m_host_id;
fastcdr::string_255 machine_id;

//!Network configuration
NetworkConfigSet_t m_networkConfiguration;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/builtin/discovery/participant/PDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void PDP::initializeParticipantProxyData(
participant_data->product_version.major = FASTDDS_VERSION_MAJOR;
participant_data->product_version.minor = FASTDDS_VERSION_MINOR;
participant_data->product_version.patch = FASTDDS_VERSION_MICRO;
participant_data->m_host_id = SystemInfo::instance().machine_id();
participant_data->machine_id = SystemInfo::instance().machine_id();

// TODO: participant_data->m_availableBuiltinEndpoints |= mp_builtin->available_builtin_endpoints();

Expand Down
1 change: 0 additions & 1 deletion src/cpp/utils/Host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class Host
if (machine_id_ == "")
{
EPROSIMA_LOG_WARNING(UTILS, "Cannot get machine id. Failing back to IP based ID");
machine_id_ = "";
}
}

Expand Down
10 changes: 0 additions & 10 deletions src/cpp/utils/SystemInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,6 @@ class SystemInfo
return Host::instance().machine_id();
}

/**
* Get the identifier of the current machine.
*
* @return the identifier of the current host.
*/
inline fastcdr::string_255 check_machine_id() const
{
return Host::instance().machine_id();
}

/**
* Get a reference to the singleton instance.
*
Expand Down
2 changes: 1 addition & 1 deletion tools/fds/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ int fastdds_discovery_server(
}

fastdds::rtps::GuidPrefix_t guid_prefix = participantQos.wire_protocol().prefix;
participantQos.transport().use_builtin_transports = true ? udp_server_initialized : false;
participantQos.transport().use_builtin_transports = udp_server_initialized;

// Create the server
int return_value = 0;
Expand Down

0 comments on commit 4a9fb4e

Please sign in to comment.