From 28f2bf19cdffc5a02caf852455b07a1bb01844f5 Mon Sep 17 00:00:00 2001 From: Sebastian Jakymiw Date: Mon, 9 Jan 2023 11:18:06 -0500 Subject: [PATCH 1/2] add network notify function Signed-off-by: Sebastian Jakymiw --- .../rmw_fastrtps_cpp/get_participant.hpp | 8 ++++++ rmw_fastrtps_cpp/src/rmw_node.cpp | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_participant.hpp b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_participant.hpp index cbd76bfbc..7f3643f37 100644 --- a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_participant.hpp +++ b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_participant.hpp @@ -34,6 +34,14 @@ RMW_FASTRTPS_CPP_PUBLIC eprosima::fastdds::dds::DomainParticipant * get_domain_participant(rmw_node_t * node); +/** + * This function returns `NULL` when either the node handle is `NULL` or when the + * node handle is from a different rmw implementation. + * + * \return rmw_ret_t non `NULL` value if successful, otherwise `NULL` + */ +rmw_ret_t rmw_notify_participant_dynamic_network_interface(rmw_context_t * context); + } // namespace rmw_fastrtps_cpp #endif // RMW_FASTRTPS_CPP__GET_PARTICIPANT_HPP_ diff --git a/rmw_fastrtps_cpp/src/rmw_node.cpp b/rmw_fastrtps_cpp/src/rmw_node.cpp index 012145a03..4d8c997d9 100644 --- a/rmw_fastrtps_cpp/src/rmw_node.cpp +++ b/rmw_fastrtps_cpp/src/rmw_node.cpp @@ -26,12 +26,14 @@ #include "rmw/ret_types.h" #include "rmw/rmw.h" +#include "rmw_fastrtps_shared_cpp/custom_participant_info.hpp" #include "rmw_fastrtps_shared_cpp/init_rmw_context_impl.hpp" #include "rmw_fastrtps_shared_cpp/rmw_common.hpp" #include "rmw_fastrtps_shared_cpp/rmw_context_impl.hpp" #include "rmw_fastrtps_cpp/identifier.hpp" #include "rmw_fastrtps_cpp/init_rmw_context_impl.hpp" +#include "rmw_fastrtps_cpp/get_participant.hpp" extern "C" { @@ -121,4 +123,30 @@ rmw_node_get_graph_guard_condition(const rmw_node_t * node) return rmw_fastrtps_shared_cpp::__rmw_node_get_graph_guard_condition( node); } + +rmw_ret_t +rmw_notify_participant_dynamic_network_interface(rmw_context_t * context) +{ + auto impl = static_cast(context->impl->participant_info); + eprosima::fastdds::dds::DomainParticipant * participant = impl->participant_; + + if (nullptr == participant) + { + return RMW_RET_ERROR; + } + + eprosima::fastdds::dds::DomainParticipantQos participant_qos; + if (participant->get_qos(participant_qos) != ReturnCode_t::RETCODE_OK) + { + return RMW_RET_ERROR; + } + + ReturnCode_t ret = participant->set_qos(participant_qos); + + if (ret != ReturnCode_t::RETCODE_OK) + { + return RMW_RET_ERROR; + } + return RMW_RET_OK; +} } // extern "C" From 75f262fbf6830fdd74a7c84ded13d4defe67ccc5 Mon Sep 17 00:00:00 2001 From: Sebastian Jakymiw Date: Thu, 19 Jan 2023 16:39:51 -0500 Subject: [PATCH 2/2] nullptr check context->impl pointer Signed-off-by: Sebastian Jakymiw --- rmw_fastrtps_cpp/src/rmw_node.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rmw_fastrtps_cpp/src/rmw_node.cpp b/rmw_fastrtps_cpp/src/rmw_node.cpp index 4d8c997d9..bec46c979 100644 --- a/rmw_fastrtps_cpp/src/rmw_node.cpp +++ b/rmw_fastrtps_cpp/src/rmw_node.cpp @@ -128,6 +128,12 @@ rmw_ret_t rmw_notify_participant_dynamic_network_interface(rmw_context_t * context) { auto impl = static_cast(context->impl->participant_info); + + if (nullptr == impl) + { + return RMW_RET_ERROR; + } + eprosima::fastdds::dds::DomainParticipant * participant = impl->participant_; if (nullptr == participant)