diff --git a/rmw_connext_cpp/src/rmw_node.cpp b/rmw_connext_cpp/src/rmw_node.cpp index 8b4d16da..ad57f633 100644 --- a/rmw_connext_cpp/src/rmw_node.cpp +++ b/rmw_connext_cpp/src/rmw_node.cpp @@ -28,10 +28,12 @@ rmw_create_node( const char * name, const char * namespace_, size_t domain_id, - const rmw_node_security_options_t * security_options) + const rmw_node_security_options_t * security_options, + bool localhost_only) { return create_node( - rti_connext_identifier, context, name, namespace_, domain_id, security_options); + rti_connext_identifier, context, name, namespace_, domain_id, security_options, + localhost_only); } rmw_ret_t diff --git a/rmw_connext_dynamic_cpp/src/functions.cpp b/rmw_connext_dynamic_cpp/src/functions.cpp index 1a7f3664..82f5d99b 100644 --- a/rmw_connext_dynamic_cpp/src/functions.cpp +++ b/rmw_connext_dynamic_cpp/src/functions.cpp @@ -298,10 +298,12 @@ rmw_create_node( const char * name, const char * namespace_, size_t domain_id, - const rmw_node_security_options_t * security_options) + const rmw_node_security_options_t * security_options, + bool localhost_only) { return create_node( - rti_connext_dynamic_identifier, context, name, namespace_, domain_id, security_options); + rti_connext_dynamic_identifier, context, name, namespace_, domain_id, security_options, + localhost_only); } rmw_ret_t diff --git a/rmw_connext_shared_cpp/include/rmw_connext_shared_cpp/node.hpp b/rmw_connext_shared_cpp/include/rmw_connext_shared_cpp/node.hpp index ab2fa407..4f953995 100644 --- a/rmw_connext_shared_cpp/include/rmw_connext_shared_cpp/node.hpp +++ b/rmw_connext_shared_cpp/include/rmw_connext_shared_cpp/node.hpp @@ -27,7 +27,8 @@ create_node( const char * name, const char * namespace_, size_t domain_id, - const rmw_node_security_options_t * options); + const rmw_node_security_options_t * options, + bool localhost_only); RMW_CONNEXT_SHARED_CPP_PUBLIC rmw_ret_t diff --git a/rmw_connext_shared_cpp/src/node.cpp b/rmw_connext_shared_cpp/src/node.cpp index c2bcec39..cce87c78 100644 --- a/rmw_connext_shared_cpp/src/node.cpp +++ b/rmw_connext_shared_cpp/src/node.cpp @@ -32,7 +32,8 @@ create_node( const char * name, const char * namespace_, size_t domain_id, - const rmw_node_security_options_t * security_options) + const rmw_node_security_options_t * security_options, + bool localhost_only) { RCUTILS_CHECK_ARGUMENT_FOR_NULL(context, NULL); RMW_CHECK_TYPE_IDENTIFIERS_MATCH( @@ -58,6 +59,19 @@ create_node( RMW_SET_ERROR_MSG("failed to get default participant qos"); return NULL; } + + if (localhost_only) { + status = DDS::PropertyQosPolicyHelper::add_property( + participant_qos.property, + "dds.transport.UDPv4.builtin.parent.allow_interfaces", + "127.0.0.1", + DDS::BOOLEAN_FALSE); + if (status != DDS::RETCODE_OK) { + RMW_SET_ERROR_MSG( + "failed to add qos property to set localhost as the only network interface"); + return NULL; + } + } // This String_dup is not matched with a String_free because DDS appears to // free this automatically. participant_qos.participant_name.name = DDS::String_dup(name);