From 83da20c7b6c14fc772afbdb4e9ab1ee73f20ab2d Mon Sep 17 00:00:00 2001 From: Carlosespicur Date: Tue, 2 Jul 2024 07:24:24 +0200 Subject: [PATCH] change namespaces and regenerate types Signed-off-by: Carlosespicur --- examples/CMakeLists.txt | 2 +- examples/cpp/dds_security/CMakeLists.txt | 15 ------ .../Application.cpp | 8 +-- .../Application.hpp | 12 ++--- .../CLIParser.hpp | 19 +++---- .../CMakeLists.txt | 16 +++--- .../HelloWorld.hpp | 4 +- .../HelloWorld.idl | 0 .../HelloWorldCdrAux.hpp | 6 +-- .../HelloWorldCdrAux.ipp | 6 +-- .../HelloWorldPubSubTypes.cxx | 2 +- .../HelloWorldPubSubTypes.hpp} | 18 +++---- .../HelloWorldTypeObjectSupport.cxx | 0 .../HelloWorldTypeObjectSupport.hpp | 6 +-- .../PublisherApp.cpp | 9 ++-- .../PublisherApp.hpp | 12 ++--- .../README.md | 49 +++++-------------- .../SubscriberApp.cpp | 8 +-- .../SubscriberApp.hpp | 14 +++--- .../certs/governance.smime | 0 .../certs/governance_dds_sec.xml | 0 .../certs/maincacert.pem | 0 .../certs/maincakey.pem | 0 .../certs/mainpubcert.pem | 0 .../certs/mainpubkey.pem | 0 .../certs/mainsubcert.pem | 0 .../certs/mainsubkey.pem | 0 .../certs/permissions.smime | 0 .../certs/permissions_dds_sec.xml | 0 .../hello_world_profile.xml | 0 .../main.cpp | 6 +-- ...ample.compose.yml => security.compose.yml} | 6 +-- ...secure_hello_world.py => test_security.py} | 4 +- versions.md | 2 +- 34 files changed, 93 insertions(+), 131 deletions(-) delete mode 100644 examples/cpp/dds_security/CMakeLists.txt rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/Application.cpp (94%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/Application.hpp (82%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/CLIParser.hpp (96%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/CMakeLists.txt (80%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorld.hpp (98%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorld.idl (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorldCdrAux.hpp (88%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorldCdrAux.ipp (96%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorldPubSubTypes.cxx (99%) rename examples/cpp/{dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h => security/HelloWorldPubSubTypes.hpp} (89%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorldTypeObjectSupport.cxx (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/HelloWorldTypeObjectSupport.hpp (90%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/PublisherApp.cpp (98%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/PublisherApp.hpp (87%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/README.md (69%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/SubscriberApp.cpp (98%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/SubscriberApp.hpp (88%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/governance.smime (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/governance_dds_sec.xml (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/maincacert.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/maincakey.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/mainpubcert.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/mainpubkey.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/mainsubcert.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/mainsubkey.pem (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/permissions.smime (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/certs/permissions_dds_sec.xml (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/hello_world_profile.xml (100%) rename examples/cpp/{dds_security/SecureHelloWorldExample => security}/main.cpp (93%) rename test/examples/{SecureHelloWorldExample.compose.yml => security.compose.yml} (77%) rename test/examples/{test_secure_hello_world.py => test_security.py} (94%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 15079268bdf..347f0722df2 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -19,7 +19,7 @@ add_subdirectory(cpp/content_filter) add_subdirectory(cpp/custom_payload_pool) add_subdirectory(cpp/dds) add_subdirectory(cpp/delivery_mechanisms) -add_subdirectory(cpp/dds_security) +add_subdirectory(cpp/security) add_subdirectory(cpp/hello_world) add_subdirectory(cpp/rtps) add_subdirectory(cpp/xtypes) diff --git a/examples/cpp/dds_security/CMakeLists.txt b/examples/cpp/dds_security/CMakeLists.txt deleted file mode 100644 index e3d1763df50..00000000000 --- a/examples/cpp/dds_security/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2024 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. - -add_subdirectory(SecureHelloWorldExample) \ No newline at end of file diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp b/examples/cpp/security/Application.cpp similarity index 94% rename from examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp rename to examples/cpp/security/Application.cpp index bab5ecce5ab..698d771e034 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/Application.cpp +++ b/examples/cpp/security/Application.cpp @@ -20,19 +20,19 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "SubscriberApp.hpp" #include "PublisherApp.hpp" +#include "SubscriberApp.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { //! Factory method to create a publisher or subscriber std::shared_ptr Application::make_app( - const CLIParser::hello_world_config& config, + const CLIParser::security_config& config, const std::string& topic_name) { std::shared_ptr entity; @@ -52,7 +52,7 @@ std::shared_ptr Application::make_app( return entity; } -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/Application.hpp b/examples/cpp/security/Application.hpp similarity index 82% rename from examples/cpp/dds_security/SecureHelloWorldExample/Application.hpp rename to examples/cpp/security/Application.hpp index 9d1f01b214b..535b84dad08 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/Application.hpp +++ b/examples/cpp/security/Application.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ -#define _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__APPLICATION_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__APPLICATION_HPP #include @@ -27,7 +27,7 @@ namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { class Application { @@ -44,13 +44,13 @@ class Application //! Factory method to create applications based on configuration static std::shared_ptr make_app( - const CLIParser::hello_world_config& config, + const CLIParser::security_config& config, const std::string& topic_name); }; -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_HELLO_WORLD_APPLICATION_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__APPLICATION_HPP */ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp b/examples/cpp/security/CLIParser.hpp similarity index 96% rename from examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp rename to examples/cpp/security/CLIParser.hpp index 2e0a5e8349a..7bbe8fe0e80 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/CLIParser.hpp +++ b/examples/cpp/security/CLIParser.hpp @@ -16,15 +16,16 @@ #include #include #include + #include -#ifndef _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ -#define _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__CLI_PARSER_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__CLI_PARSER_HPP namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { using dds::Log; @@ -50,7 +51,7 @@ class CLIParser }; //! Configuration structure for the application - struct hello_world_config + struct security_config { CLIParser::EntityKind entity = CLIParser::EntityKind::UNDEFINED; entity_config pub_config; @@ -67,7 +68,7 @@ class CLIParser static void print_help( uint8_t return_code) { - std::cout << "Usage: hello_world [options]" << std::endl; + std::cout << "Usage: security [options]" << std::endl; std::cout << "" << std::endl; std::cout << "Entities:" << std::endl; std::cout << " publisher Run a publisher entity" << std::endl; @@ -93,11 +94,11 @@ class CLIParser * * @warning This method finishes the execution of the program if the input arguments are invalid */ - static hello_world_config parse_cli_options( + static security_config parse_cli_options( int argc, char* argv[]) { - hello_world_config config; + security_config config; if (argc < 2) { @@ -283,9 +284,9 @@ class CLIParser }; -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima -#endif // _FASTDDS_HELLO_WORLD_CLI_PARSER_HPP_ +#endif // FASTDDS_EXAMPLES_CPP_SECURITY__CLI_PARSER_HPP diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/CMakeLists.txt b/examples/cpp/security/CMakeLists.txt similarity index 80% rename from examples/cpp/dds_security/SecureHelloWorldExample/CMakeLists.txt rename to examples/cpp/security/CMakeLists.txt index 4730ff52599..5e7ac34ed0a 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/CMakeLists.txt +++ b/examples/cpp/security/CMakeLists.txt @@ -38,17 +38,17 @@ message(STATUS "Configuring secure hello world example...") file(GLOB SECURE_HELLO_WORLD_SOURCES_CXX "*.cxx") file(GLOB SECURE_HELLO_WORLD_SOURCES_CPP "*.cpp") -add_executable(SecureHelloWorldExample ${SECURE_HELLO_WORLD_SOURCES_CXX} ${SECURE_HELLO_WORLD_SOURCES_CPP}) -target_compile_definitions(SecureHelloWorldExample PRIVATE +add_executable(security ${SECURE_HELLO_WORLD_SOURCES_CXX} ${SECURE_HELLO_WORLD_SOURCES_CPP}) +target_compile_definitions(security PRIVATE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. $<$:SHM_TRANSPORT_BUILTIN> # Enable SHM as built-in transport ) -target_link_libraries(SecureHelloWorldExample fastdds fastcdr) -install(TARGETS SecureHelloWorldExample - RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/dds_security/SecureHelloWorldExample/${BIN_INSTALL_DIR}) +target_link_libraries(security fastdds fastcdr) +install(TARGETS security + RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/security/${BIN_INSTALL_DIR}) install(DIRECTORY ${PROJECT_SOURCE_DIR}/certs - DESTINATION examples/cpp/dds_security/SecureHelloWorldExample/${BIN_INSTALL_DIR}) + DESTINATION examples/cpp/security/${BIN_INSTALL_DIR}) # Copy the XML files over to the build directory file(GLOB_RECURSE XML_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.xml) # for each xml file detected @@ -61,10 +61,10 @@ foreach(XML_FILE_COMPLETE_PATH ${XML_FILES}) ${CMAKE_CURRENT_BINARY_DIR}/${XML_FILE}.xml # to relative build path COPYONLY) install(FILES ${XML_FILE_COMPLETE_PATH} - DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/dds_security/SecureHelloWorldExample/${BIN_INSTALL_DIR}) + DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/security/${BIN_INSTALL_DIR}) endforeach() -add_custom_command(TARGET SecureHelloWorldExample POST_BUILD +add_custom_command(TARGET security POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/certs ${PROJECT_BINARY_DIR}/certs) diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.hpp b/examples/cpp/security/HelloWorld.hpp similarity index 98% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.hpp rename to examples/cpp/security/HelloWorld.hpp index 971fea8d920..46d0d7b5814 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.hpp +++ b/examples/cpp/security/HelloWorld.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_HPP #include #include diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.idl b/examples/cpp/security/HelloWorld.idl similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorld.idl rename to examples/cpp/security/HelloWorld.idl diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.hpp b/examples/cpp/security/HelloWorldCdrAux.hpp similarity index 88% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.hpp rename to examples/cpp/security/HelloWorldCdrAux.hpp index 6feb8a9da15..1164cd5cce1 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.hpp +++ b/examples/cpp/security/HelloWorldCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP +#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP #include "HelloWorld.hpp" @@ -42,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.ipp b/examples/cpp/security/HelloWorldCdrAux.ipp similarity index 96% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.ipp rename to examples/cpp/security/HelloWorldCdrAux.ipp index 97df3fe9d9e..19316df7d3c 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldCdrAux.ipp +++ b/examples/cpp/security/HelloWorldCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP +#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP #include "HelloWorldCdrAux.hpp" @@ -122,5 +122,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx b/examples/cpp/security/HelloWorldPubSubTypes.cxx similarity index 99% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx rename to examples/cpp/security/HelloWorldPubSubTypes.cxx index 41da39407fa..38393dbf8c9 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.cxx +++ b/examples/cpp/security/HelloWorldPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include "HelloWorldPubSubTypes.h" +#include "HelloWorldPubSubTypes.hpp" #include #include diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h b/examples/cpp/security/HelloWorldPubSubTypes.hpp similarity index 89% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h rename to examples/cpp/security/HelloWorldPubSubTypes.hpp index 3db9ca96458..556d4c05ecf 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldPubSubTypes.h +++ b/examples/cpp/security/HelloWorldPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file HelloWorldPubSubTypes.h + * @file HelloWorldPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "HelloWorld.hpp" @@ -106,7 +106,7 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,10 +124,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx b/examples/cpp/security/HelloWorldTypeObjectSupport.cxx similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.cxx rename to examples/cpp/security/HelloWorldTypeObjectSupport.cxx diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp b/examples/cpp/security/HelloWorldTypeObjectSupport.hpp similarity index 90% rename from examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp rename to examples/cpp/security/HelloWorldTypeObjectSupport.hpp index 2eba797b07f..ec922163d11 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/HelloWorldTypeObjectSupport.hpp +++ b/examples/cpp/security/HelloWorldTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP #include @@ -53,4 +53,4 @@ eProsima_user_DllExport void register_HelloWorld_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp b/examples/cpp/security/PublisherApp.cpp similarity index 98% rename from examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp rename to examples/cpp/security/PublisherApp.cpp index 77eaa516f73..d918d162559 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.cpp +++ b/examples/cpp/security/PublisherApp.cpp @@ -17,8 +17,6 @@ * */ -#include "PublisherApp.hpp" - #include #include @@ -28,12 +26,15 @@ #include #include +#include "PublisherApp.hpp" +#include "HelloWorldPubSubTypes.hpp" + using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { PublisherApp::PublisherApp( const CLIParser::entity_config& config, @@ -173,7 +174,7 @@ void PublisherApp::stop() cv_.notify_one(); } -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp b/examples/cpp/security/PublisherApp.hpp similarity index 87% rename from examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp rename to examples/cpp/security/PublisherApp.hpp index ef904f7ad06..0ff5efdeedd 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/PublisherApp.hpp +++ b/examples/cpp/security/PublisherApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ -#define _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_PUBLISHER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_PUBLISHER_APP_HPP #include @@ -28,14 +28,14 @@ #include "Application.hpp" #include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.h" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { class PublisherApp : public Application, public DataWriterListener { @@ -92,9 +92,9 @@ class PublisherApp : public Application, public DataWriterListener }; -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_HELLO_WORLD_PUBLISHER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_PUBLISHER_APP_HPP */ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/README.md b/examples/cpp/security/README.md similarity index 69% rename from examples/cpp/dds_security/SecureHelloWorldExample/README.md rename to examples/cpp/security/README.md index 02e90eccacd..8ea9dbdd555 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/README.md +++ b/examples/cpp/security/README.md @@ -4,7 +4,7 @@ The *eProsima Fast DDS hello world* example is a simple application intended to This example is part of the suite of examples designed by eProsima that aims to illustrate the features and possible configurations of DDS deployments through *eProsima Fast DDS*. -In this case, the *hello world* example describes the simplest deployment of a Fast DDS publisher and subscriber. +In this case, the *secure hello world* example describes the simplest deployment of a Fast DDS publisher and subscriber using the DDS Security specification. * [Description of the example](#description-of-the-example) * [Run the example](#run-the-example) @@ -18,51 +18,43 @@ In both cases, the three DDS entities (domain participant, publisher/subscriber If the environment does not specify the expected configuration, they take the default configuration per entity. For further information regarding the configuration environment, please refer to the *[XML profile playground](#xml-profile-playground)* section. -This particular example includes two different subscription paradigms; i.e. listening callbacks and wait-sets: - -* The listening callback mechanism consists on declaring a listener class and attaching it to the data reader. - When the data reader is triggered by an event, it runs the listener's method associated to that event, as a callback. - For simplicity, in this example, the subscriber class inherits from the listener class, overriding the corresponding callback. - -* The wait-set is a mechanism where a dedicated thread waits until a status condition occurs. - In that moment, that status condition triggering event would be evaluated to determine witch actions should be taken against it. - -For this example, both listening callback and wait-set implementation would run similar code and generate equivalent output for both triggering events: subscription matching and new data available. +This particular example includes only the listening callback mechanism, which consists on declaring a listener class and attaching it to the data reader. When the data reader is triggered by an event, it runs the listener's method associated to that event, as a callback. +For simplicity, in this example, the subscriber class inherits from the listener class, overriding the corresponding callback. ## Run the example To launch this example, two different terminals are required. One of them will run the publisher example application, and the other will run the subscriber application. -### Hello world publisher +### Secure Hello world publisher * Ubuntu ( / MacOS ) ```shell - user@machine:example_path$ ./hello_world publisher + user@machine:example_path$ ./security publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` * Windows ```powershell - example_path> hello_world.exe publisher + example_path> security.exe publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -### Hello world subscriber +### Secure Hello world subscriber * Ubuntu ( / MacOS ) ```shell - user@machine:example_path$ ./hello_world subscriber + user@machine:example_path$ ./security subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` * Windows ```powershell - example_path> hello_world.exe subscriber + example_path> security.exe subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` @@ -72,7 +64,7 @@ All the example available flags can be queried running the executable with the ` Regardless of which application is run first, since the publisher will not start sending data until a subscriber is discovered, the expected output both for publishers and subscribers is a first displayed message acknowledging the match, followed by the amount of samples sent or received until Ctrl+C is pressed. -### Hello world publisher +### Secure Hello world publisher ```shell Publisher running. Please press Ctrl+C to stop the Publisher at any time. @@ -83,7 +75,7 @@ Message: 'Hello world' with index: '3' SENT ... ``` -### Hello world subscriber +### Secure Hello world subscriber ```shell Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. @@ -106,24 +98,6 @@ Message: 'Hello world' with index: '11' SENT Publisher unmatched. ``` -## Wait-set subscriber - -As described in the *[Description of the example](#description-of-the-example)* section, the *hello world* example has two listening implementations. Launching the subscriber example with the flag ``-w`` or ``--waitset`` will use the wait-set approach instead of the listening callback. - -* Ubuntu ( / MacOS ) - - ```shell - user@machine:example_path$ ./hello_world subscriber --waitset - ``` - -* Windows - - ```powershell - example_path> hello_world.exe subscriber --waitset - ``` - -The expected output is exactly the same as the described in the *[previous](#expected-output)* section. - ## XML profile playground The *eProsima Fast DDS* entities can be configured through an XML profile from the environment. @@ -147,5 +121,6 @@ The example provides with an XML profiles files with certain QoS: - Transient local durability: enable late-join subscriber applications to receive previous samples. - Keep-last history with high depth: ensure certain amount of previous samples for late-joiners. +It also includes by default the builtin plugins required to provide secure communications. Applying different configurations to the entities will change to a greater or lesser extent how the application behaves in relation to sample management. Even when these settings affect the behavior of the sample management, the applications' output will be the similar. diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.cpp b/examples/cpp/security/SubscriberApp.cpp similarity index 98% rename from examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.cpp rename to examples/cpp/security/SubscriberApp.cpp index 0f1912d18f1..0152942c982 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.cpp +++ b/examples/cpp/security/SubscriberApp.cpp @@ -30,16 +30,16 @@ #include #include -#include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.h" #include "Application.hpp" +#include "CLIParser.hpp" +#include "HelloWorldPubSubTypes.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { SubscriberApp::SubscriberApp( const CLIParser::entity_config& config, @@ -164,7 +164,7 @@ void SubscriberApp::stop() terminate_cv_.notify_all(); } -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.hpp b/examples/cpp/security/SubscriberApp.hpp similarity index 88% rename from examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.hpp rename to examples/cpp/security/SubscriberApp.hpp index 924889e96ab..4e3751e8cfb 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/SubscriberApp.hpp +++ b/examples/cpp/security/SubscriberApp.hpp @@ -17,8 +17,8 @@ * */ -#ifndef _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ -#define _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ +#ifndef FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_SUBSCRIBER_APP_HPP +#define FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_SUBSCRIBER_APP_HPP #include @@ -26,16 +26,16 @@ #include #include -#include "CLIParser.hpp" -#include "HelloWorldPubSubTypes.h" #include "Application.hpp" +#include "CLIParser.hpp" +#include "HelloWorld.hpp" using namespace eprosima::fastdds::dds; namespace eprosima { namespace fastdds { namespace examples { -namespace hello_world { +namespace security { class SubscriberApp : public Application, public DataReaderListener { @@ -90,9 +90,9 @@ class SubscriberApp : public Application, public DataReaderListener std::condition_variable terminate_cv_; }; -} // namespace hello_world +} // namespace security } // namespace examples } // namespace fastdds } // namespace eprosima -#endif /* _FASTDDS_HELLO_WORLD_LISTENER_SUBSCRIBER_APP_HPP_ */ +#endif /* FASTDDS_EXAMPLES_CPP_SECURITY__HELLO_WORLD_SUBSCRIBER_APP_HPP */ diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/governance.smime b/examples/cpp/security/certs/governance.smime similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/governance.smime rename to examples/cpp/security/certs/governance.smime diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/governance_dds_sec.xml b/examples/cpp/security/certs/governance_dds_sec.xml similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/governance_dds_sec.xml rename to examples/cpp/security/certs/governance_dds_sec.xml diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/maincacert.pem b/examples/cpp/security/certs/maincacert.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/maincacert.pem rename to examples/cpp/security/certs/maincacert.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/maincakey.pem b/examples/cpp/security/certs/maincakey.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/maincakey.pem rename to examples/cpp/security/certs/maincakey.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubcert.pem b/examples/cpp/security/certs/mainpubcert.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubcert.pem rename to examples/cpp/security/certs/mainpubcert.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubkey.pem b/examples/cpp/security/certs/mainpubkey.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/mainpubkey.pem rename to examples/cpp/security/certs/mainpubkey.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubcert.pem b/examples/cpp/security/certs/mainsubcert.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubcert.pem rename to examples/cpp/security/certs/mainsubcert.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubkey.pem b/examples/cpp/security/certs/mainsubkey.pem similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/mainsubkey.pem rename to examples/cpp/security/certs/mainsubkey.pem diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions.smime b/examples/cpp/security/certs/permissions.smime similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions.smime rename to examples/cpp/security/certs/permissions.smime diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions_dds_sec.xml b/examples/cpp/security/certs/permissions_dds_sec.xml similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/certs/permissions_dds_sec.xml rename to examples/cpp/security/certs/permissions_dds_sec.xml diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml b/examples/cpp/security/hello_world_profile.xml similarity index 100% rename from examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml rename to examples/cpp/security/hello_world_profile.xml diff --git a/examples/cpp/dds_security/SecureHelloWorldExample/main.cpp b/examples/cpp/security/main.cpp similarity index 93% rename from examples/cpp/dds_security/SecureHelloWorldExample/main.cpp rename to examples/cpp/security/main.cpp index edfb6ff468e..702a77ccf3f 100644 --- a/examples/cpp/dds_security/SecureHelloWorldExample/main.cpp +++ b/examples/cpp/security/main.cpp @@ -29,7 +29,7 @@ using eprosima::fastdds::dds::Log; -using namespace eprosima::fastdds::examples::hello_world; +using namespace eprosima::fastdds::examples::security; std::function stop_app_handler; void signal_handler( @@ -43,8 +43,8 @@ int main( char** argv) { auto ret = EXIT_SUCCESS; - const std::string topic_name = "hello_world_topic"; - CLIParser::hello_world_config config = CLIParser::parse_cli_options(argc, argv); + const std::string topic_name = "security_topic"; + CLIParser::security_config config = CLIParser::parse_cli_options(argc, argv); uint16_t samples = 0; switch (config.entity) { diff --git a/test/examples/SecureHelloWorldExample.compose.yml b/test/examples/security.compose.yml similarity index 77% rename from test/examples/SecureHelloWorldExample.compose.yml rename to test/examples/security.compose.yml index 0c858578d08..76c97afb25d 100644 --- a/test/examples/SecureHelloWorldExample.compose.yml +++ b/test/examples/security.compose.yml @@ -23,7 +23,7 @@ services: environment: # TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@ - EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/dds_security/SecureHelloWorldExample - FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/dds_security/SecureHelloWorldExample/hello_world_profile.xml - command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ subscriber --samples 10 & $${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ publisher --samples 10" + EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/security + FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/security/hello_world_profile.xml + command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/security@FILE_EXTENSION@ subscriber --samples 10 & $${EXAMPLE_DIR}/security@FILE_EXTENSION@ publisher --samples 10" diff --git a/test/examples/test_secure_hello_world.py b/test/examples/test_security.py similarity index 94% rename from test/examples/test_secure_hello_world.py rename to test/examples/test_security.py index 73fbbaa9568..63e4b93cd87 100644 --- a/test/examples/test_secure_hello_world.py +++ b/test/examples/test_security.py @@ -14,13 +14,13 @@ import subprocess -def test_hello_world(): +def test_security(): """.""" ret = False out = '' try: out = subprocess.check_output( - '@DOCKER_EXECUTABLE@ compose -f hello_world.compose.yml up', + '@DOCKER_EXECUTABLE@ compose -f security.compose.yml up', stderr=subprocess.STDOUT, shell=True, timeout=30 diff --git a/versions.md b/versions.md index db3910de34c..75595a8e824 100644 --- a/versions.md +++ b/versions.md @@ -44,7 +44,7 @@ Forthcoming * Calling `DataReader::return_loan` returns `ReturnCode_t::RETCODE_OK` both for empty sequences and for sequences that were not loaned. * Refactor examples: * Hello world example with wait-sets and environment XML profiles. - * Secured hello world example with wait-sets and environment XML profiles. + * Secured hello world example with environment XML profiles. * Configuration example that condenses multiple QoS examples. Multiple configurations allowed through argument parsing. * Custom payload pool example that uses a user-defined payload pool instead of the default * X-Types example with dynamic type discovery and Hello world example compatibility.