Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15482] UDPv6 support for fast-discovery-server tool and ROS_DISCOVERY_SERVER #2948

Merged
merged 15 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions cmake/common/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ macro(add_gtest)
set(test "${ARGV0}")
set(command "${test}")
endif()
set(multiValueArgs SOURCES ENVIRONMENTS DEPENDENCIES LABELS)
set(multiValueArgs SOURCES ENVIRONMENTS DEPENDENCIES LABELS IGNORE)
cmake_parse_arguments(GTEST "" "${uniValueArgs}" "${multiValueArgs}" ${ARGN})

if(GTEST_NAME)
Expand Down Expand Up @@ -66,6 +66,15 @@ macro(add_gtest)
COMMAND ${command}
--gtest_filter=${GTEST_GROUP_NAME}.${GTEST_TEST_NAME}:*/${GTEST_GROUP_NAME}.${GTEST_TEST_NAME}/*:${GTEST_GROUP_NAME}/*.${GTEST_TEST_NAME})

# decide if disable
unset(GTEST_USER_DISABLED)
foreach(GTEST_USER_FILTER ${GTEST_IGNORE})
string(REGEX MATCH ${GTEST_USER_FILTER} GTEST_USER_DISABLED ${GTEST_GROUP_NAME}.${GTEST_TEST_NAME})
if(GTEST_USER_DISABLED)
break()
endif()
endforeach()

# Add environment
set(GTEST_ENVIRONMENT "")
if(WIN32)
Expand All @@ -82,13 +91,21 @@ macro(add_gtest)
endif()
unset(GTEST_ENVIRONMENT)

# Add labels
set_property(TEST ${GTEST_GROUP_NAME}.${GTEST_TEST_NAME} PROPERTY LABELS "${GTEST_LABELS}")
# Add labels and enable
set_tests_properties(${GTEST_GROUP_NAME}.${GTEST_TEST_NAME} PROPERTIES
LABELS "${GTEST_LABELS}"
DISABLED $<BOOL:${GTEST_USER_DISABLED}>)

endforeach()
endforeach()
else()
add_test(NAME ${test} COMMAND ${command})

# add filtering statement if required
if(GTEST_IGNORE)
set(gtest_filter "--gtest_filter=${GTEST_IGNORE}")
endif()

add_test(NAME ${test} COMMAND ${command} ${gtest_filter})

# Add environment
set(GTEST_ENVIRONMENT "")
Expand Down Expand Up @@ -128,6 +145,8 @@ macro(add_gtest)

# Add labels
set_property(TEST ${test} PROPERTY LABELS "${GTEST_LABELS}")

unset(gtest_filter)
endif()
endmacro()

Expand Down
9 changes: 9 additions & 0 deletions include/fastdds/rtps/attributes/ServerAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ class RemoteServerAttributes

// Live participant proxy reference
const fastrtps::rtps::ParticipantProxyData* proxy{};

// Check if there are specific transport locators associated
// the template parameter is the locator kind (e.g. LOCATOR_KIND_UDPv4)
template<int kind> bool requires_transport() const
{
return metatrafficUnicastLocatorList.has_kind<kind>() ||
metatrafficMulticastLocatorList.has_kind<kind>();
}

};

typedef std::list<RemoteServerAttributes> RemoteServerList_t;
Expand Down
17 changes: 17 additions & 0 deletions include/fastdds/rtps/common/LocatorList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class LocatorList
{
public:

using value_type = typename std::vector<Locator>::value_type;

/// Constructor
RTPS_DllAPI LocatorList()
{
Expand Down Expand Up @@ -378,6 +380,21 @@ class LocatorList
this->m_locators.swap(locatorList.m_locators);
}

// Check if there are specific transport locators associated
// the template parameter is the locator kind (e.g. LOCATOR_KIND_UDPv4)
template<int kind> bool has_kind() const
{
for (auto& loc : m_locators)
{
if ( kind == loc.kind )
{
return true;
}
}

return false;
}

private:

std::vector<Locator> m_locators;
Expand Down
22 changes: 18 additions & 4 deletions src/cpp/rtps/RTPSDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,19 +499,33 @@ RTPSParticipant* RTPSDomain::clientServerEnvironmentCreationOverride(
return nullptr;
}

// we only make the attributes copy when we are sure is worth
// We only make the attributes copy when we are sure is worth
// Is up to the caller guarantee the att argument is not modified during the call
RTPSParticipantAttributes client_att(att);

// Retrieve the info from the environment variable
// TODO(jlbueno) This should be protected with the PDP mutex.
if (load_environment_server_info(client_att.builtin.discovery_config.m_DiscoveryServers) &&
client_att.builtin.discovery_config.m_DiscoveryServers.empty())
RemoteServerList_t& server_list = client_att.builtin.discovery_config.m_DiscoveryServers;
if (load_environment_server_info(server_list) && server_list.empty())
{
// it's not an error, the environment variable may not be set. Any issue with environment
// variable syntax is logError already
return nullptr;
}

// check if some server requires the UDPv6 transport
for (auto& server : server_list)
{
if (server.requires_transport<LOCATOR_KIND_UDPv6>())
{
// extend builtin transports with the UDPv6 transport
auto descriptor = std::make_shared<fastdds::rtps::UDPv6TransportDescriptor>();
descriptor->sendBufferSize = client_att.sendSocketBufferSize;
descriptor->receiveBufferSize = client_att.listenSocketBufferSize;
client_att.userTransports.push_back(std::move(descriptor));
break;
}
}

logInfo(DOMAIN, "Detected auto client-server environment variable."
<< "Trying to create client with the default server setup: "
<< client_att.builtin.discovery_config.m_DiscoveryServers);
Expand Down
Loading