From 99d2738a84e6fba5891dc89ae5378f86c6ed3be2 Mon Sep 17 00:00:00 2001 From: Sid Faber Date: Thu, 5 Mar 2020 21:08:26 +0000 Subject: [PATCH 01/12] Enable use of Cyclone DDS security features Add utility function to insert security settings to the cyclone QOS object used to create nodes. Include a utility to find security files and properly format their location to use with DDS. Signed-off-by: Sid Faber --- README.md | 5 +- rmw_cyclonedds_cpp/src/rmw_node.cpp | 94 ++++++++++++++++++++++++++++- 2 files changed, 95 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9e0c15ca..7cef6aa1 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,5 @@ DDS directly instead of via the ROS2 abstraction. ## Known limitations -Cyclone DDS doesn't yet implement the DDS Security standard, nor does it fully implement -the Lifespan, Deadline and some of the Liveliness QoS modes. Consequently these features -of ROS2 are also not yet supported when using Cyclone DDS. +Cyclone DDS doesn't yet fully implement the Lifespan, Deadline and some of the Liveliness QoS modes. +Consequently these features of ROS2 are also not yet supported when using Cyclone DDS. diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 46414858..505892d8 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -26,9 +26,11 @@ #include #include +#include "rcutils/filesystem.h" #include "rcutils/get_env.h" #include "rcutils/logging_macros.h" #include "rcutils/strdup.h" +#include "rcutils/format_string.h" #include "rmw/allocators.h" #include "rmw/convert_rcutils_ret_to_rmw_ret.h" @@ -642,6 +644,80 @@ static std::string get_node_user_data(const char * node_name, const char * node_ std::string(";"); } +/* Returns the full URI of a security file properly formatted for DDS */ +char * get_security_file_URI( + const char * security_filename, const char * node_secure_root, + const rcutils_allocator_t allocator) +{ + char * ret; + + char * file_path = rcutils_join_path(node_secure_root, security_filename, allocator); + if (file_path == nullptr) { + ret = nullptr; + } else if (!rcutils_is_readable(file_path)) { + RCUTILS_LOG_ERROR_NAMED( + "rmw_cyclonedds_cpp", "get_security_file: %s not found", file_path); + ret = nullptr; + allocator.deallocate(file_path, allocator.state); + } else { + /* Cyclone also supports a "data:" URI */ + ret = rcutils_format_string(allocator, "file:%s", file_path); + allocator.deallocate(file_path, allocator.state); + } + return ret; +} + +void store_security_filepath_in_qos( + dds_qos_t * qos, const char * qos_property_name, const char * file_name, + const rmw_node_security_options_t * security_options) +{ + rcutils_allocator_t allocator = rcutils_get_default_allocator(); + + char * security_file_path = get_security_file_URI( + file_name, security_options->security_root_path, allocator); + if (security_file_path != nullptr) { + dds_qset_prop(qos, qos_property_name, security_file_path); + allocator.deallocate(security_file_path, allocator.state); + } +} + +/* Set all the qos properties needed to enable DDS security */ +void configure_qos_for_security( + dds_qos_t * qos, const rmw_node_security_options_t * security_options) +{ + /* File path is set to nullptr if file does not exist or is not readable */ + store_security_filepath_in_qos( + qos, "dds.sec.auth.identity_ca", "identity_ca.cert.pem", + security_options); + store_security_filepath_in_qos( + qos, "dds.sec.auth.identity_certificate", "cert.pem", + security_options); + store_security_filepath_in_qos( + qos, "dds.sec.auth.private_key", "key.pem", + security_options); + store_security_filepath_in_qos( + qos, "dds.sec.access.permissions_ca", "permissions_ca.cert.pem", + security_options); + store_security_filepath_in_qos( + qos, "dds.sec.access.governance", "governance.p7s", + security_options); + store_security_filepath_in_qos( + qos, "dds.sec.access.permissions", "permissions.p7s", + security_options); + + dds_qset_prop(qos, "dds.sec.auth.library.path", "libdds_security_auth.so"); + dds_qset_prop(qos, "dds.sec.auth.library.init", "init_authentication"); + dds_qset_prop(qos, "dds.sec.auth.library.finalize", "finalize_authentication"); + + dds_qset_prop(qos, "dds.sec.crypto.library.path", "libdds_security_crypto.so"); + dds_qset_prop(qos, "dds.sec.crypto.library.init", "init_crypto"); + dds_qset_prop(qos, "dds.sec.crypto.library.finalize", "finalize_crypto"); + + dds_qset_prop(qos, "dds.sec.access.library.path", "libdds_security_ac.so"); + dds_qset_prop(qos, "dds.sec.access.library.init", "init_access_control"); + dds_qset_prop(qos, "dds.sec.access.library.finalize", "finalize_access_control"); +} + extern "C" rmw_node_t * rmw_create_node( rmw_context_t * context, const char * name, const char * namespace_, size_t domain_id, @@ -666,7 +742,13 @@ extern "C" rmw_node_t * rmw_create_node( static_cast(domain_id); const dds_domainid_t did = DDS_DOMAIN_DEFAULT; #endif - (void) security_options; + + if (security_options == nullptr) { + RCUTILS_LOG_ERROR_NAMED( + "rmw_cyclonedds_cpp", "rmw_create_node: security options null"); + return nullptr; + } + rmw_ret_t ret; int dummy_validation_result; size_t dummy_invalid_index; @@ -688,8 +770,18 @@ extern "C" rmw_node_t * rmw_create_node( #endif dds_qos_t * qos = dds_create_qos(); + if (qos == nullptr) { + RCUTILS_LOG_ERROR_NAMED( + "rmw_cyclonedds_cpp", "rmw_create_node: Unable to create qos"); + return nullptr; + } std::string user_data = get_node_user_data(name, namespace_); dds_qset_userdata(qos, user_data.c_str(), user_data.size()); + + if (security_options->enforce_security) { + configure_qos_for_security(qos, security_options); + } + dds_entity_t pp = dds_create_participant(did, qos, nullptr); dds_delete_qos(qos); if (pp < 0) { From bca0852f502261484da318330f02a400473240b3 Mon Sep 17 00:00:00 2001 From: Sid Faber Date: Mon, 23 Mar 2020 21:13:19 +0000 Subject: [PATCH 02/12] Update conditional compile logic Add in conditional compile based on ENABLE_SECURITY make flag and Cyclone DDS feature availability. Also addressed review comments. Signed-off-by: Sid Faber --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 50 ++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 505892d8..5dc4406c 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -27,10 +27,10 @@ #include #include "rcutils/filesystem.h" +#include "rcutils/format_string.h" #include "rcutils/get_env.h" #include "rcutils/logging_macros.h" #include "rcutils/strdup.h" -#include "rcutils/format_string.h" #include "rmw/allocators.h" #include "rmw/convert_rcutils_ret_to_rmw_ret.h" @@ -61,6 +61,7 @@ #include "namespace_prefix.hpp" #include "dds/dds.h" +#include "dds/ddsc/dds_public_qos.h" #include "dds/ddsi/ddsi_sertopic.h" #include "rmw_cyclonedds_cpp/serdes.hpp" #include "serdata.hpp" @@ -81,6 +82,13 @@ #define SUPPORT_LOCALHOST 0 #endif +/* Security must be enabled when compiling and requires cyclone to support QOS property lists */ +#if DDS_HAS_SECURITY && DDS_HAS_PROPERTY_LIST_QOS +#define RMW_SUPPORT_SECURITY 1 +#else +#define RMW_SUPPORT_SECURITY 0 +#endif + /* Set to > 0 for printing warnings to stderr for each messages that was taken more than this many ms after writing */ #define REPORT_LATE_MESSAGES 0 @@ -644,6 +652,7 @@ static std::string get_node_user_data(const char * node_name, const char * node_ std::string(";"); } +#if RMW_SUPPORT_SECURITY /* Returns the full URI of a security file properly formatted for DDS */ char * get_security_file_URI( const char * security_filename, const char * node_secure_root, @@ -680,11 +689,14 @@ void store_security_filepath_in_qos( allocator.deallocate(security_file_path, allocator.state); } } +#endif /* RMW_SUPPORT_SECURITY */ /* Set all the qos properties needed to enable DDS security */ -void configure_qos_for_security( +rmw_ret_t configure_qos_for_security( dds_qos_t * qos, const rmw_node_security_options_t * security_options) { + +#if RMW_SUPPORT_SECURITY /* File path is set to nullptr if file does not exist or is not readable */ store_security_filepath_in_qos( qos, "dds.sec.auth.identity_ca", "identity_ca.cert.pem", @@ -705,17 +717,28 @@ void configure_qos_for_security( qos, "dds.sec.access.permissions", "permissions.p7s", security_options); - dds_qset_prop(qos, "dds.sec.auth.library.path", "libdds_security_auth.so"); + dds_qset_prop(qos, "dds.sec.auth.library.path", "dds_security_auth"); dds_qset_prop(qos, "dds.sec.auth.library.init", "init_authentication"); dds_qset_prop(qos, "dds.sec.auth.library.finalize", "finalize_authentication"); - dds_qset_prop(qos, "dds.sec.crypto.library.path", "libdds_security_crypto.so"); + dds_qset_prop(qos, "dds.sec.crypto.library.path", "dds_security_crypto"); dds_qset_prop(qos, "dds.sec.crypto.library.init", "init_crypto"); dds_qset_prop(qos, "dds.sec.crypto.library.finalize", "finalize_crypto"); - dds_qset_prop(qos, "dds.sec.access.library.path", "libdds_security_ac.so"); + dds_qset_prop(qos, "dds.sec.access.library.path", "dds_security_ac"); dds_qset_prop(qos, "dds.sec.access.library.init", "init_access_control"); dds_qset_prop(qos, "dds.sec.access.library.finalize", "finalize_access_control"); + + return RMW_RET_OK; +#else + (void) qos; + (void) security_options; + RMW_SET_ERROR_MSG( + "Security was requested but the Cyclone DDS being used does not have security " + "support enabled. Recompile Cyclone DDS with the '-DENABLE_SECURITY=ON' " + "CMake option"); + return RMW_RET_UNSUPPORTED; +#endif } extern "C" rmw_node_t * rmw_create_node( @@ -743,11 +766,7 @@ extern "C" rmw_node_t * rmw_create_node( const dds_domainid_t did = DDS_DOMAIN_DEFAULT; #endif - if (security_options == nullptr) { - RCUTILS_LOG_ERROR_NAMED( - "rmw_cyclonedds_cpp", "rmw_create_node: security options null"); - return nullptr; - } + RCUTILS_CHECK_ARGUMENT_FOR_NULL(security_options, nullptr); rmw_ret_t ret; int dummy_validation_result; @@ -770,16 +789,15 @@ extern "C" rmw_node_t * rmw_create_node( #endif dds_qos_t * qos = dds_create_qos(); - if (qos == nullptr) { - RCUTILS_LOG_ERROR_NAMED( - "rmw_cyclonedds_cpp", "rmw_create_node: Unable to create qos"); - return nullptr; - } + RCUTILS_CHECK_FOR_NULL_WITH_MSG( + security_options, "rmw_create_node: Unable to create qos", return nullptr); std::string user_data = get_node_user_data(name, namespace_); dds_qset_userdata(qos, user_data.c_str(), user_data.size()); if (security_options->enforce_security) { - configure_qos_for_security(qos, security_options); + if (configure_qos_for_security(qos, security_options) != RMW_RET_OK) { + return nullptr; + } } dds_entity_t pp = dds_create_participant(did, qos, nullptr); From 5e934200cebbda70cf0028031349bf2b0e64a9ed Mon Sep 17 00:00:00 2001 From: Sid Faber <56845980+SidFaber@users.noreply.github.com> Date: Fri, 27 Mar 2020 11:54:55 -0400 Subject: [PATCH 03/12] Fix memory leaks Also remove superfluous include and blank line. Signed-off-by: Sid Faber --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 5dc4406c..993758c7 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -61,7 +61,6 @@ #include "namespace_prefix.hpp" #include "dds/dds.h" -#include "dds/ddsc/dds_public_qos.h" #include "dds/ddsi/ddsi_sertopic.h" #include "rmw_cyclonedds_cpp/serdes.hpp" #include "serdata.hpp" @@ -695,7 +694,6 @@ void store_security_filepath_in_qos( rmw_ret_t configure_qos_for_security( dds_qos_t * qos, const rmw_node_security_options_t * security_options) { - #if RMW_SUPPORT_SECURITY /* File path is set to nullptr if file does not exist or is not readable */ store_security_filepath_in_qos( @@ -789,13 +787,18 @@ extern "C" rmw_node_t * rmw_create_node( #endif dds_qos_t * qos = dds_create_qos(); - RCUTILS_CHECK_FOR_NULL_WITH_MSG( - security_options, "rmw_create_node: Unable to create qos", return nullptr); + if (qos == nullptr) { + RCUTILS_LOG_ERROR_NAMED("rmw_cyclonedds_cpp", "rmw_create_node: Unable to create qos"); + node_gone_from_domain_locked(did); + return nullptr; + } std::string user_data = get_node_user_data(name, namespace_); dds_qset_userdata(qos, user_data.c_str(), user_data.size()); if (security_options->enforce_security) { if (configure_qos_for_security(qos, security_options) != RMW_RET_OK) { + dds_delete_qos(qos); + node_gone_from_domain_locked(did); return nullptr; } } From 1ca2269e6640881072eb3cc61d42666ea947adf2 Mon Sep 17 00:00:00 2001 From: Sid Faber <56845980+SidFaber@users.noreply.github.com> Date: Thu, 2 Apr 2020 12:36:31 -0400 Subject: [PATCH 04/12] Improve security logic and memory management Properly handle downstream effects of ROS_SECURITY_STRATEGY and ROS_SECURITY_ENABLE environment variables through security_options. Improve memory management and make sure to only set security qos properties when all files are sure to exist. --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 164 +++++++++++++++++----------- 1 file changed, 103 insertions(+), 61 deletions(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 993758c7..8187cf29 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -147,6 +147,18 @@ struct builtin_readers dds_entity_t rds[sizeof(builtin_topics) / sizeof(builtin_topics[0])]; }; +#if RMW_SUPPORT_SECURITY +struct dds_security_files_t +{ + char * identity_ca_cert = nullptr; + char * cert = nullptr; + char * key = nullptr; + char * permissions_ca_cert = nullptr; + char * governance_p7s = nullptr; + char * permissions_p7s = nullptr; +}; +#endif + struct CddsEntity { dds_entity_t enth; @@ -653,81 +665,108 @@ static std::string get_node_user_data(const char * node_name, const char * node_ #if RMW_SUPPORT_SECURITY /* Returns the full URI of a security file properly formatted for DDS */ -char * get_security_file_URI( - const char * security_filename, const char * node_secure_root, +bool get_security_file_URI( + char ** security_file, const char * security_filename, const char * node_secure_root, const rcutils_allocator_t allocator) { - char * ret; - + *security_file = nullptr; char * file_path = rcutils_join_path(node_secure_root, security_filename, allocator); - if (file_path == nullptr) { - ret = nullptr; - } else if (!rcutils_is_readable(file_path)) { - RCUTILS_LOG_ERROR_NAMED( - "rmw_cyclonedds_cpp", "get_security_file: %s not found", file_path); - ret = nullptr; - allocator.deallocate(file_path, allocator.state); - } else { - /* Cyclone also supports a "data:" URI */ - ret = rcutils_format_string(allocator, "file:%s", file_path); - allocator.deallocate(file_path, allocator.state); + if (file_path != nullptr) { + if (rcutils_is_readable(file_path)) { + /* Cyclone also supports a "data:" URI */ + *security_file = rcutils_format_string(allocator, "file:%s", file_path); + allocator.deallocate(file_path, allocator.state); + } else { + RCUTILS_LOG_INFO_NAMED( + "rmw_cyclonedds_cpp", "get_security_file_URI: %s not found", file_path); + allocator.deallocate(file_path, allocator.state); + } + } + return *security_file != nullptr; +} + +bool get_security_file_URIs( + const rmw_node_security_options_t * security_options, + dds_security_files_t & dds_security_files, rcutils_allocator_t allocator) +{ + bool ret = false; + + if (security_options->security_root_path != nullptr) { + ret = ( + get_security_file_URI( + &dds_security_files.identity_ca_cert, "identity_ca.cert.pem", + security_options->security_root_path, allocator) && + get_security_file_URI( + &dds_security_files.cert, "cert.pem", + security_options->security_root_path, allocator) && + get_security_file_URI( + &dds_security_files.key, "key.pem", + security_options->security_root_path, allocator) && + get_security_file_URI( + &dds_security_files.permissions_ca_cert, "permissions_ca.cert.pem", + security_options->security_root_path, allocator) && + get_security_file_URI( + &dds_security_files.governance_p7s, "governance.p7s", + security_options->security_root_path, allocator) && + get_security_file_URI( + &dds_security_files.permissions_p7s, "permissions.p7s", + security_options->security_root_path, allocator)); } return ret; } -void store_security_filepath_in_qos( - dds_qos_t * qos, const char * qos_property_name, const char * file_name, - const rmw_node_security_options_t * security_options) +void finalize_security_file_URIs( + dds_security_files_t dds_security_files, const rcutils_allocator_t allocator) { - rcutils_allocator_t allocator = rcutils_get_default_allocator(); - - char * security_file_path = get_security_file_URI( - file_name, security_options->security_root_path, allocator); - if (security_file_path != nullptr) { - dds_qset_prop(qos, qos_property_name, security_file_path); - allocator.deallocate(security_file_path, allocator.state); - } + allocator.deallocate(dds_security_files.identity_ca_cert, allocator.state); + dds_security_files.identity_ca_cert = nullptr; + allocator.deallocate(dds_security_files.cert, allocator.state); + dds_security_files.cert = nullptr; + allocator.deallocate(dds_security_files.key, allocator.state); + dds_security_files.key = nullptr; + allocator.deallocate(dds_security_files.permissions_ca_cert, allocator.state); + dds_security_files.permissions_ca_cert = nullptr; + allocator.deallocate(dds_security_files.governance_p7s, allocator.state); + dds_security_files.governance_p7s = nullptr; + allocator.deallocate(dds_security_files.permissions_p7s, allocator.state); + dds_security_files.permissions_p7s = nullptr; } + #endif /* RMW_SUPPORT_SECURITY */ -/* Set all the qos properties needed to enable DDS security */ +/* Attempt to set all the qos properties needed to enable DDS security */ rmw_ret_t configure_qos_for_security( dds_qos_t * qos, const rmw_node_security_options_t * security_options) { #if RMW_SUPPORT_SECURITY - /* File path is set to nullptr if file does not exist or is not readable */ - store_security_filepath_in_qos( - qos, "dds.sec.auth.identity_ca", "identity_ca.cert.pem", - security_options); - store_security_filepath_in_qos( - qos, "dds.sec.auth.identity_certificate", "cert.pem", - security_options); - store_security_filepath_in_qos( - qos, "dds.sec.auth.private_key", "key.pem", - security_options); - store_security_filepath_in_qos( - qos, "dds.sec.access.permissions_ca", "permissions_ca.cert.pem", - security_options); - store_security_filepath_in_qos( - qos, "dds.sec.access.governance", "governance.p7s", - security_options); - store_security_filepath_in_qos( - qos, "dds.sec.access.permissions", "permissions.p7s", - security_options); - - dds_qset_prop(qos, "dds.sec.auth.library.path", "dds_security_auth"); - dds_qset_prop(qos, "dds.sec.auth.library.init", "init_authentication"); - dds_qset_prop(qos, "dds.sec.auth.library.finalize", "finalize_authentication"); - - dds_qset_prop(qos, "dds.sec.crypto.library.path", "dds_security_crypto"); - dds_qset_prop(qos, "dds.sec.crypto.library.init", "init_crypto"); - dds_qset_prop(qos, "dds.sec.crypto.library.finalize", "finalize_crypto"); - - dds_qset_prop(qos, "dds.sec.access.library.path", "dds_security_ac"); - dds_qset_prop(qos, "dds.sec.access.library.init", "init_access_control"); - dds_qset_prop(qos, "dds.sec.access.library.finalize", "finalize_access_control"); + rmw_ret_t ret = RMW_RET_UNSUPPORTED; + dds_security_files_t dds_security_files; + rcutils_allocator_t allocator = rcutils_get_default_allocator(); - return RMW_RET_OK; + if (get_security_file_URIs(security_options, dds_security_files, allocator)) { + dds_qset_prop(qos, "dds.sec.auth.identity_ca", dds_security_files.identity_ca_cert); + dds_qset_prop(qos, "dds.sec.auth.identity_certificate", dds_security_files.cert); + dds_qset_prop(qos, "dds.sec.auth.private_key", dds_security_files.key); + dds_qset_prop(qos, "dds.sec.access.permissions_ca", dds_security_files.permissions_ca_cert); + dds_qset_prop(qos, "dds.sec.access.governance", dds_security_files.governance_p7s); + dds_qset_prop(qos, "dds.sec.access.permissions", dds_security_files.permissions_p7s); + + dds_qset_prop(qos, "dds.sec.auth.library.path", "dds_security_auth"); + dds_qset_prop(qos, "dds.sec.auth.library.init", "init_authentication"); + dds_qset_prop(qos, "dds.sec.auth.library.finalize", "finalize_authentication"); + + dds_qset_prop(qos, "dds.sec.crypto.library.path", "dds_security_crypto"); + dds_qset_prop(qos, "dds.sec.crypto.library.init", "init_crypto"); + dds_qset_prop(qos, "dds.sec.crypto.library.finalize", "finalize_crypto"); + + dds_qset_prop(qos, "dds.sec.access.library.path", "dds_security_ac"); + dds_qset_prop(qos, "dds.sec.access.library.init", "init_access_control"); + dds_qset_prop(qos, "dds.sec.access.library.finalize", "finalize_access_control"); + + ret = RMW_RET_OK; + } + finalize_security_file_URIs(dds_security_files, allocator); + return ret; #else (void) qos; (void) security_options; @@ -795,11 +834,14 @@ extern "C" rmw_node_t * rmw_create_node( std::string user_data = get_node_user_data(name, namespace_); dds_qset_userdata(qos, user_data.c_str(), user_data.size()); - if (security_options->enforce_security) { - if (configure_qos_for_security(qos, security_options) != RMW_RET_OK) { + if (configure_qos_for_security(qos, security_options) != RMW_RET_OK) { + if (security_options->enforce_security == RMW_SECURITY_ENFORCEMENT_ENFORCE) { dds_delete_qos(qos); node_gone_from_domain_locked(did); return nullptr; + } else { + RCUTILS_LOG_INFO_NAMED( + "rmw_cyclonedds_cpp", "rmw_create_node: Unable to configure security"); } } From 68d8b523ef1205088e132ceaa783bf6239dabc0e Mon Sep 17 00:00:00 2001 From: Sid Faber <56845980+SidFaber@users.noreply.github.com> Date: Thu, 2 Apr 2020 13:15:06 -0400 Subject: [PATCH 05/12] Removed stray newline Fix residue from merge conflict in README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index e5861682..1879246b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ Cyclone DDS is ready to use. It seeks to give the fastest, easiest, and most rob ## Building from source and contributing - Note the `master` branch maintains compatibility with ROS releases Dashing and later, including the not-yet-released [*Foxy*](https://index.ros.org/doc/ros2/Releases/Release-Foxy-Fitzroy/). If building ROS2 from source ([ros2.repos](https://github.com/ros2/ros2/blob/master/ros2.repos)), you already have this package and Cyclone DDS: From 4ac0536eff3bdf25352d244f6bab62b36c9ec43f Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Thu, 9 Apr 2020 11:39:06 -0500 Subject: [PATCH 06/12] Change branching strategy (#142) * Change branching strategy - now `master` targets Foxy and `dashing-eloquent` targets Dashing and Eloquent fix https://github.com/ros2/rmw_cyclonedds/issues/128 --- .github/workflows/CI.yml | 9 +-------- README.md | 5 ++++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 675dcf4b..b937554d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -5,15 +5,8 @@ jobs: strategy: fail-fast: false matrix: - rosdistro: [dashing, eloquent, master] + rosdistro: [master] os: [ubuntu-18.04, macOS-latest, windows-latest] - exclude: - # pending https://github.com/ament/ament_cmake/pull/233 - - rosdistro: eloquent - os: windows-latest - # pending https://github.com/ament/ament_cmake/pull/234 - - rosdistro: dashing - os: windows-latest runs-on: ${{ matrix.os }} steps: - if: runner.os == 'Linux' diff --git a/README.md b/README.md index 1879246b..fec645e4 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,10 @@ Cyclone DDS is ready to use. It seeks to give the fastest, easiest, and most rob ## Building from source and contributing -Note the `master` branch maintains compatibility with ROS releases Dashing and later, including the not-yet-released [*Foxy*](https://index.ros.org/doc/ros2/Releases/Release-Foxy-Fitzroy/). +The following branches are actively maintained: + +* `master`, which targets the upcoming ROS version, [*Foxy*](https://index.ros.org/doc/ros2/Releases/Release-Foxy-Fitzroy/). +* `dashing-eloquent`, which maintains compatibility with ROS releases [*Dashing*](https://index.ros.org/doc/ros2/Releases/Release-Dashing-Diademata/) and [*Eloquent*](https://index.ros.org/doc/ros2/Releases/Release-Eloquent-Elusor/) If building ROS2 from source ([ros2.repos](https://github.com/ros2/ros2/blob/master/ros2.repos)), you already have this package and Cyclone DDS: From cf22b2608aae9591fb0d81edec13b76da51789cd Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Thu, 9 Apr 2020 11:45:50 -0500 Subject: [PATCH 07/12] Remove cyclonedds_cmake_module (#139) Delete cyclonedds_cmake_module package and remove dependencies on it. This is not needed, since Eclipse Cyclone DDS already provides a package configuration file (CycloneDDSConfig.cmake) --- cyclonedds_cmake_module/CHANGELOG.rst | 27 ------- cyclonedds_cmake_module/CMakeLists.txt | 31 -------- .../cmake/Modules/FindCycloneDDS.cmake | 70 ------------------- .../cyclonedds_cmake_module-extras.cmake | 15 ---- cyclonedds_cmake_module/package.xml | 18 ----- rmw_cyclonedds_cpp/CMakeLists.txt | 2 +- rmw_cyclonedds_cpp/package.xml | 2 - 7 files changed, 1 insertion(+), 164 deletions(-) delete mode 100644 cyclonedds_cmake_module/CHANGELOG.rst delete mode 100644 cyclonedds_cmake_module/CMakeLists.txt delete mode 100644 cyclonedds_cmake_module/cmake/Modules/FindCycloneDDS.cmake delete mode 100644 cyclonedds_cmake_module/cyclonedds_cmake_module-extras.cmake delete mode 100644 cyclonedds_cmake_module/package.xml diff --git a/cyclonedds_cmake_module/CHANGELOG.rst b/cyclonedds_cmake_module/CHANGELOG.rst deleted file mode 100644 index 07c8690b..00000000 --- a/cyclonedds_cmake_module/CHANGELOG.rst +++ /dev/null @@ -1,27 +0,0 @@ -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Changelog for package cyclonedds_cmake_module -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -0.5.1 (2020-03-12) ------------------- - -0.4.4 (2019-11-19) ------------------- - -0.4.3 (2019-11-13) ------------------- - -0.4.2 (2019-11-01) ------------------- - -0.4.1 (2019-10-24) ------------------- -* Use rosdep (`#32 `_) -* Contributors: Dan Rose - -0.4.0 (2019-08-29) ------------------- -* Ensure all packages in the repository have the same version - Signed-off-by: Scott K Logan -* remove Fast-CDR references in CMake config -* initial commit -* Contributors: Erik Boasson, Scott K Logan diff --git a/cyclonedds_cmake_module/CMakeLists.txt b/cyclonedds_cmake_module/CMakeLists.txt deleted file mode 100644 index 96533615..00000000 --- a/cyclonedds_cmake_module/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cmake_minimum_required(VERSION 3.5) - -project(cyclonedds_cmake_module) - -find_package(ament_cmake REQUIRED) - -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - ament_lint_auto_find_test_dependencies() -endif() - -ament_package( - CONFIG_EXTRAS "cyclonedds_cmake_module-extras.cmake" -) - -install(DIRECTORY cmake - DESTINATION share/${PROJECT_NAME}) diff --git a/cyclonedds_cmake_module/cmake/Modules/FindCycloneDDS.cmake b/cyclonedds_cmake_module/cmake/Modules/FindCycloneDDS.cmake deleted file mode 100644 index 79c655ee..00000000 --- a/cyclonedds_cmake_module/cmake/Modules/FindCycloneDDS.cmake +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright 2018 ADLINK Technology Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -############################################################################### -# -# CMake module for finding Eclipse Cyclone DDS. -# -# Output variables: -# -# - CycloneDDS_FOUND: flag indicating if the package was found -# - CycloneDDS_INCLUDE_DIR: Paths to the header files -# -# Example usage: -# -# find_package(CycloneDDS_cmake_module REQUIRED) -# find_package(CycloneDDS MODULE) -# # use CycloneDDS_* variables -# -############################################################################### - -# lint_cmake: -convention/filename, -package/stdargs - -set(CycloneDDS_FOUND FALSE) - -find_package(CycloneDDS REQUIRED CONFIG) - -#find_library(CycloneDDS_LIBRARY_RELEASE -# NAMES cyclonedds-${cyclonedds_MAJOR_MINOR_VERSION} cyclonedds) -find_library(CycloneDDS_LIBRARY_RELEASE - NAMES cdds cdds) -#find_library(CycloneDDS_LIBRARY_DEBUG -# NAMES cycloneddsd-${cyclonedds_MAJOR_MINOR_VERSION}) - -set(CycloneDDS_INCLUDE_DIR get_target_property(VAR CycloneDDS::ddsc INTERFACE_INCLUDE_DIRECTORIES)) - -if(CycloneDDS_LIBRARY_RELEASE AND CycloneDDS_LIBRARY_DEBUG) - set(CycloneDDS_LIBRARIES - optimized ${CycloneDDS_LIBRARY_RELEASE} - debug ${CycloneDDS_LIBRARY_DEBUG} - ) -elseif(CycloneDDS_LIBRARY_RELEASE) - set(CycloneDDS_LIBRARIES - ${CycloneDDS_LIBRARY_RELEASE} - ) -elseif(CycloneDDS_LIBRARY_DEBUG) - set(CycloneDDS_LIBRARIES - ${CycloneDDS_LIBRARY_DEBUG} - ) -else() - set(CycloneDDS_LIBRARIES "") -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CycloneDDS - FOUND_VAR CycloneDDS_FOUND - REQUIRED_VARS - CycloneDDS_INCLUDE_DIR - CycloneDDS_LIBRARIES -) diff --git a/cyclonedds_cmake_module/cyclonedds_cmake_module-extras.cmake b/cyclonedds_cmake_module/cyclonedds_cmake_module-extras.cmake deleted file mode 100644 index a96253bb..00000000 --- a/cyclonedds_cmake_module/cyclonedds_cmake_module-extras.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -list(INSERT CMAKE_MODULE_PATH 0 "${cyclonedds_cmake_module_DIR}/Modules") diff --git a/cyclonedds_cmake_module/package.xml b/cyclonedds_cmake_module/package.xml deleted file mode 100644 index 11f9c400..00000000 --- a/cyclonedds_cmake_module/package.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - cyclonedds_cmake_module - 0.5.1 - Provide CMake module to find Eclipse CycloneDDS. - Erik Boasson - Apache License 2.0 - - ament_cmake - - ament_lint_auto - ament_lint_common - - - ament_cmake - - diff --git a/rmw_cyclonedds_cpp/CMakeLists.txt b/rmw_cyclonedds_cpp/CMakeLists.txt index cffd7f75..f621a9b3 100644 --- a/rmw_cyclonedds_cpp/CMakeLists.txt +++ b/rmw_cyclonedds_cpp/CMakeLists.txt @@ -29,7 +29,7 @@ find_package(ament_cmake_ros REQUIRED) find_package(rcutils REQUIRED) -find_package(cyclonedds_cmake_module REQUIRED) +#find_package(cyclonedds_cmake_module REQUIRED) find_package(CycloneDDS QUIET CONFIG) if(NOT CycloneDDS_FOUND) message(WARNING "Could not find Eclipse Cyclone DDS - skipping '${PROJECT_NAME}'") diff --git a/rmw_cyclonedds_cpp/package.xml b/rmw_cyclonedds_cpp/package.xml index 2fdca0d0..0308fb8e 100644 --- a/rmw_cyclonedds_cpp/package.xml +++ b/rmw_cyclonedds_cpp/package.xml @@ -8,10 +8,8 @@ Apache License 2.0 ament_cmake_ros - cyclonedds_cmake_module cyclonedds - cyclonedds_cmake_module rcutils rmw rosidl_generator_c From 654f3d46aa4d138da16c60ab74eedfab47f72d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Fri, 10 Apr 2020 12:26:45 +0200 Subject: [PATCH 08/12] Added rosidl_runtime c and cpp dependencies (#138) * Replaced rosidl_generator_x with rosidl_runtime_x Signed-off-by: ahcorde * Fixed package.zml Signed-off-by: ahcorde --- rmw_cyclonedds_cpp/CMakeLists.txt | 6 +++--- rmw_cyclonedds_cpp/package.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rmw_cyclonedds_cpp/CMakeLists.txt b/rmw_cyclonedds_cpp/CMakeLists.txt index f621a9b3..6ffe634e 100644 --- a/rmw_cyclonedds_cpp/CMakeLists.txt +++ b/rmw_cyclonedds_cpp/CMakeLists.txt @@ -38,13 +38,13 @@ if(NOT CycloneDDS_FOUND) endif() find_package(rmw REQUIRED) -find_package(rosidl_generator_c REQUIRED) +find_package(rosidl_runtime_c REQUIRED) find_package(rosidl_typesupport_introspection_c REQUIRED) find_package(rosidl_typesupport_introspection_cpp REQUIRED) ament_export_dependencies(rcutils) ament_export_dependencies(rmw) -ament_export_dependencies(rosidl_generator_c) +ament_export_dependencies(rosidl_runtime_c) ament_export_dependencies(rosidl_typesupport_introspection_c) ament_export_dependencies(rosidl_typesupport_introspection_cpp) @@ -71,7 +71,7 @@ ament_target_dependencies(rmw_cyclonedds_cpp "rosidl_typesupport_introspection_c" "rosidl_typesupport_introspection_cpp" "rmw" - "rosidl_generator_c" + "rosidl_runtime_c" ) configure_rmw_library(rmw_cyclonedds_cpp) diff --git a/rmw_cyclonedds_cpp/package.xml b/rmw_cyclonedds_cpp/package.xml index 0308fb8e..e3cdc7d5 100644 --- a/rmw_cyclonedds_cpp/package.xml +++ b/rmw_cyclonedds_cpp/package.xml @@ -12,7 +12,7 @@ cyclonedds rcutils rmw - rosidl_generator_c + rosidl_runtime_c rosidl_typesupport_introspection_c rosidl_typesupport_introspection_cpp From 5c6b187fa948d206c1e8cb90fd319258819a32fc Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Fri, 10 Apr 2020 22:14:29 -0700 Subject: [PATCH 09/12] rename rosidl_generator_c namespace to rosidl_runtime_c (#150) Signed-off-by: Dirk Thomas --- .../rmw_cyclonedds_cpp/TypeSupport.hpp | 18 +++---- .../rmw_cyclonedds_cpp/TypeSupport_impl.hpp | 48 +++++++++---------- .../include/rmw_cyclonedds_cpp/macros.hpp | 6 +-- .../include/rmw_cyclonedds_cpp/u16string.hpp | 6 +-- rmw_cyclonedds_cpp/src/Serialization.hpp | 2 +- rmw_cyclonedds_cpp/src/TypeSupport2.hpp | 8 ++-- rmw_cyclonedds_cpp/src/u16string.cpp | 8 ++-- 7 files changed, 48 insertions(+), 48 deletions(-) diff --git a/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/TypeSupport.hpp b/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/TypeSupport.hpp index 206f52f5..303ef3cb 100644 --- a/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/TypeSupport.hpp +++ b/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/TypeSupport.hpp @@ -16,9 +16,9 @@ #ifndef RMW_CYCLONEDDS_CPP__TYPESUPPORT_HPP_ #define RMW_CYCLONEDDS_CPP__TYPESUPPORT_HPP_ -#include -#include -#include +#include +#include +#include #include #include @@ -53,15 +53,15 @@ struct StringHelper; template<> struct StringHelper { - using type = rosidl_generator_c__String; + using type = rosidl_runtime_c__String; static std::string convert_to_std_string(void * data) { - auto c_string = static_cast(data); + auto c_string = static_cast(data); if (!c_string) { RCUTILS_LOG_ERROR_NAMED( "rmw_cyclonedds_cpp", - "Failed to cast data as rosidl_generator_c__String"); + "Failed to cast data as rosidl_runtime_c__String"); return ""; } if (!c_string->data) { @@ -73,7 +73,7 @@ struct StringHelper return std::string(c_string->data); } - static std::string convert_to_std_string(rosidl_generator_c__String & data) + static std::string convert_to_std_string(rosidl_runtime_c__String & data) { return std::string(data.data); } @@ -82,8 +82,8 @@ struct StringHelper { std::string str; deser >> str; - rosidl_generator_c__String * c_str = static_cast(field); - rosidl_generator_c__String__assign(c_str, str.c_str()); + rosidl_runtime_c__String * c_str = static_cast(field); + rosidl_runtime_c__String__assign(c_str, str.c_str()); } }; diff --git a/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/TypeSupport_impl.hpp b/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/TypeSupport_impl.hpp index f2cc2cba..0a733ee2 100644 --- a/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/TypeSupport_impl.hpp +++ b/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/TypeSupport_impl.hpp @@ -30,8 +30,8 @@ #include "rosidl_typesupport_introspection_c/message_introspection.h" #include "rosidl_typesupport_introspection_c/service_introspection.h" -#include "rosidl_generator_c/primitives_sequence_functions.h" -#include "rosidl_generator_c/u16string_functions.h" +#include "rosidl_runtime_c/primitives_sequence_functions.h" +#include "rosidl_runtime_c/u16string_functions.h" #include "serdes.hpp" #include "u16string.hpp" @@ -56,19 +56,19 @@ SPECIALIZE_GENERIC_C_SEQUENCE(uint32, uint32_t) SPECIALIZE_GENERIC_C_SEQUENCE(int64, int64_t) SPECIALIZE_GENERIC_C_SEQUENCE(uint64, uint64_t) -typedef struct rosidl_generator_c__void__Sequence +typedef struct rosidl_runtime_c__void__Sequence { void * data; /// The number of valid items in data size_t size; /// The number of allocated items in data size_t capacity; -} rosidl_generator_c__void__Sequence; +} rosidl_runtime_c__void__Sequence; inline bool -rosidl_generator_c__void__Sequence__init( - rosidl_generator_c__void__Sequence * sequence, size_t size, size_t member_size) +rosidl_runtime_c__void__Sequence__init( + rosidl_runtime_c__void__Sequence * sequence, size_t size, size_t member_size) { if (!sequence) { return false; @@ -88,7 +88,7 @@ rosidl_generator_c__void__Sequence__init( inline void -rosidl_generator_c__void__Sequence__fini(rosidl_generator_c__void__Sequence * sequence) +rosidl_runtime_c__void__Sequence__fini(rosidl_runtime_c__void__Sequence * sequence) { if (!sequence) { return; @@ -182,7 +182,7 @@ static size_t calculateMaxAlign(const MembersType * members) if (std::is_same::value) { - alignment = alignof(rosidl_generator_c__String); + alignment = alignof(rosidl_runtime_c__String); } else { alignment = alignof(std::string); } @@ -229,7 +229,7 @@ size_t get_array_size_and_assign_field( void * & subros_message, size_t, size_t) { - auto tmpsequence = static_cast(field); + auto tmpsequence = static_cast(field); if (member->is_upper_bound_ && tmpsequence->size > member->array_size_) { throw std::runtime_error("vector overcomes the maximum length"); } @@ -353,34 +353,34 @@ inline void deserialize_field( CStringHelper::assign(deser, field, call_new); } else { if (member->array_size_ && !member->is_upper_bound_) { - auto deser_field = static_cast(field); + auto deser_field = static_cast(field); // tmpstring is defined here and not below to avoid // memory allocation in every iteration of the for loop std::string tmpstring; for (size_t i = 0; i < member->array_size_; ++i) { deser.deserialize(tmpstring); - if (!rosidl_generator_c__String__assign(&deser_field[i], tmpstring.c_str())) { - throw std::runtime_error("unable to assign rosidl_generator_c__String"); + if (!rosidl_runtime_c__String__assign(&deser_field[i], tmpstring.c_str())) { + throw std::runtime_error("unable to assign rosidl_runtime_c__String"); } } } else { std::vector cpp_string_vector; deser >> cpp_string_vector; - auto & string_array_field = *reinterpret_cast(field); + auto & string_array_field = *reinterpret_cast(field); if ( - !rosidl_generator_c__String__Sequence__init( + !rosidl_runtime_c__String__Sequence__init( &string_array_field, cpp_string_vector.size())) { - throw std::runtime_error("unable to initialize rosidl_generator_c__String array"); + throw std::runtime_error("unable to initialize rosidl_runtime_c__String array"); } for (size_t i = 0; i < cpp_string_vector.size(); ++i) { if ( - !rosidl_generator_c__String__assign( + !rosidl_runtime_c__String__assign( &string_array_field.data[i], cpp_string_vector[i].c_str())) { - throw std::runtime_error("unable to assign rosidl_generator_c__String"); + throw std::runtime_error("unable to assign rosidl_runtime_c__String"); } } } @@ -399,9 +399,9 @@ inline void deserialize_field( if (!member->is_array_) { deser >> wstr; wstring_to_u16string( - wstr, *static_cast(field)); + wstr, *static_cast(field)); } else if (member->array_size_ && !member->is_upper_bound_) { - auto array = static_cast(field); + auto array = static_cast(field); for (size_t i = 0; i < member->array_size_; ++i) { deser >> wstr; wstring_to_u16string(wstr, array[i]); @@ -409,9 +409,9 @@ inline void deserialize_field( } else { uint32_t size; deser >> size; - auto sequence = static_cast(field); - if (!rosidl_generator_c__U16String__Sequence__init(sequence, size)) { - throw std::runtime_error("unable to initialize rosidl_generator_c__U16String sequence"); + auto sequence = static_cast(field); + if (!rosidl_runtime_c__U16String__Sequence__init(sequence, size)) { + throw std::runtime_error("unable to initialize rosidl_runtime_c__U16String sequence"); } for (size_t i = 0; i < sequence->size; ++i) { deser >> wstr; @@ -452,8 +452,8 @@ inline size_t get_submessage_array_deserialize( { (void)member; uint32_t vsize = deser.deserialize_len(1); - auto tmparray = static_cast(field); - rosidl_generator_c__void__Sequence__init(tmparray, vsize, sub_members_size); + auto tmparray = static_cast(field); + rosidl_runtime_c__void__Sequence__init(tmparray, vsize, sub_members_size); subros_message = reinterpret_cast(tmparray->data); return vsize; } diff --git a/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/macros.hpp b/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/macros.hpp index 2d6b6216..9be8efe5 100644 --- a/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/macros.hpp +++ b/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/macros.hpp @@ -22,14 +22,14 @@ template<> \ struct GenericCSequence \ { \ - using type = rosidl_generator_c__ ## C_NAME ## __Sequence; \ + using type = rosidl_runtime_c__ ## C_NAME ## __Sequence; \ \ static void fini(type * array) { \ - rosidl_generator_c__ ## C_NAME ## __Sequence__fini(array); \ + rosidl_runtime_c__ ## C_NAME ## __Sequence__fini(array); \ } \ \ static bool init(type * array, size_t size) { \ - return rosidl_generator_c__ ## C_NAME ## __Sequence__init(array, size); \ + return rosidl_runtime_c__ ## C_NAME ## __Sequence__init(array, size); \ } \ }; diff --git a/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/u16string.hpp b/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/u16string.hpp index eae6f096..2c298964 100644 --- a/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/u16string.hpp +++ b/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/u16string.hpp @@ -16,16 +16,16 @@ #define RMW_CYCLONEDDS_CPP__U16STRING_HPP_ #include -#include "rosidl_generator_c/u16string_functions.h" +#include "rosidl_runtime_c/u16string_functions.h" namespace rmw_cyclonedds_cpp { void u16string_to_wstring( - const rosidl_generator_c__U16String & u16str, std::wstring & wstr); + const rosidl_runtime_c__U16String & u16str, std::wstring & wstr); bool wstring_to_u16string( - const std::wstring & wstr, rosidl_generator_c__U16String & u16str); + const std::wstring & wstr, rosidl_runtime_c__U16String & u16str); void u16string_to_wstring(const std::u16string & u16str, std::wstring & wstr); diff --git a/rmw_cyclonedds_cpp/src/Serialization.hpp b/rmw_cyclonedds_cpp/src/Serialization.hpp index b1d1ff8a..5265b845 100644 --- a/rmw_cyclonedds_cpp/src/Serialization.hpp +++ b/rmw_cyclonedds_cpp/src/Serialization.hpp @@ -17,7 +17,7 @@ #include #include "TypeSupport2.hpp" -#include "rosidl_generator_c/service_type_support_struct.h" +#include "rosidl_runtime_c/service_type_support_struct.h" #include "serdata.hpp" namespace rmw_cyclonedds_cpp diff --git a/rmw_cyclonedds_cpp/src/TypeSupport2.hpp b/rmw_cyclonedds_cpp/src/TypeSupport2.hpp index c3e065f5..13ea0314 100644 --- a/rmw_cyclonedds_cpp/src/TypeSupport2.hpp +++ b/rmw_cyclonedds_cpp/src/TypeSupport2.hpp @@ -24,8 +24,8 @@ #include "bytewise.hpp" #include "rmw_cyclonedds_cpp/exception.hpp" -#include "rosidl_generator_c/string_functions.h" -#include "rosidl_generator_c/u16string_functions.h" +#include "rosidl_runtime_c/string_functions.h" +#include "rosidl_runtime_c/u16string_functions.h" #include "rosidl_typesupport_introspection_c/identifier.h" #include "rosidl_typesupport_introspection_c/message_introspection.h" #include "rosidl_typesupport_introspection_c/service_introspection.h" @@ -397,7 +397,7 @@ class U16StringValueType : public AnyValueType struct ROSIDLC_StringValueType : public U8StringValueType { public: - using type = rosidl_generator_c__String; + using type = rosidl_runtime_c__String; TypedSpan data(const void * ptr) const override { @@ -419,7 +419,7 @@ struct ROSIDLC_StringValueType : public U8StringValueType class ROSIDLC_WStringValueType : public U16StringValueType { public: - using type = rosidl_generator_c__U16String; + using type = rosidl_runtime_c__U16String; TypedSpan data(const void * ptr) const override { diff --git a/rmw_cyclonedds_cpp/src/u16string.cpp b/rmw_cyclonedds_cpp/src/u16string.cpp index ec0d4540..562041ad 100644 --- a/rmw_cyclonedds_cpp/src/u16string.cpp +++ b/rmw_cyclonedds_cpp/src/u16string.cpp @@ -13,7 +13,7 @@ // limitations under the License. #include -#include "rosidl_generator_c/u16string_functions.h" +#include "rosidl_runtime_c/u16string_functions.h" namespace rmw_cyclonedds_cpp { @@ -39,7 +39,7 @@ bool wstring_to_u16string(const std::wstring & wstr, std::u16string & u16str) return true; } -void u16string_to_wstring(const rosidl_generator_c__U16String & u16str, std::wstring & wstr) +void u16string_to_wstring(const rosidl_runtime_c__U16String & u16str, std::wstring & wstr) { wstr.resize(u16str.size); for (size_t i = 0; i < u16str.size; ++i) { @@ -47,9 +47,9 @@ void u16string_to_wstring(const rosidl_generator_c__U16String & u16str, std::wst } } -bool wstring_to_u16string(const std::wstring & wstr, rosidl_generator_c__U16String & u16str) +bool wstring_to_u16string(const std::wstring & wstr, rosidl_runtime_c__U16String & u16str) { - bool succeeded = rosidl_generator_c__U16String__resize(&u16str, wstr.size()); + bool succeeded = rosidl_runtime_c__U16String__resize(&u16str, wstr.size()); if (!succeeded) { return false; } From 0450e2d84058a1e708aaf360c3f163765bd9c2f8 Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Mon, 13 Apr 2020 15:29:31 +0200 Subject: [PATCH 10/12] security-context -> enclave (#146) Signed-off-by: Mikael Arguedas --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 48 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 4d5bf936..316e0077 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -383,7 +383,7 @@ extern "C" rmw_ret_t rmw_init_options_init( #if RMW_VERSION_GTE(0, 8, 2) init_options->localhost_only = RMW_LOCALHOST_ONLY_DEFAULT; init_options->domain_id = RMW_DEFAULT_DOMAIN_ID; - init_options->security_context = NULL; + init_options->enclave = NULL; init_options->security_options = rmw_get_zero_initialized_security_options(); #endif return RMW_RET_OK; @@ -406,19 +406,19 @@ extern "C" rmw_ret_t rmw_init_options_copy(const rmw_init_options_t * src, rmw_i const rcutils_allocator_t * allocator = &src->allocator; rmw_ret_t ret = RMW_RET_OK; - allocator->deallocate(dst->security_context, allocator->state); + allocator->deallocate(dst->enclave, allocator->state); *dst = *src; - dst->security_context = NULL; + dst->enclave = NULL; dst->security_options = rmw_get_zero_initialized_security_options(); - dst->security_context = rcutils_strdup(src->security_context, *allocator); - if (src->security_context && !dst->security_context) { + dst->enclave = rcutils_strdup(src->enclave, *allocator); + if (src->enclave && !dst->enclave) { ret = RMW_RET_BAD_ALLOC; goto fail; } return rmw_security_options_copy(&src->security_options, allocator, &dst->security_options); fail: - allocator->deallocate(dst->security_context, allocator->state); + allocator->deallocate(dst->enclave, allocator->state); return ret; #else *dst = *src; @@ -437,7 +437,7 @@ extern "C" rmw_ret_t rmw_init_options_fini(rmw_init_options_t * init_options) eclipse_cyclonedds_identifier, return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); #if RMW_VERSION_GTE(0, 8, 2) - allocator.deallocate(init_options->security_context, allocator.state); + allocator.deallocate(init_options->enclave, allocator.state); rmw_security_options_fini(&init_options->security_options, &allocator); #endif *init_options = rmw_get_zero_initialized_init_options(); @@ -702,10 +702,10 @@ static std::string get_node_user_data_name_ns(const char * node_name, const char #if RMW_VERSION_GTE(0, 8, 2) static std::string get_node_user_data( - const char * node_name, const char * node_namespace, const char * security_context) + const char * node_name, const char * node_namespace, const char * enclave) { return get_node_user_data_name_ns(node_name, node_namespace) + - std::string("securitycontext=") + std::string(security_context) + + std::string("enclave=") + std::string(enclave) + std::string(";"); } #else @@ -894,7 +894,7 @@ extern "C" rmw_node_t * rmw_create_node( dds_qos_t * qos = dds_create_qos(); #if RMW_VERSION_GTE(0, 8, 2) - std::string user_data = get_node_user_data(name, namespace_, context->options.security_context); + std::string user_data = get_node_user_data(name, namespace_, context->options.enclave); #else std::string user_data = get_node_user_data(name, namespace_); #endif @@ -3204,7 +3204,7 @@ extern "C" rmw_ret_t rmw_get_node_names_impl( const rmw_node_t * node, rcutils_string_array_t * node_names, rcutils_string_array_t * node_namespaces, - rcutils_string_array_t * security_contexts) + rcutils_string_array_t * enclaves) { RET_WRONG_IMPLID(node); auto node_impl = static_cast(node->data); @@ -3215,7 +3215,7 @@ extern "C" rmw_ret_t rmw_get_node_names_impl( } std::regex re { - "^name=([^;]*);namespace=([^;]*);(securitycontext=([^;]*);)?", + "^name=([^;]*);namespace=([^;]*);(enclave=([^;]*);)?", std::regex_constants::extended }; std::vector> ns; @@ -3240,8 +3240,8 @@ extern "C" rmw_ret_t rmw_get_node_names_impl( RMW_SET_ERROR_MSG(rcutils_get_error_string().str); goto fail_alloc; } - if (security_contexts && - rcutils_string_array_init(security_contexts, ns.size(), &allocator) != RCUTILS_RET_OK) + if (enclaves && + rcutils_string_array_init(enclaves, ns.size(), &allocator) != RCUTILS_RET_OK) { RMW_SET_ERROR_MSG(rcutils_get_error_string().str); goto fail_alloc; @@ -3255,10 +3255,10 @@ extern "C" rmw_ret_t rmw_get_node_names_impl( RMW_SET_ERROR_MSG("rmw_get_node_names for name/namespace"); goto fail_alloc; } - if (security_contexts) { - security_contexts->data[i] = rcutils_strdup(std::get<2>(n).c_str(), allocator); - if (!security_contexts->data[i]) { - RMW_SET_ERROR_MSG("rmw_get_node_names for security_context"); + if (enclaves) { + enclaves->data[i] = rcutils_strdup(std::get<2>(n).c_str(), allocator); + if (!enclaves->data[i]) { + RMW_SET_ERROR_MSG("rmw_get_node_names for enclave"); goto fail_alloc; } } @@ -3284,8 +3284,8 @@ extern "C" rmw_ret_t rmw_get_node_names_impl( rcutils_reset_error(); } } - if (security_contexts) { - if (rcutils_string_array_fini(security_contexts) != RCUTILS_RET_OK) { + if (enclaves) { + if (rcutils_string_array_fini(enclaves) != RCUTILS_RET_OK) { RCUTILS_LOG_ERROR_NAMED( "rmw_cyclonedds_cpp", "failed to cleanup during error handling: %s", rcutils_get_error_string().str); @@ -3308,20 +3308,20 @@ extern "C" rmw_ret_t rmw_get_node_names( } #if RMW_VERSION_GTE(0, 8, 2) -extern "C" rmw_ret_t rmw_get_node_names_with_security_contexts( +extern "C" rmw_ret_t rmw_get_node_names_with_enclaves( const rmw_node_t * node, rcutils_string_array_t * node_names, rcutils_string_array_t * node_namespaces, - rcutils_string_array_t * security_contexts) + rcutils_string_array_t * enclaves) { - if (RMW_RET_OK != rmw_check_zero_rmw_string_array(security_contexts)) { + if (RMW_RET_OK != rmw_check_zero_rmw_string_array(enclaves)) { return RMW_RET_ERROR; } return rmw_get_node_names_impl( node, node_names, node_namespaces, - security_contexts); + enclaves); } #endif From 5781044edd8bab6e648016a646552dda6c2e9a19 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Mon, 13 Apr 2020 16:08:25 -0500 Subject: [PATCH 11/12] Implement rmw_set_log_severity (#149) --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 316e0077..04dd6dd9 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -347,9 +347,24 @@ extern "C" const char * rmw_get_serialization_format() extern "C" rmw_ret_t rmw_set_log_severity(rmw_log_severity_t severity) { - static_cast(severity); - RMW_SET_ERROR_MSG("unimplemented"); - return RMW_RET_ERROR; + uint32_t mask = 0; + switch (severity) { + default: + RMW_SET_ERROR_MSG_WITH_FORMAT_STRING("%s: Invalid log severity '%d'", __func__, severity); + return RMW_RET_INVALID_ARGUMENT; + case RMW_LOG_SEVERITY_DEBUG: + mask |= DDS_LC_DISCOVERY | DDS_LC_THROTTLE | DDS_LC_CONFIG; + case RMW_LOG_SEVERITY_INFO: + mask |= DDS_LC_INFO; + case RMW_LOG_SEVERITY_WARN: + mask |= DDS_LC_WARNING; + case RMW_LOG_SEVERITY_ERROR: + mask |= DDS_LC_ERROR; + case RMW_LOG_SEVERITY_FATAL: + mask |= DDS_LC_FATAL; + } + dds_set_log_mask(mask); + return RMW_RET_OK; } extern "C" rmw_ret_t rmw_context_fini(rmw_context_t * context) From a9e8784c048b65e33cc284d1eaa61ed3339babfa Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Mon, 13 Apr 2020 21:05:42 -0500 Subject: [PATCH 12/12] Make case fallthrough explicit (#153) * Make case fallthrough explicit --- rmw_cyclonedds_cpp/CMakeLists.txt | 2 +- rmw_cyclonedds_cpp/src/fallthrough_macro.hpp | 29 ++++++++++++++++++++ rmw_cyclonedds_cpp/src/rmw_node.cpp | 5 ++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 rmw_cyclonedds_cpp/src/fallthrough_macro.hpp diff --git a/rmw_cyclonedds_cpp/CMakeLists.txt b/rmw_cyclonedds_cpp/CMakeLists.txt index 6ffe634e..8da01c40 100644 --- a/rmw_cyclonedds_cpp/CMakeLists.txt +++ b/rmw_cyclonedds_cpp/CMakeLists.txt @@ -22,7 +22,7 @@ if(NOT CMAKE_CXX_STANDARD) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) + add_compile_options(-Wall -Wextra -Wpedantic -Wimplicit-fallthrough) endif() find_package(ament_cmake_ros REQUIRED) diff --git a/rmw_cyclonedds_cpp/src/fallthrough_macro.hpp b/rmw_cyclonedds_cpp/src/fallthrough_macro.hpp new file mode 100644 index 00000000..ceb02d24 --- /dev/null +++ b/rmw_cyclonedds_cpp/src/fallthrough_macro.hpp @@ -0,0 +1,29 @@ +// Copyright 2019 ADLINK Technology via Rover Robotics and Dan Rose +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef FALLTHROUGH_MACRO_HPP_ +#define FALLTHROUGH_MACRO_HPP_ + +#if __has_cpp_attribute(fallthrough) || (__cplusplus >= 201603L) +// C++17 +#define FALLTHROUGH [[fallthrough]] +#elif __has_cpp_attribute(clang::fallthrough) +// Clang +#define FALLTHROUGH [[clang::fallthrough]] +#else +// gcc +#define FALLTHROUGH /* fallthrough */ +#endif + +#endif // FALLTHROUGH_MACRO_HPP_ diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 04dd6dd9..141706b7 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -45,6 +45,7 @@ #include "rmw/sanity_checks.h" #include "rmw/validate_node_name.h" +#include "fallthrough_macro.hpp" #include "Serialization.hpp" #include "rmw/impl/cpp/macros.hpp" @@ -354,12 +355,16 @@ extern "C" rmw_ret_t rmw_set_log_severity(rmw_log_severity_t severity) return RMW_RET_INVALID_ARGUMENT; case RMW_LOG_SEVERITY_DEBUG: mask |= DDS_LC_DISCOVERY | DDS_LC_THROTTLE | DDS_LC_CONFIG; + FALLTHROUGH; case RMW_LOG_SEVERITY_INFO: mask |= DDS_LC_INFO; + FALLTHROUGH; case RMW_LOG_SEVERITY_WARN: mask |= DDS_LC_WARNING; + FALLTHROUGH; case RMW_LOG_SEVERITY_ERROR: mask |= DDS_LC_ERROR; + FALLTHROUGH; case RMW_LOG_SEVERITY_FATAL: mask |= DDS_LC_FATAL; }