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

add network notify function #662

Open
wants to merge 2 commits into
base: rolling
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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_
34 changes: 34 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
{
Expand Down Expand Up @@ -121,4 +123,36 @@ 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<CustomParticipantInfo *>(context->impl->participant_info);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check if impl is a valid pointer?


if (nullptr == impl)
{
return RMW_RET_ERROR;
}

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"