From c028b45bfb3756bb56d4f29315aa5be491910435 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Thu, 25 Apr 2024 19:44:56 -0500 Subject: [PATCH 01/60] Fix Missing ACE with OPENDDS_ACE_TAO_SRC The ACE and TAO library targets from MPC might be called `ACE-target` and `TAO-target` depending on if they're in directories of the same name. It should be trivial to predict this, but the path logic for this in MPC seems buggy and might not prepend `-target` when `OPENDDS_ACE_TAO_SRC` is outside of the build directory, so we're just going to check both for all targets. --- cmake/ace_group.cmake | 6 ------ cmake/build_ace_tao.cmake | 4 ---- cmake/get_ace_tao.cmake | 3 --- cmake/import_common.cmake | 17 +++++++++++++---- cmake/tao_group.cmake | 6 ------ docs/news.d/cmake-ace-tao-src.rst | 7 +++++++ 6 files changed, 20 insertions(+), 23 deletions(-) create mode 100644 docs/news.d/cmake-ace-tao-src.rst diff --git a/cmake/ace_group.cmake b/cmake/ace_group.cmake index 6105b1b9733..77f0c55a65d 100644 --- a/cmake/ace_group.cmake +++ b/cmake/ace_group.cmake @@ -12,13 +12,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/import_common.cmake") _opendds_group(ACE DEFAULT_REQUIRED ACE::ACE) -if(_OPENDDS_ACE_MPC_NAME_IS_ACE_TARGET) - set(_mpc_name ACE-target) -else() - set(_mpc_name ACE) -endif() _opendds_group_lib(ACE - MPC_NAME "${_mpc_name}" DEPENDS Threads::Threads ) _opendds_group_lib(XML_Utils diff --git a/cmake/build_ace_tao.cmake b/cmake/build_ace_tao.cmake index c011484d426..276dfe0cc6a 100644 --- a/cmake/build_ace_tao.cmake +++ b/cmake/build_ace_tao.cmake @@ -1,9 +1,5 @@ include(ExternalProject) -if(_OPENDDS_MPC_TYPE STREQUAL gnuace) - set(_OPENDDS_TAO_MPC_NAME_IS_TAO_TARGET TRUE CACHE INTERNAL "") -endif() - if(OPENDDS_JUST_BUILD_HOST_TOOLS) set(ws "${OPENDDS_BUILD_DIR}/host-tools.mwc") file(WRITE "${ws}" diff --git a/cmake/get_ace_tao.cmake b/cmake/get_ace_tao.cmake index fb13d58d26d..54b3b9b187e 100644 --- a/cmake/get_ace_tao.cmake +++ b/cmake/get_ace_tao.cmake @@ -133,9 +133,6 @@ if(EXISTS "${OPENDDS_ACE_TAO_SRC}/ace/Version.h") set(OPENDDS_ACE "${OPENDDS_ACE_TAO_SRC}" CACHE INTERNAL "") elseif(EXISTS "${OPENDDS_ACE_TAO_SRC}/ACE/ace/Version.h") set(OPENDDS_ACE "${OPENDDS_ACE_TAO_SRC}/ACE" CACHE INTERNAL "") - if(_OPENDDS_MPC_TYPE STREQUAL gnuace) - set(_OPENDDS_ACE_MPC_NAME_IS_ACE_TARGET TRUE CACHE INTERNAL "") - endif() else() message(FATAL_ERROR "Can't find ace/Version.h in ${OPENDDS_ACE}") endif() diff --git a/cmake/import_common.cmake b/cmake/import_common.cmake index 41588915b1c..453bc880399 100644 --- a/cmake/import_common.cmake +++ b/cmake/import_common.cmake @@ -104,11 +104,20 @@ endfunction() function(_opendds_find_in_mpc_projects found_var path_var mpc_projects mpc_name config) string(JSON mpc_project ERROR_VARIABLE err GET "${mpc_projects}" "${mpc_name}") if(NOT mpc_project) - set(${found_var} FALSE CACHE INTERNAL "" FORCE) - if(debug) - message(STATUS "lib ${target} (${mpc_name}) not in MPC projects") + # The ACE and TAO libraries targets from MPC might be called ACE-target and + # TAO-target depending on if they're in directories of the same name. It + # should be trivial to predict this, but the path logic for this in MPC + # seems buggy and might not prepend -target when OPENDDS_ACE_TAO_SRC is + # outside of the build directory, so we're just going to check both for all + # targets. + string(JSON mpc_project ERROR_VARIABLE err GET "${mpc_projects}" "${mpc_name}-target") + if(NOT mpc_project) + set(${found_var} FALSE CACHE INTERNAL "" FORCE) + if(debug) + message(STATUS "lib ${target} (${mpc_name} or ${mpc_name}-target) not in MPC projects") + endif() + return() endif() - return() endif() string(JSON configs ERROR_VARIABLE err GET "${mpc_project}" "configs") if(config AND configs) diff --git a/cmake/tao_group.cmake b/cmake/tao_group.cmake index 7260988bd30..4d9b0494919 100644 --- a/cmake/tao_group.cmake +++ b/cmake/tao_group.cmake @@ -12,13 +12,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/import_common.cmake") _opendds_group(TAO DEFAULT_REQUIRED TAO::TAO TAO::tao_idl) -if(_OPENDDS_TAO_MPC_NAME_IS_TAO_TARGET) - set(_mpc_name TAO-target) -else() - set(_mpc_name TAO) -endif() _opendds_group_lib(TAO - MPC_NAME "${_mpc_name}" DEPENDS ACE::ACE ) _opendds_group_lib(IDL_FE diff --git a/docs/news.d/cmake-ace-tao-src.rst b/docs/news.d/cmake-ace-tao-src.rst new file mode 100644 index 00000000000..6ac106d57e9 --- /dev/null +++ b/docs/news.d/cmake-ace-tao-src.rst @@ -0,0 +1,7 @@ +.. news-prs: 4604 + +.. news-start-section: Platform Support and Dependencies +.. news-start-section: Building with CMake +- Fixed CMake saying it's missing the ACE library when using :cmake:var:`OPENDDS_ACE_TAO_SRC` with an ACE/TAO outside of the build directory. +.. news-end-section +.. news-end-section From 69481c0a2e79555aea5be22c1095939982610c9f Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Thu, 25 Apr 2024 11:09:10 -0500 Subject: [PATCH 02/60] rtps_udp sends heartbeats when sending fragments Problem ------- Suppose a writer has an agressive heartbeat period and then writes a sample that is highly fragmented. It is possible (probable) that the heartbeat timer will go off before all fragments have been sent. The reader can then nack fragments that haven't even been sent. The writer would then resend the requested fragments. Solution -------- Before sending a heartbeat, check that the user is not in the middle of a send. The solution does not make a change for resends due to reliability and/or durability. The reason for this is that sending heartbeats and nack responses are mutually exclusive based on locking. --- .../framework/TransportSendStrategy.cpp | 4 ++- .../framework/TransportSendStrategy.h | 29 ++++++++++++++++++- .../transport/rtps_udp/RtpsUdpDataLink.cpp | 11 +++++-- docs/news.d/heartbeat-fragmentation.rst | 5 ++++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 docs/news.d/heartbeat-fragmentation.rst diff --git a/dds/DCPS/transport/framework/TransportSendStrategy.cpp b/dds/DCPS/transport/framework/TransportSendStrategy.cpp index f154d5fb8e4..881271ed065 100644 --- a/dds/DCPS/transport/framework/TransportSendStrategy.cpp +++ b/dds/DCPS/transport/framework/TransportSendStrategy.cpp @@ -81,7 +81,8 @@ TransportSendStrategy::TransportSendStrategy( transport_(transport), graceful_disconnecting_(false), link_released_(true), - send_buffer_(0) + send_buffer_(0), + is_sending_(GUID_UNKNOWN) { DBG_ENTRY_LVL("TransportSendStrategy","TransportSendStrategy",6); @@ -1088,6 +1089,7 @@ TransportSendStrategy::send(TransportQueueElement* element, bool relink) // Loop for sending 'element', in fragments if needed bool first_pkt = true; // enter the loop 1st time through unconditionally + BeginEndSend bes(*this, element->publication_id()); for (TransportQueueElement* next_fragment = 0; (first_pkt || next_fragment) && (mode_ == MODE_DIRECT || mode_ == MODE_TERMINATED);) { diff --git a/dds/DCPS/transport/framework/TransportSendStrategy.h b/dds/DCPS/transport/framework/TransportSendStrategy.h index 477a1c2aac5..469fc1f7dd1 100644 --- a/dds/DCPS/transport/framework/TransportSendStrategy.h +++ b/dds/DCPS/transport/framework/TransportSendStrategy.h @@ -326,7 +326,14 @@ class OpenDDS_Dcps_Export TransportSendStrategy /// Access the current sending mode. SendMode mode() const; -protected: + + bool is_sending(const GUID_t& guid) const + { + GuardType g(is_sending_lock_); + return is_sending_ == guid; + } + + protected: /// Implement framework chain visitations to remove a sample. virtual RemoveResult do_remove_sample(const GUID_t& pub_id, const TransportQueueElement::MatchCriteria& criteria, bool remove_all = false); @@ -438,6 +445,26 @@ class OpenDDS_Dcps_Export TransportSendStrategy /// Current transport packet header. TransportHeader header_; + struct BeginEndSend { + BeginEndSend(TransportSendStrategy& tss, + const GUID_t& guid) + : tss_(tss) + { + GuardType g(tss_.is_sending_lock_); + tss_.is_sending_ = guid; + } + + ~BeginEndSend() + { + GuardType g(tss_.is_sending_lock_); + tss_.is_sending_ = GUID_UNKNOWN; + } + + TransportSendStrategy& tss_; + }; + mutable LockType is_sending_lock_; + GUID_t is_sending_; + protected: ThreadSynch* synch() const; diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp b/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp index cd3d90cfc20..e7ed59c9817 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp @@ -1460,11 +1460,18 @@ RtpsUdpDataLink::RtpsWriter::send_heartbeats(const MonotonicTimePoint& /*now*/) } MetaSubmessageVec meta_submessages; - gather_heartbeats_i(meta_submessages); + const bool not_sending = !link->send_strategy()->is_sending(id_); + if (not_sending) { + gather_heartbeats_i(meta_submessages); + } if (!preassociation_readers_.empty() || !lagging_readers_.empty()) { heartbeat_->schedule(fallback_.get()); - fallback_.advance(); + if (not_sending) { + fallback_.advance(); + } else { + fallback_.set(initial_fallback_); + } } else { fallback_.set(initial_fallback_); } diff --git a/docs/news.d/heartbeat-fragmentation.rst b/docs/news.d/heartbeat-fragmentation.rst new file mode 100644 index 00000000000..417e63f691d --- /dev/null +++ b/docs/news.d/heartbeat-fragmentation.rst @@ -0,0 +1,5 @@ +.. news-prs: 4603 + +.. news-start-section: Fixes +- Do not send heartbeats during a fragmented send in ``rtps_udp``. +.. news-end-section From 54796ebccc885ab5e0b28c70a351aa1d4e23ca45 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Tue, 23 Apr 2024 16:19:45 -0500 Subject: [PATCH 03/60] DevGuide doesn't document `send_buffer_size` and `rcv_buffer_size` Problem ------- The DevGuide doesn't document `send_buffer_size` and `rcv_buffer_size` for the `rtps_udp` transport and RTPS Discovery. Solution -------- Add documentation. --- docs/devguide/run_time_configuration.rst | 18 ++++++++++++++++-- docs/news.d/buffer-doc.rst | 5 +++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 docs/news.d/buffer-doc.rst diff --git a/docs/devguide/run_time_configuration.rst b/docs/devguide/run_time_configuration.rst index cd8d1a80bcc..707f333dabc 100644 --- a/docs/devguide/run_time_configuration.rst +++ b/docs/devguide/run_time_configuration.rst @@ -1366,15 +1366,19 @@ Those properties, along with options specific to OpenDDS's RTPS discovery implem Sets the duration that a passive endpoint will wait for a connection. .. prop:: SendBufferSize= - :default: ``0`` (system default value is used) + :default: ``0`` (system default value is used, ``65466`` typical) Socket send buffer size for both SPDP and SEDP. + See :prop:`[transport@rtps_udp]send_buffer_size`. + .. prop:: RecvBufferSize= - :default: ``0`` (system default value is used) + :default: ``0`` (system default value is used, ``65466`` typical) Socket receive buffer size for both SPDP and SEDP. + See :prop:`[transport@rtps_udp]rcv_buffer_size`. + .. prop:: MaxParticipantsInAuthentication= :default: ``0`` (no limit) @@ -2666,6 +2670,16 @@ Some implementation notes related to using the ``rtps_udp`` transport protocol a The maximum message size. + .. prop:: send_buffer_size= + :default: ``0`` (system default value is used, ``65466`` typical) + + Socket send buffer size for sending RTPS messages. + + .. prop:: rcv_buffer_size= + :default: ``0`` (system default value is used, ``65466`` typical) + + Socket receive buffer size for receiving RTPS messages. + .. prop:: ttl= :default: ``1`` (all data is restricted to the local network) diff --git a/docs/news.d/buffer-doc.rst b/docs/news.d/buffer-doc.rst new file mode 100644 index 00000000000..6648574a93e --- /dev/null +++ b/docs/news.d/buffer-doc.rst @@ -0,0 +1,5 @@ +.. news-prs: 4602 + +.. news-start-section: Documentation +- Added :cfg:prop:`[transport@rtps_udp]send_buffer_size` and :cfg:prop:`[transport@rtps_udp]rcv_buffer_size`. +.. news-end-section From 3aa1b0648a38879d9173d850a3b1f9af15235e26 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Fri, 26 Apr 2024 14:13:34 -0500 Subject: [PATCH 04/60] ValueDispatcher assumes pointer is KeyOnly Problem ------- The ValueDispatcher code assumes the value indicated by the void* is a KeyOnly*. This is incorrect as the void* is a T*. Solution -------- Assume the void* is a T* and construct the KeyOnly. --- dds/DCPS/ValueDispatcher.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dds/DCPS/ValueDispatcher.h b/dds/DCPS/ValueDispatcher.h index ca723287be2..95f9d64eeae 100644 --- a/dds/DCPS/ValueDispatcher.h +++ b/dds/DCPS/ValueDispatcher.h @@ -20,6 +20,7 @@ namespace DCPS { struct OpenDDS_Dcps_Export ValueDispatcher { virtual ~ValueDispatcher() {} + // The void* is assumed to point to a value of type T (see template below). virtual void* new_value() const = 0; virtual void delete_value(void* data) const = 0; @@ -55,7 +56,7 @@ struct ValueDispatcher_T : public virtual ValueDispatcher { case Sample::Full: return vread(value_reader, *static_cast(data)); case Sample::KeyOnly: - return vread(value_reader, *static_cast*>(data)); + return vread(value_reader, KeyOnly(*static_cast(data))); default: if (log_level >= LogLevel::Notice) { ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: ValueDispatcher_T<%C>::read:" @@ -71,7 +72,7 @@ struct ValueDispatcher_T : public virtual ValueDispatcher { case Sample::Full: return vwrite(value_writer, *static_cast(data)); case Sample::KeyOnly: - return vwrite(value_writer, *static_cast*>(data)); + return vwrite(value_writer, KeyOnly(*static_cast(data))); default: if (log_level >= LogLevel::Notice) { ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: ValueDispatcher_T<%C>::write:" From 2a4535fff2b8ab8bceaab389f674b41fbafd7080 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 30 Apr 2024 11:38:29 -0500 Subject: [PATCH 05/60] Improvements to configure Script - Fix uninitialized value warning - Tweak configure script output: - Bring `--help` mostly back to 80-ish columns. - Try to make new options a little more clear. - Use "cross-compile" instead of "cross compile" and "GoogleTest" instead of "Google Test", "CMake" instead of "cmake", etc. - `--mpc:OPT` should accept `--mpc:*=OPT=VALUE`. - Try to make how features are handled a little bit more sane by putting them all in `@features`. It's still not great and I know I'm at least partially to blame. - Try to put all features not in `default.features` in `opendds_mwc.pl`. - Add `OpenDDSCOnfig.h.bak*` to git ignore. --- configure | 159 +++++++++++++++++++++++++++---------------------- dds/.gitignore | 1 + 2 files changed, 90 insertions(+), 70 deletions(-) diff --git a/configure b/configure index fa7ce95af34..89e49b1d3f1 100755 --- a/configure +++ b/configure @@ -166,13 +166,15 @@ sub targetUsage { my $argPadding = 29; my $argIndent = "\n " . (' ' x $argPadding); -my @specs = # Array of array-refs, each inner array is an option group which - # has the format [Group Description, Opt1 Spec, Opt1 Description, - # Opt2 Spec, Opt2 Description, ...] +# Array of array-refs, each inner array is an option group which +# has the format [Group Description, Opt1 Spec, Opt1 Description, +# Opt2 Spec, Opt2 Description, ...] # OPT is a custom token marking a string option that # defaults to $opts{'OPT'} = '' and can be overridden by opts by passing # --no-OPT or --OPT with a value. # OPT hides the option from --help +# OPT hides the option from GetOpt::Long +my @specs = ( ['Options controlling the configure script:', 'help|h|?', 'Show this help and exit', @@ -189,7 +191,7 @@ my @specs = # Array of array-refs, each inner array is an option group which 'target=s', 'Cross-compile target (none): see --target-help', 'target-arch=s', 'Architecture for target (none): see --target-help', 'target-compiler=s', 'Compiler for target (if req\'d): see --target-help', - 'host-tools=s', 'DDS_ROOT of host tools for cross compile (build)', + 'host-tools=s', 'DDS_ROOT of host tools for cross-compile (build)', 'host-ace=s', 'Define host ACE_ROOT (uses relative path from' . $argIndent . 'target DDS_ROOT to target ACE_ROOT)', 'host-tools-only!', 'Just build the host tools (no)', @@ -210,9 +212,11 @@ my @specs = # Array of array-refs, each inner array is an option group which $argIndent . ' asan: Address Sanitizer, gcc/clang only' . $argIndent . ' tsan: Thread Sanitizer, gcc/clang only' . $argIndent . ' ubsan: Undefined Behavior Sanitizer, clang only', - 'compile-warnings=s', 'Enable additional compiler warnings (empty)' . - $argIndent . 'If set to WARNING, enable additional warnings' . - $argIndent . 'If set to ERROR, enable additional warnings and treated them as errors', + 'compile-warnings=s', 'Enable additional compiler warnings' . + $argIndent . '(default compiler warnings)' . + $argIndent . ' WARNING: enable additional warnings' . + $argIndent . ' ERROR: enable additional warnings that are' . + $argIndent . ' treated as errors', ], ['Required dependencies for OpenDDS:', 'ace=s', 'ACE (use ACE_ROOT, ACE_wrappers, or download)', @@ -229,13 +233,18 @@ my @specs = # Array of array-refs, each inner array is an option group which 'configh=s@', 'Extra text for config.h', 'macros=s@', 'Extra text for platform_macros.GNU', 'features=s@', 'Extra text for default.features', - 'mpcopts=s@', 'Extra command-line args for MPC' . + 'mpcopts=s@', 'Extra command-line options for MPC' . $argIndent . 'This option can be given multiple times' . - $argIndent . 'Example: --mpcopts=-value_template --mpcopts=build_flags+="-Wall -Werror"', - 'mpc:ARG VALUE', 'Extra command-line args for MPC' . - $argIndent . 'This option can be given multiple times' . - $argIndent . 'For example, --mpc:value_template build_flags+="-Wall -Werror" turns into' . - $argIndent . 'the following options for MPC: -value_template build_flags+="-Wall -Werror"', + $argIndent . 'For example:' . + $argIndent . ' --mpcopts=-value_template --mpcopts=build_flags+="-Wall -Werror"' . + $argIndent . 'turns into the following arguments for MPC:' . + $argIndent . ' -value_template build_flags+="-Wall -Werror"', + 'mpc:OPT=VALUE', 'Extra command-line options for MPC' . + $argIndent . 'For example:' . + $argIndent . ' --mpc:value_template build_flags+="-Wall -Werror"' . + $argIndent . 'turns into the following arguments for MPC:' . + $argIndent . ' -value_template build_flags+="-Wall -Werror"' . + $argIndent . 'This option can be given multiple times', 'boottime!', 'Use CLOCK_BOOTTIME for timers (no)', ], ['Optional dependencies for OpenDDS (disabled by default unless noted otherwise):', @@ -262,14 +271,13 @@ my @specs = # Array of array-refs, each inner array is an option group which $argIndent . 'use git submodle, RAPIDJSON_ROOT, or system pkg)', 'qt:s', 'Qt5 (use QTDIR or system pkg)', 'qt-include:s', 'Qt include dir (use QT5_INCDIR, QTDIR/include,' . - $argIndent . 'or sysytem package)', + $argIndent . 'or system package)', 'xerces3:s', 'Xerces-C++ 3 for QoS XML handling, DDS Security', 'openssl:s', 'OpenSSL for DDS Security', - 'cmake:s', 'Path to cmake binary for compiling Google Test' . - $argIndent . 'Framework. (Check Path and Check Normal' . - $argIndent . 'Locations)', - 'gtest:s', 'Path to Google Test Framework, required for' . - $argIndent . 'tests (uses GTEST_ROOT).' . + 'cmake:s', 'Path to CMake for compiling GoogleTest' . + $argIndent . '(Check PATH and normal locations)', + 'gtest:s', 'Path to GoogleTest, required for tests' . + $argIndent . '(uses GTEST_ROOT)' . $argIndent . 'If not built, will try to build using CMake.', ], ['Optional OpenDDS features:', @@ -387,17 +395,21 @@ sub parseArgs { while (@ARGV != 0) { my $arg = shift(@ARGV); - if ($arg =~ /^--mpc:(.*)$/) { + if ($arg =~ /^--mpc:([^=]*)(?:=(.*))?$/) { my $key = $1; - if (@ARGV != 0) { - my $value = shift(@ARGV); + my $value = $2; + if (defined($value)) { + push(@{$opts->{'mpcopts'}}, '-' . $key, $value); + } + elsif (@ARGV != 0) { + $value = shift(@ARGV); push(@{$opts->{'mpcopts'}}, '-' . $key, $value); } else { - print "ERROR: $arg requires a value\n"; + print STDERR "ERROR: $arg requires a value\n"; usage(1); } } else { - print "ERROR: unknown argument $arg\n"; + print STDERR "ERROR: unknown argument $arg\n"; usage(1); } } @@ -436,6 +448,11 @@ if (exists($opts{'std'})) { # Accept any of --std=17, --std=stdcpp17, --std=c++17, etc. $cxx_std =~ s/^(std)?(cpp|c\+\+)//; } +my @mpcopts; +push(@mpcopts, @{$opts{'mpcopts'}}) if exists($opts{'mpcopts'}); +my @features; +push(@features, @{$opts{'features'}}) if exists($opts{'features'}); +push(@features, 'java=1') if $opts{'java'}; $opts{'host'} = perlOS_to_host() unless $opts{'host'}; @@ -772,15 +789,15 @@ EOF $opts{'compiler_target_architecture'} = $arch; if ($ver >= 19) { - push(@{$opts{'features'}}, 'no_cxx11=0'); + push(@features, 'no_cxx11=0'); print "Visual C++ has >= C++11 support\n" if $opts{'verbose'}; } if ($opts{'std'}) { my $std = "stdcpp$cxx_std"; - push(@{$opts{'mpcopts'}}, '-value_template', "LanguageStandard=$std"); + push(@mpcopts, '-value_template', "LanguageStandard=$std"); print "Setting Visual C++ LanguageStandard to $std\n" if $opts{'verbose'}; if ($opts{'std'} eq 'latest' || $cxx_std >= 17) { - push(@{$opts{'features'}}, 'no_cxx17=0'); + push(@features, 'no_cxx17=0'); print "Visual C++ has >= C++17 support\n" if $opts{'verbose'}; } } @@ -823,13 +840,14 @@ EOF } if ($opts{'std'} && $opts{'std'} =~ /(0x|11|1y|14|1z|17|2a|20|2b|23)$/) { - push(@{$opts{'features'}}, 'no_cxx11=0'); + push(@features, 'no_cxx11=0'); print "Compiler has >= C++11 support\n" if $opts{'verbose'}; } } } -if ($opts{'compile-warnings'} eq 'WARNING' or $opts{'compile-warnings'} eq 'ERROR') { +my $compile_warnings = $opts{'compile-warnings'} // ''; +if ($compile_warnings eq 'WARNING' or $compile_warnings eq 'ERROR') { my ($section_names, $sections) = read_ini_file("$FindBin::RealBin/build.ini"); my %compiler_map = ( 'g++' => 'GNU', 'clang' => 'Clang', 'cl' => 'MSVC', 'cl.exe' => 'MSVC'); my $section = $compiler_map{$opts{'compiler'}}; @@ -838,9 +856,9 @@ if ($opts{'compile-warnings'} eq 'WARNING' or $opts{'compile-warnings'} eq 'ERRO } my $warning_flags = $sections->{$section}{'warning'}; my $error_flags = $sections->{$section}{'error'}; - push(@{$opts{'mpcopts'}}, '-value_template', "compile_flags+=${warning_flags}"); - if ($opts{'compile-warnings'} eq 'ERROR') { - push(@{$opts{'mpcopts'}}, '-value_template', "compile_flags+=${error_flags}"); + push(@mpcopts, '-value_template', "compile_flags+=${warning_flags}"); + if ($compile_warnings eq 'ERROR') { + push(@mpcopts, '-value_template', "compile_flags+=${error_flags}"); } } @@ -1191,16 +1209,20 @@ sub write_config_h { my $wrote_df = 0; -sub write_default_features { +sub default_features { my %buildEnv = %{shift()}; my @feat; if ($buildEnv{'build'} eq 'target') { push(@feat, 'ipv6=1') if $opts{'ipv6'}; - push(@feat, @{$opts{'features'}}) if $opts{'features'}; - } - elsif ($opts{'java'}) { - push(@feat, 'java=1'); + my @normalized = map {/=/ ? $_: "$_=1"} @features; + push(@feat, @normalized) if @normalized; } + return @feat; +} + +sub write_default_features { + my %buildEnv = %{shift()}; + my @feat = default_features(\%buildEnv); if (@feat) { my $DF = backup_and_open("$buildEnv{'ACE_ROOT'}/bin/MakeProjectCreator" . @@ -1623,7 +1645,7 @@ if (exists $opts{'gtest'} || $tests) { setEnv('GTEST_ROOT', $gtest_root); } else { - print "Could not find Google Test, cloning...\n" if $opts{'verbose'}; + print "Could not find GoogleTest, cloning...\n" if $opts{'verbose'}; if (git_ensure_submodule($rel_path)) { $use_sm_dir = 1; } @@ -1642,8 +1664,8 @@ if (exists $opts{'gtest'} || $tests) { } if (!defined($gtest_root)) { - die "ERROR: Google Test '$gtest_sanity' not found in submodule src '$sm_src' or " . - "default install dir '$sys_dir', please pass a correct version of Google Test to --gtest\nStopped"; + die "ERROR: GoogleTest '$gtest_sanity' not found in submodule src '$sm_src' or " . + "default install dir '$sys_dir', please pass a correct version of GoogleTest to --gtest\nStopped"; } } if ($is_windows && -d File::Spec->catdir($gtest_root, 'bin')) { @@ -1655,7 +1677,7 @@ if (exists $opts{'gtest'} || $tests) { } if ($build_gtest && !$has_cmake) { - die "ERROR: Google Test in $opts{'gtest'} must be built but can't find CMake\nStopped"; + die "ERROR: GoogleTest in $opts{'gtest'} must be built but can't find CMake\nStopped"; } if (exists $opts{'rapidjson'}) { @@ -1775,18 +1797,15 @@ for my $key (keys %optdep) { sub has_feature { my $feat = shift; - if ($opts{'features'}) { - for my $f (@{$opts{'features'}}) { - my ($key, $value) = split(/=/, $f); - if ($key eq $feat) { - return 1; - } + for my $f (@features) { + my ($key, $value) = split(/=/, $f); + if ($key eq $feat) { + return 1; } } return 0; } -my @features; if ($opts{'java'}) { my $feat = 'java_pre_jpms'; unless (has_feature($feat)) { @@ -1904,7 +1923,7 @@ sub win32_cmake_generator { } if ($build_gtest) { - print("Building Google Test...\n"); + print("Building GoogleTest...\n"); my $cwd = Cwd::getcwd(); my $build_dir = $opts{'gtest'} . $slash . 'build'; @@ -1940,7 +1959,7 @@ if ($build_gtest) { or die "ERROR: Invoking @{$cmd} failed.\nStopped"; } - print("Done Building Google Test\n"); + print("Done Building GoogleTest\n"); } if (exists $opts{'jboss'} && !exists $opts{'java'}) { @@ -2274,15 +2293,10 @@ sub generate_workspace { # We can't detect C++11 compatibility in cross compilers at the moment, # but all the NDKs we officially support are C++11+ by default, so enable # C++11 features unless an explicit 'no_cxx11' feature already is set. - my $set = 1; - for my $feature (@{$opts{'features'}}) { - if ($feature =~ /no_cxx11/) { - $set = 0; - } - } - disable_feature(\@features, 'no_cxx11') if ($set); - if ($opts{'verbose'}) { - print "Setting no_cxx11=0 for Android: $set\n"; + my $feat = 'no_cxx11'; + unless (has_feature($feat)) { + disable_feature(\@features, $feat); + print "Setting $feat=0 for Android\n"; } # Disable including $JAVA_HOME/include on Android. Android NDK includes a @@ -2465,26 +2479,31 @@ EOT print "ENV: saving current environment\n" if $opts{'verbose'}; mergeToEnv($buildEnv); - my @mwc_common_args = ('-type', "$mpctype"); + my @mwc_common_args = ('-type', $mpctype, @mpcopts); if ($static) { push(@mwc_common_args, '-static'); } - if (defined $opts{'mpcopts'}) { - push(@mwc_common_args, @{$opts{'mpcopts'}}); - } - my @feature_opts = (); - if (!$buildtao && @features) { - push(@feature_opts, '-features', join(',', map {/=/ ? $_: "$_=1"} @features)); + if (!$buildtao) { + my %existing_features = get_default_features($buildEnv); + my %requested_features = get_requested_features(); + my @features_to_add; + for my $feature (keys(%requested_features)) { + my $value = $requested_features{$feature}; + push(@features_to_add, "$feature=$value") unless exists($existing_features{$feature}); + } + if (@features_to_add) { + push(@mwc_common_args, '-features', join(',', @features_to_add)); + } } # Generate our own mwc wrapper script - write_opendds_mwc($buildEnv->{'DDS_ROOT'}, [@mwc_common_args, @feature_opts]); + write_opendds_mwc($buildEnv->{'DDS_ROOT'}, [@mwc_common_args]); my @mwc = ('perl', "$ENV{ACE_ROOT}/bin/mwc.pl"); print 'Running MPC to generate ', ($mpctype eq 'gnuace' ? 'makefiles' : 'project files'), ".\n"; - if (run_command([@mwc, @mwc_common_args, @feature_opts, "$buildEnv->{'DDS_ROOT'}$slash$ws"])) { + if (run_command([@mwc, @mwc_common_args, "$buildEnv->{'DDS_ROOT'}$slash$ws"])) { die "ERROR: Error from MPC, stopped"; } $buildEnv->{'mpctype'} = $mpctype; @@ -2922,11 +2941,9 @@ sub write_cmake_file { 'content-filtered-topic' => 1, 'content-subscription' => 1, 'debug' => 1, - 'features' => '', 'gtest' => '', 'inline' => 1, 'java' => '', - 'mpcopts' => '', 'multi-topic' => 1, 'object-model-profile' => 1, 'openssl' => '', @@ -2944,6 +2961,8 @@ sub write_cmake_file { for my $opt (sort(keys(%opts_to_use))) { print_cmake_config($fh, $opt, exists($opts{$opt}) ? $opts{$opt} : $opts_to_use{$opt}); } + print_cmake_config($fh, 'features', \@features); + print_cmake_config($fh, 'mpcopts', \@mpcopts); print $fh "\n# Sanitizers\n"; for my $name (sort(keys(%all_sanitizers))) { diff --git a/dds/.gitignore b/dds/.gitignore index 852ab06c95b..cc549b7cad6 100644 --- a/dds/.gitignore +++ b/dds/.gitignore @@ -269,6 +269,7 @@ /OctetSeqS.h /OctetSeqS.inl /OpenDDSConfig.h +/OpenDDSConfig.h.bak* /OpenddsDcpsExtC.cpp /OpenddsDcpsExtC.h /OpenddsDcpsExtC.inl From 4829b5a4639a027d7be898ea955672aa0db5c6b2 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 30 Apr 2024 13:15:21 -0500 Subject: [PATCH 06/60] Use "cross compile" when it's a noun --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 89e49b1d3f1..0fadfc2421d 100755 --- a/configure +++ b/configure @@ -105,7 +105,7 @@ my %platforminfo = 'no_host' => 1, 'aceplatform' => 'lynxos', 'compiler_root_env' => 'ENV_PREFIX', - 'usage' => ['Set up the cross-compile using '. + 'usage' => ['Set up the cross compile using '. 'the script from LynxOS', ], }, @@ -191,7 +191,7 @@ my @specs = 'target=s', 'Cross-compile target (none): see --target-help', 'target-arch=s', 'Architecture for target (none): see --target-help', 'target-compiler=s', 'Compiler for target (if req\'d): see --target-help', - 'host-tools=s', 'DDS_ROOT of host tools for cross-compile (build)', + 'host-tools=s', 'DDS_ROOT of host tools for cross compile (build)', 'host-ace=s', 'Define host ACE_ROOT (uses relative path from' . $argIndent . 'target DDS_ROOT to target ACE_ROOT)', 'host-tools-only!', 'Just build the host tools (no)', From f2f2630d7905ccff4d591909ea1e68a0d8bf34e0 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 30 Apr 2024 12:58:46 -0500 Subject: [PATCH 07/60] Fix Minor Issues in DevGuide --- docs/devguide/introduction.rst | 6 +++--- docs/devguide/run_time_configuration.rst | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/devguide/introduction.rst b/docs/devguide/introduction.rst index 1260260e023..891719a745a 100644 --- a/docs/devguide/introduction.rst +++ b/docs/devguide/introduction.rst @@ -36,7 +36,7 @@ You may modify it for your own needs, within the terms of the license agreements You must not copyright OpenDDS software. For details of the licensing terms, see the file named :ghfile:`LICENSE` that is included in the OpenDDS source code distribution or visit https://opendds.org/about/license.html. -OpenDDS also utilizes other open source software products including MPC (Make Project Creator), ACE (the ADAPTIVE Communication Environment), and TAO (The ACE ORB). +OpenDDS also utilizes other open source software products including :ref:`deps-mpc` and :ref:`deps-ace-tao`. OpenDDS is open source and the development team welcomes contributions of code, tests, documentation, and ideas. Active participation by users ensures a robust implementation. @@ -741,7 +741,7 @@ In Static Discovery, each participant starts with a database containing identifi When an application creates a data writer or data reader, Static Discovery causes it to send out periodic announcements. Upon receiving one of these announcements, Static Discovery consults its local database of entities to look up the details necessary for matching and matches it against local entities. -Static Discovery requires that the :ref:`quality_of_service--user-data` QoS be configured for each participant, data writer, and data reader. +Static Discovery requires that the :ref:`qos-user-data` be configured for each participant, data writer, and data reader. This user data must contain the identifier of the entity that is being created. Thus, the user data QoS is not available for general use when using Static Discovery. Static Discovery also requires that the network locators for all entities be determined up front by configuring the transport with the necessary networking information. @@ -756,7 +756,7 @@ Threading OpenDDS creates its own threads for handling I/O, timers, asynchronous jobs, and cleanup tasks. These threads are collectively called *service threads*. -Applications may receive a callback from these threads via :ref:`introduction--listeners` (see :ref:`conditions_and_listeners--listeners`). +Applications may receive a callback from these threads via :ref:`conditions_and_listeners--listeners`. When publishing a sample, OpenDDS normally attempts to send the sample to any connected subscribers using the calling thread. If the send call would block, then the sample may be queued for sending on a separate service thread. diff --git a/docs/devguide/run_time_configuration.rst b/docs/devguide/run_time_configuration.rst index cd8d1a80bcc..03986f0473f 100644 --- a/docs/devguide/run_time_configuration.rst +++ b/docs/devguide/run_time_configuration.rst @@ -2194,7 +2194,7 @@ Transport Instance Properties Sect<7.4.5> Transport instances are specified in the OpenDDS configuration file via sections with the format of ``[transport/]``, where ```` is a unique name for that instance within that process. -Each transport instance must specify the :val:`[transport]transport_type=tcp` option with a valid transport implementation type. +Each transport instance must specify the :prop:`[transport]transport_type` option with a valid transport implementation type. The following sections list the other options that can be specified, starting with those options common to all transport types and following with those specific to each transport type. When using dynamic libraries, the OpenDDS transport libraries are dynamically loaded whenever an instance of that type is defined in a configuration file. From 6734aa82ccf675550b947ccfbcd34b174e810114 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 30 Apr 2024 14:52:58 -0500 Subject: [PATCH 08/60] Update configure Co-authored-by: Adam Mitz --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 0fadfc2421d..58c5cebdf87 100755 --- a/configure +++ b/configure @@ -1214,7 +1214,7 @@ sub default_features { my @feat; if ($buildEnv{'build'} eq 'target') { push(@feat, 'ipv6=1') if $opts{'ipv6'}; - my @normalized = map {/=/ ? $_: "$_=1"} @features; + my @normalized = map {/=/ ? $_ : "$_=1"} @features; push(@feat, @normalized) if @normalized; } return @feat; From 9bf567d224f42c7b37fee5bb94f193a4c0675b65 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 30 Apr 2024 15:04:53 -0500 Subject: [PATCH 09/60] Move Setting java Feature --- configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 58c5cebdf87..cdc21d40925 100755 --- a/configure +++ b/configure @@ -452,7 +452,6 @@ my @mpcopts; push(@mpcopts, @{$opts{'mpcopts'}}) if exists($opts{'mpcopts'}); my @features; push(@features, @{$opts{'features'}}) if exists($opts{'features'}); -push(@features, 'java=1') if $opts{'java'}; $opts{'host'} = perlOS_to_host() unless $opts{'host'}; @@ -1807,6 +1806,8 @@ sub has_feature { } if ($opts{'java'}) { + push(@features, 'java=1'); + my $feat = 'java_pre_jpms'; unless (has_feature($feat)) { my $javac = File::Spec->catfile($opts{'java'}, 'bin', 'javac'); From 2f5bfb2b82c52bdb08742158e9295713508c50f6 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 1 May 2024 19:31:21 -0500 Subject: [PATCH 10/60] Brute Force Check of ACE Required C++ Std in CMake Since https://github.com/OpenDDS/OpenDDS/pull/4487, CMake requires knowledge of the minimum C++ standard of ACE. Before it used the ACE version to assume it, but the required standard changed in ACE to C++17. To support this correctly in CMake, we could do a version check, but master has currently the same version as the last ACE7 release. This changes it to try to compile against `ace/Global_Macros.h` like how we currently check the compiler default. This will allow us to get any standard ACE requires as long it's a standard we're aware of. We will not need this after https://github.com/OpenDDS/OpenDDS/issues/4578, because CMake can directly tell us what ACE/TAO requires. This change still doesn't cover a case like ACE/TAO 7.1.4, where ACE/TAO was compiled with something other the compiler default or the minimum standard of ACE. CMake can't detect that, so that requires manually setting the standard in either CMake and/or the ACE/TAO build so they match. --- cmake/ace_cppstd.cpp | 7 +++ cmake/init.cmake | 83 ++++++++++++++++++++------- dds/DdsDcps.mpc | 1 + docs/news.d/cmake-ace-tao-cpp-std.rst | 5 ++ 4 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 cmake/ace_cppstd.cpp create mode 100644 docs/news.d/cmake-ace-tao-cpp-std.rst diff --git a/cmake/ace_cppstd.cpp b/cmake/ace_cppstd.cpp new file mode 100644 index 00000000000..1375ba8ee98 --- /dev/null +++ b/cmake/ace_cppstd.cpp @@ -0,0 +1,7 @@ +#define ACE_DOESNT_DEFINE_MAIN 1 +#include + +int main() +{ + return 0; +} diff --git a/cmake/init.cmake b/cmake/init.cmake index 590399a76f6..06cc1badb8a 100644 --- a/cmake/init.cmake +++ b/cmake/init.cmake @@ -155,6 +155,11 @@ function(_opendds_cxx_std_to_year out_var cxx_std) set(${out_var} ${year} PARENT_SCOPE) endfunction() +function(_opendds_cplusplus_to_year out_var cplusplus) + math(EXPR year "${cplusplus} / 100") + set(${out_var} ${year} PARENT_SCOPE) +endfunction() + function(_opendds_cxx_std_from_year out_var year) if(year STREQUAL 1998) set(std 98) @@ -167,14 +172,15 @@ endfunction() function(_opendds_set_cxx_std) # Get the latest known default compiler C++ standard set(default_cxx_std_year 1998) - foreach(cplusplus 201103 201402 201703 202002 202302) - try_compile(at_least + set(cplusplus_values 201103 201402 201703 202002 202302) + foreach(cplusplus IN LISTS cplusplus_values) + try_compile(compiled "${CMAKE_CURRENT_BINARY_DIR}/opendds_test_cplusplus_${cplusplus}" SOURCES "${CMAKE_CURRENT_LIST_DIR}/cplusplus.cpp" COMPILE_DEFINITIONS "-DOPENDDS_TEST_CPLUSPLUS=${cplusplus}L" ) - if(at_least) - math(EXPR default_cxx_std_year "${cplusplus} / 100") + if(compiled) + _opendds_cplusplus_to_year(default_cxx_std_year ${cplusplus}) else() break() endif() @@ -207,10 +213,8 @@ function(_opendds_set_cxx_std) endif() # Get the C++ standard ACE requires - set(ace7 FALSE) - if(NOT OPENDDS_ACE_VERSION VERSION_LESS "7.0.0") - set(ace7 TRUE) - endif() + set(ace_info "ACE ${OPENDDS_ACE_VERSION}") + set(compiler_info "compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") set(existing_cxx11 FALSE) if(OPENDDS_CXX11 OR (DEFINED _opendds_default_features_no_cxx11 AND _opendds_default_features_no_cxx11 STREQUAL "0")) @@ -220,12 +224,54 @@ function(_opendds_set_cxx_std) if(ACE_IS_BEING_BUILT AND NOT cxx_std_year LESS 2011) set(can_build_cxx11 TRUE) endif() - if(ace7) - set(ace_min_cxx_std_year 2014) - elseif(existing_cxx11 OR can_build_cxx11) - set(ace_min_cxx_std_year 2011) + if(OPENDDS_ACE_VERSION VERSION_LESS "7.0.0") + # What ACE 6 requires depends on the no_cxx11 feature + set(ace_info "${ace_info} (cxx11=${existing_cxx11})") + if(existing_cxx11 OR can_build_cxx11) + set(ace_min_cxx_std_year 2011) + else() + set(ace_min_cxx_std_year 1998) + endif() else() - set(ace_min_cxx_std_year 1998) + # What ACE 7+ requires depends on a check in ace/Global_Macros.h. We must + # compile against that header using each standard we know of until it + # compiles. + set(dir "${CMAKE_CURRENT_BINARY_DIR}/opendds_test_ace_cppstd") + set(includes "${ACE_INCLUDE_DIRS}") + if(NOT EXISTS "${ACE_INCLUDE_DIRS}/ace/config.h") + if(NOT ACE_IS_BEING_BUILT) + message(FATAL_ERROR "ACE doesn't have a config.h.") + endif() + # Won't compile without a config.h, so make a fake one. + set(include_dir "${dir}/include") + list(APPEND includes "${include_dir}") + set(ace_dir "${include_dir}/ace") + file(MAKE_DIRECTORY "${ace_dir}") + file(WRITE "${ace_dir}/config.h" "#include \n") + endif() + foreach(try_cplusplus IN LISTS cplusplus_values) + _opendds_cplusplus_to_year(try_year ${try_cplusplus}) + _opendds_cxx_std_from_year(try_std ${try_year}) + try_compile(compiled + "${dir}/${try_cplusplus}" + SOURCES "${CMAKE_CURRENT_LIST_DIR}/ace_cppstd.cpp" + CMAKE_FLAGS + "-DCMAKE_CXX_STANDARD=${try_std}" + "-DINCLUDE_DIRECTORIES=${includes}" + OUTPUT_VARIABLE build_output + ) + if(compiled) + set(ace_min_cxx_std_year ${try_year}) + break() + endif() + endforeach() + if(NOT DEFINED ace_min_cxx_std_year) + message(FATAL_ERROR + " Can't figure out required C++ standard for ${ace_info}\n" + " Tried up to C++ ${try_year} on ${compiler_info}, last output:\n" + " \n" + " ${build_output}") + endif() endif() if(OPENDDS_CMAKE_VERBOSE) @@ -239,17 +285,12 @@ function(_opendds_set_cxx_std) # See if ACE requires a later standard if(cxx_std_year LESS ace_min_cxx_std_year) - set(compiler_info "compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") - set(ace_info "ACE ${OPENDDS_ACE_VERSION}") - if(NOT ace7) - set(ace_info "${ace_info} (cxx11=${existing_cxx11})") - endif() - set(ace_info "${ace_info} requires at least C++ ${ace_min_cxx_std_year}") + set(msg "${ace_info} requires at least C++ ${ace_min_cxx_std_year}") if(NOT explicit AND max_cxx_std_year LESS ace_min_cxx_std_year) - message(FATAL_ERROR "${ace_info}, but ${compiler_info} only supports up to " + message(FATAL_ERROR "${msg}, but ${compiler_info} only supports up to " "C++ ${max_cxx_std_year}.") endif() - message(STATUS "${compiler_info} would use ${cxx_std_year}, but ${ace_info}. Raising " + message(STATUS "${compiler_info} would use ${cxx_std_year}, but ${msg}. Raising " "requirment to that.") set(cxx_std_year ${ace_min_cxx_std_year}) endif() diff --git a/dds/DdsDcps.mpc b/dds/DdsDcps.mpc index fda2efbad65..00d2fbe853f 100644 --- a/dds/DdsDcps.mpc +++ b/dds/DdsDcps.mpc @@ -113,6 +113,7 @@ project(OpenDDS_Dcps): core, coverage_optional, \ " @$(MKDIR) $(cmake_dir_install_dest)" " cp $(DDS_ROOT)/cmake/*.cmake $(cmake_dir_install_dest)" " cp $(DDS_ROOT)/cmake/cplusplus.cpp $(cmake_dir_install_dest)" +" cp $(DDS_ROOT)/cmake/ace_cppstd.cpp $(cmake_dir_install_dest)" " cp $(DDS_ROOT)/cmake/export.h.in $(cmake_dir_install_dest)" " echo '' >> $(cmake_config_install_dest)" " echo '# From make install' >> $(cmake_config_install_dest)" diff --git a/docs/news.d/cmake-ace-tao-cpp-std.rst b/docs/news.d/cmake-ace-tao-cpp-std.rst new file mode 100644 index 00000000000..8f52ea8444f --- /dev/null +++ b/docs/news.d/cmake-ace-tao-cpp-std.rst @@ -0,0 +1,5 @@ +.. news-prs: 4618 + +.. news-start-section: Platform Support and Dependencies +- Fix cases where the CMake support fails when using the ACE/TAO master branch because it now requires C++17. +.. news-end-section. news-end-section From 03feae5132e4c93aefb4a3feb83c0673723f3864 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 1 May 2024 21:25:13 -0500 Subject: [PATCH 11/60] MSVC doesn't define the correct __cplusplus --- cmake/cplusplus.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmake/cplusplus.cpp b/cmake/cplusplus.cpp index 373d339b3c1..1b7355945d2 100644 --- a/cmake/cplusplus.cpp +++ b/cmake/cplusplus.cpp @@ -1,4 +1,13 @@ -#if __cplusplus < OPENDDS_TEST_CPLUSPLUS +// msvc doesn't define __cplusplus by default for some reason +#ifdef _MSVC_LANG +# if _MSVC_LANG < OPENDDS_TEST_CPLUSPLUS +# error "Less then requested value" +# endif +#elif __cplusplus < OPENDDS_TEST_CPLUSPLUS # error "Less then requested value" #endif -int main() {} + +int main() +{ + return 0; +} From c69fdcf0d4c670eabcda52024f305d9ced6951d1 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 1 May 2024 21:26:25 -0500 Subject: [PATCH 12/60] Remove Unused Checkouts in cmake.yml --- .github/workflows/cmake.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index d6956ecf446..e5844185c41 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -213,16 +213,6 @@ jobs: with: ndk-version: r25c add-to-path: false - - name: Checkout MPC - uses: actions/checkout@v4 - with: - repository: DOCGroup/MPC - path: MPC - - name: Checkout ACE/TAO - uses: actions/checkout@v4 - with: - repository: DOCGroup/ACE_TAO - path: OpenDDS/build/ACE_TAO - name: Install Ninja run: sudo apt-get -y install ninja-build - name: Configure Host Tools From 5a08a0580215a6405c2207554db6e11b78e74ef6 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Tue, 30 Apr 2024 09:06:34 -0500 Subject: [PATCH 13/60] Samples from a DynamicDataReader are immutable Problem ------- Users cannot read a sample from a DynamicDataReader, modify it, and then write it. Solution -------- Update the DynamicSample implementation to use DynamicDataImpl with a DynamicDataXcdrReadImpl backing store. --- dds/DCPS/XTypes/DynamicDataBase.cpp | 89 +++++++++- dds/DCPS/XTypes/DynamicDataImpl.cpp | 165 +----------------- dds/DCPS/XTypes/DynamicDataImpl.h | 13 -- dds/DCPS/XTypes/DynamicDataXcdrReadImpl.cpp | 91 ---------- dds/DCPS/XTypes/DynamicDataXcdrReadImpl.h | 4 - dds/DCPS/XTypes/DynamicSample.cpp | 3 +- docs/news.d/dynamic-read-write.rst | 5 + tests/DCPS/DynamicResponse/Common.h | 45 ++++- tests/DCPS/DynamicResponse/Origin.cpp | 70 +++++--- tests/DCPS/DynamicResponse/README.rst | 23 +++ tests/DCPS/DynamicResponse/Responder.cpp | 38 +++- .../dds/DCPS/XTypes/DynamicDataImpl.cpp | 48 ++--- 12 files changed, 264 insertions(+), 330 deletions(-) create mode 100644 docs/news.d/dynamic-read-write.rst create mode 100644 tests/DCPS/DynamicResponse/README.rst diff --git a/dds/DCPS/XTypes/DynamicDataBase.cpp b/dds/DCPS/XTypes/DynamicDataBase.cpp index 4699ad18cc2..93d122c02ca 100644 --- a/dds/DCPS/XTypes/DynamicDataBase.cpp +++ b/dds/DCPS/XTypes/DynamicDataBase.cpp @@ -346,9 +346,94 @@ DDS::ReturnCode_t DynamicDataBase::unsupported_method(const char* method_name, b } #ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE -DDS::ReturnCode_t DynamicDataBase::get_simple_value(DCPS::Value& /*value*/, DDS::MemberId /*id*/) +namespace { + template + DDS::ReturnCode_t get_some_value(DCPS::Value& value, DDS::MemberId id, DDS::DynamicData& dyn, + DDS::ReturnCode_t (DDS::DynamicData::* pmf)(T&, DDS::MemberId)) + { + T v; + const DDS::ReturnCode_t ret = (dyn.*pmf)(v, id); + if (ret == DDS::RETCODE_OK) { + value = v; + } + return ret; + } + + DDS::ReturnCode_t get_some_value(DCPS::Value& value, DDS::MemberId id, DDS::DynamicData& dyn, + DDS::ReturnCode_t (DDS::DynamicData::* pmf)(char*&, DDS::MemberId)) + { + CORBA::String_var v; + const DDS::ReturnCode_t ret = (dyn.*pmf)(v, id); + if (ret == DDS::RETCODE_OK) { + value = v.in(); + } + return ret; + } + + DDS::ReturnCode_t get_some_value(DCPS::Value& value, DDS::MemberId id, DDS::DynamicData& dyn, + DDS::ReturnCode_t (DDS::DynamicData::* pmf)(ACE_CDR::WChar*&, DDS::MemberId)) + { + CORBA::WString_var v; + const DDS::ReturnCode_t ret = (dyn.*pmf)(v, id); + if (ret == DDS::RETCODE_OK) { + value = v.in(); + } + return ret; + } +} + +DDS::ReturnCode_t DynamicDataBase::get_simple_value(DCPS::Value& value, DDS::MemberId id) { - return unsupported_method("DynamicDataBase::get_simple_value"); + DDS::DynamicType_var member_type; + DDS::ReturnCode_t rc = get_member_type(member_type, type_, id); + if (rc != DDS::RETCODE_OK) { + return rc; + } + const TypeKind member_kind = member_type->get_kind(); + switch (member_kind) { + case TK_BOOLEAN: + return get_some_value(value, id, *this, &DDS::DynamicData::get_boolean_value); + case TK_BYTE: + return get_some_value(value, id, *this, &DDS::DynamicData::get_byte_value); + case TK_INT8: + return get_some_value(value, id, *this, &DDS::DynamicData::get_int8_value); + case TK_INT16: + return get_some_value(value, id, *this, &DDS::DynamicData::get_int16_value); + case TK_INT32: + return get_some_value(value, id, *this, &DDS::DynamicData::get_int32_value); + case TK_INT64: + return get_some_value(value, id, *this, &DDS::DynamicData::get_int64_value); + case TK_UINT8: + return get_some_value(value, id, *this, &DDS::DynamicData::get_uint8_value); + case TK_UINT16: + return get_some_value(value, id, *this, &DDS::DynamicData::get_uint16_value); + case TK_UINT32: + return get_some_value(value, id, *this, &DDS::DynamicData::get_uint32_value); + case TK_UINT64: + return get_some_value(value, id, *this, &DDS::DynamicData::get_uint64_value); + case TK_FLOAT32: + return get_some_value(value, id, *this, &DDS::DynamicData::get_float32_value); + case TK_FLOAT64: + return get_some_value(value, id, *this, &DDS::DynamicData::get_float64_value); + case TK_FLOAT128: + return get_some_value(value, id, *this, &DDS::DynamicData::get_float128_value); + case TK_CHAR8: + return get_some_value(value, id, *this, &DDS::DynamicData::get_char8_value); + case TK_CHAR16: + return get_some_value(value, id, *this, &DDS::DynamicData::get_char16_value); + case TK_ENUM: + case TK_STRING8: + return get_some_value(value, id, *this, &DDS::DynamicData::get_string_value); + case TK_STRING16: + return get_some_value(value, id, *this, &DDS::DynamicData::get_wstring_value); + default: + if (log_level >= LogLevel::Notice) { + ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: DynamicDataBase::get_simple_value: " + "Member type %C is not supported by DCPS::Value\n", + typekind_to_string(member_kind))); + } + } + return DDS::RETCODE_ERROR; } #endif diff --git a/dds/DCPS/XTypes/DynamicDataImpl.cpp b/dds/DCPS/XTypes/DynamicDataImpl.cpp index a0f8487b833..931f37ae0ee 100644 --- a/dds/DCPS/XTypes/DynamicDataImpl.cpp +++ b/dds/DCPS/XTypes/DynamicDataImpl.cpp @@ -30,7 +30,7 @@ DynamicDataImpl::DynamicDataImpl(DDS::DynamicType_ptr type, DDS::DynamicData_ptr backing_store) : DynamicDataBase(type) , container_(type_, this) - , backing_store_(backing_store) + , backing_store_(DDS::DynamicData::_duplicate(backing_store)) { } @@ -2130,169 +2130,6 @@ DDS::ReturnCode_t DynamicDataImpl::set_wstring_value(DDS::MemberId id, const COR #endif } -#ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE -DDS::ReturnCode_t DynamicDataImpl::get_simple_value_boolean(DCPS::Value& value, - DDS::MemberId id) const -{ - const_single_iterator single_it = container_.single_map_.find(id); - if (single_it != container_.single_map_.end()) { - value = single_it->second.get().val_; - return DDS::RETCODE_OK; - } - const_complex_iterator complex_it = container_.complex_map_.find(id); - if (complex_it != container_.complex_map_.end()) { - const DynamicDataImpl* inner_dd = dynamic_cast(complex_it->second.in()); - if (!inner_dd) { - return DDS::RETCODE_ERROR; - } - const_single_iterator inner_it = inner_dd->container_.single_map_.find(MEMBER_ID_INVALID); - if (inner_it != inner_dd->container_.single_map_.end()) { - value = inner_it->second.get().val_; - return DDS::RETCODE_OK; - } - } - return DDS::RETCODE_ERROR; -} - -DDS::ReturnCode_t DynamicDataImpl::get_simple_value_char(DCPS::Value& value, - DDS::MemberId id) const -{ - const_single_iterator single_it = container_.single_map_.find(id); - if (single_it != container_.single_map_.end()) { - value = single_it->second.get().val_; - return DDS::RETCODE_OK; - } - const_complex_iterator complex_it = container_.complex_map_.find(id); - if (complex_it != container_.complex_map_.end()) { - const DynamicDataImpl* inner_dd = dynamic_cast(complex_it->second.in()); - if (!inner_dd) { - return DDS::RETCODE_ERROR; - } - const_single_iterator inner_it = inner_dd->container_.single_map_.find(MEMBER_ID_INVALID); - if (inner_it != inner_dd->container_.single_map_.end()) { - value = inner_it->second.get().val_; - return DDS::RETCODE_OK; - } - } - return DDS::RETCODE_ERROR; -} - -template -DDS::ReturnCode_t DynamicDataImpl::get_simple_value_primitive(DCPS::Value& value, - DDS::MemberId id) const -{ - const_single_iterator single_it = container_.single_map_.find(id); - if (single_it != container_.single_map_.end()) { - value = single_it->second.get(); - return DDS::RETCODE_OK; - } - const_complex_iterator complex_it = container_.complex_map_.find(id); - if (complex_it != container_.complex_map_.end()) { - const DynamicDataImpl* inner_dd = dynamic_cast(complex_it->second.in()); - if (!inner_dd) { - return DDS::RETCODE_ERROR; - } - const_single_iterator inner_it = inner_dd->container_.single_map_.find(MEMBER_ID_INVALID); - if (inner_it != inner_dd->container_.single_map_.end()) { - value = inner_it->second.get(); - return DDS::RETCODE_OK; - } - } - return DDS::RETCODE_ERROR; -} - -DDS::ReturnCode_t DynamicDataImpl::get_simple_value_string(DCPS::Value& value, - DDS::MemberId id) const -{ - const_single_iterator single_it = container_.single_map_.find(id); - if (single_it != container_.single_map_.end()) { - value = single_it->second.get(); - return DDS::RETCODE_OK; - } - - const_complex_iterator complex_it = container_.complex_map_.find(id); - if (complex_it != container_.complex_map_.end()) { - // The string member has its own DynamicData object. - const DynamicDataImpl* str_dd = dynamic_cast(complex_it->second.in()); - char* str = 0; - if (!str_dd || !str_dd->read_basic_value(str)) { - return DDS::RETCODE_ERROR; - } - value = str; - return DDS::RETCODE_OK; - } - return DDS::RETCODE_ERROR; -} - -DDS::ReturnCode_t DynamicDataImpl::get_simple_value_enum(DCPS::Value& value, - DDS::MemberId id) const -{ - DDS::DynamicType_var mtype; - DDS::ReturnCode_t ret = get_member_type(mtype, type_, id); - if (ret != DDS::RETCODE_OK) { - return ret; - } - - DDS::Int32 enumAsInteger; - ret = get_enum_value(enumAsInteger, mtype, interface_from_this(), id); - if (ret != DDS::RETCODE_OK) { - return ret; - } - - DDS::String8_var str; - ret = get_enumerator_name(str, enumAsInteger, mtype); - if (ret != DDS::RETCODE_OK) { - return ret; - } - - value = str.in(); - return DDS::RETCODE_OK; -} - -DDS::ReturnCode_t DynamicDataImpl::get_simple_value(DCPS::Value& value, DDS::MemberId id) -{ - DDS::DynamicTypeMember_var dtm; - if (type_->get_member(dtm, id) != DDS::RETCODE_OK) { - return DDS::RETCODE_ERROR; - } - DDS::MemberDescriptor_var md; - if (dtm->get_descriptor(md) != DDS::RETCODE_OK) { - return DDS::RETCODE_ERROR; - } - DDS::DynamicType_var member_type = get_base_type(md->type()); - const TypeKind member_kind = member_type->get_kind(); - switch (member_kind) { - case TK_BOOLEAN: - return get_simple_value_boolean(value, id); - case TK_INT32: - return get_simple_value_primitive(value, id); - case TK_UINT32: - return get_simple_value_primitive(value, id); - case TK_INT64: - return get_simple_value_primitive(value, id); - case TK_UINT64: - return get_simple_value_primitive(value, id); - case TK_CHAR8: - return get_simple_value_char(value, id); - case TK_FLOAT64: - return get_simple_value_primitive(value, id); - case TK_FLOAT128: - return get_simple_value_primitive(value, id); - case TK_STRING8: - return get_simple_value_string(value, id); - case TK_ENUM: - return get_simple_value_enum(value, id); - default: - if (log_level >= LogLevel::Notice) { - ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: DynamicDataImpl::get_simple_value:" - " Member type %C is not supported by DCPS::Value\n", - typekind_to_string(member_kind))); - } - } - return DDS::RETCODE_ERROR; -} -#endif - bool DynamicDataImpl::serialized_size(const DCPS::Encoding& enc, size_t& size, DCPS::Sample::Extent ext) const { DynamicDataImpl* non_const_this = const_cast(this); diff --git a/dds/DCPS/XTypes/DynamicDataImpl.h b/dds/DCPS/XTypes/DynamicDataImpl.h index c9fc3cd02b3..aa7f6625cfb 100644 --- a/dds/DCPS/XTypes/DynamicDataImpl.h +++ b/dds/DCPS/XTypes/DynamicDataImpl.h @@ -213,23 +213,10 @@ class OpenDDS_Dcps_Export DynamicDataImpl : public DynamicDataBase { DDS::ReturnCode_t set_wstring_values(DDS::MemberId id, const DDS::WstringSeq& value); -#ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE - DDS::ReturnCode_t get_simple_value(DCPS::Value& value, DDS::MemberId id); -#endif - bool serialized_size(const DCPS::Encoding& enc, size_t& size, DCPS::Sample::Extent ext) const; bool serialize(DCPS::Serializer& ser, DCPS::Sample::Extent ext) const; private: -#ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE - DDS::ReturnCode_t get_simple_value_boolean(DCPS::Value& value, DDS::MemberId id) const; - DDS::ReturnCode_t get_simple_value_char(DCPS::Value& value, DDS::MemberId id) const; - template - DDS::ReturnCode_t get_simple_value_primitive(DCPS::Value& value, DDS::MemberId id) const; - DDS::ReturnCode_t get_simple_value_string(DCPS::Value& value, DDS::MemberId id) const; - DDS::ReturnCode_t get_simple_value_enum(DCPS::Value& value, DDS::MemberId id) const; -#endif - CORBA::ULong get_string_item_count() const; CORBA::ULong get_sequence_item_count() const; bool has_member(DDS::MemberId id) const; diff --git a/dds/DCPS/XTypes/DynamicDataXcdrReadImpl.cpp b/dds/DCPS/XTypes/DynamicDataXcdrReadImpl.cpp index 81e2cbad290..48433da6998 100644 --- a/dds/DCPS/XTypes/DynamicDataXcdrReadImpl.cpp +++ b/dds/DCPS/XTypes/DynamicDataXcdrReadImpl.cpp @@ -2901,97 +2901,6 @@ bool DynamicDataXcdrReadImpl::check_xcdr1_mutable_i(DDS::DynamicType_ptr dt, Dyn return true; } -#ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE -namespace { - template - DDS::ReturnCode_t get_some_value(DCPS::Value& value, DDS::MemberId id, DynamicDataXcdrReadImpl& dyn, - DDS::ReturnCode_t (DynamicDataXcdrReadImpl::* pmf)(T&, DDS::MemberId)) - { - T v; - const DDS::ReturnCode_t ret = (dyn.*pmf)(v, id); - if (ret == DDS::RETCODE_OK) { - value = v; - } - return ret; - } - - DDS::ReturnCode_t get_some_value(DCPS::Value& value, DDS::MemberId id, DynamicDataXcdrReadImpl& dyn, - DDS::ReturnCode_t (DynamicDataXcdrReadImpl::* pmf)(char*&, DDS::MemberId)) - { - CORBA::String_var v; - const DDS::ReturnCode_t ret = (dyn.*pmf)(v, id); - if (ret == DDS::RETCODE_OK) { - value = v.in(); - } - return ret; - } - - DDS::ReturnCode_t get_some_value(DCPS::Value& value, DDS::MemberId id, DynamicDataXcdrReadImpl& dyn, - DDS::ReturnCode_t (DynamicDataXcdrReadImpl::* pmf)(ACE_CDR::WChar*&, DDS::MemberId)) - { - CORBA::WString_var v; - const DDS::ReturnCode_t ret = (dyn.*pmf)(v, id); - if (ret == DDS::RETCODE_OK) { - value = v.in(); - } - return ret; - } -} - -DDS::ReturnCode_t DynamicDataXcdrReadImpl::get_simple_value(DCPS::Value& value, DDS::MemberId id) -{ - DDS::DynamicTypeMember_var dtm; - if (type_->get_member(dtm, id) != DDS::RETCODE_OK) { - return DDS::RETCODE_ERROR; - } - DDS::MemberDescriptor_var md; - if (dtm->get_descriptor(md) != DDS::RETCODE_OK) { - return DDS::RETCODE_ERROR; - } - DDS::DynamicType_var member_type = get_base_type(md->type()); - const TypeKind member_kind = member_type->get_kind(); - switch (member_kind) { - case TK_BOOLEAN: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_boolean_value); - case TK_BYTE: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_byte_value); - case TK_INT8: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_int8_value); - case TK_INT16: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_int16_value); - case TK_INT32: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_int32_value); - case TK_INT64: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_int64_value_impl); - case TK_UINT8: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_uint8_value); - case TK_UINT16: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_uint16_value); - case TK_UINT32: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_uint32_value); - case TK_UINT64: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_uint64_value_impl); - case TK_FLOAT32: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_float32_value); - case TK_FLOAT64: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_float64_value); - case TK_FLOAT128: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_float128_value); - case TK_CHAR8: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_char8_value); - case TK_CHAR16: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_char16_value); - case TK_ENUM: - case TK_STRING8: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_string_value); - case TK_STRING16: - return get_some_value(value, id, *this, &DynamicDataXcdrReadImpl::get_wstring_value); - default: - return DDS::RETCODE_UNSUPPORTED; - } -} -#endif - #ifndef OPENDDS_SAFETY_PROFILE bool print_member(DDS::DynamicData_ptr dd, DCPS::String& type_string, DCPS::String& indent, MemberId member_id); diff --git a/dds/DCPS/XTypes/DynamicDataXcdrReadImpl.h b/dds/DCPS/XTypes/DynamicDataXcdrReadImpl.h index 339446ee6af..310c47cac35 100644 --- a/dds/DCPS/XTypes/DynamicDataXcdrReadImpl.h +++ b/dds/DCPS/XTypes/DynamicDataXcdrReadImpl.h @@ -340,10 +340,6 @@ class OpenDDS_Dcps_Export DynamicDataXcdrReadImpl : public DynamicDataBase { CORBA::Boolean equals(DDS::DynamicData_ptr other); -#ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE - DDS::ReturnCode_t get_simple_value(DCPS::Value& value, DDS::MemberId id); -#endif - bool serialized_size(const DCPS::Encoding&, size_t&, DCPS::Sample::Extent) const { // Not supported. diff --git a/dds/DCPS/XTypes/DynamicSample.cpp b/dds/DCPS/XTypes/DynamicSample.cpp index 1864abd5a5f..4390376d701 100644 --- a/dds/DCPS/XTypes/DynamicSample.cpp +++ b/dds/DCPS/XTypes/DynamicSample.cpp @@ -93,7 +93,8 @@ bool DynamicSample::deserialize(Serializer& ser) mb->wr_ptr(len); const DDS::DynamicType_var type = data_->type(); - data_ = new DynamicDataXcdrReadImpl(mb.get(), ser.encoding(), type, extent_); + DDS::DynamicData_var back = new DynamicDataXcdrReadImpl(mb.get(), ser.encoding(), type, extent_); + data_ = new DynamicDataImpl(type, back); return true; } diff --git a/docs/news.d/dynamic-read-write.rst b/docs/news.d/dynamic-read-write.rst new file mode 100644 index 00000000000..fb0ff9712e5 --- /dev/null +++ b/docs/news.d/dynamic-read-write.rst @@ -0,0 +1,5 @@ +.. news-prs: 04609 + +.. news-start-section: Additions +- Samples from DynamicDataReaders can be modified and passed to DynamicDataWriters. +.. news-end-section diff --git a/tests/DCPS/DynamicResponse/Common.h b/tests/DCPS/DynamicResponse/Common.h index e2a5d657ea6..1e40d2f81a8 100644 --- a/tests/DCPS/DynamicResponse/Common.h +++ b/tests/DCPS/DynamicResponse/Common.h @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -11,6 +12,15 @@ #include +const char ORIGIN[] = "origin"; +const char RESPONDER[] = "responder"; + +const char TOPICS_CREATED[] = "topics created"; +const char TOPICS_ANALYZED[] = "topics analyzed"; +const char ORIGIN_SAMPLES_AWAY[] = "origin samples away"; +const char RESPONDER_SAMPLES_AWAY[] = "responder samples away"; +const char DONE[] = "done"; + struct Test { const char* const name; int exit_status; @@ -114,6 +124,23 @@ struct Test { return dw2; } + template + typename DataReaderType::_var_type create_reader(DDS::Topic_var& topic) + { + DDS::DataReaderQos qos; + sub->get_default_datareader_qos(qos); + qos.history.kind = DDS::KEEP_ALL_HISTORY_QOS; + qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS; + DDS::DataReader_var dr = + sub->create_datareader(topic, qos, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK); + typename DataReaderType::_var_type dr2 = DataReaderType::_narrow(dr); + if (!dr2) { + ACE_ERROR((LM_ERROR, "%C (%P|%t) ERROR: create_datareader failed!\n", name)); + exit_status = 1; + } + return dr2; + } + bool check_rc(DDS::ReturnCode_t rc, const std::string& what) { if (rc != DDS::RETCODE_OK) { @@ -127,14 +154,11 @@ struct Test { void wait_for(const std::string& actor, const std::string& what) { - ACE_DEBUG((LM_DEBUG, "%C is waiting for %C to post %C\n", name, actor.c_str(), what.c_str())); dcs->wait_for(name, actor, what); - ACE_DEBUG((LM_DEBUG, "%C is DONE waiting for %C to post %C\n", name, actor.c_str(), what.c_str())); } void post(const std::string& what) { - ACE_DEBUG((LM_DEBUG, "%C is posting %C\n", name, what.c_str())); dcs->post(name, what); } }; @@ -192,6 +216,21 @@ struct Topic { return true; } + bool write(const TopicType& msg) + { + return writer->write(msg, DDS::HANDLE_NIL) == DDS::RETCODE_OK; + } + + bool wait_dr_match(int count) const + { + DDS::DataReader_var dr = DDS::DataReader::_duplicate(reader); + if (Utils::wait_match(dr, count, Utils::EQ)) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: main(): Error waiting for match for dr\n")); + return false; + } + return true; + } + bool read_multiple(SeqType& seq) { DDS::DataReader_var dr = DDS::DataReader::_duplicate(reader); diff --git a/tests/DCPS/DynamicResponse/Origin.cpp b/tests/DCPS/DynamicResponse/Origin.cpp index 0fa66d6e08f..2bd8d77bcc9 100644 --- a/tests/DCPS/DynamicResponse/Origin.cpp +++ b/tests/DCPS/DynamicResponse/Origin.cpp @@ -6,53 +6,81 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { - Test t("origin"); + Test t(ORIGIN); if (!t.init(argc, argv)) { - return 1; + return EXIT_FAILURE; } Topic ss_topic(t); if (!ss_topic.init()) { - return 1; + return EXIT_FAILURE; } Topic su_topic(t); if (!su_topic.init()) { - return 1; + return EXIT_FAILURE; } // This is just here to test that the responder can't get this type's // DynamicType because it's missing a complete TypeObject. Topic ssnc_topic(t); if (!ssnc_topic.init()) { - return 1; + return EXIT_FAILURE; } - t.post("ready"); + t.post(TOPICS_CREATED); - // TODO: Write samples to be changed by responder + t.wait_for(RESPONDER, TOPICS_ANALYZED); - t.wait_for("responder", "done"); + if (!ss_topic.wait_dr_match(2)) { + return EXIT_FAILURE; + } - SimpleStruct ss; - if (ss_topic.read_one(ss)) { - ACE_DEBUG((LM_DEBUG, "ss: string_value: %C\n", ss.string_value.in())); - if (std::strcmp(ss.string_value.in(), "Hello struct")) { - ACE_ERROR((LM_ERROR, "ERROR: Didn't get expected value from SimpleStruct\n")); - t.exit_status = 1; + if (!su_topic.wait_dr_match(2)) { + return EXIT_FAILURE; + } + + { + SimpleStruct ss; + ss.string_value = "initial"; + if (!ss_topic.write(ss)) { + return EXIT_FAILURE; } + + SimpleUnion su; + su.string_value("initial"); + if (!su_topic.write(su)) { + return EXIT_FAILURE; + } + } + + t.post(ORIGIN_SAMPLES_AWAY); + + t.wait_for(RESPONDER, RESPONDER_SAMPLES_AWAY); + + SimpleStruct ss; + if (!ss_topic.read_one(ss)) { + return EXIT_FAILURE; + } + + ACE_DEBUG((LM_DEBUG, "ss: string_value: %C\n", ss.string_value.in())); + if (std::strcmp(ss.string_value.in(), "Hello struct")) { + ACE_ERROR((LM_ERROR, "ERROR: Didn't get expected value from SimpleStruct\n")); + t.exit_status = 1; } SimpleUnion su; - if (su_topic.read_one(su)) { - ACE_DEBUG((LM_DEBUG, "su: string_value: %C\n", ss.string_value.in())); - if (std::strcmp(su.string_value(), "Hello union")) { - ACE_ERROR((LM_ERROR, "ERROR: Didn't get expected value from SimpleUnion\n")); - t.exit_status = 1; - } + if (!su_topic.read_one(su)) { + return EXIT_FAILURE; + } + + ACE_DEBUG((LM_DEBUG, "su: string_value: %C\n", su.string_value())); + if (std::strcmp(su.string_value(), "Hello union")) { + ACE_ERROR((LM_ERROR, "ERROR: Didn't get expected value from SimpleUnion\n")); + t.exit_status = 1; } - t.post("done"); + t.post(DONE); return t.exit_status; } diff --git a/tests/DCPS/DynamicResponse/README.rst b/tests/DCPS/DynamicResponse/README.rst new file mode 100644 index 00000000000..0466986cc79 --- /dev/null +++ b/tests/DCPS/DynamicResponse/README.rst @@ -0,0 +1,23 @@ +#################### +DynamicResponse Test +#################### + +This test creates two processes called the origin and the responder. + +The origin creates three topics +- a struct with CompleteTypeObject +- a union with CompleteTypeObject +- a struct without a CompleteTypeObject + +The availability of the CompleteTypeObject means a DynamicType is available in discovery. + +The basic flow is +1. The origin creates three topics. +2. The responder discovers the three topics and confirms if the DynamicType is available. +3. The origin writes samples. +4. The responder reads the (dynamic) samples, modifies them, and writes them. +5. The origin reads the samples. + +This test uses the file-based Distributed Condition Set. + +To run the test: `./run_test.pl` diff --git a/tests/DCPS/DynamicResponse/Responder.cpp b/tests/DCPS/DynamicResponse/Responder.cpp index 1bc978e9fc4..de197611466 100644 --- a/tests/DCPS/DynamicResponse/Responder.cpp +++ b/tests/DCPS/DynamicResponse/Responder.cpp @@ -21,6 +21,7 @@ struct DynamicTopic { DDS::DynamicType_var type; DDS::TypeSupport_var ts; DDS::Topic_var topic; + DDS::DynamicDataReader_var reader; DDS::DynamicDataWriter_var writer; }; @@ -28,7 +29,7 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { using OpenDDS::DCPS::retcode_to_string; - Test t("responder"); + Test t(RESPONDER); if (!t.init(argc, argv)) { return 1; } @@ -44,7 +45,7 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) topics["SimpleUnion"] = DynamicTopic(); topics["SimpleStructNotComplete"].get_dynamic_type_rc = DDS::RETCODE_NO_DATA; - t.wait_for("origin", "ready"); + t.wait_for(ORIGIN, TOPICS_CREATED); size_t found_count = 0; while (found_count < topics.size()) { @@ -85,10 +86,17 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) continue; } + topic.reader = t.create_reader(topic.topic); + DDS::DataReader_var dr = DDS::DataReader::_duplicate(topic.reader); + if (Utils::wait_match(dr, 1, Utils::EQ)) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: main(): Error waiting for match for dr\n")); + continue; + } + topic.writer = t.create_writer(topic.topic); DDS::DataWriter_var dw = DDS::DataWriter::_duplicate(topic.writer); - if (Utils::wait_match(dw, 1, Utils::EQ)) { + if (Utils::wait_match(dw, 2, Utils::EQ)) { ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: main(): Error waiting for match for dw\n")); continue; } @@ -97,12 +105,23 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) } ACE_DEBUG((LM_DEBUG, "Found all %B topics\n", topics.size())); + t.post(TOPICS_ANALYZED); + + t.wait_for(ORIGIN, ORIGIN_SAMPLES_AWAY); + for (DynamicTopicMap::iterator it = topics.begin(); it != topics.end(); ++it) { DynamicTopic& topic = it->second; if (topic.type) { - // TODO: Read First + DDS::DataReader_var dr = DDS::DataReader::_duplicate(topic.reader); + ACE_DEBUG((LM_DEBUG, "%C (%P|%t) waiting for sample on %C\n", RESPONDER, it->first.c_str())); + Utils::waitForSample(dr); + DDS::DynamicData_var dd; + DDS::SampleInfo info; + if (!t.check_rc(topic.reader->read_next_sample(dd, info), "read failed")) { + ACE_DEBUG((LM_ERROR, "ERROR: read_next_sample failed\n")); + t.exit_status = 1; + } - DDS::DynamicData_var dd = DDS::DynamicDataFactory::get_instance()->create_data(topic.type); const DDS::TypeKind tk = topic.type->get_kind(); if (!t.check_rc(dd->set_string_value(0, tk == OpenDDS::XTypes::TK_STRUCTURE ? "Hello struct" : "Hello union"), @@ -113,12 +132,17 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) if (!t.check_rc(topic.writer->write(dd, DDS::HANDLE_NIL), "write failed")) { t.exit_status = 1; } + const DDS::Duration_t duration = { 30, 0 }; + if (topic.writer->wait_for_acknowledgments(duration) != DDS::RETCODE_OK) { + ACE_DEBUG((LM_ERROR, "ERROR: wait_for_acknowledgments failed\n")); + t.exit_status = 1; + } } } - t.post("done"); + t.post(RESPONDER_SAMPLES_AWAY); - t.wait_for("origin", "done"); + t.wait_for(ORIGIN, DONE); return t.exit_status; } diff --git a/tests/unit-tests/dds/DCPS/XTypes/DynamicDataImpl.cpp b/tests/unit-tests/dds/DCPS/XTypes/DynamicDataImpl.cpp index 905eb23ea40..27f505dac60 100644 --- a/tests/unit-tests/dds/DCPS/XTypes/DynamicDataImpl.cpp +++ b/tests/unit-tests/dds/DCPS/XTypes/DynamicDataImpl.cpp @@ -2194,7 +2194,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Mutable_WriteValueToStruct) // Test reading from the backing store. ACE_Message_Block bs_msg(256); bs_msg.copy((const char*)single_value_struct, sizeof single_value_struct); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); MutableSingleValueStruct input; set_single_value_struct(input); @@ -2245,7 +2245,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Mutable_ReadValueFromBackingStore) ACE_Message_Block bs_msg(256); bs_msg.copy((const char*)buffer, sizeof buffer); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); CORBA::Int8 int8_val = 0; EXPECT_EQ(DDS::RETCODE_OK, ddi.get_int8_value(int8_val, 3)); @@ -2323,7 +2323,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Mutable_WriteValueToUnion) // Read from the backing store ACE_Message_Block bs_msg(32); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_int32_union_backing_store(ddi); } @@ -2338,7 +2338,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Mutable_WriteValueToUnion) // Test an instance starting with a backing store. ACE_Message_Block bs_msg(32); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_uint32_union_backing_store(ddi); } @@ -2451,7 +2451,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Mutable_WriteValueToUnion) // Read from the backing store ACE_Message_Block bs_msg(32); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_string_union_backing_store(ddi); } @@ -2548,7 +2548,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Mutable_WriteSequenceToStruct) // Test reading from the backing store ACE_Message_Block bs_msg(512); bs_msg.copy((const char*)sequence_struct, sizeof sequence_struct); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_reading_sequence_value_struct(ddi); @@ -2613,7 +2613,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Mutable_WriteSequenceToUnion) // Read from the backing store ACE_Message_Block bs_msg(64); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_int32s_union_backing_store(ddi); } @@ -2746,7 +2746,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Mutable_WriteSequenceToUnion) // Read from the backing store ACE_Message_Block bs_msg(64); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_strings_union_backing_store(ddi); } @@ -2786,7 +2786,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Mutable_WriteValueToArray) // Test reading from the backing store ACE_Message_Block bs_msg(64); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); DDS::DynamicData_var nested_dd; @@ -2957,7 +2957,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Mutable_WriteStructWithNestedMembers) // Read from the backing store ACE_Message_Block bs_msg(128); bs_msg.copy((const char*)mutable_struct, sizeof mutable_struct); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); CORBA::Int8 i_val = 0; @@ -3091,7 +3091,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Appendable_WriteValueToStruct) // Read-only from the backing store. ACE_Message_Block bs_msg(128); bs_msg.copy((const char*)single_value_struct, sizeof single_value_struct); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); AppendableSingleValueStruct input; set_single_value_struct(input); @@ -3123,7 +3123,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Appendable_WriteValueToUnion) // Read from the backing store ACE_Message_Block bs_msg(32); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_int32_union_backing_store(ddi); } @@ -3138,7 +3138,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Appendable_WriteValueToUnion) // Test an instance starting with a backing store. ACE_Message_Block bs_msg(32); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_uint32_union_backing_store(ddi); } @@ -3251,7 +3251,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Appendable_WriteValueToUnion) // Read from the backing store ACE_Message_Block bs_msg(32); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_string_union_backing_store(ddi); } @@ -3314,7 +3314,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Appendable_WriteSequenceToStruct) // Test reading from the backing store ACE_Message_Block bs_msg(512); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_reading_sequence_value_struct(ddi); @@ -3344,7 +3344,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Appendable_WriteSequenceToUnion) // Read from the backing store ACE_Message_Block bs_msg(64); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_int32s_union_backing_store(ddi); } @@ -3467,7 +3467,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Appendable_WriteSequenceToUnion) // Read from the backing store ACE_Message_Block bs_msg(64); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_strings_union_backing_store(ddi); } @@ -3609,7 +3609,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Final_WriteValueToStruct) // Read-only from the backing store. ACE_Message_Block bs_msg(128); bs_msg.copy((const char*)single_value_struct, sizeof single_value_struct); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); FinalSingleValueStruct input; set_single_value_struct(input); @@ -3640,7 +3640,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Final_WriteValueToUnion) // Read from the backing store ACE_Message_Block bs_msg(32); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_int32_union_backing_store(ddi); } @@ -3654,7 +3654,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Final_WriteValueToUnion) // Test an instance starting with a backing store. ACE_Message_Block bs_msg(32); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_uint32_union_backing_store(ddi); } @@ -3754,7 +3754,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Final_WriteValueToUnion) // Read from the backing store ACE_Message_Block bs_msg(32); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_string_union_backing_store(ddi); } @@ -3814,7 +3814,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Final_WriteSequenceToStruct) // Test reading from the backing store ACE_Message_Block bs_msg(512); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_reading_sequence_value_struct(ddi); @@ -3843,7 +3843,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Final_WriteSequenceToUnion) // Read from the backing store ACE_Message_Block bs_msg(64); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_int32s_union_backing_store(ddi); } @@ -3952,7 +3952,7 @@ TEST(dds_DCPS_XTypes_DynamicDataImpl, Final_WriteSequenceToUnion) // Read from the backing store ACE_Message_Block bs_msg(64); bs_msg.copy((const char*)expected_cdr, sizeof expected_cdr); - DDS::DynamicData_ptr backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); + DDS::DynamicData_var backstore = new XTypes::DynamicDataXcdrReadImpl(&bs_msg, xcdr2, dt); XTypes::DynamicDataImpl ddi(dt, backstore); verify_strings_union_backing_store(ddi); } From 6d4d51d6895640b853783f699945cf6eda9f132a Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Fri, 3 May 2024 16:36:56 -0500 Subject: [PATCH 14/60] Merge C++ Std Test Source Files CMake --- cmake/ace_cppstd.cpp | 7 ------- cmake/cplusplus.cpp | 13 ------------- cmake/init.cmake | 23 ++++++++++++++++------- cmake/test_cxx_std.cpp | 15 +++++++++++++++ 4 files changed, 31 insertions(+), 27 deletions(-) delete mode 100644 cmake/ace_cppstd.cpp delete mode 100644 cmake/cplusplus.cpp create mode 100644 cmake/test_cxx_std.cpp diff --git a/cmake/ace_cppstd.cpp b/cmake/ace_cppstd.cpp deleted file mode 100644 index 1375ba8ee98..00000000000 --- a/cmake/ace_cppstd.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#define ACE_DOESNT_DEFINE_MAIN 1 -#include - -int main() -{ - return 0; -} diff --git a/cmake/cplusplus.cpp b/cmake/cplusplus.cpp deleted file mode 100644 index 1b7355945d2..00000000000 --- a/cmake/cplusplus.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// msvc doesn't define __cplusplus by default for some reason -#ifdef _MSVC_LANG -# if _MSVC_LANG < OPENDDS_TEST_CPLUSPLUS -# error "Less then requested value" -# endif -#elif __cplusplus < OPENDDS_TEST_CPLUSPLUS -# error "Less then requested value" -#endif - -int main() -{ - return 0; -} diff --git a/cmake/init.cmake b/cmake/init.cmake index 06cc1badb8a..b5717714f93 100644 --- a/cmake/init.cmake +++ b/cmake/init.cmake @@ -170,14 +170,23 @@ function(_opendds_cxx_std_from_year out_var year) endfunction() function(_opendds_set_cxx_std) + set(cplusplus_values 201103 201402 201703 202002 202302) + set(test_cxx_std "${CMAKE_CURRENT_LIST_DIR}/test_cxx_std.cpp") + set(temp_dir "${CMAKE_CURRENT_BINARY_DIR}/opendds_test_cxx_std") + file(MAKE_DIRECTORY "${temp_dir}") + # Get the latest known default compiler C++ standard set(default_cxx_std_year 1998) - set(cplusplus_values 201103 201402 201703 202002 202302) foreach(cplusplus IN LISTS cplusplus_values) + set(args) + if(MSVC AND NOT MSVC_VERSION LESS 1914) + list(APPEND args CMAKE_FLAGS "-DCMAKE_CXX_FLAGS=/Zc:__cplusplus") + endif() try_compile(compiled - "${CMAKE_CURRENT_BINARY_DIR}/opendds_test_cplusplus_${cplusplus}" - SOURCES "${CMAKE_CURRENT_LIST_DIR}/cplusplus.cpp" + "${temp_dir}/cplusplus_${cplusplus}" + SOURCES "${test_cxx_std}" COMPILE_DEFINITIONS "-DOPENDDS_TEST_CPLUSPLUS=${cplusplus}L" + ${args} ) if(compiled) _opendds_cplusplus_to_year(default_cxx_std_year ${cplusplus}) @@ -236,14 +245,13 @@ function(_opendds_set_cxx_std) # What ACE 7+ requires depends on a check in ace/Global_Macros.h. We must # compile against that header using each standard we know of until it # compiles. - set(dir "${CMAKE_CURRENT_BINARY_DIR}/opendds_test_ace_cppstd") set(includes "${ACE_INCLUDE_DIRS}") if(NOT EXISTS "${ACE_INCLUDE_DIRS}/ace/config.h") if(NOT ACE_IS_BEING_BUILT) message(FATAL_ERROR "ACE doesn't have a config.h.") endif() # Won't compile without a config.h, so make a fake one. - set(include_dir "${dir}/include") + set(include_dir "${temp_dir}/include") list(APPEND includes "${include_dir}") set(ace_dir "${include_dir}/ace") file(MAKE_DIRECTORY "${ace_dir}") @@ -253,8 +261,9 @@ function(_opendds_set_cxx_std) _opendds_cplusplus_to_year(try_year ${try_cplusplus}) _opendds_cxx_std_from_year(try_std ${try_year}) try_compile(compiled - "${dir}/${try_cplusplus}" - SOURCES "${CMAKE_CURRENT_LIST_DIR}/ace_cppstd.cpp" + "${temp_dir}/ace_cxx_std_${try_cplusplus}" + SOURCES "${test_cxx_std}" + COMPILE_DEFINITIONS "-DOPENDDS_TEST_ACE_CXX_STD" CMAKE_FLAGS "-DCMAKE_CXX_STANDARD=${try_std}" "-DINCLUDE_DIRECTORIES=${includes}" diff --git a/cmake/test_cxx_std.cpp b/cmake/test_cxx_std.cpp new file mode 100644 index 00000000000..969068816cb --- /dev/null +++ b/cmake/test_cxx_std.cpp @@ -0,0 +1,15 @@ +#ifdef OPENDDS_TEST_CPLUSPLUS +# if __cplusplus < OPENDDS_TEST_CPLUSPLUS +# error "Less then requested value" +# endif +#elif defined OPENDDS_TEST_ACE_CXX_STD +# define ACE_DOESNT_DEFINE_MAIN 1 +# include +#else +# error "No macro was defined!" +#endif + +int main() +{ + return 0; +} From a9d17f11aeaa433aa5016368da8f88a37826c678 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Fri, 3 May 2024 19:50:28 -0500 Subject: [PATCH 15/60] Install test_cxx_std.cpp --- CMakeLists.txt | 1 + dds/DdsDcps.mpc | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1a49d16eda..cc5084db4c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,7 @@ install( cmake/opendds_version.cmake cmake/tao_group.cmake cmake/tao_idl_sources.cmake + cmake/test_cxx_std.cpp "${config_cmake}" DESTINATION "${cmake_dest}" ) diff --git a/dds/DdsDcps.mpc b/dds/DdsDcps.mpc index 00d2fbe853f..1a4ef7e82a2 100644 --- a/dds/DdsDcps.mpc +++ b/dds/DdsDcps.mpc @@ -112,8 +112,7 @@ project(OpenDDS_Dcps): core, coverage_optional, \ " cp $(DDS_ROOT)/user_macros.GNU $(DESTDIR)$(INSTALL_PREFIX)/share/dds $(ACE_NUL_STDERR)" " @$(MKDIR) $(cmake_dir_install_dest)" " cp $(DDS_ROOT)/cmake/*.cmake $(cmake_dir_install_dest)" -" cp $(DDS_ROOT)/cmake/cplusplus.cpp $(cmake_dir_install_dest)" -" cp $(DDS_ROOT)/cmake/ace_cppstd.cpp $(cmake_dir_install_dest)" +" cp $(DDS_ROOT)/cmake/test_cxx_std.cpp $(cmake_dir_install_dest)" " cp $(DDS_ROOT)/cmake/export.h.in $(cmake_dir_install_dest)" " echo '' >> $(cmake_config_install_dest)" " echo '# From make install' >> $(cmake_config_install_dest)" From 9a218e92b530a19b17585cc49d3c9dc8cf4f996b Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 6 May 2024 17:16:52 -0500 Subject: [PATCH 16/60] Test _MSVC_LANG instead of __cplusplus for CMake --- cmake/init.cmake | 5 ----- cmake/test_cxx_std.cpp | 6 +++++- docs/news.d/cmake-ace-tao-cpp-std.rst | 9 +++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmake/init.cmake b/cmake/init.cmake index b5717714f93..96f7d489075 100644 --- a/cmake/init.cmake +++ b/cmake/init.cmake @@ -178,15 +178,10 @@ function(_opendds_set_cxx_std) # Get the latest known default compiler C++ standard set(default_cxx_std_year 1998) foreach(cplusplus IN LISTS cplusplus_values) - set(args) - if(MSVC AND NOT MSVC_VERSION LESS 1914) - list(APPEND args CMAKE_FLAGS "-DCMAKE_CXX_FLAGS=/Zc:__cplusplus") - endif() try_compile(compiled "${temp_dir}/cplusplus_${cplusplus}" SOURCES "${test_cxx_std}" COMPILE_DEFINITIONS "-DOPENDDS_TEST_CPLUSPLUS=${cplusplus}L" - ${args} ) if(compiled) _opendds_cplusplus_to_year(default_cxx_std_year ${cplusplus}) diff --git a/cmake/test_cxx_std.cpp b/cmake/test_cxx_std.cpp index 969068816cb..da063eb1e2f 100644 --- a/cmake/test_cxx_std.cpp +++ b/cmake/test_cxx_std.cpp @@ -1,5 +1,9 @@ #ifdef OPENDDS_TEST_CPLUSPLUS -# if __cplusplus < OPENDDS_TEST_CPLUSPLUS +# ifdef _MSVC_LANG +# if _MSVC_LANG < OPENDDS_TEST_CPLUSPLUS +# error "Less then requested value" +# endif +# elif __cplusplus < OPENDDS_TEST_CPLUSPLUS # error "Less then requested value" # endif #elif defined OPENDDS_TEST_ACE_CXX_STD diff --git a/docs/news.d/cmake-ace-tao-cpp-std.rst b/docs/news.d/cmake-ace-tao-cpp-std.rst index 8f52ea8444f..e582401dff9 100644 --- a/docs/news.d/cmake-ace-tao-cpp-std.rst +++ b/docs/news.d/cmake-ace-tao-cpp-std.rst @@ -1,5 +1,10 @@ .. news-prs: 4618 .. news-start-section: Platform Support and Dependencies -- Fix cases where the CMake support fails when using the ACE/TAO master branch because it now requires C++17. -.. news-end-section. news-end-section +.. news-start-section: CMake +- Allow using the ACE/TAO master branch which now requires C++17. +.. news-end-section +.. news-start-section: Building with CMake +- Visual Studio now defaults to using at least C++11 with ACE 6/TAO 2 instead of C++03. +.. news-end-section +.. news-end-section From 26d2d2e6f38df67c94c6ef308fc5e15041fd9c95 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Tue, 7 May 2024 11:25:39 -0500 Subject: [PATCH 17/60] MetaStruct conversion of wchar is compiler dependent Problem ------- The `Value` class used for `MetaStruct` has various constructors based on integer size and sign. When constructing a `Value` from a wchar, different compilers make different choices. Solution -------- Provide explicit support for wchar conversion. --- dds/DCPS/FilterEvaluator.cpp | 4 ++++ dds/DCPS/FilterEvaluator.h | 1 + dds/idl/metaclass_generator.cpp | 11 +++++++++++ 3 files changed, 16 insertions(+) diff --git a/dds/DCPS/FilterEvaluator.cpp b/dds/DCPS/FilterEvaluator.cpp index a46cd5ff62a..72e1c928e9b 100644 --- a/dds/DCPS/FilterEvaluator.cpp +++ b/dds/DCPS/FilterEvaluator.cpp @@ -629,6 +629,10 @@ Value::Value(const std::string& s, bool conversion_preferred) {} #ifdef DDS_HAS_WCHAR +Value::Value(ACE_OutputCDR::from_wchar wc, bool conversion_preferred) + : type_(VAL_INT), i_(wc.val_), conversion_preferred_(conversion_preferred) +{} + Value::Value(const std::wstring& s, bool conversion_preferred) : type_(VAL_STRING), s_(ACE_OS::strdup(ACE_Wide_To_Ascii(s.c_str()).char_rep())) , conversion_preferred_(conversion_preferred) diff --git a/dds/DCPS/FilterEvaluator.h b/dds/DCPS/FilterEvaluator.h index 075f75c012a..abaaad2a70b 100644 --- a/dds/DCPS/FilterEvaluator.h +++ b/dds/DCPS/FilterEvaluator.h @@ -50,6 +50,7 @@ struct OpenDDS_Dcps_Export Value { Value(const char* s, bool conversion_preferred = false); Value(const std::string& s, bool conversion_preferred = false); #ifdef DDS_HAS_WCHAR + Value(ACE_OutputCDR::from_wchar wc, bool conversion_preferred = false); Value(const std::wstring& s, bool conversion_preferred = false); #endif Value(const TAO::String_Manager& s, bool conversion_preferred = false); diff --git a/dds/idl/metaclass_generator.cpp b/dds/idl/metaclass_generator.cpp index 3827e7ebf78..0943ff4bec0 100644 --- a/dds/idl/metaclass_generator.cpp +++ b/dds/idl/metaclass_generator.cpp @@ -58,6 +58,17 @@ namespace { prefix += "static_cast("; } suffix = use_cxx11 ? "()))" : ")"; + } else if (cls & CL_PRIMITIVE) { + AST_Type* const actual = resolveActualType(field->field_type()); + const AST_PredefinedType::PredefinedType pt = + dynamic_cast(actual)->pt(); + if (use_cxx11) { + suffix += "()"; + } + if (pt == AST_PredefinedType::PT_wchar) { + prefix = "ACE_OutputCDR::from_wchar(" + prefix; + suffix += ")"; + } } else if (use_cxx11) { suffix += "()"; } From 37ff5a857c3a24aa49882f96160d73d5fbb7efa5 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Wed, 1 May 2024 10:29:06 -0500 Subject: [PATCH 18/60] Internal documentation lacks dependency management policy Problem ------- The internal (developer) documentation lacks the policy used for managing the dependencies of OpenDDS. Solution -------- Add it. --- docs/internal/dev_guidelines.rst | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/internal/dev_guidelines.rst b/docs/internal/dev_guidelines.rst index 7fd76b3eda4..88513e6dda3 100644 --- a/docs/internal/dev_guidelines.rst +++ b/docs/internal/dev_guidelines.rst @@ -53,6 +53,41 @@ Dependencies :doc:`/devguide/building/dependencies` for all dependencies and details on how these are used in OpenDDS. +********************* +Dependency Management +********************* + +ACE/TAO +======= + +By default, the :ghfile:`configure` script and :ref:`CMake support` use released versions of ACE/TAO. +The same versions are used for pull requests. +The versions are documented in :ghfile:`acetao.ini`. +Currently, the :ghfile:`configure` scripts uses a release of ACE6 and CMake uses a release of ACE7. + +The versions are updated by the GitHub Actions workflow in :ghfile:`.github/workflows/update-ace-tao.yml` for micro/patch releases. +When a new version of ACE/TAO is available, the workflow creates a pull request based on the new version. +Ideally, this pull request would be merged early in a development cycle to allow the maximum number of builds to use the new versions. +Changing the major and minor version will be considered at the beginning of a development cycle. + +To stay abreast of changes in ACE/TAO and provide feedback to ACE/TAO, there are additional GitHub Action workflows for build and testing with various ACE/TAO branches. +These workflows are executed on a periodic basis. + +A developer is allowed to change the ACE/TAO version for their PR. +If this is not a release, then the PR would be merged after the necessary ACE/TAO functionality is released. +Ideally, the GitHub Actions files would be extended with variables that allow the default versions to be changed easily and a lint script would be added to prevent unintended changes. + +TODO +==== + +* MPC +* Perl +* openssl +* xerces +* rapidjson +* GoogleTest +* vcpkg + .. _dev_guidelines-text_file_formating: ******************** From c235225dd99779b48fbd9cdb0dfa7fa389625d07 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Fri, 10 May 2024 12:43:13 -0500 Subject: [PATCH 19/60] OpenDDS lacks pre-C++17 support for `optional` Problem ------- OpenDDS has an implementation of `optional` in XTypes. However, it is not an exact replacement for `std::optional`. Providing an implementation of `optional` will ease issues with the impending `@optional` implementation. Solution -------- Provide an implementation of `optional` when `std::optional` is not available. --- dds/DCPS/XTypes/TypeObject.cpp | 10 +- dds/DCPS/XTypes/TypeObject.h | 160 ++------ dds/DCPS/optional.h | 295 ++++++++++++++ dds/idl/typeobject_generator.cpp | 6 +- dds/idl/typeobject_generator.h | 2 +- tests/DCPS/Messenger/run_test.pl | 1 + .../unit-tests/dds/DCPS/XTypes/TypeObject.cpp | 79 +--- tests/unit-tests/dds/DCPS/optional.cpp | 377 ++++++++++++++++++ 8 files changed, 728 insertions(+), 202 deletions(-) create mode 100644 dds/DCPS/optional.h create mode 100644 tests/unit-tests/dds/DCPS/optional.cpp diff --git a/dds/DCPS/XTypes/TypeObject.cpp b/dds/DCPS/XTypes/TypeObject.cpp index d43d421e84b..d4e27cffe82 100644 --- a/dds/DCPS/XTypes/TypeObject.cpp +++ b/dds/DCPS/XTypes/TypeObject.cpp @@ -51,10 +51,10 @@ MinimalMemberDetail::MinimalMemberDetail(const OPENDDS_STRING& name) #undef max #endif -AppliedBuiltinMemberAnnotations::AppliedBuiltinMemberAnnotations(const Optional& a_unit, - const Optional& a_min, - const Optional& a_max, - const Optional& a_hash_id) +AppliedBuiltinMemberAnnotations::AppliedBuiltinMemberAnnotations(const OPENDDS_OPTIONAL_NS::optional& a_unit, + const OPENDDS_OPTIONAL_NS::optional& a_min, + const OPENDDS_OPTIONAL_NS::optional& a_max, + const OPENDDS_OPTIONAL_NS::optional& a_hash_id) : unit(a_unit) , min(a_min) , max(a_max) @@ -499,7 +499,7 @@ void compute_dependencies(const TypeMap& type_map, } void compute_dependencies(const TypeMap& type_map, - const Optional& ann_seq, + const OPENDDS_OPTIONAL_NS::optional& ann_seq, OPENDDS_SET(TypeIdentifier)& dependencies) { if (ann_seq) { diff --git a/dds/DCPS/XTypes/TypeObject.h b/dds/DCPS/XTypes/TypeObject.h index 7c22e793151..5d3621bab3d 100644 --- a/dds/DCPS/XTypes/TypeObject.h +++ b/dds/DCPS/XTypes/TypeObject.h @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -63,89 +64,6 @@ namespace XTypes { OpenDDS_Dcps_Export const DCPS::Encoding& get_typeobject_encoding(); - template - class Optional { - public: - Optional() - : present_(false) - , value_() - {} - - Optional(const T& v) - : present_(true) - { - new(value_) T(v); - } - - ~Optional() { - if (present_) { - value().~T(); - } - } - - Optional(const Optional& rhs) - : present_(false) - , value_() - { - *this = rhs; - } - - Optional& operator=(const Optional& rhs) { - if (this != &rhs) { - if (present_) { - if (rhs.present_) { - value() = rhs.value(); - } else { - value().~T(); - } - } else { - if (rhs.present_) { - new(value_) T(rhs.value()); - } - } - present_ = rhs.present_; - } - return *this; - } - - bool operator==(const Optional& other) const - { - if (present_) { - return present_ == other.present_ && value() == other.value(); - } - - return present_ == other.present_; - } - - bool operator!=(const Optional& other) const - { - return !(*this == other); - } - - operator bool() const { - return present_; - } - - bool has_value() const { - return present_; - } - - T& value() { - return reinterpret_cast(value_); - } - - const T& value() const { - return reinterpret_cast(value_); - } - - private: - bool present_; - union { - ACE_CDR::LongDouble max_alignment; - unsigned char value_[sizeof(T)]; - }; - }; - template struct Sequence { typedef ACE_CDR::ULong size_type; @@ -1139,12 +1057,12 @@ namespace XTypes { struct AppliedAnnotation { TypeIdentifier annotation_typeid; - Optional param_seq; + OPENDDS_OPTIONAL_NS::optional param_seq; AppliedAnnotation() {} AppliedAnnotation(const TypeIdentifier& ann_typeid, - const Optional& a_param_seq) + const OPENDDS_OPTIONAL_NS::optional& a_param_seq) : annotation_typeid(ann_typeid) , param_seq(a_param_seq) {} @@ -1196,17 +1114,17 @@ namespace XTypes { // --- Aggregate types: ------------------------------------------------ struct OpenDDS_Dcps_Export AppliedBuiltinMemberAnnotations { - Optional unit; // @unit("") - Optional min; // @min , @range - Optional max; // @max , @range - Optional hash_id; // @hash_id("") + OPENDDS_OPTIONAL_NS::optional unit; // @unit("") + OPENDDS_OPTIONAL_NS::optional min; // @min , @range + OPENDDS_OPTIONAL_NS::optional max; // @max , @range + OPENDDS_OPTIONAL_NS::optional hash_id; // @hash_id("") AppliedBuiltinMemberAnnotations() {} - AppliedBuiltinMemberAnnotations(const Optional& a_unit, - const Optional& a_min, - const Optional& a_max, - const Optional& a_hash_id); + AppliedBuiltinMemberAnnotations(const OPENDDS_OPTIONAL_NS::optional& a_unit, + const OPENDDS_OPTIONAL_NS::optional& a_min, + const OPENDDS_OPTIONAL_NS::optional& a_max, + const OPENDDS_OPTIONAL_NS::optional& a_hash_id); bool operator==(const AppliedBuiltinMemberAnnotations& other) const { @@ -1251,14 +1169,14 @@ namespace XTypes { // COMPLETE Details for a member of an aggregate type struct CompleteMemberDetail { MemberName name; - Optional ann_builtin; - Optional ann_custom; + OPENDDS_OPTIONAL_NS::optional ann_builtin; + OPENDDS_OPTIONAL_NS::optional ann_custom; CompleteMemberDetail() {} CompleteMemberDetail(const MemberName& a_name, - const Optional& an_ann_builtin, - const Optional& an_ann_custom) + const OPENDDS_OPTIONAL_NS::optional& an_ann_builtin, + const OPENDDS_OPTIONAL_NS::optional& an_ann_custom) : name(a_name) , ann_builtin(an_ann_builtin) , ann_custom(an_ann_custom) @@ -1370,11 +1288,11 @@ namespace XTypes { typedef Sequence MinimalStructMemberSeq; struct AppliedBuiltinTypeAnnotations { - Optional verbatim; // @verbatim(...) + OPENDDS_OPTIONAL_NS::optional verbatim; // @verbatim(...) AppliedBuiltinTypeAnnotations() {} - explicit AppliedBuiltinTypeAnnotations(const Optional& a_verbatim) + explicit AppliedBuiltinTypeAnnotations(const OPENDDS_OPTIONAL_NS::optional& a_verbatim) : verbatim(a_verbatim) {} @@ -1403,14 +1321,14 @@ namespace XTypes { }; struct CompleteTypeDetail { - Optional ann_builtin; - Optional ann_custom; + OPENDDS_OPTIONAL_NS::optional ann_builtin; + OPENDDS_OPTIONAL_NS::optional ann_custom; QualifiedTypeName type_name; CompleteTypeDetail() {} - CompleteTypeDetail(const Optional& an_ann_builtin, - const Optional& an_ann_custom, + CompleteTypeDetail(const OPENDDS_OPTIONAL_NS::optional& an_ann_builtin, + const OPENDDS_OPTIONAL_NS::optional& an_ann_custom, const QualifiedTypeName& a_type_name) : ann_builtin(an_ann_builtin) , ann_custom(an_ann_custom) @@ -1658,14 +1576,14 @@ namespace XTypes { // Member of a union type struct CompleteDiscriminatorMember { CommonDiscriminatorMember common; - Optional ann_builtin; - Optional ann_custom; + OPENDDS_OPTIONAL_NS::optional ann_builtin; + OPENDDS_OPTIONAL_NS::optional ann_custom; CompleteDiscriminatorMember() {} CompleteDiscriminatorMember(const CommonDiscriminatorMember& a_common, - const Optional& an_ann_builtin, - const Optional& an_ann_custom) + const OPENDDS_OPTIONAL_NS::optional& an_ann_builtin, + const OPENDDS_OPTIONAL_NS::optional& an_ann_custom) : common(a_common) , ann_builtin(an_ann_builtin) , ann_custom(an_ann_custom) @@ -1963,14 +1881,14 @@ namespace XTypes { struct CompleteAliasBody { CommonAliasBody common; - Optional ann_builtin; - Optional ann_custom; + OPENDDS_OPTIONAL_NS::optional ann_builtin; + OPENDDS_OPTIONAL_NS::optional ann_custom; CompleteAliasBody() {} CompleteAliasBody(const CommonAliasBody& a_common, - const Optional& an_ann_builtin, - const Optional& an_ann_custom) + const OPENDDS_OPTIONAL_NS::optional& an_ann_builtin, + const OPENDDS_OPTIONAL_NS::optional& an_ann_custom) : common(a_common) , ann_builtin(an_ann_builtin) , ann_custom(an_ann_custom) @@ -2099,13 +2017,13 @@ namespace XTypes { // --- Collections: ---------------------------------------------------- struct CompleteElementDetail { - Optional ann_builtin; - Optional ann_custom; + OPENDDS_OPTIONAL_NS::optional ann_builtin; + OPENDDS_OPTIONAL_NS::optional ann_custom; CompleteElementDetail() {} - CompleteElementDetail(const Optional& an_ann_builtin, - const Optional& an_ann_custom) + CompleteElementDetail(const OPENDDS_OPTIONAL_NS::optional& an_ann_builtin, + const OPENDDS_OPTIONAL_NS::optional& an_ann_custom) : ann_builtin(an_ann_builtin) , ann_custom(an_ann_custom) {} @@ -2210,12 +2128,12 @@ namespace XTypes { struct CompleteCollectionHeader { CommonCollectionHeader common; - Optional detail; // not present for anonymous + OPENDDS_OPTIONAL_NS::optional detail; // not present for anonymous CompleteCollectionHeader() {} CompleteCollectionHeader(const CommonCollectionHeader& a_common, - const Optional& a_detail) + const OPENDDS_OPTIONAL_NS::optional& a_detail) : common(a_common) , detail(a_detail) {} @@ -3477,7 +3395,7 @@ const XTypes::TypeMap& getCompleteTypeMap(); template void serialized_size(const Encoding& encoding, size_t& size, - const XTypes::Optional& opt) + const OPENDDS_OPTIONAL_NS::optional& opt) { size += DCPS::boolean_cdr_size; if (opt) { @@ -3486,7 +3404,7 @@ void serialized_size(const Encoding& encoding, size_t& size, } template -bool operator<<(Serializer& strm, const XTypes::Optional& opt) +bool operator<<(Serializer& strm, const OPENDDS_OPTIONAL_NS::optional& opt) { if (!(strm << ACE_OutputCDR::from_boolean(opt.has_value()))) { return false; @@ -3495,7 +3413,7 @@ bool operator<<(Serializer& strm, const XTypes::Optional& opt) } template -bool operator>>(Serializer& strm, XTypes::Optional& opt) +bool operator>>(Serializer& strm, OPENDDS_OPTIONAL_NS::optional& opt) { bool present; if (!(strm >> ACE_InputCDR::to_boolean(present))) { @@ -3504,7 +3422,7 @@ bool operator>>(Serializer& strm, XTypes::Optional& opt) if (present) { T value; const bool status = strm >> value; - opt = XTypes::Optional(value); + opt = OPENDDS_OPTIONAL_NS::optional(value); return status; } diff --git a/dds/DCPS/optional.h b/dds/DCPS/optional.h new file mode 100644 index 00000000000..0eb6ed01db1 --- /dev/null +++ b/dds/DCPS/optional.h @@ -0,0 +1,295 @@ +#ifndef OPENDDS_DCPS_OPTIONAL_H +#define OPENDDS_DCPS_OPTIONAL_H + +#include "Definitions.h" + +#include + +#include + +#ifndef ACE_LACKS_PRAGMA_ONCE +# pragma once +#endif + +#ifdef ACE_HAS_CPP17 +# define OPENDDS_HAS_STD_OPTIONAL +#endif + +#ifdef OPENDDS_HAS_STD_OPTIONAL +# include +# define OPENDDS_OPTIONAL_NS std +#else +# define OPENDDS_OPTIONAL_NS OpenDDS::DCPS +#endif + +#include "SafeBool_T.h" +#include +#include + +OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace OpenDDS { +namespace DCPS { + +template +class optional : public SafeBool_T > { +public: + typedef T value_type; + + optional() + : value_(0) + {} + + optional(const T& a_value) + : value_(new(value_storage_) T(a_value)) + {} + + optional(const optional& other) + { + if (other.has_value()) { + value_ = new(value_storage_) T(*other); + } else { + value_ = 0; + } + } + + template + optional(const optional& other) + { + if (other.has_value()) { + value_ = new(value_storage_) T(*other); + } else { + value_ = 0; + } + } + + ~optional() + { + reset(); + } + + optional& operator=(const T& a_value) + { + reset(); + value_ = new(value_storage_) T(a_value); + return *this; + } + + optional& operator=(const optional& other) + { + reset(); + if (other.has_value()) { + value_ = new(value_storage_) T(*other); + } + return *this; + } + + template + optional& operator=(const optional& other) + { + reset(); + if (other.has_value()) { + value_ = new(value_storage_) T(*other); + } + return *this; + } + + const T* operator->() const + { + return value_; + } + + T* operator->() + { + return value_; + } + + const T& operator*() const + { + return *value_; + } + + T& operator*() + { + return *value_; + } + + bool has_value() const + { + return boolean_test(); + } + + T& value() + { + if (!has_value()) { + throw std::runtime_error("bad_optional_access"); + } + return *value_; + } + + const T& value() const + { + if (!has_value()) { + throw std::runtime_error("bad_optional_access"); + } + return *value_; + } + + T value_or(const T& default_value) const + { + return has_value() ? value() : default_value; + } + + void swap(optional& other) + { + if (has_value() && other.has_value()) { + std::swap(**this, *other); + } else if (has_value()) { + other.value_ = new(other.value_storage_) T(*value_); + reset(); + } else if (other.has_value()) { + value_ = new(value_storage_) T(*other.value_); + other.reset(); + } + } + + void reset() + { + if (value_) { + value_->~T(); + value_ = 0; + } + } + + bool boolean_test() const + { + return value_ != 0; + } + +private: + T* value_; + union { + ACE_CDR::ULongLong max_alignment_; + unsigned char value_storage_[sizeof(T)]; + }; +}; + +template +void swap(optional& lhs, optional& rhs) +{ + return lhs.swap(rhs); +} + +template +bool operator==(const optional& lhs, const optional& rhs) +{ + return (!lhs.has_value() && !rhs.has_value()) || (lhs.has_value() && rhs.has_value() && *lhs == *rhs); +} + +template +bool operator<(const optional& lhs, const optional& rhs) +{ + return (!lhs.has_value() && rhs.has_value()) || (lhs.has_value() && rhs.has_value() && *lhs < *rhs); +} + +template +bool operator==(const optional& lhs, const U& rhs) +{ + return lhs.has_value() && *lhs == rhs; +} + +template +bool operator==(const T& lhs, const optional& rhs) +{ + return rhs.has_value() && lhs == *rhs; +} + +template +bool operator<(const optional& lhs, const U& rhs) +{ + return !lhs.has_value() || *lhs < rhs; +} + +template +bool operator<(const T& lhs, const optional& rhs) +{ + return rhs.has_value() && lhs < *rhs; +} + +template +bool operator!=(const optional& lhs, const optional& rhs) +{ + return (lhs.has_value() != rhs.has_value()) || (lhs.has_value() && rhs.has_value() && !(*lhs == *rhs)); +} + +template +bool operator<=(const optional& lhs, const optional& rhs) +{ + return !lhs.has_value() || (lhs.has_value() && rhs.has_value() && !(*rhs < *lhs)); +} + +template +bool operator>(const optional& lhs, const optional& rhs) +{ + return (lhs.has_value() && !rhs.has_value()) || (lhs.has_value() && rhs.has_value() && *rhs < *lhs); +} + +template +bool operator>=(const optional& lhs, const optional& rhs) +{ + return !rhs.has_value() || (lhs.has_value() && rhs.has_value() && !(*lhs < *rhs)); +} + +template +bool operator!=(const optional& lhs, const U& rhs) +{ + return !lhs.has_value() || !(*lhs == rhs); +} + +template +bool operator!=(const T& lhs, const optional& rhs) +{ + return !rhs.has_value() || !(lhs == *rhs); +} + +template +bool operator<=(const optional& lhs, const U& rhs) +{ + return !lhs.has_value() || !(rhs < *lhs); +} + +template +bool operator<=(const T& lhs, const optional& rhs) +{ + return rhs.has_value() && !(*rhs < lhs); +} + +template +bool operator>(const optional& lhs, const U& rhs) +{ + return lhs.has_value() && (rhs < *lhs); +} + +template +bool operator>(const T& lhs, const optional& rhs) +{ + return rhs.has_value() && !(*rhs < lhs); +} + +template +bool operator>=(const optional& lhs, const U& rhs) +{ + return lhs.has_value() && !(*lhs < rhs); +} + +template +bool operator>=(const T& lhs, const optional& rhs) +{ + return rhs.has_value() && !(*rhs < lhs); +} + +} // namespace DCPS +} // namespace OpenDDS + +OPENDDS_END_VERSIONED_NAMESPACE_DECL +#endif diff --git a/dds/idl/typeobject_generator.cpp b/dds/idl/typeobject_generator.cpp index 3634d72ac56..59657700cf6 100644 --- a/dds/idl/typeobject_generator.cpp +++ b/dds/idl/typeobject_generator.cpp @@ -1010,16 +1010,16 @@ typeobject_generator::update_maps(AST_Type* type, } void typeobject_generator::set_builtin_member_annotations(AST_Decl* member, - OpenDDS::XTypes::Optional& annotations) + OPENDDS_OPTIONAL_NS::optional& annotations) { // Support only @hashid annotation for member at this time. const HashidAnnotation* hashid_ann = dynamic_cast(be_global->builtin_annotations_["::@hashid"]); std::string hash_name; if (hashid_ann->node_value_exists(member, hash_name)) { - OpenDDS::XTypes::Optional hash_id(hash_name); + OPENDDS_OPTIONAL_NS::optional hash_id(hash_name); if (!annotations) { OpenDDS::XTypes::AppliedBuiltinMemberAnnotations value; - annotations = OpenDDS::XTypes::Optional(value); + annotations = OPENDDS_OPTIONAL_NS::optional(value); } annotations.value().hash_id = hash_id; } diff --git a/dds/idl/typeobject_generator.h b/dds/idl/typeobject_generator.h index 6cabb3e0d97..63d043ccafd 100644 --- a/dds/idl/typeobject_generator.h +++ b/dds/idl/typeobject_generator.h @@ -81,7 +81,7 @@ class typeobject_generator : public dds_generator { const OpenDDS::XTypes::TypeObject& minimal_to, const OpenDDS::XTypes::TypeObject& complete_to); void set_builtin_member_annotations(AST_Decl* member, - OpenDDS::XTypes::Optional& annotations); + OPENDDS_OPTIONAL_NS::optional& annotations); OpenDDS::XTypes::TypeIdentifier get_minimal_type_identifier(AST_Type* type); OpenDDS::XTypes::TypeIdentifier get_complete_type_identifier(AST_Type* type); diff --git a/tests/DCPS/Messenger/run_test.pl b/tests/DCPS/Messenger/run_test.pl index 529495f191d..a2d519e8744 100755 --- a/tests/DCPS/Messenger/run_test.pl +++ b/tests/DCPS/Messenger/run_test.pl @@ -15,6 +15,7 @@ my $test = new PerlDDS::TestFramework(); +$test->{dcps_log_level} = 'debug'; $test->{dcps_debug_level} = 4; $test->{dcps_transport_debug_level} = 2; # will manually set -DCPSConfigFile diff --git a/tests/unit-tests/dds/DCPS/XTypes/TypeObject.cpp b/tests/unit-tests/dds/DCPS/XTypes/TypeObject.cpp index 50bc5c223b3..857b11ee410 100644 --- a/tests/unit-tests/dds/DCPS/XTypes/TypeObject.cpp +++ b/tests/unit-tests/dds/DCPS/XTypes/TypeObject.cpp @@ -160,71 +160,6 @@ TEST(dds_DCPS_XTypes_TypeObject, maintest) EXPECT_EQ(badIdentifier, bad); } -TEST(dds_DCPS_XTypes_TypeObject, Optional_equal) -{ - Optional uut1; - Optional uut2; - Optional uut3(3); - Optional uut4(3); - Optional uut5(4); - - EXPECT_EQ(uut1, uut2); - EXPECT_EQ(uut3, uut4); - - EXPECT_NE(uut1, uut3); - EXPECT_NE(uut4, uut5); -} - -TEST(dds_DCPS_XTypes_TypeObject, Optional_has_value) -{ - Optional opt1; - Optional opt2("test"); - - EXPECT_FALSE(opt1); - EXPECT_FALSE(opt1.has_value()); - EXPECT_TRUE(opt2); - EXPECT_TRUE(opt2.has_value()); -} - -TEST(dds_DCPS_XTypes_TypeObject, Optional_destructor) -{ - // The Destruction object 'd' will set destroyed to true in - // its destructor. - bool destroyed = false; - Destruction d(destroyed); - - // But, because opt1 will be destroyed first, it should set - // destroyed to true first. - { - Optional opt1(d); - EXPECT_TRUE(opt1); - } - - // This should be true because the destructor of the Destruction - // object inside of the Optional will have run. - EXPECT_TRUE(destroyed); -} - -TEST(dds_DCPS_XTypes_TypeObject, Optional_assignment) -{ - Optional opt1; - Optional opt2("test"); - Optional opt3; - Optional opt4("other"); - - opt1 = opt2; - EXPECT_EQ(opt1, opt2); - - opt2 = opt1; - EXPECT_TRUE(opt2); - - opt4 = opt3; - EXPECT_EQ(opt3, opt4); - - opt3 = opt4; - EXPECT_FALSE(opt3); -} - TEST(dds_DCPS_XTypes_TypeObject, Sequence_equal) { Sequence uut1; @@ -632,9 +567,9 @@ TEST(dds_DCPS_XTypes_TypeObject, AppliedVerbatimAnnotation_equal) TEST(dds_DCPS_XTypes_TypeObject, AppliedBuiltinMemberAnnotations_equal) { AppliedBuiltinMemberAnnotations uut1; - uut1.unit = Optional("meters"); + uut1.unit = OPENDDS_OPTIONAL_NS::optional("meters"); AppliedBuiltinMemberAnnotations uut2; - uut2.unit = Optional("meters"); + uut2.unit = OPENDDS_OPTIONAL_NS::optional("meters"); AppliedBuiltinMemberAnnotations uut3; EXPECT_EQ(uut1, uut2); @@ -705,9 +640,9 @@ TEST(dds_DCPS_XTypes_TypeObject, AppliedBuiltinTypeAnnotations_equal) value.text = "text"; AppliedBuiltinTypeAnnotations uut1; - uut1.verbatim = Optional(value); + uut1.verbatim = OPENDDS_OPTIONAL_NS::optional(value); AppliedBuiltinTypeAnnotations uut2; - uut2.verbatim = Optional(value); + uut2.verbatim = OPENDDS_OPTIONAL_NS::optional(value); AppliedBuiltinTypeAnnotations uut3; EXPECT_EQ(uut1, uut2); @@ -1123,12 +1058,12 @@ TEST(dds_DCPS_XTypes_TypeObject, MinimalAliasType_equal) TEST(dds_DCPS_XTypes_TypeObject, CompleteElementDetail_equal) { AppliedBuiltinMemberAnnotations builtin; - builtin.unit = Optional("meters"); + builtin.unit = OPENDDS_OPTIONAL_NS::optional("meters"); CompleteElementDetail uut1; - uut1.ann_builtin = Optional(builtin); + uut1.ann_builtin = OPENDDS_OPTIONAL_NS::optional(builtin); CompleteElementDetail uut2; - uut2.ann_builtin = Optional(builtin); + uut2.ann_builtin = OPENDDS_OPTIONAL_NS::optional(builtin); CompleteElementDetail uut3; EXPECT_EQ(uut1, uut2); diff --git a/tests/unit-tests/dds/DCPS/optional.cpp b/tests/unit-tests/dds/DCPS/optional.cpp new file mode 100644 index 00000000000..1b041731bbd --- /dev/null +++ b/tests/unit-tests/dds/DCPS/optional.cpp @@ -0,0 +1,377 @@ +#include + +#include + +using namespace OpenDDS::DCPS; + +template +struct StaticCounter { + static int count; + T value; + + StaticCounter(T v) + : value(v) + { + ++count; + } + + StaticCounter(const StaticCounter& other) + : value(other.value) + { + ++count; + } + + template + StaticCounter(StaticCounter u) + : value(u.value) + { + ++count; + } + + ~StaticCounter() + { + --count; + } + + bool operator==(const StaticCounter& other) const + { + return value == other.value; + } + + bool operator<(const StaticCounter& other) const + { + return value < other.value; + } +}; + +template <> +int StaticCounter::count = 0; +template <> +int StaticCounter::count = 0; + +typedef StaticCounter IntCounter; +typedef StaticCounter CharCounter; + +TEST(dds_DCPS_optional, default_ctor) +{ + optional x; + EXPECT_FALSE(x.has_value()); + EXPECT_FALSE(x); + EXPECT_EQ(IntCounter::count, 0); + EXPECT_THROW(x.value(), std::runtime_error); +} + +TEST(dds_DCPS_optional, value_ctor) +{ + { + optional x(IntCounter(5)); + EXPECT_TRUE(x.has_value()); + EXPECT_TRUE(x); + EXPECT_EQ(x.value().value, 5); + EXPECT_EQ(x->value, 5); + x->value = 6; + EXPECT_EQ(x->value, 6); + EXPECT_EQ((*x).value, 6); + (*x).value = 7; + EXPECT_EQ((*x).value, 7); + EXPECT_EQ(IntCounter::count, 1); + } + EXPECT_EQ(IntCounter::count, 0); +} + +TEST(dds_DCPS_optional, copy_ctor) +{ + optional x; + optional y(x); + EXPECT_FALSE(y.has_value()); + EXPECT_FALSE(y); + EXPECT_EQ(IntCounter::count, 0); + { + optional x(IntCounter(5)); + optional y(x); + EXPECT_TRUE(y.has_value()); + EXPECT_TRUE(y); + EXPECT_EQ(y.value().value, 5); + EXPECT_EQ(IntCounter::count, 2); + } + EXPECT_EQ(IntCounter::count, 0); +} + +TEST(dds_DCPS_optional, copy_convert_ctor) +{ + optional x; + optional y(x); + EXPECT_FALSE(y.has_value()); + EXPECT_FALSE(y); + EXPECT_EQ(IntCounter::count, 0); + EXPECT_EQ(CharCounter::count, 0); + { + optional x(CharCounter(5)); + optional y(x); + EXPECT_TRUE(y.has_value()); + EXPECT_TRUE(y); + EXPECT_EQ(y.value().value, 5); + EXPECT_EQ(IntCounter::count, 1); + EXPECT_EQ(CharCounter::count, 1); + } + EXPECT_EQ(IntCounter::count, 0); + EXPECT_EQ(CharCounter::count, 0); +} + +TEST(dds_DCPS_optional, value_assign) +{ + optional x; + x = 5; + EXPECT_TRUE(x.has_value()); + EXPECT_TRUE(x); + EXPECT_EQ(x.value().value, 5); + EXPECT_EQ(IntCounter::count, 1); +} + +TEST(dds_DCPS_optional, copy_assign) +{ + optional x; + optional y(IntCounter(5)); + x = y; + EXPECT_TRUE(x.has_value()); + EXPECT_TRUE(x); + EXPECT_EQ(x.value().value, 5); + EXPECT_EQ(IntCounter::count, 2); +} + +TEST(dds_DCPS_optional, copy_convert_assign) +{ + optional x; + optional y; + y = x; + EXPECT_FALSE(y.has_value()); + EXPECT_FALSE(y); + EXPECT_EQ(IntCounter::count, 0); + EXPECT_EQ(CharCounter::count, 0); + { + optional x(CharCounter(5)); + optional y; + y = x; + EXPECT_TRUE(y.has_value()); + EXPECT_TRUE(y); + EXPECT_EQ(y.value().value, 5); + EXPECT_EQ(IntCounter::count, 1); + EXPECT_EQ(CharCounter::count, 1); + } + EXPECT_EQ(IntCounter::count, 0); + EXPECT_EQ(CharCounter::count, 0); +} + +TEST(dds_DCPS_optional, swap) +{ + optional x(5); + optional y(6); + x.swap(y); + EXPECT_TRUE(x); + EXPECT_TRUE(y); + EXPECT_EQ(x->value, 6); + EXPECT_EQ(y->value, 5); + swap(x, y); + EXPECT_TRUE(x); + EXPECT_TRUE(y); + EXPECT_EQ(x->value, 5); + EXPECT_EQ(y->value, 6); +} + +TEST(dds_DCPS_optional, reset) +{ + optional x(5); + EXPECT_EQ(IntCounter::count, 1); + x.reset(); + EXPECT_EQ(IntCounter::count, 0); +} + +TEST(dds_DCPS_optional, equal) +{ + optional a; + optional b; + optional x(5); + optional y(5); + optional z(6); + EXPECT_TRUE(a == b); + EXPECT_TRUE(x == y); + EXPECT_FALSE(a == x); + EXPECT_FALSE(x == z); +} + +TEST(dds_DCPS_optional, not_equal) +{ + optional a; + optional b; + optional x(5); + optional y(5); + optional z(6); + EXPECT_FALSE(a != b); + EXPECT_FALSE(x != y); + EXPECT_TRUE(a != x); + EXPECT_TRUE(x != z); +} + +TEST(dds_DCPS_optional, less_than) +{ + optional a; + optional b; + optional x(5); + optional y(5); + optional z(6); + EXPECT_FALSE(a < b); + EXPECT_FALSE(x < y); + EXPECT_TRUE(a < x); + EXPECT_TRUE(x < z); + EXPECT_FALSE(b < a); + EXPECT_FALSE(y < x); + EXPECT_FALSE(x < a); + EXPECT_FALSE(z < x); +} + +TEST(dds_DCPS_optional, less_than_equal) +{ + optional a; + optional b; + optional x(5); + optional y(5); + optional z(6); + EXPECT_TRUE(a <= b); + EXPECT_TRUE(x <= y); + EXPECT_TRUE(a <= x); + EXPECT_TRUE(x <= z); + EXPECT_TRUE(b <= a); + EXPECT_TRUE(y <= x); + EXPECT_FALSE(x <= a); + EXPECT_FALSE(z <= x); +} + +TEST(dds_DCPS_optional, greater_than) +{ + optional a; + optional b; + optional x(5); + optional y(5); + optional z(6); + EXPECT_FALSE(a > b); + EXPECT_FALSE(x > y); + EXPECT_FALSE(a > x); + EXPECT_FALSE(x > z); + EXPECT_FALSE(b > a); + EXPECT_FALSE(y > x); + EXPECT_TRUE(x > a); + EXPECT_TRUE(z > x); +} + +TEST(dds_DCPS_optional, greater_than_equal) +{ + optional a; + optional b; + optional x(5); + optional y(5); + optional z(6); + EXPECT_TRUE(a >= b); + EXPECT_TRUE(x >= y); + EXPECT_FALSE(a >= x); + EXPECT_FALSE(x >= z); + EXPECT_TRUE(b >= a); + EXPECT_TRUE(y >= x); + EXPECT_TRUE(x >= a); + EXPECT_TRUE(z >= x); +} + +TEST(dds_DCPS_optional, equal_value) +{ + optional a; + optional x(5); + IntCounter y(5); + IntCounter z(6); + EXPECT_FALSE(a == y); + EXPECT_FALSE(a == z); + EXPECT_TRUE(x == y); + EXPECT_FALSE(x == z); + EXPECT_FALSE(y == a); + EXPECT_FALSE(z == a); + EXPECT_TRUE(y == x); + EXPECT_FALSE(z == x); +} + +TEST(dds_DCPS_optional, not_equal_value) +{ + optional a; + optional x(5); + IntCounter y(5); + IntCounter z(6); + EXPECT_TRUE(a != y); + EXPECT_TRUE(a != z); + EXPECT_FALSE(x != y); + EXPECT_TRUE(x != z); + EXPECT_TRUE(y != a); + EXPECT_TRUE(z != a); + EXPECT_FALSE(y != x); + EXPECT_TRUE(z != x); +} + +TEST(dds_DCPS_optional, less_than_value) +{ + optional a; + optional x(5); + IntCounter y(5); + IntCounter z(6); + EXPECT_TRUE(a < y); + EXPECT_TRUE(a < z); + EXPECT_FALSE(x < y); + EXPECT_TRUE(x < z); + EXPECT_FALSE(y < a); + EXPECT_FALSE(z < a); + EXPECT_FALSE(y < x); + EXPECT_FALSE(z < x); +} + +TEST(dds_DCPS_optional, less_than_equal_value) +{ + optional a; + optional x(5); + IntCounter y(5); + IntCounter z(6); + EXPECT_TRUE(a <= y); + EXPECT_TRUE(a <= z); + EXPECT_TRUE(x <= y); + EXPECT_TRUE(x <= z); + EXPECT_FALSE(y <= a); + EXPECT_FALSE(z <= a); + EXPECT_TRUE(y <= x); + EXPECT_FALSE(z <= x); +} + +TEST(dds_DCPS_optional, greater_than_value) +{ + optional a; + optional x(5); + IntCounter y(5); + IntCounter z(6); + EXPECT_FALSE(a > y); + EXPECT_FALSE(a > z); + EXPECT_FALSE(x > y); + EXPECT_FALSE(x > z); + EXPECT_FALSE(y > a); + EXPECT_FALSE(z > a); + EXPECT_TRUE(y > x); + EXPECT_FALSE(z > x); +} + +TEST(dds_DCPS_optional, greater_than_equal_value) +{ + optional a; + optional x(5); + IntCounter y(5); + IntCounter z(6); + EXPECT_FALSE(a >= y); + EXPECT_FALSE(a >= z); + EXPECT_TRUE(x >= y); + EXPECT_FALSE(x >= z); + EXPECT_FALSE(y >= a); + EXPECT_FALSE(z >= a); + EXPECT_TRUE(y >= x); + EXPECT_FALSE(z >= x); +} From ba3c67e922991df6067cd2c6bf5c1c5411479aa3 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Wed, 15 May 2024 09:56:40 -0500 Subject: [PATCH 20/60] Fix warnings in Hash.cpp --- dds/DCPS/Hash.cpp | 50 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/dds/DCPS/Hash.cpp b/dds/DCPS/Hash.cpp index af4f2ad79a4..fbf4846112e 100644 --- a/dds/DCPS/Hash.cpp +++ b/dds/DCPS/Hash.cpp @@ -94,7 +94,7 @@ typedef struct { */ #if defined(__i386__) || defined(__x86_64__) || defined(__vax__) #define SET(n) \ - (*(MD5_u32plus *)&ptr[(n) * 4]) + (*(const MD5_u32plus *)&ptr[(n) * 4]) #define GET(n) \ SET(n) #else @@ -284,33 +284,33 @@ void MD5_Final(unsigned char *result, MD5_CTX *ctx) memset(&ctx->buffer[used], 0, free - 8); ctx->lo <<= 3; - ctx->buffer[56] = ctx->lo; - ctx->buffer[57] = ctx->lo >> 8; - ctx->buffer[58] = ctx->lo >> 16; - ctx->buffer[59] = ctx->lo >> 24; - ctx->buffer[60] = ctx->hi; - ctx->buffer[61] = ctx->hi >> 8; - ctx->buffer[62] = ctx->hi >> 16; - ctx->buffer[63] = ctx->hi >> 24; + ctx->buffer[56] = ctx->lo & 0xFF; + ctx->buffer[57] = (ctx->lo >> 8) & 0xFF; + ctx->buffer[58] = (ctx->lo >> 16) & 0xFF; + ctx->buffer[59] = (ctx->lo >> 24) & 0xFF; + ctx->buffer[60] = ctx->hi & 0xFF; + ctx->buffer[61] = (ctx->hi >> 8) & 0xFF; + ctx->buffer[62] = (ctx->hi >> 16) & 0xFF; + ctx->buffer[63] = (ctx->hi >> 24) & 0xFF; body(ctx, ctx->buffer, 64); - result[0] = ctx->a; - result[1] = ctx->a >> 8; - result[2] = ctx->a >> 16; - result[3] = ctx->a >> 24; - result[4] = ctx->b; - result[5] = ctx->b >> 8; - result[6] = ctx->b >> 16; - result[7] = ctx->b >> 24; - result[8] = ctx->c; - result[9] = ctx->c >> 8; - result[10] = ctx->c >> 16; - result[11] = ctx->c >> 24; - result[12] = ctx->d; - result[13] = ctx->d >> 8; - result[14] = ctx->d >> 16; - result[15] = ctx->d >> 24; + result[0] = ctx->a & 0xFF; + result[1] = (ctx->a >> 8) & 0xFF; + result[2] = (ctx->a >> 16) & 0xFF; + result[3] = (ctx->a >> 24) & 0xFF; + result[4] = ctx->b & 0xFF; + result[5] = (ctx->b >> 8) & 0xFF; + result[6] = (ctx->b >> 16) & 0xFF; + result[7] = (ctx->b >> 24) & 0xFF; + result[8] = ctx->c & 0xFF; + result[9] = (ctx->c >> 8) & 0xFF; + result[10] = (ctx->c >> 16) & 0xFF; + result[11] = (ctx->c >> 24) & 0xFF; + result[12] = ctx->d & 0xFF; + result[13] = (ctx->d >> 8) & 0xFF; + result[14] = (ctx->d >> 16) & 0xFF; + result[15] = (ctx->d >> 24) & 0xFF; memset(ctx, 0, sizeof(*ctx)); } From f4a6c0f270a8a80f70cde9c8ee3926dd7ab474f8 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Wed, 15 May 2024 14:30:02 -0500 Subject: [PATCH 21/60] Try C++ language standard --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index ecd56457720..bf05639186c 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -11481,7 +11481,7 @@ jobs: call setenv.cmd mkdir tests\cmake\build cd tests\cmake\build - cmake .. + cmake .. -DCMAKE_CXX_STANDARD=20 cmake --build . - name: check build configuration shell: cmd From 2dce55d2489742e3e6cbcb3535f4b98b632dfb3c Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Wed, 15 May 2024 09:38:57 -0500 Subject: [PATCH 22/60] Debugging output not available for Messenger test Problem ------- Debugging is not turned on for the Messenger test. Solution -------- Restore default debugging. See 2605ead31cb4334c388f305e0fee89aa838bf857. --- bin/PerlDDS/Run_Test.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/PerlDDS/Run_Test.pm b/bin/PerlDDS/Run_Test.pm index 0a599682f61..cf1126496a7 100644 --- a/bin/PerlDDS/Run_Test.pm +++ b/bin/PerlDDS/Run_Test.pm @@ -595,7 +595,7 @@ sub _process_common { my $self = shift; my $name = shift; my $params = shift; - my $debug_logging = $self->{dcps_log_level}; + my $debug_logging = 1; if ($$params !~ /-DCPSLogLevel / && $self->{dcps_log_level}) { $$params .= " -DCPSLogLevel $self->{dcps_log_level}"; From 4afecf71c51abeeed844c31c867bc57520f77338 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 17 May 2024 08:41:20 +0200 Subject: [PATCH 23/60] Fixed typo * configure: --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index cdc21d40925..5fc0993d5e8 100755 --- a/configure +++ b/configure @@ -268,7 +268,7 @@ my @specs = 'rapidjson:s', 'RapidJSON for Wireshark dissector and JSON' . $argIndent . 'Sample Serialization (Enabled by default,' . - $argIndent . 'use git submodle, RAPIDJSON_ROOT, or system pkg)', + $argIndent . 'use git submodule, RAPIDJSON_ROOT, or system pkg)', 'qt:s', 'Qt5 (use QTDIR or system pkg)', 'qt-include:s', 'Qt include dir (use QT5_INCDIR, QTDIR/include,' . $argIndent . 'or system package)', From 6bfa061fa3e0bbc3cac221c0315722d743e81dd6 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Fri, 17 May 2024 08:53:37 +0200 Subject: [PATCH 24/60] Update dependencies.rst Updated link to OCI TAO DevGruide --- docs/devguide/building/dependencies.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/devguide/building/dependencies.rst b/docs/devguide/building/dependencies.rst index 6a6acf78fc1..858e23cd645 100644 --- a/docs/devguide/building/dependencies.rst +++ b/docs/devguide/building/dependencies.rst @@ -116,7 +116,7 @@ TAO is a C++ CORBA Implementation built on ACE. - This is the only library which depends on ``TAO_PortableServer``. -The TAO Developer's Guide book can be requested for free from https://objectcomputing.com/products/tao/tao-developers-guide. +The TAO Developer's Guide book can be requested for free from https://objectcomputing.com/platforms/tao/tao-developers-guide. The CORBA Programmers Guide can be downloaded for free from https://www.remedy.nl/opensource/corbapg.html. .. _deps-optional: From 0d82400a523f9fe0c31ebd1d45343dbacaa31be0 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Fri, 17 May 2024 16:20:27 -0500 Subject: [PATCH 25/60] Environment variables are not processed immediately Problem ------- Environment variables are not processed immediately by the Service Participant. For many configuration keys, this is irrelevant. For others, like those processed in `Service_Participant::ConfigReaderListener::on_data_available`, it applies the configuration immediately. A related problem is that if there are no arguments or configuration file, then the configuration from environment variables is not applied. This prevents an "environment variable only" configuration from working properly. Solution -------- Invoke the listener after each environment variable is processed. --- dds/DCPS/Service_Participant.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dds/DCPS/Service_Participant.cpp b/dds/DCPS/Service_Participant.cpp index ccd3cb5bdc4..276c8f7a25e 100644 --- a/dds/DCPS/Service_Participant.cpp +++ b/dds/DCPS/Service_Participant.cpp @@ -568,6 +568,7 @@ void Service_Participant::parse_env(const String& p) const String key = q.substr(0, pos); const String value = q.substr(pos + 1); config_store_->set(key.c_str(), value); + config_reader_listener_->on_data_available(config_reader_); } } } From 1e3257d584b94b2e4eb35ff341f6d2497000db2b Mon Sep 17 00:00:00 2001 From: Jan Vermaete Date: Sat, 18 May 2024 19:34:30 +0200 Subject: [PATCH 26/60] cmake: ignore the not used targets when building with juist the host tools. Signed-off-by: Jan Vermaete --- cmake/build_ace_tao.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/build_ace_tao.cmake b/cmake/build_ace_tao.cmake index 276dfe0cc6a..3e12f1b1546 100644 --- a/cmake/build_ace_tao.cmake +++ b/cmake/build_ace_tao.cmake @@ -37,7 +37,9 @@ execute_process( # Get the C++ standard OpenDDS is going to be built with. We are going to force # the ACE/TAO build to use the same standard. set(_opendds_idl_std "$") -set(_opendds_dcps_std "$") +if(NOT OPENDDS_JUST_BUILD_HOST_TOOLS) + set(_opendds_dcps_std "$") +endif() set(_opendds_std "$,${_opendds_dcps_std},${_opendds_idl_std}>") set(_build_cmd "${CMAKE_COMMAND}" -E env "ACE_ROOT=${OPENDDS_ACE}" "TAO_ROOT=${OPENDDS_TAO}") From fcc93fa03851f4252c56c04f5962f8ab80a5b0e6 Mon Sep 17 00:00:00 2001 From: iguessthislldo Date: Mon, 20 May 2024 00:53:05 +0000 Subject: [PATCH 27/60] Update ACE/TAO to 6.5.21 Updated: - ACE 6/TAO 2 from 6.5.20 to [6.5.21](https://github.com/DOCGroup/ACE_TAO/releases/tag/ACE%2BTAO-6_5_21). --- acetao.ini | 22 +++++++++++----------- docs/news.d/automated-update-ace6tao2.rst | 9 +++++++++ 2 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 docs/news.d/automated-update-ace6tao2.rst diff --git a/acetao.ini b/acetao.ini index 2ad3cc9320d..4b32597b2d5 100644 --- a/acetao.ini +++ b/acetao.ini @@ -5,19 +5,19 @@ [ace6tao2] hold=0 desc=ACE 6/TAO 2 -version=6.5.20 +version=6.5.21 repo=https://github.com/DOCGroup/ACE_TAO.git branch=ace6tao2 -url=https://github.com/DOCGroup/ACE_TAO/releases/tag/ACE%2BTAO-6_5_20 -zip-filename=ACE+TAO-src-6.5.20.zip -zip-url=https://github.com/DOCGroup/ACE_TAO/releases/download/ACE%2BTAO-6_5_20/ACE%2BTAO-src-6.5.20.zip -zip-md5=5050fb0a2b97ad32be553102bb85b5ce -tar.gz-filename=ACE+TAO-src-6.5.20.tar.gz -tar.gz-url=https://github.com/DOCGroup/ACE_TAO/releases/download/ACE%2BTAO-6_5_20/ACE%2BTAO-src-6.5.20.tar.gz -tar.gz-md5=10cd636115d7463d96dd1bcb645b8b36 -tar.bz2-filename=ACE+TAO-src-6.5.20.tar.bz2 -tar.bz2-url=https://github.com/DOCGroup/ACE_TAO/releases/download/ACE%2BTAO-6_5_20/ACE%2BTAO-src-6.5.20.tar.bz2 -tar.bz2-md5=2551d7d445456bcb316fe5e9a4b514ea +url=https://github.com/DOCGroup/ACE_TAO/releases/tag/ACE%2BTAO-6_5_21 +zip-filename=ACE+TAO-src-6.5.21.zip +zip-url=https://github.com/DOCGroup/ACE_TAO/releases/download/ACE%2BTAO-6_5_21/ACE%2BTAO-src-6.5.21.zip +zip-md5=6c3f14102768819c2082273be309e366 +tar.gz-filename=ACE+TAO-src-6.5.21.tar.gz +tar.gz-url=https://github.com/DOCGroup/ACE_TAO/releases/download/ACE%2BTAO-6_5_21/ACE%2BTAO-src-6.5.21.tar.gz +tar.gz-md5=c8b028c4d6b253d35dddf01332d7de10 +tar.bz2-filename=ACE+TAO-src-6.5.21.tar.bz2 +tar.bz2-url=https://github.com/DOCGroup/ACE_TAO/releases/download/ACE%2BTAO-6_5_21/ACE%2BTAO-src-6.5.21.tar.bz2 +tar.bz2-md5=7b04201352aefa4cdd3938adef86cde6 [ace7tao3] hold=1 diff --git a/docs/news.d/automated-update-ace6tao2.rst b/docs/news.d/automated-update-ace6tao2.rst new file mode 100644 index 00000000000..3f49058ab42 --- /dev/null +++ b/docs/news.d/automated-update-ace6tao2.rst @@ -0,0 +1,9 @@ +# This file was generated by tools/scripts/gitrelease.pl. It can be edited, but +# if there is another release for ace6tao2, the automated PR +# will overwrite this file. +.. news-prs: none +.. news-start-section: Platform Support and Dependencies +.. news-start-section: ACE/TAO +- Updated ACE 6/TAO 2 from 6.5.20 to `6.5.21 `__. +.. news-end-section +.. news-end-section From fdb4f2775dde2153340d708762ca3ed338407be6 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Mon, 20 May 2024 16:04:17 -0500 Subject: [PATCH 28/60] macos-11 runners are going away Problem ------- The macos-11 GHA runners are going away. Solution -------- Upgrade to macos-13. --- .github/workflows/build_and_test.yml | 82 ++++++++++++++-------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index bf05639186c..d436ed6bc8a 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -12040,11 +12040,11 @@ jobs: cat "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" grep -q 'Failures: 0' "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" - # macOS 11.0 + # macOS 13 - ACE_TAO_m11_sec: + ACE_TAO_m13_sec: - runs-on: macos-11.0 + runs-on: macos-13 steps: - name: checkout OpenDDS @@ -12121,11 +12121,11 @@ jobs: name: ${{ github.job }}_artifact path: ${{ github.job }}.tar.xz - build_m11_sec: + build_m13_sec: - runs-on: macos-11.0 + runs-on: macos-13 - needs: ACE_TAO_m11_sec + needs: ACE_TAO_m13_sec steps: - name: install xerces-c @@ -12145,13 +12145,13 @@ jobs: - name: download ACE_TAO artifact uses: actions/download-artifact@v4 with: - name: ACE_TAO_m11_sec_artifact + name: ACE_TAO_m13_sec_artifact path: ACE_TAO - name: extract ACE_TAO artifact shell: bash run: | cd ACE_TAO - gtar xvfJ ACE_TAO_m11_sec.tar.xz + gtar xvfJ ACE_TAO_m13_sec.tar.xz - name: checkout OpenDDS uses: actions/checkout@v4 with: @@ -12197,11 +12197,11 @@ jobs: name: ${{ github.job }}_artifact path: ${{ github.job }}.tar.xz - test_m11_sec: + test_m13_sec: - runs-on: macos-11.0 + runs-on: macos-13 - needs: build_m11_sec + needs: build_m13_sec permissions: contents: read @@ -12230,13 +12230,13 @@ jobs: - name: download ACE_TAO artifact uses: actions/download-artifact@v4 with: - name: ACE_TAO_m11_sec_artifact + name: ACE_TAO_m13_sec_artifact path: ACE_TAO - name: extract ACE_TAO artifact shell: bash run: | cd ACE_TAO - gtar xvfJ ACE_TAO_m11_sec.tar.xz + gtar xvfJ ACE_TAO_m13_sec.tar.xz - name: checkout OpenDDS uses: actions/checkout@v4 with: @@ -12245,13 +12245,13 @@ jobs: - name: download OpenDDS artifact uses: actions/download-artifact@v4 with: - name: build_m11_sec_artifact + name: build_m13_sec_artifact path: OpenDDS - name: extract OpenDDS artifact shell: bash run: | cd OpenDDS - gtar xvfJ build_m11_sec.tar.xz + gtar xvfJ build_m13_sec.tar.xz - name: check build configuration shell: bash run: | @@ -12316,11 +12316,11 @@ jobs: cat "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" grep -q 'Failures: 0' "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" - cmake_m11_sec: + cmake_m13_sec: - runs-on: macos-11.0 + runs-on: macos-13 - needs: build_m11_sec + needs: build_m13_sec permissions: contents: read @@ -12349,13 +12349,13 @@ jobs: - name: download ACE_TAO artifact uses: actions/download-artifact@v4 with: - name: ACE_TAO_m11_sec_artifact + name: ACE_TAO_m13_sec_artifact path: ACE_TAO - name: extract ACE_TAO artifact shell: bash run: | cd ACE_TAO - gtar xvfJ ACE_TAO_m11_sec.tar.xz + gtar xvfJ ACE_TAO_m13_sec.tar.xz - name: checkout OpenDDS uses: actions/checkout@v4 with: @@ -12364,13 +12364,13 @@ jobs: - name: download OpenDDS artifact uses: actions/download-artifact@v4 with: - name: build_m11_sec_artifact + name: build_m13_sec_artifact path: OpenDDS - name: extract OpenDDS artifact shell: bash run: | cd OpenDDS - gtar xvfJ build_m11_sec.tar.xz + gtar xvfJ build_m13_sec.tar.xz - name: check build configuration shell: bash run: | @@ -12435,11 +12435,11 @@ jobs: cat "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" grep -q 'Failures: 0' "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" - build_m11_j_FM-1f: + build_m13_j_FM-1f: - runs-on: macos-11.0 + runs-on: macos-13 - needs: ACE_TAO_m11_sec + needs: ACE_TAO_m13_sec steps: - name: install xerces-c @@ -12459,13 +12459,13 @@ jobs: - name: download ACE_TAO artifact uses: actions/download-artifact@v4 with: - name: ACE_TAO_m11_sec_artifact + name: ACE_TAO_m13_sec_artifact path: ACE_TAO - name: extract ACE_TAO artifact shell: bash run: | cd ACE_TAO - gtar xvfJ ACE_TAO_m11_sec.tar.xz + gtar xvfJ ACE_TAO_m13_sec.tar.xz - name: checkout OpenDDS uses: actions/checkout@v4 with: @@ -12525,11 +12525,11 @@ jobs: name: ${{ github.job }}_artifact path: ${{ github.job }}.tar.xz - test_m11_j_FM-1f: + test_m13_j_FM-1f: - runs-on: macos-11.0 + runs-on: macos-13 - needs: build_m11_j_FM-1f + needs: build_m13_j_FM-1f permissions: contents: read @@ -12558,13 +12558,13 @@ jobs: - name: download ACE_TAO artifact uses: actions/download-artifact@v4 with: - name: ACE_TAO_m11_sec_artifact + name: ACE_TAO_m13_sec_artifact path: ACE_TAO - name: extract ACE_TAO artifact shell: bash run: | cd ACE_TAO - gtar xvfJ ACE_TAO_m11_sec.tar.xz + gtar xvfJ ACE_TAO_m13_sec.tar.xz - name: checkout OpenDDS uses: actions/checkout@v4 with: @@ -12573,13 +12573,13 @@ jobs: - name: download OpenDDS artifact uses: actions/download-artifact@v4 with: - name: build_m11_j_FM-1f_artifact + name: build_m13_j_FM-1f_artifact path: OpenDDS - name: extract OpenDDS artifact shell: bash run: | cd OpenDDS - gtar xvfJ build_m11_j_FM-1f.tar.xz + gtar xvfJ build_m13_j_FM-1f.tar.xz - name: check build configuration shell: bash run: | @@ -12644,11 +12644,11 @@ jobs: cat "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" grep -q 'Failures: 0' "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" - cmake_modeling_m11_j_FM-1f: + cmake_modeling_m13_j_FM-1f: - runs-on: macos-11.0 + runs-on: macos-13 - needs: build_m11_j_FM-1f + needs: build_m13_j_FM-1f permissions: contents: read @@ -12677,13 +12677,13 @@ jobs: - name: download ACE_TAO artifact uses: actions/download-artifact@v4 with: - name: ACE_TAO_m11_sec_artifact + name: ACE_TAO_m13_sec_artifact path: ACE_TAO - name: extract ACE_TAO artifact shell: bash run: | cd ACE_TAO - gtar xvfJ ACE_TAO_m11_sec.tar.xz + gtar xvfJ ACE_TAO_m13_sec.tar.xz - name: checkout OpenDDS uses: actions/checkout@v4 with: @@ -12692,13 +12692,13 @@ jobs: - name: download OpenDDS artifact uses: actions/download-artifact@v4 with: - name: build_m11_j_FM-1f_artifact + name: build_m13_j_FM-1f_artifact path: OpenDDS - name: extract OpenDDS artifact shell: bash run: | cd OpenDDS - gtar xvfJ build_m11_j_FM-1f.tar.xz + gtar xvfJ build_m13_j_FM-1f.tar.xz - name: check build configuration shell: bash run: | From b4a030ce29949c7ab3efd83e6281bd7ff9fe4627 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 21 May 2024 09:55:51 -0500 Subject: [PATCH 29/60] More Predictable Port Usage in RTPS - Added `SedpPortMode=probe` to make it make it possible to predict what ports the unicast SEDP sockets use. - Added `SpdpPortMode` which deprecates `SpdpRequestRandomPort`. - Added `SpdpMulticastAddress`, `Ipv4SpdpMulticastAddress`, `SedpMulticastAddress`, and `Ipv4SedpMulticastAddress` to set the multicast addresses and ports separately on SPDP and SEDP. - Calculated ports are now checked if they would overflow. - Remove need for sentinel in `EnumList` arrays for `ConfigStore`. --- dds/DCPS/ConfigStoreImpl.h | 20 +- dds/DCPS/NetworkAddress.cpp | 1 - dds/DCPS/RTPS/MessageUtils.cpp | 39 ++ dds/DCPS/RTPS/MessageUtils.h | 32 ++ dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp | 319 +++++++++--- dds/DCPS/RTPS/RtpsDiscoveryConfig.h | 64 ++- dds/DCPS/RTPS/Sedp.cpp | 39 +- dds/DCPS/RTPS/Sedp.h | 4 + dds/DCPS/RTPS/Spdp.cpp | 286 +++++------ dds/DCPS/RTPS/Spdp.h | 13 +- dds/DCPS/Service_Participant.cpp | 3 +- dds/DCPS/StaticDiscovery.cpp | 27 +- docs/devguide/run_time_configuration.rst | 4 +- tests/Utils/GtestRc.h | 30 +- tests/unit-tests/dds/DCPS/ConfigStoreImpl.cpp | 3 +- .../dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp | 477 ++++++++++++++++++ 16 files changed, 1061 insertions(+), 300 deletions(-) create mode 100644 tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp diff --git a/dds/DCPS/ConfigStoreImpl.h b/dds/DCPS/ConfigStoreImpl.h index 29ddb7948aa..8b04356325d 100644 --- a/dds/DCPS/ConfigStoreImpl.h +++ b/dds/DCPS/ConfigStoreImpl.h @@ -166,14 +166,14 @@ class OpenDDS_Dcps_Export ConfigStoreImpl : public ConfigStore { StringList get(const char* key, const StringList& value) const; - template + template T get(const char* key, T value, - const EnumList decoder[]) + const EnumList (&decoder)[count]) { bool found = false; String value_as_string; - for (size_t idx = 0; decoder[idx].name; ++idx) { + for (size_t idx = 0; idx < count; ++idx) { if (decoder[idx].value == value) { value_as_string = decoder[idx].name; found = true; @@ -188,7 +188,7 @@ class OpenDDS_Dcps_Export ConfigStoreImpl : public ConfigStore { } const String actual = get(key, value_as_string); - for (size_t idx = 0; decoder[idx].name; ++idx) { + for (size_t idx = 0; idx < count; ++idx) { if (decoder[idx].name == actual) { return decoder[idx].value; } @@ -204,14 +204,14 @@ class OpenDDS_Dcps_Export ConfigStoreImpl : public ConfigStore { return value; } - template + template void set(const char* key, T value, - const EnumList decoder[]) + const EnumList (&decoder)[count]) { bool found = false; String value_as_string; - for (size_t idx = 0; decoder[idx].name; ++idx) { + for (size_t idx = 0; idx < count; ++idx) { if (decoder[idx].value == value) { value_as_string = decoder[idx].name; found = true; @@ -232,15 +232,15 @@ class OpenDDS_Dcps_Export ConfigStoreImpl : public ConfigStore { set(key, value_as_string); } - template + template void set(const char* key, const String& value, - const EnumList decoder[]) + const EnumList (&decoder)[count]) { bool found = false; // Sanity check. String value_as_string; - for (size_t idx = 0; decoder[idx].name; ++idx) { + for (size_t idx = 0; idx < count; ++idx) { if (value == decoder[idx].name) { set(key, value); found = true; diff --git a/dds/DCPS/NetworkAddress.cpp b/dds/DCPS/NetworkAddress.cpp index 891dd65fb5f..e9db61ef83b 100644 --- a/dds/DCPS/NetworkAddress.cpp +++ b/dds/DCPS/NetworkAddress.cpp @@ -8,7 +8,6 @@ #include "NetworkAddress.h" #include "Hash.h" -#include "LogAddr.h" #include diff --git a/dds/DCPS/RTPS/MessageUtils.cpp b/dds/DCPS/RTPS/MessageUtils.cpp index 2a661333682..6802fd9fce9 100644 --- a/dds/DCPS/RTPS/MessageUtils.cpp +++ b/dds/DCPS/RTPS/MessageUtils.cpp @@ -8,6 +8,8 @@ #include "MessageTypes.h" #include +#include + #include OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL @@ -16,6 +18,8 @@ namespace OpenDDS { namespace RTPS { using DCPS::Encoding; +using DCPS::LogLevel; +using DCPS::log_level; const DCPS::Encoding& get_locators_encoding() { @@ -134,6 +138,41 @@ bool bitmapNonEmpty(const SequenceNumberSet& snSet) return (bool)(snSet.bitmap[last_index] & mask); } +bool get_rtps_port(DDS::UInt16& port_result, const char* what, + DDS::UInt16 port_base, DDS::UInt16 offset, + DDS::UInt16 domain, DDS::UInt16 domain_gain, + DDS::UInt16 part, DDS::UInt16 part_gain) +{ + const DDS::UInt32 port = static_cast(port_base) + + domain * domain_gain + part * part_gain + offset; + ACE_DEBUG((LM_DEBUG, "HERE %C %u + %u * %u + %u * %u + %u = %u\n", what, port_base, domain, domain_gain, part, part_gain, offset, port)); + if (port > 65535) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: rtps_port: %C port %u is too high\n", what, port)); + } + return false; + } + port_result = static_cast(port); + return true; +} + +namespace { + const DCPS::EnumList port_modes[] = { + {PortMode_System, "system"}, + {PortMode_Probe, "probe"} + }; +}; + +PortMode get_port_mode(const String& key, PortMode default_value) +{ + return TheServiceParticipant->config_store()->get(key.c_str(), default_value, port_modes); +} + +void set_port_mode(const String& key, PortMode value) +{ + TheServiceParticipant->config_store()->set(key.c_str(), value, port_modes); +} + } } diff --git a/dds/DCPS/RTPS/MessageUtils.h b/dds/DCPS/RTPS/MessageUtils.h index 0cb42274bb6..d52b550c659 100644 --- a/dds/DCPS/RTPS/MessageUtils.h +++ b/dds/DCPS/RTPS/MessageUtils.h @@ -237,6 +237,38 @@ handle_to_octets(DDS::Security::NativeCryptoHandle handle) } #endif +// Default values for spec-defined parameters for determining what ports RTPS +// uses. +const DDS::UInt16 default_port_base = 7400; // (PB) +const DDS::UInt16 default_domain_gain = 250; // (DG) +const DDS::UInt16 default_part_gain = 2; // (PG) +const DDS::UInt16 default_spdp_multicast_offset = 0; // (D0) +const DDS::UInt16 default_spdp_unicast_offset = 10; // (D1) +const DDS::UInt16 default_user_multicast_offset = 1; // (D2) +const DDS::UInt16 default_user_unicast_offset = 11; // (D3) + +// Default values for OpenDDS-specific parameters for determining what ports +// RTPS uses. +const DDS::UInt16 default_sedp_multicast_offset = 2; // (DX) +const DDS::UInt16 default_sedp_unicast_offset = 12; // (DY) + +OpenDDS_Rtps_Export +bool get_rtps_port(DDS::UInt16& port_result, const char* what, + DDS::UInt16 port_base, DDS::UInt16 offset, + DDS::UInt16 domain, DDS::UInt16 domain_gain, + DDS::UInt16 part = 0, DDS::UInt16 part_gain = 0); + +enum PortMode { + PortMode_System, + PortMode_Probe +}; + +OpenDDS_Rtps_Export +PortMode get_port_mode(const String& key, PortMode default_value); + +OpenDDS_Rtps_Export +void set_port_mode(const String& key, PortMode value); + } // namespace RTPS } // namespace OpenDDS diff --git a/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp b/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp index 033ab4725b6..1daf01715a8 100644 --- a/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp +++ b/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp @@ -7,19 +7,6 @@ #include -namespace { - u_short get_default_d0(u_short fallback) - { -#if !defined ACE_LACKS_GETENV && !defined ACE_LACKS_ENV - const char* from_env = std::getenv("OPENDDS_RTPS_DEFAULT_D0"); - if (from_env) { - return static_cast(std::atoi(from_env)); - } -#endif - return fallback; - } -} - OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { @@ -164,93 +151,164 @@ RtpsDiscoveryConfig::lease_extension(const DCPS::TimeDuration& period) DCPS::ConfigStoreImpl::Format_IntegerSeconds); } -u_short +PortMode RtpsDiscoveryConfig::spdp_port_mode() const +{ + // TODO: Deprecated, remove in OpenDDS 4 + const bool request_random_port = TheServiceParticipant->config_store()->get_boolean( + config_key("SPDP_REQUEST_RANDOM_PORT").c_str(), false); + return get_port_mode(config_key("SPDP_PORT_MODE"), + request_random_port ? PortMode_System : PortMode_Probe); +} + +void RtpsDiscoveryConfig::spdp_port_mode(PortMode value) +{ + set_port_mode(config_key("SPDP_PORT_MODE"), value); +} + +bool +RtpsDiscoveryConfig::spdp_request_random_port() const +{ + return spdp_port_mode() == PortMode_System; +} + +void +RtpsDiscoveryConfig::spdp_request_random_port(bool f) +{ + spdp_port_mode(f ? PortMode_System : PortMode_Probe); +} + +PortMode RtpsDiscoveryConfig::sedp_port_mode() const +{ + return get_port_mode(config_key("SEDP_PORT_MODE"), PortMode_System); +} + +void RtpsDiscoveryConfig::sedp_port_mode(PortMode value) +{ + set_port_mode(config_key("SEDP_PORT_MODE"), value); +} + +DDS::UInt16 RtpsDiscoveryConfig::pb() const { - // see RTPS v2.1 9.6.1.3 for PB, DG, PG, D0, D1 defaults return TheServiceParticipant->config_store()->get_uint32(config_key("PB").c_str(), - 7400); + default_port_base); } void -RtpsDiscoveryConfig::pb(u_short port_base) +RtpsDiscoveryConfig::pb(DDS::UInt16 port_base) { TheServiceParticipant->config_store()->set_uint32(config_key("PB").c_str(), port_base); } -u_short +DDS::UInt16 RtpsDiscoveryConfig::dg() const { - // see RTPS v2.1 9.6.1.3 for PB, DG, PG, D0, D1 defaults return TheServiceParticipant->config_store()->get_uint32(config_key("DG").c_str(), - 250); + default_domain_gain); } void -RtpsDiscoveryConfig::dg(u_short domain_gain) +RtpsDiscoveryConfig::dg(DDS::UInt16 domain_gain) { TheServiceParticipant->config_store()->set_uint32(config_key("DG").c_str(), domain_gain); } -u_short +DDS::UInt16 RtpsDiscoveryConfig::pg() const { - // see RTPS v2.1 9.6.1.3 for PB, DG, PG, D0, D1 defaults return TheServiceParticipant->config_store()->get_uint32(config_key("PG").c_str(), - 2); + default_part_gain); } void -RtpsDiscoveryConfig::pg(u_short participant_gain) +RtpsDiscoveryConfig::pg(DDS::UInt16 participant_gain) { TheServiceParticipant->config_store()->set_uint32(config_key("PG").c_str(), participant_gain); } -u_short +DDS::UInt16 RtpsDiscoveryConfig::d0() const { - // see RTPS v2.1 9.6.1.3 for PB, DG, PG, D0, D1 defaults + DDS::UInt16 default_value = 0; +#if !defined ACE_LACKS_GETENV && !defined ACE_LACKS_ENV + const char* const from_env = ACE_OS::getenv("OPENDDS_RTPS_DEFAULT_D0"); + if (from_env) { + default_value = static_cast(std::atoi(from_env)); + } +#endif return TheServiceParticipant->config_store()->get_uint32(config_key("D0").c_str(), - get_default_d0(0)); + default_value); } void -RtpsDiscoveryConfig::d0(u_short offset_zero) +RtpsDiscoveryConfig::d0(DDS::UInt16 spdp_multicast_offset) { TheServiceParticipant->config_store()->set_uint32(config_key("D0").c_str(), - offset_zero); + spdp_multicast_offset); } -u_short +DDS::UInt16 RtpsDiscoveryConfig::d1() const { - // see RTPS v2.1 9.6.1.3 for PB, DG, PG, D0, D1 defaults return TheServiceParticipant->config_store()->get_uint32(config_key("D1").c_str(), - 10); + default_spdp_unicast_offset); } void -RtpsDiscoveryConfig::d1(u_short offset_one) +RtpsDiscoveryConfig::d1(DDS::UInt16 spdp_unicast_offset) { TheServiceParticipant->config_store()->set_uint32(config_key("D1").c_str(), - offset_one); + spdp_unicast_offset); } - -u_short +DDS::UInt16 RtpsDiscoveryConfig::dx() const { return TheServiceParticipant->config_store()->get_uint32(config_key("DX").c_str(), - 2); + default_sedp_multicast_offset); } void -RtpsDiscoveryConfig::dx(u_short offset_two) +RtpsDiscoveryConfig::dx(DDS::UInt16 sedp_multicast_offset) { TheServiceParticipant->config_store()->set_uint32(config_key("DX").c_str(), - offset_two); + sedp_multicast_offset); +} + +DDS::UInt16 +RtpsDiscoveryConfig::dy() const +{ + return TheServiceParticipant->config_store()->get_uint32(config_key("DY").c_str(), + default_sedp_unicast_offset); +} + +void +RtpsDiscoveryConfig::dy(DDS::UInt16 sedp_unicast_offset) +{ + TheServiceParticipant->config_store()->set_uint32(config_key("DY").c_str(), + sedp_unicast_offset); +} + +bool RtpsDiscoveryConfig::spdp_multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const +{ + return get_rtps_port(port, "SPDP multicast", pb(), d0(), domain, dg()); +} + +bool RtpsDiscoveryConfig::spdp_unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const +{ + return get_rtps_port(port, "SPDP unicast", pb(), d1(), domain, dg(), part, pg()); +} + +bool RtpsDiscoveryConfig::sedp_multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const +{ + return get_rtps_port(port, "SEDP multicast", pb(), dx(), domain, dg()); +} + +bool RtpsDiscoveryConfig::sedp_unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const +{ + return get_rtps_port(port, "SEDP unicast", pb(), dy(), domain, dg(), part, pg()); } unsigned char @@ -327,6 +385,20 @@ RtpsDiscoveryConfig::sedp_local_address() const DCPS::ConfigStoreImpl::Kind_IPV4); } +bool RtpsDiscoveryConfig::sedp_unicast_address( + DCPS::NetworkAddress& addr, DDS::DomainId_t domain, DDS::UInt16 part_id) const +{ + addr = sedp_local_address(); + if (addr.get_port_number() == 0 && sedp_port_mode() == PortMode_Probe) { + DDS::UInt16 port = 0; + if (!sedp_unicast_port(port, domain, part_id)) { + return false; + } + addr.set_port_number(port); + } + return true; +} + void RtpsDiscoveryConfig::sedp_local_address(const DCPS::NetworkAddress& mi) { @@ -372,6 +444,21 @@ RtpsDiscoveryConfig::spdp_local_address(const DCPS::NetworkAddress& mi) DCPS::ConfigStoreImpl::Kind_IPV4); } +bool RtpsDiscoveryConfig::spdp_unicast_address(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const +{ + addr = spdp_local_address(); + fixed_port = addr.get_port_number() > 0; + if (!fixed_port && spdp_port_mode() == PortMode_Probe) { + DDS::UInt16 port = 0; + if (!spdp_unicast_port(port, domain, part_id)) { + return false; + } + addr.set_port_number(port); + } + return true; +} + OPENDDS_STRING RtpsDiscoveryConfig::multicast_interface() const { @@ -444,21 +531,58 @@ RtpsDiscoveryConfig::default_multicast_group(const DCPS::NetworkAddress& group) DCPS::ConfigStoreImpl::Kind_IPV4); } -u_short -RtpsDiscoveryConfig::port_common(DDS::DomainId_t domain) const +bool RtpsDiscoveryConfig::spdp_multicast_address( + DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const { - // Ports are set by the formulas in RTPS v2.1 Table 9.8 - return pb() + (dg() * domain); + addr = TheServiceParticipant->config_store()->get( + config_key("SPDP_MULTICAST_ADDRESS").c_str(), + default_multicast_group(domain), + DCPS::ConfigStoreImpl::Format_Optional_Port, + DCPS::ConfigStoreImpl::Kind_IPV4); + + if (addr.get_port_number() == 0) { + DDS::UInt16 port; + if (!spdp_multicast_port(port, domain)) { + return false; + } + addr.set_port_number(port); + } + return true; } -DCPS::NetworkAddress -RtpsDiscoveryConfig::multicast_address(u_short port_common, - DDS::DomainId_t domain) const +void RtpsDiscoveryConfig::spdp_multicast_address(const DCPS::NetworkAddress& addr) +{ + TheServiceParticipant->config_store()->set(config_key("SPDP_MULTICAST_ADDRESS").c_str(), + addr, + DCPS::ConfigStoreImpl::Format_Optional_Port, + DCPS::ConfigStoreImpl::Kind_IPV4); +} + +bool RtpsDiscoveryConfig::sedp_multicast_address( + DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const { - DCPS::NetworkAddress addr = default_multicast_group(domain); - // Ports are set by the formulas in RTPS v2.1 Table 9.8 - addr.set_port_number(port_common + d0()); - return addr; + addr = TheServiceParticipant->config_store()->get( + config_key("SEDP_MULTICAST_ADDRESS").c_str(), + default_multicast_group(domain), + DCPS::ConfigStoreImpl::Format_Optional_Port, + DCPS::ConfigStoreImpl::Kind_IPV4); + + if (addr.get_port_number() == 0) { + DDS::UInt16 port; + if (!sedp_multicast_port(port, domain)) { + return false; + } + addr.set_port_number(port); + } + return true; +} + +void RtpsDiscoveryConfig::sedp_multicast_address(const DCPS::NetworkAddress& addr) +{ + TheServiceParticipant->config_store()->set(config_key("SEDP_MULTICAST_ADDRESS").c_str(), + addr, + DCPS::ConfigStoreImpl::Format_Optional_Port, + DCPS::ConfigStoreImpl::Kind_IPV4); } #ifdef ACE_HAS_IPV6 @@ -480,6 +604,23 @@ RtpsDiscoveryConfig::ipv6_spdp_local_address(const DCPS::NetworkAddress& mi) DCPS::ConfigStoreImpl::Kind_IPV6); } +bool RtpsDiscoveryConfig::ipv6_spdp_unicast_address(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const +{ + addr = ipv6_spdp_local_address(); + fixed_port = addr.get_port_number() > 0; + if (!fixed_port) { + if (spdp_port_mode() == PortMode_Probe) { + DDS::UInt16 port = 0; + if (!spdp_unicast_port(port, domain, part_id)) { + return false; + } + addr.set_port_number(port); + } + } + return true; +} + DCPS::NetworkAddress RtpsDiscoveryConfig::ipv6_sedp_local_address() const { @@ -498,6 +639,22 @@ RtpsDiscoveryConfig::ipv6_sedp_local_address(const DCPS::NetworkAddress& mi) DCPS::ConfigStoreImpl::Kind_IPV6); } +bool RtpsDiscoveryConfig::ipv6_sedp_unicast_address( + DCPS::NetworkAddress& addr, DDS::DomainId_t domain, DDS::UInt16 part_id) const +{ + addr = ipv6_sedp_local_address(); + if (addr.get_port_number() == 0) { + if (sedp_port_mode() == PortMode_Probe) { + DDS::UInt16 port = 0; + if (!sedp_unicast_port(port, domain, part_id)) { + return false; + } + addr.set_port_number(port); + } + } + return true; +} + DCPS::NetworkAddress RtpsDiscoveryConfig::ipv6_sedp_advertised_local_address() const { @@ -534,30 +691,60 @@ RtpsDiscoveryConfig::ipv6_default_multicast_group(const DCPS::NetworkAddress& gr DCPS::ConfigStoreImpl::Kind_IPV6); } -DCPS::NetworkAddress -RtpsDiscoveryConfig::ipv6_multicast_address(u_short port_common) const +bool RtpsDiscoveryConfig::ipv6_spdp_multicast_address( + DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const { - DCPS::NetworkAddress addr = ipv6_default_multicast_group(); - // Ports are set by the formulas in RTPS v2.1 Table 9.8 - addr.set_port_number(port_common + d0()); - return addr; + addr = TheServiceParticipant->config_store()->get( + config_key("IPV6_SPDP_MULTICAST_ADDRESS").c_str(), + ipv6_default_multicast_group(domain), + DCPS::ConfigStoreImpl::Format_Optional_Port, + DCPS::ConfigStoreImpl::Kind_IPV6); + + if (addr.get_port_number() == 0) { + DDS::UInt16 port; + if (!spdp_multicast_port(port, domain)) { + return false; + } + addr.set_port_number(port); + } + return true; } -#endif +void RtpsDiscoveryConfig::ipv6_spdp_multicast_address(const DCPS::NetworkAddress& addr) +{ + TheServiceParticipant->config_store()->set(config_key("IPV6_SPDP_MULTICAST_ADDRESS").c_str(), + addr, + DCPS::ConfigStoreImpl::Format_Optional_Port, + DCPS::ConfigStoreImpl::Kind_IPV6); +} -bool -RtpsDiscoveryConfig::spdp_request_random_port() const +bool RtpsDiscoveryConfig::ipv6_sedp_multicast_address( + DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const { - return TheServiceParticipant->config_store()->get_boolean(config_key("SPDP_REQUEST_RANDOM_PORT").c_str(), - false); + addr = TheServiceParticipant->config_store()->get( + config_key("IPV6_SEDP_MULTICAST_ADDRESS").c_str(), + ipv6_default_multicast_group(domain), + DCPS::ConfigStoreImpl::Format_Optional_Port, + DCPS::ConfigStoreImpl::Kind_IPV6); + + if (addr.get_port_number() == 0) { + DDS::UInt16 port; + if (!sedp_multicast_port(port, domain)) { + return false; + } + addr.set_port_number(port); + } + return true; } -void -RtpsDiscoveryConfig::spdp_request_random_port(bool f) +void RtpsDiscoveryConfig::ipv6_sedp_multicast_address(const DCPS::NetworkAddress& addr) { - TheServiceParticipant->config_store()->set_boolean(config_key("SPDP_REQUEST_RANDOM_PORT").c_str(), - f); + TheServiceParticipant->config_store()->set(config_key("IPV6_SEDP_MULTICAST_ADDRESS").c_str(), + addr, + DCPS::ConfigStoreImpl::Format_Optional_Port, + DCPS::ConfigStoreImpl::Kind_IPV6); } +#endif OPENDDS_STRING RtpsDiscoveryConfig::guid_interface() const diff --git a/dds/DCPS/RTPS/RtpsDiscoveryConfig.h b/dds/DCPS/RTPS/RtpsDiscoveryConfig.h index 06ddba26f1b..b4b248e2228 100644 --- a/dds/DCPS/RTPS/RtpsDiscoveryConfig.h +++ b/dds/DCPS/RTPS/RtpsDiscoveryConfig.h @@ -59,23 +59,37 @@ class OpenDDS_Rtps_Export RtpsDiscoveryConfig : public OpenDDS::DCPS::RcObject { DCPS::TimeDuration lease_extension() const; void lease_extension(const DCPS::TimeDuration& period); - u_short pb() const; - void pb(u_short port_base); + PortMode spdp_port_mode() const; + void spdp_port_mode(PortMode value); - u_short dg() const; - void dg(u_short domain_gain); + PortMode sedp_port_mode() const; + void sedp_port_mode(PortMode value); - u_short pg() const; - void pg(u_short participant_gain); + DDS::UInt16 pb() const; + void pb(DDS::UInt16 port_base); - u_short d0() const; - void d0(u_short offset_zero); + DDS::UInt16 dg() const; + void dg(DDS::UInt16 domain_gain); - u_short d1() const; - void d1(u_short offset_one); + DDS::UInt16 pg() const; + void pg(DDS::UInt16 participant_gain); - u_short dx() const; - void dx(u_short offset_two); + DDS::UInt16 d0() const; + void d0(DDS::UInt16 spdp_multicast_offset); + + DDS::UInt16 d1() const; + void d1(DDS::UInt16 spdp_unicast_offset); + + DDS::UInt16 dx() const; + void dx(DDS::UInt16 sedp_multicast_offset); + + DDS::UInt16 dy() const; + void dy(DDS::UInt16 sedp_unicast_offset); + + bool spdp_multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const; + bool spdp_unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const; + bool sedp_multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const; + bool sedp_unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const; unsigned char ttl() const; void ttl(unsigned char time_to_live); @@ -89,12 +103,18 @@ class OpenDDS_Rtps_Export RtpsDiscoveryConfig : public OpenDDS::DCPS::RcObject { DCPS::NetworkAddress sedp_local_address() const; void sedp_local_address(const DCPS::NetworkAddress& mi); + bool sedp_unicast_address( + DCPS::NetworkAddress& addr, DDS::DomainId_t domain, DDS::UInt16 part_id) const; + DCPS::NetworkAddress sedp_advertised_local_address() const; void sedp_advertised_local_address(const DCPS::NetworkAddress& mi); DCPS::NetworkAddress spdp_local_address() const; void spdp_local_address(const DCPS::NetworkAddress& mi); + bool spdp_unicast_address(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const; + bool sedp_multicast() const; void sedp_multicast(bool sm); @@ -104,27 +124,39 @@ class OpenDDS_Rtps_Export RtpsDiscoveryConfig : public OpenDDS::DCPS::RcObject { DCPS::NetworkAddress default_multicast_group(DDS::DomainId_t domain) const; void default_multicast_group(const DCPS::NetworkAddress& group); - u_short port_common(DDS::DomainId_t domain) const; + bool spdp_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; + void spdp_multicast_address(const DCPS::NetworkAddress& addr); - DCPS::NetworkAddress multicast_address(u_short port_common, - DDS::DomainId_t domain) const; + bool sedp_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; + void sedp_multicast_address(const DCPS::NetworkAddress& addr); #ifdef ACE_HAS_IPV6 DCPS::NetworkAddress ipv6_spdp_local_address() const; void ipv6_spdp_local_address(const DCPS::NetworkAddress& mi); + bool ipv6_spdp_unicast_address(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const; + DCPS::NetworkAddress ipv6_sedp_local_address() const; void ipv6_sedp_local_address(const DCPS::NetworkAddress& mi); + bool ipv6_sedp_unicast_address( + DCPS::NetworkAddress& addr, DDS::DomainId_t domain, DDS::UInt16 part_id) const; + DCPS::NetworkAddress ipv6_sedp_advertised_local_address() const; void ipv6_sedp_advertised_local_address(const DCPS::NetworkAddress& mi); DCPS::NetworkAddress ipv6_default_multicast_group() const; void ipv6_default_multicast_group(const DCPS::NetworkAddress& group); - DCPS::NetworkAddress ipv6_multicast_address(u_short port_common) const; + bool ipv6_spdp_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; + void ipv6_spdp_multicast_address(const DCPS::NetworkAddress& addr); + + bool ipv6_sedp_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; + void ipv6_sedp_multicast_address(const DCPS::NetworkAddress& addr); #endif + // TODO: Deprecated, remove in OpenDDS 4 bool spdp_request_random_port() const; void spdp_request_random_port(bool f); diff --git a/dds/DCPS/RTPS/Sedp.cpp b/dds/DCPS/RTPS/Sedp.cpp index 06daad3e49c..6f64c38492c 100644 --- a/dds/DCPS/RTPS/Sedp.cpp +++ b/dds/DCPS/RTPS/Sedp.cpp @@ -401,6 +401,10 @@ DDS::ReturnCode_t Sedp::init(const GUID_t& guid, const RtpsDiscovery& disco, DDS::DomainId_t domainId, + DDS::UInt16 ipv4_participant_port_id, +#ifdef ACE_HAS_IPV6 + DDS::UInt16 ipv6_participant_port_id, +#endif XTypes::TypeLookupService_rch tls) { type_lookup_service_ = tls; @@ -434,40 +438,45 @@ Sedp::init(const GUID_t& guid, transport_inst_->receive_preallocated_message_blocks(disco.config()->sedp_receive_preallocated_message_blocks()); transport_inst_->receive_preallocated_data_blocks(disco.config()->sedp_receive_preallocated_data_blocks()); - if (disco.sedp_multicast()) { - config_store_->set_boolean(transport_inst_->config_key("USE_MULTICAST").c_str(), true); - - // Bind to a specific multicast group - const u_short mc_port = disco.pb() + disco.dg() * domainId + disco.dx(); - - DCPS::NetworkAddress mc_addr = disco.default_multicast_group(domainId); - mc_addr.set_port_number(mc_port); + const bool sedp_multicast = disco.sedp_multicast(); + config_store_->set_boolean(transport_inst_->config_key("USE_MULTICAST").c_str(), sedp_multicast); + if (sedp_multicast) { + DCPS::NetworkAddress mc_addr; + if (!disco.config()->sedp_multicast_address(mc_addr, domainId)) { + return DDS::RETCODE_ERROR; + } config_store_->set(transport_inst_->config_key("MULTICAST_GROUP_ADDRESS").c_str(), - NetworkAddress(mc_addr), + mc_addr, ConfigStoreImpl::Format_Optional_Port, ConfigStoreImpl::Kind_IPV4); config_store_->set_uint32(transport_inst_->config_key("TTL").c_str(), disco.ttl()); config_store_->set(transport_inst_->config_key("MULTICAST_INTERFACE").c_str(), disco.multicast_interface()); - } else { - config_store_->set_boolean(transport_inst_->config_key("USE_MULTICAST").c_str(), false); } + DCPS::NetworkAddress addr4; + if (!disco.config()->sedp_unicast_address(addr4, domainId, ipv4_participant_port_id)) { + return DDS::RETCODE_ERROR; + } config_store_->set(transport_inst_->config_key("LOCAL_ADDRESS").c_str(), - NetworkAddress(disco.config()->sedp_local_address()), + addr4, ConfigStoreImpl::Format_Required_Port, ConfigStoreImpl::Kind_IPV4); config_store_->set(transport_inst_->config_key("ADVERTISED_ADDRESS").c_str(), - NetworkAddress(disco.config()->sedp_advertised_local_address()), + disco.config()->sedp_advertised_local_address(), ConfigStoreImpl::Format_Required_Port, ConfigStoreImpl::Kind_IPV4); #ifdef ACE_HAS_IPV6 + DCPS::NetworkAddress addr6; + if (!disco.config()->ipv6_sedp_unicast_address(addr6, domainId, ipv6_participant_port_id)) { + return DDS::RETCODE_ERROR; + } config_store_->set(transport_inst_->config_key("IPV6_LOCAL_ADDRESS").c_str(), - NetworkAddress(disco.config()->ipv6_sedp_local_address()), + addr6, ConfigStoreImpl::Format_Required_Port, ConfigStoreImpl::Kind_IPV6); config_store_->set(transport_inst_->config_key("IPV6_ADVERTISED_ADDRESS").c_str(), - NetworkAddress(disco.config()->ipv6_sedp_advertised_local_address()), + disco.config()->ipv6_sedp_advertised_local_address(), ConfigStoreImpl::Format_Required_Port, ConfigStoreImpl::Kind_IPV6); #endif diff --git a/dds/DCPS/RTPS/Sedp.h b/dds/DCPS/RTPS/Sedp.h index c9c20e85af8..a705f75657b 100644 --- a/dds/DCPS/RTPS/Sedp.h +++ b/dds/DCPS/RTPS/Sedp.h @@ -320,6 +320,10 @@ class Sedp : public virtual DCPS::RcEventHandler { DDS::ReturnCode_t init(const DCPS::GUID_t& guid, const RtpsDiscovery& disco, DDS::DomainId_t domainId, + DDS::UInt16 ipv4_participant_port_id, +#ifdef ACE_HAS_IPV6 + DDS::UInt16 ipv6_participant_port_id, +#endif XTypes::TypeLookupService_rch tls); #ifdef OPENDDS_SECURITY diff --git a/dds/DCPS/RTPS/Spdp.cpp b/dds/DCPS/RTPS/Spdp.cpp index 2bdad9bcf78..c3a16b6d596 100644 --- a/dds/DCPS/RTPS/Spdp.cpp +++ b/dds/DCPS/RTPS/Spdp.cpp @@ -245,6 +245,10 @@ Spdp::Spdp(DDS::DomainId_t domain, , guid_(guid) , participant_discovered_at_(MonotonicTimePoint::now().to_monotonic_time()) , is_application_participant_(false) + , ipv4_participant_port_id_(0) +#ifdef ACE_HAS_IPV6 + , ipv6_participant_port_id_(0) +#endif , tport_(DCPS::make_rch(rchandle_from(this))) , initialized_flag_(false) , eh_shutdown_(false) @@ -304,6 +308,10 @@ Spdp::Spdp(DDS::DomainId_t domain, , guid_(guid) , participant_discovered_at_(MonotonicTimePoint::now().to_monotonic_time()) , is_application_participant_(false) + , ipv4_participant_port_id_(0) +#ifdef ACE_HAS_IPV6 + , ipv6_participant_port_id_(0) +#endif , tport_(DCPS::make_rch(rchandle_from(this))) , initialized_flag_(false) , eh_shutdown_(false) @@ -2177,7 +2185,11 @@ Spdp::init_bit(DCPS::RcHandle bit_subscriber) bit_subscriber_ = bit_subscriber; // Defer initilization until we have the bit subscriber. - sedp_->init(guid_, *disco_, domain_, type_lookup_service_); + sedp_->init(guid_, *disco_, domain_, ipv4_participant_port_id_, +#ifdef ACE_HAS_IPV6 + ipv6_participant_port_id_, +#endif + type_lookup_service_); tport_->open(sedp_->reactor_task(), sedp_->job_queue()); #ifdef OPENDDS_SECURITY @@ -2350,38 +2362,35 @@ Spdp::SpdpTransport::SpdpTransport(DCPS::RcHandle outer) #ifdef ACE_HAS_MAC_OSX multicast_socket_.opts(ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_NO | ACE_SOCK_Dgram_Mcast::DEFOPT_NULLIFACE); -#ifdef ACE_HAS_IPV6 +# ifdef ACE_HAS_IPV6 multicast_ipv6_socket_.opts(ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_NO | ACE_SOCK_Dgram_Mcast::DEFOPT_NULLIFACE); -#endif +# endif #endif multicast_interface_ = outer->disco_->multicast_interface(); - const u_short port_common = outer->config_->port_common(outer->domain_); - multicast_address_ = outer->config_->multicast_address(port_common, outer->domain_); - -#ifdef ACE_HAS_IPV6 - multicast_ipv6_address_ = outer->config_->ipv6_multicast_address(port_common); -#endif - + if (!outer->config_->spdp_multicast_address(multicast_address_, outer->domain_)) { + throw std::runtime_error("failed to get valid multicast IPv4 address for SPDP"); + } send_addrs_.insert(multicast_address_); #ifdef ACE_HAS_IPV6 + if (!outer->config_->ipv6_spdp_multicast_address(multicast_ipv6_address_, outer->domain_)) { + throw std::runtime_error("failed to get valid multicast IPv4 address for SPDP"); + } send_addrs_.insert(multicast_ipv6_address_); #endif const DCPS::NetworkAddressSet addrs = outer->config_->spdp_send_addrs(); send_addrs_.insert(addrs.begin(), addrs.end()); - u_short participantId = 0; - #ifdef OPENDDS_SAFETY_PROFILE - const u_short startingParticipantId = participantId; + const DDS::UInt16 startingParticipantId = outer->ipv4_participant_port_id_; #endif - const u_short max_part_id = 119; // RTPS 2.5 9.6.2.3 - while (!open_unicast_socket(port_common, participantId)) { - if (participantId == max_part_id && log_level >= LogLevel::Warning) { + const DDS::UInt16 max_part_id = 119; // RTPS 2.5 9.6.2.3 + while (!open_unicast_socket(outer->ipv4_participant_port_id_)) { + if (outer->ipv4_participant_port_id_ == max_part_id && log_level >= LogLevel::Warning) { ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: Spdp::SpdpTransport: " "participant id is going above max %u allowed by RTPS spec\n", max_part_id)); // As long as it doesn't result in an invalid port, going past this @@ -2389,24 +2398,24 @@ Spdp::SpdpTransport::SpdpTransport(DCPS::RcHandle outer) // limited number of ports at its disposal. Also another implementation // could use this as a hard limit, but that's much less of a concern. } - ++participantId; + ++outer->ipv4_participant_port_id_; } -#ifdef ACE_HAS_IPV6 - u_short port = uni_port_; - while (!open_unicast_ipv6_socket(port)) { - ++port; +#ifdef ACE_HAS_IPV6 + outer->ipv6_participant_port_id_ = outer->ipv4_participant_port_id_; + while (!open_unicast_ipv6_socket(outer->ipv6_participant_port_id_)) { + ++outer->ipv6_participant_port_id_; } #endif #ifdef OPENDDS_SAFETY_PROFILE - if (participantId > startingParticipantId && ACE_OS::getpid() == -1) { + if (outer->ipv4_participant_port_id_ > startingParticipantId && ACE_OS::getpid() == -1) { // Since pids are not available, use the fact that we had to increment // participantId to modify the GUID's pid bytes. This avoids GUID conflicts // between processes on the same host which start at the same time // (resulting in the same seed value for the random number generator). - hdr_.guidPrefix[8] = static_cast(participantId >> 8); - hdr_.guidPrefix[9] = static_cast(participantId & 0xFF); + hdr_.guidPrefix[8] = static_cast(outer->ipv4_participant_port_id_ >> 8); + hdr_.guidPrefix[9] = static_cast(outer->ipv4_participant_port_id_ & 0xFF); outer->guid_.guidPrefix[8] = hdr_.guidPrefix[8]; outer->guid_.guidPrefix[9] = hdr_.guidPrefix[9]; } @@ -3401,31 +3410,18 @@ Spdp::signal_liveliness(DDS::LivelinessQosPolicyKind kind) } bool -Spdp::SpdpTransport::open_unicast_socket(u_short port_common, - u_short participant_id) +Spdp::SpdpTransport::open_unicast_socket(DDS::UInt16 participant_id) { DCPS::RcHandle outer = outer_.lock(); if (!outer) { throw std::runtime_error("couldn't get Spdp"); } - DCPS::NetworkAddress local_addr = outer->config_->spdp_local_address(); - const bool fixed_port = local_addr.get_port_number(); - - if (fixed_port) { - uni_port_ = local_addr.get_port_number(); - } else if (!outer->config_->spdp_request_random_port()) { - const ACE_UINT32 port = static_cast(port_common) + outer->config_->d1() + - outer->config_->pg() * participant_id; - if (port > 65535) { - if (log_level >= LogLevel::Error) { - ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: Spdp::SpdpTransport::open_unicast_socket: " - "port %u is too high\n", port)); - } - throw std::runtime_error("failed to open unicast port for SPDP (port too high)"); - } - uni_port_ = static_cast(port); - local_addr.set_port_number(uni_port_); + DCPS::NetworkAddress local_addr; + bool fixed_port; + if (!outer->config_->spdp_unicast_address( + local_addr, fixed_port, outer->domain_, participant_id)) { + throw std::runtime_error("failed to get valid unicast IPv4 address for SPDP"); } if (unicast_socket_.open(local_addr.to_addr(), PF_INET) != 0) { @@ -3435,170 +3431,138 @@ Spdp::SpdpTransport::open_unicast_socket(u_short port_common, "failed to open %C %p.\n", LogAddr(local_addr).c_str(), ACE_TEXT("ACE_SOCK_Dgram::open"))); } - throw std::runtime_error("failed to open unicast port for SPDP"); + throw std::runtime_error("failed to open fixed unicast IPv4 port for SPDP"); } if (DCPS::DCPS_debug_level > 3) { ACE_DEBUG((LM_DEBUG, - ACE_TEXT("(%P|%t) Spdp::SpdpTransport::open_unicast_socket() - ") - ACE_TEXT("failed to open %C %p. ") - ACE_TEXT("Trying next participantId...\n"), - DCPS::LogAddr(local_addr).c_str(), ACE_TEXT("ACE_SOCK_Dgram::open"))); + "(%P|%t) Spdp::SpdpTransport::open_unicast_socket: " + "failed to open %C %p, trying next participant ID...\n", + LogAddr(local_addr).c_str(), ACE_TEXT("ACE_SOCK_Dgram::open"))); } return false; } - if (!fixed_port && outer->config_->spdp_request_random_port()) { - ACE_INET_Addr addr; - if (unicast_socket_.get_local_addr(addr) == 0) { - uni_port_ = addr.get_port_number(); + set_unicast_socket_opts(outer, unicast_socket_, uni_port_); + + return true; +} + +namespace { + template + bool set_sock_opt(ACE_SOCK_Dgram& sock, + int level, int option, T value, bool ignore_notsup = false) + { + if (sock.set_option(level, option, (void*) &value, sizeof(T)) < 0) { + return ignore_notsup && errno == ENOTSUP; } + return true; } +} + +void Spdp::SpdpTransport::set_unicast_socket_opts( + DCPS::RcHandle& outer, ACE_SOCK_Dgram& sock, DDS::UInt16& port) +{ + ACE_INET_Addr addr; + if (sock.get_local_addr(addr) != 0) { + throw std::runtime_error("failed to get address from socket"); + } + port = addr.get_port_number(); + const bool ipv6 = +#ifdef ACE_HAS_IPV6 + addr.get_type () == AF_INET6; +#else + false; +#endif if (DCPS::DCPS_debug_level > 3) { - ACE_DEBUG((LM_INFO, - ACE_TEXT("(%P|%t) Spdp::SpdpTransport::open_unicast_socket() - ") - ACE_TEXT("opened unicast socket on port %d\n"), - uni_port_)); + ACE_DEBUG((LM_DEBUG, + "(%P|%t) Spdp::SpdpTransport::set_unicast_socket_opts: " + "opened %C unicast socket %d on port %d\n", + ipv6 ? "IPv6" : "IPv4", sock.get_handle(), port)); } - if (!DCPS::set_socket_multicast_ttl(unicast_socket_, outer->config_->ttl())) { - if (DCPS::DCPS_debug_level > 0) { + if (!DCPS::set_socket_multicast_ttl(sock, outer->config_->ttl())) { + if (log_level >= LogLevel::Error) { ACE_ERROR((LM_ERROR, - ACE_TEXT("(%P|%t) ERROR: Spdp::SpdpTransport::open_unicast_socket() - ") - ACE_TEXT("failed to set TTL value to %d ") - ACE_TEXT("for port:%hu %p\n"), - outer->config_->ttl(), uni_port_, ACE_TEXT("DCPS::set_socket_multicast_ttl:"))); + "(%P|%t) ERROR: Spdp::SpdpTransport::set_unicast_socket_opts: " + "failed to set TTL value to %d for port:%hu %p\n", + outer->config_->ttl(), port, ACE_TEXT("DCPS::set_socket_multicast_ttl:"))); } throw std::runtime_error("failed to set TTL"); } const int send_buffer_size = outer->config()->send_buffer_size(); - if (send_buffer_size > 0) { - if (unicast_socket_.set_option(SOL_SOCKET, - SO_SNDBUF, - (void *) &send_buffer_size, - sizeof(send_buffer_size)) < 0 - && errno != ENOTSUP) { - if (DCPS::DCPS_debug_level > 0) { - ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Spdp::SpdpTransport::open_unicast_socket() - failed to set the send buffer size to %d errno %m\n"), send_buffer_size)); - } - throw std::runtime_error("failed to set send buffer size"); + if (send_buffer_size > 0 && !set_sock_opt(sock, SOL_SOCKET, SO_SNDBUF, send_buffer_size, true)) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: Spdp::SpdpTransport::set_unicast_socket_opts: " + "failed to set the send buffer size to %d: %m\n", send_buffer_size)); } + throw std::runtime_error("failed to set send buffer size"); } const int recv_buffer_size = outer->config()->recv_buffer_size(); - if (recv_buffer_size > 0) { - if (unicast_socket_.set_option(SOL_SOCKET, - SO_RCVBUF, - (void *) &recv_buffer_size, - sizeof(recv_buffer_size)) < 0 - && errno != ENOTSUP) { - if (DCPS::DCPS_debug_level > 0) { - ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Spdp::SpdpTransport::open_unicast_socket() - failed to set the recv buffer size to %d errno %m\n"), recv_buffer_size)); - } - throw std::runtime_error("failed to set recv buffer size"); + if (recv_buffer_size > 0 && !set_sock_opt(sock, SOL_SOCKET, SO_RCVBUF, recv_buffer_size, true)) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: Spdp::SpdpTransport::set_unicast_socket_opts: " + "failed to set the recv buffer size to %d: %m\n", recv_buffer_size)); } + throw std::runtime_error("failed to set recv buffer size"); } + bool success = true; + if (ipv6) { +#ifdef ACE_RECVPKTINFO6 + success = set_sock_opt(sock, IPPROTO_IPV6, ACE_RECVPKTINFO6, 1); +#endif + } else { #ifdef ACE_RECVPKTINFO - int sockopt = 1; - if (unicast_socket_.set_option(IPPROTO_IP, ACE_RECVPKTINFO, &sockopt, sizeof sockopt) == -1) { - ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Spdp::SpdpTransport::open_unicast_socket: set_option: %m\n")), false); - } + success = set_sock_opt(sock, IPPROTO_IP, ACE_RECVPKTINFO, 1); #endif - - return true; + } + if (!success) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: Spdp::SpdpTransport::set_unicast_socket_opts: " + "failed to set RECVPKTINFO: %m\n")); + } + throw std::runtime_error("failed to set RECVPKTINFO"); + } } #ifdef ACE_HAS_IPV6 bool -Spdp::SpdpTransport::open_unicast_ipv6_socket(u_short port) +Spdp::SpdpTransport::open_unicast_ipv6_socket(DDS::UInt16 participant_id) { DCPS::RcHandle outer = outer_.lock(); - if (!outer) return false; - - DCPS::NetworkAddress local_addr = outer->config_->ipv6_spdp_local_address(); - const bool fixed_port = local_addr.get_port_number(); + if (!outer) { + throw std::runtime_error("couldn't get Spdp"); + } - if (fixed_port) { - ipv6_uni_port_ = local_addr.get_port_number(); - } else { - ipv6_uni_port_ = port; - local_addr.set_port_number(ipv6_uni_port_); + DCPS::NetworkAddress local_addr; + bool fixed_port; + if (!outer->config_->spdp_unicast_address( + local_addr, fixed_port, outer->domain_, participant_id)) { + throw std::runtime_error("failed to get valid unicast IPv4 address for SPDP"); } if (unicast_ipv6_socket_.open(local_addr.to_addr(), PF_INET6) != 0) { if (fixed_port) { - if (DCPS::DCPS_debug_level > 0) { - ACE_ERROR((LM_ERROR, - ACE_TEXT("(%P|%t) Spdp::SpdpTransport::open_unicast_ipv6_socket() - ") - ACE_TEXT("failed to open %C %p.\n"), - DCPS::LogAddr(local_addr).c_str(), ACE_TEXT("ACE_SOCK_Dgram::open"))); + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: Spdp::SpdpTransport::open_unicast_ipv6_socket: " + "failed to open %C %p.\n", + LogAddr(local_addr).c_str(), ACE_TEXT("ACE_SOCK_Dgram::open"))); } - throw std::runtime_error("failed to open ipv6 unicast port for SPDP"); + throw std::runtime_error("failed to open fixed unicast IPv6 port for SPDP"); } if (DCPS::DCPS_debug_level > 3) { - ACE_DEBUG((LM_WARNING, - ACE_TEXT("(%P|%t) Spdp::SpdpTransport::open_unicast_ipv6_socket() - ") - ACE_TEXT("failed to open %C %p. ") - ACE_TEXT("Trying next port...\n"), - DCPS::LogAddr(local_addr).c_str(), ACE_TEXT("ACE_SOCK_Dgram::open"))); + ACE_DEBUG((LM_DEBUG, + "(%P|%t) Spdp::SpdpTransport::open_unicast_ipv6_socket: " + "failed to open %C %p, trying next participant ID...\n", + LogAddr(local_addr).c_str(), ACE_TEXT("ACE_SOCK_Dgram::open"))); } return false; } - if (DCPS::DCPS_debug_level > 3) { - ACE_DEBUG((LM_INFO, - ACE_TEXT("(%P|%t) Spdp::SpdpTransport::open_unicast_ipv6_socket() - ") - ACE_TEXT("opened unicast ipv6 socket on port %d\n"), - ipv6_uni_port_)); - } - - if (!DCPS::set_socket_multicast_ttl(unicast_ipv6_socket_, outer->config_->ttl())) { - if (DCPS::DCPS_debug_level > 0) { - ACE_ERROR((LM_ERROR, - ACE_TEXT("(%P|%t) ERROR: Spdp::SpdpTransport::open_unicast_ipv6_socket() - ") - ACE_TEXT("failed to set TTL value to %d ") - ACE_TEXT("for port:%hu %p\n"), - outer->config_->ttl(), ipv6_uni_port_, ACE_TEXT("DCPS::set_socket_multicast_ttl:"))); - } - throw std::runtime_error("failed to set TTL"); - } - - const int send_buffer_size = outer->config()->send_buffer_size(); - if (send_buffer_size > 0) { - if (unicast_ipv6_socket_.set_option(SOL_SOCKET, - SO_SNDBUF, - (void *) &send_buffer_size, - sizeof(send_buffer_size)) < 0 - && errno != ENOTSUP) { - if (DCPS::DCPS_debug_level > 0) { - ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Spdp::SpdpTransport::open_unicast_ipv6_socket() - failed to set the send buffer size to %d errno %m\n"), send_buffer_size)); - } - throw std::runtime_error("failed to set send buffer size"); - } - } - - const int recv_buffer_size = outer->config()->recv_buffer_size(); - if (recv_buffer_size > 0) { - if (unicast_ipv6_socket_.set_option(SOL_SOCKET, - SO_RCVBUF, - (void *) &recv_buffer_size, - sizeof(recv_buffer_size)) < 0 - && errno != ENOTSUP) { - if (DCPS::DCPS_debug_level > 0) { - ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Spdp::SpdpTransport::open_unicast_ipv6_socket() - failed to set the recv buffer size to %d errno %m\n"), recv_buffer_size)); - } - throw std::runtime_error("failed to set recv buffer size"); - } - } - -#ifdef ACE_RECVPKTINFO6 - int sockopt = 1; - if (unicast_ipv6_socket_.set_option(IPPROTO_IPV6, ACE_RECVPKTINFO6, &sockopt, sizeof sockopt) == -1) { - ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Spdp::SpdpTransport::open_unicast_ipv6_socket: set_option: %m\n")), false); - } -#endif + set_unicast_socket_opts(outer, unicast_ipv6_socket_, ipv6_uni_port_); return true; } diff --git a/dds/DCPS/RTPS/Spdp.h b/dds/DCPS/RTPS/Spdp.h index 6084538bcf7..78862fd8cc3 100644 --- a/dds/DCPS/RTPS/Spdp.h +++ b/dds/DCPS/RTPS/Spdp.h @@ -403,6 +403,10 @@ class OpenDDS_Rtps_Export Spdp DCPS::GUID_t guid_; const DCPS::MonotonicTime_t participant_discovered_at_; bool is_application_participant_; + DDS::UInt16 ipv4_participant_port_id_; +#ifdef ACE_HAS_IPV6 + DDS::UInt16 ipv6_participant_port_id_; +#endif void data_received(const DataSubmessage& data, const ParameterList& plist, const DCPS::NetworkAddress& from); @@ -491,9 +495,10 @@ class OpenDDS_Rtps_Export Spdp ssize_t send(const DCPS::NetworkAddress& addr); void close(const DCPS::ReactorTask_rch& reactor_task); void dispose_unregister(); - bool open_unicast_socket(u_short port_common, u_short participant_id); + void set_unicast_socket_opts(DCPS::RcHandle& outer, ACE_SOCK_Dgram& sock, DDS::UInt16& port); + bool open_unicast_socket(DDS::UInt16 participant_id); #ifdef ACE_HAS_IPV6 - bool open_unicast_ipv6_socket(u_short port); + bool open_unicast_ipv6_socket(DDS::UInt16 participant_id); #endif void on_data_available(DCPS::RcHandle > reader); @@ -515,13 +520,13 @@ class OpenDDS_Rtps_Export Spdp UserTagSubmessage user_tag_; DataSubmessage data_; DCPS::SequenceNumber seq_; - u_short uni_port_; + DDS::UInt16 uni_port_; ACE_SOCK_Dgram unicast_socket_; OPENDDS_STRING multicast_interface_; DCPS::NetworkAddress multicast_address_; ACE_SOCK_Dgram_Mcast multicast_socket_; #ifdef ACE_HAS_IPV6 - u_short ipv6_uni_port_; + DDS::UInt16 ipv6_uni_port_; ACE_SOCK_Dgram unicast_ipv6_socket_; OPENDDS_STRING multicast_ipv6_interface_; DCPS::NetworkAddress multicast_ipv6_address_; diff --git a/dds/DCPS/Service_Participant.cpp b/dds/DCPS/Service_Participant.cpp index ccd3cb5bdc4..45d00d4b783 100644 --- a/dds/DCPS/Service_Participant.cpp +++ b/dds/DCPS/Service_Participant.cpp @@ -2288,8 +2288,7 @@ namespace { { { Service_Participant::Encoding_Normal, "Normal" }, { Service_Participant::Encoding_WriteOldFormat, "WriteOldFormat" }, - { Service_Participant::Encoding_ReadOldFormat, "ReadOldFormat" }, - { Service_Participant::Encoding_Normal, 0 } + { Service_Participant::Encoding_ReadOldFormat, "ReadOldFormat" } }; } diff --git a/dds/DCPS/StaticDiscovery.cpp b/dds/DCPS/StaticDiscovery.cpp index c73caf2c07e..4153250118e 100644 --- a/dds/DCPS/StaticDiscovery.cpp +++ b/dds/DCPS/StaticDiscovery.cpp @@ -1657,56 +1657,50 @@ namespace { const EnumList durability_kinds[] = { { DDS::VOLATILE_DURABILITY_QOS, "VOLATILE" }, - { DDS::TRANSIENT_LOCAL_DURABILITY_QOS, "TRANSIENT_LOCAL" }, + { DDS::TRANSIENT_LOCAL_DURABILITY_QOS, "TRANSIENT_LOCAL" } #ifndef OPENDDS_NO_PERSISTENCE_PROFILE + , { DDS::TRANSIENT_DURABILITY_QOS, "TRANSIENT" }, - { DDS::PERSISTENT_DURABILITY_QOS, "PERSISTENT" }, + { DDS::PERSISTENT_DURABILITY_QOS, "PERSISTENT" } #endif - { static_cast(0), 0 } }; const EnumList liveliness_kinds[] = { { DDS::AUTOMATIC_LIVELINESS_QOS, "AUTOMATIC" }, { DDS::MANUAL_BY_TOPIC_LIVELINESS_QOS, "MANUAL_BY_TOPIC" }, - { DDS::MANUAL_BY_PARTICIPANT_LIVELINESS_QOS, "MANUAL_BY_PARTICIPANT" }, - { static_cast(0), 0 } + { DDS::MANUAL_BY_PARTICIPANT_LIVELINESS_QOS, "MANUAL_BY_PARTICIPANT" } }; const EnumList reliability_kinds[] = { { DDS::BEST_EFFORT_RELIABILITY_QOS, "BEST_EFFORT" }, - { DDS::RELIABLE_RELIABILITY_QOS, "RELIABLE" }, - { static_cast(0), 0 } + { DDS::RELIABLE_RELIABILITY_QOS, "RELIABLE" } }; const EnumList destination_order_kinds[] = { { DDS::BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS, "BY_RECEPTION_TIMESTAMP" }, - { DDS::BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS, "BY_SOURCE_TIMESTAMP" }, - { static_cast(0), 0 } + { DDS::BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS, "BY_SOURCE_TIMESTAMP" } }; const EnumList history_kinds[] = { { DDS::KEEP_ALL_HISTORY_QOS, "KEEP_ALL" }, - { DDS::KEEP_LAST_HISTORY_QOS, "KEEP_LAST" }, - { static_cast(0), 0 } + { DDS::KEEP_LAST_HISTORY_QOS, "KEEP_LAST" } }; const EnumList ownership_kinds[] = { { DDS::SHARED_OWNERSHIP_QOS, "SHARED" }, - { DDS::EXCLUSIVE_OWNERSHIP_QOS, "EXCLUSIVE" }, - { static_cast(0), 0 } + { DDS::EXCLUSIVE_OWNERSHIP_QOS, "EXCLUSIVE" } }; const EnumList access_scope_kinds[] = { { DDS::INSTANCE_PRESENTATION_QOS, "INSTANCE" }, { DDS::TOPIC_PRESENTATION_QOS, "TOPIC" }, - { DDS::GROUP_PRESENTATION_QOS, "GROUP" }, - { static_cast(0), 0 } + { DDS::GROUP_PRESENTATION_QOS, "GROUP" } }; enum Type { @@ -1716,8 +1710,7 @@ namespace { const EnumList type_kinds[] = { { Reader, "reader" }, - { Writer, "writer" }, - { static_cast(0), 0 } + { Writer, "writer" } }; } diff --git a/docs/devguide/run_time_configuration.rst b/docs/devguide/run_time_configuration.rst index 9e275588fd2..22c5d92e908 100644 --- a/docs/devguide/run_time_configuration.rst +++ b/docs/devguide/run_time_configuration.rst @@ -817,7 +817,7 @@ Configuring for InfoRepo Discovery .. Sect<7.3.2> -This section describes the configuration properties for the :ref:`inforepo-disc`. +This section describes the configuration properties for :ref:`inforepo-disc`. Assume for example that the :ref:`inforepo` is started on a host and port of ``myhost.mydomain.com:12345``. Applications can make their OpenDDS participants aware of how to find this service through command line options or by reading a configuration file. @@ -1014,7 +1014,7 @@ Configuring for RTPS Discovery .. Sect<7.3.3> -This section describes the configuration properties for the :ref:`rtps-disc`. +This section describes the configuration properties for :ref:`rtps-disc`. The RTPS specification gives the following simple description that forms the basis for the discovery approach used by OpenDDS and the two different protocols used to accomplish the discovery operations. The excerpt from the :omgspec:`rtps:8.5.1` is as follows: diff --git a/tests/Utils/GtestRc.h b/tests/Utils/GtestRc.h index eafca1b06de..4a5d4afb966 100644 --- a/tests/Utils/GtestRc.h +++ b/tests/Utils/GtestRc.h @@ -2,6 +2,7 @@ #define OPENDDS_TEST_GTEST_RC_H #include +#include #include @@ -20,9 +21,30 @@ inline ::testing::AssertionResult retcodes_equal( " Which is: " << OpenDDS::DCPS::retcode_to_string(b) << "\n"; } -#define EXPECT_RC_EQ(A, B) EXPECT_PRED_FORMAT2(retcodes_equal, (A), (B)) -#define ASSERT_RC_EQ(A, B) ASSERT_PRED_FORMAT2(retcodes_equal, (A), (B)) -#define EXPECT_RC_OK(VALUE) EXPECT_RC_EQ(::DDS::RETCODE_OK, (VALUE)) -#define ASSERT_RC_OK(VALUE) ASSERT_RC_EQ(::DDS::RETCODE_OK, (VALUE)) +#define EXPECT_RC_EQ(A, B) EXPECT_PRED_FORMAT2(retcodes_equal, A, B) +#define ASSERT_RC_EQ(A, B) ASSERT_PRED_FORMAT2(retcodes_equal, A, B) +#define EXPECT_RC_OK(VALUE) EXPECT_RC_EQ(::DDS::RETCODE_OK, VALUE) +#define ASSERT_RC_OK(VALUE) ASSERT_RC_EQ(::DDS::RETCODE_OK, VALUE) + +inline ::testing::AssertionResult addr_equal( + const char* a_expr, const char* b_expr, + const OpenDDS::DCPS::NetworkAddress& a, const OpenDDS::DCPS::NetworkAddress& b) +{ + const OpenDDS::DCPS::LogAddr ala(a); + const OpenDDS::DCPS::LogAddr bla(b); + if (ala.str() == bla.str()) { + return ::testing::AssertionSuccess(); + } + + return ::testing::AssertionFailure() << + "Expected equality of these values:\n" + " " << a_expr << "\n" + " Which is: " << ala.str() << "\n" + " " << b_expr << "\n" + " Which is: " << bla.str() << "\n"; +} + +#define EXPECT_ADDR_EQ(A, B) EXPECT_PRED_FORMAT2(addr_equal, A, B) +#define ASSERT_ADDR_EQ(A, B) ASSERT_PRED_FORMAT2(addr_equal, A, B) #endif diff --git a/tests/unit-tests/dds/DCPS/ConfigStoreImpl.cpp b/tests/unit-tests/dds/DCPS/ConfigStoreImpl.cpp index d066c8410b6..a5c856d6278 100644 --- a/tests/unit-tests/dds/DCPS/ConfigStoreImpl.cpp +++ b/tests/unit-tests/dds/DCPS/ConfigStoreImpl.cpp @@ -252,8 +252,7 @@ TEST(dds_DCPS_ConfigStoreImpl, set_get_Enum) { { ALPHA, "alpha" }, { BETA, "beta" }, - { GAMMA, "gamma" }, - { static_cast(0), 0 } + { GAMMA, "gamma" } }; ConfigTopic_rch topic = make_rch(); diff --git a/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp b/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp new file mode 100644 index 00000000000..5964e8e627a --- /dev/null +++ b/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp @@ -0,0 +1,477 @@ +#include + +#include + +using namespace OpenDDS::RTPS; +using namespace OpenDDS::DCPS; + +namespace { + struct AddressTest { + RcHandle store; + RtpsDiscoveryConfig rtps; + NetworkAddress addr; + bool fixed; + + AddressTest() + : store(make_rch(TheServiceParticipant->config_topic())) + , rtps("ADDRESS_TEST") + , addr() + , fixed(false) + { + store->unset_section(rtps.config_prefix()); + } + + ~AddressTest() + { + store->unset_section(rtps.config_prefix()); + } + }; +} + +TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, sedp_unicast_address) +{ + { + AddressTest t; + ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress()); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.sedp_port_mode(PortMode_System); + ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress()); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.sedp_port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7662, "0.0.0.0")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.sedp_port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7668, "0.0.0.0")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.sedp_port_mode(PortMode_Probe); + t.rtps.pb(7500); + t.rtps.dg(260); + t.rtps.pg(3); + t.rtps.dy(8); + ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "0.0.0.0")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.sedp_port_mode(PortMode_Probe); + t.rtps.pb(9999); + t.rtps.dg(9999); + t.rtps.pg(9999); + t.rtps.dy(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_FALSE(t.rtps.sedp_unicast_address(t.addr, 9999, 9999)); + } + + { + AddressTest t; + t.rtps.sedp_local_address(NetworkAddress(1234, "1.2.3.4")); + ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); + EXPECT_FALSE(t.fixed); + } +} + +TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_unicast_address) +{ + { + AddressTest t; + ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, "0.0.0.0")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.spdp_port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, "0.0.0.0")); + EXPECT_FALSE(t.fixed); + } + + + { + AddressTest t; + t.rtps.spdp_port_mode(PortMode_System); + ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress()); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.spdp_port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7666, "0.0.0.0")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.spdp_port_mode(PortMode_Probe); + t.rtps.pb(7500); + t.rtps.dg(260); + t.rtps.pg(3); + t.rtps.d1(8); + ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "0.0.0.0")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.spdp_port_mode(PortMode_Probe); + t.rtps.pb(9999); + t.rtps.dg(9999); + t.rtps.pg(9999); + t.rtps.d1(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_FALSE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 9999, 9999)); + } + + { + AddressTest t; + t.rtps.spdp_local_address(NetworkAddress(1234, "1.2.3.4")); + ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); + EXPECT_TRUE(t.fixed); + } +} + +TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_multicast_address) +{ + { + AddressTest t; + ASSERT_TRUE(t.rtps.spdp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7650, "239.255.0.1")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + ASSERT_TRUE(t.rtps.spdp_multicast_address(t.addr, 2)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7900, "239.255.0.1")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.pb(7500); + t.rtps.dg(260); + t.rtps.d0(17); + ASSERT_TRUE(t.rtps.spdp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "239.255.0.1")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.pb(9999); + t.rtps.dg(9999); + t.rtps.d0(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_FALSE(t.rtps.spdp_multicast_address(t.addr, 9999)); + } + + { + AddressTest t; + t.rtps.spdp_multicast_address(NetworkAddress(1234, "1.2.3.4")); + ASSERT_TRUE(t.rtps.spdp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); + EXPECT_FALSE(t.fixed); + } +} + +TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, sedp_multicast_address) +{ + { + AddressTest t; + ASSERT_TRUE(t.rtps.sedp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7652, "239.255.0.1")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + ASSERT_TRUE(t.rtps.sedp_multicast_address(t.addr, 2)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7902, "239.255.0.1")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.pb(7500); + t.rtps.dg(260); + t.rtps.dx(17); + ASSERT_TRUE(t.rtps.sedp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "239.255.0.1")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.pb(9999); + t.rtps.dg(9999); + t.rtps.dx(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_FALSE(t.rtps.sedp_multicast_address(t.addr, 9999)); + } + + { + AddressTest t; + t.rtps.sedp_multicast_address(NetworkAddress(1234, "1.2.3.4")); + ASSERT_TRUE(t.rtps.sedp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); + EXPECT_FALSE(t.fixed); + } +} + +#ifdef ACE_HAS_IPV6 +TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_sedp_unicast_address) +{ + { + AddressTest t; + ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress()); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.sedp_port_mode(PortMode_System); + ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress()); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.sedp_port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7662, "[::]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.sedp_port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7668, "[::]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.sedp_port_mode(PortMode_Probe); + t.rtps.pb(7500); + t.rtps.dg(260); + t.rtps.pg(3); + t.rtps.dy(8); + ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "[::]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.sedp_port_mode(PortMode_Probe); + t.rtps.pb(9999); + t.rtps.dg(9999); + t.rtps.pg(9999); + t.rtps.dy(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_FALSE(t.rtps.ipv6_sedp_unicast_address(t.addr, 9999, 9999)); + } + + { + AddressTest t; + t.rtps.sedp_local_address(NetworkAddress(1234, "[1:2:3:4]")); + ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); + EXPECT_FALSE(t.fixed); + } +} + +TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_unicast_address) +{ + { + AddressTest t; + ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, "[::]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.spdp_port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, "[::]")); + EXPECT_FALSE(t.fixed); + } + + + { + AddressTest t; + t.rtps.spdp_port_mode(PortMode_System); + ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress()); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.spdp_port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7666, "[::]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.spdp_port_mode(PortMode_Probe); + t.rtps.pb(7500); + t.rtps.dg(260); + t.rtps.pg(3); + t.rtps.d1(8); + ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "[::]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.spdp_port_mode(PortMode_Probe); + t.rtps.pb(9999); + t.rtps.dg(9999); + t.rtps.pg(9999); + t.rtps.d1(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_FALSE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 9999, 9999)); + } + + { + AddressTest t; + t.rtps.spdp_local_address(NetworkAddress(1234, "[1:2:3:4]")); + ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); + EXPECT_TRUE(t.fixed); + } +} + +TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_multicast_address) +{ + { + AddressTest t; + ASSERT_TRUE(t.rtps.ipv6_spdp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7650, "[FF03::1]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + ASSERT_TRUE(t.rtps.ipv6_spdp_multicast_address(t.addr, 2)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7900, "[FF03::1]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.pb(7500); + t.rtps.dg(260); + t.rtps.d0(17); + ASSERT_TRUE(t.rtps.ipv6_spdp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "[FF03::1]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.pb(9999); + t.rtps.dg(9999); + t.rtps.d0(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_FALSE(t.rtps.ipv6_spdp_multicast_address(t.addr, 9999)); + } + + { + AddressTest t; + t.rtps.ipv6_spdp_multicast_address(NetworkAddress(1234, "[1:2:3:4]")); + ASSERT_TRUE(t.rtps.ipv6_spdp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); + EXPECT_FALSE(t.fixed); + } +} + +TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_sedp_multicast_address) +{ + { + AddressTest t; + ASSERT_TRUE(t.rtps.ipv6_sedp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7652, "[FF03::1]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + ASSERT_TRUE(t.rtps.ipv6_sedp_multicast_address(t.addr, 2)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7902, "[FF03::1]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.pb(7500); + t.rtps.dg(260); + t.rtps.dx(17); + ASSERT_TRUE(t.rtps.ipv6_sedp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "[FF03::1]")); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps.pb(9999); + t.rtps.dg(9999); + t.rtps.dx(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_FALSE(t.rtps.ipv6_sedp_multicast_address(t.addr, 9999)); + } + + { + AddressTest t; + t.rtps.ipv6_sedp_multicast_address(NetworkAddress(1234, "[1:2:3:4]")); + ASSERT_TRUE(t.rtps.ipv6_sedp_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); + EXPECT_FALSE(t.fixed); + } +} +#endif From 6ee2f343b5e0eadef6f9ff8582d9652a53df792d Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 21 May 2024 10:21:04 -0500 Subject: [PATCH 30/60] Update Master with v3.28.1 Release --- NEWS.md | 34 +++++++++++++++++++++ docs/news.d/_releases/v3.28.1.rst | 40 +++++++++++++++++++++++++ docs/news.d/buffer-doc.rst | 5 ---- docs/news.d/cmake-ace-tao-src.rst | 7 ----- docs/news.d/compiler-warnings.rst | 5 ---- docs/news.d/gov-gen.rst | 5 ---- docs/news.d/heartbeat-fragmentation.rst | 5 ---- docs/news.d/mpcopts.rst | 13 -------- docs/news.d/type-object-encoding.rst | 5 ---- 9 files changed, 74 insertions(+), 45 deletions(-) create mode 100644 docs/news.d/_releases/v3.28.1.rst delete mode 100644 docs/news.d/buffer-doc.rst delete mode 100644 docs/news.d/cmake-ace-tao-src.rst delete mode 100644 docs/news.d/compiler-warnings.rst delete mode 100644 docs/news.d/gov-gen.rst delete mode 100644 docs/news.d/heartbeat-fragmentation.rst delete mode 100644 docs/news.d/mpcopts.rst delete mode 100644 docs/news.d/type-object-encoding.rst diff --git a/NEWS.md b/NEWS.md index 9b204cf1507..202f1362fdd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,39 @@ # OpenDDS Releases +## Version 3.28.1 of OpenDDS + +Released 2024-05-02 + +Download [this release on GitHub](https://github.com/OpenDDS/OpenDDS/releases/tag/DDS-3.28.1). + +Read [the documentation for this release on Read the Docs](https://opendds.readthedocs.io/en/dds-3.28.1). + +### Additions + +- Added [`OPENDDS_COMPILE_WARNINGS`](https://opendds.readthedocs.io/en/dds-3.28.1/devguide/building/index.html#cmake-var-OPENDDS_COMPILE_WARNINGS) and `configure` option `--compile-warnings=[WARNING|ERROR]` to enable additional compiler warnings and treating them as errors. ([PR #4558](https://github.com/OpenDDS/OpenDDS/pull/4558)) +- Add a `configure` script option for MPC options requiring a value. ([PR #4574](https://github.com/OpenDDS/OpenDDS/pull/4574)) + - For example, `./configure --mpc:value_template build_flags+="-Wall -Werror"`. + +### Platform Support and Dependencies + +- Building with CMake + - Fixed CMake saying it's missing the ACE library when using [`OPENDDS_ACE_TAO_SRC`](https://opendds.readthedocs.io/en/dds-3.28.1/devguide/building/index.html#cmake-var-OPENDDS_ACE_TAO_SRC) with an ACE/TAO outside of the build directory. ([PR #4604](https://github.com/OpenDDS/OpenDDS/pull/4604)) + +### Removals + +- Values passed to the configure script via `--mpcopts` are no longer split on spaces. ([PR #4574](https://github.com/OpenDDS/OpenDDS/pull/4574)) + - For example, `./configure --mpcopts="-value_template build_flags+=-Wall -Werror"` must now be written as `./configure --mpcopts=-value_template --mpcopts="build_flags+=-Wall -Werror"`. + +### Fixes + +- Fixed incorrect usage of OpenSSL in `gov_gen` application. ([PR #4591](https://github.com/OpenDDS/OpenDDS/pull/4591)) +- Fix bug where `Service_Participant::type_object_encoding` doesn't return configured value. ([PR #4593](https://github.com/OpenDDS/OpenDDS/pull/4593)) +- Do not send heartbeats during a fragmented send in `rtps_udp`. ([PR #4603](https://github.com/OpenDDS/OpenDDS/pull/4603)) + +### Documentation + +- Added [`[transport] send_buffer_size (rtps_udp)`](https://opendds.readthedocs.io/en/dds-3.28.1/devguide/run_time_configuration.html#cfg-prop-transport-rtps_udp-send_buffer_size) and [`[transport] rcv_buffer_size (rtps_udp)`](https://opendds.readthedocs.io/en/dds-3.28.1/devguide/run_time_configuration.html#cfg-prop-transport-rtps_udp-rcv_buffer_size). ([PR #4602](https://github.com/OpenDDS/OpenDDS/pull/4602)) + ## Version 3.28.0 of OpenDDS Released 2024-04-16 diff --git a/docs/news.d/_releases/v3.28.1.rst b/docs/news.d/_releases/v3.28.1.rst new file mode 100644 index 00000000000..bac0bfc7ddf --- /dev/null +++ b/docs/news.d/_releases/v3.28.1.rst @@ -0,0 +1,40 @@ +Released 2024-05-02 + +Download :ghrelease:`this release on GitHub `. + +Read `the documentation for this release on Read the Docs `__. + +Additions +========= + +- Added :cmake:var:`OPENDDS_COMPILE_WARNINGS` and ``configure`` option ``--compile-warnings=[WARNING|ERROR]`` to enable additional compiler warnings and treating them as errors. (:ghpr:`4558`) +- Add a ``configure`` script option for MPC options requiring a value. (:ghpr:`4574`) + + - For example, ``./configure --mpc:value_template build_flags+="-Wall -Werror"``. + +Platform Support and Dependencies +================================= + +- Building with CMake + + - Fixed CMake saying it's missing the ACE library when using :cmake:var:`OPENDDS_ACE_TAO_SRC` with an ACE/TAO outside of the build directory. (:ghpr:`4604`) + +Removals +======== + +- Values passed to the configure script via ``--mpcopts`` are no longer split on spaces. (:ghpr:`4574`) + + - For example, ``./configure --mpcopts="-value_template build_flags+=-Wall -Werror"`` must now be written as ``./configure --mpcopts=-value_template --mpcopts="build_flags+=-Wall -Werror"``. + +Fixes +===== + +- Fixed incorrect usage of OpenSSL in ``gov_gen`` application. (:ghpr:`4591`) +- Fix bug where ``Service_Participant::type_object_encoding`` doesn't return configured value. (:ghpr:`4593`) +- Do not send heartbeats during a fragmented send in ``rtps_udp``. (:ghpr:`4603`) + +Documentation +============= + +- Added :cfg:prop:`[transport@rtps_udp]send_buffer_size` and :cfg:prop:`[transport@rtps_udp]rcv_buffer_size`. (:ghpr:`4602`) + diff --git a/docs/news.d/buffer-doc.rst b/docs/news.d/buffer-doc.rst deleted file mode 100644 index 6648574a93e..00000000000 --- a/docs/news.d/buffer-doc.rst +++ /dev/null @@ -1,5 +0,0 @@ -.. news-prs: 4602 - -.. news-start-section: Documentation -- Added :cfg:prop:`[transport@rtps_udp]send_buffer_size` and :cfg:prop:`[transport@rtps_udp]rcv_buffer_size`. -.. news-end-section diff --git a/docs/news.d/cmake-ace-tao-src.rst b/docs/news.d/cmake-ace-tao-src.rst deleted file mode 100644 index 6ac106d57e9..00000000000 --- a/docs/news.d/cmake-ace-tao-src.rst +++ /dev/null @@ -1,7 +0,0 @@ -.. news-prs: 4604 - -.. news-start-section: Platform Support and Dependencies -.. news-start-section: Building with CMake -- Fixed CMake saying it's missing the ACE library when using :cmake:var:`OPENDDS_ACE_TAO_SRC` with an ACE/TAO outside of the build directory. -.. news-end-section -.. news-end-section diff --git a/docs/news.d/compiler-warnings.rst b/docs/news.d/compiler-warnings.rst deleted file mode 100644 index b5bac1d3f26..00000000000 --- a/docs/news.d/compiler-warnings.rst +++ /dev/null @@ -1,5 +0,0 @@ -.. news-prs: 4558 - -.. news-start-section: Additions -- Added :cmake:var:`OPENDDS_COMPILE_WARNINGS` and ``configure`` option ``--compile-warnings=[WARNING|ERROR]`` to enable additional compiler warnings and treating them as errors. -.. news-end-section diff --git a/docs/news.d/gov-gen.rst b/docs/news.d/gov-gen.rst deleted file mode 100644 index 4a628c16593..00000000000 --- a/docs/news.d/gov-gen.rst +++ /dev/null @@ -1,5 +0,0 @@ -.. news-prs: 4591 - -.. news-start-section: Fixes -- Fixed incorrect usage of OpenSSL in ``gov_gen`` application. -.. news-end-section diff --git a/docs/news.d/heartbeat-fragmentation.rst b/docs/news.d/heartbeat-fragmentation.rst deleted file mode 100644 index 417e63f691d..00000000000 --- a/docs/news.d/heartbeat-fragmentation.rst +++ /dev/null @@ -1,5 +0,0 @@ -.. news-prs: 4603 - -.. news-start-section: Fixes -- Do not send heartbeats during a fragmented send in ``rtps_udp``. -.. news-end-section diff --git a/docs/news.d/mpcopts.rst b/docs/news.d/mpcopts.rst deleted file mode 100644 index 6bb642e214b..00000000000 --- a/docs/news.d/mpcopts.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. news-prs: 4574 - -.. news-start-section: Removals -- Values passed to the configure script via ``--mpcopts`` are no longer split on spaces. - - - For example, ``./configure --mpcopts="-value_template build_flags+=-Wall -Werror"`` must now be written as ``./configure --mpcopts=-value_template --mpcopts="build_flags+=-Wall -Werror"``. -.. news-end-section - -.. news-start-section: Additions -- Add a ``configure`` script option for MPC options requiring a value. - - - For example, ``./configure --mpc:value_template build_flags+="-Wall -Werror"``. -.. news-end-section diff --git a/docs/news.d/type-object-encoding.rst b/docs/news.d/type-object-encoding.rst deleted file mode 100644 index 72311540e3e..00000000000 --- a/docs/news.d/type-object-encoding.rst +++ /dev/null @@ -1,5 +0,0 @@ -.. news-prs: 4593 - -.. news-start-section: Fixes -- Fix bug where ``Service_Participant::type_object_encoding`` doesn't return configured value. -.. news-end-section From b547e3635ea50340a6658648758b987db3b81319 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Fri, 24 May 2024 20:10:37 -0500 Subject: [PATCH 31/60] PortMode for RTPS/UDP, Fixes for RTPS Disc Ports --- dds/DCPS/NetworkResource.cpp | 28 +- dds/DCPS/NetworkResource.h | 13 + dds/DCPS/RTPS/MessageUtils.cpp | 11 +- dds/DCPS/RTPS/Sedp.cpp | 23 +- dds/DCPS/RTPS/Sedp.h | 4 +- dds/DCPS/RTPS/Spdp.cpp | 47 +-- .../transport/framework/TransportInst.cpp | 10 +- dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp | 204 +++++++++++-- dds/DCPS/transport/rtps_udp/RtpsUdpInst.h | 36 ++- .../transport/rtps_udp/RtpsUdpTransport.cpp | 160 +++++----- .../transport/rtps_udp/RtpsUdpTransport.h | 4 + .../ConcurrentAuthLimit.cpp | 7 +- .../dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp | 33 ++- .../DCPS/transport/rtps_udp/RtpsUdpInst.cpp | 276 ++++++++++++++++++ 14 files changed, 695 insertions(+), 161 deletions(-) create mode 100644 tests/unit-tests/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp diff --git a/dds/DCPS/NetworkResource.cpp b/dds/DCPS/NetworkResource.cpp index eebb6c39c0e..58949cffc93 100644 --- a/dds/DCPS/NetworkResource.cpp +++ b/dds/DCPS/NetworkResource.cpp @@ -1,16 +1,15 @@ /* - * - * * Distributed under the OpenDDS License. * See: http://www.opendds.org/license.html */ -#include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/ +#include // Only the _pch include should start with DCPS/ #include "NetworkResource.h" #include "LogAddr.h" #include "TimeTypes.h" +#include "debug.h" #include #include @@ -435,6 +434,29 @@ bool set_socket_multicast_ttl(const ACE_SOCK_Dgram& socket, const unsigned char& return true; } +bool set_recvpktinfo(ACE_SOCK_Dgram& sock, bool ipv4) +{ + bool success = true; +#if defined ACE_RECVPKTINFO || defined ACE_RECVPKTINFO6 + if (ipv4) { +# ifdef ACE_RECVPKTINFO + success = set_sock_opt(sock, IPPROTO_IP, ACE_RECVPKTINFO, 1); +# endif + } else { +# ifdef ACE_RECVPKTINFO6 + success = set_sock_opt(sock, IPPROTO_IPV6, ACE_RECVPKTINFO6, 1); +# endif + } + if (!success && log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: set_recvpktinfo: failed to set RECVPKTINFO: %m\n")); + } +# else + ACE_UNUSED_ARG(sock); + ACE_UNUSED_ARG(ipv4); +# endif + return success; +} + bool open_appropriate_socket_type(ACE_SOCK_Dgram& socket, const ACE_INET_Addr& local_address, int* proto_family) { #if defined (ACE_HAS_IPV6) && defined (IPV6_V6ONLY) diff --git a/dds/DCPS/NetworkResource.h b/dds/DCPS/NetworkResource.h index 539bf79cd71..214a698afd4 100644 --- a/dds/DCPS/NetworkResource.h +++ b/dds/DCPS/NetworkResource.h @@ -88,6 +88,19 @@ void get_interface_addrs(OPENDDS_VECTOR(ACE_INET_Addr)& addrs); extern OpenDDS_Dcps_Export bool set_socket_multicast_ttl(const ACE_SOCK_Dgram& socket, const unsigned char& ttl); +template +bool set_sock_opt(ACE_SOCK_Dgram& sock, + int level, int option, T value, bool ignore_notsup = false) +{ + if (sock.set_option(level, option, (void*) &value, sizeof(T)) < 0) { + return ignore_notsup && errno == ENOTSUP; + } + return true; +} + +OpenDDS_Dcps_Export +bool set_recvpktinfo(ACE_SOCK_Dgram& sock, bool ipv4); + /// Helper function to create dual stack socket to support IPV4 and IPV6, /// for IPV6 builds allows for setting IPV6_V6ONLY socket option to 0 before binding /// Otherwise defaults to opening a socket based on the type of local_address diff --git a/dds/DCPS/RTPS/MessageUtils.cpp b/dds/DCPS/RTPS/MessageUtils.cpp index 6802fd9fce9..13a805c3504 100644 --- a/dds/DCPS/RTPS/MessageUtils.cpp +++ b/dds/DCPS/RTPS/MessageUtils.cpp @@ -145,14 +145,15 @@ bool get_rtps_port(DDS::UInt16& port_result, const char* what, { const DDS::UInt32 port = static_cast(port_base) + domain * domain_gain + part * part_gain + offset; - ACE_DEBUG((LM_DEBUG, "HERE %C %u + %u * %u + %u * %u + %u = %u\n", what, port_base, domain, domain_gain, part, part_gain, offset, port)); + port_result = static_cast(port); if (port > 65535) { - if (log_level >= LogLevel::Error) { - ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: rtps_port: %C port %u is too high\n", what, port)); + if (log_level >= LogLevel::Warning) { + ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: rtps_port: " + "%C port %u is going to be truncated to %u. This behavior is deprecated, please reduce " + "domain ID or other RTPS port parameters.\n", + what, port, port_result)); } - return false; } - port_result = static_cast(port); return true; } diff --git a/dds/DCPS/RTPS/Sedp.cpp b/dds/DCPS/RTPS/Sedp.cpp index 6f64c38492c..49f66f6d44e 100644 --- a/dds/DCPS/RTPS/Sedp.cpp +++ b/dds/DCPS/RTPS/Sedp.cpp @@ -417,6 +417,7 @@ Sedp::init(const GUID_t& guid, DCPS::TransportRegistry::DEFAULT_INST_PREFIX + OPENDDS_STRING("_SEDPTransportInst_") + key + domainStr, "rtps_udp"); + DCPS::RtpsUdpInst_rch inst = DCPS::static_rchandle_cast(transport_inst_); // Be careful to not call any function that causes the transport be // to created before the configuration is complete. @@ -454,12 +455,17 @@ Sedp::init(const GUID_t& guid, config_store_->set(transport_inst_->config_key("MULTICAST_INTERFACE").c_str(), disco.multicast_interface()); } - DCPS::NetworkAddress addr4; - if (!disco.config()->sedp_unicast_address(addr4, domainId, ipv4_participant_port_id)) { - return DDS::RETCODE_ERROR; - } + inst->port_mode(disco.config()->sedp_port_mode()); + inst->pb(disco.config()->pb()); + inst->dg(disco.config()->dg()); + inst->pg(disco.config()->pg()); + inst->d2(disco.config()->dx()); + inst->d3(disco.config()->dy()); + inst->d3(disco.config()->dy()); + + inst->init_participant_port_id(ipv4_participant_port_id); config_store_->set(transport_inst_->config_key("LOCAL_ADDRESS").c_str(), - addr4, + disco.config()->sedp_local_address(), ConfigStoreImpl::Format_Required_Port, ConfigStoreImpl::Kind_IPV4); config_store_->set(transport_inst_->config_key("ADVERTISED_ADDRESS").c_str(), @@ -467,12 +473,9 @@ Sedp::init(const GUID_t& guid, ConfigStoreImpl::Format_Required_Port, ConfigStoreImpl::Kind_IPV4); #ifdef ACE_HAS_IPV6 - DCPS::NetworkAddress addr6; - if (!disco.config()->ipv6_sedp_unicast_address(addr6, domainId, ipv6_participant_port_id)) { - return DDS::RETCODE_ERROR; - } + inst->ipv6_init_participant_port_id(ipv6_participant_port_id); config_store_->set(transport_inst_->config_key("IPV6_LOCAL_ADDRESS").c_str(), - addr6, + disco.config()->ipv6_sedp_local_address(), ConfigStoreImpl::Format_Required_Port, ConfigStoreImpl::Kind_IPV6); config_store_->set(transport_inst_->config_key("IPV6_ADVERTISED_ADDRESS").c_str(), diff --git a/dds/DCPS/RTPS/Sedp.h b/dds/DCPS/RTPS/Sedp.h index a705f75657b..a32ed0628cc 100644 --- a/dds/DCPS/RTPS/Sedp.h +++ b/dds/DCPS/RTPS/Sedp.h @@ -587,6 +587,7 @@ class Sedp : public virtual DCPS::RcEventHandler { public: Endpoint(const DCPS::GUID_t& repo_id, Sedp& sedp) : repo_id_(repo_id) + , domain_id_(sedp.get_domain_id()) , sedp_(sedp) , shutting_down_(false) #ifdef OPENDDS_SECURITY @@ -612,7 +613,7 @@ class Sedp : public virtual DCPS::RcEventHandler { DDS::DomainId_t domain_id() const { - return 0; // not used for SEDP + return domain_id_; } CORBA::Long get_priority_value(const DCPS::AssociationData&) const @@ -665,6 +666,7 @@ class Sedp : public virtual DCPS::RcEventHandler { protected: DCPS::GUID_t repo_id_; + DDS::DomainId_t domain_id_; Sedp& sedp_; AtomicBool shutting_down_; #ifdef OPENDDS_SECURITY diff --git a/dds/DCPS/RTPS/Spdp.cpp b/dds/DCPS/RTPS/Spdp.cpp index c3a16b6d596..35ba9d0d7b2 100644 --- a/dds/DCPS/RTPS/Spdp.cpp +++ b/dds/DCPS/RTPS/Spdp.cpp @@ -47,6 +47,7 @@ using DCPS::ENDIAN_LITTLE; using DCPS::LogLevel; using DCPS::log_level; using DCPS::LogAddr; +using DCPS::set_sock_opt; namespace { const Encoding encoding_plain_big(Encoding::KIND_XCDR1, ENDIAN_BIG); @@ -2384,10 +2385,7 @@ Spdp::SpdpTransport::SpdpTransport(DCPS::RcHandle outer) const DCPS::NetworkAddressSet addrs = outer->config_->spdp_send_addrs(); send_addrs_.insert(addrs.begin(), addrs.end()); -#ifdef OPENDDS_SAFETY_PROFILE const DDS::UInt16 startingParticipantId = outer->ipv4_participant_port_id_; -#endif - const DDS::UInt16 max_part_id = 119; // RTPS 2.5 9.6.2.3 while (!open_unicast_socket(outer->ipv4_participant_port_id_)) { if (outer->ipv4_participant_port_id_ == max_part_id && log_level >= LogLevel::Warning) { @@ -2399,12 +2397,18 @@ Spdp::SpdpTransport::SpdpTransport(DCPS::RcHandle outer) // could use this as a hard limit, but that's much less of a concern. } ++outer->ipv4_participant_port_id_; + if (outer->ipv4_participant_port_id_ == startingParticipantId) { + throw std::runtime_error("could not find a free IPv4 unicast port for SPDP"); + } } #ifdef ACE_HAS_IPV6 outer->ipv6_participant_port_id_ = outer->ipv4_participant_port_id_; while (!open_unicast_ipv6_socket(outer->ipv6_participant_port_id_)) { ++outer->ipv6_participant_port_id_; + if (outer->ipv4_participant_port_id_ == outer->ipv6_participant_port_id_) { + throw std::runtime_error("could not find a free IPv6 unicast port for SPDP"); + } } #endif @@ -3447,18 +3451,6 @@ Spdp::SpdpTransport::open_unicast_socket(DDS::UInt16 participant_id) return true; } -namespace { - template - bool set_sock_opt(ACE_SOCK_Dgram& sock, - int level, int option, T value, bool ignore_notsup = false) - { - if (sock.set_option(level, option, (void*) &value, sizeof(T)) < 0) { - return ignore_notsup && errno == ENOTSUP; - } - return true; - } -} - void Spdp::SpdpTransport::set_unicast_socket_opts( DCPS::RcHandle& outer, ACE_SOCK_Dgram& sock, DDS::UInt16& port) { @@ -3467,18 +3459,13 @@ void Spdp::SpdpTransport::set_unicast_socket_opts( throw std::runtime_error("failed to get address from socket"); } port = addr.get_port_number(); - const bool ipv6 = -#ifdef ACE_HAS_IPV6 - addr.get_type () == AF_INET6; -#else - false; -#endif + const bool ipv4 = addr.get_type () == AF_INET; if (DCPS::DCPS_debug_level > 3) { ACE_DEBUG((LM_DEBUG, "(%P|%t) Spdp::SpdpTransport::set_unicast_socket_opts: " "opened %C unicast socket %d on port %d\n", - ipv6 ? "IPv6" : "IPv4", sock.get_handle(), port)); + ipv4 ? "IPv4" : "IPv6", sock.get_handle(), port)); } if (!DCPS::set_socket_multicast_ttl(sock, outer->config_->ttl())) { @@ -3509,21 +3496,7 @@ void Spdp::SpdpTransport::set_unicast_socket_opts( throw std::runtime_error("failed to set recv buffer size"); } - bool success = true; - if (ipv6) { -#ifdef ACE_RECVPKTINFO6 - success = set_sock_opt(sock, IPPROTO_IPV6, ACE_RECVPKTINFO6, 1); -#endif - } else { -#ifdef ACE_RECVPKTINFO - success = set_sock_opt(sock, IPPROTO_IP, ACE_RECVPKTINFO, 1); -#endif - } - if (!success) { - if (log_level >= LogLevel::Error) { - ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: Spdp::SpdpTransport::set_unicast_socket_opts: " - "failed to set RECVPKTINFO: %m\n")); - } + if (!DCPS::set_recvpktinfo(sock, ipv4)) { throw std::runtime_error("failed to set RECVPKTINFO"); } } diff --git a/dds/DCPS/transport/framework/TransportInst.cpp b/dds/DCPS/transport/framework/TransportInst.cpp index 50013b16f97..ac3f4467ae0 100644 --- a/dds/DCPS/transport/framework/TransportInst.cpp +++ b/dds/DCPS/transport/framework/TransportInst.cpp @@ -287,23 +287,23 @@ TransportInst::get_or_create_impl(DDS::DomainId_t domain, { ACE_GUARD_RETURN(ACE_SYNCH_MUTEX, g, lock_, TransportImpl_rch()); - // Only use the domain if the inst is a template. + // Only use the domain to find the impl is if this inst is a template. // Furthermore, only use the client if the instantiation rule is per_participant. - + DDS::DomainId_t find_domain = domain; if (is_template_) { if (instantiation_rule() != "per_participant") { participant = 0; } } else { - domain = 0; + find_domain = 0; participant = 0; } if (!shutting_down_) { try { - DomainMap::iterator pos = domain_map_.find(domain); + DomainMap::iterator pos = domain_map_.find(find_domain); if (pos == domain_map_.end()) { - pos = domain_map_.insert(std::make_pair(domain, ParticipantMap())).first; + pos = domain_map_.insert(std::make_pair(find_domain, ParticipantMap())).first; } ParticipantMap::iterator pos2 = pos->second.find(participant); if (pos2 == pos->second.end()) { diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp b/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp index 122a09ba2b5..a965d753c64 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp @@ -1,12 +1,11 @@ /* - * - * * Distributed under the OpenDDS License. * See: http://www.opendds.org/license.html */ -#include "RtpsSampleHeader.h" #include "RtpsUdpInst.h" + +#include "RtpsSampleHeader.h" #include "RtpsUdpLoader.h" #include "RtpsUdpTransport.h" #include "RtpsUdpSendStrategy.h" @@ -235,6 +234,86 @@ RtpsUdpInst::send_delay() const ConfigStoreImpl::Format_IntegerMilliseconds); } +RTPS::PortMode RtpsUdpInst::port_mode() const +{ + return get_port_mode(config_key("PORT_MODE"), RTPS::PortMode_System); +} + +void RtpsUdpInst::port_mode(RTPS::PortMode value) +{ + set_port_mode(config_key("PORT_MODE"), value); +} + +void RtpsUdpInst::pb(DDS::UInt16 port_base) +{ + TheServiceParticipant->config_store()->set_uint32(config_key("PB").c_str(), + port_base); +} + +DDS::UInt16 RtpsUdpInst::pb() const +{ + return TheServiceParticipant->config_store()->get_uint32(config_key("PB").c_str(), + RTPS::default_port_base); +} + +void RtpsUdpInst::dg(DDS::UInt16 domain_gain) +{ + TheServiceParticipant->config_store()->set_uint32(config_key("DG").c_str(), + domain_gain); +} + +DDS::UInt16 RtpsUdpInst::dg() const +{ + return TheServiceParticipant->config_store()->get_uint32(config_key("DG").c_str(), + RTPS::default_domain_gain); +} + +void RtpsUdpInst::pg(DDS::UInt16 participant_gain) +{ + TheServiceParticipant->config_store()->set_uint32(config_key("PG").c_str(), + participant_gain); +} + +DDS::UInt16 RtpsUdpInst::pg() const +{ + return TheServiceParticipant->config_store()->get_uint32(config_key("PG").c_str(), + RTPS::default_part_gain); +} + +void RtpsUdpInst::d2(DDS::UInt16 multicast_offset) +{ + TheServiceParticipant->config_store()->set_uint32(config_key("D2").c_str(), + multicast_offset); +} + +DDS::UInt16 RtpsUdpInst::d2() const +{ + return TheServiceParticipant->config_store()->get_uint32(config_key("D2").c_str(), + RTPS::default_user_multicast_offset); +} + +void RtpsUdpInst::d3(DDS::UInt16 unicast_offset) +{ + TheServiceParticipant->config_store()->set_uint32(config_key("D3").c_str(), + unicast_offset); +} + +DDS::UInt16 RtpsUdpInst::d3() const +{ + return TheServiceParticipant->config_store()->get_uint32(config_key("D3").c_str(), + RTPS::default_user_unicast_offset); +} + +bool RtpsUdpInst::multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const +{ + return RTPS::get_rtps_port(port, "RTPS/UDP multicast", pb(), d2(), domain, dg()); +} + +bool RtpsUdpInst::unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const +{ + return RTPS::get_rtps_port(port, "RTPS/UDP unicast", pb(), d3(), domain, dg(), part, pg()); +} + void RtpsUdpInst::multicast_group_address(const NetworkAddress& addr) { @@ -247,10 +326,23 @@ RtpsUdpInst::multicast_group_address(const NetworkAddress& addr) NetworkAddress RtpsUdpInst::multicast_group_address(DDS::DomainId_t domain) const { - NetworkAddress na = TheServiceParticipant->config_store()->get(config_key("MULTICAST_GROUP_ADDRESS").c_str(), - NetworkAddress(7401, "239.255.0.2"), - ConfigStoreImpl::Format_Optional_Port, - ConfigStoreImpl::Kind_IPV4); + NetworkAddress addr; + return multicast_address(addr, domain) ? addr : NetworkAddress(); +} + +bool RtpsUdpInst::multicast_address(DCPS::NetworkAddress& na, DDS::DomainId_t domain) const +{ + na = TheServiceParticipant->config_store()->get(config_key("MULTICAST_GROUP_ADDRESS").c_str(), + NetworkAddress(0, "239.255.0.2"), + ConfigStoreImpl::Format_Optional_Port, + ConfigStoreImpl::Kind_IPV4); + DDS::UInt16 default_port = 0; + if (!multicast_port(default_port, domain)) { + return false; + } + if (na.get_port_number() == 0) { + na.set_port_number(default_port); + } const NetworkAddress na_original = na; if (is_template()) { @@ -275,7 +367,7 @@ RtpsUdpInst::multicast_group_address(DDS::DomainId_t domain) const "could not convert %C to integer\n", last_octet.c_str())); } - return na; + return false; } val += domain; @@ -289,10 +381,10 @@ RtpsUdpInst::multicast_group_address(DDS::DomainId_t domain) const "could not add_domain_id_to_ip_addr for address %C\n", addr.c_str())); } - return na; + return false; } - if (log_level >= LogLevel::Debug && DCPS_debug_level > 0) { + if (DCPS_debug_level > 0) { ACE_DEBUG((LM_DEBUG, "(%P|%t) DEBUG: RtpsUdpInst::multicast_group_address: " "processing add_domain_id_to_ip_addr: %C=%C => %C\n", @@ -302,17 +394,14 @@ RtpsUdpInst::multicast_group_address(DDS::DomainId_t domain) const if (directive.find("add_domain_id_to_port") != directive.npos) { if (na.get_port_number() == 0) { - // use default port + domainId. See 9.6.1.3 in the RTPS 2.2 protocol specification. - const int PB = 7400; - const int DG = 250; - const int D2 = 1; - na.set_port_number(PB + DG * domain + D2 + domain); + // use default port + domainId + na.set_port_number(default_port + domain); } else { // address has a port supplied na.set_port_number(na.get_port_number() + domain); } - if (log_level >= LogLevel::Debug && DCPS_debug_level > 0) { + if (DCPS_debug_level > 0) { ACE_DEBUG((LM_DEBUG, "(%P|%t) DEBUG: RtpsUdpInst::multicast_group_address: " "processing add_domain_id_to_port: %C=%C => %C\n", @@ -322,7 +411,19 @@ RtpsUdpInst::multicast_group_address(DDS::DomainId_t domain) const } } - return na; + return true; +} + +void RtpsUdpInst::init_participant_port_id(DDS::UInt16 part_id) +{ + TheServiceParticipant->config_store()->set_uint32(config_key("INIT_PARTICIPANT_PORT_ID").c_str(), + part_id); +} + +DDS::UInt16 RtpsUdpInst::init_participant_port_id() const +{ + return TheServiceParticipant->config_store()->get_uint32(config_key("INIT_PARTICIPANT_PORT_ID").c_str(), + 0); } void @@ -343,6 +444,21 @@ RtpsUdpInst::local_address() const ConfigStoreImpl::Kind_IPV4); } +bool RtpsUdpInst::unicast_address(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const +{ + addr = local_address(); + fixed_port = addr.get_port_number() > 0; + if (!fixed_port && port_mode() == RTPS::PortMode_Probe) { + DDS::UInt16 port; + if (!unicast_port(port, domain, part_id)) { + return false; + } + addr.set_port_number(port); + } + return true; +} + void RtpsUdpInst::advertised_address(const NetworkAddress& addr) { @@ -372,12 +488,39 @@ RtpsUdpInst::ipv6_multicast_group_address(const NetworkAddress& addr) } NetworkAddress -RtpsUdpInst::ipv6_multicast_group_address() const +RtpsUdpInst::ipv6_multicast_group_address(DDS::DomainId_t domain) const { - return TheServiceParticipant->config_store()->get(config_key("IPV6_MULTICAST_GROUP_ADDRESS").c_str(), - NetworkAddress(7401, "FF03::2"), - ConfigStoreImpl::Format_Optional_Port, - ConfigStoreImpl::Kind_IPV6); + NetworkAddress addr; + return ipv6_multicast_address(addr, domain) ? addr : NetworkAddress(); +} + +bool RtpsUdpInst::ipv6_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const +{ + NetworkAddress addr = TheServiceParticipant->config_store()->get( + config_key("IPV6_MULTICAST_GROUP_ADDRESS").c_str(), + NetworkAddress(0, "FF03::2"), ConfigStoreImpl::Format_Optional_Port, + ConfigStoreImpl::Kind_IPV6); + + if (na.get_port_number() == 0) { + DDS::UInt16 default_port = 0; + if (!multicast_port(default_port, domain)) { + return false; + } + na.set_port_number(default_port); + } + return +} + +void RtpsUdpInst::ipv6_init_participant_port_id(DDS::UInt16 part_id) +{ + TheServiceParticipant->config_store()->set_uint32(config_key("IPV6_INIT_PARTICIPANT_PORT_ID").c_str(), + part_id); +} + +DDS::UInt16 RtpsUdpInst::ipv6_init_participant_port_id() const +{ + return TheServiceParticipant->config_store()->get_uint32(config_key("IPV6_INIT_PARTICIPANT_PORT_ID").c_str(), + 0); } void @@ -398,6 +541,21 @@ RtpsUdpInst::ipv6_local_address() const ConfigStoreImpl::Kind_IPV6); } +bool RtpsUdpInst::ipv6_unicast_address(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const +{ + addr = ipv6_local_address(); + fixed_port = addr.get_port_number() > 0; + if (!fixed_port && port_mode() == RTPS::PortMode_Probe) { + DDS::UInt16 port; + if (!unicast_port(port, domain, part_id)) { + return false; + } + addr.set_port_number(port); + } + return true; +} + void RtpsUdpInst::ipv6_advertised_address(const NetworkAddress& addr) { @@ -514,7 +672,7 @@ RtpsUdpInst::dump_to_str(DDS::DomainId_t domain) const ret += formatNameForDump("local_address") + LogAddr(local_address()).str() + '\n'; ret += formatNameForDump("advertised_address") + LogAddr(advertised_address()).str() + '\n'; #ifdef ACE_HAS_IPV6 - ret += formatNameForDump("ipv6_multicast_group_address") + LogAddr(ipv6_multicast_group_address()).str() + '\n'; + ret += formatNameForDump("ipv6_multicast_group_address") + LogAddr(ipv6_multicast_group_address(domain)).str() + '\n'; ret += formatNameForDump("ipv6_local_address") + LogAddr(ipv6_local_address()).str() + '\n'; ret += formatNameForDump("ipv6_advertised_address") + LogAddr(ipv6_advertised_address()).str() + '\n'; #endif diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpInst.h b/dds/DCPS/transport/rtps_udp/RtpsUdpInst.h index e648cd2ba8e..5c39013a8a9 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpInst.h +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpInst.h @@ -1,6 +1,4 @@ /* - * - * * Distributed under the OpenDDS License. * See: http://www.opendds.org/license.html */ @@ -14,6 +12,7 @@ #include #include #include +#include #include OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL @@ -97,21 +96,54 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpInst : public TransportInst { DDS::DomainId_t domain) const; const TransportBLOB* get_blob(const OpenDDS::DCPS::TransportLocatorSeq& trans_info) const; + RTPS::PortMode port_mode() const; + void port_mode(RTPS::PortMode value); + + void pb(DDS::UInt16 port_base); + DDS::UInt16 pb() const; + + void dg(DDS::UInt16 domain_gain); + DDS::UInt16 dg() const; + + void pg(DDS::UInt16 participant_gain); + DDS::UInt16 pg() const; + + void d2(DDS::UInt16 multicast_offset); + DDS::UInt16 d2() const; + + void d3(DDS::UInt16 unicast_offset); + DDS::UInt16 d3() const; + + bool multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const; + bool unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const; + + bool multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; void multicast_group_address(const NetworkAddress& addr); NetworkAddress multicast_group_address(DDS::DomainId_t domain) const; + void init_participant_port_id(DDS::UInt16 part_id); + DDS::UInt16 init_participant_port_id() const; + void local_address(const NetworkAddress& addr); NetworkAddress local_address() const; + bool unicast_address(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const; void advertised_address(const NetworkAddress& addr); NetworkAddress advertised_address() const; #ifdef ACE_HAS_IPV6 + bool ipv6_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; void ipv6_multicast_group_address(const NetworkAddress& addr); NetworkAddress ipv6_multicast_group_address() const; + void ipv6_init_participant_port_id(DDS::UInt16 part_id); + DDS::UInt16 ipv6_init_participant_port_id() const; + void ipv6_local_address(const NetworkAddress& addr); NetworkAddress ipv6_local_address() const; + bool ipv6_unicast_address(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const; void ipv6_advertised_address(const NetworkAddress& addr); NetworkAddress ipv6_advertised_address() const; diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp index 46686827a05..097fb6a4665 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp @@ -512,26 +512,41 @@ RtpsUdpTransport::append_transport_statistics(TransportStatisticsSequence& seq) core_.append_transport_statistics(seq); } -bool -RtpsUdpTransport::configure_i(const RtpsUdpInst_rch& config) +bool RtpsUdpTransport::open_socket( + const RtpsUdpInst_rch& config, ACE_SOCK_Dgram& sock, int protocol, DDS::UInt16 part_port_id, + NetworkAddress& actual, bool& fail) { - if (!config) { + fail = true; + const bool ipv4 = protocol == PF_INET; + + NetworkAddress address; + bool fixed_port; + if (ipv4) { + if (!config->unicast_address(address, fixed_port, domain_, part_port_id)) { + return false; + } +#ifdef ACE_HAS_IPV6 + } else if (!config->ipv6_unicast_address(address, fixed_port, domain_, part_port_id)) { return false; +#endif } - // Open the socket here so that any addresses/ports left - // unspecified in the RtpsUdpInst are known by the time we get to - // connection_info_i(). Opening the sockets here also allows us to - // detect and report errors during DataReader/Writer setup instead - // of during association. - - const NetworkAddress address4 = config->local_address(); - - if (unicast_socket_.open(address4.to_addr(), PF_INET) != 0) { - ACE_ERROR_RETURN((LM_ERROR, - ACE_TEXT("(%P|%t) ERROR: RtpsUdpTransport::configure_i: open4 %C: %m\n"), - LogAddr(address4).c_str()), - false); + if (sock.open(address.to_addr(), protocol) != 0) { + if (fixed_port) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: RtpsUdpTransport::open_socket: " + "failed to open unicast %C socket for %C: %m\n", + ipv4 ? "IPv4" : "IPv6", LogAddr(address).c_str())); + } + } else { + if (DCPS::DCPS_debug_level > 3) { + ACE_DEBUG((LM_DEBUG, "(%P|%t) RtpsUdpTransport::open_socket: " + "failed to open unicast %C socket for %C: %m, trying next participant ID...\n", + ipv4 ? "IPv4" : "IPv6", LogAddr(address).c_str())); + } + fail = false; + } + return false; } #ifdef ACE_WIN32 @@ -542,73 +557,88 @@ RtpsUdpTransport::configure_i(const RtpsUdpInst_rch& config) // which in this case is used to receive from multiple peers. { BOOL recv_udp_connreset = FALSE; - unicast_socket_.control(SIO_UDP_CONNRESET, &recv_udp_connreset); + sock.control(SIO_UDP_CONNRESET, &recv_udp_connreset); } #endif - ACE_INET_Addr actual4; - if (unicast_socket_.get_local_addr(actual4) != 0) { - ACE_ERROR_RETURN((LM_ERROR, - ACE_TEXT("(%P|%t) ERROR: RtpsUdpTransport::configure_i: get_local_addr4 %C: %m\n"), - LogAddr(address4).c_str()), - false); + ACE_INET_Addr ace_actual; + if (sock.get_local_addr(ace_actual) != 0) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: RtpsUdpTransport::open_socket: " + "failed to get actual address from %C socket for %C: %m\n", + ipv4 ? "IPv4" : "IPv6", LogAddr(address).c_str())); + } + return false; } + actual = ace_actual; - config->actual_local_address_ = NetworkAddress(actual4); - -#ifdef ACE_RECVPKTINFO - int sockopt = 1; - if (unicast_socket_.set_option(IPPROTO_IP, ACE_RECVPKTINFO, &sockopt, sizeof sockopt) == -1) { - ACE_ERROR_RETURN((LM_ERROR, - ACE_TEXT("(%P|%t) ERROR: RtpsUdpTransport::configure_i: set_option4 %C: %m\n"), - LogAddr(address4).c_str()), false); + if (!set_recvpktinfo(sock, ipv4)) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: RtpsUdpTransport::open_socket: " + "failed to set RECVPKTINFO on %C socket for %C\n", + ipv4 ? "IPv4" : "IPv6", LogAddr(address).c_str())); + } + return false; } -#endif -#ifdef ACE_HAS_IPV6 - const NetworkAddress address6 = config->ipv6_local_address(); + fail = false; + return true; +} - if (ipv6_unicast_socket_.open(address6.to_addr(), PF_INET6) != 0) { - ACE_ERROR_RETURN((LM_ERROR, - ACE_TEXT("(%P|%t) ERROR: RtpsUdpTransport::configure_i: open6 %C: %m\n"), - LogAddr(address6).c_str()), - false); +bool +RtpsUdpTransport::configure_i(const RtpsUdpInst_rch& config) +{ + if (!config) { + return false; } -#ifdef ACE_WIN32 - // By default Winsock will cause reads to fail with "connection reset" - // when UDP sends result in ICMP "port unreachable" messages. - // The transport framework is not set up for this since returning <= 0 - // from our receive_bytes causes the framework to close down the datalink - // which in this case is used to receive from multiple peers. - { - BOOL recv_udp_connreset = FALSE; - ipv6_unicast_socket_.control(SIO_UDP_CONNRESET, &recv_udp_connreset); - } -#endif + // Open the socket here so that any addresses/ports left + // unspecified in the RtpsUdpInst are known by the time we get to + // connection_info_i(). Opening the sockets here also allows us to + // detect and report errors during DataReader/Writer setup instead + // of during association. - ACE_INET_Addr actual6; - if (ipv6_unicast_socket_.get_local_addr(actual6) != 0) { - ACE_ERROR_RETURN((LM_ERROR, - ACE_TEXT("(%P|%t) ERROR: RtpsUdpTransport::configure_i: get_local_addr6 %C: %m\n"), - LogAddr(address6).c_str()), - false); + bool error = false; + const DDS::UInt16 init_part_port_id4 = config->init_participant_port_id(); + DDS::UInt16 part_port_id4 = init_part_port_id4; + NetworkAddress actual4; + while (!open_socket(config, unicast_socket_, PF_INET, part_port_id4, actual4, error) && !error) { + ++part_port_id4; + if (part_port_id4 == init_part_port_id4) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: RtpsUdpTransport::configure_i: " + "could not find a free IPv4 unicast port\n")); + } + return false; + } } + if (error) { + return false; + } + config->actual_local_address_ = actual4; +#ifdef ACE_HAS_IPV6 + const DDS::UInt16 init_part_port_id6 = config->ipv6_init_participant_port_id(); + DDS::UInt16 part_port_id6 = init_part_port_id6; + NetworkAddress actual6; + while (!open_socket(config, ipv6_unicast_socket_, PF_INET6, part_port_id, actual6, error) && !error) { + ++part_port_id6; + if (part_port_id6 == init_part_port_id6) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: RtpsUdpTransport::configure_i: " + "could not find a free IPv6 unicast port\n")); + } + return false; + } + } + if (error) { + return false; + } NetworkAddress temp(actual6); if (actual6.is_ipv4_mapped_ipv6() && temp.is_any()) { temp = NetworkAddress(actual6.get_port_number(), "::"); } config->ipv6_actual_local_address_ = temp; - -#ifdef ACE_RECVPKTINFO6 - if (ipv6_unicast_socket_.set_option(IPPROTO_IPV6, ACE_RECVPKTINFO6, &sockopt, sizeof sockopt) == -1) { - ACE_ERROR_RETURN((LM_ERROR, - ACE_TEXT("(%P|%t) ERROR: RtpsUdpTransport::configure_i: set_option4 %C: %m\n"), - LogAddr(address6).c_str()), - false); - } -#endif #endif create_reactor_task(false, "RtpsUdpTransport" + config->name()); diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h index b30fcd43eeb..197ea73e53d 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h @@ -288,6 +288,10 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpTransport : public TransportImpl, public Co bool disassociate, bool association_failed); + bool open_socket( + const RtpsUdpInst_rch& config, ACE_SOCK_Dgram& sock, int protocol, DDS::UInt16 part_port_id, + NetworkAddress& actual, bool& fail); + bool configure_i(const RtpsUdpInst_rch& config); void client_stop(const GUID_t& localId); diff --git a/tests/security/ConcurrentAuthLimit/ConcurrentAuthLimit.cpp b/tests/security/ConcurrentAuthLimit/ConcurrentAuthLimit.cpp index f73b7bd66ad..5efc5107369 100644 --- a/tests/security/ConcurrentAuthLimit/ConcurrentAuthLimit.cpp +++ b/tests/security/ConcurrentAuthLimit/ConcurrentAuthLimit.cpp @@ -264,8 +264,11 @@ int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) return EXIT_FAILURE; } - const u_short port_common = disc->config()->port_common(domain); - const NetworkAddress multicast_address = disc->config()->multicast_address(port_common, domain); + NetworkAddress multicast_address; + if (!disc->config()->spdp_multicast_address(multicast_address, domain)) { + ACE_ERROR((LM_ERROR, "ERROR: failed to get SPDP multicast address\n")); + return EXIT_FAILURE; + } ACE_DEBUG((LM_DEBUG, "multicast_address = %C\n", LogAddr(multicast_address).c_str())); ACE_SOCK_Dgram_Mcast multicast_socket; #ifdef ACE_HAS_MAC_OSX diff --git a/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp b/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp index 5964e8e627a..3c58317c493 100644 --- a/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp +++ b/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp @@ -82,7 +82,9 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, sedp_unicast_address) t.rtps.dy(9999); LogRestore lr; log_level.set(LogLevel::None); - ASSERT_FALSE(t.rtps.sedp_unicast_address(t.addr, 9999, 9999)); + ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 9999, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, "0.0.0.0")); + EXPECT_FALSE(t.fixed); } { @@ -149,7 +151,9 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_unicast_address) t.rtps.d1(9999); LogRestore lr; log_level.set(LogLevel::None); - ASSERT_FALSE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 9999, 9999)); + ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 9999, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, "0.0.0.0")); + EXPECT_FALSE(t.fixed); } { @@ -194,7 +198,9 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_multicast_address) t.rtps.d0(9999); LogRestore lr; log_level.set(LogLevel::None); - ASSERT_FALSE(t.rtps.spdp_multicast_address(t.addr, 9999)); + ASSERT_TRUE(t.rtps.spdp_multicast_address(t.addr, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, "239.255.0.1")); + EXPECT_FALSE(t.fixed); } { @@ -239,7 +245,10 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, sedp_multicast_address) t.rtps.dx(9999); LogRestore lr; log_level.set(LogLevel::None); - ASSERT_FALSE(t.rtps.sedp_multicast_address(t.addr, 9999)); + ASSERT_TRUE(t.rtps.sedp_multicast_address(t.addr, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, "239.255.0.1")); + + EXPECT_FALSE(t.fixed); } { @@ -306,7 +315,9 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_sedp_unicast_address) t.rtps.dy(9999); LogRestore lr; log_level.set(LogLevel::None); - ASSERT_FALSE(t.rtps.ipv6_sedp_unicast_address(t.addr, 9999, 9999)); + ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 9999, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, "[::]")); + EXPECT_FALSE(t.fixed); } { @@ -373,7 +384,9 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_unicast_address) t.rtps.d1(9999); LogRestore lr; log_level.set(LogLevel::None); - ASSERT_FALSE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 9999, 9999)); + ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 9999, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, "[::]")); + EXPECT_FALSE(t.fixed); } { @@ -418,7 +431,9 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_multicast_address) t.rtps.d0(9999); LogRestore lr; log_level.set(LogLevel::None); - ASSERT_FALSE(t.rtps.ipv6_spdp_multicast_address(t.addr, 9999)); + ASSERT_TRUE(t.rtps.ipv6_spdp_multicast_address(t.addr, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, "[FF03::1]")); + EXPECT_FALSE(t.fixed); } { @@ -463,7 +478,9 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_sedp_multicast_address) t.rtps.dx(9999); LogRestore lr; log_level.set(LogLevel::None); - ASSERT_FALSE(t.rtps.ipv6_sedp_multicast_address(t.addr, 9999)); + ASSERT_TRUE(t.rtps.ipv6_sedp_multicast_address(t.addr, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, "[FF03::1]")); + EXPECT_FALSE(t.fixed); } { diff --git a/tests/unit-tests/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp b/tests/unit-tests/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp new file mode 100644 index 00000000000..f7e22f36aae --- /dev/null +++ b/tests/unit-tests/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp @@ -0,0 +1,276 @@ +#include + +#include + +using namespace OpenDDS::RTPS; +using namespace OpenDDS::DCPS; + +namespace { + struct RtpsUdpType { + RcHandle store; + RcHandle rtps_udp; + + RtpsUdpType() + : store(make_rch(TheServiceParticipant->config_topic())) + , rtps_udp(make_rch("RTPS_UDP_INST_UNIT_TEST", false)) + { + store->unset_section(rtps_udp->config_prefix()); + } + + ~RtpsUdpType() + { + store->unset_section(rtps_udp->config_prefix()); + } + }; + + struct AddressTest : public RtpsUdpType { + NetworkAddress addr; + bool fixed; + + AddressTest() + : addr() + , fixed(false) + { + } + }; +} + +TEST(dds_DCPS_RTPS_RtpsUdpInst, multicast_address) +{ + const char* const default_addr = "239.255.0.2"; + + { + AddressTest t; + ASSERT_TRUE(t.rtps_udp->multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7651, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + ASSERT_TRUE(t.rtps_udp->multicast_address(t.addr, 2)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7901, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->pb(7500); + t.rtps_udp->dg(260); + t.rtps_udp->d2(17); + ASSERT_TRUE(t.rtps_udp->multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->pb(9999); + t.rtps_udp->dg(9999); + t.rtps_udp->d2(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_TRUE(t.rtps_udp->multicast_address(t.addr, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->multicast_group_address(NetworkAddress(1234, "1.2.3.4")); + ASSERT_TRUE(t.rtps_udp->multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); + EXPECT_FALSE(t.fixed); + } +} + +TEST(dds_DCPS_RTPS_RtpsUdpInst, unicast_address) +{ + const char* const default_addr = "0.0.0.0"; + + { + AddressTest t; + ASSERT_TRUE(t.rtps_udp->unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress()); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->port_mode(PortMode_System); + ASSERT_TRUE(t.rtps_udp->unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress()); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps_udp->unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7661, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps_udp->unicast_address(t.addr, t.fixed, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7667, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->port_mode(PortMode_Probe); + t.rtps_udp->pb(7500); + t.rtps_udp->dg(260); + t.rtps_udp->pg(3); + t.rtps_udp->d3(8); + ASSERT_TRUE(t.rtps_udp->unicast_address(t.addr, t.fixed, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->port_mode(PortMode_Probe); + t.rtps_udp->pb(9999); + t.rtps_udp->dg(9999); + t.rtps_udp->pg(9999); + t.rtps_udp->d3(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_TRUE(t.rtps_udp->unicast_address(t.addr, t.fixed, 9999, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->local_address(NetworkAddress(1234, "1.2.3.4")); + ASSERT_TRUE(t.rtps_udp->unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); + EXPECT_TRUE(t.fixed); + } +} + +#ifdef ACE_HAS_IPV6 +TEST(dds_DCPS_RTPS_RtpsUdpInst, ipv6_multicast_address) +{ + const char* const default_addr = "239.255.0.2"; + + { + AddressTest t; + ASSERT_TRUE(t.rtps_udp->ipv6_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7651, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + ASSERT_TRUE(t.rtps_udp->ipv6_multicast_address(t.addr, 2)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7901, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->pb(7500); + t.rtps_udp->dg(260); + t.rtps_udp->d2(17); + ASSERT_TRUE(t.rtps_udp->ipv6_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->pb(9999); + t.rtps_udp->dg(9999); + t.rtps_udp->d2(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_TRUE(t.rtps_udp->ipv6_multicast_address(t.addr, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->multicast_group_address(NetworkAddress(1234, "[1:2:3:4]")); + ASSERT_TRUE(t.rtps_udp->ipv6_multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); + EXPECT_FALSE(t.fixed); + } +} + +TEST(dds_DCPS_RTPS_RtpsUdpInst, ipv6_unicast_address) +{ + const char* const default_addr = "[::]"; + + { + AddressTest t; + ASSERT_TRUE(t.rtps_udp->ipv6_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress()); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->port_mode(PortMode_System); + ASSERT_TRUE(t.rtps_udp->ipv6_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress()); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps_udp->ipv6_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7661, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->port_mode(PortMode_Probe); + ASSERT_TRUE(t.rtps_udp->ipv6_unicast_address(t.addr, t.fixed, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7667, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->port_mode(PortMode_Probe); + t.rtps_udp->pb(7500); + t.rtps_udp->dg(260); + t.rtps_udp->pg(3); + t.rtps_udp->d3(8); + ASSERT_TRUE(t.rtps_udp->ipv6_unicast_address(t.addr, t.fixed, 1, 3)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->port_mode(PortMode_Probe); + t.rtps_udp->pb(9999); + t.rtps_udp->dg(9999); + t.rtps_udp->pg(9999); + t.rtps_udp->d3(9999); + LogRestore lr; + log_level.set(LogLevel::None); + ASSERT_TRUE(t.rtps_udp->ipv6_unicast_address(t.addr, t.fixed, 9999, 9999)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, default_addr)); + EXPECT_FALSE(t.fixed); + } + + { + AddressTest t; + t.rtps_udp->local_address(NetworkAddress(1234, "[1:2:3:4]")); + ASSERT_TRUE(t.rtps_udp->ipv6_unicast_address(t.addr, t.fixed, 1, 0)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); + EXPECT_TRUE(t.fixed); + } +} +#endif From 5e07cfbf3c5fb323fbb2b6a5792591685238b82b Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 28 May 2024 02:31:17 -0500 Subject: [PATCH 32/60] Fix IPv6, SEDP Ports, Simplify Code, and News --- dds/DCPS/RTPS/MessageUtils.cpp | 33 ++ dds/DCPS/RTPS/MessageUtils.h | 14 + dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp | 128 +------ dds/DCPS/RTPS/RtpsDiscoveryConfig.h | 17 +- dds/DCPS/RTPS/Sedp.cpp | 34 +- dds/DCPS/RTPS/Spdp.cpp | 2 +- .../transport/rtps_udp/RtpsUdpDataLink.cpp | 2 +- dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp | 51 +-- dds/DCPS/transport/rtps_udp/RtpsUdpInst.h | 7 +- .../transport/rtps_udp/RtpsUdpTransport.cpp | 91 ++--- .../transport/rtps_udp/RtpsUdpTransport.h | 3 +- docs/devguide/run_time_configuration.rst | 311 ++++++++++++++---- docs/news.d/rtps-ports.rst | 22 ++ .../dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp | 299 +++-------------- .../DCPS/transport/rtps_udp/RtpsUdpInst.cpp | 65 ++-- 15 files changed, 510 insertions(+), 569 deletions(-) create mode 100644 docs/news.d/rtps-ports.rst diff --git a/dds/DCPS/RTPS/MessageUtils.cpp b/dds/DCPS/RTPS/MessageUtils.cpp index 13a805c3504..95cbda5d061 100644 --- a/dds/DCPS/RTPS/MessageUtils.cpp +++ b/dds/DCPS/RTPS/MessageUtils.cpp @@ -174,6 +174,39 @@ void set_port_mode(const String& key, PortMode value) TheServiceParticipant->config_store()->set(key.c_str(), value, port_modes); } +bool set_rtps_multicast_port( + DCPS::NetworkAddress& addr, const char* what, + DDS::UInt16 port_base, DDS::UInt16 offset, + DDS::UInt16 domain, DDS::UInt16 domain_gain) +{ + if (addr.get_port_number() == 0) { + DDS::UInt16 port; + if (!get_rtps_port(port, what, port_base, offset, domain, domain_gain)) { + return false; + } + addr.set_port_number(port); + } + return true; +} + +bool set_rtps_unicast_port( + DCPS::NetworkAddress& addr, bool& fixed_port, + const char* what, PortMode port_mode, + DDS::UInt16 port_base, DDS::UInt16 offset, + DDS::UInt16 domain, DDS::UInt16 domain_gain, + DDS::UInt16 part, DDS::UInt16 part_gain) +{ + fixed_port = addr.get_port_number() > 0 || port_mode != PortMode_Probe; + if (!fixed_port) { + DDS::UInt16 port = 0; + if (!get_rtps_port(port, what, port_base, offset, domain, domain_gain, part, part_gain)) { + return false; + } + addr.set_port_number(port); + } + return true; +} + } } diff --git a/dds/DCPS/RTPS/MessageUtils.h b/dds/DCPS/RTPS/MessageUtils.h index d52b550c659..c3e79ab4aff 100644 --- a/dds/DCPS/RTPS/MessageUtils.h +++ b/dds/DCPS/RTPS/MessageUtils.h @@ -269,6 +269,20 @@ PortMode get_port_mode(const String& key, PortMode default_value); OpenDDS_Rtps_Export void set_port_mode(const String& key, PortMode value); +OpenDDS_Rtps_Export +bool set_rtps_multicast_port( + DCPS::NetworkAddress& addr, const char* what, + DDS::UInt16 port_base, DDS::UInt16 offset, + DDS::UInt16 domain, DDS::UInt16 domain_gain); + +OpenDDS_Rtps_Export +bool set_rtps_unicast_port( + DCPS::NetworkAddress& addr, bool& fixed_port, + const char* what, PortMode port_mode, + DDS::UInt16 port_base, DDS::UInt16 offset, + DDS::UInt16 domain, DDS::UInt16 domain_gain, + DDS::UInt16 part, DDS::UInt16 part_gain); + } // namespace RTPS } // namespace OpenDDS diff --git a/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp b/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp index 1daf01715a8..48234ab0f40 100644 --- a/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp +++ b/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp @@ -291,24 +291,17 @@ RtpsDiscoveryConfig::dy(DDS::UInt16 sedp_unicast_offset) sedp_unicast_offset); } -bool RtpsDiscoveryConfig::spdp_multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const +bool RtpsDiscoveryConfig::set_spdp_multicast_port(DCPS::NetworkAddress& addr, + DDS::DomainId_t domain) const { - return get_rtps_port(port, "SPDP multicast", pb(), d0(), domain, dg()); + return set_rtps_multicast_port(addr, "SPDP multicast", pb(), d0(), domain, dg()); } -bool RtpsDiscoveryConfig::spdp_unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const -{ - return get_rtps_port(port, "SPDP unicast", pb(), d1(), domain, dg(), part, pg()); -} - -bool RtpsDiscoveryConfig::sedp_multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const -{ - return get_rtps_port(port, "SEDP multicast", pb(), dx(), domain, dg()); -} - -bool RtpsDiscoveryConfig::sedp_unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const +bool RtpsDiscoveryConfig::set_spdp_unicast_port(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const { - return get_rtps_port(port, "SEDP unicast", pb(), dy(), domain, dg(), part, pg()); + return set_rtps_unicast_port(addr, fixed_port, "SPDP unicast", spdp_port_mode(), + pb(), d1(), domain, dg(), part_id, pg()); } unsigned char @@ -385,20 +378,6 @@ RtpsDiscoveryConfig::sedp_local_address() const DCPS::ConfigStoreImpl::Kind_IPV4); } -bool RtpsDiscoveryConfig::sedp_unicast_address( - DCPS::NetworkAddress& addr, DDS::DomainId_t domain, DDS::UInt16 part_id) const -{ - addr = sedp_local_address(); - if (addr.get_port_number() == 0 && sedp_port_mode() == PortMode_Probe) { - DDS::UInt16 port = 0; - if (!sedp_unicast_port(port, domain, part_id)) { - return false; - } - addr.set_port_number(port); - } - return true; -} - void RtpsDiscoveryConfig::sedp_local_address(const DCPS::NetworkAddress& mi) { @@ -448,15 +427,7 @@ bool RtpsDiscoveryConfig::spdp_unicast_address(DCPS::NetworkAddress& addr, bool& DDS::DomainId_t domain, DDS::UInt16 part_id) const { addr = spdp_local_address(); - fixed_port = addr.get_port_number() > 0; - if (!fixed_port && spdp_port_mode() == PortMode_Probe) { - DDS::UInt16 port = 0; - if (!spdp_unicast_port(port, domain, part_id)) { - return false; - } - addr.set_port_number(port); - } - return true; + return set_spdp_unicast_port(addr, fixed_port, domain, part_id); } OPENDDS_STRING @@ -539,15 +510,7 @@ bool RtpsDiscoveryConfig::spdp_multicast_address( default_multicast_group(domain), DCPS::ConfigStoreImpl::Format_Optional_Port, DCPS::ConfigStoreImpl::Kind_IPV4); - - if (addr.get_port_number() == 0) { - DDS::UInt16 port; - if (!spdp_multicast_port(port, domain)) { - return false; - } - addr.set_port_number(port); - } - return true; + return set_spdp_multicast_port(addr, domain); } void RtpsDiscoveryConfig::spdp_multicast_address(const DCPS::NetworkAddress& addr) @@ -558,23 +521,13 @@ void RtpsDiscoveryConfig::spdp_multicast_address(const DCPS::NetworkAddress& add DCPS::ConfigStoreImpl::Kind_IPV4); } -bool RtpsDiscoveryConfig::sedp_multicast_address( - DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const +DCPS::NetworkAddress RtpsDiscoveryConfig::sedp_multicast_address(DDS::DomainId_t domain) const { - addr = TheServiceParticipant->config_store()->get( + return TheServiceParticipant->config_store()->get( config_key("SEDP_MULTICAST_ADDRESS").c_str(), default_multicast_group(domain), DCPS::ConfigStoreImpl::Format_Optional_Port, DCPS::ConfigStoreImpl::Kind_IPV4); - - if (addr.get_port_number() == 0) { - DDS::UInt16 port; - if (!sedp_multicast_port(port, domain)) { - return false; - } - addr.set_port_number(port); - } - return true; } void RtpsDiscoveryConfig::sedp_multicast_address(const DCPS::NetworkAddress& addr) @@ -608,17 +561,7 @@ bool RtpsDiscoveryConfig::ipv6_spdp_unicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain, DDS::UInt16 part_id) const { addr = ipv6_spdp_local_address(); - fixed_port = addr.get_port_number() > 0; - if (!fixed_port) { - if (spdp_port_mode() == PortMode_Probe) { - DDS::UInt16 port = 0; - if (!spdp_unicast_port(port, domain, part_id)) { - return false; - } - addr.set_port_number(port); - } - } - return true; + return set_spdp_unicast_port(addr, fixed_port, domain, part_id); } DCPS::NetworkAddress @@ -639,22 +582,6 @@ RtpsDiscoveryConfig::ipv6_sedp_local_address(const DCPS::NetworkAddress& mi) DCPS::ConfigStoreImpl::Kind_IPV6); } -bool RtpsDiscoveryConfig::ipv6_sedp_unicast_address( - DCPS::NetworkAddress& addr, DDS::DomainId_t domain, DDS::UInt16 part_id) const -{ - addr = ipv6_sedp_local_address(); - if (addr.get_port_number() == 0) { - if (sedp_port_mode() == PortMode_Probe) { - DDS::UInt16 port = 0; - if (!sedp_unicast_port(port, domain, part_id)) { - return false; - } - addr.set_port_number(port); - } - } - return true; -} - DCPS::NetworkAddress RtpsDiscoveryConfig::ipv6_sedp_advertised_local_address() const { @@ -696,18 +623,10 @@ bool RtpsDiscoveryConfig::ipv6_spdp_multicast_address( { addr = TheServiceParticipant->config_store()->get( config_key("IPV6_SPDP_MULTICAST_ADDRESS").c_str(), - ipv6_default_multicast_group(domain), + ipv6_default_multicast_group(), DCPS::ConfigStoreImpl::Format_Optional_Port, DCPS::ConfigStoreImpl::Kind_IPV6); - - if (addr.get_port_number() == 0) { - DDS::UInt16 port; - if (!spdp_multicast_port(port, domain)) { - return false; - } - addr.set_port_number(port); - } - return true; + return set_spdp_multicast_port(addr, domain); } void RtpsDiscoveryConfig::ipv6_spdp_multicast_address(const DCPS::NetworkAddress& addr) @@ -718,25 +637,6 @@ void RtpsDiscoveryConfig::ipv6_spdp_multicast_address(const DCPS::NetworkAddress DCPS::ConfigStoreImpl::Kind_IPV6); } -bool RtpsDiscoveryConfig::ipv6_sedp_multicast_address( - DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const -{ - addr = TheServiceParticipant->config_store()->get( - config_key("IPV6_SEDP_MULTICAST_ADDRESS").c_str(), - ipv6_default_multicast_group(domain), - DCPS::ConfigStoreImpl::Format_Optional_Port, - DCPS::ConfigStoreImpl::Kind_IPV6); - - if (addr.get_port_number() == 0) { - DDS::UInt16 port; - if (!sedp_multicast_port(port, domain)) { - return false; - } - addr.set_port_number(port); - } - return true; -} - void RtpsDiscoveryConfig::ipv6_sedp_multicast_address(const DCPS::NetworkAddress& addr) { TheServiceParticipant->config_store()->set(config_key("IPV6_SEDP_MULTICAST_ADDRESS").c_str(), diff --git a/dds/DCPS/RTPS/RtpsDiscoveryConfig.h b/dds/DCPS/RTPS/RtpsDiscoveryConfig.h index b4b248e2228..6708d0cf334 100644 --- a/dds/DCPS/RTPS/RtpsDiscoveryConfig.h +++ b/dds/DCPS/RTPS/RtpsDiscoveryConfig.h @@ -86,10 +86,9 @@ class OpenDDS_Rtps_Export RtpsDiscoveryConfig : public OpenDDS::DCPS::RcObject { DDS::UInt16 dy() const; void dy(DDS::UInt16 sedp_unicast_offset); - bool spdp_multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const; - bool spdp_unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const; - bool sedp_multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const; - bool sedp_unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const; + bool set_spdp_multicast_port(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; + bool set_spdp_unicast_port(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const; unsigned char ttl() const; void ttl(unsigned char time_to_live); @@ -103,9 +102,6 @@ class OpenDDS_Rtps_Export RtpsDiscoveryConfig : public OpenDDS::DCPS::RcObject { DCPS::NetworkAddress sedp_local_address() const; void sedp_local_address(const DCPS::NetworkAddress& mi); - bool sedp_unicast_address( - DCPS::NetworkAddress& addr, DDS::DomainId_t domain, DDS::UInt16 part_id) const; - DCPS::NetworkAddress sedp_advertised_local_address() const; void sedp_advertised_local_address(const DCPS::NetworkAddress& mi); @@ -127,7 +123,7 @@ class OpenDDS_Rtps_Export RtpsDiscoveryConfig : public OpenDDS::DCPS::RcObject { bool spdp_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; void spdp_multicast_address(const DCPS::NetworkAddress& addr); - bool sedp_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; + DCPS::NetworkAddress sedp_multicast_address(DDS::DomainId_t domain) const; void sedp_multicast_address(const DCPS::NetworkAddress& addr); #ifdef ACE_HAS_IPV6 @@ -140,9 +136,6 @@ class OpenDDS_Rtps_Export RtpsDiscoveryConfig : public OpenDDS::DCPS::RcObject { DCPS::NetworkAddress ipv6_sedp_local_address() const; void ipv6_sedp_local_address(const DCPS::NetworkAddress& mi); - bool ipv6_sedp_unicast_address( - DCPS::NetworkAddress& addr, DDS::DomainId_t domain, DDS::UInt16 part_id) const; - DCPS::NetworkAddress ipv6_sedp_advertised_local_address() const; void ipv6_sedp_advertised_local_address(const DCPS::NetworkAddress& mi); @@ -152,7 +145,7 @@ class OpenDDS_Rtps_Export RtpsDiscoveryConfig : public OpenDDS::DCPS::RcObject { bool ipv6_spdp_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; void ipv6_spdp_multicast_address(const DCPS::NetworkAddress& addr); - bool ipv6_sedp_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; + DCPS::NetworkAddress ipv6_sedp_multicast_address(DDS::DomainId_t domain) const; void ipv6_sedp_multicast_address(const DCPS::NetworkAddress& addr); #endif diff --git a/dds/DCPS/RTPS/Sedp.cpp b/dds/DCPS/RTPS/Sedp.cpp index 49f66f6d44e..1f64bcbac4c 100644 --- a/dds/DCPS/RTPS/Sedp.cpp +++ b/dds/DCPS/RTPS/Sedp.cpp @@ -417,7 +417,6 @@ Sedp::init(const GUID_t& guid, DCPS::TransportRegistry::DEFAULT_INST_PREFIX + OPENDDS_STRING("_SEDPTransportInst_") + key + domainStr, "rtps_udp"); - DCPS::RtpsUdpInst_rch inst = DCPS::static_rchandle_cast(transport_inst_); // Be careful to not call any function that causes the transport be // to created before the configuration is complete. @@ -439,15 +438,18 @@ Sedp::init(const GUID_t& guid, transport_inst_->receive_preallocated_message_blocks(disco.config()->sedp_receive_preallocated_message_blocks()); transport_inst_->receive_preallocated_data_blocks(disco.config()->sedp_receive_preallocated_data_blocks()); + set_port_mode(transport_inst_->config_key("PORT_MODE").c_str(), disco.config()->sedp_port_mode()); + config_store_->set_int32(transport_inst_->config_key("PB").c_str(), disco.config()->pb()); + config_store_->set_int32(transport_inst_->config_key("DG").c_str(), disco.config()->dg()); + config_store_->set_int32(transport_inst_->config_key("PG").c_str(), disco.config()->pg()); + config_store_->set_int32(transport_inst_->config_key("D2").c_str(), disco.config()->dx()); + config_store_->set_int32(transport_inst_->config_key("D3").c_str(), disco.config()->dy()); + const bool sedp_multicast = disco.sedp_multicast(); config_store_->set_boolean(transport_inst_->config_key("USE_MULTICAST").c_str(), sedp_multicast); if (sedp_multicast) { - DCPS::NetworkAddress mc_addr; - if (!disco.config()->sedp_multicast_address(mc_addr, domainId)) { - return DDS::RETCODE_ERROR; - } config_store_->set(transport_inst_->config_key("MULTICAST_GROUP_ADDRESS").c_str(), - mc_addr, + disco.config()->sedp_multicast_address(domainId), ConfigStoreImpl::Format_Optional_Port, ConfigStoreImpl::Kind_IPV4); @@ -455,15 +457,8 @@ Sedp::init(const GUID_t& guid, config_store_->set(transport_inst_->config_key("MULTICAST_INTERFACE").c_str(), disco.multicast_interface()); } - inst->port_mode(disco.config()->sedp_port_mode()); - inst->pb(disco.config()->pb()); - inst->dg(disco.config()->dg()); - inst->pg(disco.config()->pg()); - inst->d2(disco.config()->dx()); - inst->d3(disco.config()->dy()); - inst->d3(disco.config()->dy()); - - inst->init_participant_port_id(ipv4_participant_port_id); + config_store_->set_int32( + transport_inst_->config_key("INIT_PARTICIPANT_PORT_ID").c_str(), ipv4_participant_port_id); config_store_->set(transport_inst_->config_key("LOCAL_ADDRESS").c_str(), disco.config()->sedp_local_address(), ConfigStoreImpl::Format_Required_Port, @@ -473,7 +468,8 @@ Sedp::init(const GUID_t& guid, ConfigStoreImpl::Format_Required_Port, ConfigStoreImpl::Kind_IPV4); #ifdef ACE_HAS_IPV6 - inst->ipv6_init_participant_port_id(ipv6_participant_port_id); + config_store_->set_int32( + transport_inst_->config_key("IPV6_INIT_PARTICIPANT_PORT_ID").c_str(), ipv6_participant_port_id); config_store_->set(transport_inst_->config_key("IPV6_LOCAL_ADDRESS").c_str(), disco.config()->ipv6_sedp_local_address(), ConfigStoreImpl::Format_Required_Port, @@ -520,6 +516,12 @@ Sedp::init(const GUID_t& guid, const_cast(use_xtypes_complete_) = disco.use_xtypes_complete(); reactor_task_ = transport_inst_->reactor_task(domainId, 0); + if (!reactor_task_) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: Sedp::init: SEDP transport initialization failed\n")); + } + return DDS::RETCODE_ERROR; + } // One should assume that the transport is configured after this // point. Changes to transport_inst_ or rtps_inst after this line // may not be reflected. diff --git a/dds/DCPS/RTPS/Spdp.cpp b/dds/DCPS/RTPS/Spdp.cpp index 35ba9d0d7b2..b0af3fdb0d1 100644 --- a/dds/DCPS/RTPS/Spdp.cpp +++ b/dds/DCPS/RTPS/Spdp.cpp @@ -3459,7 +3459,7 @@ void Spdp::SpdpTransport::set_unicast_socket_opts( throw std::runtime_error("failed to get address from socket"); } port = addr.get_port_number(); - const bool ipv4 = addr.get_type () == AF_INET; + const bool ipv4 = addr.get_type() == AF_INET; if (DCPS::DCPS_debug_level > 3) { ACE_DEBUG((LM_DEBUG, diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp b/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp index e7ed59c9817..ce35897bd5f 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp @@ -443,7 +443,7 @@ void RtpsUdpDataLink::on_data_available(RcHandlemulticast_group_address(tport->domain()), multicast_socket_ #ifdef ACE_HAS_IPV6 - , cfg->ipv6_multicast_group_address(), + , cfg->ipv6_multicast_group_address(tport->domain()), ipv6_multicast_socket_ #endif ); diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp b/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp index a965d753c64..c5f71fb30ba 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp @@ -304,14 +304,16 @@ DDS::UInt16 RtpsUdpInst::d3() const RTPS::default_user_unicast_offset); } -bool RtpsUdpInst::multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const +bool RtpsUdpInst::set_multicast_port(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const { - return RTPS::get_rtps_port(port, "RTPS/UDP multicast", pb(), d2(), domain, dg()); + return RTPS::set_rtps_multicast_port(addr, "RTPS/UDP multicast", pb(), d2(), domain, dg()); } -bool RtpsUdpInst::unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const +bool RtpsUdpInst::set_unicast_port(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const { - return RTPS::get_rtps_port(port, "RTPS/UDP unicast", pb(), d3(), domain, dg(), part, pg()); + return RTPS::set_rtps_unicast_port(addr, fixed_port, "RTPS/UDP unicast", port_mode(), + pb(), d3(), domain, dg(), part_id, pg()); } void @@ -336,13 +338,10 @@ bool RtpsUdpInst::multicast_address(DCPS::NetworkAddress& na, DDS::DomainId_t do NetworkAddress(0, "239.255.0.2"), ConfigStoreImpl::Format_Optional_Port, ConfigStoreImpl::Kind_IPV4); - DDS::UInt16 default_port = 0; - if (!multicast_port(default_port, domain)) { + if (!set_multicast_port(na, domain)) { return false; } - if (na.get_port_number() == 0) { - na.set_port_number(default_port); - } + const DDS::UInt16 default_port = na.get_port_number(); const NetworkAddress na_original = na; if (is_template()) { @@ -448,15 +447,7 @@ bool RtpsUdpInst::unicast_address(DCPS::NetworkAddress& addr, bool& fixed_port, DDS::DomainId_t domain, DDS::UInt16 part_id) const { addr = local_address(); - fixed_port = addr.get_port_number() > 0; - if (!fixed_port && port_mode() == RTPS::PortMode_Probe) { - DDS::UInt16 port; - if (!unicast_port(port, domain, part_id)) { - return false; - } - addr.set_port_number(port); - } - return true; + return set_unicast_port(addr, fixed_port, domain, part_id); } void @@ -496,19 +487,11 @@ RtpsUdpInst::ipv6_multicast_group_address(DDS::DomainId_t domain) const bool RtpsUdpInst::ipv6_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const { - NetworkAddress addr = TheServiceParticipant->config_store()->get( + addr = TheServiceParticipant->config_store()->get( config_key("IPV6_MULTICAST_GROUP_ADDRESS").c_str(), NetworkAddress(0, "FF03::2"), ConfigStoreImpl::Format_Optional_Port, ConfigStoreImpl::Kind_IPV6); - - if (na.get_port_number() == 0) { - DDS::UInt16 default_port = 0; - if (!multicast_port(default_port, domain)) { - return false; - } - na.set_port_number(default_port); - } - return + return set_multicast_port(addr, domain); } void RtpsUdpInst::ipv6_init_participant_port_id(DDS::UInt16 part_id) @@ -545,15 +528,7 @@ bool RtpsUdpInst::ipv6_unicast_address(DCPS::NetworkAddress& addr, bool& fixed_p DDS::DomainId_t domain, DDS::UInt16 part_id) const { addr = ipv6_local_address(); - fixed_port = addr.get_port_number() > 0; - if (!fixed_port && port_mode() == RTPS::PortMode_Probe) { - DDS::UInt16 port; - if (!unicast_port(port, domain, part_id)) { - return false; - } - addr.set_port_number(port); - } - return true; + return set_unicast_port(addr, fixed_port, domain, part_id); } void @@ -696,7 +671,7 @@ RtpsUdpInst::populate_locator(TransportLocator& info, address_to_locator(locators[idx++], multicast_group_addr.to_addr()); } #ifdef ACE_HAS_IPV6 - const NetworkAddress ipv6_multicast_group_addr = ipv6_multicast_group_address(); + const NetworkAddress ipv6_multicast_group_addr = ipv6_multicast_group_address(domain); if ((flags & CONNINFO_MULTICAST) && use_multicast() && ipv6_multicast_group_addr != NetworkAddress::default_IPV6) { grow(locators); address_to_locator(locators[idx++], ipv6_multicast_group_addr.to_addr()); diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpInst.h b/dds/DCPS/transport/rtps_udp/RtpsUdpInst.h index 5c39013a8a9..01a5094f976 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpInst.h +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpInst.h @@ -114,8 +114,9 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpInst : public TransportInst { void d3(DDS::UInt16 unicast_offset); DDS::UInt16 d3() const; - bool multicast_port(DDS::UInt16& port, DDS::UInt16 domain) const; - bool unicast_port(DDS::UInt16& port, DDS::UInt16 domain, DDS::UInt16 part) const; + bool set_multicast_port(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; + bool set_unicast_port(DCPS::NetworkAddress& addr, bool& fixed_port, + DDS::DomainId_t domain, DDS::UInt16 part_id) const; bool multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; void multicast_group_address(const NetworkAddress& addr); @@ -135,7 +136,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpInst : public TransportInst { #ifdef ACE_HAS_IPV6 bool ipv6_multicast_address(DCPS::NetworkAddress& addr, DDS::DomainId_t domain) const; void ipv6_multicast_group_address(const NetworkAddress& addr); - NetworkAddress ipv6_multicast_group_address() const; + NetworkAddress ipv6_multicast_group_address(DDS::DomainId_t domain) const; void ipv6_init_participant_port_id(DDS::UInt16 part_id); DDS::UInt16 ipv6_init_participant_port_id() const; diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp index 097fb6a4665..6c77cb1134e 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp @@ -513,40 +513,69 @@ RtpsUdpTransport::append_transport_statistics(TransportStatisticsSequence& seq) } bool RtpsUdpTransport::open_socket( - const RtpsUdpInst_rch& config, ACE_SOCK_Dgram& sock, int protocol, DDS::UInt16 part_port_id, - NetworkAddress& actual, bool& fail) + const RtpsUdpInst_rch& config, ACE_SOCK_Dgram& sock, int protocol, ACE_INET_Addr& actual) { - fail = true; const bool ipv4 = protocol == PF_INET; + const DDS::UInt16 init_part_port_id = +#ifdef ACE_HAS_IPV6 + ipv4 ? config->init_participant_port_id() : config->ipv6_init_participant_port_id(); +#else + config->init_participant_port_id(); +#endif NetworkAddress address; bool fixed_port; - if (ipv4) { - if (!config->unicast_address(address, fixed_port, domain_, part_port_id)) { + DDS::UInt16 part_port_id = init_part_port_id; + while (true) { +#ifdef ACE_HAS_IPV6 + if (ipv4) { +#endif + if (!config->unicast_address(address, fixed_port, domain_, part_port_id)) { + return false; + } +#ifdef ACE_HAS_IPV6 + } else if (!config->ipv6_unicast_address(address, fixed_port, domain_, part_port_id)) { return false; } -#ifdef ACE_HAS_IPV6 - } else if (!config->ipv6_unicast_address(address, fixed_port, domain_, part_port_id)) { - return false; #endif - } - if (sock.open(address.to_addr(), protocol) != 0) { + if (sock.open(address.to_addr(), protocol) == 0) { + break; + } + if (fixed_port) { if (log_level >= LogLevel::Error) { ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: RtpsUdpTransport::open_socket: " "failed to open unicast %C socket for %C: %m\n", ipv4 ? "IPv4" : "IPv6", LogAddr(address).c_str())); } + return false; + } else { if (DCPS::DCPS_debug_level > 3) { ACE_DEBUG((LM_DEBUG, "(%P|%t) RtpsUdpTransport::open_socket: " "failed to open unicast %C socket for %C: %m, trying next participant ID...\n", ipv4 ? "IPv4" : "IPv6", LogAddr(address).c_str())); } - fail = false; + + ++part_port_id; + + if (part_port_id == init_part_port_id) { + if (log_level >= LogLevel::Error) { + ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: RtpsUdpTransport::open_socket: " + "could not find a free %C unicast port\n", + ipv4 ? "IPv4" : "IPv6")); + } + return false; + } } - return false; + } + + if (DCPS::DCPS_debug_level > 3) { + ACE_DEBUG((LM_DEBUG, + "(%P|%t) RtpsUdpTransport::open_socket: " + "opened %C unicast socket %d for %C\n", + ipv4 ? "IPv4" : "IPv6", sock.get_handle(), LogAddr(address).c_str())); } #ifdef ACE_WIN32 @@ -561,8 +590,7 @@ bool RtpsUdpTransport::open_socket( } #endif - ACE_INET_Addr ace_actual; - if (sock.get_local_addr(ace_actual) != 0) { + if (sock.get_local_addr(actual) != 0) { if (log_level >= LogLevel::Error) { ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: RtpsUdpTransport::open_socket: " "failed to get actual address from %C socket for %C: %m\n", @@ -570,7 +598,6 @@ bool RtpsUdpTransport::open_socket( } return false; } - actual = ace_actual; if (!set_recvpktinfo(sock, ipv4)) { if (log_level >= LogLevel::Error) { @@ -581,7 +608,6 @@ bool RtpsUdpTransport::open_socket( return false; } - fail = false; return true; } @@ -598,40 +624,15 @@ RtpsUdpTransport::configure_i(const RtpsUdpInst_rch& config) // detect and report errors during DataReader/Writer setup instead // of during association. - bool error = false; - const DDS::UInt16 init_part_port_id4 = config->init_participant_port_id(); - DDS::UInt16 part_port_id4 = init_part_port_id4; - NetworkAddress actual4; - while (!open_socket(config, unicast_socket_, PF_INET, part_port_id4, actual4, error) && !error) { - ++part_port_id4; - if (part_port_id4 == init_part_port_id4) { - if (log_level >= LogLevel::Error) { - ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: RtpsUdpTransport::configure_i: " - "could not find a free IPv4 unicast port\n")); - } - return false; - } - } - if (error) { + ACE_INET_Addr actual4; + if (!open_socket(config, unicast_socket_, PF_INET, actual4)) { return false; } config->actual_local_address_ = actual4; #ifdef ACE_HAS_IPV6 - const DDS::UInt16 init_part_port_id6 = config->ipv6_init_participant_port_id(); - DDS::UInt16 part_port_id6 = init_part_port_id6; - NetworkAddress actual6; - while (!open_socket(config, ipv6_unicast_socket_, PF_INET6, part_port_id, actual6, error) && !error) { - ++part_port_id6; - if (part_port_id6 == init_part_port_id6) { - if (log_level >= LogLevel::Error) { - ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: RtpsUdpTransport::configure_i: " - "could not find a free IPv6 unicast port\n")); - } - return false; - } - } - if (error) { + ACE_INET_Addr actual6; + if (!open_socket(config, ipv6_unicast_socket_, PF_INET6, actual6)) { return false; } NetworkAddress temp(actual6); diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h index 197ea73e53d..4e8e49ceb06 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h @@ -289,8 +289,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpTransport : public TransportImpl, public Co bool association_failed); bool open_socket( - const RtpsUdpInst_rch& config, ACE_SOCK_Dgram& sock, int protocol, DDS::UInt16 part_port_id, - NetworkAddress& actual, bool& fail); + const RtpsUdpInst_rch& config, ACE_SOCK_Dgram& sock, int protocol, ACE_INET_Addr& actual); bool configure_i(const RtpsUdpInst_rch& config); diff --git a/docs/devguide/run_time_configuration.rst b/docs/devguide/run_time_configuration.rst index 22c5d92e908..d56c4ad6139 100644 --- a/docs/devguide/run_time_configuration.rst +++ b/docs/devguide/run_time_configuration.rst @@ -108,6 +108,14 @@ In this case, the ``MY_DISCOVERY`` instance of ``RTPS_DISCOVERY`` will have a `` :sec:`transport` + * - :ref:`config-templates` + + - :sec:`DomainRange` + + :sec:`transport_template` + + :sec:`Customization` + * - Other - :sec:`ice` @@ -227,8 +235,8 @@ For example: publisher -DCPSConfigFile pub.ini -For each of the section types with the exception of :sec:`common` and ``[ice]``, the syntax of a section header takes the form of ``[/]``. -For example, a ``[repository]`` section type would always be used in a configuration file like so: ``[repository/repo_1]`` where ``repository`` is the section type and ``repo_1`` is an instance name of a repository configuration. +For each of the section types with the exception of :sec:`common` and :sec:`ice`, the syntax of a section header takes the form of ``[/]``. +For example, a :sec:`repository` section type would always be used in a configuration file like so: ``[repository/repo_1]`` where ``repository`` is the section type and ``repo_1`` is an instance name of a repository configuration. Using instances to configure discovery and transports is explained further in :ref:`config-disc` and :ref:`config-transport` respectively. @@ -675,13 +683,13 @@ When DDS applications are written, participants are assigned to a domain and nee OpenDDS offers a centralized discovery mechanism, a peer-to-peer discovery mechanism, and a static discovery mechanism. The centralized mechanism uses a separate service running a ``DCPSInfoRepo`` process. -The RTPS peer-to-peer mechanism uses the DDSI-RTPS discovery protocol standard to achieve non-centralized discovery. +The RTPS peer-to-peer mechanism uses the RTPS discovery protocol standard to achieve non-centralized discovery. The static discovery mechanism uses the configuration file to determine which writers and readers should be associated and uses the underlying transport to determine which writers and readers exist. A number of configuration options exist to meet the deployment needs of DDS applications. Except for static discovery, each mechanism uses default values if no configuration is supplied either via the command line or configuration file. The following sections show how to configure the advanced discovery capabilities. -For example, some deployments may need to use multiple ``DCPSInfoRepo`` services or DDSI-RTPS discovery to satisfy interoperability requirements. +For example, some deployments may need to use multiple ``DCPSInfoRepo`` services or RTPS discovery to satisfy interoperability requirements. .. _config-domain: .. _run_time_configuration--domain-configuration: @@ -795,7 +803,9 @@ For more explanation of a similar configuration for RTPS discovery see :ref:`run Key value of the mapped repository - .. deprecated:: Provided for backward compatibility. + .. deprecated:: 3.1.0 + + Provided for backward compatibility. .. prop:: DiscoveryConfig= :default: :prop:`[common]DCPSDefaultDiscovery` @@ -1003,7 +1013,9 @@ Here are the valid properties for a ``[repository]`` section: Unique key value for the repository - .. deprecated:: Provided for backward compatibility. + .. deprecated:: 3.1.0 + + Provided for backward compatibility. .. _rtps-disc-config: .. _run_time_configuration--configuring-for-ddsi-rtps-discovery: @@ -1115,72 +1127,75 @@ Those properties, along with options specific to OpenDDS's RTPS discovery implem Extends the lease of discovered participants by the set amount of seconds. Useful on spotty connections to reduce load on the :ref:`RtpsRelay `. - .. prop:: PB= + .. prop:: PB= :default: ``7400`` - This number sets the starting point for deriving port numbers used for Simple Endpoint Discovery Protocol (SEDP). - This property is used in conjunction with :prop:`DG`, :prop:`PG`, :prop:`D0` (or :prop:`DX`), and :prop:`D1` to construct the necessary Endpoints for RTPS discovery communication. - See :omgspec:`rtps:9.6.1.1` for how these Endpoints are constructed. + The port base parameter for the :ref:`computed RTPS ports `. .. prop:: DG= :default: ``250`` - An integer value representing the Domain Gain. - This is a multiplier that assists in formulating Multicast or Unicast ports for RTPS. + The domain gain coefficient parameter for the :ref:`computed RTPS ports `. .. prop:: PG= :default: ``2`` - An integer that assists in configuring SPDP Unicast ports and serves as an offset multiplier. - Participants are assigned addresses using the formula: - - .. math:: - - \mathit{PB} + DG \times \mathit{domainId} + \mathit{d}1 + \mathit{PG} \times \mathit{participantId} - - See :omgspec:`rtps:9.6.1.1` for how these Endpoints are constructed. + The participant gain coefficient parameter for the :ref:`computed RTPS ports `. .. prop:: D0= :default: The value of the ``OPENDDS_RTPS_DEFAULT_D0`` environment variable if set, else ``0`` - An integer value that assists in providing an offset for calculating an assignable port in SPDP Multicast configurations. - The formula used is: - - .. math:: - - \mathit{PB} + \mathit{DG} \times \mathit{domainId} + \mathit{d0} - - See :omgspec:`rtps:9.6.1.1` for how these Endpoints are constructed. + The offset parameter for the :ref:`computed SPDP multicast port `. .. prop:: D1= :default: ``10`` - An integer value that assists in providing an offset for calculating an assignable port in SPDP Unicast configurations. - The formula used is: + The offset parameter for the :ref:`computed SPDP unicast port `. + + .. prop:: DX= + :default: ``2`` - .. math:: + The offset parameter for the :ref:`computed SEDP multicast port `. - \mathit{PB} + \mathit{DG} \times \mathit{domainId} + \mathit{d1} + \mathit{PG} \times \mathit{participantId} + .. prop:: DY= + :default: ``12`` - See :omgspec:`rtps:9.6.1.1` for how these Endpoints are constructed. + The offset parameter for the :ref:`computed SEDP unicast port `. - .. prop:: DX= - :default: ``2`` + .. prop:: SpdpPortMode=system|probe + :default: :val:`system` - An integer value that assists in providing an offset for calculating a port in SEDP Multicast configurations. - This is only valid when :prop:`SedpMulticast=1 `. - The formula used is: + When :prop:`SpdpLocalAddress` and :prop:`Ipv6SpdpLocalAddress` don't explicitly set the ports, they are assigned according to one of these methods: - .. math:: + .. val:: system - \mathit{PB} + \mathit{DG} \times \mathit{domainId} + \mathit{dx} + The operating system assigns one when the socket is opened. - This is an OpenDDS extension and not part of the OMG DDSI-RTPS specification. + .. val:: probe + + :ref:`Computed SPDP unicast port ` .. prop:: SpdpRequestRandomPort= :default: ``0`` - Use a random port for SPDP. + ``0`` is the same as :val:`SpdpPortMode=probe` and ``1`` is the same as :val:`SpdpPortMode=system`. + + .. deprecated:: 3.29.0 + + Use :prop:`SpdpPortMode` instead. + + .. prop:: SedpPortMode=system|probe + :default: :val:`system` + + When :prop:`SedpLocalAddress` and :prop:`Ipv6SedpLocalAddress` don't explicitly set the ports, they are assigned according to one of these methods: + + .. val:: system + + The operating system assigns one when the socket is opened. + + .. val:: probe + + :ref:`Computed SEDP unicast port ` .. prop:: SedpMaxMessageSize= :default: ``65466`` (maximum worst-case UDP payload size) @@ -1196,18 +1211,52 @@ Those properties, along with options specific to OpenDDS's RTPS discovery implem When set to ``1``, Multicast is used. When set to ``0``, Unicast is used. - .. prop:: SedpLocalAddress=:[] + .. prop:: SedpMulticastAddress=[:] + :default: :prop:`InteropMulticastOverride` + + The multicast group to use for SEDP multicast traffic. + If ```` is ``0`` or not specified, it is calculated as described in :ref:`config-ports-used-by-sedp-multicast`. + + .. prop:: Ipv6SedpMulticastAddress=[:] + :default: :prop:`Ipv6DefaultMulticastGroup` + + IPv6 variant of :prop:`SedpMulticastAddress`. + + .. prop:: SedpLocalAddress=:[] :default: :prop:`[common]DCPSDefaultAddress` Configure the transport instance created and used by SEDP to bind to the specified local address and port. In order to leave the port unspecified, it can be omitted from the setting but the trailing ``:`` must be present. + If ```` is ``0`` or not specified, it is calculated as described in :ref:`config-ports-used-by-sedp-unicast`. - .. prop:: SpdpLocalAddress=[:] + .. prop:: Ipv6SedpLocalAddress=:[] + :default: :prop:`[common]DCPSDefaultAddress` + + IPv6 variant of :prop:`SedpLocalAddress`. + + .. prop:: SpdpMulticastAddress=[:] + :default: :prop:`InteropMulticastOverride` + + The multicast group to use for SPDP multicast traffic. + If ```` is ``0`` or not specified, it is calculated as described in :ref:`config-ports-used-by-spdp-multicast`. + + .. prop:: Ipv6SpdpMulticastAddress=[:] + :default: :prop:`Ipv6DefaultMulticastGroup` + + IPv6 variant of :prop:`Ipv6SpdpMulticastAddress`. + + .. prop:: SpdpLocalAddress=[:] :default: :prop:`[common]DCPSDefaultAddress` Address of a local interface, which will be used by SPDP to bind to that specific interface. + If ```` is ``0`` or not specified, it is calculated as described in :ref:`config-ports-used-by-spdp-unicast`. + + .. prop:: Ipv6SpdpLocalAddress=[:] + :default: :prop:`[common]DCPSDefaultAddress` - .. prop:: SedpAdvertisedLocalAddress=:[] + IPv6 variant of :prop:`SpdpLocalAddress`. + + .. prop:: SedpAdvertisedLocalAddress=:[] Sets the address advertised by SEDP. Typically used when the participant is behind a firewall or NAT. @@ -1251,10 +1300,17 @@ Those properties, along with options specific to OpenDDS's RTPS discovery implem This setting should be disabled for participants that cannot use multicast to send SPDP announcements, e.g., an RtpsRelay. .. prop:: InteropMulticastOverride= + :default: ``239.255.0.1`` + + A network address specifying the multicast group to be used for SPDP and SEDP. + The default is defined by the RTPS specification. + This property can be used, for example, to specify use of a routed group address to provide a larger discovery scope. + It can be modified by :prop:`[Customization]InteropMulticastOverride`. - A network address specifying the multicast group to be used for SPDP discovery. - This overrides the interoperability group of the specification, ``239.255.0.1`` - It can be used, for example, to specify use of a routed group address to provide a larger discovery scope. + .. prop:: Ipv6DefaultMulticastGroup= + :default: ``ff03::1`` + + IPv6-variant of :prop:`InteropMulticastOverride`. .. prop:: TTL=n :default: ``1`` (all data is restricted to the local network) @@ -1413,16 +1469,82 @@ Those properties, along with options specific to OpenDDS's RTPS discovery implem If ```` is 0 (the default), the submessage is not added. Otherwise this submessage's contents is the 4-byte unsigned integer ````. +.. _config-ports-used-by-rtps-disc: + +Ports Used by RTPS Discovery +---------------------------- + +See :omgspec:`rtps:9.6.1 Default Locators` for the related RTPS spec definitions. + +.. _config-ports-used-by-spdp: + +Simple Participant Discovery Protocol (SPDP) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. _config-ports-used-by-spdp-multicast: + +SPDP Multicast +"""""""""""""" + +The SPDP multicast port will be one of the following: + +- Port from :prop:`SpdpMulticastAddress <[rtps_discovery]SpdpMulticastAddress>` if set +- :prop:`PB <[rtps_discovery]PB>` + :prop:`DG <[rtps_discovery]DG>` × *domainId* + :prop:`D0 <[rtps_discovery]D0>` + +.. _config-ports-used-by-spdp-unicast: + +SPDP Unicast +"""""""""""" + +The SPDP unicast port will be one of the following: + +- Port from :prop:`SpdpLocalAddress <[rtps_discovery]SpdpLocalAddress>` if set +- A system-provided port if :val:`SpdpPortMode=system <[rtps_discovery]SpdpPortMode=system>` +- :prop:`PB <[rtps_discovery]PB>` + :prop:`DG <[rtps_discovery]DG>` × *domainId* + :prop:`D1 <[rtps_discovery]D1>` + :prop:`PG <[rtps_discovery]PG>` × *participantId* if :val:`SpdpPortMode=probe <[rtps_discovery]SpdpPortMode=probe>` is set (default) + + - If the port can not be opened, then the *participantId* is incremented until a port can be opened. + - If no valid UDP port can be opened, then an error will be logged. + +.. _config-ports-used-by-sedp: + +Simple Endpoint Discovery Protocol (SEDP) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. note:: + + :prop:`DX <[rtps_discovery]DX>` and :prop:`DY <[rtps_discovery]DY>` are OpenDDS-specific. + +.. _config-ports-used-by-sedp-multicast: + +SEDP Multicast +"""""""""""""" + +If :prop:`SedpMulticast=1 <[rtps_discovery]SedpMulticast>`, the SEDP multicast port will be one of the following: + +- Port from :prop:`SedpMulticastAddress <[rtps_discovery]SedpMulticastAddress>` if set (the same as SPDP) +- :prop:`PB <[rtps_discovery]PB>` + :prop:`DG <[rtps_discovery]DG>` × *domainId* + :prop:`DX <[rtps_discovery]DX>` + +.. _config-ports-used-by-sedp-unicast: + +SEDP Unicast +"""""""""""" + +The SEDP unicast port will be one of the following: + +- Port from :prop:`SedpLocalAddress <[rtps_discovery]SedpLocalAddress>` if set +- :prop:`PB <[rtps_discovery]PB>` + :prop:`DG <[rtps_discovery]DG>` × *domainId* + :prop:`DY <[rtps_discovery]DY>` + :prop:`PG <[rtps_discovery]PG>` × *participantId* if :val:`SedpPortMode=probe <[rtps_discovery]SedpPortMode=probe>` is set +- A system-provided port if :val:`SedpPortMode=system <[rtps_discovery]SedpPortMode=system>` (default) + .. _run_time_configuration--additional-ddsi-rtps-discovery-features: -Additional DDSI-RTPS Discovery Features ---------------------------------------- +Additional RTPS Discovery Features +---------------------------------- .. Sect<7.3.3.1> -The DDSI_RTPS discovery implementation creates and manages a transport instance -- specifically an object of class ``RtpsUdpInst``. -In order for applications to access this object and enable advanced features (:ref:`Additional RTPS_UDP Features `), the ``RtpsDiscovery`` class provides the method ``sedp_transport_inst(domainId, participant)``. +The RTPS discovery implementation creates and manages a transport instance -- specifically an object of class ``RtpsUdpInst``. +In order for applications to access this object and :ref:`enable advanced features `, the ``RtpsDiscovery`` class provides the method ``sedp_transport_inst(domainId, participant)``. .. _static-disc-config: .. _run_time_configuration--configuring-for-static-discovery: @@ -2595,16 +2717,17 @@ Some implementation notes related to using the ``rtps_udp`` transport protocol a When set to ``0`` (false) the transport uses Unicast, otherwise a value of ``1`` (true) will use Multicast. .. prop:: multicast_group_address=: - :default: ``239.255.0.2:7401`` + :default: ``239.255.0.2:0`` When :prop:`use_multicast` is enabled, this is the multicast network address that should be used. - If ```` is not specified for the network address, port 7401 will be used. + If ```` is ``0`` or not specified, it is calculated as described in :ref:`config-ports-used-by-rtps-udp-multicast`. + It can be modified by :prop:`[Customization]multicast_group_address`. .. prop:: ipv6_multicast_group_address= - :default: ``[FF03::2]:7401`` + :default: ``[FF03::2]:0`` When the transport is set to multicast, this is the multicast network address that should be used. - If ```` is not specified for the network address, port 7401 will be used. + If ```` is ``0`` or not specified, it is calculated as described in :ref:`config-ports-used-by-rtps-udp-multicast`. .. prop:: multicast_interface= :default: :prop:`[common]DCPSDefaultAddress` @@ -2612,17 +2735,57 @@ Some implementation notes related to using the ``rtps_udp`` transport protocol a Specifies the network interface to be used by this transport instance. This uses a platform-specific format that identifies the network interface. - .. prop:: local_address=:[] + .. prop:: local_address=:[] :default: :prop:`[common]DCPSDefaultAddress` Bind the socket to the given address and port. - Port can be omitted but the trailing ``:`` is required. + ```` can be omitted but the trailing ``:`` is required. + If ```` is ``0`` or not specified, it is calculated as described in :ref:`config-ports-used-by-rtps-udp-unicast`. - .. prop:: ipv6_local_address=:[] + .. prop:: ipv6_local_address=:[] :default: :prop:`[common]DCPSDefaultAddress` Bind the socket to the given address and port. - Port can be omitted but the trailing ``:`` is required. + ```` can be omitted but the trailing ``:`` is required. + If ```` is ``0`` or not specified, it is calculated as described in :ref:`config-ports-used-by-rtps-udp-unicast`. + + .. prop:: PortMode=system|probe + :default: :val:`system` + + When :prop:`local_address` and :prop:`ipv6_local_address` don't explicitly set the ports, they are assigned according to one of these methods: + + .. val:: system + + The operating system assigns one when the socket is opened. + + .. val:: probe + + :ref:`Computed unicast port ` + + .. prop:: PB= + :default: ``7400`` + + The port base parameter for the :ref:`computed RTPS ports `. + + .. prop:: DG= + :default: ``250`` + + The domain gain coefficient parameter for the :ref:`computed RTPS ports `. + + .. prop:: PG= + :default: ``2`` + + The participant gain coefficient parameter for the :ref:`computed RTPS ports `. + + .. prop:: D2= + :default: ``1`` + + The offset parameter for the :ref:`computed multicast port `. + + .. prop:: D3= + :default: ``11`` + + The offset parameter for the :ref:`computed unicast port `. .. prop:: advertised_address=:[] @@ -2710,6 +2873,34 @@ Some implementation notes related to using the ``rtps_udp`` transport protocol a Enable or disable :ref:`ICE ` for this transport instance. +.. _config-ports-used-by-rtps-udp: + +Ports used by RTPS/UDP +^^^^^^^^^^^^^^^^^^^^^^ + +See :omgspec:`rtps:9.6.1 Default Locators` for the related RTPS spec definitions. + +.. _config-ports-used-by-rtps-udp-multicast: + +Multicast +""""""""" + +If :prop:`use_multicast=1 <[transport@rtps_udp]use_multicast>` the RTPS/UDP multicast port will be one of the following: + +- Port from :prop:`multicast_group_address <[transport@rtps_udp]multicast_group_address>` and :prop:`ipv6_multicast_group_address <[transport@rtps_udp]ipv6_multicast_group_address>` if set +- :prop:`PB <[transport@rtps_udp]PB>` + :prop:`DG <[transport@rtps_udp]DG>` × *domainId* + :prop:`D2 <[transport@rtps_udp]D2>` + +.. _config-ports-used-by-rtps-udp-unicast: + +Unicast +""""""" + +The RTPS/UDP unicast port will be one of the following: + +- Port from :prop:`local_address <[transport@rtps_udp]local_address>` and :prop:`ipv6_local_address <[transport@rtps_udp]ipv6_local_address>` if set +- :prop:`PB <[transport@rtps_udp]PB>` + :prop:`DG <[transport@rtps_udp]DG>` × *domainId* + :prop:`D3 <[transport@rtps_udp]D3>` + :prop:`PG <[transport@rtps_udp]PG>` × *participantId* if :val:`PortMode=prob <[transport@rtps_udp]PortMode=probe>` +- A system-provided port if :val:`PortMode=system <[transport@rtps_udp]PortMode=system>` (default) + .. _run_time_configuration--additional-rtps-udp-features: Additional RTPS UDP Features diff --git a/docs/news.d/rtps-ports.rst b/docs/news.d/rtps-ports.rst new file mode 100644 index 00000000000..136c28a0404 --- /dev/null +++ b/docs/news.d/rtps-ports.rst @@ -0,0 +1,22 @@ +.. news-prs: 4655 + +.. news-start-section: Additions +- Added config properties to give more control over what UDP ports RTPS uses: + + - For RTPS Discovery: + + - :cfg:val:`[rtps_discovery]SedpPortMode=probe` will use ports similar to how the RTPS specification defines them. + This uses the existing port parameter properties for SPDP and a new one, :cfg:prop:`[rtps_discovery]DY`. + - Added :cfg:prop:`[rtps_discovery]SpdpPortMode` as an alias to the now deprecated :cfg:prop:`[rtps_discovery]SpdpRequestRandomPort`. + - Added :cfg:prop:`[rtps_discovery]SpdpMulticastAddress`, :cfg:prop:`[rtps_discovery]Ipv6SpdpMulticastAddress`, :cfg:prop:`[rtps_discovery]SedpMulticastAddress`, and :cfg:prop:`[rtps_discovery]Ipv6SedpMulticastAddress` to set the multicast addresses and ports separately on SPDP and SEDP. + - See :ref:`here ` for the full overview of port usage. + + - For RTPS/UDP Transport: + + - Added :cfg:val:`[transport@rtps_udp]PortMode=probe` will use port exactly as the RTPS specification defines them. + This uses new port parameter properties: :cfg:prop:`[transport@rtps_udp]PB`, :cfg:prop:`[transport@rtps_udp]DG`, :cfg:prop:`[transport@rtps_udp]PG`, :cfg:prop:`[transport@rtps_udp]D2`, and :cfg:prop:`[transport@rtps_udp]D3`. + - See :ref:`here ` for the full overview of port usage. + + - All ports calculated using port parameter properties now warn if they overflow the 16 bit integer. + - :cfg:val:`[rtps_discovery]SedpPortMode=probe` and :cfg:val:`[transport@rtps_udp]PortMode=probe` might make :ref:`config template customizations ` unnecessary. +.. news-end-section diff --git a/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp b/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp index 3c58317c493..6ba9cd1f540 100644 --- a/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp +++ b/tests/unit-tests/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp @@ -26,82 +26,21 @@ namespace { store->unset_section(rtps.config_prefix()); } }; -} - -TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, sedp_unicast_address) -{ - { - AddressTest t; - ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress()); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_port_mode(PortMode_System); - ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress()); - EXPECT_FALSE(t.fixed); - } - { - AddressTest t; - t.rtps.sedp_port_mode(PortMode_Probe); - ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7662, "0.0.0.0")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_port_mode(PortMode_Probe); - ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 3)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7668, "0.0.0.0")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_port_mode(PortMode_Probe); - t.rtps.pb(7500); - t.rtps.dg(260); - t.rtps.pg(3); - t.rtps.dy(8); - ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 3)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "0.0.0.0")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_port_mode(PortMode_Probe); - t.rtps.pb(9999); - t.rtps.dg(9999); - t.rtps.pg(9999); - t.rtps.dy(9999); - LogRestore lr; - log_level.set(LogLevel::None); - ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 9999, 9999)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, "0.0.0.0")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_local_address(NetworkAddress(1234, "1.2.3.4")); - ASSERT_TRUE(t.rtps.sedp_unicast_address(t.addr, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); - EXPECT_FALSE(t.fixed); - } + const NetworkAddress fake_ipv4_addr(1234, "1.2.3.4"); +#ifdef ACE_HAS_IPV6 + const NetworkAddress fake_ipv6_addr(1234, "::1:2:3:4"); +#endif } TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_unicast_address) { + const char* const default_addr = "0.0.0.0"; + { AddressTest t; ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, "0.0.0.0")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, default_addr)); EXPECT_FALSE(t.fixed); } @@ -109,7 +48,7 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_unicast_address) AddressTest t; t.rtps.spdp_port_mode(PortMode_Probe); ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, "0.0.0.0")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, default_addr)); EXPECT_FALSE(t.fixed); } @@ -118,15 +57,15 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_unicast_address) AddressTest t; t.rtps.spdp_port_mode(PortMode_System); ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress()); - EXPECT_FALSE(t.fixed); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(0, default_addr)); + EXPECT_TRUE(t.fixed); } { AddressTest t; t.rtps.spdp_port_mode(PortMode_Probe); ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 3)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7666, "0.0.0.0")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7666, default_addr)); EXPECT_FALSE(t.fixed); } @@ -138,7 +77,7 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_unicast_address) t.rtps.pg(3); t.rtps.d1(8); ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 3)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "0.0.0.0")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, default_addr)); EXPECT_FALSE(t.fixed); } @@ -152,32 +91,34 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_unicast_address) LogRestore lr; log_level.set(LogLevel::None); ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 9999, 9999)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, "0.0.0.0")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, default_addr)); EXPECT_FALSE(t.fixed); } { AddressTest t; - t.rtps.spdp_local_address(NetworkAddress(1234, "1.2.3.4")); + t.rtps.spdp_local_address(fake_ipv4_addr); ASSERT_TRUE(t.rtps.spdp_unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); + EXPECT_ADDR_EQ(t.addr, fake_ipv4_addr); EXPECT_TRUE(t.fixed); } } TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_multicast_address) { + const char* const default_addr = "239.255.0.1"; + { AddressTest t; ASSERT_TRUE(t.rtps.spdp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7650, "239.255.0.1")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7650, default_addr)); EXPECT_FALSE(t.fixed); } { AddressTest t; ASSERT_TRUE(t.rtps.spdp_multicast_address(t.addr, 2)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7900, "239.255.0.1")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7900, default_addr)); EXPECT_FALSE(t.fixed); } @@ -187,7 +128,7 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_multicast_address) t.rtps.dg(260); t.rtps.d0(17); ASSERT_TRUE(t.rtps.spdp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "239.255.0.1")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, default_addr)); EXPECT_FALSE(t.fixed); } @@ -199,142 +140,29 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, spdp_multicast_address) LogRestore lr; log_level.set(LogLevel::None); ASSERT_TRUE(t.rtps.spdp_multicast_address(t.addr, 9999)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, "239.255.0.1")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, default_addr)); EXPECT_FALSE(t.fixed); } { AddressTest t; - t.rtps.spdp_multicast_address(NetworkAddress(1234, "1.2.3.4")); + t.rtps.spdp_multicast_address(fake_ipv4_addr); ASSERT_TRUE(t.rtps.spdp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); + EXPECT_ADDR_EQ(t.addr, fake_ipv4_addr); EXPECT_FALSE(t.fixed); } } -TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, sedp_multicast_address) -{ - { - AddressTest t; - ASSERT_TRUE(t.rtps.sedp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7652, "239.255.0.1")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - ASSERT_TRUE(t.rtps.sedp_multicast_address(t.addr, 2)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7902, "239.255.0.1")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.pb(7500); - t.rtps.dg(260); - t.rtps.dx(17); - ASSERT_TRUE(t.rtps.sedp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "239.255.0.1")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.pb(9999); - t.rtps.dg(9999); - t.rtps.dx(9999); - LogRestore lr; - log_level.set(LogLevel::None); - ASSERT_TRUE(t.rtps.sedp_multicast_address(t.addr, 9999)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, "239.255.0.1")); - - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_multicast_address(NetworkAddress(1234, "1.2.3.4")); - ASSERT_TRUE(t.rtps.sedp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); - EXPECT_FALSE(t.fixed); - } -} #ifdef ACE_HAS_IPV6 -TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_sedp_unicast_address) -{ - { - AddressTest t; - ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress()); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_port_mode(PortMode_System); - ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress()); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_port_mode(PortMode_Probe); - ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7662, "[::]")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_port_mode(PortMode_Probe); - ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 3)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7668, "[::]")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_port_mode(PortMode_Probe); - t.rtps.pb(7500); - t.rtps.dg(260); - t.rtps.pg(3); - t.rtps.dy(8); - ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 3)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "[::]")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_port_mode(PortMode_Probe); - t.rtps.pb(9999); - t.rtps.dg(9999); - t.rtps.pg(9999); - t.rtps.dy(9999); - LogRestore lr; - log_level.set(LogLevel::None); - ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 9999, 9999)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, "[::]")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.sedp_local_address(NetworkAddress(1234, "[1:2:3:4]")); - ASSERT_TRUE(t.rtps.ipv6_sedp_unicast_address(t.addr, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); - EXPECT_FALSE(t.fixed); - } -} - TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_unicast_address) { + const char* const default_addr = "::"; + { AddressTest t; ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, "[::]")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, default_addr)); EXPECT_FALSE(t.fixed); } @@ -342,7 +170,7 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_unicast_address) AddressTest t; t.rtps.spdp_port_mode(PortMode_Probe); ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, "[::]")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7660, default_addr)); EXPECT_FALSE(t.fixed); } @@ -352,14 +180,14 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_unicast_address) t.rtps.spdp_port_mode(PortMode_System); ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 0)); EXPECT_ADDR_EQ(t.addr, NetworkAddress()); - EXPECT_FALSE(t.fixed); + EXPECT_TRUE(t.fixed); } { AddressTest t; t.rtps.spdp_port_mode(PortMode_Probe); ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 3)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7666, "[::]")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7666, default_addr)); EXPECT_FALSE(t.fixed); } @@ -371,7 +199,7 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_unicast_address) t.rtps.pg(3); t.rtps.d1(8); ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 3)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "[::]")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, default_addr)); EXPECT_FALSE(t.fixed); } @@ -385,32 +213,34 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_unicast_address) LogRestore lr; log_level.set(LogLevel::None); ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 9999, 9999)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, "[::]")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(29664, default_addr)); EXPECT_FALSE(t.fixed); } { AddressTest t; - t.rtps.spdp_local_address(NetworkAddress(1234, "[1:2:3:4]")); + t.rtps.ipv6_spdp_local_address(fake_ipv6_addr); ASSERT_TRUE(t.rtps.ipv6_spdp_unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); + EXPECT_ADDR_EQ(t.addr, fake_ipv6_addr); EXPECT_TRUE(t.fixed); } } TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_multicast_address) { + const char* const default_addr = "ff03::1"; + { AddressTest t; ASSERT_TRUE(t.rtps.ipv6_spdp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7650, "[FF03::1]")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7650, default_addr)); EXPECT_FALSE(t.fixed); } { AddressTest t; ASSERT_TRUE(t.rtps.ipv6_spdp_multicast_address(t.addr, 2)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7900, "[FF03::1]")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7900, default_addr)); EXPECT_FALSE(t.fixed); } @@ -420,7 +250,7 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_multicast_address) t.rtps.dg(260); t.rtps.d0(17); ASSERT_TRUE(t.rtps.ipv6_spdp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "[FF03::1]")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, default_addr)); EXPECT_FALSE(t.fixed); } @@ -432,62 +262,15 @@ TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_spdp_multicast_address) LogRestore lr; log_level.set(LogLevel::None); ASSERT_TRUE(t.rtps.ipv6_spdp_multicast_address(t.addr, 9999)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, "[FF03::1]")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, default_addr)); EXPECT_FALSE(t.fixed); } { AddressTest t; - t.rtps.ipv6_spdp_multicast_address(NetworkAddress(1234, "[1:2:3:4]")); + t.rtps.ipv6_spdp_multicast_address(fake_ipv6_addr); ASSERT_TRUE(t.rtps.ipv6_spdp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); - EXPECT_FALSE(t.fixed); - } -} - -TEST(dds_DCPS_RTPS_RtpsDiscoveryConfig, ipv6_sedp_multicast_address) -{ - { - AddressTest t; - ASSERT_TRUE(t.rtps.ipv6_sedp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7652, "[FF03::1]")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - ASSERT_TRUE(t.rtps.ipv6_sedp_multicast_address(t.addr, 2)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7902, "[FF03::1]")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.pb(7500); - t.rtps.dg(260); - t.rtps.dx(17); - ASSERT_TRUE(t.rtps.ipv6_sedp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(7777, "[FF03::1]")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.pb(9999); - t.rtps.dg(9999); - t.rtps.dx(9999); - LogRestore lr; - log_level.set(LogLevel::None); - ASSERT_TRUE(t.rtps.ipv6_sedp_multicast_address(t.addr, 9999)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(57599, "[FF03::1]")); - EXPECT_FALSE(t.fixed); - } - - { - AddressTest t; - t.rtps.ipv6_sedp_multicast_address(NetworkAddress(1234, "[1:2:3:4]")); - ASSERT_TRUE(t.rtps.ipv6_sedp_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); + EXPECT_ADDR_EQ(t.addr, fake_ipv6_addr); EXPECT_FALSE(t.fixed); } } diff --git a/tests/unit-tests/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp b/tests/unit-tests/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp index f7e22f36aae..6b48dca7c34 100644 --- a/tests/unit-tests/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp +++ b/tests/unit-tests/dds/DCPS/transport/rtps_udp/RtpsUdpInst.cpp @@ -12,7 +12,7 @@ namespace { RtpsUdpType() : store(make_rch(TheServiceParticipant->config_topic())) - , rtps_udp(make_rch("RTPS_UDP_INST_UNIT_TEST", false)) + , rtps_udp(make_rch("RTPS_UDP_INST_UNIT_TEST", true)) { store->unset_section(rtps_udp->config_prefix()); } @@ -33,6 +33,11 @@ namespace { { } }; + + const NetworkAddress fake_ipv4_addr(1234, "1.2.3.4"); +#ifdef ACE_HAS_IPV6 + const NetworkAddress fake_ipv6_addr(1234, "::1:2:3:4"); +#endif } TEST(dds_DCPS_RTPS_RtpsUdpInst, multicast_address) @@ -77,9 +82,31 @@ TEST(dds_DCPS_RTPS_RtpsUdpInst, multicast_address) { AddressTest t; - t.rtps_udp->multicast_group_address(NetworkAddress(1234, "1.2.3.4")); + t.rtps_udp->multicast_group_address(fake_ipv4_addr); + ASSERT_TRUE(t.rtps_udp->multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, fake_ipv4_addr); + EXPECT_FALSE(t.fixed); + } + + // add_domain_id_to_port template with fixed port + { + AddressTest t; + t.store->set_string(t.rtps_udp->config_key("CUSTOMIZATION").c_str(), "CUST"); + t.store->set_string("CUSTOMIZATION_CUST_MULTICAST_GROUP_ADDRESS", "add_domain_id_to_port"); + t.rtps_udp->multicast_group_address(fake_ipv4_addr); + ASSERT_TRUE(t.rtps_udp->multicast_address(t.addr, 1)); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(1235, "1.2.3.4")); + EXPECT_FALSE(t.fixed); + } + + // add_domain_id_to_port template with spec port + { + AddressTest t; + t.store->set_string(t.rtps_udp->config_key("CUSTOMIZATION").c_str(), "CUST"); + t.store->set_string("CUSTOMIZATION_CUST_MULTICAST_GROUP_ADDRESS", "add_domain_id_to_port"); + t.rtps_udp->multicast_group_address(NetworkAddress(0, "1.2.3.4")); ASSERT_TRUE(t.rtps_udp->multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(7652, "1.2.3.4")); EXPECT_FALSE(t.fixed); } } @@ -91,16 +118,16 @@ TEST(dds_DCPS_RTPS_RtpsUdpInst, unicast_address) { AddressTest t; ASSERT_TRUE(t.rtps_udp->unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress()); - EXPECT_FALSE(t.fixed); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(0, default_addr)); + EXPECT_TRUE(t.fixed); } { AddressTest t; t.rtps_udp->port_mode(PortMode_System); ASSERT_TRUE(t.rtps_udp->unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress()); - EXPECT_FALSE(t.fixed); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(0, default_addr)); + EXPECT_TRUE(t.fixed); } { @@ -147,9 +174,9 @@ TEST(dds_DCPS_RTPS_RtpsUdpInst, unicast_address) { AddressTest t; - t.rtps_udp->local_address(NetworkAddress(1234, "1.2.3.4")); + t.rtps_udp->local_address(fake_ipv4_addr); ASSERT_TRUE(t.rtps_udp->unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "1.2.3.4")); + EXPECT_ADDR_EQ(t.addr, fake_ipv4_addr); EXPECT_TRUE(t.fixed); } } @@ -157,7 +184,7 @@ TEST(dds_DCPS_RTPS_RtpsUdpInst, unicast_address) #ifdef ACE_HAS_IPV6 TEST(dds_DCPS_RTPS_RtpsUdpInst, ipv6_multicast_address) { - const char* const default_addr = "239.255.0.2"; + const char* const default_addr = "ff03::2"; { AddressTest t; @@ -197,30 +224,30 @@ TEST(dds_DCPS_RTPS_RtpsUdpInst, ipv6_multicast_address) { AddressTest t; - t.rtps_udp->multicast_group_address(NetworkAddress(1234, "[1:2:3:4]")); + t.rtps_udp->ipv6_multicast_group_address(fake_ipv6_addr); ASSERT_TRUE(t.rtps_udp->ipv6_multicast_address(t.addr, 1)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); + EXPECT_ADDR_EQ(t.addr, fake_ipv6_addr); EXPECT_FALSE(t.fixed); } } TEST(dds_DCPS_RTPS_RtpsUdpInst, ipv6_unicast_address) { - const char* const default_addr = "[::]"; + const char* const default_addr = "::"; { AddressTest t; ASSERT_TRUE(t.rtps_udp->ipv6_unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress()); - EXPECT_FALSE(t.fixed); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(0, default_addr)); + EXPECT_TRUE(t.fixed); } { AddressTest t; t.rtps_udp->port_mode(PortMode_System); ASSERT_TRUE(t.rtps_udp->ipv6_unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress()); - EXPECT_FALSE(t.fixed); + EXPECT_ADDR_EQ(t.addr, NetworkAddress(0, default_addr)); + EXPECT_TRUE(t.fixed); } { @@ -267,9 +294,9 @@ TEST(dds_DCPS_RTPS_RtpsUdpInst, ipv6_unicast_address) { AddressTest t; - t.rtps_udp->local_address(NetworkAddress(1234, "[1:2:3:4]")); + t.rtps_udp->ipv6_local_address(fake_ipv6_addr); ASSERT_TRUE(t.rtps_udp->ipv6_unicast_address(t.addr, t.fixed, 1, 0)); - EXPECT_ADDR_EQ(t.addr, NetworkAddress(1234, "[1:2:3:4]")); + EXPECT_ADDR_EQ(t.addr, fake_ipv6_addr); EXPECT_TRUE(t.fixed); } } From cc0ea977f88ae56f437a0cbf56aa37c146e977b4 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Tue, 28 May 2024 13:26:07 -0500 Subject: [PATCH 33/60] Review, Fix spdp_transport Test, Doc Tweaks --- dds/DCPS/RTPS/Sedp.h | 2 +- dds/DCPS/RTPS/Spdp.cpp | 4 ++-- docs/devguide/run_time_configuration.rst | 12 +++++++++++- docs/news.d/rtps-ports.rst | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/dds/DCPS/RTPS/Sedp.h b/dds/DCPS/RTPS/Sedp.h index a32ed0628cc..580d009e3a9 100644 --- a/dds/DCPS/RTPS/Sedp.h +++ b/dds/DCPS/RTPS/Sedp.h @@ -666,7 +666,7 @@ class Sedp : public virtual DCPS::RcEventHandler { protected: DCPS::GUID_t repo_id_; - DDS::DomainId_t domain_id_; + const DDS::DomainId_t domain_id_; Sedp& sedp_; AtomicBool shutting_down_; #ifdef OPENDDS_SECURITY diff --git a/dds/DCPS/RTPS/Spdp.cpp b/dds/DCPS/RTPS/Spdp.cpp index b0af3fdb0d1..94ca65fb3a5 100644 --- a/dds/DCPS/RTPS/Spdp.cpp +++ b/dds/DCPS/RTPS/Spdp.cpp @@ -3512,9 +3512,9 @@ Spdp::SpdpTransport::open_unicast_ipv6_socket(DDS::UInt16 participant_id) DCPS::NetworkAddress local_addr; bool fixed_port; - if (!outer->config_->spdp_unicast_address( + if (!outer->config_->ipv6_spdp_unicast_address( local_addr, fixed_port, outer->domain_, participant_id)) { - throw std::runtime_error("failed to get valid unicast IPv4 address for SPDP"); + throw std::runtime_error("failed to get valid unicast IPv6 address for SPDP"); } if (unicast_ipv6_socket_.open(local_addr.to_addr(), PF_INET6) != 0) { diff --git a/docs/devguide/run_time_configuration.rst b/docs/devguide/run_time_configuration.rst index d56c4ad6139..aab20e624f1 100644 --- a/docs/devguide/run_time_configuration.rst +++ b/docs/devguide/run_time_configuration.rst @@ -1306,11 +1306,13 @@ Those properties, along with options specific to OpenDDS's RTPS discovery implem The default is defined by the RTPS specification. This property can be used, for example, to specify use of a routed group address to provide a larger discovery scope. It can be modified by :prop:`[Customization]InteropMulticastOverride`. + It is the default host for :prop:`SpdpMulticastAddress` and :prop:`SedpMulticastAddress`. .. prop:: Ipv6DefaultMulticastGroup= :default: ``ff03::1`` IPv6-variant of :prop:`InteropMulticastOverride`. + It is the default host for :prop:`Ipv6SpdpMulticastAddress` and :prop:`Ipv6SedpMulticastAddress`. .. prop:: TTL=n :default: ``1`` (all data is restricted to the local network) @@ -1533,6 +1535,10 @@ The SEDP unicast port will be one of the following: - Port from :prop:`SedpLocalAddress <[rtps_discovery]SedpLocalAddress>` if set - :prop:`PB <[rtps_discovery]PB>` + :prop:`DG <[rtps_discovery]DG>` × *domainId* + :prop:`DY <[rtps_discovery]DY>` + :prop:`PG <[rtps_discovery]PG>` × *participantId* if :val:`SedpPortMode=probe <[rtps_discovery]SedpPortMode=probe>` is set + + - If the port can not be opened, then the *participantId* is incremented until a port can be opened. + - If no valid UDP port can be opened, then an error will be logged. + - A system-provided port if :val:`SedpPortMode=system <[rtps_discovery]SedpPortMode=system>` (default) .. _run_time_configuration--additional-ddsi-rtps-discovery-features: @@ -2726,7 +2732,7 @@ Some implementation notes related to using the ``rtps_udp`` transport protocol a .. prop:: ipv6_multicast_group_address= :default: ``[FF03::2]:0`` - When the transport is set to multicast, this is the multicast network address that should be used. + When :prop:`use_multicast` is enabled, this is the multicast IPv6 network address that should be used. If ```` is ``0`` or not specified, it is calculated as described in :ref:`config-ports-used-by-rtps-udp-multicast`. .. prop:: multicast_interface= @@ -2899,6 +2905,10 @@ The RTPS/UDP unicast port will be one of the following: - Port from :prop:`local_address <[transport@rtps_udp]local_address>` and :prop:`ipv6_local_address <[transport@rtps_udp]ipv6_local_address>` if set - :prop:`PB <[transport@rtps_udp]PB>` + :prop:`DG <[transport@rtps_udp]DG>` × *domainId* + :prop:`D3 <[transport@rtps_udp]D3>` + :prop:`PG <[transport@rtps_udp]PG>` × *participantId* if :val:`PortMode=prob <[transport@rtps_udp]PortMode=probe>` + + - If the port can not be opened, then the *participantId* is incremented until a port can be opened. + - If no valid UDP port can be opened, then an error will be logged. + - A system-provided port if :val:`PortMode=system <[transport@rtps_udp]PortMode=system>` (default) .. _run_time_configuration--additional-rtps-udp-features: diff --git a/docs/news.d/rtps-ports.rst b/docs/news.d/rtps-ports.rst index 136c28a0404..0f5788b45ce 100644 --- a/docs/news.d/rtps-ports.rst +++ b/docs/news.d/rtps-ports.rst @@ -5,7 +5,7 @@ - For RTPS Discovery: - - :cfg:val:`[rtps_discovery]SedpPortMode=probe` will use ports similar to how the RTPS specification defines them. + - Added :cfg:val:`[rtps_discovery]SedpPortMode=probe`, which will use ports similar to how the RTPS specification defines them. This uses the existing port parameter properties for SPDP and a new one, :cfg:prop:`[rtps_discovery]DY`. - Added :cfg:prop:`[rtps_discovery]SpdpPortMode` as an alias to the now deprecated :cfg:prop:`[rtps_discovery]SpdpRequestRandomPort`. - Added :cfg:prop:`[rtps_discovery]SpdpMulticastAddress`, :cfg:prop:`[rtps_discovery]Ipv6SpdpMulticastAddress`, :cfg:prop:`[rtps_discovery]SedpMulticastAddress`, and :cfg:prop:`[rtps_discovery]Ipv6SedpMulticastAddress` to set the multicast addresses and ports separately on SPDP and SEDP. @@ -13,7 +13,7 @@ - For RTPS/UDP Transport: - - Added :cfg:val:`[transport@rtps_udp]PortMode=probe` will use port exactly as the RTPS specification defines them. + - Added :cfg:val:`[transport@rtps_udp]PortMode=probe`, which will use ports exactly as the RTPS specification defines them. This uses new port parameter properties: :cfg:prop:`[transport@rtps_udp]PB`, :cfg:prop:`[transport@rtps_udp]DG`, :cfg:prop:`[transport@rtps_udp]PG`, :cfg:prop:`[transport@rtps_udp]D2`, and :cfg:prop:`[transport@rtps_udp]D3`. - See :ref:`here ` for the full overview of port usage. From b96e697057648c9ab7c947471aebe32cfb13f473 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 29 May 2024 13:44:04 -0500 Subject: [PATCH 34/60] Cleaner CMake C++ Standard Target Check, Add News --- cmake/build_ace_tao.cmake | 9 +++++---- docs/news.d/cmake_just_build_host_tools.rst | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 docs/news.d/cmake_just_build_host_tools.rst diff --git a/cmake/build_ace_tao.cmake b/cmake/build_ace_tao.cmake index 3e12f1b1546..98022b6f517 100644 --- a/cmake/build_ace_tao.cmake +++ b/cmake/build_ace_tao.cmake @@ -36,11 +36,12 @@ execute_process( # Get the C++ standard OpenDDS is going to be built with. We are going to force # the ACE/TAO build to use the same standard. -set(_opendds_idl_std "$") -if(NOT OPENDDS_JUST_BUILD_HOST_TOOLS) - set(_opendds_dcps_std "$") +if(TARGET OpenDDS_Dcps) + set(_opendds_std_target OpenDDS_Dcps) +else() + set(_opendds_std_target opendds_idl) endif() -set(_opendds_std "$,${_opendds_dcps_std},${_opendds_idl_std}>") +set(_opendds_std "$") set(_build_cmd "${CMAKE_COMMAND}" -E env "ACE_ROOT=${OPENDDS_ACE}" "TAO_ROOT=${OPENDDS_TAO}") if(_OPENDDS_XERCES3_FOR_ACE) diff --git a/docs/news.d/cmake_just_build_host_tools.rst b/docs/news.d/cmake_just_build_host_tools.rst new file mode 100644 index 00000000000..a7d75aa6672 --- /dev/null +++ b/docs/news.d/cmake_just_build_host_tools.rst @@ -0,0 +1,7 @@ +.. news-prs: 4646 + +.. news-start-section: Platform Support and Dependencies +.. news-start-section: Building with CMake +- Fixed :ghissue:`configure error <4645>` when using :cmake:var:`OPENDDS_JUST_BUILD_HOST_TOOLS` with CMake <3.28. +.. news-end-section +.. news-end-section From cd58f706ffbdff3b5f4631ba430f7b9ea91a475a Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Wed, 22 May 2024 10:49:48 -0500 Subject: [PATCH 35/60] Inconsistent setting of `OPENDDS_SECURITY` corrupts builds Problem ------- `OPENDDS_SECURITY` is a macro that appears in public headers. If a user enables security during the build of OpenDDS but then does not set it during the build of their application, then the build is inconsistent and the application fails in unexpected ways. Regardless of the build system (MPC, CMake, or something else), the idea that security is enabled must be preserved to generate consistent builds. Solution -------- See https://github.com/OpenDDS/OpenDDS/issues/4616 for background. Add `OPENDDS_CONFIG_SECURITY` to `dds/OpenDDSConfig.h`. Add `dds/OpenDDSConfigWrapper.h` and `dds/OpenDDSConfigWrapper.idl` which accommodate both `OPENDDS_SECURITY` and `OPENDDS_CONFIG_SECURITY`. --- CMakeLists.txt | 1 + cmake/opendds_target_sources.cmake | 5 + configure | 1 + dds/CMakeLists.txt | 3 + dds/DCPS/DCPS_Utils.cpp | 4 +- dds/DCPS/DataReaderImpl.cpp | 30 +- dds/DCPS/DataReaderImpl.h | 7 +- dds/DCPS/DataReaderImpl_T.h | 11 +- dds/DCPS/DataWriterImpl.cpp | 31 +- dds/DCPS/DataWriterImpl.h | 8 +- dds/DCPS/DataWriterImpl_T.h | 14 +- dds/DCPS/Definitions.h | 9 +- dds/DCPS/Discovery.h | 23 +- dds/DCPS/DomainParticipantImpl.cpp | 47 ++-- dds/DCPS/DomainParticipantImpl.h | 21 +- .../InfoRepoDiscovery/InfoRepoDiscovery.cpp | 11 +- .../InfoRepoDiscovery/InfoRepoDiscovery.h | 9 +- dds/DCPS/RTPS/DiscoveredEntities.h | 41 +-- dds/DCPS/RTPS/ICE/AgentImpl.cpp | 6 +- dds/DCPS/RTPS/ICE/AgentImpl.h | 7 +- dds/DCPS/RTPS/ICE/Checklist.cpp | 6 +- dds/DCPS/RTPS/ICE/Checklist.h | 6 +- dds/DCPS/RTPS/ICE/EndpointManager.cpp | 7 +- dds/DCPS/RTPS/ICE/EndpointManager.h | 8 +- dds/DCPS/RTPS/ICE/Ice.cpp | 8 +- dds/DCPS/RTPS/ICE/Ice.h | 6 +- dds/DCPS/RTPS/ICE/Stun.cpp | 6 +- dds/DCPS/RTPS/ICE/Stun.h | 6 +- dds/DCPS/RTPS/ICE/Task.cpp | 6 +- dds/DCPS/RTPS/LocalEntities.h | 9 +- dds/DCPS/RTPS/MessageTypes.h | 4 +- dds/DCPS/RTPS/MessageUtils.h | 11 +- dds/DCPS/RTPS/ParameterListConverter.cpp | 20 +- dds/DCPS/RTPS/ParameterListConverter.h | 12 +- dds/DCPS/RTPS/RtpsCore.idl | 7 +- dds/DCPS/RTPS/RtpsDiscovery.cpp | 17 +- dds/DCPS/RTPS/RtpsDiscovery.h | 10 +- dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp | 6 +- dds/DCPS/RTPS/RtpsDiscoveryConfig.h | 8 +- dds/DCPS/RTPS/RtpsSecurity.idl | 4 +- dds/DCPS/RTPS/Sedp.cpp | 266 +++++++++--------- dds/DCPS/RTPS/Sedp.h | 84 +++--- dds/DCPS/RTPS/Spdp.cpp | 119 ++++---- dds/DCPS/RTPS/Spdp.h | 57 ++-- dds/DCPS/Service_Participant.cpp | 26 +- dds/DCPS/Service_Participant.h | 18 +- dds/DCPS/StaticDiscovery.cpp | 18 +- dds/DCPS/StaticDiscovery.h | 16 +- dds/DCPS/debug.cpp | 11 +- dds/DCPS/debug.h | 10 +- .../security/BuiltInSecurityPluginInst.cpp | 6 +- dds/DCPS/security/BuiltInSecurityPluginInst.h | 7 +- .../security/framework/HandleRegistry.cpp | 6 +- dds/DCPS/security/framework/HandleRegistry.h | 6 +- .../security/framework/SecurityConfig.cpp | 8 +- dds/DCPS/security/framework/SecurityConfig.h | 18 +- .../security/framework/SecurityPluginInst.h | 9 +- .../security/framework/SecurityRegistry.cpp | 19 +- .../transport/framework/TransportClient.cpp | 2 +- .../transport/framework/TransportClient.h | 4 +- dds/DCPS/transport/framework/TransportImpl.h | 21 +- .../framework/TransportSendStrategy.cpp | 10 +- .../framework/TransportSendStrategy.h | 8 +- .../transport/rtps_udp/RtpsSampleHeader.cpp | 12 +- .../transport/rtps_udp/RtpsUdpDataLink.cpp | 63 +++-- dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.h | 43 +-- .../transport/rtps_udp/RtpsUdpDataLink.inl | 2 +- .../rtps_udp/RtpsUdpReceiveStrategy.cpp | 38 +-- .../rtps_udp/RtpsUdpReceiveStrategy.h | 11 +- .../rtps_udp/RtpsUdpSendStrategy.cpp | 12 +- .../transport/rtps_udp/RtpsUdpSendStrategy.h | 14 +- .../transport/rtps_udp/RtpsUdpTransport.cpp | 31 +- .../transport/rtps_udp/RtpsUdpTransport.h | 14 +- dds/DdsDcps.mpc | 3 + dds/DdsSecurityCore.idl | 4 +- dds/DdsSecurityParams.idl | 4 +- dds/OpenDDSConfig.h.in | 2 + dds/OpenDDSConfigWrapper.h | 32 +++ dds/OpenDDSConfigWrapper.idl | 11 + dds/OpenDDSConfigWrapperC.h | 11 + examples/DCPS/ishapes/ShapesWidget.cpp | 4 +- examples/DCPS/ishapes/main.cpp | 9 +- .../bench/unit-tests/UnitTests.cpp | 7 +- performance-tests/bench/worker/main.cpp | 4 +- tests/DCPS/FindTopic/LocalDiscovery.cpp | 6 +- tests/DCPS/FindTopic/LocalDiscovery.h | 5 +- tests/DCPS/LargeSample/common.cpp | 7 +- tests/DCPS/LargeSample/common.h | 3 +- tests/DCPS/LargeSample/publisher.cpp | 7 +- tests/DCPS/LargeSample/subscriber.cpp | 10 +- tests/DCPS/Messenger/publisher.cpp | 11 +- tests/DCPS/Messenger/subscriber.cpp | 9 +- .../ParticipantLocationTest.cpp | 7 +- tests/DCPS/Restart/RestartTest.cpp | 19 +- tests/DCPS/RtpsRelay/STUN/StunClient.cpp | 9 +- tests/DCPS/RtpsRelay/Smoke/monitor.cpp | 6 +- tests/DCPS/RtpsRelay/Smoke/publisher.cpp | 14 +- tests/DCPS/RtpsRelay/Smoke/subscriber.cpp | 14 +- tests/DCPS/XTypes/Common.h | 13 +- tests/cmake/idl_compiler_tests/CMakeLists.txt | 6 + tests/stress-tests/StressTests.cpp | 6 +- tests/transport/spdp/spdp_transport.cpp | 8 +- tests/unit-tests/UnitTests.cpp | 7 +- .../dds/DCPS/RTPS/DiscoveredEntities.cpp | 23 +- .../dds/DCPS/RTPS/LocalEntities.cpp | 4 +- .../dds/DCPS/RTPS/ParameterListConverter.cpp | 13 +- .../security/AccessControl/Permissions.cpp | 6 +- .../DCPS/security/AccessControl/XmlUtils.cpp | 6 +- .../security/AccessControlBuiltInImpl.cpp | 4 +- .../LocalAuthCredentialData.cpp | 4 +- .../security/AuthenticationBuiltInImpl.cpp | 3 +- .../dds/DCPS/security/CryptoBuiltInImpl.cpp | 4 +- .../dds/DCPS/security/SSL/Certificate.cpp | 4 +- .../dds/DCPS/security/SSL/DiffieHellman.cpp | 4 +- .../dds/DCPS/security/SSL/PrivateKey.cpp | 4 +- .../dds/DCPS/security/SSL/SignedDocument.cpp | 4 +- .../dds/DCPS/security/SSL/SubjectName.cpp | 4 +- .../dds/DCPS/security/SSL/Utils.cpp | 4 +- .../security/framework/SecurityConfig.cpp | 4 +- 119 files changed, 1064 insertions(+), 734 deletions(-) create mode 100644 dds/OpenDDSConfigWrapper.h create mode 100644 dds/OpenDDSConfigWrapper.idl create mode 100644 dds/OpenDDSConfigWrapperC.h diff --git a/CMakeLists.txt b/CMakeLists.txt index cc5084db4c1..b8df092369a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ endif() set(OPENDDS_CONFIG_AUTO_STATIC_INCLUDES 1) # Always true for CMake builds set(config_file "dds/OpenDDSConfig.h") set(config_out_dir "${CMAKE_CURRENT_BINARY_DIR}/opendds_config_include") +set(OPENDDS_CONFIG_INCLUDE_DIR "${config_out_dir}" CACHE INTERNAL "") set(config_out_file "${config_out_dir}/${config_file}") configure_file("${config_file}.in" "${config_out_file}") add_library(OpenDDS_Config INTERFACE) diff --git a/cmake/opendds_target_sources.cmake b/cmake/opendds_target_sources.cmake index 13bd83e0172..11c168304e3 100644 --- a/cmake/opendds_target_sources.cmake +++ b/cmake/opendds_target_sources.cmake @@ -351,6 +351,11 @@ function(opendds_target_sources target) list(APPEND opendds_options "-D${def}") endforeach() + if(DEFINED OPENDDS_CONFIG_INCLUDE_DIR) + list(APPEND tao_options "-I${OPENDDS_CONFIG_INCLUDE_DIR}") + list(APPEND opendds_options "-I${OPENDDS_CONFIG_INCLUDE_DIR}") + endif() + foreach(scope PUBLIC PRIVATE INTERFACE) if(idl_sources_${scope}) _opendds_target_idl_sources(${target} diff --git a/configure b/configure index 5fc0993d5e8..619d7ae87f3 100755 --- a/configure +++ b/configure @@ -1433,6 +1433,7 @@ sub write_opendds_configh { my %config = ( 'OPENDDS_CONFIG_AUTO_STATIC_INCLUDES' => 0, 'OPENDDS_CONFIG_BOOTTIME_TIMERS' => $opts{'boottime'} // 0, + 'OPENDDS_CONFIG_SECURITY' => $opts{'security'} // 0, ); my $replace_value = sub { diff --git a/dds/CMakeLists.txt b/dds/CMakeLists.txt index 81c114a47cb..822f538b8c4 100644 --- a/dds/CMakeLists.txt +++ b/dds/CMakeLists.txt @@ -555,6 +555,9 @@ target_sources(OpenDDS_Dcps DCPS/yard/yard_tree.hpp Version.h Versioned_Namespace.h + OpenDDSConfigWrapper.h + OpenDDSConfigWrapperC.h + OpenDDSConfigWrapper.idl ) target_compile_definitions(OpenDDS_Dcps PUBLIC ${OPENDDS_DCPS_COMPILE_DEFINITIONS}) _opendds_library(OpenDDS_Dcps MSVC_BIGOBJ) diff --git a/dds/DCPS/DCPS_Utils.cpp b/dds/DCPS/DCPS_Utils.cpp index a9a7919fac9..50dcc73d7cd 100644 --- a/dds/DCPS/DCPS_Utils.cpp +++ b/dds/DCPS/DCPS_Utils.cpp @@ -15,7 +15,7 @@ #include /* For ACE::wild_match() */ #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include "dds/DdsSecurityCoreC.h" #endif @@ -55,7 +55,7 @@ const char* retcode_to_string(DDS::ReturnCode_t value) return "No data"; case DDS::RETCODE_ILLEGAL_OPERATION: return "Illegal operation"; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY case DDS::Security::RETCODE_NOT_ALLOWED_BY_SECURITY: return "Not allowed by security"; #endif diff --git a/dds/DCPS/DataReaderImpl.cpp b/dds/DCPS/DataReaderImpl.cpp index e110172230e..f6eb48bfc85 100644 --- a/dds/DCPS/DataReaderImpl.cpp +++ b/dds/DCPS/DataReaderImpl.cpp @@ -7,27 +7,31 @@ #include "DataReaderImpl.h" -#include "SubscriptionInstance.h" -#include "ReceivedDataElementList.h" +#include "DCPS_Utils.h" #include "DomainParticipantImpl.h" -#include "Service_Participant.h" -#include "Qos_Helper.h" #include "FeatureDisabledQosCheck.h" #include "GuidConverter.h" -#include "TopicImpl.h" +#include "MonitorFactory.h" +#include "Qos_Helper.h" +#include "QueryConditionImpl.h" +#include "ReadConditionImpl.h" +#include "ReceivedDataElementList.h" +#include "SafetyProfileStreams.h" #include "Serializer.h" +#include "Service_Participant.h" #include "SubscriberImpl.h" +#include "SubscriptionInstance.h" +#include "TopicImpl.h" #include "Transient_Kludge.h" +#include "TypeSupportImpl.h" #include "Util.h" -#include "DCPS_Utils.h" -#include "QueryConditionImpl.h" -#include "ReadConditionImpl.h" -#include "MonitorFactory.h" + #include "transport/framework/EntryExit.h" #include "transport/framework/TransportExceptions.h" -#include "SafetyProfileStreams.h" -#include "TypeSupportImpl.h" + #include "XTypes/TypeObject.h" + +#include #ifndef DDS_HAS_MINIMUM_BIT # include "BuiltInTopicUtils.h" #endif @@ -1267,7 +1271,7 @@ DataReaderImpl::enable() exprParams, type_info); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY { ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, sample_lock_, DDS::RETCODE_ERROR); security_config_ = participant->get_security_config(); @@ -3387,7 +3391,7 @@ void DataReaderImpl::accept_sample_processing(const SubscriptionInstance_rch& in } } -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY DDS::Security::ParticipantCryptoHandle DataReaderImpl::get_crypto_handle() const { RcHandle participant = participant_servant_.lock(); diff --git a/dds/DCPS/DataReaderImpl.h b/dds/DCPS/DataReaderImpl.h index b11a23693bd..fa2cd8329b6 100644 --- a/dds/DCPS/DataReaderImpl.h +++ b/dds/DCPS/DataReaderImpl.h @@ -11,6 +11,7 @@ #include "dcps_export.h" #include "AssociationData.h" +#include "AtomicBool.h" #include "Cached_Allocator_With_Overflow_T.h" #include "CoherentChangeControl.h" #include "ContentFilteredTopicImpl.h" @@ -35,7 +36,7 @@ #include "TopicImpl.h" #include "WriterInfo.h" #include "ZeroCopyInfoSeq_T.h" -#include "AtomicBool.h" + #include "transport/framework/ReceivedDataSample.h" #include "transport/framework/TransportClient.h" #include "transport/framework/TransportReceiveListener.h" @@ -824,7 +825,7 @@ class OpenDDS_Dcps_Export DataReaderImpl return data.publication_transport_priority_; } -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY DDS::Security::ParticipantCryptoHandle get_crypto_handle() const; #endif @@ -1074,7 +1075,7 @@ class OpenDDS_Dcps_Export DataReaderImpl }; protected: -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Security::SecurityConfig_rch security_config_; DDS::DynamicType_var dynamic_type_; #endif diff --git a/dds/DCPS/DataReaderImpl_T.h b/dds/DCPS/DataReaderImpl_T.h index 04bf91151cf..6b656b7d367 100644 --- a/dds/DCPS/DataReaderImpl_T.h +++ b/dds/DCPS/DataReaderImpl_T.h @@ -7,16 +7,19 @@ # define OPENDDS_HAS_STD_SHARED_PTR #endif +#include "BuiltInTopicUtils.h" +#include "GuidConverter.h" #include "MultiTopicImpl.h" #include "RakeResults_T.h" #include "SubscriberImpl.h" -#include "BuiltInTopicUtils.h" -#include "Util.h" #include "TypeSupportImpl.h" +#include "Util.h" #include "dcps_export.h" -#include "GuidConverter.h" + #include "XTypes/DynamicDataAdapter.h" +#include + #ifndef OPENDDS_HAS_STD_SHARED_PTR # include #endif @@ -1268,7 +1271,7 @@ namespace OpenDDS { const OpenDDS::DCPS::DataSampleHeader& header, OpenDDS::DCPS::SubscriptionInstance_rch& instance_ptr) { -#if defined(OPENDDS_SECURITY) && OPENDDS_HAS_DYNAMIC_DATA_ADAPTER +#if OPENDDS_CONFIG_SECURITY && OPENDDS_HAS_DYNAMIC_DATA_ADAPTER const bool is_dispose_msg = header.message_id_ == OpenDDS::DCPS::DISPOSE_INSTANCE || header.message_id_ == OpenDDS::DCPS::DISPOSE_UNREGISTER_INSTANCE; diff --git a/dds/DCPS/DataWriterImpl.cpp b/dds/DCPS/DataWriterImpl.cpp index e542ae6b506..4624a389fa0 100644 --- a/dds/DCPS/DataWriterImpl.cpp +++ b/dds/DCPS/DataWriterImpl.cpp @@ -7,23 +7,26 @@ #include "DataWriterImpl.h" -#include "FeatureDisabledQosCheck.h" +#include "DCPS_Utils.h" +#include "DataDurabilityCache.h" +#include "DataSampleElement.h" #include "DomainParticipantImpl.h" -#include "PublisherImpl.h" -#include "Service_Participant.h" +#include "FeatureDisabledQosCheck.h" #include "GuidConverter.h" -#include "TopicImpl.h" +#include "MonitorFactory.h" #include "PublicationInstance.h" +#include "PublisherImpl.h" +#include "SendStateDataSampleList.h" #include "Serializer.h" +#include "Service_Participant.h" +#include "TopicImpl.h" #include "Transient_Kludge.h" -#include "DataDurabilityCache.h" -#include "MonitorFactory.h" -#include "SendStateDataSampleList.h" -#include "DataSampleElement.h" +#include "TypeSupportImpl.h" #include "Util.h" -#include "DCPS_Utils.h" + #include "XTypes/TypeObject.h" -#include "TypeSupportImpl.h" + +#include #ifndef OPENDDS_NO_OBJECT_MODEL_PROFILE # include "CoherentChangeControl.h" #endif @@ -1519,7 +1522,7 @@ DataWriterImpl::enable() return DDS::RETCODE_ERROR; } -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY security_config_ = participant->get_security_config(); participant_permissions_handle_ = participant->permissions_handle(); dynamic_type_ = type_support_->get_type(); @@ -2764,7 +2767,7 @@ DataWriterImpl::retrieve_inline_qos_data(TransportSendListener::InlineQosData& q qos_data.topic_name = this->topic_name_.in(); } -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY DDS::Security::ParticipantCryptoHandle DataWriterImpl::get_crypto_handle() const { RcHandle participant = participant_servant_.lock(); @@ -2961,7 +2964,7 @@ DDS::ReturnCode_t DataWriterImpl::dispose_w_timestamp( DDS::InstanceHandle_t instance_handle, const DDS::Time_t& source_timestamp) { -#if defined(OPENDDS_SECURITY) && OPENDDS_HAS_DYNAMIC_DATA_ADAPTER +#if OPENDDS_CONFIG_SECURITY && OPENDDS_HAS_DYNAMIC_DATA_ADAPTER DDS::DynamicData_var dynamic_data = sample.get_dynamic_data(dynamic_type_); DDS::Security::SecurityException ex; if (dynamic_data && security_config_ && @@ -3100,7 +3103,7 @@ DDS::ReturnCode_t DataWriterImpl::get_or_create_instance_handle( handle = lookup_instance(sample); if (handle == DDS::HANDLE_NIL || !get_handle_instance(handle)) { Sample_rch copy = sample.copy(Sample::ReadOnly, Sample::KeyOnly); -#if defined(OPENDDS_SECURITY) && OPENDDS_HAS_DYNAMIC_DATA_ADAPTER +#if OPENDDS_CONFIG_SECURITY && OPENDDS_HAS_DYNAMIC_DATA_ADAPTER DDS::DynamicData_var dynamic_data = copy->get_dynamic_data(dynamic_type_); DDS::Security::SecurityException ex; if (dynamic_data && security_config_ && diff --git a/dds/DCPS/DataWriterImpl.h b/dds/DCPS/DataWriterImpl.h index 2181bfb0eb0..ba524ad91a8 100644 --- a/dds/DCPS/DataWriterImpl.h +++ b/dds/DCPS/DataWriterImpl.h @@ -23,9 +23,11 @@ #include "Time_Helper.h" #include "TopicImpl.h" #include "WriteDataContainer.h" +#include "unique_ptr.h" + #include "transport/framework/TransportClient.h" #include "transport/framework/TransportSendListener.h" -#include "unique_ptr.h" + #ifndef OPENDDS_NO_CONTENT_FILTERED_TOPIC # include "FilterEvaluator.h" #endif @@ -711,7 +713,7 @@ class OpenDDS_Dcps_Export DataWriterImpl return this->qos_.transport_priority.value; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::ParticipantCryptoHandle get_crypto_handle() const; #endif @@ -851,7 +853,7 @@ class OpenDDS_Dcps_Export DataWriterImpl bool insert_instance(DDS::InstanceHandle_t handle, Sample_rch& sample); InstanceValuesToHandles::iterator find_instance(const Sample& sample); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY protected: Security::SecurityConfig_rch security_config_; DDS::Security::PermissionsHandle participant_permissions_handle_; diff --git a/dds/DCPS/DataWriterImpl_T.h b/dds/DCPS/DataWriterImpl_T.h index 534934616c0..73d1aa7c31c 100644 --- a/dds/DCPS/DataWriterImpl_T.h +++ b/dds/DCPS/DataWriterImpl_T.h @@ -6,16 +6,18 @@ #ifndef OPENDDS_DCPS_DATAWRITERIMPL_T_H #define OPENDDS_DCPS_DATAWRITERIMPL_T_H -#include "Sample.h" -#include "PublicationInstance.h" +#include "DCPS_Utils.h" #include "DataWriterImpl.h" -#include "Util.h" +#include "PublicationInstance.h" +#include "SafetyProfileStreams.h" +#include "Sample.h" #include "TypeSupportImpl.h" +#include "Util.h" #include "dcps_export.h" -#include "SafetyProfileStreams.h" -#include "DCPS_Utils.h" -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY # include #endif diff --git a/dds/DCPS/Definitions.h b/dds/DCPS/Definitions.h index 56803c12928..ed7e5e7429f 100644 --- a/dds/DCPS/Definitions.h +++ b/dds/DCPS/Definitions.h @@ -8,14 +8,7 @@ #include -// OpenDDSConfig.h is generated by the configure script or by CMake -// If you're manually configuring OpenDDS, start by creating an empty file -// named OpenDDSConfig.h in a dds/ directory on the include path. -// See the OpenDDS Developer's Guide and dds/OpenDDSConfig.h.in for details -// regarding what can be customized. -#ifndef OPENDDS_IGNORE_OPENDDSCONFIG_H_FILE -# include -#endif +#include #include diff --git a/dds/DCPS/Discovery.h b/dds/DCPS/Discovery.h index 1947890f48e..a9b5b5cd7f7 100644 --- a/dds/DCPS/Discovery.h +++ b/dds/DCPS/Discovery.h @@ -6,21 +6,24 @@ #ifndef OPENDDS_DCPS_DISCOVERY_H #define OPENDDS_DCPS_DISCOVERY_H -#include "RcObject.h" -#include "RcHandle_T.h" -#include "unique_ptr.h" -#include "XTypes/TypeObject.h" -#include "XTypes/TypeLookupService.h" +#include "ConditionVariable.h" #include "DataReaderCallbacks.h" #include "DataWriterCallbacks.h" -#include "TopicCallbacks.h" -#include "PoolAllocator.h" #include "PoolAllocationBase.h" -#include "ConditionVariable.h" +#include "PoolAllocator.h" +#include "RcHandle_T.h" +#include "RcObject.h" +#include "TopicCallbacks.h" +#include "unique_ptr.h" + +#include "XTypes/TypeLookupService.h" +#include "XTypes/TypeObject.h" #include #include -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -108,7 +111,7 @@ class OpenDDS_Dcps_Export Discovery : public virtual RcObject { const DDS::DomainParticipantQos& qos, XTypes::TypeLookupService_rch tls) = 0; -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY virtual OpenDDS::DCPS::AddDomainStatus add_domain_participant_secure( DDS::DomainId_t domain, const DDS::DomainParticipantQos& qos, diff --git a/dds/DCPS/DomainParticipantImpl.cpp b/dds/DCPS/DomainParticipantImpl.cpp index 146029579d1..5719b5b5155 100644 --- a/dds/DCPS/DomainParticipantImpl.cpp +++ b/dds/DCPS/DomainParticipantImpl.cpp @@ -7,33 +7,38 @@ #include "DomainParticipantImpl.h" +#include "BuiltInTopicUtils.h" +#include "ContentFilteredTopicImpl.h" +#include "DCPS_Utils.h" +#include "DataWriterImpl.h" +#include "DomainParticipantFactoryImpl.h" #include "FeatureDisabledQosCheck.h" -#include "Service_Participant.h" -#include "Qos_Helper.h" #include "GuidConverter.h" -#include "PublisherImpl.h" -#include "SubscriberImpl.h" -#include "DataWriterImpl.h" #include "Marked_Default_Qos.h" -#include "Registered_Data_Types.h" -#include "Transient_Kludge.h" -#include "DomainParticipantFactoryImpl.h" -#include "Util.h" -#include "DCPS_Utils.h" #include "MonitorFactory.h" -#include "ContentFilteredTopicImpl.h" #include "MultiTopicImpl.h" -#include "Service_Participant.h" +#include "PublisherImpl.h" +#include "Qos_Helper.h" #include "RecorderImpl.h" +#include "Registered_Data_Types.h" #include "ReplayerImpl.h" -#include "BuiltInTopicUtils.h" +#include "Service_Participant.h" +#include "Service_Participant.h" +#include "SubscriberImpl.h" +#include "Transient_Kludge.h" +#include "Util.h" + #include "transport/framework/TransportRegistry.h" #include "transport/framework/TransportExceptions.h" -#ifdef OPENDDS_SECURITY + +#include + +#if OPENDDS_CONFIG_SECURITY # include "security/framework/SecurityRegistry.h" # include "security/framework/SecurityConfig.h" # include "security/framework/Properties.h" #endif + #include "XTypes/Utils.h" #include @@ -99,7 +104,7 @@ DomainParticipantImpl::DomainParticipantImpl( , default_publisher_qos_(TheServiceParticipant->initial_PublisherQos()) , default_subscriber_qos_(TheServiceParticipant->initial_SubscriberQos()) , qos_(qos) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , id_handle_(DDS::HANDLE_NIL) , perm_handle_(DDS::HANDLE_NIL) , part_crypto_handle_(DDS::HANDLE_NIL) @@ -132,7 +137,7 @@ DomainParticipantImpl::DomainParticipantImpl( DomainParticipantImpl::~DomainParticipantImpl() { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (security_config_ && perm_handle_ != DDS::HANDLE_NIL) { Security::AccessControl_var access = security_config_->get_access_control(); DDS::Security::SecurityException se; @@ -1626,7 +1631,7 @@ DomainParticipantImpl::enable() return DDS::RETCODE_OK; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!security_config_ && TheServiceParticipant->get_security()) { security_config_ = TheSecurityRegistry->default_config(); if (!security_config_) { @@ -1647,7 +1652,7 @@ DomainParticipantImpl::enable() return DDS::RETCODE_ERROR; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (TheServiceParticipant->get_security() && !security_config_) { if (DCPS::security_debug.new_entity_error) { ACE_ERROR((LM_ERROR, @@ -1660,7 +1665,7 @@ DomainParticipantImpl::enable() AddDomainStatus value = {GUID_UNKNOWN, false}; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (TheServiceParticipant->get_security() && security_config_->qos_implies_security(qos_)) { Security::Authentication_var auth = security_config_->get_authentication(); @@ -1770,7 +1775,7 @@ DomainParticipantImpl::enable() return DDS::RETCODE_ERROR; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } #endif @@ -1952,7 +1957,7 @@ DomainParticipantImpl::create_new_topic( this->topics_protector_, DDS::Topic::_nil()); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (perm_handle_ && !topicIsBIT(topic_name, type_name)) { Security::AccessControl_var access = security_config_->get_access_control(); diff --git a/dds/DCPS/DomainParticipantImpl.h b/dds/DCPS/DomainParticipantImpl.h index a0736fb3221..5d79a091ab3 100644 --- a/dds/DCPS/DomainParticipantImpl.h +++ b/dds/DCPS/DomainParticipantImpl.h @@ -6,22 +6,25 @@ #ifndef OPENDDS_DCPS_DOMAIN_PARTICIPANT_IMPL_H #define OPENDDS_DCPS_DOMAIN_PARTICIPANT_IMPL_H -#include "EntityImpl.h" +#include "ConditionVariable.h" #include "Definitions.h" #include "DisjointSequence.h" -#include "TopicImpl.h" +#include "EntityImpl.h" +#include "GuidBuilder.h" +#include "GuidUtils.h" #include "InstanceHandle.h" #include "OwnershipManager.h" -#include "GuidBuilder.h" #include "PoolAllocator.h" #include "Recorder.h" #include "Replayer.h" -#include "ConditionVariable.h" -#include "TimeTypes.h" -#include "GuidUtils.h" #include "SporadicTask.h" +#include "TimeTypes.h" +#include "TopicImpl.h" + #include "XTypes/TypeLookupService.h" + #include "transport/framework/TransportImpl_rch.h" + #include "security/framework/SecurityConfig_rch.h" #include @@ -401,7 +404,7 @@ class OpenDDS_Dcps_Export DomainParticipantImpl XTypes::TypeLookupService_rch get_type_lookup_service() { return type_lookup_service_; } -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY Security::SecurityConfig_rch get_security_config() const { return security_config_; @@ -477,7 +480,7 @@ class OpenDDS_Dcps_Export DomainParticipantImpl /// can be notified by the listener of this entity. DDS::StatusMask listener_mask_; - #if defined(OPENDDS_SECURITY) + #if OPENDDS_CONFIG_SECURITY /// This participant id handle given by authentication. DDS::Security::IdentityHandle id_handle_; /// This participant permissions handle given by access constrol. @@ -567,7 +570,7 @@ class OpenDDS_Dcps_Export DomainParticipantImpl RecorderSet recorders_; ReplayerSet replayers_; -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY Security::SecurityConfig_rch security_config_; #endif diff --git a/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.cpp b/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.cpp index 7b54433b28d..0e8f0ce0235 100644 --- a/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.cpp +++ b/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.cpp @@ -10,10 +10,11 @@ #include "DataWriterRemoteC.h" #include "DataWriterRemoteImpl.h" #include "FailoverListener.h" -#include "dds/DCPS/Service_Participant.h" -#include "dds/DCPS/RepoIdBuilder.h" -#include "dds/DCPS/DCPS_Utils.h" + #include "dds/DCPS/BuiltInTopicUtils.h" +#include "dds/DCPS/DCPS_Utils.h" +#include "dds/DCPS/RepoIdBuilder.h" +#include "dds/DCPS/Service_Participant.h" #include "dds/DCPS/transport/framework/TransportRegistry.h" #include "dds/DCPS/transport/framework/TransportType.h" @@ -23,6 +24,8 @@ #include "tao/BiDir_GIOP/BiDirGIOP.h" #include "ace/Reactor.h" +#include + #if !defined (DDS_HAS_MINIMUM_BIT) #include "dds/DCPS/DomainParticipantImpl.h" #include "dds/DCPS/BuiltInTopicUtils.h" @@ -525,7 +528,7 @@ InfoRepoDiscovery::add_domain_participant(DDS::DomainId_t domainId, return ads; } -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY DCPS::AddDomainStatus InfoRepoDiscovery::add_domain_participant_secure( DDS::DomainId_t /*domain*/, diff --git a/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.h b/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.h index f7fdfbe4502..640e533780f 100644 --- a/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.h +++ b/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.h @@ -13,12 +13,17 @@ #include "InfoC.h" #include +#include + #include #include #include +#include + #include + #include -#include + #include #include @@ -82,7 +87,7 @@ class OpenDDS_InfoRepoDiscovery_Export InfoRepoDiscovery : public Discovery { const DDS::DomainParticipantQos& qos, XTypes::TypeLookupService_rch tls); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY virtual OpenDDS::DCPS::AddDomainStatus add_domain_participant_secure( DDS::DomainId_t domain, const DDS::DomainParticipantQos& qos, diff --git a/dds/DCPS/RTPS/DiscoveredEntities.h b/dds/DCPS/RTPS/DiscoveredEntities.h index 2f929e3ad57..77183ad0922 100644 --- a/dds/DCPS/RTPS/DiscoveredEntities.h +++ b/dds/DCPS/RTPS/DiscoveredEntities.h @@ -9,15 +9,18 @@ #include "AssociationRecord.h" #include "RtpsCoreC.h" -#ifdef OPENDDS_SECURITY -# include "RtpsSecurityC.h" -#endif + #include "ICE/Ice.h" +#include #include #include #include +#if OPENDDS_CONFIG_SECURITY +# include "RtpsSecurityC.h" +#endif + #ifndef ACE_LACKS_PRAGMA_ONCE # pragma once #endif @@ -27,7 +30,7 @@ OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { namespace RTPS { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY enum AuthState { AUTH_STATE_HANDSHAKE, AUTH_STATE_AUTHENTICATED, @@ -51,7 +54,7 @@ struct DiscoveredParticipant { : location_ih_(DDS::HANDLE_NIL) , bit_ih_(DDS::HANDLE_NIL) , seq_reset_count_(0) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , have_spdp_info_(false) , have_sedp_info_(false) , have_auth_req_msg_(false) @@ -69,7 +72,7 @@ struct DiscoveredParticipant { , participant_tokens_sent_(false) #endif { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY pdata_.dataKind = Security::DPDK_NONE; security_info_.participant_security_attributes = 0; security_info_.plugin_participant_security_attributes = 0; @@ -84,7 +87,7 @@ struct DiscoveredParticipant { , bit_ih_(DDS::HANDLE_NIL) , max_seq_(seq) , seq_reset_count_(0) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , have_spdp_info_(false) , have_sedp_info_(false) , have_auth_req_msg_(false) @@ -121,7 +124,7 @@ struct DiscoveredParticipant { location_data_.lease_duration.sec = 0; location_data_.lease_duration.nanosec = 0; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY security_info_.participant_security_attributes = 0; security_info_.plugin_participant_security_attributes = 0; #else @@ -161,7 +164,7 @@ struct DiscoveredParticipant { typedef OPENDDS_LIST(ReaderAssociationRecord_rch) ReaderAssociationRecords; ReaderAssociationRecords reader_pending_records_; ReaderAssociationRecords reader_associated_records_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool have_spdp_info_; ICE::AgentInfo spdp_info_; bool have_sedp_info_; @@ -208,11 +211,11 @@ struct DiscoveredSubscription : DCPS::PoolAllocationBase { : bit_ih_(DDS::HANDLE_NIL) , participant_discovered_at_(DCPS::monotonic_time_zero()) , transport_context_(0) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , have_ice_agent_info_(false) #endif { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY security_attribs_.base = DDS::Security::TopicSecurityAttributes(); security_attribs_.is_key_protected = 0; security_attribs_.is_payload_protected = 0; @@ -226,12 +229,12 @@ struct DiscoveredSubscription : DCPS::PoolAllocationBase { , bit_ih_(DDS::HANDLE_NIL) , participant_discovered_at_(DCPS::monotonic_time_zero()) , transport_context_(0) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , security_attribs_(DDS::Security::EndpointSecurityAttributes()) , have_ice_agent_info_(false) #endif { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY security_attribs_.base = DDS::Security::TopicSecurityAttributes(); security_attribs_.is_key_protected = 0; security_attribs_.is_payload_protected = 0; @@ -247,7 +250,7 @@ struct DiscoveredSubscription : DCPS::PoolAllocationBase { ACE_CDR::ULong transport_context_; XTypes::TypeInformation type_info_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::EndpointSecurityAttributes security_attribs_; bool have_ice_agent_info_; ICE::AgentInfo ice_agent_info_; @@ -269,11 +272,11 @@ struct DiscoveredPublication : DCPS::PoolAllocationBase { : bit_ih_(DDS::HANDLE_NIL) , participant_discovered_at_(DCPS::monotonic_time_zero()) , transport_context_(0) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , have_ice_agent_info_(false) #endif { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY security_attribs_.base = DDS::Security::TopicSecurityAttributes(); security_attribs_.is_key_protected = 0; security_attribs_.is_payload_protected = 0; @@ -287,11 +290,11 @@ struct DiscoveredPublication : DCPS::PoolAllocationBase { , bit_ih_(DDS::HANDLE_NIL) , participant_discovered_at_(DCPS::monotonic_time_zero()) , transport_context_(0) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , have_ice_agent_info_(false) #endif { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY security_attribs_.base = DDS::Security::TopicSecurityAttributes(); security_attribs_.is_key_protected = 0; security_attribs_.is_payload_protected = 0; @@ -307,7 +310,7 @@ struct DiscoveredPublication : DCPS::PoolAllocationBase { ACE_CDR::ULong transport_context_; XTypes::TypeInformation type_info_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::EndpointSecurityAttributes security_attribs_; bool have_ice_agent_info_; ICE::AgentInfo ice_agent_info_; diff --git a/dds/DCPS/RTPS/ICE/AgentImpl.cpp b/dds/DCPS/RTPS/ICE/AgentImpl.cpp index be7d3b9985d..b82cf64054e 100644 --- a/dds/DCPS/RTPS/ICE/AgentImpl.cpp +++ b/dds/DCPS/RTPS/ICE/AgentImpl.cpp @@ -14,12 +14,14 @@ #include #include +#include + OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { namespace ICE { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY using DCPS::TimeDuration; using DCPS::MonotonicTimePoint; @@ -305,7 +307,7 @@ void AgentImpl::process_deferred() } } -#endif /* OPENDDS_SECURITY */ +#endif } // namespace ICE } // namespace OpenDDS diff --git a/dds/DCPS/RTPS/ICE/AgentImpl.h b/dds/DCPS/RTPS/ICE/AgentImpl.h index 9779402c4e3..71e2077d8f3 100644 --- a/dds/DCPS/RTPS/ICE/AgentImpl.h +++ b/dds/DCPS/RTPS/ICE/AgentImpl.h @@ -5,7 +5,9 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY +#include "dds/OpenDDSConfigWrapper.h" + +#if OPENDDS_CONFIG_SECURITY #ifndef OPENDDS_DCPS_RTPS_ICE_AGENTIMPL_H #define OPENDDS_DCPS_RTPS_ICE_AGENTIMPL_H @@ -21,6 +23,7 @@ #include "dds/DCPS/InternalDataReader.h" #include "dds/DCPS/ReactorInterceptor.h" #include "dds/DCPS/Service_Participant.h" + #include "dds/Versioned_Namespace.h" #include @@ -160,4 +163,4 @@ class AgentImpl OPENDDS_END_VERSIONED_NAMESPACE_DECL #endif /* OPENDDS_RTPS_ICE_AGENT_IMPL_H */ -#endif /* OPENDDS_SECURITY */ +#endif diff --git a/dds/DCPS/RTPS/ICE/Checklist.cpp b/dds/DCPS/RTPS/ICE/Checklist.cpp index 16e8657a498..9bf1c1cce3f 100644 --- a/dds/DCPS/RTPS/ICE/Checklist.cpp +++ b/dds/DCPS/RTPS/ICE/Checklist.cpp @@ -5,7 +5,9 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "Checklist.h" @@ -814,4 +816,4 @@ void Checklist::indication() } // namespace OpenDDS OPENDDS_END_VERSIONED_NAMESPACE_DECL -#endif /* OPENDDS_SECURITY */ +#endif diff --git a/dds/DCPS/RTPS/ICE/Checklist.h b/dds/DCPS/RTPS/ICE/Checklist.h index 9bf718d6853..250e8b49109 100644 --- a/dds/DCPS/RTPS/ICE/Checklist.h +++ b/dds/DCPS/RTPS/ICE/Checklist.h @@ -5,7 +5,9 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #ifndef OPENDDS_DCPS_RTPS_ICE_CHECKLIST_H #define OPENDDS_DCPS_RTPS_ICE_CHECKLIST_H @@ -293,4 +295,4 @@ typedef DCPS::RcHandle ChecklistPtr; OPENDDS_END_VERSIONED_NAMESPACE_DECL #endif /* OPENDDS_RTPS_ICE_CHECKLIST_H */ -#endif /* OPENDDS_SECURITY */ +#endif diff --git a/dds/DCPS/RTPS/ICE/EndpointManager.cpp b/dds/DCPS/RTPS/ICE/EndpointManager.cpp index 4273ecb4155..a12f87aff10 100644 --- a/dds/DCPS/RTPS/ICE/EndpointManager.cpp +++ b/dds/DCPS/RTPS/ICE/EndpointManager.cpp @@ -11,9 +11,12 @@ #include "Checklist.h" #include "dds/DCPS/SafetyProfileStreams.h" + #include "dds/DCPS/security/framework/SecurityConfig.h" #include "dds/DCPS/security/framework/SecurityRegistry.h" +#include + #include OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL @@ -21,7 +24,7 @@ OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { namespace ICE { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY using DCPS::MonotonicTimePoint; @@ -845,7 +848,7 @@ void EndpointManager::purge() } } -#endif /* OPENDDS_SECURITY */ +#endif } // namespace ICE } // namespace OpenDDS diff --git a/dds/DCPS/RTPS/ICE/EndpointManager.h b/dds/DCPS/RTPS/ICE/EndpointManager.h index 1518c6f992a..bad2cbd58f4 100644 --- a/dds/DCPS/RTPS/ICE/EndpointManager.h +++ b/dds/DCPS/RTPS/ICE/EndpointManager.h @@ -5,7 +5,8 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY + +#if OPENDDS_CONFIG_SECURITY #ifndef OPENDDS_DCPS_RTPS_ICE_ENDPOINTMANAGER_H #define OPENDDS_DCPS_RTPS_ICE_ENDPOINTMANAGER_H @@ -14,7 +15,10 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "dds/DCPS/Definitions.h" + +#include #include "dds/Versioned_Namespace.h" + #include #include "Ice.h" @@ -265,4 +269,4 @@ typedef DCPS::RcHandle EndpointManagerPtr; OPENDDS_END_VERSIONED_NAMESPACE_DECL #endif /* OPENDDS_RTPS_ICE_ENDPOINT_MANAGER_H */ -#endif /* OPENDDS_SECURITY */ +#endif diff --git a/dds/DCPS/RTPS/ICE/Ice.cpp b/dds/DCPS/RTPS/ICE/Ice.cpp index 8927d5fa6fb..7d97e7972fb 100644 --- a/dds/DCPS/RTPS/ICE/Ice.cpp +++ b/dds/DCPS/RTPS/ICE/Ice.cpp @@ -4,11 +4,15 @@ * Distributed under the OpenDDS License. * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY + +#include + +#if OPENDDS_CONFIG_SECURITY #include "Ice.h" #include "AgentImpl.h" + #include "dds/DCPS/SafetyProfileStreams.h" #include "dds/DCPS/debug.h" #include @@ -468,4 +472,4 @@ ServerReflexiveStateMachine::error_response(const STUN::Message& message) OPENDDS_END_VERSIONED_NAMESPACE_DECL -#endif /* OPENDDS_SECURITY */ +#endif diff --git a/dds/DCPS/RTPS/ICE/Ice.h b/dds/DCPS/RTPS/ICE/Ice.h index d4f66108d16..440e591df35 100644 --- a/dds/DCPS/RTPS/ICE/Ice.h +++ b/dds/DCPS/RTPS/ICE/Ice.h @@ -3,7 +3,9 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #ifndef OPENDDS_DCPS_RTPS_ICE_ICE_H #define OPENDDS_DCPS_RTPS_ICE_ICE_H @@ -210,4 +212,4 @@ class OpenDDS_Rtps_Export ServerReflexiveStateMachine { OPENDDS_END_VERSIONED_NAMESPACE_DECL #endif /* OPENDDS_RTPS_ICE_H */ -#endif /* OPENDDS_SECURITY */ +#endif diff --git a/dds/DCPS/RTPS/ICE/Stun.cpp b/dds/DCPS/RTPS/ICE/Stun.cpp index 810a938f3bf..9578078c5fd 100644 --- a/dds/DCPS/RTPS/ICE/Stun.cpp +++ b/dds/DCPS/RTPS/ICE/Stun.cpp @@ -5,7 +5,9 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "Stun.h" @@ -983,4 +985,4 @@ bool operator<<(DCPS::Serializer& serializer, const Message& message) } // namespace OpenDDS OPENDDS_END_VERSIONED_NAMESPACE_DECL -#endif /* OPENDDS_SECURITY */ +#endif diff --git a/dds/DCPS/RTPS/ICE/Stun.h b/dds/DCPS/RTPS/ICE/Stun.h index 0c550ab2572..db9ee2102e8 100644 --- a/dds/DCPS/RTPS/ICE/Stun.h +++ b/dds/DCPS/RTPS/ICE/Stun.h @@ -5,7 +5,9 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #ifndef OPENDDS_DCPS_RTPS_ICE_STUN_H #define OPENDDS_DCPS_RTPS_ICE_STUN_H @@ -279,4 +281,4 @@ const DCPS::Encoding encoding(DCPS::Encoding::KIND_UNALIGNED_CDR, DCPS::ENDIAN_B OPENDDS_END_VERSIONED_NAMESPACE_DECL #endif /* OPENDDS_RTPS_STUN_H */ -#endif /* OPENDDS_SECURITY */ +#endif diff --git a/dds/DCPS/RTPS/ICE/Task.cpp b/dds/DCPS/RTPS/ICE/Task.cpp index b4358f1016c..962aedf3590 100644 --- a/dds/DCPS/RTPS/ICE/Task.cpp +++ b/dds/DCPS/RTPS/ICE/Task.cpp @@ -9,19 +9,21 @@ #include "AgentImpl.h" +#include + OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { namespace ICE { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Task::enqueue(const DCPS::MonotonicTimePoint& a_release_time) { agent_impl_->enqueue(a_release_time, rchandle_from(this)); } -#endif /* OPENDDS_SECURITY */ +#endif } // namespace ICE } // namespace OpenDDS diff --git a/dds/DCPS/RTPS/LocalEntities.h b/dds/DCPS/RTPS/LocalEntities.h index c4912dbdb64..30fa6a2df7d 100644 --- a/dds/DCPS/RTPS/LocalEntities.h +++ b/dds/DCPS/RTPS/LocalEntities.h @@ -5,6 +5,7 @@ #ifndef OPENDDS_DCPS_RTPS_LOCAL_ENTITIES_H #define OPENDDS_DCPS_RTPS_LOCAL_ENTITIES_H +#include #include #include @@ -12,11 +13,13 @@ #include #include #include + #include + #include #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include # include #endif @@ -36,7 +39,7 @@ struct LocalEntity { , participant_discovered_at_(DCPS::monotonic_time_zero()) , transport_context_(0) , sequence_(DCPS::SequenceNumber::SEQUENCENUMBER_UNKNOWN()) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , have_ice_agent_info(false) { security_attribs_.base.is_read_protected = false; @@ -61,7 +64,7 @@ struct LocalEntity { DCPS::SequenceNumber sequence_; DCPS::RepoIdSet remote_expectant_opendds_associations_; XTypes::TypeInformation type_info_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool have_ice_agent_info; ICE::AgentInfo ice_agent_info; DDS::Security::EndpointSecurityAttributes security_attribs_; diff --git a/dds/DCPS/RTPS/MessageTypes.h b/dds/DCPS/RTPS/MessageTypes.h index 361e8727fc6..eb0f175dfed 100644 --- a/dds/DCPS/RTPS/MessageTypes.h +++ b/dds/DCPS/RTPS/MessageTypes.h @@ -12,6 +12,8 @@ #include +#include + OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { @@ -67,7 +69,7 @@ namespace OpenDDS { const ProtocolVersion_t PROTOCOLVERSION = PROTOCOLVERSION_2_4; using OpenDDS::DCPS::EntityId_t; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY /** * The below entities are from the security spec. V1.1 diff --git a/dds/DCPS/RTPS/MessageUtils.h b/dds/DCPS/RTPS/MessageUtils.h index c3e79ab4aff..d11b0cff907 100644 --- a/dds/DCPS/RTPS/MessageUtils.h +++ b/dds/DCPS/RTPS/MessageUtils.h @@ -11,17 +11,18 @@ #include "RtpsCoreTypeSupportImpl.h" #include "rtps_export.h" +#include #include -#include #include -#include -#include #include +#include #include -#include +#include +#include #include #include +#include #include #include @@ -172,7 +173,7 @@ inline void append_submessage(RTPS::Message& message, const RTPS::DataFragSubmes DCPS::push_back(message.submessages, sm); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY inline DDS::Security::ParticipantSecurityAttributesMask security_attributes_to_bitmask(const DDS::Security::ParticipantSecurityAttributes& sec_attr) { diff --git a/dds/DCPS/RTPS/ParameterListConverter.cpp b/dds/DCPS/RTPS/ParameterListConverter.cpp index f3d1e9ab4e0..5dec08e2a44 100644 --- a/dds/DCPS/RTPS/ParameterListConverter.cpp +++ b/dds/DCPS/RTPS/ParameterListConverter.cpp @@ -9,12 +9,14 @@ #include "MessageUtils.h" +#include #include #include +#include #include -#include #include -#include + +#include #include @@ -272,7 +274,7 @@ namespace { } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY OpenDDS::Security::DiscoveredParticipantDataKind find_data_kind(const ParameterList& param_list) { enum FieldMaskNames { @@ -363,7 +365,7 @@ bool from_param_list(const ParameterList& param_list, return true; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool to_param_list(const DDS::Security::ParticipantBuiltinTopicData& pbtd, ParameterList& param_list) { @@ -513,7 +515,7 @@ bool to_param_list(const ParticipantProxy_t& proxy, proxy.availableBuiltinEndpoints); DCPS::push_back(param_list, be_param); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Parameter ebe_param; ebe_param.extended_builtin_endpoints( proxy.availableExtendedBuiltinEndpoints); @@ -571,7 +573,7 @@ bool from_param_list(const ParameterList& param_list, { // Start by setting defaults proxy.availableBuiltinEndpoints = 0; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY proxy.availableExtendedBuiltinEndpoints = 0; #endif proxy.expectsInlineQos = false; @@ -615,7 +617,7 @@ bool from_param_list(const ParameterList& param_list, proxy.availableBuiltinEndpoints = param.builtin_endpoints(); break; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY case DDS::Security::PID_EXTENDED_BUILTIN_ENDPOINTS: proxy.availableExtendedBuiltinEndpoints = param.extended_builtin_endpoints(); @@ -734,7 +736,7 @@ bool from_param_list(const ParameterList& param_list, return result; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool to_param_list(const OpenDDS::Security::SPDPdiscoveredParticipantData& participant_data, ParameterList& param_list) { @@ -1473,7 +1475,7 @@ bool from_param_list(const ParameterList& param_list, return true; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool to_param_list(const DDS::Security::EndpointSecurityInfo& info, ParameterList& param_list) { diff --git a/dds/DCPS/RTPS/ParameterListConverter.h b/dds/DCPS/RTPS/ParameterListConverter.h index 287ae04d782..3bf758624e3 100644 --- a/dds/DCPS/RTPS/ParameterListConverter.h +++ b/dds/DCPS/RTPS/ParameterListConverter.h @@ -10,7 +10,9 @@ #include "rtps_export.h" #include "RtpsCoreC.h" -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "RtpsSecurityC.h" #endif @@ -25,7 +27,7 @@ namespace OpenDDS { namespace RTPS { namespace ParameterListConverter { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY struct DiscoveredPublication_SecurityWrapper { DCPS::DiscoveredWriterData data; DDS::Security::EndpointSecurityInfo security_info; @@ -73,7 +75,7 @@ OpenDDS_Rtps_Export bool from_param_list(const ParameterList& param_list, DDS::ParticipantBuiltinTopicData& pbtd); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // DDS::Security::ParticipantBuiltinTopicData OpenDDS_Rtps_Export @@ -125,7 +127,7 @@ OpenDDS_Rtps_Export bool from_param_list(const ParameterList& param_list, SPDPdiscoveredParticipantData& participant_data); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // OpenDDS::Security::SPDPdiscoveredParticipantData OpenDDS_Rtps_Export @@ -170,7 +172,7 @@ bool from_param_list(const ParameterList& param_list, bool use_xtypes, XTypes::TypeInformation& type_info); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // DDS::Security::EndpointSecurityInfo OpenDDS_Rtps_Export diff --git a/dds/DCPS/RTPS/RtpsCore.idl b/dds/DCPS/RTPS/RtpsCore.idl index 6df0b293d05..2f939b42738 100644 --- a/dds/DCPS/RTPS/RtpsCore.idl +++ b/dds/DCPS/RTPS/RtpsCore.idl @@ -11,8 +11,9 @@ #include "dds/OpenddsDcpsExt.idl" #include "dds/DdsDcpsInfoUtils.idl" #include "dds/DdsDcpsInfrastructure.idl" +#include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY #include "dds/DdsSecurityParams.idl" #endif @@ -469,7 +470,7 @@ module OpenDDS { case PID_OPENDDS_LOCATOR: DCPS::TransportLocator opendds_locator; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY case DDS::Security::PID_IDENTITY_TOKEN: DDS::Security::IdentityToken identity_token; @@ -618,7 +619,7 @@ module OpenDDS { DDS::PropertyQosPolicy property; OpenDDSParticipantFlags_t opendds_participant_flags; boolean opendds_rtps_relay_application_participant; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::ExtendedBuiltinEndpointSet_t availableExtendedBuiltinEndpoints; #endif }; diff --git a/dds/DCPS/RTPS/RtpsDiscovery.cpp b/dds/DCPS/RTPS/RtpsDiscovery.cpp index 0d6e4c1b462..ac24afd932a 100644 --- a/dds/DCPS/RTPS/RtpsDiscovery.cpp +++ b/dds/DCPS/RTPS/RtpsDiscovery.cpp @@ -7,18 +7,19 @@ #include "RtpsDiscoveryConfig.h" -#include -#include +#include #include -#include +#include #include -#include #include +#include +#include #include #include #include +#include #include #include @@ -55,7 +56,7 @@ RtpsDiscovery::Config::discovery_config() RtpsDiscovery_rch discovery = OpenDDS::DCPS::make_rch(rtps_name); RtpsDiscoveryConfig_rch config = discovery->config(); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY if (config_store->has(config->config_key("IceTa").c_str())) { if (log_level >= DCPS::LogLevel::Warning) { ACE_ERROR((LM_WARNING, @@ -128,7 +129,7 @@ RtpsDiscovery::Config::discovery_config() } config_store->set("IceChangePasswordPeriod", config_store->get(config->config_key("IceChangePasswordPeriod").c_str(), "")); } -#endif /* OPENDDS_SECURITY */ +#endif TheServiceParticipant->add_discovery(discovery); } @@ -196,7 +197,7 @@ RtpsDiscovery::add_domain_participant(DDS::DomainId_t domain, return ads; } -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY DCPS::AddDomainStatus RtpsDiscovery::add_domain_participant_secure( DDS::DomainId_t domain, @@ -246,7 +247,7 @@ RtpsDiscovery::use_rtps_relay_now(bool after) config->use_rtps_relay(after); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void RtpsDiscovery::use_ice_now(bool after) { diff --git a/dds/DCPS/RTPS/RtpsDiscovery.h b/dds/DCPS/RTPS/RtpsDiscovery.h index 8acf1b19fca..55567ef4e3d 100644 --- a/dds/DCPS/RTPS/RtpsDiscovery.h +++ b/dds/DCPS/RTPS/RtpsDiscovery.h @@ -11,9 +11,11 @@ #include "Spdp.h" #include "rtps_export.h" +#include #include #include -#include + +#include #include @@ -66,7 +68,7 @@ class OpenDDS_Rtps_Export RtpsDiscovery : public DCPS::Discovery { const DDS::DomainParticipantQos& qos, XTypes::TypeLookupService_rch tls); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY # if defined __GNUC__ && ((__GNUC__ == 5 && __GNUC_MINOR__ < 3) || __GNUC__ < 5) && ! defined __clang__ # define OPENDDS_GCC_PRE53_DISABLE_OPTIMIZATION __attribute__((optimize("-O0"))) # else @@ -158,7 +160,7 @@ class OpenDDS_Rtps_Export RtpsDiscovery : public DCPS::Discovery { bool use_rtps_relay() const { return config_->use_rtps_relay(); } void use_rtps_relay_now(bool f); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool use_ice() const { return config_->use_ice(); } void use_ice_now(bool f); #endif @@ -178,7 +180,7 @@ class OpenDDS_Rtps_Export RtpsDiscovery : public DCPS::Discovery { RtpsDiscoveryConfig_rch config() const { return config_; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::ParticipantCryptoHandle get_crypto_handle(DDS::DomainId_t domain, const DCPS::GUID_t& local_participant, const DCPS::GUID_t& remote_participant = GUID_UNKNOWN) const; diff --git a/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp b/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp index 48234ab0f40..f809d25e9cf 100644 --- a/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp +++ b/dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp @@ -7,6 +7,8 @@ #include +#include + OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { @@ -103,7 +105,7 @@ RtpsDiscoveryConfig::max_lease_duration(const DCPS::TimeDuration& period) DCPS::ConfigStoreImpl::Format_IntegerSeconds); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::TimeDuration RtpsDiscoveryConfig::security_unsecure_lease_duration() const { @@ -840,7 +842,7 @@ RtpsDiscoveryConfig::sedp_stun_server_address(const DCPS::NetworkAddress& addres DCPS::ConfigStoreImpl::Kind_IPV4); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool RtpsDiscoveryConfig::use_ice() const { diff --git a/dds/DCPS/RTPS/RtpsDiscoveryConfig.h b/dds/DCPS/RTPS/RtpsDiscoveryConfig.h index 6708d0cf334..08b0427310c 100644 --- a/dds/DCPS/RTPS/RtpsDiscoveryConfig.h +++ b/dds/DCPS/RTPS/RtpsDiscoveryConfig.h @@ -8,8 +8,10 @@ #include "Spdp.h" -#include #include +#include + +#include OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL @@ -48,7 +50,7 @@ class OpenDDS_Rtps_Export RtpsDiscoveryConfig : public OpenDDS::DCPS::RcObject { DCPS::TimeDuration max_lease_duration() const; void max_lease_duration(const DCPS::TimeDuration& period); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::TimeDuration security_unsecure_lease_duration() const; void security_unsecure_lease_duration(const DCPS::TimeDuration& period); @@ -189,7 +191,7 @@ class OpenDDS_Rtps_Export RtpsDiscoveryConfig : public OpenDDS::DCPS::RcObject { DCPS::NetworkAddress sedp_stun_server_address() const; void sedp_stun_server_address(const DCPS::NetworkAddress& address); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool use_ice() const; void use_ice(bool ui); #endif diff --git a/dds/DCPS/RTPS/RtpsSecurity.idl b/dds/DCPS/RTPS/RtpsSecurity.idl index 50c3c7d12fd..c65e56f783d 100644 --- a/dds/DCPS/RTPS/RtpsSecurity.idl +++ b/dds/DCPS/RTPS/RtpsSecurity.idl @@ -5,7 +5,9 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #ifndef OPENDDS_DCPS_RTPS_RTPS_SECURITY_IDL #define OPENDDS_DCPS_RTPS_RTPS_SECURITY_IDL diff --git a/dds/DCPS/RTPS/Sedp.cpp b/dds/DCPS/RTPS/Sedp.cpp index 1f64bcbac4c..3be6eb9db5e 100644 --- a/dds/DCPS/RTPS/Sedp.cpp +++ b/dds/DCPS/RTPS/Sedp.cpp @@ -10,36 +10,38 @@ #include "RtpsDiscovery.h" #include "Spdp.h" -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include #include #include -#include +#include +#include +#include #include -#include + #include #include #include + #include #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include #endif #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -241,7 +243,7 @@ bool checkAndAssignLocators(OpenDDS::DCPS::ReaderProxy_t& x, return false; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool is_stateless(const OpenDDS::DCPS::GUID_t& guid) { return guid.entityId == OpenDDS::RTPS::ENTITYID_P2P_BUILTIN_PARTICIPANT_STATELESS_WRITER || @@ -288,7 +290,7 @@ RtpsDiscoveryCore::RtpsDiscoveryCore(RcHandle config, , spdp_rtps_relay_send_period_(config->spdp_rtps_relay_send_period()) , rtps_relay_only_(config->rtps_relay_only()) , use_rtps_relay_(config->use_rtps_relay()) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , use_ice_(config->use_ice()) #endif , spdp_rtps_relay_address_(config->spdp_rtps_relay_address()) @@ -313,7 +315,7 @@ Sedp::Sedp(const GUID_t& participant_id, Spdp& owner, ACE_Thread_Mutex& lock) , use_xtypes_complete_(false) , local_participant_automatic_liveliness_sn_(DCPS::SequenceNumber::SEQUENCENUMBER_UNKNOWN()) , local_participant_manual_liveliness_sn_(DCPS::SequenceNumber::SEQUENCENUMBER_UNKNOWN()) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , local_participant_automatic_liveliness_sn_secure_(DCPS::SequenceNumber::SEQUENCENUMBER_UNKNOWN()) , local_participant_manual_liveliness_sn_secure_(DCPS::SequenceNumber::SEQUENCENUMBER_UNKNOWN()) , permissions_handle_(DDS::HANDLE_NIL) @@ -321,19 +323,19 @@ Sedp::Sedp(const GUID_t& participant_id, Spdp& owner, ACE_Thread_Mutex& lock) #endif , publications_writer_(make_rch( make_id(participant_id, ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER), ref(*this))) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , publications_secure_writer_(make_rch( make_id(participant_id, ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_WRITER), ref(*this))) #endif , subscriptions_writer_(make_rch( make_id(participant_id, ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER), ref(*this))) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , subscriptions_secure_writer_(make_rch( make_id(participant_id, ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_WRITER), ref(*this))) #endif , participant_message_writer_(make_rch( make_id(participant_id, ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER), ref(*this))) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , participant_message_secure_writer_(make_rch( make_id(participant_id, ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_SECURE_WRITER), ref(*this))) , participant_stateless_message_writer_(make_rch( @@ -347,7 +349,7 @@ Sedp::Sedp(const GUID_t& participant_id, Spdp& owner, ACE_Thread_Mutex& lock) make_id(participant_id, ENTITYID_TL_SVC_REQ_WRITER), ref(*this))) , type_lookup_reply_writer_(make_rch( make_id(participant_id, ENTITYID_TL_SVC_REPLY_WRITER), ref(*this))) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , type_lookup_request_secure_writer_(make_rch( make_id(participant_id, ENTITYID_TL_SVC_REQ_WRITER_SECURE), ref(*this))) , type_lookup_reply_secure_writer_(make_rch( @@ -355,19 +357,19 @@ Sedp::Sedp(const GUID_t& participant_id, Spdp& owner, ACE_Thread_Mutex& lock) #endif , publications_reader_(make_rch( make_id(participant_id, ENTITYID_SEDP_BUILTIN_PUBLICATIONS_READER), ref(*this))) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , publications_secure_reader_(make_rch( make_id(participant_id, ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_READER), ref(*this))) #endif , subscriptions_reader_(make_rch( make_id(participant_id, ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_READER), ref(*this))) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , subscriptions_secure_reader_(make_rch( make_id(participant_id, ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_READER), ref(*this))) #endif , participant_message_reader_(make_rch( make_id(participant_id, ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_READER), ref(*this))) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , participant_message_secure_reader_(make_rch( make_id(participant_id, ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_SECURE_READER), ref(*this))) , participant_stateless_message_reader_(make_rch( @@ -381,7 +383,7 @@ Sedp::Sedp(const GUID_t& participant_id, Spdp& owner, ACE_Thread_Mutex& lock) make_id(participant_id, ENTITYID_TL_SVC_REQ_READER), ref(*this))) , type_lookup_reply_reader_(make_rch( make_id(participant_id, ENTITYID_TL_SVC_REPLY_READER), ref(*this))) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , type_lookup_request_secure_reader_(make_rch( make_id(participant_id, ENTITYID_TL_SVC_REQ_READER_SECURE), ref(*this))) , type_lookup_reply_secure_reader_(make_rch( @@ -389,7 +391,7 @@ Sedp::Sedp(const GUID_t& participant_id, Spdp& owner, ACE_Thread_Mutex& lock) , ice_agent_(ICE::Agent::instance()) , publication_agent_info_listener_(DCPS::make_rch(ref(*this))) , subscription_agent_info_listener_(DCPS::make_rch(ref(*this))) -#endif // OPENDDS_SECURITY +#endif , core_(owner.config(), DCPS::TransportRegistry::DEFAULT_INST_PREFIX + OPENDDS_STRING("_SPDPTransportInst_") + @@ -494,7 +496,7 @@ Sedp::init(const GUID_t& guid, disco.config()->sedp_stun_server_address(), ConfigStoreImpl::Format_Required_Port, ConfigStoreImpl::Kind_IPV4); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY config_store_->set_boolean(transport_inst_->config_key("USE_ICE").c_str(), disco.config()->use_ice()); #endif @@ -535,12 +537,12 @@ Sedp::init(const GUID_t& guid, const bool durable = true; const bool nondurable = false; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const bool besteffort = false; #endif const BuiltinEndpointSet_t bep = spdp_.available_builtin_endpoints(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const DDS::Security::ExtendedBuiltinEndpointSet_t xbep = spdp_.available_extended_builtin_endpoints(); #endif @@ -550,7 +552,7 @@ Sedp::init(const GUID_t& guid, } publications_reader_->enable_transport_using_config(reliable, durable, transport_cfg_, 0); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY publications_secure_writer_->set_crypto_handles(spdp_.crypto_handle()); publications_secure_reader_->set_crypto_handles(spdp_.crypto_handle()); if (bep & DDS::Security::SEDP_BUILTIN_PUBLICATIONS_SECURE_WRITER) { @@ -564,7 +566,7 @@ Sedp::init(const GUID_t& guid, } subscriptions_reader_->enable_transport_using_config(reliable, durable, transport_cfg_, 0); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY subscriptions_secure_writer_->set_crypto_handles(spdp_.crypto_handle()); subscriptions_secure_reader_->set_crypto_handles(spdp_.crypto_handle()); if (bep & DDS::Security::SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_WRITER) { @@ -578,7 +580,7 @@ Sedp::init(const GUID_t& guid, } participant_message_reader_->enable_transport_using_config(reliable, durable, transport_cfg_, 0); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY participant_message_secure_writer_->set_crypto_handles(spdp_.crypto_handle()); participant_message_secure_reader_->set_crypto_handles(spdp_.crypto_handle()); if (bep & DDS::Security::BUILTIN_PARTICIPANT_MESSAGE_SECURE_WRITER) { @@ -614,7 +616,7 @@ Sedp::init(const GUID_t& guid, type_lookup_reply_reader_->enable_transport_using_config(reliable, nondurable, transport_cfg_, 0); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (xbep & DDS::Security::TYPE_LOOKUP_SERVICE_REQUEST_WRITER_SECURE) { type_lookup_request_secure_writer_->set_crypto_handles(spdp_.crypto_handle()); type_lookup_request_secure_writer_->enable_transport_using_config(reliable, nondurable, transport_cfg_, 0); @@ -639,7 +641,7 @@ Sedp::init(const GUID_t& guid, return DDS::RETCODE_OK; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t Sedp::init_security(DDS::Security::IdentityHandle /* id_handle */, DDS::Security::PermissionsHandle perm_handle, DDS::Security::ParticipantCryptoHandle crypto_handle) @@ -1043,7 +1045,7 @@ create_association_data_proto(DCPS::AssociationData& proto, populate_locators(proto.remote_data_, pdata); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Sedp::generate_remote_matched_crypto_handle(const BuiltinAssociationRecord& record) { if (DCPS::GuidConverter(record.remote_id()).isWriter()) { @@ -1059,13 +1061,13 @@ bool Sedp::ready(const DiscoveredParticipant& participant, const GUID_t& remote_id, bool local_tokens_sent) const { -#ifndef OPENDDS_SECURITY +#if !OPENDDS_CONFIG_SECURITY ACE_UNUSED_ARG(participant); ACE_UNUSED_ARG(local_tokens_sent); #endif return remote_knows_about_local_i(local_id, remote_id) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY && remote_is_authenticated_i(local_id, remote_id, participant) && local_has_remote_participant_token_i(local_id, remote_id) && remote_has_local_participant_token_i(local_id, remote_id, participant) @@ -1077,7 +1079,7 @@ bool Sedp::ready(const DiscoveredParticipant& participant, void Sedp::associate(DiscoveredParticipant& participant -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , const DDS::Security::ParticipantSecurityAttributes& participant_sec_attr #endif ) @@ -1162,7 +1164,7 @@ Sedp::associate(DiscoveredParticipant& participant //FUTURE: if/when topic propagation is supported, add it here -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (spdp_.is_security_enabled()) { using namespace DDS::Security; @@ -1365,7 +1367,7 @@ void Sedp::process_association_records_i(DiscoveredParticipant& participant) } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Sedp::generate_remote_matched_crypto_handles(DiscoveredParticipant& participant) { for (DiscoveredParticipant::BuiltinAssociationRecords::iterator pos = participant.builtin_pending_records_.begin(), @@ -1439,9 +1441,9 @@ void Sedp::associate_volatile(DiscoveredParticipant& participant) participant.builtin_pending_records_.push_back(record); } } -#endif // OPENDDS_SECURITY +#endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void disassociate_helper_extended(DDS::Security::ExtendedBuiltinEndpointSet_t& extended_associated_endpoints, const CORBA::ULong flags, const DCPS::GUID_t& id, const EntityId_t& ent, @@ -1607,7 +1609,7 @@ Sedp::disassociate(DiscoveredParticipant& participant) //FUTURE: if/when topic propagation is supported, add it here -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Clean up crypto handles after diassociation because the transport might be using them. if (spdp_.is_security_enabled()) { static const EntityId_t secure_entities[] = { @@ -1677,7 +1679,7 @@ Sedp::replay_durable_data_for(const DCPS::GUID_t& remote_sub_id) write_durable_subscription_data(remote_sub_id, false); } else if (remote_sub_id.entityId == ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_READER) { write_durable_participant_message_data(remote_sub_id); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } else if (remote_sub_id.entityId == ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_READER) { write_durable_publication_data(remote_sub_id, true); } else if (remote_sub_id.entityId == ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_READER) { @@ -1754,7 +1756,7 @@ Sedp::update_locators(const ParticipantData_t& pdata) transport_inst_->update_locators(remote_id, remote_data, get_domain_id(), 0); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (avail & DDS::Security::SEDP_BUILTIN_PUBLICATIONS_SECURE_WRITER) { remote_id.entityId = ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_WRITER; transport_inst_->update_locators(remote_id, remote_data, get_domain_id(), 0); @@ -1913,7 +1915,7 @@ Sedp::update_topic_qos(const GUID_t& topicId, const DDS::TopicQos& qos) DDS::ReturnCode_t Sedp::remove_publication_i(const GUID_t& publicationId, LocalPublication& pub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::DataWriterCallbacks_rch pl = pub.publication_.lock(); if (pl) { DCPS::WeakRcHandle endpoint = pl->get_ice_endpoint(); @@ -1963,7 +1965,7 @@ DDS::ReturnCode_t Sedp::remove_subscription_i(const GUID_t& subscriptionId, LocalSubscription& sub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::DataReaderCallbacks_rch sl = sub.subscription_.lock(); if (sl) { DCPS::WeakRcHandle endpoint = sl->get_ice_endpoint(); @@ -2048,7 +2050,7 @@ Sedp::shutdown() participant_message_reader_->shutting_down(); type_lookup_request_reader_->shutting_down(); type_lookup_reply_reader_->shutting_down(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY publications_secure_reader_->shutting_down(); subscriptions_secure_reader_->shutting_down(); participant_message_secure_reader_->shutting_down(); @@ -2063,7 +2065,7 @@ Sedp::shutdown() participant_message_writer_->shutting_down(); type_lookup_request_writer_->shutting_down(); type_lookup_reply_writer_->shutting_down(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY publications_secure_writer_->shutting_down(); subscriptions_secure_writer_->shutting_down(); participant_message_secure_writer_->shutting_down(); @@ -2076,7 +2078,7 @@ Sedp::shutdown() type_lookup_fini(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY using namespace OpenDDS::Security; using namespace DDS::Security; @@ -2113,7 +2115,7 @@ void Sedp::process_discovered_writer_data(DCPS::MessageId message_id, const DCPS::DiscoveredWriterData& wdata, const GUID_t& guid, const XTypes::TypeInformation& type_info -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , bool have_ice_agent_info, const ICE::AgentInfo& ice_agent_info, @@ -2131,7 +2133,7 @@ void Sedp::process_discovered_writer_data(DCPS::MessageId message_id, if (message_id == DCPS::SAMPLE_DATA) { DCPS::DiscoveredWriterData wdata_copy; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (iter != discovered_publications_.end()) { DiscoveredPublication& dpub = iter->second; if (!dpub.have_ice_agent_info_ && have_ice_agent_info) { @@ -2155,13 +2157,13 @@ void Sedp::process_discovered_writer_data(DCPS::MessageId message_id, prepub.transport_context_ = spdp_.get_participant_flags(participant_id); prepub.type_info_ = type_info; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY prepub.have_ice_agent_info_ = have_ice_agent_info; prepub.ice_agent_info_ = ice_agent_info; #endif topic_name = prepub.get_topic_name(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { DDS::Security::SecurityException ex = {"", 0, 0}; @@ -2364,7 +2366,7 @@ Sedp::data_received(DCPS::MessageId message_id, return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (message_id == DCPS::SAMPLE_DATA && should_drop_message(wdata.ddsPublicationData.topic_name)) { return; } @@ -2375,13 +2377,13 @@ Sedp::data_received(DCPS::MessageId message_id, } process_discovered_writer_data(message_id, wdata, guid, dpub.type_info_ -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , dpub.have_ice_agent_info_, dpub.ice_agent_info_ #endif ); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Sedp::data_received(DCPS::MessageId message_id, const ParameterListConverter::DiscoveredPublication_SecurityWrapper& wrapper) { @@ -2408,7 +2410,7 @@ void Sedp::process_discovered_reader_data(DCPS::MessageId message_id, const DCPS::DiscoveredReaderData& rdata, const GUID_t& guid, const XTypes::TypeInformation& type_info -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , bool have_ice_agent_info, const ICE::AgentInfo& ice_agent_info, @@ -2427,7 +2429,7 @@ void Sedp::process_discovered_reader_data(DCPS::MessageId message_id, if (message_id == DCPS::SAMPLE_DATA) { DCPS::DiscoveredReaderData rdata_copy; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (iter != discovered_subscriptions_.end()) { DiscoveredSubscription& dsub = iter->second; if (!dsub.have_ice_agent_info_ && have_ice_agent_info) { @@ -2450,14 +2452,14 @@ void Sedp::process_discovered_reader_data(DCPS::MessageId message_id, presub.participant_discovered_at_ = spdp_.get_participant_discovered_at(participant_id); presub.transport_context_ = spdp_.get_participant_flags(participant_id); presub.type_info_ = type_info; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY presub.have_ice_agent_info_ = have_ice_agent_info; presub.ice_agent_info_ = ice_agent_info; #endif topic_name = presub.get_topic_name(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { DDS::Security::SecurityException ex = {"", 0, 0}; @@ -2700,7 +2702,7 @@ Sedp::data_received(DCPS::MessageId message_id, return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (message_id == DCPS::SAMPLE_DATA && should_drop_message(rdata.ddsSubscriptionData.topic_name)) { return; } @@ -2711,13 +2713,13 @@ Sedp::data_received(DCPS::MessageId message_id, } process_discovered_reader_data(message_id, rdata, guid, dsub.type_info_ -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , dsub.have_ice_agent_info_, dsub.ice_agent_info_ #endif ); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Sedp::data_received(DCPS::MessageId message_id, const ParameterListConverter::DiscoveredSubscription_SecurityWrapper& wrapper) { @@ -2796,7 +2798,7 @@ Sedp::data_received(DCPS::MessageId /*message_id*/, notify_liveliness(data); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Sedp::received_participant_message_data_secure(DCPS::MessageId /*message_id*/, const ParticipantMessageData& data) @@ -3014,7 +3016,7 @@ Sedp::association_complete_i(const GUID_t& localId, } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (remoteId.entityId == ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_READER) { write_durable_publication_data(remoteId, true); } else if (remoteId.entityId == ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_READER) { @@ -3051,7 +3053,7 @@ void Sedp::data_acked_i(const DCPS::GUID_t& local_id, { if (local_id.entityId == ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER || local_id.entityId == ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY || local_id.entityId == ENTITYID_P2P_BUILTIN_PARTICIPANT_VOLATILE_SECURE_WRITER || local_id.entityId == ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_WRITER || local_id.entityId == ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_WRITER @@ -3069,7 +3071,7 @@ void Sedp::data_acked_i(const DCPS::GUID_t& local_id, void Sedp::signal_liveliness(DDS::LivelinessQosPolicyKind kind) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::SecurityException se = {"", 0, 0}; DDS::Security::TopicSecurityAttributes attribs; @@ -3099,7 +3101,7 @@ void Sedp::signal_liveliness(DDS::LivelinessQosPolicyKind kind) signal_liveliness_unsecure(kind); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } #endif } @@ -3141,7 +3143,7 @@ bool Sedp::send_type_lookup_request(const XTypes::TypeIdentifierSeq& type_ids, { TypeLookupRequestWriter_rch writer = type_lookup_request_writer_; DCPS::GUID_t remote_reader = make_id(reader, ENTITYID_TL_SVC_REQ_READER); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled() && is_discovery_protected) { writer = type_lookup_request_secure_writer_; remote_reader = make_id(reader, ENTITYID_TL_SVC_REQ_READER_SECURE); @@ -3156,7 +3158,7 @@ bool Sedp::send_type_lookup_request(const XTypes::TypeIdentifierSeq& type_ids, XTypes::TypeLookup_getTypes_HashId : XTypes::TypeLookup_getDependencies_HashId); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Sedp::signal_liveliness_secure(DDS::LivelinessQosPolicyKind kind) { @@ -3444,7 +3446,7 @@ Sedp::LivelinessWriter::write_participant_message(const ParticipantMessageData& return result; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t Sedp::SecurityWriter::write_stateless_message(const DDS::Security::ParticipantStatelessMessage& msg, const GUID_t& reader, @@ -4123,7 +4125,7 @@ void Sedp::cleanup_type_lookup_data(const DCPS::GUID_t& guid, const XTypes::TypeIdentifier& ti, bool secure) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (secure) { type_lookup_reply_secure_reader_->cleanup(guid, ti); } else { @@ -4203,25 +4205,25 @@ Sedp::Reader::data_received(const DCPS::ReceivedDataSample& sample) // Figure Out Extensibility of Data Based On Entity Id const bool is_mutable = entity_id == ENTITYID_SEDP_BUILTIN_PUBLICATIONS_WRITER || -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY entity_id == ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_WRITER || #endif entity_id == ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_WRITER || -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY entity_id == ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_WRITER || entity_id == ENTITYID_SPDP_RELIABLE_BUILTIN_PARTICIPANT_SECURE_WRITER || #endif false; const bool is_final = (entity_id == ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_WRITER && full_message) || -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY (entity_id == ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_SECURE_WRITER && full_message) || entity_id == ENTITYID_P2P_BUILTIN_PARTICIPANT_STATELESS_WRITER || entity_id == ENTITYID_P2P_BUILTIN_PARTICIPANT_VOLATILE_SECURE_WRITER || #endif entity_id == ENTITYID_TL_SVC_REQ_WRITER || entity_id == ENTITYID_TL_SVC_REPLY_WRITER || -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY entity_id == ENTITYID_TL_SVC_REQ_WRITER_SECURE || entity_id == ENTITYID_TL_SVC_REPLY_WRITER_SECURE || #endif @@ -4283,7 +4285,7 @@ Sedp::LivelinessReader::data_received_i(const DCPS::ReceivedDataSample& sample, } sedp_.data_received(id, data); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } else if (entity_id == ENTITYID_P2P_BUILTIN_PARTICIPANT_MESSAGE_SECURE_WRITER && full_message) { ParticipantMessageData data; if (!(ser >> data)) { @@ -4304,7 +4306,7 @@ Sedp::SecurityReader::data_received_i(const DCPS::ReceivedDataSample& sample, DCPS::Serializer& ser, DCPS::Extensibility) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const DCPS::MessageId id = static_cast(sample.header_.message_id_); if (entity_id == ENTITYID_P2P_BUILTIN_PARTICIPANT_STATELESS_WRITER) { @@ -4362,7 +4364,7 @@ Sedp::DiscoveryReader::data_received_i(const DCPS::ReceivedDataSample& sample, } return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY wdata.have_ice_agent_info_ = false; ICE::AgentInfoMap ai_map; if (!ParameterListConverter::from_param_list(data, ai_map)) { @@ -4388,7 +4390,7 @@ Sedp::DiscoveryReader::data_received_i(const DCPS::ReceivedDataSample& sample, sedp_.data_received(id, wdata); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } else if (entity_id == ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_WRITER) { ParameterList data; if (!decode_parameter_list(sample, ser, extensibility, data)) { @@ -4451,7 +4453,7 @@ Sedp::DiscoveryReader::data_received_i(const DCPS::ReceivedDataSample& sample, } return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY rdata.have_ice_agent_info_ = false; ICE::AgentInfoMap ai_map; if (!ParameterListConverter::from_param_list(data, ai_map)) { @@ -4480,7 +4482,7 @@ Sedp::DiscoveryReader::data_received_i(const DCPS::ReceivedDataSample& sample, sedp_.data_received(id, rdata); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } else if (entity_id == ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_WRITER) { ParameterList data; if (!decode_parameter_list(sample, ser, extensibility, data)) { @@ -4575,7 +4577,7 @@ Sedp::TypeLookupRequestReader::data_received_i(const DCPS::ReceivedDataSample& s return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (entity_id == ENTITYID_TL_SVC_REQ_WRITER_SECURE) { const DCPS::GUID_t reader = make_id(sample.header_.publication_id_, ENTITYID_TL_SVC_REPLY_READER_SECURE); if (!sedp_.type_lookup_reply_secure_writer_->send_type_lookup_reply(type_lookup_reply, reader)) { @@ -4595,7 +4597,7 @@ Sedp::TypeLookupRequestReader::data_received_i(const DCPS::ReceivedDataSample& s } return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } #else ACE_UNUSED_ARG(entity_id); @@ -4613,7 +4615,7 @@ void Sedp::TypeLookupReplyReader::data_received_i( DCPS::LogGuid(sample.header_.publication_id_).c_str())); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (remote_id == ENTITYID_TL_SVC_REPLY_WRITER_SECURE) { if (!process_type_lookup_reply(sample, ser, true)) { if (DCPS::DCPS_debug_level) { @@ -4631,7 +4633,7 @@ void Sedp::TypeLookupReplyReader::data_received_i( } return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } #else ACE_UNUSED_ARG(remote_id); @@ -4732,7 +4734,7 @@ void Sedp::write_durable_publication_data(const GUID_t& reader, bool secure) { if (!(spdp_.available_builtin_endpoints() & (DISC_BUILTIN_ENDPOINT_PUBLICATION_ANNOUNCER -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY | DDS::Security::SEDP_BUILTIN_PUBLICATIONS_SECURE_WRITER #endif ))) { @@ -4740,7 +4742,7 @@ Sedp::write_durable_publication_data(const GUID_t& reader, bool secure) } if (secure) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY LocalPublicationIter pub, end = local_publications_.end(); for (pub = local_publications_.begin(); pub != end; ++pub) { if (pub->second.security_attribs_.base.is_discovery_protected) { @@ -4752,7 +4754,7 @@ Sedp::write_durable_publication_data(const GUID_t& reader, bool secure) } else { LocalPublicationIter pub, end = local_publications_.end(); for (pub = local_publications_.begin(); pub != end; ++pub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!pub->second.security_attribs_.base.is_discovery_protected) { write_publication_data(pub->first, pub->second, reader); } @@ -4768,7 +4770,7 @@ void Sedp::write_durable_subscription_data(const GUID_t& reader, bool secure) { if (!(spdp_.available_builtin_endpoints() & (DISC_BUILTIN_ENDPOINT_SUBSCRIPTION_ANNOUNCER -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY | DDS::Security::SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_WRITER #endif ))) { @@ -4776,7 +4778,7 @@ Sedp::write_durable_subscription_data(const GUID_t& reader, bool secure) } if (secure) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY LocalSubscriptionIter sub, end = local_subscriptions_.end(); for (sub = local_subscriptions_.begin(); sub != end; ++sub) { if (is_security_enabled() && sub->second.security_attribs_.base.is_discovery_protected) { @@ -4788,7 +4790,7 @@ Sedp::write_durable_subscription_data(const GUID_t& reader, bool secure) } else { LocalSubscriptionIter sub, end = local_subscriptions_.end(); for (sub = local_subscriptions_.begin(); sub != end; ++sub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!(is_security_enabled() && sub->second.security_attribs_.base.is_discovery_protected)) { write_subscription_data(sub->first, sub->second, reader); } @@ -4822,7 +4824,7 @@ Sedp::write_durable_participant_message_data(const GUID_t& reader) participant_message_writer_->end_historic_samples(reader); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Sedp::write_durable_participant_message_data_secure(const GUID_t& reader) { @@ -4899,7 +4901,7 @@ Sedp::add_publication_i(const DCPS::GUID_t& rid, { pub.participant_discovered_at_ = spdp_.get_participant_discovered_at(); pub.transport_context_ = participant_flags_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::DataWriterCallbacks_rch pl = pub.publication_.lock(); if (pl) { DCPS::WeakRcHandle endpoint = pl->get_ice_endpoint(); @@ -4925,7 +4927,7 @@ Sedp::write_publication_data( { DDS::ReturnCode_t result = DDS::RETCODE_OK; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled() && lp.security_attribs_.base.is_discovery_protected) { result = write_publication_data_secure(rid, lp, reader); @@ -4934,7 +4936,7 @@ Sedp::write_publication_data( result = write_publication_data_unsecure(rid, lp, reader); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } #endif @@ -4966,7 +4968,7 @@ Sedp::write_publication_data_unsecure( ACE_TEXT(" to ParameterList\n"))); result = DDS::RETCODE_ERROR; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (lp.have_ice_agent_info) { ICE::AgentInfoMap ai_map; ai_map["DATA"] = lp.ice_agent_info; @@ -4990,7 +4992,7 @@ Sedp::write_publication_data_unsecure( return result; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t Sedp::write_publication_data_secure( const GUID_t& rid, @@ -5051,7 +5053,7 @@ Sedp::add_subscription_i(const DCPS::GUID_t& rid, { sub.participant_discovered_at_ = spdp_.get_participant_discovered_at(); sub.transport_context_ = participant_flags_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::DataReaderCallbacks_rch sl = sub.subscription_.lock(); if (sl) { DCPS::WeakRcHandle endpoint = sl->get_ice_endpoint(); @@ -5077,7 +5079,7 @@ Sedp::write_subscription_data( { DDS::ReturnCode_t result = DDS::RETCODE_OK; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled() && ls.security_attribs_.base.is_discovery_protected) { result = write_subscription_data_secure(rid, ls, reader); @@ -5086,7 +5088,7 @@ Sedp::write_subscription_data( result = write_subscription_data_unsecure(rid, ls, reader); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } #endif @@ -5119,7 +5121,7 @@ Sedp::write_subscription_data_unsecure( result = DDS::RETCODE_ERROR; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (ls.have_ice_agent_info) { ICE::AgentInfoMap ai_map; ai_map["DATA"] = ls.ice_agent_info; @@ -5142,7 +5144,7 @@ Sedp::write_subscription_data_unsecure( return result; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t Sedp::write_subscription_data_secure( const GUID_t& rid, @@ -5221,7 +5223,7 @@ Sedp::write_participant_message_data( return result; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t Sedp::write_participant_message_data_secure( const GUID_t& rid, @@ -5344,7 +5346,7 @@ Sedp::populate_transport_locator_sequence(DCPS::TransportLocatorSeq& wTls, } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::DatawriterCryptoHandle Sedp::generate_remote_matched_writer_crypto_handle(const GUID_t& writer, const GUID_t& reader) @@ -5706,7 +5708,7 @@ DDS::DomainId_t Sedp::get_domain_id() const { void Sedp::add_assoc_i(const DCPS::GUID_t& local_guid, const LocalPublication& lpub, const DCPS::GUID_t& remote_guid, const DiscoveredSubscription& dsub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::DataWriterCallbacks_rch pl = lpub.publication_.lock(); if (pl) { DCPS::WeakRcHandle endpoint = pl->get_ice_endpoint(); @@ -5725,7 +5727,7 @@ Sedp::add_assoc_i(const DCPS::GUID_t& local_guid, const LocalPublication& lpub, void Sedp::remove_assoc_i(const DCPS::GUID_t& local_guid, const LocalPublication& lpub, const DCPS::GUID_t& remote_guid) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::DataWriterCallbacks_rch pl = lpub.publication_.lock(); if (pl) { DCPS::WeakRcHandle endpoint = pl->get_ice_endpoint(); @@ -5743,7 +5745,7 @@ Sedp::remove_assoc_i(const DCPS::GUID_t& local_guid, const LocalPublication& lpu void Sedp::add_assoc_i(const DCPS::GUID_t& local_guid, const LocalSubscription& lsub, const DCPS::GUID_t& remote_guid, const DiscoveredPublication& dpub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::DataReaderCallbacks_rch sl = lsub.subscription_.lock(); if (sl) { DCPS::WeakRcHandle endpoint = sl->get_ice_endpoint(); @@ -5762,7 +5764,7 @@ Sedp::add_assoc_i(const DCPS::GUID_t& local_guid, const LocalSubscription& lsub, void Sedp::remove_assoc_i(const DCPS::GUID_t& local_guid, const LocalSubscription& lsub, const DCPS::GUID_t& remote_guid) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::DataReaderCallbacks_rch sl = lsub.subscription_.lock(); if (sl) { DCPS::WeakRcHandle endpoint = sl->get_ice_endpoint(); @@ -5777,7 +5779,7 @@ Sedp::remove_assoc_i(const DCPS::GUID_t& local_guid, const LocalSubscription& ls #endif } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Sedp::PublicationAgentInfoListener::update_agent_info(const DCPS::GUID_t& a_local_guid, const ICE::AgentInfo& a_agent_info) @@ -5829,7 +5831,7 @@ Sedp::SubscriptionAgentInfoListener::remove_agent_info(const DCPS::GUID_t& a_loc void Sedp::start_ice(const DCPS::GUID_t& guid, const LocalPublication& lpub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::DataWriterCallbacks_rch pl = lpub.publication_.lock(); if (pl) { DCPS::WeakRcHandle endpoint = pl->get_ice_endpoint(); @@ -5856,7 +5858,7 @@ Sedp::start_ice(const DCPS::GUID_t& guid, const LocalPublication& lpub) { void Sedp::start_ice(const DCPS::GUID_t& guid, const LocalSubscription& lsub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::DataReaderCallbacks_rch sl = lsub.subscription_.lock(); if (sl) { DCPS::WeakRcHandle endpoint = sl->get_ice_endpoint(); @@ -5883,7 +5885,7 @@ Sedp::start_ice(const DCPS::GUID_t& guid, const LocalSubscription& lsub) { void Sedp::start_ice(const DCPS::GUID_t& guid, const DiscoveredPublication& dpub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!dpub.have_ice_agent_info_) { return; } @@ -5910,7 +5912,7 @@ Sedp::start_ice(const DCPS::GUID_t& guid, const DiscoveredPublication& dpub) { void Sedp::start_ice(const DCPS::GUID_t& guid, const DiscoveredSubscription& dsub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!dsub.have_ice_agent_info_) { return; } @@ -5941,7 +5943,7 @@ Sedp::start_ice(const DCPS::GUID_t& guid, const DiscoveredSubscription& dsub) { void Sedp::stop_ice(const DCPS::GUID_t& guid, const DiscoveredPublication& dpub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY for (DCPS::RepoIdSet::const_iterator it = dpub.matched_endpoints_.begin(), end = dpub.matched_endpoints_.end(); it != end; ++it) { const DCPS::GuidConverter conv(*it); @@ -5968,7 +5970,7 @@ Sedp::stop_ice(const DCPS::GUID_t& guid, const DiscoveredPublication& dpub) void Sedp::stop_ice(const DCPS::GUID_t& guid, const DiscoveredSubscription& dsub) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY for (DCPS::RepoIdSet::const_iterator it = dsub.matched_endpoints_.begin(), end = dsub.matched_endpoints_.end(); it != end; ++it) { const DCPS::GuidConverter conv(*it); @@ -6009,7 +6011,7 @@ Sedp::use_ice_now(bool f) { transport_inst_->use_ice_now(f); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!f) { return; } @@ -6233,7 +6235,7 @@ bool Sedp::add_publication( pb.type_info_ = type_info; const String& topic_name = topic_names_[topicId]; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { DDS::Security::SecurityException ex; @@ -6315,7 +6317,7 @@ void Sedp::remove_publication(const GUID_t& publicationId) if (iter != local_publications_.end()) { if (DDS::RETCODE_OK == remove_publication_i(publicationId, iter->second)) { String topic_name = topic_names_[iter->second.topic_id_]; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { cleanup_secure_writer(publicationId); } @@ -6379,7 +6381,7 @@ bool Sedp::add_subscription( sb.type_info_ = type_info; const String& topic_name = topic_names_[topicId]; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { DDS::Security::SecurityException ex; @@ -6462,7 +6464,7 @@ void Sedp::remove_subscription(const GUID_t& subscriptionId) if (iter != local_subscriptions_.end()) { if (DDS::RETCODE_OK == remove_subscription_i(subscriptionId, iter->second)) { String topic_name = topic_names_[iter->second.topic_id_]; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { cleanup_secure_reader(subscriptionId); } @@ -6519,7 +6521,7 @@ bool Sedp::remote_knows_about_local_i(const GUID_t& local, const GUID_t& remote) if (gc.isWriter()) { LocalPublicationCIter pub = local_publications_.find(local); if (pub != local_publications_.end()) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (pub->second.security_attribs_.base.is_discovery_protected) { return publications_secure_writer_->is_leading(make_id(remote, ENTITYID_SEDP_BUILTIN_PUBLICATIONS_SECURE_READER)); } @@ -6532,7 +6534,7 @@ bool Sedp::remote_knows_about_local_i(const GUID_t& local, const GUID_t& remote) } else { LocalSubscriptionCIter pub = local_subscriptions_.find(local); if (pub != local_subscriptions_.end()) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (pub->second.security_attribs_.base.is_discovery_protected) { return subscriptions_secure_writer_->is_leading(make_id(remote, ENTITYID_SEDP_BUILTIN_SUBSCRIPTIONS_SECURE_READER)); } @@ -6545,7 +6547,7 @@ bool Sedp::remote_knows_about_local_i(const GUID_t& local, const GUID_t& remote) } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool Sedp::remote_is_authenticated_i(const GUID_t& local, const GUID_t& remote, const DiscoveredParticipant& participant) const { if (DCPS_debug_level > 6) { @@ -6571,7 +6573,7 @@ bool Sedp::remote_is_authenticated_i(const GUID_t& local, const GUID_t& remote, } #endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool Sedp::local_has_remote_participant_token_i(const GUID_t& local, const GUID_t& remote) const { if (DCPS_debug_level > 6) { @@ -7003,7 +7005,7 @@ void Sedp::match(const GUID_t& writer, const GUID_t& reader) request_type_objects( reader_local ? writer_type_info : reader_type_info, MatchingPair(reader, writer, reader_local), -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY reader_local ? lsi->second.security_attribs_.base.is_discovery_protected : lpi->second.security_attribs_.base.is_discovery_protected, @@ -7027,7 +7029,7 @@ void Sedp::request_remote_complete_type_objects( DiscoveredPublicationIter dpi = discovered_publications_.find(remote_entity); if (dpi != discovered_publications_.end()) { discovered = true; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY discovery_protected = dpi->second.security_attribs_.base.is_discovery_protected; #endif } @@ -7035,7 +7037,7 @@ void Sedp::request_remote_complete_type_objects( DiscoveredSubscriptionIter dsi = discovered_subscriptions_.find(remote_entity); if (dsi != discovered_subscriptions_.end()) { discovered = true; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY discovery_protected = dsi->second.security_attribs_.base.is_discovery_protected; #endif } @@ -7472,7 +7474,7 @@ void Sedp::match_continue(const GUID_t& writer, const GUID_t& reader) wa.participantDiscoveredAt = writer_participant_discovered_at; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { match_continue_security_enabled(writer, reader, call_writer, call_reader); } @@ -7631,7 +7633,7 @@ void Sedp::get_remote_type_objects(const XTypes::TypeIdentifierWithDependencies& const SequenceNumber& orig_seqnum = get_minimal ? md.rpc_seqnum_minimal : md.rpc_seqnum_complete; orig_req_data.seq_number = orig_seqnum; orig_req_data.secure = false; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled() && is_discovery_protected) { orig_req_data.secure = true; } @@ -7660,7 +7662,7 @@ void Sedp::get_remote_type_objects(const XTypes::TypeIdentifierWithDependencies& type_lookup_reply_deadline_processor_->schedule(max_type_lookup_service_reply_period_); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Sedp::match_continue_security_enabled( const GUID_t& writer, const GUID_t& reader, bool call_writer, bool call_reader) { diff --git a/dds/DCPS/RTPS/Sedp.h b/dds/DCPS/RTPS/Sedp.h index 580d009e3a9..10604b01bf6 100644 --- a/dds/DCPS/RTPS/Sedp.h +++ b/dds/DCPS/RTPS/Sedp.h @@ -6,18 +6,20 @@ #ifndef OPENDDS_DCPS_RTPS_SEDP_H #define OPENDDS_DCPS_RTPS_SEDP_H +#include + #include "AssociationRecord.h" #include "DiscoveredEntities.h" #include "LocalEntities.h" #include "MessageTypes.h" #include "MessageUtils.h" #include "TypeLookupTypeSupportImpl.h" -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include "ParameterListConverter.h" #endif #include "RtpsRpcTypeSupportImpl.h" #include "RtpsCoreTypeSupportImpl.h" -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include "RtpsSecurityC.h" #endif @@ -53,7 +55,7 @@ #include #include #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -119,7 +121,7 @@ class RtpsDiscoveryCore { return (!(rtps_relay_only_ || use_rtps_relay_)) && from == spdp_rtps_relay_address_; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void use_ice(bool flag) { ACE_Guard guard(mutex_); @@ -182,7 +184,7 @@ class RtpsDiscoveryCore { relay_stun_task_falloff_.set(sedp_heartbeat_period_); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY TimeDuration advance_relay_stun_task_falloff() { ACE_Guard guard(mutex_); @@ -298,7 +300,7 @@ class RtpsDiscoveryCore { const TimeDuration spdp_rtps_relay_send_period_; bool rtps_relay_only_; bool use_rtps_relay_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool use_ice_; #endif DCPS::NetworkAddress spdp_rtps_relay_address_; @@ -326,7 +328,7 @@ class Sedp : public virtual DCPS::RcEventHandler { #endif XTypes::TypeLookupService_rch tls); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t init_security(DDS::Security::IdentityHandle id_handle, DDS::Security::PermissionsHandle perm_handle, DDS::Security::ParticipantCryptoHandle crypto_handle); @@ -345,7 +347,7 @@ class Sedp : public virtual DCPS::RcEventHandler { DCPS::NetworkAddress multicast_group() const; void associate(DiscoveredParticipant& participant -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , const DDS::Security::ParticipantSecurityAttributes& participant_sec_attr #endif ); @@ -357,7 +359,7 @@ class Sedp : public virtual DCPS::RcEventHandler { void process_association_records_i(DiscoveredParticipant& participant); void generate_remote_matched_crypto_handles(DiscoveredParticipant& participant); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void disassociate_volatile(DiscoveredParticipant& participant); void cleanup_volatile_crypto(const DCPS::GUID_t& remote); void associate_volatile(DiscoveredParticipant& participant); @@ -376,7 +378,7 @@ class Sedp : public virtual DCPS::RcEventHandler { void update_locators(const ParticipantData_t& pdata); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t write_stateless_message(const DDS::Security::ParticipantStatelessMessage& msg, const DCPS::GUID_t& reader); @@ -420,7 +422,7 @@ class Sedp : public virtual DCPS::RcEventHandler { bool is_discovery_protected, bool send_get_types, const SequenceNumber& seq_num); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void signal_liveliness_secure(DDS::LivelinessQosPolicyKind kind); #endif @@ -485,7 +487,7 @@ class Sedp : public virtual DCPS::RcEventHandler { void update_subscription_locators(const GUID_t& subscriptionId, const DCPS::TransportLocatorSeq& transInfo); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY inline Security::HandleRegistry_rch get_handle_registry() const { return handle_registry_; @@ -513,7 +515,7 @@ class Sedp : public virtual DCPS::RcEventHandler { void populate_origination_locator(const GUID_t& id, DCPS::TransportLocator& tl); bool remote_knows_about_local_i(const GUID_t& local, const GUID_t& remote) const; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool remote_is_authenticated_i(const GUID_t& local, const GUID_t& remote, const DiscoveredParticipant& participant) const; bool local_has_remote_participant_token_i(const GUID_t& local, const GUID_t& remote) const; bool remote_has_local_participant_token_i(const GUID_t& local, const GUID_t& remote, const DiscoveredParticipant& participant) const; @@ -553,7 +555,7 @@ class Sedp : public virtual DCPS::RcEventHandler { topics_.erase(top_it); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void cleanup_secure_writer(const GUID_t& publicationId); void cleanup_secure_reader(const GUID_t& subscriptionId); #endif @@ -590,7 +592,7 @@ class Sedp : public virtual DCPS::RcEventHandler { , domain_id_(sedp.get_domain_id()) , sedp_(sedp) , shutting_down_(false) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , participant_crypto_handle_(DDS::HANDLE_NIL) , endpoint_crypto_handle_(DDS::HANDLE_NIL) #endif @@ -624,7 +626,7 @@ class Sedp : public virtual DCPS::RcEventHandler { using DCPS::TransportClient::enable_transport_using_config; using DCPS::TransportClient::disassociate; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void set_crypto_handles(DDS::Security::ParticipantCryptoHandle p, DDS::Security::NativeCryptoHandle e = DDS::HANDLE_NIL) { @@ -669,7 +671,7 @@ class Sedp : public virtual DCPS::RcEventHandler { const DDS::DomainId_t domain_id_; Sedp& sedp_; AtomicBool shutting_down_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::ParticipantCryptoHandle participant_crypto_handle_; DDS::Security::NativeCryptoHandle endpoint_crypto_handle_; #endif @@ -759,7 +761,7 @@ class Sedp : public virtual DCPS::RcEventHandler { virtual ~SecurityWriter(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t write_stateless_message(const DDS::Security::ParticipantStatelessMessage& msg, const DCPS::GUID_t& reader, DCPS::SequenceNumber& sequence); @@ -796,7 +798,7 @@ class Sedp : public virtual DCPS::RcEventHandler { virtual ~DiscoveryWriter(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t write_dcps_participant_secure(const Security::SPDPdiscoveredParticipantData& msg, const DCPS::GUID_t& reader, DCPS::SequenceNumber& sequence); #endif @@ -1034,7 +1036,7 @@ class Sedp : public virtual DCPS::RcEventHandler { const DCPS::DiscoveredWriterData& wdata, const DCPS::GUID_t& guid, const XTypes::TypeInformation& type_info -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , bool have_ice_agent_info, const ICE::AgentInfo& ice_agent_info, @@ -1045,7 +1047,7 @@ class Sedp : public virtual DCPS::RcEventHandler { void data_received(DCPS::MessageId message_id, const DiscoveredPublication& wdata); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void data_received(DCPS::MessageId message_id, const ParameterListConverter::DiscoveredPublication_SecurityWrapper& wrapper); #endif @@ -1054,7 +1056,7 @@ class Sedp : public virtual DCPS::RcEventHandler { const DCPS::DiscoveredReaderData& rdata, const DCPS::GUID_t& guid, const XTypes::TypeInformation& type_info -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , bool have_ice_agent_info, const ICE::AgentInfo& ice_agent_info, @@ -1065,7 +1067,7 @@ class Sedp : public virtual DCPS::RcEventHandler { void data_received(DCPS::MessageId message_id, const DiscoveredSubscription& rdata); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void data_received(DCPS::MessageId message_id, const ParameterListConverter::DiscoveredSubscription_SecurityWrapper& wrapper); #endif @@ -1078,7 +1080,7 @@ class Sedp : public virtual DCPS::RcEventHandler { void data_received(DCPS::MessageId message_id, const ParticipantMessageData& data); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void received_participant_message_data_secure(DCPS::MessageId message_id, const ParticipantMessageData& data); @@ -1127,7 +1129,7 @@ class Sedp : public virtual DCPS::RcEventHandler { void write_durable_participant_message_data(const DCPS::GUID_t& reader); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void write_durable_participant_message_data_secure(const DCPS::GUID_t& reader); #endif @@ -1138,7 +1140,7 @@ class Sedp : public virtual DCPS::RcEventHandler { LocalPublication& pub, const DCPS::GUID_t& reader = GUID_UNKNOWN); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t write_publication_data_secure(const DCPS::GUID_t& rid, LocalPublication& pub, const DCPS::GUID_t& reader = GUID_UNKNOWN); @@ -1156,7 +1158,7 @@ class Sedp : public virtual DCPS::RcEventHandler { LocalSubscription& sub, const DCPS::GUID_t& reader = GUID_UNKNOWN); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t write_subscription_data_secure(const DCPS::GUID_t& rid, LocalSubscription& sub, const DCPS::GUID_t& reader = GUID_UNKNOWN); @@ -1169,7 +1171,7 @@ class Sedp : public virtual DCPS::RcEventHandler { DDS::ReturnCode_t write_participant_message_data(const DCPS::GUID_t& rid, DCPS::SequenceNumber& sn, const DCPS::GUID_t& reader = GUID_UNKNOWN); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t write_participant_message_data_secure(const DCPS::GUID_t& rid, DCPS::SequenceNumber& sn, const DCPS::GUID_t& reader = GUID_UNKNOWN); @@ -1178,7 +1180,7 @@ class Sedp : public virtual DCPS::RcEventHandler { virtual bool is_expectant_opendds(const GUID_t& endpoint) const; protected: -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::DatawriterCryptoHandle generate_remote_matched_writer_crypto_handle(const DCPS::GUID_t& writer, const DCPS::GUID_t& reader); @@ -1383,7 +1385,7 @@ class Sedp : public virtual DCPS::RcEventHandler { void get_remote_type_objects(const XTypes::TypeIdentifierWithDependencies& tid_with_deps, MatchingData& md, bool get_minimal, const GUID_t& remote_id, bool is_discovery_protected); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void match_continue_security_enabled( const GUID_t& writer, const GUID_t& reader, bool call_writer, bool call_reader); #endif @@ -1419,7 +1421,7 @@ class Sedp : public virtual DCPS::RcEventHandler { return td->second.has_dcps_key(); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY inline bool is_security_enabled() { return (permissions_handle_ != DDS::HANDLE_NIL) && (access_control_ != 0); @@ -1497,7 +1499,7 @@ class Sedp : public virtual DCPS::RcEventHandler { // These are the last sequence numbers sent for the various "liveliness" instances. DCPS::SequenceNumber local_participant_automatic_liveliness_sn_; DCPS::SequenceNumber local_participant_manual_liveliness_sn_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::SequenceNumber local_participant_automatic_liveliness_sn_secure_; DCPS::SequenceNumber local_participant_manual_liveliness_sn_secure_; @@ -1522,15 +1524,15 @@ class Sedp : public virtual DCPS::RcEventHandler { #endif DiscoveryWriter_rch publications_writer_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DiscoveryWriter_rch publications_secure_writer_; #endif DiscoveryWriter_rch subscriptions_writer_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DiscoveryWriter_rch subscriptions_secure_writer_; #endif LivelinessWriter_rch participant_message_writer_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY LivelinessWriter_rch participant_message_secure_writer_; SecurityWriter_rch participant_stateless_message_writer_; DiscoveryWriter_rch dcps_participant_secure_writer_; @@ -1539,20 +1541,20 @@ class Sedp : public virtual DCPS::RcEventHandler { #endif TypeLookupRequestWriter_rch type_lookup_request_writer_; TypeLookupReplyWriter_rch type_lookup_reply_writer_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY TypeLookupRequestWriter_rch type_lookup_request_secure_writer_; TypeLookupReplyWriter_rch type_lookup_reply_secure_writer_; #endif DiscoveryReader_rch publications_reader_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DiscoveryReader_rch publications_secure_reader_; #endif DiscoveryReader_rch subscriptions_reader_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DiscoveryReader_rch subscriptions_secure_reader_; #endif LivelinessReader_rch participant_message_reader_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY LivelinessReader_rch participant_message_secure_reader_; SecurityReader_rch participant_stateless_message_reader_; SecurityReader_rch participant_volatile_message_secure_reader_; @@ -1560,12 +1562,12 @@ class Sedp : public virtual DCPS::RcEventHandler { #endif TypeLookupRequestReader_rch type_lookup_request_reader_; TypeLookupReplyReader_rch type_lookup_reply_reader_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY TypeLookupRequestReader_rch type_lookup_request_secure_reader_; TypeLookupReplyReader_rch type_lookup_reply_secure_reader_; #endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::RcHandle ice_agent_; RcHandle publication_agent_info_listener_; RcHandle subscription_agent_info_listener_; diff --git a/dds/DCPS/RTPS/Spdp.cpp b/dds/DCPS/RTPS/Spdp.cpp index 94ca65fb3a5..aa9b6d3541f 100644 --- a/dds/DCPS/RTPS/Spdp.cpp +++ b/dds/DCPS/RTPS/Spdp.cpp @@ -10,20 +10,23 @@ #include "ParameterListConverter.h" #include "RtpsDiscovery.h" -#include +#include #include #include #include #include #include #include -#include +#include + #include -#ifdef OPENDDS_SECURITY -# include -#endif #include +#include + +#if OPENDDS_CONFIG_SECURITY +# include +#endif #include #include // For setsockopt() @@ -73,7 +76,7 @@ namespace { } #endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY #ifndef DDS_HAS_MINIMUM_BIT DCPS::ParticipantLocation compute_ice_location_mask(const DCPS::NetworkAddress& address) @@ -181,7 +184,7 @@ void Spdp::init(DDS::DomainId_t /*domain*/, BUILTIN_ENDPOINT_TYPE_LOOKUP_REPLY_DATA_WRITER; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { using namespace DDS::Security; @@ -235,7 +238,7 @@ Spdp::Spdp(DDS::DomainId_t domain, , max_spdp_sequence_msg_reset_check_(disco->config()->max_spdp_sequence_msg_reset_check()) , check_source_ip_(disco->config()->check_source_ip()) , undirected_spdp_(disco->config()->undirected_spdp()) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , max_participants_in_authentication_(disco->config()->max_participants_in_authentication()) , security_unsecure_lease_duration_(disco->config()->security_unsecure_lease_duration()) , auth_resend_period_(disco->config()->auth_resend_period()) @@ -257,7 +260,7 @@ Spdp::Spdp(DDS::DomainId_t domain, , shutdown_flag_(false) , available_builtin_endpoints_(0) , sedp_(DCPS::make_rch(guid_, DCPS::ref(*this), DCPS::ref(lock_))) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , available_extended_builtin_endpoints_(0) , security_config_() , security_enabled_(false) @@ -272,13 +275,13 @@ Spdp::Spdp(DDS::DomainId_t domain, init(domain, guid, qos, tls); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY init_participant_sec_attributes(participant_sec_attr_); #endif } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Spdp::Spdp(DDS::DomainId_t domain, const DCPS::GUID_t& guid, const DDS::DomainParticipantQos& qos, @@ -402,7 +405,7 @@ Spdp::shutdown() ACE_TEXT("remove discovered participants\n"))); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY try { write_secure_disposes(); } catch (const CORBA::Exception& e) { @@ -412,7 +415,7 @@ Spdp::shutdown() #endif for (DiscoveredParticipantIter part = participants_.begin(); part != participants_.end(); ++part) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::WeakRcHandle sedp_endpoint = sedp_->get_ice_endpoint(); if (sedp_endpoint) { stop_ice(sedp_endpoint, part->first, part->second.pdata_.participantProxy.availableBuiltinEndpoints, @@ -428,7 +431,7 @@ Spdp::shutdown() } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::WeakRcHandle sedp_endpoint = sedp_->get_ice_endpoint(); if (sedp_endpoint) { const GUID_t l = make_id(guid_, ENTITYID_SEDP_BUILTIN_PUBLICATIONS_READER); @@ -457,7 +460,7 @@ Spdp::~Spdp() { } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Spdp::write_secure_updates() { @@ -481,7 +484,7 @@ Spdp::write_secure_disposes() namespace { DDS::ParticipantBuiltinTopicData& partBitData(ParticipantData_t& pdata) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY return pdata.ddsParticipantDataSecure.base.base; #else return pdata.ddsParticipantData; @@ -709,7 +712,7 @@ bool ip_in_locator_list(const DCPS::NetworkAddress& from, const DCPS::LocatorSeq return false; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool ip_in_AgentInfo(const DCPS::NetworkAddress& from, const ParameterList& plist) { bool found = false; @@ -775,7 +778,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, // Don't trust SPDP for the RtpsRelay application participant. // Otherwise, anyone can reset the application participant. -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled() && !from_sedp) { pdata.participantProxy.opendds_rtps_relay_application_participant = false; } @@ -790,7 +793,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (max_participants_in_authentication_ && n_participants_in_authentication_ >= max_participants_in_authentication_) { if (DCPS::security_debug.auth_debug) { @@ -815,7 +818,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, } if (!from_sedp) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { effective_lease = security_unsecure_lease_duration_; } else { @@ -830,7 +833,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, } effective_lease = maxLeaseDuration; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } #endif } @@ -846,7 +849,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, // add a new participant -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY std::pair p = participants_.insert(std::make_pair(guid, DiscoveredParticipant(pdata, seq, auth_resend_period_))); ++n_participants_in_authentication_; if (DCPS::security_debug.auth_debug) { @@ -877,7 +880,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, #endif sedp_->associate(iter->second -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , participant_sec_attr_ #endif ); @@ -892,7 +895,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { if (!iter->second.has_security_data()) { if (!participant_sec_attr_.allow_unauthenticated_participants) { @@ -962,7 +965,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, enqueue_location_update_i(iter, location_mask, from, "existing participant"); } #endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Non-secure updates for authenticated participants are used for liveliness but // are otherwise ignored. Non-secure dispose messages are ignored completely. if (is_security_enabled() && iter->second.auth_state_ == AUTH_STATE_AUTHENTICATED && !from_sedp) { @@ -978,7 +981,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, #endif if (id == DCPS::DISPOSE_INSTANCE || id == DCPS::DISPOSE_UNREGISTER_INSTANCE) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::WeakRcHandle sedp_endpoint = sedp_->get_ice_endpoint(); if (sedp_endpoint) { stop_ice(sedp_endpoint, iter->first, iter->second.pdata_.participantProxy.availableBuiltinEndpoints, @@ -1040,7 +1043,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, #endif // Else a reset has occurred and check if we should remove the participant } else if (iter->second.seq_reset_count_ >= max_spdp_sequence_msg_reset_check_) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY purge_handshake_deadlines(iter); #endif #ifndef DDS_HAS_MINIMUM_BIT @@ -1094,7 +1097,7 @@ Spdp::data_received(const DataSubmessage& data, pdata.participantProxy.domainId = domain_; pdata.discoveredAt = now.to_monotonic_time(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY pdata.ddsParticipantDataSecure.base.base.key = DCPS::BUILTIN_TOPIC_KEY_UNKNOWN; #endif @@ -1120,7 +1123,7 @@ Spdp::data_received(const DataSubmessage& data, const DCPS::MessageId msg_id = (data.inlineQos.length() && disposed(data.inlineQos)) ? DCPS::DISPOSE_INSTANCE : DCPS::SAMPLE_DATA; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const bool from_relay = sedp_->core().from_relay(from); if (check_source_ip_ && msg_id == DCPS::SAMPLE_DATA && !from_relay && !ip_in_locator_list(from, pdata.participantProxy.metatrafficUnicastLocatorList) && !ip_in_AgentInfo(from, plist)) { @@ -1167,7 +1170,7 @@ Spdp::match_unauthenticated(const DiscoveredParticipantIter& dp_iter) #endif /* DDS_HAS_MINIMUM_BIT */ } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Spdp::handle_auth_request(const DDS::Security::ParticipantStatelessMessage& msg) @@ -2193,7 +2196,7 @@ Spdp::init_bit(DCPS::RcHandle bit_subscriber) type_lookup_service_); tport_->open(sedp_->reactor_task(), sedp_->job_queue()); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::WeakRcHandle sedp_endpoint = sedp_->get_ice_endpoint(); if (sedp_endpoint) { const GUID_t l = make_id(guid_, ENTITYID_SEDP_BUILTIN_PUBLICATIONS_READER); @@ -2230,7 +2233,7 @@ Spdp::is_expectant_opendds(const GUID_t& participant) const } ParticipantData_t Spdp::build_local_pdata( -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool always_in_the_clear, Security::DiscoveredParticipantDataKind kind #endif @@ -2264,7 +2267,7 @@ ParticipantData_t Spdp::build_local_pdata( } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const Security::SPDPdiscoveredParticipantData pdata = { kind, { // ParticipantBuiltinTopicDataSecure @@ -2303,7 +2306,7 @@ ParticipantData_t Spdp::build_local_pdata( , qos_.property , { participant_flags_ } // opendds_participant_flags , is_application_participant_ -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , available_extended_builtin_endpoints_ #endif }, @@ -2321,7 +2324,7 @@ ParticipantData_t Spdp::build_local_pdata( bool Spdp::announce_domain_participant_qos() { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_security_enabled()) { write_secure_updates(); } @@ -2446,7 +2449,7 @@ Spdp::SpdpTransport::open(const DCPS::ReactorTask_rch& reactor_task, DCPS::RcHandle outer = outer_.lock(); if (!outer) return; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Add the endpoint before any sending and receiving occurs. DCPS::WeakRcHandle endpoint = get_ice_endpoint(); if (endpoint) { @@ -2459,7 +2462,7 @@ Spdp::SpdpTransport::open(const DCPS::ReactorTask_rch& reactor_task, reactor(reactor_task->get_reactor()); reactor_task->interceptor()->execute_or_enqueue(DCPS::make_rch(rchandle_from(this), reactor_task)); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Now that the endpoint is added, SEDP can write the SPDP info. if (outer->is_security_enabled()) { outer->write_secure_updates(); @@ -2478,7 +2481,7 @@ Spdp::SpdpTransport::open(const DCPS::ReactorTask_rch& reactor_task, DCPS::make_rch(TheServiceParticipant->time_source(), reactor_task->interceptor(), rchandle_from(this), &SpdpTransport::process_lease_expirations); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY handshake_deadline_task_ = DCPS::make_rch(TheServiceParticipant->time_source(), reactor_task->interceptor(), rchandle_from(this), &SpdpTransport::process_handshake_deadlines); @@ -2584,7 +2587,7 @@ Spdp::SpdpTransport::enable_periodic_tasks() local_send_task_->enable(TimeDuration::zero_value); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::RcHandle outer = outer_.lock(); if (!outer) return; @@ -2648,7 +2651,7 @@ Spdp::SpdpTransport::close(const DCPS::ReactorTask_rch& reactor_task) TheServiceParticipant->network_interface_address_topic()->disconnect(network_interface_address_reader_); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::WeakRcHandle endpoint = get_ice_endpoint(); if (endpoint) { outer->ice_agent_->remove_endpoint(endpoint); @@ -2729,7 +2732,7 @@ Spdp::SpdpTransport::write_i(WriteFlags flags) } const ParticipantData_t pdata = outer->build_local_pdata( -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY true, outer->is_security_enabled() ? Security::DPDK_ENHANCED : Security::DPDK_ORIGINAL #endif ); @@ -2748,7 +2751,7 @@ Spdp::SpdpTransport::write_i(WriteFlags flags) return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!outer->is_security_enabled()) { ICE::AgentInfoMap ai_map; DCPS::WeakRcHandle sedp_endpoint = outer->sedp_->get_ice_endpoint(); @@ -2814,7 +2817,7 @@ Spdp::update_rtps_relay_application_participant_i(DiscoveredParticipantIter iter } if (new_participant) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY tport_->relay_spdp_task_->cancel(); sedp_->core().reset_relay_spdp_task_falloff(); tport_->relay_spdp_task_->schedule(TimeDuration::zero_value); @@ -2859,7 +2862,7 @@ Spdp::SpdpTransport::write_i(const DCPS::GUID_t& guid, const DCPS::NetworkAddres if (!outer) return; const ParticipantData_t pdata = outer->build_local_pdata( -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY true, outer->is_security_enabled() ? Security::DPDK_ENHANCED : Security::DPDK_ORIGINAL #endif ); @@ -2878,7 +2881,7 @@ Spdp::SpdpTransport::write_i(const DCPS::GUID_t& guid, const DCPS::NetworkAddres return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!outer->is_security_enabled()) { ICE::AgentInfoMap ai_map; DCPS::WeakRcHandle sedp_endpoint = outer->sedp_->get_ice_endpoint(); @@ -3221,7 +3224,7 @@ Spdp::SpdpTransport::handle_input(ACE_HANDLE h) return 0; // Ignore } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Assume STUN if (!outer->initialized() || outer->shutting_down()) { return 0; @@ -3259,7 +3262,7 @@ Spdp::SpdpTransport::handle_input(ACE_HANDLE h) DCPS::WeakRcHandle Spdp::SpdpTransport::get_ice_endpoint() { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::RcHandle outer = outer_.lock(); return outer && outer->sedp_->core().use_ice() ? DCPS::static_rchandle_cast(rchandle_from(this)) : DCPS::WeakRcHandle(); #else @@ -3267,7 +3270,7 @@ Spdp::SpdpTransport::get_ice_endpoint() #endif } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY ICE::AddressListType Spdp::SpdpTransport::host_addresses() const { @@ -3405,7 +3408,7 @@ Spdp::SpdpTransport::ice_disconnect(const ICE::GuidSetType& guids, const ACE_INE outer->sedp_->job_queue()->enqueue(DCPS::make_rch(outer, guids, DCPS::NetworkAddress(addr), false)); } #endif /* DDS_HAS_MINIMUM_BIT */ -#endif /* OPENDDS_SECURITY */ +#endif void Spdp::signal_liveliness(DDS::LivelinessQosPolicyKind kind) @@ -3605,7 +3608,7 @@ void Spdp::SpdpTransport::on_data_available(DCPS::ConfigReader_rch) if (sample.key_has_prefix(config_prefix)) { has_prefix = true; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (config->config_key("RTPS_RELAY_ONLY") == sample.key()) { const bool flag = config->rtps_relay_only(); core.rtps_relay_only(flag); @@ -3880,7 +3883,7 @@ Spdp::process_lease_expirations(const DCPS::MonotonicTimePoint& now) DCPS::LogGuid(part->first).c_str())); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::WeakRcHandle sedp_endpoint = sedp_->get_ice_endpoint(); if (sedp_endpoint) { stop_ice(sedp_endpoint, part->first, part->second.pdata_.participantProxy.availableBuiltinEndpoints, @@ -3901,7 +3904,7 @@ Spdp::process_lease_expirations(const DCPS::MonotonicTimePoint& now) } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Spdp::ParticipantCryptoInfoPair Spdp::lookup_participant_crypto_info(const DCPS::GUID_t& id) const { @@ -3981,7 +3984,7 @@ AuthState Spdp::lookup_participant_auth_state(const GUID_t& id) const } #endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Spdp::start_ice(DCPS::WeakRcHandle endpoint, GUID_t r, BuiltinEndpointSet_t avail, DDS::Security::ExtendedBuiltinEndpointSet_t extended_avail, const ICE::AgentInfo& agent_info) @@ -4433,7 +4436,7 @@ void Spdp::SpdpTransport::thread_status_task(const DCPS::MonotonicTimePoint& now #endif /* DDS_HAS_MINIMUM_BIT */ } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Spdp::SpdpTransport::process_handshake_deadlines(const DCPS::MonotonicTimePoint& now) { DCPS::RcHandle outer = outer_.lock(); @@ -4601,7 +4604,7 @@ DCPS::MonotonicTime_t Spdp::get_participant_discovered_at(const DCPS::GUID_t& gu bool Spdp::secure_part_user_data() const { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY return security_enabled_ && secure_participant_user_data_; #else return false; @@ -4611,7 +4614,7 @@ bool Spdp::secure_part_user_data() const DDS::ParticipantBuiltinTopicData Spdp::get_part_bit_data(bool secure) const { bool include_user_data = true; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (secure_part_user_data()) { include_user_data = secure; } @@ -4690,7 +4693,7 @@ void Spdp::purge_discovered_participant(const DiscoveredParticipantIter& iter) remove_lease_expiration_i(iter); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (security_config_) { DDS::Security::SecurityException se = {"", 0, 0}; DDS::Security::Authentication_var auth = security_config_->get_authentication(); @@ -4765,7 +4768,7 @@ void Spdp::purge_discovered_participant(const DiscoveredParticipantIter& iter) #endif } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void Spdp::set_auth_state(DiscoveredParticipant& dp, AuthState new_state) { if (dp.auth_state_ == AUTH_STATE_HANDSHAKE && diff --git a/dds/DCPS/RTPS/Spdp.h b/dds/DCPS/RTPS/Spdp.h index 78862fd8cc3..085398dd071 100644 --- a/dds/DCPS/RTPS/Spdp.h +++ b/dds/DCPS/RTPS/Spdp.h @@ -11,26 +11,27 @@ #include "ICE/Ice.h" #include "RtpsCoreC.h" -#include -#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include -#include #include -#include -#include -#include -#include +#include + #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include #endif -#include -#include -#include -#include -#include #include #include @@ -59,7 +60,7 @@ const char SEDP_AGENT_INFO_KEY[] = "SEDP"; /// Simple Participant Discovery Protocol for a single local DomainParticipant. class OpenDDS_Rtps_Export Spdp : public virtual DCPS::RcObject -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , public virtual ICE::AgentInfoListener #endif { @@ -76,7 +77,7 @@ class OpenDDS_Rtps_Export Spdp RtpsDiscovery* disco, XTypes::TypeLookupService_rch tls); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Spdp(DDS::DomainId_t domain, const DCPS::GUID_t& guid, const DDS::DomainParticipantQos& qos, @@ -123,7 +124,7 @@ class OpenDDS_Rtps_Export Spdp bool has_discovered_participant(const DCPS::GUID_t& guid) const; ACE_CDR::ULong get_participant_flags(const DCPS::GUID_t& guid) const; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Security::SecurityConfig_rch get_security_config() const { return security_config_; } DDS::Security::ParticipantCryptoHandle crypto_handle() const { return crypto_handle_; } DDS::Security::ParticipantCryptoHandle remote_crypto_handle(const DCPS::GUID_t& remote_participant) const; @@ -144,7 +145,7 @@ class OpenDDS_Rtps_Export Spdp bool validateSequenceNumber(const DCPS::MonotonicTimePoint& now, const DCPS::SequenceNumber& seq, DiscoveredParticipantIter& iter); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void process_handshake_deadlines(const DCPS::MonotonicTimePoint& tv); void process_handshake_resends(const DCPS::MonotonicTimePoint& tv); @@ -160,7 +161,7 @@ class OpenDDS_Rtps_Export Spdp bool is_expectant_opendds(const GUID_t& participant) const; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY typedef std::pair ParticipantCryptoInfoPair; ParticipantCryptoInfoPair lookup_participant_crypto_info(const DCPS::GUID_t& id) const; void send_participant_crypto_tokens(const DCPS::GUID_t& id); @@ -191,7 +192,7 @@ class OpenDDS_Rtps_Export Spdp #endif BuiltinEndpointSet_t available_builtin_endpoints() const { return available_builtin_endpoints_; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::ExtendedBuiltinEndpointSet_t available_extended_builtin_endpoints() const { return available_extended_builtin_endpoints_; @@ -201,7 +202,7 @@ class OpenDDS_Rtps_Export Spdp DCPS::WeakRcHandle get_ice_endpoint_if_added(); ParticipantData_t build_local_pdata( -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool always_in_the_clear, Security::DiscoveredParticipantDataKind kind #endif @@ -362,7 +363,7 @@ class OpenDDS_Rtps_Export Spdp private: -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY typedef OPENDDS_MAP_CMP(GUID_t, DDS::Security::AuthRequestMessageToken, GUID_tKeyLessThan) PendingRemoteAuthTokenMap; #endif @@ -389,7 +390,7 @@ class OpenDDS_Rtps_Export Spdp const u_short max_spdp_sequence_msg_reset_check_; const bool check_source_ip_; const bool undirected_spdp_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const size_t max_participants_in_authentication_; const DCPS::TimeDuration security_unsecure_lease_duration_; const DCPS::TimeDuration auth_resend_period_; @@ -425,7 +426,7 @@ class OpenDDS_Rtps_Export Spdp void update_rtps_relay_application_participant_i(DiscoveredParticipantIter iter, bool new_participant); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::ReturnCode_t send_handshake_message(const DCPS::GUID_t& guid, DiscoveredParticipant& dp, const DDS::Security::ParticipantStatelessMessage& msg); @@ -440,7 +441,7 @@ class OpenDDS_Rtps_Export Spdp : public virtual DCPS::RcEventHandler , public virtual DCPS::InternalDataReaderListener , public virtual DCPS::ConfigListener -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , public virtual ICE::Endpoint #endif { @@ -505,7 +506,7 @@ class OpenDDS_Rtps_Export Spdp DCPS::WeakRcHandle get_ice_endpoint(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY ICE::AddressListType host_addresses() const; void send(const ACE_INET_Addr& address, const STUN::Message& message); ACE_INET_Addr stun_server_address() const; @@ -548,7 +549,7 @@ class OpenDDS_Rtps_Export Spdp void thread_status_task(const DCPS::MonotonicTimePoint& now); DCPS::RcHandle thread_status_task_; DCPS::RcHandle > network_interface_address_reader_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void process_handshake_deadlines(const DCPS::MonotonicTimePoint& now); DCPS::RcHandle handshake_deadline_task_; void process_handshake_resends(const DCPS::MonotonicTimePoint& now); @@ -571,7 +572,7 @@ class OpenDDS_Rtps_Export Spdp DCPS::RcHandle tport_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY class SendStun : public DCPS::Job { public: SendStun(const DCPS::RcHandle& tport, @@ -629,7 +630,7 @@ class OpenDDS_Rtps_Export Spdp void process_lease_expirations(const DCPS::MonotonicTimePoint& now); TimeQueue lease_expirations_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::ExtendedBuiltinEndpointSet_t available_extended_builtin_endpoints_; Security::SecurityConfig_rch security_config_; bool security_enabled_; diff --git a/dds/DCPS/Service_Participant.cpp b/dds/DCPS/Service_Participant.cpp index 860f19b094b..e527c890740 100644 --- a/dds/DCPS/Service_Participant.cpp +++ b/dds/DCPS/Service_Participant.cpp @@ -7,23 +7,27 @@ #include "Service_Participant.h" -#include "Logging.h" -#include "WaitSet.h" -#include "transport/framework/TransportRegistry.h" -#include "debug.h" #include "BuiltInTopicUtils.h" #include "DataDurabilityCache.h" +#include "DefaultNetworkConfigMonitor.h" #include "GuidConverter.h" +#include "LinuxNetworkConfigMonitor.h" +#include "Logging.h" #include "MonitorFactory.h" +#include "Qos_Helper.h" #include "RecorderImpl.h" #include "ReplayerImpl.h" -#include "LinuxNetworkConfigMonitor.h" -#include "DefaultNetworkConfigMonitor.h" #include "StaticDiscovery.h" #include "ThreadStatusManager.h" -#include "Qos_Helper.h" +#include "WaitSet.h" +#include "debug.h" + +#include "transport/framework/TransportRegistry.h" + +#include + #include "../Version.h" -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include "security/framework/SecurityRegistry.h" #endif @@ -315,7 +319,7 @@ DDS::ReturnCode_t Service_Participant::shutdown() discovery_types_.clear(); } TransportRegistry::close(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY OpenDDS::Security::SecurityRegistry::close(); #endif } catch (const CORBA::Exception& ex) { @@ -1637,7 +1641,7 @@ Service_Participant::bit_lookup_duration_msec(int msec) config_store_->set_int32(COMMON_DCPS_BIT_LOOKUP_DURATION_MSEC, msec); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool Service_Participant::get_security() const { @@ -2350,7 +2354,7 @@ Service_Participant::ConfigReaderListener::on_data_available(InternalDataReader_ OpenDDS::DCPS::Transport_debug_level = ACE_OS::atoi(p.value().c_str()); } else if (p.key() == COMMON_DCPS_THREAD_STATUS_INTERVAL) { service_participant_.thread_status_manager_.thread_status_interval(TimeDuration(ACE_OS::atoi(p.value().c_str()))); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } else if (p.key() == COMMON_DCPS_SECURITY_DEBUG_LEVEL) { security_debug.set_debug_level(ACE_OS::atoi(p.value().c_str())); } else if (p.key() == COMMON_DCPS_SECURITY_DEBUG) { diff --git a/dds/DCPS/Service_Participant.h b/dds/DCPS/Service_Participant.h index 42bee23a91d..6b0302954ec 100644 --- a/dds/DCPS/Service_Participant.h +++ b/dds/DCPS/Service_Participant.h @@ -6,21 +6,21 @@ #ifndef OPENDDS_DCPS_SERVICE_PARTICIPANT_H #define OPENDDS_DCPS_SERVICE_PARTICIPANT_H +#include "AtomicBool.h" +#include "ConfigStoreImpl.h" #include "Definitions.h" -#include "MonitorFactory.h" #include "Discovery.h" -#include "PoolAllocator.h" #include "DomainParticipantFactoryImpl.h" -#include "unique_ptr.h" -#include "ReactorTask.h" #include "JobQueue.h" -#include "NetworkConfigMonitor.h" +#include "MonitorFactory.h" #include "NetworkConfigModifier.h" +#include "NetworkConfigMonitor.h" +#include "PoolAllocator.h" +#include "ReactorTask.h" #include "Recorder.h" #include "Replayer.h" #include "TimeSource.h" -#include "AtomicBool.h" -#include "ConfigStoreImpl.h" +#include "unique_ptr.h" #include #include @@ -157,7 +157,7 @@ const int COMMON_SCHEDULER_SLICE_default = 0; const char DEFAULT_CONFIGURATION_FILE[] = "DEFAULT_CONFIGURATION_FILE"; const String DEFAULT_CONFIGURATION_FILE_default = ""; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const char COMMON_DCPS_SECURITY[] = "COMMON_DCPS_SECURITY"; const bool COMMON_DCPS_SECURITY_default = false; @@ -452,7 +452,7 @@ class OpenDDS_Dcps_Export Service_Participant { void bit_lookup_duration_msec(int msec); //@} -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY bool get_security() const; void set_security(bool b); #endif diff --git a/dds/DCPS/StaticDiscovery.cpp b/dds/DCPS/StaticDiscovery.cpp index 4153250118e..f585981d1c8 100644 --- a/dds/DCPS/StaticDiscovery.cpp +++ b/dds/DCPS/StaticDiscovery.cpp @@ -2,18 +2,22 @@ #include "StaticDiscovery.h" -#include "debug.h" -#include "DomainParticipantImpl.h" -#include "Marked_Default_Qos.h" -#include "SubscriberImpl.h" #include "BuiltInTopicUtils.h" -#include "Registered_Data_Types.h" -#include "Qos_Helper.h" #include "DataWriterImpl.h" #include "DcpsUpcalls.h" +#include "DomainParticipantImpl.h" +#include "Marked_Default_Qos.h" +#include "Qos_Helper.h" +#include "Registered_Data_Types.h" +#include "SubscriberImpl.h" +#include "debug.h" + #include "transport/framework/TransportRegistry.h" + #include "XTypes/TypeAssignability.h" +#include + #include OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL @@ -1623,7 +1627,7 @@ StaticDiscovery::add_domain_participant(DDS::DomainId_t domain, return ads; } -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY AddDomainStatus StaticDiscovery::add_domain_participant_secure( DDS::DomainId_t /*domain*/, diff --git a/dds/DCPS/StaticDiscovery.h b/dds/DCPS/StaticDiscovery.h index 04100f0dff1..712082a4a0e 100644 --- a/dds/DCPS/StaticDiscovery.h +++ b/dds/DCPS/StaticDiscovery.h @@ -6,16 +6,18 @@ #ifndef OPENDDS_DCPS_STATICDISCOVERY_H #define OPENDDS_DCPS_STATICDISCOVERY_H -#include "WaitSet.h" -#include "PoolAllocator.h" -#include "TopicDetails.h" -#include "SporadicTask.h" +#include "BuiltInTopicDataReaderImpls.h" +#include "DCPS_Utils.h" #include "GuidUtils.h" #include "Marked_Default_Qos.h" -#include "DCPS_Utils.h" -#include "BuiltInTopicDataReaderImpls.h" +#include "PoolAllocator.h" +#include "SporadicTask.h" +#include "TopicDetails.h" +#include "WaitSet.h" #include "dcps_export.h" +#include + #include #ifndef ACE_LACKS_PRAGMA_ONCE @@ -873,7 +875,7 @@ class OpenDDS_Dcps_Export StaticDiscovery : public Discovery { const DDS::DomainParticipantQos& qos, XTypes::TypeLookupService_rch tls); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY virtual AddDomainStatus add_domain_participant_secure( DDS::DomainId_t domain, const DDS::DomainParticipantQos& qos, diff --git a/dds/DCPS/debug.cpp b/dds/DCPS/debug.cpp index 867624a43d2..c48ec75f796 100644 --- a/dds/DCPS/debug.cpp +++ b/dds/DCPS/debug.cpp @@ -6,9 +6,12 @@ #include // Only the _pch include should start with DCPS/ #include "debug.h" + #include "Util.h" -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "PoolAllocator.h" #endif @@ -28,14 +31,14 @@ OpenDDS_Dcps_Export TransportDebug transport_debug; OpenDDS_Dcps_Export LogLevel log_level(LogLevel::Warning); OpenDDS_Dcps_Export unsigned int DCPS_debug_level = 0; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY OpenDDS_Dcps_Export SecurityDebug security_debug; #endif void LogLevel::set(LogLevel::Value value) { level_ = value; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (level_ >= Notice) { security_debug.set_debug_level(1); } else { @@ -130,7 +133,7 @@ OpenDDS_Dcps_Export void set_DCPS_debug_level(unsigned int lvl) DCPS_debug_level = lvl; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY SecurityDebug::SecurityDebug() : fake_encryption(false) , force_auth_role(FORCE_AUTH_ROLE_NORMAL) diff --git a/dds/DCPS/debug.h b/dds/DCPS/debug.h index c4aa9b89516..806ea78638e 100644 --- a/dds/DCPS/debug.h +++ b/dds/DCPS/debug.h @@ -8,6 +8,8 @@ #include "dcps_export.h" +#include + #ifndef OPENDDS_UTIL_BUILD #include "transport/framework/TransportDebug.h" #endif @@ -89,7 +91,7 @@ extern OpenDDS_Dcps_Export unsigned int Transport_debug_level; extern OpenDDS_Dcps_Export TransportDebug transport_debug; #endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY /** * Global Security Debug Settings */ @@ -170,7 +172,7 @@ class LogRestore { , orig_dcps_debug_level_(DCPS_debug_level) , orig_transport_debug_level_(Transport_debug_level) , orig_transport_debug_(transport_debug) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , orig_security_debug_(security_debug) #endif { @@ -182,7 +184,7 @@ class LogRestore { DCPS_debug_level = orig_dcps_debug_level_; Transport_debug_level = orig_transport_debug_level_; transport_debug = orig_transport_debug_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY security_debug = orig_security_debug_; #endif } @@ -192,7 +194,7 @@ class LogRestore { unsigned orig_dcps_debug_level_; unsigned orig_transport_debug_level_; TransportDebug orig_transport_debug_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY SecurityDebug orig_security_debug_; #endif }; diff --git a/dds/DCPS/security/BuiltInSecurityPluginInst.cpp b/dds/DCPS/security/BuiltInSecurityPluginInst.cpp index 0143d98fd0e..a72c2667254 100644 --- a/dds/DCPS/security/BuiltInSecurityPluginInst.cpp +++ b/dds/DCPS/security/BuiltInSecurityPluginInst.cpp @@ -12,6 +12,8 @@ #include "CryptoBuiltInImpl.h" #include "UtilityImpl.h" +#include + OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { @@ -21,7 +23,7 @@ using DDS::Security::CryptoKeyExchange; using DDS::Security::CryptoTransform; BuiltInSecurityPluginInst::BuiltInSecurityPluginInst() -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY : authentication_(new AuthenticationBuiltInImpl) , access_control_(new AccessControlBuiltInImpl) , key_factory_(new CryptoBuiltInImpl) @@ -36,7 +38,7 @@ BuiltInSecurityPluginInst::~BuiltInSecurityPluginInst() { } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Authentication_var BuiltInSecurityPluginInst::create_authentication() { return authentication_; diff --git a/dds/DCPS/security/BuiltInSecurityPluginInst.h b/dds/DCPS/security/BuiltInSecurityPluginInst.h index 2a9bc269da9..0271784de24 100644 --- a/dds/DCPS/security/BuiltInSecurityPluginInst.h +++ b/dds/DCPS/security/BuiltInSecurityPluginInst.h @@ -9,8 +9,11 @@ #define OPENDDS_DCPS_SECURITY_BUILTINSECURITYPLUGININST_H #include "OpenDDS_Security_Export.h" + #include "framework/SecurityPluginInst.h" +#include + OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { @@ -27,7 +30,7 @@ class OpenDDS_Security_Export BuiltInSecurityPluginInst : public SecurityPluginI BuiltInSecurityPluginInst(); ~BuiltInSecurityPluginInst(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY virtual Authentication_var create_authentication(); virtual AccessControl_var create_access_control(); virtual CryptoKeyFactory_var create_crypto_key_factory(); @@ -39,7 +42,7 @@ class OpenDDS_Security_Export BuiltInSecurityPluginInst : public SecurityPluginI virtual void shutdown(); private: -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Authentication_var authentication_; AccessControl_var access_control_; CryptoKeyFactory_var key_factory_; diff --git a/dds/DCPS/security/framework/HandleRegistry.cpp b/dds/DCPS/security/framework/HandleRegistry.cpp index f48bc2203d9..a6eeebd7dbf 100644 --- a/dds/DCPS/security/framework/HandleRegistry.cpp +++ b/dds/DCPS/security/framework/HandleRegistry.cpp @@ -5,7 +5,9 @@ #include //Only the _pch include should start with DCPS/ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "HandleRegistry.h" @@ -383,4 +385,4 @@ HandleRegistry::erase_remote_datawriter_crypto_handle(const DCPS::GUID_t& id) OPENDDS_END_VERSIONED_NAMESPACE_DECL -#endif // OPENDDS_SECURITY +#endif diff --git a/dds/DCPS/security/framework/HandleRegistry.h b/dds/DCPS/security/framework/HandleRegistry.h index 9fbc83c3a0f..453bc6383f8 100644 --- a/dds/DCPS/security/framework/HandleRegistry.h +++ b/dds/DCPS/security/framework/HandleRegistry.h @@ -3,7 +3,9 @@ * See: http://www.OpenDDS.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #ifndef OPENDDS_DCPS_SECURITY_FRAMEWORK_HANDLEREGISTRY_H #define OPENDDS_DCPS_SECURITY_FRAMEWORK_HANDLEREGISTRY_H @@ -113,4 +115,4 @@ typedef DCPS::RcHandle HandleRegistry_rch; OPENDDS_END_VERSIONED_NAMESPACE_DECL #endif // OPENDDS_DCPS_SECURITY_FRAMEWORK_HANDLEREGISTRY_H -#endif // OPENDDS_SECURITY +#endif diff --git a/dds/DCPS/security/framework/SecurityConfig.cpp b/dds/DCPS/security/framework/SecurityConfig.cpp index c134ebe7e13..36d37843f4d 100644 --- a/dds/DCPS/security/framework/SecurityConfig.cpp +++ b/dds/DCPS/security/framework/SecurityConfig.cpp @@ -10,6 +10,8 @@ #include "Properties.h" +#include + #include OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL @@ -18,7 +20,7 @@ namespace OpenDDS { namespace Security { SecurityConfig::SecurityConfig(const OPENDDS_STRING& name, -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Authentication_var authentication_plugin, AccessControl_var access_ctrl_plugin, CryptoKeyExchange_var key_exchange_plugin, @@ -28,7 +30,7 @@ SecurityConfig::SecurityConfig(const OPENDDS_STRING& name, #endif const ConfigPropertyList& properties) : name_(name) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , authentication_plugin_(authentication_plugin) , access_control_plugin_(access_ctrl_plugin) , key_exchange_plugin_(key_exchange_plugin) @@ -41,7 +43,7 @@ SecurityConfig::SecurityConfig(const OPENDDS_STRING& name, SecurityConfig::~SecurityConfig() { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (DCPS::security_debug.bookkeeping) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) {bookkeeping} ") ACE_TEXT("SecurityConfig::~SecurityConfig handle_registry_map_ %B\n"), diff --git a/dds/DCPS/security/framework/SecurityConfig.h b/dds/DCPS/security/framework/SecurityConfig.h index 71f6d700bb4..7e3b3b7e5e1 100644 --- a/dds/DCPS/security/framework/SecurityConfig.h +++ b/dds/DCPS/security/framework/SecurityConfig.h @@ -10,15 +10,17 @@ #include "HandleRegistry.h" #include "Utility.h" +#include +#include #include #include -#include -#include -#ifdef OPENDDS_SECURITY +#include +#include + +#if OPENDDS_CONFIG_SECURITY # include #endif -#include #include #if !defined (ACE_LACKS_PRAGMA_ONCE) @@ -32,7 +34,7 @@ OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { namespace Security { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY using DDS::Security::Authentication_var; using DDS::Security::AccessControl_var; using DDS::Security::CryptoKeyExchange_var; @@ -48,7 +50,7 @@ class OpenDDS_Dcps_Export SecurityConfig : public DCPS::RcObject { return name_; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Get the plugins associated with this configuration Authentication_var get_authentication() const { @@ -122,7 +124,7 @@ class OpenDDS_Dcps_Export SecurityConfig : public DCPS::RcObject { bool qos_implies_security(const DDS::DomainParticipantQos& qos) const; SecurityConfig(const OPENDDS_STRING& name, -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Authentication_var authentication_plugin, AccessControl_var access_ctrl_plugin, CryptoKeyExchange_var key_exchange_plugin, @@ -142,7 +144,7 @@ class OpenDDS_Dcps_Export SecurityConfig : public DCPS::RcObject { const OPENDDS_STRING name_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Authentication_var authentication_plugin_; AccessControl_var access_control_plugin_; CryptoKeyExchange_var key_exchange_plugin_; diff --git a/dds/DCPS/security/framework/SecurityPluginInst.h b/dds/DCPS/security/framework/SecurityPluginInst.h index a678f780cb2..bbc69e3d319 100644 --- a/dds/DCPS/security/framework/SecurityPluginInst.h +++ b/dds/DCPS/security/framework/SecurityPluginInst.h @@ -9,9 +9,12 @@ #include "Utility.h" #include + #include -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -22,7 +25,7 @@ OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { namespace Security { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY using DDS::Security::Authentication_var; using DDS::Security::AccessControl_var; using DDS::Security::CryptoKeyFactory_var; @@ -45,7 +48,7 @@ using DDS::Security::CryptoTransform_var; class OpenDDS_Dcps_Export SecurityPluginInst : public DCPS::RcObject { public: -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Factory methods for the plugin specific interfaces. A SecurityPluginInst // may not support creating all of these interfaces virtual Authentication_var create_authentication() = 0; diff --git a/dds/DCPS/security/framework/SecurityRegistry.cpp b/dds/DCPS/security/framework/SecurityRegistry.cpp index 68939e3ae16..4da68be457d 100644 --- a/dds/DCPS/security/framework/SecurityRegistry.cpp +++ b/dds/DCPS/security/framework/SecurityRegistry.cpp @@ -12,12 +12,15 @@ #include "SecurityConfig.h" #include -#include -#include + +#include #include #include -#include #include +#include +#include + +#include #include #include @@ -186,7 +189,7 @@ SecurityRegistry::create_config(const OPENDDS_STRING& config_name) // release the new config and fail SecurityConfig_rch new_config = DCPS::make_rch(config_name, -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY auth_plugin_inst->create_authentication(), ac_plugin_inst->create_access_control(), crypto_plugin_inst->create_crypto_key_exchange(), @@ -211,7 +214,7 @@ SecurityConfig_rch SecurityRegistry::create_config(const OPENDDS_STRING& config_name, SecurityPluginInst_rch plugin) { -#ifndef OPENDDS_SECURITY +#if !OPENDDS_CONFIG_SECURITY ACE_UNUSED_ARG(plugin); #endif @@ -222,7 +225,7 @@ SecurityRegistry::create_config(const OPENDDS_STRING& config_name, SecurityConfig_rch new_config = DCPS::make_rch(config_name, -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY plugin->create_authentication(), plugin->create_access_control(), plugin->create_crypto_key_exchange(), @@ -254,7 +257,7 @@ SecurityRegistry::get_config(const OPENDDS_STRING& config_name) const SecurityConfig_rch SecurityRegistry::default_config() const { -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY GuardType guard(lock_); if (!default_config_ && !TheServiceParticipant->get_security()) { Authentication_var a; @@ -280,7 +283,7 @@ SecurityRegistry::default_config(const SecurityConfig_rch& config) SecurityConfig_rch SecurityRegistry::builtin_config() const { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY GuardType g1(default_load_lock_); GuardType guard(lock_); if (!builtin_config_) { diff --git a/dds/DCPS/transport/framework/TransportClient.cpp b/dds/DCPS/transport/framework/TransportClient.cpp index 9fd7f358585..2f088bbb2c3 100644 --- a/dds/DCPS/transport/framework/TransportClient.cpp +++ b/dds/DCPS/transport/framework/TransportClient.cpp @@ -155,7 +155,7 @@ TransportClient::enable_transport_using_config(bool reliable, bool durable, if (impl) { impls_.push_back(impl); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY impl->local_crypto_handle(get_crypto_handle()); #endif diff --git a/dds/DCPS/transport/framework/TransportClient.h b/dds/DCPS/transport/framework/TransportClient.h index 747404fbb9d..b437514bade 100644 --- a/dds/DCPS/transport/framework/TransportClient.h +++ b/dds/DCPS/transport/framework/TransportClient.h @@ -23,6 +23,8 @@ #include #include +#include + #include #include #include @@ -171,7 +173,7 @@ class OpenDDS_Dcps_Export TransportClient -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY virtual DDS::Security::ParticipantCryptoHandle get_crypto_handle() const { return DDS::HANDLE_NIL; diff --git a/dds/DCPS/transport/framework/TransportImpl.h b/dds/DCPS/transport/framework/TransportImpl.h index 1886398d9eb..55f47bf594f 100644 --- a/dds/DCPS/transport/framework/TransportImpl.h +++ b/dds/DCPS/transport/framework/TransportImpl.h @@ -11,20 +11,21 @@ #include "TransportInst.h" #include "DataLinkCleanupTask.h" -#include -#include +#include +#include +#include +#include #include +#include #include #include -#include -#include -#include -#include +#include -#include -#include #include -#ifdef OPENDDS_SECURITY +#include +#include +#include +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -261,7 +262,7 @@ class OpenDDS_Dcps_Export TransportImpl : public virtual RcObject { const ConnectionAttribs& attribs, bool active, bool connect); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY virtual void local_crypto_handle(DDS::Security::ParticipantCryptoHandle) {} #endif diff --git a/dds/DCPS/transport/framework/TransportSendStrategy.cpp b/dds/DCPS/transport/framework/TransportSendStrategy.cpp index 881271ed065..017f6644cec 100644 --- a/dds/DCPS/transport/framework/TransportSendStrategy.cpp +++ b/dds/DCPS/transport/framework/TransportSendStrategy.cpp @@ -23,10 +23,12 @@ #include "DirectPriorityMapper.h" #include "EntryExit.h" -#include #include +#include #include +#include + #include #if !defined (__ACE_INLINE__) @@ -1752,7 +1754,7 @@ TransportSendStrategy::do_send_packet(const ACE_Message_Block* packet, int& bp) } DBG_ENTRY_LVL("TransportSendStrategy", "do_send_packet", 6); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Message_Block_Ptr substitute; if (security_config()) { const DDS::Security::CryptoTransform_var crypto = security_config()->get_crypto_transform(); @@ -1773,7 +1775,7 @@ TransportSendStrategy::do_send_packet(const ACE_Message_Block* packet, int& bp) iovec iov[MAX_SEND_BLOCKS]; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const int num_blocks = mb_to_iov(substitute ? *substitute : *packet, iov); #else const int num_blocks = mb_to_iov(*packet, iov); @@ -1792,7 +1794,7 @@ TransportSendStrategy::do_send_packet(const ACE_Message_Block* packet, int& bp) "The send_bytes() said that num_bytes_sent == [%d].\n", num_bytes_sent), 5); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (num_bytes_sent > 0 && substitute && packet->data_block() != substitute->data_block()) { // Although the "substitute" data took the place of "packet", the rest // of the framework needs to account for the bytes in "packet" being taken diff --git a/dds/DCPS/transport/framework/TransportSendStrategy.h b/dds/DCPS/transport/framework/TransportSendStrategy.h index 469fc1f7dd1..5ba2a43362a 100644 --- a/dds/DCPS/transport/framework/TransportSendStrategy.h +++ b/dds/DCPS/transport/framework/TransportSendStrategy.h @@ -17,15 +17,15 @@ #include "TransportReplacedElement.h" #include "TransportRetainedElement.h" -#include #include "dds/DCPS/Atomic.h" #include #include #include #include #include +#include -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY #include #include #include @@ -215,7 +215,7 @@ class OpenDDS_Dcps_Export TransportSendStrategy /// Returns true if anything in the delayed notification list matched. bool send_delayed_notifications(const TransportQueueElement::MatchCriteria* match = 0); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY virtual Security::SecurityConfig_rch security_config() const { return Security::SecurityConfig_rch(); } #endif @@ -266,7 +266,7 @@ class OpenDDS_Dcps_Export TransportSendStrategy /// Form an IOV and call the send_bytes() template method. ssize_t do_send_packet(const ACE_Message_Block* packet, int& bp); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY /// Derived classes can override to transform the data right before it's /// sent. If the returned value is non-NULL it will be sent instead of /// sending the parameter. If the returned value is NULL the original diff --git a/dds/DCPS/transport/rtps_udp/RtpsSampleHeader.cpp b/dds/DCPS/transport/rtps_udp/RtpsSampleHeader.cpp index 18e164e342a..5c702d529bf 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsSampleHeader.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsSampleHeader.cpp @@ -9,19 +9,23 @@ #include "RtpsUdpSendStrategy.h" -#include -#include #include +#include #include #include +#include +#include #include -#include + #include #include #include + #include #include +#include + #include #ifndef __ACE_INLINE__ @@ -110,7 +114,7 @@ RtpsSampleHeader::init(ACE_Message_Block& mb) CASE_SMKIND(DATA, DataSubmessage, data) CASE_SMKIND(DATA_FRAG, DataFragSubmessage, data_frag) -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY // Each submessage type introduced by the Security spec is treated // as an opaque octet sequence at this layer. case SEC_BODY: diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp b/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp index ce35897bd5f..fb027281717 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.cpp @@ -10,23 +10,26 @@ #include "RtpsUdpSendStrategy.h" #include "RtpsUdpReceiveStrategy.h" -#include #include -#include +#include #include #include #include +#include + #include #include #include #include + #include #include -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY # include #endif -#include #include #include @@ -89,14 +92,14 @@ RtpsUdpDataLink::RtpsUdpDataLink(const RtpsUdpTransport_rch& transport, , heartbeat_(make_rch(event_dispatcher_, make_rch >(rchandle_from(this), &RtpsUdpDataLink::send_heartbeats))) , heartbeatchecker_(make_rch(event_dispatcher_, make_rch >(rchandle_from(this), &RtpsUdpDataLink::check_heartbeats))) , max_bundle_size_(config->max_message_size() - RTPS::RTPSHDR_SZ) // default maximum bundled message size is max udp message size (see TransportStrategy) minus RTPS header -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , security_config_(Security::SecurityRegistry::instance()->default_config()) , local_crypto_handle_(DDS::HANDLE_NIL) , ice_agent_(ICE::Agent::instance()) #endif , network_interface_address_reader_(make_rch >(DCPS::DataReaderQosBuilder().reliability_reliable().durability_transient_local(), rchandle_from(this))) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const GUID_t guid = make_id(local_prefix, ENTITYID_PARTICIPANT); handle_registry_ = security_config_->get_handle_registry(guid); #endif @@ -1173,7 +1176,7 @@ RtpsUdpDataLink::RtpsWriter::customize_queue_element_helper( return element; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY { GuardType guard(link->strategy_lock_); if (link->send_strategy_) { @@ -1280,7 +1283,7 @@ RtpsUdpDataLink::customize_queue_element_non_reliable_i( return element; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const GUID_t pub_id = element->publication_id(); { @@ -2044,7 +2047,7 @@ RtpsUdpDataLink::RtpsWriter::add_reader(const ReaderInfo_rch& reader) ReaderInfoMap::const_iterator iter = remote_readers_.find(reader->id_); if (iter == remote_readers_.end()) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_pvs_writer_) { reader->max_pvs_sn_ = max_sn_; } @@ -2106,7 +2109,7 @@ RtpsUdpDataLink::RtpsWriter::remove_reader(const GUID_t& id) snris_erase(acked_sn == max_sn ? leading_readers_ : lagging_readers_, acked_sn, reader); check_leader_lagger(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_pvs_writer_ && !reader->pvs_outstanding_.empty()) { const OPENDDS_VECTOR(SequenceRange) psr = reader->pvs_outstanding_.present_sequence_ranges(); @@ -2403,7 +2406,7 @@ RtpsUdpDataLink::RtpsReader::gather_ack_nacks_i(const WriterInfo_rch& writer, } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY namespace { const NetworkAddress BUNDLING_PLACEHOLDER; } @@ -2439,7 +2442,7 @@ RtpsUdpDataLink::build_meta_submessage_map(MetaSubmessageVec& meta_submessages, } else { addrs = get_addresses_i(it->src_guid_); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (local_crypto_handle() != DDS::HANDLE_NIL && separate_message(it->src_guid_.entityId)) { addrs.insert(BUNDLING_PLACEHOLDER); // removed in bundle_mapped_meta_submessages } @@ -2458,7 +2461,7 @@ RtpsUdpDataLink::build_meta_submessage_map(MetaSubmessageVec& meta_submessages, addrset_max_size = std::max(addrset_max_size, static_cast(addrs.size())); if (addrs.empty()) { continue; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } else if (addrs.size() == 1 && *addrs.begin() == BUNDLING_PLACEHOLDER) { continue; #endif @@ -2481,7 +2484,7 @@ RtpsUdpDataLink::build_meta_submessage_map(MetaSubmessageVec& meta_submessages, cache_hits, cache_misses, addrset_min_size, addrset_max_size)); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool RtpsUdpDataLink::separate_message(EntityId_t entity) { // submessages generated by these entities may not be combined @@ -2499,7 +2502,7 @@ namespace { struct BundleHelper { static const size_t initial_size = -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY RtpsUdpSendStrategy::MaxSecureFullMessageLeadingSize; #else 0; @@ -2525,7 +2528,7 @@ struct BundleHelper { bool add_to_bundle(T& submessage) { const size_t prev_size = size_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Could be an encoded submessage (encoding happens later) size_ += RtpsUdpSendStrategy::MaxSecureSubmessageLeadingSize; #endif @@ -2533,13 +2536,13 @@ struct BundleHelper { submessage.smHeader.submessageLength = static_cast(submessage_size - RTPS::SMHDR_SZ); align(size_, RTPS::SM_ALIGN); size_ += submessage_size; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Could be an encoded submessage (encoding happens later) align(size_, RTPS::SM_ALIGN); size_ += RtpsUdpSendStrategy::MaxSecureSubmessageFollowingSize; #endif size_t compare_size = size_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Could be an encoded rtps message (encoding happens later) align(compare_size, RTPS::SM_ALIGN); compare_size += RtpsUdpSendStrategy::MaxSecureFullMessageFollowingSize; @@ -3361,7 +3364,7 @@ RtpsUdpDataLink::RtpsWriter::process_acknack(const RTPS::AckNackSubmessage& ackn TqeSet to_deliver; acked_by_all_helper_i(to_deliver); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_pvs_writer_ && !reader->pvs_outstanding_.empty() && reader->pvs_outstanding_.low() < reader->cur_cumulative_ack_) { @@ -3763,13 +3766,13 @@ SequenceNumber RtpsUdpDataLink::RtpsWriter::expected_max_sn(const ReaderInfo_rch& reader) const { ACE_UNUSED_ARG(reader); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_pvs_writer_) { return reader->max_pvs_sn_; } else { #endif return max_sn_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } #endif } @@ -3815,7 +3818,7 @@ RtpsUdpDataLink::RtpsWriter::make_leader_lagger(const GUID_t& reader_id, return; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!is_pvs_writer_) { #endif if (previous_max_sn != max_sn_) { @@ -3833,7 +3836,7 @@ RtpsUdpDataLink::RtpsWriter::make_leader_lagger(const GUID_t& reader_id, heartbeat_->schedule(fallback_.get()); } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } else { // Move a specific reader. const ReaderInfoMap::iterator iter = remote_readers_.find(reader_id); @@ -3871,7 +3874,7 @@ RtpsUdpDataLink::RtpsWriter::make_lagger_leader(const ReaderInfo_rch& reader, const SequenceNumber acked_sn = reader->acked_sn(); if (previous_acked_sn == acked_sn) { return; } const SequenceNumber previous_max_sn = expected_max_sn(reader); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_pvs_writer_ && acked_sn > previous_max_sn) { reader->max_pvs_sn_ = acked_sn; } @@ -3939,7 +3942,7 @@ RtpsUdpDataLink::RtpsWriter::record_directed(const GUID_t& reader_id, SequenceNu { ACE_UNUSED_ARG(reader_id); ACE_UNUSED_ARG(seq); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!is_pvs_writer_) { return; } @@ -4188,7 +4191,7 @@ RtpsUdpDataLink::RtpsWriter::gather_directed_heartbeat_i(const SingleSendBuffer: { const SequenceNumber first_sn = reader->durable_ ? 1 : std::max(non_durable_first_sn(proxy), reader->start_sn_); SequenceNumber last_sn = expected_max_sn(reader); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (is_pvs_writer_ && last_sn < first_sn.previous()) { // This can happen if the reader get's reset. // Adjust the heartbeat to be valid. @@ -4270,7 +4273,7 @@ RtpsUdpDataLink::RtpsWriter::gather_heartbeats_i(MetaSubmessageVec& meta_submess if (!lagging_readers_.empty()) { if (leading_readers_.empty() && remote_readers_.size() > 1 -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY && !is_pvs_writer_ && !is_ps_writer_ #endif @@ -4458,7 +4461,7 @@ RtpsUdpDataLink::RtpsWriter::RtpsWriter(const TransportClient_rch& client, const , durable_(durable) , stopping_(false) , heartbeat_count_(heartbeat_count) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , is_pvs_writer_(id_.entityId == RTPS::ENTITYID_P2P_BUILTIN_PARTICIPANT_VOLATILE_SECURE_WRITER) , is_ps_writer_(id_.entityId == RTPS::ENTITYID_SPDP_RELIABLE_BUILTIN_PARTICIPANT_SECURE_WRITER) #endif @@ -4759,7 +4762,7 @@ RtpsUdpDataLink::accumulate_addresses(const GUID_t& local, const GUID_t& remote, } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY WeakRcHandle endpoint = get_ice_endpoint(); if (endpoint) { ice_addr = ice_agent_->get_address(endpoint, local, remote); @@ -4788,7 +4791,7 @@ RtpsUdpDataLink::accumulate_addresses(const GUID_t& local, const GUID_t& remote, entry.value().expires_ = normal_addrs_expires; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY RcHandle RtpsUdpDataLink::get_ice_agent() const { diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.h b/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.h index bd3685ce411..659e789fa3e 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.h +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.h @@ -17,35 +17,38 @@ #include "TransactionalRtpsSendQueue.h" #include -#include -#include #include #include #include + +#include +#include #include +#include #include +#include #include -#include +#include +#include +#include +#include #include -#include -#include #include -#include +#include +#include +#include #include -#include -#include -#include -#include #include -#include -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY # include # include # include #endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -209,7 +212,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpDataLink virtual void pre_stop_i(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::RcHandle get_ice_agent() const; #endif virtual DCPS::WeakRcHandle get_ice_endpoint() const; @@ -217,7 +220,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpDataLink virtual bool is_leading(const GUID_t& writer_id, const GUID_t& reader_id) const; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Security::SecurityConfig_rch security_config() const { ACE_Guard guard(security_mutex_); @@ -351,7 +354,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpDataLink OPENDDS_MAP(SequenceNumber, TransportQueueElement*) durable_data_; MonotonicTimePoint durable_timestamp_; const SequenceNumber start_sn_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY SequenceNumber max_pvs_sn_; DisjointSequence pvs_outstanding_; #endif @@ -370,7 +373,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpDataLink , participant_flags_(participant_flags) , required_acknack_count_(0) , start_sn_(start_sn) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , max_pvs_sn_(SequenceNumber::ZERO()) #endif {} @@ -447,7 +450,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpDataLink const bool durable_; bool stopping_; CORBA::Long heartbeat_count_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY /// Participant Volatile Secure writer const bool is_pvs_writer_; /// Partcicipant Secure (Reliable SPDP) writer @@ -489,7 +492,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpDataLink void record_directed(const GUID_t& reader, SequenceNumber seq); void update_remote_guids_cache_i(bool add, const GUID_t& guid); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool is_pvs_writer() const { return is_pvs_writer_; } #else bool is_pvs_writer() const { return false; } @@ -923,7 +926,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpDataLink GUID_t writer_id_; }; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY mutable ACE_Thread_Mutex security_mutex_; Security::SecurityConfig_rch security_config_; Security::HandleRegistry_rch handle_registry_; diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.inl b/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.inl index a83ce77899e..9443459f8d9 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.inl +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpDataLink.inl @@ -59,7 +59,7 @@ RtpsUdpDataLink::ipv6_multicast_socket() } #endif -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY ACE_INLINE DDS::Security::ParticipantCryptoHandle RtpsUdpDataLink::local_crypto_handle() const { diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpReceiveStrategy.cpp b/dds/DCPS/transport/rtps_udp/RtpsUdpReceiveStrategy.cpp index 7935653b217..f0c8325a6ba 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpReceiveStrategy.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpReceiveStrategy.cpp @@ -12,11 +12,15 @@ #include "dds/DCPS/RTPS/MessageUtils.h" #include "dds/DCPS/RTPS/MessageTypes.h" -#include "dds/DCPS/GuidUtils.h" + +#include #include -#include "dds/DCPS/Util.h" +#include + #include "dds/DCPS/transport/framework/TransportDebug.h" +#include + #include "ace/Reactor.h" #include @@ -40,7 +44,7 @@ RtpsUdpReceiveStrategy::RtpsUdpReceiveStrategy(RtpsUdpDataLink* link, , reassembly_(link->config()->fragment_reassembly_timeout()) , receiver_(local_prefix) , thread_status_manager_(thread_status_manager) -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , secure_sample_() , encoded_rtps_(false) , encoded_submsg_(false) @@ -68,7 +72,7 @@ RtpsUdpReceiveStrategy::RtpsUdpReceiveStrategy(RtpsUdpDataLink* link, )); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY secure_prefix_.smHeader.submessageId = SUBMESSAGE_NONE; #endif } @@ -217,7 +221,7 @@ RtpsUdpReceiveStrategy::receive_bytes_helper(iovec iov[], int n, const ACE_SOCK_Dgram& socket, ACE_INET_Addr& remote_address, -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::RcHandle ice_agent, DCPS::WeakRcHandle endpoint, #endif @@ -247,7 +251,7 @@ RtpsUdpReceiveStrategy::receive_bytes_helper(iovec iov[], return ret; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Assume STUN # ifndef ACE_RECVPKTINFO ACE_ERROR((LM_ERROR, "ERROR: RtpsUdpReceiveStrategy::receive_bytes_helper potential STUN message " @@ -282,7 +286,7 @@ RtpsUdpReceiveStrategy::receive_bytes_helper(iovec iov[], if (tport.relay_srsm().is_response(message)) { tport.process_relay_sra(tport.relay_srsm().receive(message)); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } else if (endpoint) { ice_agent->receive(endpoint, local_address, remote_address, message); #endif @@ -297,7 +301,7 @@ RtpsUdpReceiveStrategy::receive_bytes_helper(iovec iov[], return ret; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY namespace { ssize_t recv_err(const char* msg, const ACE_INET_Addr& remote, const DCPS::GUID_t& peer, bool& stop) { @@ -352,14 +356,14 @@ RtpsUdpReceiveStrategy::receive_bytes(iovec iov[], const ssize_t ret = (scatter < 0) ? scatter : (iter - buffer); #else const ssize_t ret = receive_bytes_helper(iov, n, socket, remote_address, -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY link_->get_ice_agent(), link_->get_ice_endpoint(), #endif *link_->transport(), stop); #endif remote_address_ = remote_address; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (stop) { return ret; } @@ -464,7 +468,7 @@ RtpsUdpReceiveStrategy::receive_bytes(iovec iov[], bool RtpsUdpReceiveStrategy::check_encoded(const EntityId_t& sender) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY using namespace DDS::Security; const GUID_t sendGuid = make_id(receiver_.source_guid_prefix_, sender); const GuidConverter conv(sendGuid); @@ -520,7 +524,7 @@ RtpsUdpReceiveStrategy::deliver_sample(ReceivedDataSample& sample, DCPS::push_back(message_.submessages, rsh.submessage_); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const SubmessageKind kind = rsh.submessage_._d(); if (secure_prefix_.smHeader.submessageId == SEC_PREFIX && kind != SEC_POSTFIX) { @@ -566,7 +570,7 @@ RtpsUdpReceiveStrategy::deliver_sample_i(ReceivedDataSample& sample, break; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!decode_payload(sample, data)) { if (transport_debug.log_dropped_messages) { ACE_DEBUG((LM_DEBUG, "(%P|%t) {transport_debug.log_dropped_messages} RtpsUdpReceiveStrategy::deliver_sample_i - decode error\n")); @@ -725,7 +729,7 @@ RtpsUdpReceiveStrategy::deliver_sample_i(ReceivedDataSample& sample, has successfully reassembled the fragments and we now have a DATA submsg */ -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY case SEC_PREFIX: secure_prefix_ = submessage.security_sm(); break; @@ -740,7 +744,7 @@ RtpsUdpReceiveStrategy::deliver_sample_i(ReceivedDataSample& sample, } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void RtpsUdpReceiveStrategy::deliver_from_secure(const RTPS::Submessage& submessage, const NetworkAddress& remote_addr) @@ -1020,7 +1024,7 @@ RtpsUdpReceiveStrategy::check_header(const RtpsTransportHeader& header) message_.hdr = header.header_; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY secure_prefix_.smHeader.submessageId = SUBMESSAGE_NONE; #endif @@ -1031,7 +1035,7 @@ bool RtpsUdpReceiveStrategy::check_header(const RtpsSampleHeader& header) { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (secure_prefix_.smHeader.submessageId) { return header.valid(); } diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpReceiveStrategy.h b/dds/DCPS/transport/rtps_udp/RtpsUdpReceiveStrategy.h index 67285e3d157..a05e59b8c77 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpReceiveStrategy.h +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpReceiveStrategy.h @@ -16,8 +16,11 @@ #include "dds/DCPS/RTPS/RtpsCoreC.h" #include "dds/DCPS/RTPS/ICE/Ice.h" -#include "dds/DCPS/RcEventHandler.h" + #include "dds/DCPS/NetworkAddress.h" +#include "dds/DCPS/RcEventHandler.h" + +#include #include "ace/SOCK_Dgram.h" @@ -78,7 +81,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpReceiveStrategy int n, const ACE_SOCK_Dgram& socket, ACE_INET_Addr& remote_address, -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::RcHandle agent, DCPS::WeakRcHandle endpoint, #endif @@ -116,7 +119,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpReceiveStrategy virtual bool reassemble(ReceivedDataSample& data); virtual bool reassemble_i(ReceivedDataSample& data, RtpsSampleHeader& rsh); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY bool sec_submsg_to_octets(DDS::OctetSeq& encoded, const RTPS::Submessage& postfix); @@ -174,7 +177,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpReceiveStrategy ACE_INET_Addr remote_address_; RTPS::Message message_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY RTPS::SecuritySubmessage secure_prefix_; OPENDDS_VECTOR(RTPS::Submessage) secure_submessages_; ReceivedDataSample secure_sample_; diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpSendStrategy.cpp b/dds/DCPS/transport/rtps_udp/RtpsUdpSendStrategy.cpp index 17eae6ea38f..37bf8512c3b 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpSendStrategy.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpSendStrategy.cpp @@ -11,11 +11,15 @@ #include "RtpsUdpTransport.h" #include +#include + #include #include + #include #include #include + #include #include #include @@ -170,7 +174,7 @@ RtpsUdpSendStrategy::send_rtps_control(RTPS::Message& message, const AMB_Continuation cont(rtps_header_mb_lock_, rtps_header_mb_, submessages); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Message_Block_Ptr alternate; if (security_config()) { const DDS::Security::CryptoTransform_var crypto = link_->security_config()->get_crypto_transform(); @@ -210,7 +214,7 @@ RtpsUdpSendStrategy::send_rtps_control(RTPS::Message& message, const AMB_Continuation cont(rtps_header_mb_lock_, rtps_header_mb_, submessages); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY Message_Block_Ptr alternate; if (security_config()) { const DDS::Security::CryptoTransform_var crypto = link_->security_config()->get_crypto_transform(); @@ -348,7 +352,7 @@ RtpsUdpSendStrategy::add_delayed_notification(TransportQueueElement* element) } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY namespace { DDS::OctetSeq toSeq(const ACE_Message_Block* mb) { @@ -788,7 +792,7 @@ size_t RtpsUdpSendStrategy::max_message_size() const { // TODO: Make this conditional on if the message actually needs to do this. return max_message_size_ -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Worst case scenario is full message encryption plus one submessage encryption. - MaxSecureSubmessageAdditionalSize - MaxSecureFullMessageAdditionalSize #endif diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpSendStrategy.h b/dds/DCPS/transport/rtps_udp/RtpsUdpSendStrategy.h index 5db04a2d052..c0d77d07023 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpSendStrategy.h +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpSendStrategy.h @@ -9,12 +9,16 @@ #include "Rtps_Udp_Export.h" #include "RtpsUdpDataLink_rch.h" -#include #include +#include + #include + #include -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -53,7 +57,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpSendStrategy const NetworkAddressSet& destinations); void append_submessages(const RTPS::SubmessageSeq& submessages); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY void encode_payload(const GUID_t& pub_id, Message_Block_Ptr& payload, RTPS::SubmessageSeq& submessages); #endif @@ -75,7 +79,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpSendStrategy static const size_t MaxSecureFullMessageAdditionalSize = MaxSecureFullMessageLeadingSize + MaxSubmessagePadding + MaxSecureFullMessageFollowingSize; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY virtual Security::SecurityConfig_rch security_config() const; #endif @@ -95,7 +99,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpSendStrategy ssize_t send_single_i(const iovec iov[], int n, const NetworkAddress& addr); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY ACE_Message_Block* pre_send_packet(const ACE_Message_Block* plain); struct Chunk { diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp index 6c77cb1134e..5db19a1338e 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.cpp @@ -11,14 +11,17 @@ #include "RtpsUdpSendStrategy.h" #include "RtpsUdpReceiveStrategy.h" +#include #include #include #include #include #include + #include #include + #include #include @@ -48,10 +51,10 @@ RtpsUdpCore::RtpsUdpCore(const RtpsUdpInst_rch& inst) RtpsUdpTransport::RtpsUdpTransport(const RtpsUdpInst_rch& inst, DDS::DomainId_t domain) : TransportImpl(inst, domain) -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY , local_crypto_handle_(DDS::HANDLE_NIL) #endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , ice_endpoint_(make_rch(ref(*this))) , ice_agent_(ICE::Agent::instance()) #endif @@ -69,7 +72,7 @@ RtpsUdpTransport::config() const return dynamic_rchandle_cast(TransportImpl::config()); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::RcHandle RtpsUdpTransport::get_ice_agent() const { @@ -80,7 +83,7 @@ RtpsUdpTransport::get_ice_agent() const DCPS::WeakRcHandle RtpsUdpTransport::get_ice_endpoint() { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY return core_.use_ice() ? static_rchandle_cast(ice_endpoint_) : DCPS::WeakRcHandle(); #else return DCPS::WeakRcHandle(); @@ -99,13 +102,13 @@ RtpsUdpTransport::make_datalink(const GuidPrefix_t& local_prefix) if (equal_guid_prefixes(local_prefix_, GUIDPREFIX_UNKNOWN)) { assign(local_prefix_, local_prefix); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY core_.reset_relay_stun_task_falloff(); relay_stun_task_->schedule(TimeDuration::zero_value); #endif } -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY { if (core_.use_ice()) { ReactorInterceptor_rch ri = reactor_task()->interceptor(); @@ -119,7 +122,7 @@ RtpsUdpTransport::make_datalink(const GuidPrefix_t& local_prefix) RtpsUdpDataLink_rch link = make_rch(rchandle_from(this), local_prefix, config(), reactor_task()); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY link->local_crypto_handle(local_crypto_handle_); #endif @@ -290,7 +293,7 @@ RtpsUdpTransport::use_datalink(const GUID_t& local_id, return true; } -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY void RtpsUdpTransport::local_crypto_handle(DDS::Security::ParticipantCryptoHandle pch) { @@ -647,7 +650,7 @@ RtpsUdpTransport::configure_i(const RtpsUdpInst_rch& config) ACE_Reactor* reactor = reactor_task()->get_reactor(); job_queue_ = DCPS::make_rch(reactor); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (core_.use_ice()) { start_ice(); } @@ -661,7 +664,7 @@ RtpsUdpTransport::configure_i(const RtpsUdpInst_rch& config) link_->default_listener(*config->opendds_discovery_default_listener_); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY core_.reset_relay_stun_task_falloff(); relay_stun_task_->schedule(TimeDuration::zero_value); #endif @@ -687,7 +690,7 @@ void RtpsUdpTransport::client_stop(const GUID_t& localId) void RtpsUdpTransport::shutdown_i() { -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (core_.use_ice()) { stop_ice(); } @@ -734,7 +737,7 @@ RtpsUdpTransport::on_data_available(ConfigReader_rch) if (sample.key_has_prefix(config_prefix)) { has_prefix = true; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (sample.key() == cfg->config_key("RTPS_RELAY_ONLY")) { core_.rtps_relay_only(cfg->rtps_relay_only()); if (core_.rtps_relay_only()) { @@ -780,7 +783,7 @@ RtpsUdpTransport::on_data_available(ConfigReader_rch) } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const ACE_SOCK_Dgram& RtpsUdpTransport::IceEndpoint::choose_recv_socket(ACE_HANDLE fd) const @@ -807,7 +810,7 @@ RtpsUdpTransport::IceEndpoint::handle_input(ACE_HANDLE fd) bool stop; RtpsUdpReceiveStrategy::receive_bytes_helper(iov, 1, choose_recv_socket(fd), remote_address, -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY transport.get_ice_agent(), transport.get_ice_endpoint(), #endif transport, stop); diff --git a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h index 4e8e49ceb06..55d7dd05b66 100644 --- a/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h +++ b/dds/DCPS/transport/rtps_udp/RtpsUdpTransport.h @@ -14,13 +14,17 @@ #include #include #include + #include #include + #include #include #include #include +#include + OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { @@ -211,7 +215,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpCore { transport_statistics_.reload(TheServiceParticipant->config_store(), config_prefix); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void reset_relay_stun_task_falloff() { ACE_Guard guard(mutex_); @@ -253,11 +257,11 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpTransport : public TransportImpl, public Co RtpsUdpTransport(const RtpsUdpInst_rch& inst, DDS::DomainId_t domain); RtpsUdpInst_rch config() const; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DCPS::RcHandle get_ice_agent() const; #endif virtual DCPS::WeakRcHandle get_ice_endpoint(); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY ICE::ServerReflexiveStateMachine& relay_srsm() { return relay_srsm_; } void process_relay_sra(ICE::ServerReflexiveStateMachine::StateChange); void disable_relay_stun_task(); @@ -342,7 +346,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpTransport : public TransportImpl, public Co SequenceNumber max_sn, const TransportClient_rch& client); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY void local_crypto_handle(DDS::Security::ParticipantCryptoHandle pch); #endif @@ -369,7 +373,7 @@ class OpenDDS_Rtps_Udp_Export RtpsUdpTransport : public TransportImpl, public Co JobQueue_rch job_queue_; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::Security::ParticipantCryptoHandle local_crypto_handle_; diff --git a/dds/DdsDcps.mpc b/dds/DdsDcps.mpc index 1a4ef7e82a2..b09dbd26751 100644 --- a/dds/DdsDcps.mpc +++ b/dds/DdsDcps.mpc @@ -49,6 +49,8 @@ project(OpenDDS_Dcps): core, coverage_optional, \ Header_Files { OpenDDSConfig.h + OpenDDSConfigWrapper.h + OpenDDSConfigWrapperC.h Version.h Versioned_Namespace.h DCPS @@ -110,6 +112,7 @@ project(OpenDDS_Dcps): core, coverage_optional, \ " @$(MKDIR) $(DESTDIR)$(INSTALL_PREFIX)/share/dds/dds" " ln -sf ../../../include/dds/Version.h $(DESTDIR)$(INSTALL_PREFIX)/share/dds/dds" " cp $(DDS_ROOT)/user_macros.GNU $(DESTDIR)$(INSTALL_PREFIX)/share/dds $(ACE_NUL_STDERR)" +" cp $(DDS_ROOT)/dds/OpenDDSConfigWrapper.idl $(DESTDIR)$(INSTALL_PREFIX)/include/dds $(ACE_NUL_STDERR)" " @$(MKDIR) $(cmake_dir_install_dest)" " cp $(DDS_ROOT)/cmake/*.cmake $(cmake_dir_install_dest)" " cp $(DDS_ROOT)/cmake/test_cxx_std.cpp $(cmake_dir_install_dest)" diff --git a/dds/DdsSecurityCore.idl b/dds/DdsSecurityCore.idl index 06d03a0ab9a..1cb33d1dfb1 100644 --- a/dds/DdsSecurityCore.idl +++ b/dds/DdsSecurityCore.idl @@ -5,7 +5,9 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #ifndef OPENDDS_DDS_SECURITY_CORE_IDL #define OPENDDS_DDS_SECURITY_CORE_IDL diff --git a/dds/DdsSecurityParams.idl b/dds/DdsSecurityParams.idl index 181c934fa78..69c7935a080 100644 --- a/dds/DdsSecurityParams.idl +++ b/dds/DdsSecurityParams.idl @@ -10,7 +10,9 @@ * */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #ifndef OPENDDS_DDS_SECURITY_PARAMS_IDL #define OPENDDS_DDS_SECURITY_PARAMS_IDL diff --git a/dds/OpenDDSConfig.h.in b/dds/OpenDDSConfig.h.in index 2d94f0e2d40..92116c04bd2 100644 --- a/dds/OpenDDSConfig.h.in +++ b/dds/OpenDDSConfig.h.in @@ -13,4 +13,6 @@ #define OPENDDS_CONFIG_BOOTTIME_TIMERS @OPENDDS_CONFIG_BOOTTIME_TIMERS@ +#define OPENDDS_CONFIG_SECURITY @OPENDDS_CONFIG_SECURITY@ + #endif diff --git a/dds/OpenDDSConfigWrapper.h b/dds/OpenDDSConfigWrapper.h new file mode 100644 index 00000000000..a30d8a1ef58 --- /dev/null +++ b/dds/OpenDDSConfigWrapper.h @@ -0,0 +1,32 @@ +/* + * Distributed under the OpenDDS License. + * See: http://www.opendds.org/license.html + */ + +#ifndef OPENDDS_CONFIG_WRAPPER_H +#define OPENDDS_CONFIG_WRAPPER_H + +// OpenDDSConfig.h is generated by the configure script or by CMake +// If you're manually configuring OpenDDS, start by creating an empty file +// named OpenDDSConfig.h in a dds/ directory on the include path. +// See the OpenDDS Developer's Guide and dds/OpenDDSConfig.h.in for details +// regarding what can be customized. +#ifndef OPENDDS_IGNORE_OPENDDSCONFIG_H_FILE +# include +#endif + +#if defined OPENDDS_SECURITY && defined OPENDDS_CONFIG_SECURITY +# if !OPENDDS_CONFIG_SECURITY +# error OPENDDS_SECURITY is defined but OPENDDS_CONFIG_SECURITY=0 +# endif +#elif defined OPENDDS_SECURITY +# define OPENDDS_CONFIG_SECURITY 1 +#elif defined OPENDDS_CONFIG_SECURITY +# if OPENDDS_CONFIG_SECURITY +# define OPENDDS_SECURITY +# endif +#else +# define OPENDDS_CONFIG_SECURITY 0 +#endif + +#endif diff --git a/dds/OpenDDSConfigWrapper.idl b/dds/OpenDDSConfigWrapper.idl new file mode 100644 index 00000000000..9ce72b3298c --- /dev/null +++ b/dds/OpenDDSConfigWrapper.idl @@ -0,0 +1,11 @@ +/* + * Distributed under the OpenDDS License. + * See: http://www.opendds.org/license.html + */ + +#ifndef OPENDDS_CONFIG_WRAPPER_IDL +#define OPENDDS_CONFIG_WRAPPER_IDL + +#include "OpenDDSConfigWrapper.h" + +#endif diff --git a/dds/OpenDDSConfigWrapperC.h b/dds/OpenDDSConfigWrapperC.h new file mode 100644 index 00000000000..01a5ba3de95 --- /dev/null +++ b/dds/OpenDDSConfigWrapperC.h @@ -0,0 +1,11 @@ +/* + * Distributed under the OpenDDS License. + * See: http://www.opendds.org/license.html + */ + +#ifndef OPENDDS_CONFIG_WRAPPER_C_H +#define OPENDDS_CONFIG_WRAPPER_C_H + +#include "OpenDDSConfigWrapper.h" + +#endif diff --git a/examples/DCPS/ishapes/ShapesWidget.cpp b/examples/DCPS/ishapes/ShapesWidget.cpp index ccfbe5a967a..6ba4929cc75 100644 --- a/examples/DCPS/ishapes/ShapesWidget.cpp +++ b/examples/DCPS/ishapes/ShapesWidget.cpp @@ -17,11 +17,13 @@ #include "dds/DCPS/Service_Participant.h" +#include + namespace { const char* logoFile() { return -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY TheServiceParticipant->get_security() ? ":/images/logo_secure_beta.png" : #endif ":/images/logo.png"; diff --git a/examples/DCPS/ishapes/main.cpp b/examples/DCPS/ishapes/main.cpp index 16f1e97deea..aec967c549c 100644 --- a/examples/DCPS/ishapes/main.cpp +++ b/examples/DCPS/ishapes/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -28,14 +29,14 @@ #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY #include #endif using namespace OpenDDS::RTPS; using namespace OpenDDS::DCPS; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // security setup helpers: const char auth_ca_file[] = "file:security/TESTONLY_identity_ca_cert.pem"; @@ -158,7 +159,7 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { DDS::DomainParticipantQos dp_qos; dpf->get_default_participant_qos(dp_qos); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (!governance.empty() && !permissions.empty()) { TheServiceParticipant->set_security(true); DDS::PropertySeq& props = dp_qos.property.value; @@ -191,7 +192,7 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { // create and show your widgets here ShapesDialog shapes(participant, qosConfig, defaultSize); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (TheServiceParticipant->get_security()) { shapes.setWindowTitle("OpenDDS with DDS Security"); } diff --git a/performance-tests/bench/unit-tests/UnitTests.cpp b/performance-tests/bench/unit-tests/UnitTests.cpp index a74ee13ddb3..8b4cf4872bf 100644 --- a/performance-tests/bench/unit-tests/UnitTests.cpp +++ b/performance-tests/bench/unit-tests/UnitTests.cpp @@ -1,7 +1,10 @@ #include #include -#ifdef OPENDDS_SECURITY + +#include + +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -25,7 +28,7 @@ int main(int argc, char* argv[]) } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY openssl_init(); #endif ACE::init(); diff --git a/performance-tests/bench/worker/main.cpp b/performance-tests/bench/worker/main.cpp index 57fd0b0a747..2d4f5da1009 100644 --- a/performance-tests/bench/worker/main.cpp +++ b/performance-tests/bench/worker/main.cpp @@ -43,6 +43,8 @@ #include #include +#include + #include #include #ifdef ACE_AS_STATIC_LIBS @@ -53,7 +55,7 @@ # include # include # include -# ifdef OPENDDS_SECURITY +# if OPENDDS_CONFIG_SECURITY # include # endif #endif diff --git a/tests/DCPS/FindTopic/LocalDiscovery.cpp b/tests/DCPS/FindTopic/LocalDiscovery.cpp index 671bbc879aa..b716471ab9d 100644 --- a/tests/DCPS/FindTopic/LocalDiscovery.cpp +++ b/tests/DCPS/FindTopic/LocalDiscovery.cpp @@ -1,7 +1,9 @@ #include "LocalDiscovery.h" -#include #include +#include + +#include LocalDiscovery::LocalDiscovery() : Discovery() @@ -49,7 +51,7 @@ AddDomainStatus LocalDiscovery::add_domain_participant( return ads; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY AddDomainStatus LocalDiscovery::add_domain_participant_secure( DDS::DomainId_t, const DDS::DomainParticipantQos&, diff --git a/tests/DCPS/FindTopic/LocalDiscovery.h b/tests/DCPS/FindTopic/LocalDiscovery.h index ebcaa61356c..ca6816b061f 100644 --- a/tests/DCPS/FindTopic/LocalDiscovery.h +++ b/tests/DCPS/FindTopic/LocalDiscovery.h @@ -1,7 +1,10 @@ #include #include + #include +#include + #include #include @@ -47,7 +50,7 @@ class LocalDiscovery : public Discovery { const DDS::DomainParticipantQos& qos, OpenDDS::XTypes::TypeLookupService_rch tls); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY AddDomainStatus add_domain_participant_secure( DDS::DomainId_t domain, const DDS::DomainParticipantQos& qos, diff --git a/tests/DCPS/LargeSample/common.cpp b/tests/DCPS/LargeSample/common.cpp index 65b00d1a6a3..c9e6325047d 100644 --- a/tests/DCPS/LargeSample/common.cpp +++ b/tests/DCPS/LargeSample/common.cpp @@ -1,7 +1,10 @@ #include "common.h" #include -#ifdef OPENDDS_SECURITY + +#include + +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -21,7 +24,7 @@ unsigned char expected_data_field_element(int writer_id, int sample_id, int j) return static_cast(j % 256) + writer_id + sample_id * 3; } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void append( DDS::PropertySeq& props, const char* name, const char* value, bool propagate) { diff --git a/tests/DCPS/LargeSample/common.h b/tests/DCPS/LargeSample/common.h index 7634a28e347..36c6c3c362b 100644 --- a/tests/DCPS/LargeSample/common.h +++ b/tests/DCPS/LargeSample/common.h @@ -3,6 +3,7 @@ #include #include +#include const DDS::DomainId_t domain = 113; const size_t default_writer_process_count = 2; @@ -12,7 +13,7 @@ const size_t default_data_field_length_offset = 0; unsigned expected_data_field_length(unsigned offset, int writer_id, int sample_id); unsigned char expected_data_field_element(int writer_id, int sample_id, int j); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void append( DDS::PropertySeq& props, const char* name, const char* value, bool propagate = false); void set_security_qos(DDS::DomainParticipantQos& participant_qos, unsigned secid); diff --git a/tests/DCPS/LargeSample/publisher.cpp b/tests/DCPS/LargeSample/publisher.cpp index ea67a3714f8..15da5055e62 100644 --- a/tests/DCPS/LargeSample/publisher.cpp +++ b/tests/DCPS/LargeSample/publisher.cpp @@ -11,13 +11,16 @@ #include #include #include + +#include + #if defined ACE_AS_STATIC_LIBS && !defined OPENDDS_SAFETY_PROFILE # include # include # include # include # include -# ifdef OPENDDS_SECURITY +# if OPENDDS_CONFIG_SECURITY # include # endif #endif @@ -78,7 +81,7 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) // Create DomainParticipant DDS::DomainParticipantQos participant_qos; dpf->get_default_participant_qos(participant_qos); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY set_security_qos(participant_qos, security_id); #endif DDS::DomainParticipant_var participant = diff --git a/tests/DCPS/LargeSample/subscriber.cpp b/tests/DCPS/LargeSample/subscriber.cpp index ec0b45aeccf..10135f42bcb 100644 --- a/tests/DCPS/LargeSample/subscriber.cpp +++ b/tests/DCPS/LargeSample/subscriber.cpp @@ -9,20 +9,24 @@ #include "../../Utils/ExceptionStreams.h" #include +#include + #include #include +#include #include #include + #include #include -#include + #if defined ACE_AS_STATIC_LIBS && !defined OPENDDS_SAFETY_PROFILE # include # include # include # include # include -# ifdef OPENDDS_SECURITY +# if OPENDDS_CONFIG_SECURITY # include # endif #endif @@ -88,7 +92,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) // Create DomainParticipant DDS::DomainParticipantQos participant_qos; dpf->get_default_participant_qos(participant_qos); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY set_security_qos(participant_qos, security_id); #endif DDS::DomainParticipant_var participant = diff --git a/tests/DCPS/Messenger/publisher.cpp b/tests/DCPS/Messenger/publisher.cpp index ca85e4da21c..af4b4126bc6 100644 --- a/tests/DCPS/Messenger/publisher.cpp +++ b/tests/DCPS/Messenger/publisher.cpp @@ -8,11 +8,14 @@ #include +#include #include #include #include -#include -#ifdef OPENDDS_SECURITY + +#include + +#if OPENDDS_CONFIG_SECURITY # include #endif #include @@ -22,7 +25,7 @@ # include # include # include -# ifdef OPENDDS_SECURITY +# if OPENDDS_CONFIG_SECURITY # include # endif # endif @@ -74,7 +77,7 @@ int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) DDS::DomainParticipantQos part_qos; dpf->get_default_participant_qos(part_qos); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (TheServiceParticipant->get_security()) { // Determine the path to the keys String path_to_tests; diff --git a/tests/DCPS/Messenger/subscriber.cpp b/tests/DCPS/Messenger/subscriber.cpp index da13e1408c1..cf204f7709f 100644 --- a/tests/DCPS/Messenger/subscriber.cpp +++ b/tests/DCPS/Messenger/subscriber.cpp @@ -8,11 +8,14 @@ #include "Args.h" #include +#include + #include #include #include #include -#ifdef OPENDDS_SECURITY + +#if OPENDDS_CONFIG_SECURITY # include #endif #include @@ -22,7 +25,7 @@ # include # include # include -# ifdef OPENDDS_SECURITY +# if OPENDDS_CONFIG_SECURITY # include # endif # endif @@ -57,7 +60,7 @@ int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) DDS::DomainParticipantQos part_qos; dpf->get_default_participant_qos(part_qos); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY if (TheServiceParticipant->get_security()) { // Determine the path to the keys String path_to_tests; diff --git a/tests/DCPS/ParticipantLocationTopic/ParticipantLocationTest.cpp b/tests/DCPS/ParticipantLocationTopic/ParticipantLocationTest.cpp index aefbe41ac05..dcfe73e62c5 100644 --- a/tests/DCPS/ParticipantLocationTopic/ParticipantLocationTest.cpp +++ b/tests/DCPS/ParticipantLocationTopic/ParticipantLocationTest.cpp @@ -8,10 +8,13 @@ #include #include +#include #include #include #include -#include + +#include + #include #include #ifdef ACE_AS_STATIC_LIBS @@ -106,7 +109,7 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) DDS::DomainParticipantQos sub_qos; dpf->get_default_participant_qos(sub_qos); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Determine the path to the keys OPENDDS_STRING path_to_tests; const char* dds_root = ACE_OS::getenv("DDS_ROOT"); diff --git a/tests/DCPS/Restart/RestartTest.cpp b/tests/DCPS/Restart/RestartTest.cpp index 097e57ba07e..b39fe04957f 100644 --- a/tests/DCPS/Restart/RestartTest.cpp +++ b/tests/DCPS/Restart/RestartTest.cpp @@ -2,13 +2,18 @@ #include -#include #include #include +#include + #include #include + #include -#ifdef OPENDDS_SECURITY + +#include + +#if OPENDDS_CONFIG_SECURITY # include # include # ifdef ACE_AS_STATIC_LIBS @@ -23,7 +28,7 @@ #include #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const char auth_ca_file[] = "file:../../security/certs/identity/identity_ca_cert.pem"; const char perm_ca_file[] = "file:../../security/certs/permissions/permissions_ca_cert.pem"; const char id_cert_file[] = "file:../../security/certs/identity/test_participant_02_cert.pem"; @@ -62,7 +67,7 @@ struct Application { OpenDDS::DCPS::TransportConfig_rch cfg = TheTransportRegistry->create_config(transport_config_name_); cfg->instances_.push_back(ti); -#if defined OPENDDS_SECURITY && defined ACE_AS_STATIC_LIBS +#if OPENDDS_CONFIG_SECURITY && defined ACE_AS_STATIC_LIBS OpenDDS::Security::BuiltInPluginLoader().init(0, 0); #endif @@ -79,7 +84,7 @@ struct Application { DDS::DomainParticipantQos participant_qos; dpf->get_default_participant_qos(participant_qos); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY DDS::PropertySeq& props = participant_qos.property.value; if (TheServiceParticipant->get_security()) { using namespace DDS::Security::Properties; @@ -175,14 +180,14 @@ int main(int argc, char* argv[]) if (argument == "--help" || argument == "-h") { std::cout << usage; return EXIT_SUCCESS; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY } else if (argument == "--secure") { TheServiceParticipant->set_security(true); #endif } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY OpenDDS::DCPS::security_debug.new_entity_error = true; #endif diff --git a/tests/DCPS/RtpsRelay/STUN/StunClient.cpp b/tests/DCPS/RtpsRelay/STUN/StunClient.cpp index 417409ad7dd..e6fdf0b8d07 100644 --- a/tests/DCPS/RtpsRelay/STUN/StunClient.cpp +++ b/tests/DCPS/RtpsRelay/STUN/StunClient.cpp @@ -5,9 +5,12 @@ * See: http://www.opendds.org/license.html */ -#include "dds/DCPS/RTPS/ICE/Stun.h" -#include "dds/DCPS/Message_Block_Ptr.h" #include +#include + +#include + +#include #include "ace/ACE.h" #include "ace/Argv_Type_Converter.h" @@ -19,7 +22,7 @@ #include #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY void generate_transaction_id(OpenDDS::STUN::Message& message) { diff --git a/tests/DCPS/RtpsRelay/Smoke/monitor.cpp b/tests/DCPS/RtpsRelay/Smoke/monitor.cpp index cf46ac5a04e..ad662890d70 100644 --- a/tests/DCPS/RtpsRelay/Smoke/monitor.cpp +++ b/tests/DCPS/RtpsRelay/Smoke/monitor.cpp @@ -9,10 +9,14 @@ #include #include #include + #include + +#include + #ifdef ACE_AS_STATIC_LIBS # include -# ifdef OPENDDS_SECURITY +# if OPENDDS_CONFIG_SECURITY # include # endif #endif diff --git a/tests/DCPS/RtpsRelay/Smoke/publisher.cpp b/tests/DCPS/RtpsRelay/Smoke/publisher.cpp index f89d8469b83..66f5e401224 100644 --- a/tests/DCPS/RtpsRelay/Smoke/publisher.cpp +++ b/tests/DCPS/RtpsRelay/Smoke/publisher.cpp @@ -11,19 +11,23 @@ #include #include #include -#include #include + +#include + #include + +#include #include #ifdef ACE_AS_STATIC_LIBS # include # include -# ifdef OPENDDS_SECURITY +# if OPENDDS_CONFIG_SECURITY # include # endif #endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -33,7 +37,7 @@ #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const char auth_ca_file[] = "file:../../../security/certs/identity/identity_ca_cert.pem"; const char perm_ca_file[] = "file:../../../security/certs/permissions/permissions_ca_cert.pem"; const char id_cert_file[] = "file:../../../security/certs/identity/test_participant_02_cert.pem"; @@ -106,7 +110,7 @@ int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) part_qos.user_data.value.length(static_cast(std::strlen(USER_DATA))); std::memcpy(part_qos.user_data.value.get_buffer(), USER_DATA, std::strlen(USER_DATA)); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY if (TheServiceParticipant->get_security()) { DDS::PropertySeq& props = part_qos.property.value; append(props, DDS::Security::Properties::AuthIdentityCA, auth_ca_file); diff --git a/tests/DCPS/RtpsRelay/Smoke/subscriber.cpp b/tests/DCPS/RtpsRelay/Smoke/subscriber.cpp index cae21a4ff01..091206f6c53 100644 --- a/tests/DCPS/RtpsRelay/Smoke/subscriber.cpp +++ b/tests/DCPS/RtpsRelay/Smoke/subscriber.cpp @@ -10,28 +10,32 @@ #include #include -#include #include #include #include + +#include + #include + +#include #include #ifdef ACE_AS_STATIC_LIBS # include # include -# ifdef OPENDDS_SECURITY +# if OPENDDS_CONFIG_SECURITY # include # endif #endif -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include #endif #include #include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const char auth_ca_file[] = "file:../../../security/certs/identity/identity_ca_cert.pem"; const char perm_ca_file[] = "file:../../../security/certs/permissions/permissions_ca_cert.pem"; const char id_cert_file[] = "file:../../../security/certs/identity/test_participant_03_cert.pem"; @@ -124,7 +128,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) part_qos.user_data.value.length(static_cast(std::strlen(USER_DATA))); std::memcpy(part_qos.user_data.value.get_buffer(), USER_DATA, std::strlen(USER_DATA)); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY if (TheServiceParticipant->get_security()) { DDS::PropertySeq& props = part_qos.property.value; append(props, DDS::Security::Properties::AuthIdentityCA, auth_ca_file); diff --git a/tests/DCPS/XTypes/Common.h b/tests/DCPS/XTypes/Common.h index bfef3e09b51..afe10c98264 100644 --- a/tests/DCPS/XTypes/Common.h +++ b/tests/DCPS/XTypes/Common.h @@ -3,18 +3,23 @@ #include "CommonTypeSupportImpl.h" +#include +#include #include #include #include + #include + #include -#include -#include + +#include + #ifdef ACE_AS_STATIC_LIBS # include # include # include -# ifdef OPENDDS_SECURITY +# if OPENDDS_CONFIG_SECURITY # include # endif #endif @@ -315,7 +320,7 @@ void create_participant(const DomainParticipantFactory_var& dpf, DomainParticipa DomainParticipantQos part_qos; dpf->get_default_participant_qos(part_qos); -#if defined(OPENDDS_SECURITY) +#if OPENDDS_CONFIG_SECURITY if (TheServiceParticipant->get_security()) { using namespace DDS::Security::Properties; PropertySeq& props = part_qos.property.value; diff --git a/tests/cmake/idl_compiler_tests/CMakeLists.txt b/tests/cmake/idl_compiler_tests/CMakeLists.txt index 6b82ea30aa4..859b233e082 100644 --- a/tests/cmake/idl_compiler_tests/CMakeLists.txt +++ b/tests/cmake/idl_compiler_tests/CMakeLists.txt @@ -49,6 +49,12 @@ function(assert_includes target) get_target_property(interface_include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES) remove_build_interface("${interface_include_directories}" interface_include_directories) + if(DEFINED OPENDDS_CONFIG_INCLUDE_DIR) + if(arg_INTERFACE) + list(APPEND arg_INTERFACE "${OPENDDS_CONFIG_INCLUDE_DIR}") + endif() + list(APPEND arg_PRIVATE "${OPENDDS_CONFIG_INCLUDE_DIR}") + endif() foreach(inc ${arg_INTERFACE}) if(NOT "${inc}" IN_LIST interface_include_directories) message(SEND_ERROR "ERROR: ${target} expected ${inc} in INTERFACE includes") diff --git a/tests/stress-tests/StressTests.cpp b/tests/stress-tests/StressTests.cpp index b78b0c567ec..c11a36b44ac 100644 --- a/tests/stress-tests/StressTests.cpp +++ b/tests/stress-tests/StressTests.cpp @@ -1,6 +1,8 @@ #include -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "dds/DCPS/security/OpenSSL_init.h" #endif @@ -9,7 +11,7 @@ int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY openssl_init(); #endif ACE::init(); diff --git a/tests/transport/spdp/spdp_transport.cpp b/tests/transport/spdp/spdp_transport.cpp index 2cd73298fd8..f571f4c1105 100644 --- a/tests/transport/spdp/spdp_transport.cpp +++ b/tests/transport/spdp/spdp_transport.cpp @@ -15,8 +15,10 @@ #include #include -#include #include +#include + +#include #include #include @@ -335,7 +337,7 @@ bool run_test() BUILTIN_ENDPOINT_TYPE_LOOKUP_REPLY_DATA_WRITER | BUILTIN_ENDPOINT_TYPE_LOOKUP_REPLY_DATA_READER; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY const DDS::Security::ExtendedBuiltinEndpointSet_t availableExtendedBuiltinEndpoints = DDS::Security::TYPE_LOOKUP_SERVICE_REQUEST_WRITER_SECURE | DDS::Security::TYPE_LOOKUP_SERVICE_REPLY_WRITER_SECURE | @@ -396,7 +398,7 @@ bool run_test() , qos.property , {PFLAGS_THIS_VERSION} // opendds_participant_flags , false // opendds_rtps_relay_application_participant -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY , availableExtendedBuiltinEndpoints #endif }, diff --git a/tests/unit-tests/UnitTests.cpp b/tests/unit-tests/UnitTests.cpp index a74ee13ddb3..8b4cf4872bf 100644 --- a/tests/unit-tests/UnitTests.cpp +++ b/tests/unit-tests/UnitTests.cpp @@ -1,7 +1,10 @@ #include #include -#ifdef OPENDDS_SECURITY + +#include + +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -25,7 +28,7 @@ int main(int argc, char* argv[]) } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY openssl_init(); #endif ACE::init(); diff --git a/tests/unit-tests/dds/DCPS/RTPS/DiscoveredEntities.cpp b/tests/unit-tests/dds/DCPS/RTPS/DiscoveredEntities.cpp index 0f53ac3156a..7d713185826 100644 --- a/tests/unit-tests/dds/DCPS/RTPS/DiscoveredEntities.cpp +++ b/tests/unit-tests/dds/DCPS/RTPS/DiscoveredEntities.cpp @@ -8,14 +8,13 @@ #include #include -#include #include -#ifdef OPENDDS_SECURITY -# include -#endif +#include + +#include -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY # include #endif @@ -30,7 +29,7 @@ TEST(dds_DCPS_RTPS_DiscoveredEntities, DiscoveredParticipant_ctor) EXPECT_EQ(uut.location_ih_, DDS::HANDLE_NIL); EXPECT_EQ(uut.bit_ih_, DDS::HANDLE_NIL); EXPECT_EQ(uut.seq_reset_count_, 0); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY EXPECT_EQ(uut.have_spdp_info_, false); EXPECT_EQ(uut.have_sedp_info_, false); EXPECT_EQ(uut.have_auth_req_msg_, false); @@ -86,7 +85,7 @@ TEST(dds_DCPS_RTPS_DiscoveredEntities, DiscoveredParticipant_ctor) EXPECT_EQ(uut.location_data_.lease_duration.sec, 0); EXPECT_EQ(uut.location_data_.lease_duration.nanosec, 0u); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY EXPECT_EQ(uut.have_spdp_info_, false); EXPECT_EQ(uut.have_sedp_info_, false); EXPECT_EQ(uut.have_auth_req_msg_, false); @@ -108,7 +107,7 @@ TEST(dds_DCPS_RTPS_DiscoveredEntities, DiscoveredParticipant_ctor) } } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY TEST(dds_DCPS_RTPS_DiscoveredEntities, DiscoveredParticipant_has_security_data) { DiscoveredParticipant uut; @@ -128,7 +127,7 @@ TEST(dds_DCPS_RTPS_DiscoveredEntities, DiscoveredSubscription_ctor) EXPECT_EQ(uut.bit_ih_, DDS::HANDLE_NIL); EXPECT_EQ(uut.participant_discovered_at_, monotonic_time_zero()); EXPECT_EQ(uut.transport_context_, 0u); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY EXPECT_EQ(uut.have_ice_agent_info_, false); // Can't compare IDL defined type. //EXPECT_EQ(uut.security_attribs_.base, DDS::Security::TopicSecurityAttributes()); @@ -152,7 +151,7 @@ TEST(dds_DCPS_RTPS_DiscoveredEntities, DiscoveredSubscription_ctor) EXPECT_EQ(uut.bit_ih_, DDS::HANDLE_NIL); EXPECT_EQ(uut.participant_discovered_at_, monotonic_time_zero()); EXPECT_EQ(uut.transport_context_, 0u); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Can't compare IDL defined type. //EXPECT_EQ(uut.security_attribs_, DDS::Security::EndpointSecurityAttributes()); EXPECT_EQ(uut.have_ice_agent_info_, false); @@ -176,7 +175,7 @@ TEST(dds_DCPS_RTPS_DiscoveredEntities, DiscoveredPublication_ctor) EXPECT_EQ(uut.bit_ih_, DDS::HANDLE_NIL); EXPECT_EQ(uut.participant_discovered_at_, monotonic_time_zero()); EXPECT_EQ(uut.transport_context_, 0u); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY EXPECT_EQ(uut.have_ice_agent_info_, false); // Can't compare IDL defined type. //EXPECT_EQ(uut.security_attribs_.base, DDS::Security::TopicSecurityAttributes()); @@ -200,7 +199,7 @@ TEST(dds_DCPS_RTPS_DiscoveredEntities, DiscoveredPublication_ctor) EXPECT_EQ(uut.bit_ih_, DDS::HANDLE_NIL); EXPECT_EQ(uut.participant_discovered_at_, monotonic_time_zero()); EXPECT_EQ(uut.transport_context_, 0u); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY // Can't compare IDL defined type. //EXPECT_EQ(uut.security_attribs_, DDS::Security::EndpointSecurityAttributes()); EXPECT_EQ(uut.have_ice_agent_info_, false); diff --git a/tests/unit-tests/dds/DCPS/RTPS/LocalEntities.cpp b/tests/unit-tests/dds/DCPS/RTPS/LocalEntities.cpp index a88887d32de..3490975c706 100644 --- a/tests/unit-tests/dds/DCPS/RTPS/LocalEntities.cpp +++ b/tests/unit-tests/dds/DCPS/RTPS/LocalEntities.cpp @@ -10,6 +10,8 @@ #include +#include + TEST(dds_DCPS_RTPS_DiscoveredEntities, LocalEntity_ctor) { OpenDDS::RTPS::LocalEntity uut; @@ -17,7 +19,7 @@ TEST(dds_DCPS_RTPS_DiscoveredEntities, LocalEntity_ctor) EXPECT_EQ(uut.participant_discovered_at_, OpenDDS::DCPS::monotonic_time_zero()); EXPECT_EQ(uut.transport_context_, 0u); EXPECT_EQ(uut.sequence_, OpenDDS::DCPS::SequenceNumber::SEQUENCENUMBER_UNKNOWN()); -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY EXPECT_EQ(uut.have_ice_agent_info, false); EXPECT_EQ(uut.security_attribs_.base.is_read_protected, false); EXPECT_EQ(uut.security_attribs_.base.is_write_protected, false); diff --git a/tests/unit-tests/dds/DCPS/RTPS/ParameterListConverter.cpp b/tests/unit-tests/dds/DCPS/RTPS/ParameterListConverter.cpp index 241cf8ca6a5..8daecbe3f9d 100644 --- a/tests/unit-tests/dds/DCPS/RTPS/ParameterListConverter.cpp +++ b/tests/unit-tests/dds/DCPS/RTPS/ParameterListConverter.cpp @@ -5,17 +5,20 @@ */ #include "ace/OS_main.h" + #include "dds/DCPS/Definitions.h" #include "dds/DCPS/GuidBuilder.h" +#include "dds/DCPS/Service_Participant.h" + #include "dds/DCPS/RTPS/MessageUtils.h" #include "dds/DCPS/RTPS/GuidGenerator.h" #include "dds/DCPS/RTPS/ParameterListConverter.h" #include "dds/DCPS/RTPS/RtpsCoreC.h" -#include "dds/DCPS/Service_Participant.h" + #include "dds/DdsDcpsInfoUtilsC.h" // make sure we get set_default overloads in scope -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY #include "dds/DdsSecurityCoreTypeSupportImpl.h" #endif #include "dds/DdsDcpsInfoUtilsTypeSupportImpl.h" @@ -33,7 +36,7 @@ using namespace OpenDDS::DCPS; using namespace OpenDDS::RTPS::ParameterListConverter; using namespace OpenDDS::RTPS; -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY using namespace DDS::Security; using namespace OpenDDS::Security; #endif @@ -487,7 +490,7 @@ namespace { } // method } // Factory namespace -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY OpenDDS::RTPS::SPDPdiscoveredParticipantData spdp_participant( const void* user_data = 0, CORBA::ULong user_data_len = 0, @@ -685,7 +688,7 @@ Parameter get(const ParameterList& param_list, return Parameter(); } -#ifdef OPENDDS_SECURITY +#if OPENDDS_CONFIG_SECURITY namespace { void init(OpenDDS::Security::SPDPdiscoveredParticipantData& s) { diff --git a/tests/unit-tests/dds/DCPS/security/AccessControl/Permissions.cpp b/tests/unit-tests/dds/DCPS/security/AccessControl/Permissions.cpp index 97dac56a764..220780fbac4 100644 --- a/tests/unit-tests/dds/DCPS/security/AccessControl/Permissions.cpp +++ b/tests/unit-tests/dds/DCPS/security/AccessControl/Permissions.cpp @@ -1,4 +1,6 @@ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include #include @@ -96,4 +98,4 @@ TEST(dds_DCPS_security_AccessControl_Permissions, Permissions_load) EXPECT_EQ(action.validity, Permissions::Validity_t(1444870800, 1760490000)); } -#endif // OPENDDS_SECURITY +#endif diff --git a/tests/unit-tests/dds/DCPS/security/AccessControl/XmlUtils.cpp b/tests/unit-tests/dds/DCPS/security/AccessControl/XmlUtils.cpp index 5aef57e6ac7..2af9c4d9e11 100644 --- a/tests/unit-tests/dds/DCPS/security/AccessControl/XmlUtils.cpp +++ b/tests/unit-tests/dds/DCPS/security/AccessControl/XmlUtils.cpp @@ -1,4 +1,6 @@ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include #include @@ -313,4 +315,4 @@ TEST(dds_DCPS_security_AccessControl_XmlUtils, parse_domain_id_set) } } -#endif // OPENDDS_SECURITY +#endif diff --git a/tests/unit-tests/dds/DCPS/security/AccessControlBuiltInImpl.cpp b/tests/unit-tests/dds/DCPS/security/AccessControlBuiltInImpl.cpp index 0a1ad6aead6..7a4ec23e549 100644 --- a/tests/unit-tests/dds/DCPS/security/AccessControlBuiltInImpl.cpp +++ b/tests/unit-tests/dds/DCPS/security/AccessControlBuiltInImpl.cpp @@ -1,4 +1,6 @@ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include #include diff --git a/tests/unit-tests/dds/DCPS/security/Authentication/LocalAuthCredentialData.cpp b/tests/unit-tests/dds/DCPS/security/Authentication/LocalAuthCredentialData.cpp index 05c50b1ae5f..15e044ae5fa 100644 --- a/tests/unit-tests/dds/DCPS/security/Authentication/LocalAuthCredentialData.cpp +++ b/tests/unit-tests/dds/DCPS/security/Authentication/LocalAuthCredentialData.cpp @@ -3,7 +3,9 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include #include diff --git a/tests/unit-tests/dds/DCPS/security/AuthenticationBuiltInImpl.cpp b/tests/unit-tests/dds/DCPS/security/AuthenticationBuiltInImpl.cpp index 449868a1d16..1549136cf13 100644 --- a/tests/unit-tests/dds/DCPS/security/AuthenticationBuiltInImpl.cpp +++ b/tests/unit-tests/dds/DCPS/security/AuthenticationBuiltInImpl.cpp @@ -3,8 +3,9 @@ * See: http://www.opendds.org/license.html */ -#ifdef OPENDDS_SECURITY +#include +#if OPENDDS_CONFIG_SECURITY #include #include #include diff --git a/tests/unit-tests/dds/DCPS/security/CryptoBuiltInImpl.cpp b/tests/unit-tests/dds/DCPS/security/CryptoBuiltInImpl.cpp index 29893209e85..2965fc9d7d7 100644 --- a/tests/unit-tests/dds/DCPS/security/CryptoBuiltInImpl.cpp +++ b/tests/unit-tests/dds/DCPS/security/CryptoBuiltInImpl.cpp @@ -1,4 +1,6 @@ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "dds/DCPS/LocalObject.h" #include "dds/DCPS/security/CryptoBuiltInImpl.h" diff --git a/tests/unit-tests/dds/DCPS/security/SSL/Certificate.cpp b/tests/unit-tests/dds/DCPS/security/SSL/Certificate.cpp index fb823209b50..0cf56d7082f 100644 --- a/tests/unit-tests/dds/DCPS/security/SSL/Certificate.cpp +++ b/tests/unit-tests/dds/DCPS/security/SSL/Certificate.cpp @@ -3,7 +3,9 @@ * See: http://www.OpenDDS.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "gtest/gtest.h" #include "dds/DCPS/security/OpenSSL_init.h" diff --git a/tests/unit-tests/dds/DCPS/security/SSL/DiffieHellman.cpp b/tests/unit-tests/dds/DCPS/security/SSL/DiffieHellman.cpp index d260a066a25..95178a3f3df 100644 --- a/tests/unit-tests/dds/DCPS/security/SSL/DiffieHellman.cpp +++ b/tests/unit-tests/dds/DCPS/security/SSL/DiffieHellman.cpp @@ -3,7 +3,9 @@ * See: http://www.OpenDDS.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "gtest/gtest.h" #include "dds/DCPS/security/OpenSSL_init.h" diff --git a/tests/unit-tests/dds/DCPS/security/SSL/PrivateKey.cpp b/tests/unit-tests/dds/DCPS/security/SSL/PrivateKey.cpp index 12321b09eaf..9132d4a31a4 100644 --- a/tests/unit-tests/dds/DCPS/security/SSL/PrivateKey.cpp +++ b/tests/unit-tests/dds/DCPS/security/SSL/PrivateKey.cpp @@ -3,7 +3,9 @@ * See: http://www.OpenDDS.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "gtest/gtest.h" #include "dds/DCPS/security/OpenSSL_init.h" diff --git a/tests/unit-tests/dds/DCPS/security/SSL/SignedDocument.cpp b/tests/unit-tests/dds/DCPS/security/SSL/SignedDocument.cpp index 5b1e92529c8..35acce6be9f 100644 --- a/tests/unit-tests/dds/DCPS/security/SSL/SignedDocument.cpp +++ b/tests/unit-tests/dds/DCPS/security/SSL/SignedDocument.cpp @@ -3,7 +3,9 @@ * See: http://www.OpenDDS.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include #include diff --git a/tests/unit-tests/dds/DCPS/security/SSL/SubjectName.cpp b/tests/unit-tests/dds/DCPS/security/SSL/SubjectName.cpp index da561381ca8..27740000c85 100644 --- a/tests/unit-tests/dds/DCPS/security/SSL/SubjectName.cpp +++ b/tests/unit-tests/dds/DCPS/security/SSL/SubjectName.cpp @@ -3,7 +3,9 @@ * See: http://www.OpenDDS.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "gtest/gtest.h" #include "dds/DCPS/security/OpenSSL_init.h" diff --git a/tests/unit-tests/dds/DCPS/security/SSL/Utils.cpp b/tests/unit-tests/dds/DCPS/security/SSL/Utils.cpp index a839665889f..2175dab677b 100644 --- a/tests/unit-tests/dds/DCPS/security/SSL/Utils.cpp +++ b/tests/unit-tests/dds/DCPS/security/SSL/Utils.cpp @@ -3,7 +3,9 @@ * See: http://www.OpenDDS.org/license.html */ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #include "gtest/gtest.h" #include "dds/DCPS/security/OpenSSL_init.h" diff --git a/tests/unit-tests/dds/DCPS/security/framework/SecurityConfig.cpp b/tests/unit-tests/dds/DCPS/security/framework/SecurityConfig.cpp index fa80af5f34d..c96c3d87e35 100644 --- a/tests/unit-tests/dds/DCPS/security/framework/SecurityConfig.cpp +++ b/tests/unit-tests/dds/DCPS/security/framework/SecurityConfig.cpp @@ -1,4 +1,6 @@ -#ifdef OPENDDS_SECURITY +#include + +#if OPENDDS_CONFIG_SECURITY #if defined (ACE_AS_STATIC_LIBS) #include From 1ef00f6d7b962b5a44ed7623df5f6670b28433da Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 31 May 2024 13:50:45 +0000 Subject: [PATCH 36/60] Updates to InternalThreadStatus for systems that suspend/resume * Added a monotonic timestamp to the struct used for the InternalThreadStatus topic * Updated the ReactorTask's event loop to use timers instead of a timeout in the select() call --- dds/DCPS/RTPS/Spdp.cpp | 1 + dds/DCPS/ReactorTask.cpp | 25 ++- dds/DCPS/ReactorTask.h | 3 +- dds/DCPS/ThreadStatusManager.h | 12 ++ dds/OpenddsDcpsExt.idl | 2 + docs/devguide/built_in_topics.rst | 2 + java/dds/.gitignore | 114 +++++++------ java/dds/OpenDDS/DCPS/.gitignore | 161 +++++++++++------- java/dds/dcps_java.mpc | 3 +- .../InternalThreadListener.java | 3 +- .../InternalThreadStatusListenerImpl.cpp | 1 + 11 files changed, 199 insertions(+), 128 deletions(-) diff --git a/dds/DCPS/RTPS/Spdp.cpp b/dds/DCPS/RTPS/Spdp.cpp index 94ca65fb3a5..f8ba155b717 100644 --- a/dds/DCPS/RTPS/Spdp.cpp +++ b/dds/DCPS/RTPS/Spdp.cpp @@ -4427,6 +4427,7 @@ void Spdp::SpdpTransport::thread_status_task(const DCPS::MonotonicTimePoint& now DCPS::InternalThreadBuiltinTopicData data; data.thread_id = i->bit_key().c_str(); data.utilization = i->utilization(now); + data.monotonic_timestamp = i->last_update().to_monotonic_time(); outer->bit_subscriber_->add_thread_status(data, DDS::NEW_VIEW_STATE, i->timestamp()); } diff --git a/dds/DCPS/ReactorTask.cpp b/dds/DCPS/ReactorTask.cpp index bc0660576ad..c7e510854af 100644 --- a/dds/DCPS/ReactorTask.cpp +++ b/dds/DCPS/ReactorTask.cpp @@ -13,6 +13,7 @@ #endif /* __ACE_INLINE__ */ #include "Service_Participant.h" +#include "Timers.h" #include #include @@ -159,18 +160,26 @@ int ReactorTask::svc() condition_.notify_all(); } - // Tell the reactor to handle events. + Timers::TimerId thread_status_timer = Timers::InvalidTimerId; + RcHandle tsm_updater_handler; + if (thread_status_manager_->update_thread_status()) { - while (state() == STATE_RUNNING) { - ACE_Time_Value t = thread_status_manager_->thread_status_interval().value(); - ThreadStatusManager::Sleeper sleeper(*thread_status_manager_); - reactor_->run_reactor_event_loop(t, 0); - } + tsm_updater_handler = make_rch(); + const TimeDuration period = thread_status_manager_->thread_status_interval(); + thread_status_timer = Timers::schedule(reactor_, *tsm_updater_handler, thread_status_manager_, + period, period); - } else { - reactor_->run_reactor_event_loop(); + if (thread_status_timer == Timers::InvalidTimerId) { + //TODO: log error + } } + ThreadStatusManager::Sleeper sleeper(thread_status_manager_); + reactor_->run_reactor_event_loop(); + + if (thread_status_timer != Timers::InvalidTimerId) { + Timers::cancel(reactor_, thread_status_timer); + } return 0; } diff --git a/dds/DCPS/ReactorTask.h b/dds/DCPS/ReactorTask.h index 6b1464250dd..aa9a415bb57 100644 --- a/dds/DCPS/ReactorTask.h +++ b/dds/DCPS/ReactorTask.h @@ -111,11 +111,10 @@ class OpenDDS_Dcps_Export ReactorTask : public virtual ACE_Task_Base, #endif TimerQueueType* timer_queue_; + ReactorInterceptor_rch interceptor_; // thread status reporting String name_; - - ReactorInterceptor_rch interceptor_; ThreadStatusManager* thread_status_manager_; }; diff --git a/dds/DCPS/ThreadStatusManager.h b/dds/DCPS/ThreadStatusManager.h index a848232e4d0..f25eef55b43 100644 --- a/dds/DCPS/ThreadStatusManager.h +++ b/dds/DCPS/ThreadStatusManager.h @@ -9,6 +9,7 @@ #define OPENDDS_DCPS_THREADSTATUSMANAGER_H #include "dcps_export.h" +#include "RcEventHandler.h" #include "TimeTypes.h" OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL @@ -158,6 +159,16 @@ class OpenDDS_Dcps_Export ThreadStatusManager { ThreadStatusManager* const thread_status_manager_; }; + struct Updater : RcEventHandler { + int handle_timeout(const ACE_Time_Value&, const void* arg) + { + const ThreadStatusManager* const tsmConst = static_cast(arg); + ThreadStatusManager* const tsm = const_cast(tsmConst); + tsm->idle(); + return 0; + } + }; + /// Copy active and idle threads to running and finished threads to /// finished. Only threads updated after start are considered. void harvest(const MonotonicTimePoint& start, @@ -188,6 +199,7 @@ class OpenDDS_Dcps_Export ThreadStatusManager { mutable ACE_Thread_Mutex lock_; }; + } // namespace DCPS } // namespace OpenDDS diff --git a/dds/OpenddsDcpsExt.idl b/dds/OpenddsDcpsExt.idl index 84366fd3f89..90b354ee2fd 100644 --- a/dds/OpenddsDcpsExt.idl +++ b/dds/OpenddsDcpsExt.idl @@ -9,6 +9,7 @@ #define OPENDDS_DCPS_EXT_IDL #include +#include #include #if defined __OPENDDS_IDL && !defined DDS_HAS_MINIMUM_BIT @@ -74,6 +75,7 @@ module OpenDDS struct InternalThreadBuiltinTopicData { BUILT_IN_TOPIC_KEY string thread_id; double utilization; + MonotonicTime_t monotonic_timestamp; }; const long LOCATOR_KIND_INVALID = -1; diff --git a/docs/devguide/built_in_topics.rst b/docs/devguide/built_in_topics.rst index 18b41983f51..f6f3ba16d2e 100644 --- a/docs/devguide/built_in_topics.rst +++ b/docs/devguide/built_in_topics.rst @@ -294,3 +294,5 @@ The topic type InternalThreadBuiltinTopicData is defined in :ghfile:`dds/Opendds * ``thread_id`` (key) -- A string identifier for the thread. * ``utilization`` -- Estimated utilization of this thread (0.0-1.0). + +* ``monotonic_timestamp`` -- Time of most recent update (monotonic clock). The SampleInfo's ``source_timestamp`` has the timestamp on the system clock. diff --git a/java/dds/.gitignore b/java/dds/.gitignore index a8b75c343dc..fada886db38 100644 --- a/java/dds/.gitignore +++ b/java/dds/.gitignore @@ -3,14 +3,51 @@ /*.vcproj /BitsExtJC.cpp /BitsJC.cpp +/classes +/DDS__ConditionTAOPeer.h +/DDS__ContentFilteredTopicTAOPeer.h +/DDS__DataReaderListenerTAOPeer.h +/DDS__DataReaderTAOPeer.h +/DDS__DataWriterListenerTAOPeer.h +/DDS__DataWriterTAOPeer.h +/DDS__DomainParticipantFactoryTAOPeer.h +/DDS__DomainParticipantListenerTAOPeer.h +/DDS__DomainParticipantTAOPeer.h +/DDS__EntityTAOPeer.h +/DDS__GuardConditionInterfTAOPeer.h +/DDS__MultiTopicTAOPeer.h +/DDS__ParticipantBuiltinTopicDataDataReaderTAOPeer.h +/DDS__ParticipantBuiltinTopicDataDataWriterTAOPeer.h +/DDS__ParticipantBuiltinTopicDataTypeSupportTAOPeer.h +/DDS__PublicationBuiltinTopicDataDataReaderTAOPeer.h +/DDS__PublicationBuiltinTopicDataDataWriterTAOPeer.h +/DDS__PublicationBuiltinTopicDataTypeSupportTAOPeer.h +/DDS__PublisherListenerTAOPeer.h +/DDS__PublisherTAOPeer.h +/DDS__QueryConditionTAOPeer.h +/DDS__ReadConditionTAOPeer.h +/DDS__StatusConditionTAOPeer.h +/DDS__SubscriberListenerTAOPeer.h +/DDS__SubscriberTAOPeer.h +/DDS__SubscriptionBuiltinTopicDataDataReaderTAOPeer.h +/DDS__SubscriptionBuiltinTopicDataDataWriterTAOPeer.h +/DDS__SubscriptionBuiltinTopicDataTypeSupportTAOPeer.h +/DDS__TopicBuiltinTopicDataDataReaderTAOPeer.h +/DDS__TopicBuiltinTopicDataDataWriterTAOPeer.h +/DDS__TopicBuiltinTopicDataTypeSupportTAOPeer.h +/DDS__TopicDescriptionTAOPeer.h +/DDS__TopicListenerTAOPeer.h +/DDS__TopicTAOPeer.h +/DDS__TypeSupportTAOPeer.h +/DDS__WaitSetInterfTAOPeer.h /DDS_ConditionHelper.h /DDS_ContentFilteredTopicHelper.h /DDS_DATAREADER_QOS_DEFAULT.h /DDS_DATAREADER_QOS_USE_TOPIC_QOS.h -/DDS_DATAWRITER_QOS_DEFAULT.h -/DDS_DATAWRITER_QOS_USE_TOPIC_QOS.h /DDS_DataReaderHelper.h /DDS_DataReaderListenerHelper.h +/DDS_DATAWRITER_QOS_DEFAULT.h +/DDS_DATAWRITER_QOS_USE_TOPIC_QOS.h /DDS_DataWriterHelper.h /DDS_DataWriterListenerHelper.h /DDS_DomainParticipantFactoryHelper.h @@ -22,7 +59,6 @@ /DDS_ListenerHelper.h /DDS_MultiTopicHelper.h /DDS_PARTICIPANT_QOS_DEFAULT.h -/DDS_PUBLISHER_QOS_DEFAULT.h /DDS_ParticipantBuiltinTopicDataDataReaderHelper.h /DDS_ParticipantBuiltinTopicDataDataWriterHelper.h /DDS_ParticipantBuiltinTopicDataTypeSupportHelper.h @@ -31,12 +67,13 @@ /DDS_PublicationBuiltinTopicDataDataWriterHelper.h /DDS_PublicationBuiltinTopicDataTypeSupportHelper.h /DDS_PublicationBuiltinTopicDataTypeSupportImpl.h +/DDS_PUBLISHER_QOS_DEFAULT.h /DDS_PublisherHelper.h /DDS_PublisherListenerHelper.h /DDS_QueryConditionHelper.h /DDS_ReadConditionHelper.h -/DDS_SUBSCRIBER_QOS_DEFAULT.h /DDS_StatusConditionHelper.h +/DDS_SUBSCRIBER_QOS_DEFAULT.h /DDS_SubscriberHelper.h /DDS_SubscriberListenerHelper.h /DDS_SubscriptionBuiltinTopicDataDataReaderHelper.h @@ -54,42 +91,6 @@ /DDS_TypeSupportHelper.h /DDS_WaitSet.h /DDS_WaitSetInterfHelper.h -/DDS__ConditionTAOPeer.h -/DDS__ContentFilteredTopicTAOPeer.h -/DDS__DataReaderListenerTAOPeer.h -/DDS__DataReaderTAOPeer.h -/DDS__DataWriterListenerTAOPeer.h -/DDS__DataWriterTAOPeer.h -/DDS__DomainParticipantFactoryTAOPeer.h -/DDS__DomainParticipantListenerTAOPeer.h -/DDS__DomainParticipantTAOPeer.h -/DDS__EntityTAOPeer.h -/DDS__GuardConditionInterfTAOPeer.h -/DDS__MultiTopicTAOPeer.h -/DDS__ParticipantBuiltinTopicDataDataReaderTAOPeer.h -/DDS__ParticipantBuiltinTopicDataDataWriterTAOPeer.h -/DDS__ParticipantBuiltinTopicDataTypeSupportTAOPeer.h -/DDS__PublicationBuiltinTopicDataDataReaderTAOPeer.h -/DDS__PublicationBuiltinTopicDataDataWriterTAOPeer.h -/DDS__PublicationBuiltinTopicDataTypeSupportTAOPeer.h -/DDS__PublisherListenerTAOPeer.h -/DDS__PublisherTAOPeer.h -/DDS__QueryConditionTAOPeer.h -/DDS__ReadConditionTAOPeer.h -/DDS__StatusConditionTAOPeer.h -/DDS__SubscriberListenerTAOPeer.h -/DDS__SubscriberTAOPeer.h -/DDS__SubscriptionBuiltinTopicDataDataReaderTAOPeer.h -/DDS__SubscriptionBuiltinTopicDataDataWriterTAOPeer.h -/DDS__SubscriptionBuiltinTopicDataTypeSupportTAOPeer.h -/DDS__TopicBuiltinTopicDataDataReaderTAOPeer.h -/DDS__TopicBuiltinTopicDataDataWriterTAOPeer.h -/DDS__TopicBuiltinTopicDataTypeSupportTAOPeer.h -/DDS__TopicDescriptionTAOPeer.h -/DDS__TopicListenerTAOPeer.h -/DDS__TopicTAOPeer.h -/DDS__TypeSupportTAOPeer.h -/DDS__WaitSetInterfTAOPeer.h /DdsDcpsConditionSeqJC.cpp /DdsDcpsConditionSeqJC.h /DdsDcpsCoreJC.cpp @@ -104,6 +105,8 @@ /DdsDcpsDomainJC.h /DdsDcpsGuidJC.cpp /DdsDcpsGuidJC.h +/DdsDcpsInfoUtilsJC.cpp +/DdsDcpsInfoUtilsJC.h /DdsDcpsInfrastructureJC.cpp /DdsDcpsInfrastructureJC.h /DdsDcpsInfrastructureTypeSupportJC.cpp @@ -118,6 +121,20 @@ /DdsDcpsTopicJC.h /DdsDcpsTypeSupportExtJC.cpp /DdsDcpsTypeSupportExtJC.h +/OpenDDS_DCPS__ConfigStoreTAOPeer.h +/OpenDDS_DCPS__ConnectionRecordDataReaderTAOPeer.h +/OpenDDS_DCPS__ConnectionRecordDataWriterTAOPeer.h +/OpenDDS_DCPS__ConnectionRecordTypeSupportTAOPeer.h +/OpenDDS_DCPS__DataReaderExTAOPeer.h +/OpenDDS_DCPS__DataReaderListenerTAOPeer.h +/OpenDDS_DCPS__DataWriterListenerTAOPeer.h +/OpenDDS_DCPS__InternalThreadBuiltinTopicDataDataReaderTAOPeer.h +/OpenDDS_DCPS__InternalThreadBuiltinTopicDataDataWriterTAOPeer.h +/OpenDDS_DCPS__InternalThreadBuiltinTopicDataTypeSupportTAOPeer.h +/OpenDDS_DCPS__ParticipantLocationBuiltinTopicDataDataReaderTAOPeer.h +/OpenDDS_DCPS__ParticipantLocationBuiltinTopicDataDataWriterTAOPeer.h +/OpenDDS_DCPS__ParticipantLocationBuiltinTopicDataTypeSupportTAOPeer.h +/OpenDDS_DCPS__TypeSupportTAOPeer.h /OpenDDS_DCPS_CdrRepresentationFormatHelper.h /OpenDDS_DCPS_ConfigStoreHelper.h /OpenDDS_DCPS_ConnectionRecordDataReaderHelper.h @@ -140,21 +157,6 @@ /OpenDDS_DCPS_RepresentationFormatHelper.h /OpenDDS_DCPS_TheParticipantFactory.h /OpenDDS_DCPS_TheServiceParticipant.h -/OpenDDS_DCPS_TypeSupportHelper.h -/OpenDDS_DCPS__ConfigStoreTAOPeer.h -/OpenDDS_DCPS__ConnectionRecordDataReaderTAOPeer.h -/OpenDDS_DCPS__ConnectionRecordDataWriterTAOPeer.h -/OpenDDS_DCPS__ConnectionRecordTypeSupportTAOPeer.h -/OpenDDS_DCPS__DataReaderExTAOPeer.h -/OpenDDS_DCPS__DataReaderListenerTAOPeer.h -/OpenDDS_DCPS__DataWriterListenerTAOPeer.h -/OpenDDS_DCPS__InternalThreadBuiltinTopicDataDataReaderTAOPeer.h -/OpenDDS_DCPS__InternalThreadBuiltinTopicDataDataWriterTAOPeer.h -/OpenDDS_DCPS__InternalThreadBuiltinTopicDataTypeSupportTAOPeer.h -/OpenDDS_DCPS__ParticipantLocationBuiltinTopicDataDataReaderTAOPeer.h -/OpenDDS_DCPS__ParticipantLocationBuiltinTopicDataDataWriterTAOPeer.h -/OpenDDS_DCPS__ParticipantLocationBuiltinTopicDataTypeSupportTAOPeer.h -/OpenDDS_DCPS__TypeSupportTAOPeer.h /OpenDDS_DCPS_transport_MulticastInst.h /OpenDDS_DCPS_transport_RtpsUdpInst.h /OpenDDS_DCPS_transport_TcpInst.h @@ -162,8 +164,8 @@ /OpenDDS_DCPS_transport_TransportConfig.h /OpenDDS_DCPS_transport_TransportInst.h /OpenDDS_DCPS_transport_UdpInst.h +/OpenDDS_DCPS_TypeSupportHelper.h /OpenddsDcpsExtJC.cpp /OpenddsDcpsExtJC.h /OpenddsDcpsExtTypeSupportJC.cpp /OpenddsDcpsExtTypeSupportJC.h -/classes diff --git a/java/dds/OpenDDS/DCPS/.gitignore b/java/dds/OpenDDS/DCPS/.gitignore index 4d19b4eb4cb..8b523302bc0 100644 --- a/java/dds/OpenDDS/DCPS/.gitignore +++ b/java/dds/OpenDDS/DCPS/.gitignore @@ -1,3 +1,50 @@ +/_CdrRepresentationFormatLocalBase.java +/_CdrRepresentationFormatTAOPeer.java +/_ConfigStoreLocalBase.java +/_ConfigStoreTAOPeer.java +/_ConnectionDataDataReaderLocalBase.java +/_ConnectionDataDataReaderTAOPeer.java +/_ConnectionDataDataWriterLocalBase.java +/_ConnectionDataDataWriterTAOPeer.java +/_ConnectionDataTypeSupportLocalBase.java +/_ConnectionDataTypeSupportTAOPeer.java +/_ConnectionRecordDataReaderLocalBase.java +/_ConnectionRecordDataReaderTAOPeer.java +/_ConnectionRecordDataWriterLocalBase.java +/_ConnectionRecordDataWriterTAOPeer.java +/_ConnectionRecordTypeSupportLocalBase.java +/_ConnectionRecordTypeSupportTAOPeer.java +/_DataReaderExLocalBase.java +/_DataReaderExTAOPeer.java +/_DataReaderListenerLocalBase.java +/_DataReaderListenerTAOPeer.java +/_DataWriterListenerLocalBase.java +/_DataWriterListenerTAOPeer.java +/_DomainParticipantExtLocalBase.java +/_DomainParticipantExtTAOPeer.java +/_InternalThreadBuiltinTopicDataDataReaderLocalBase.java +/_InternalThreadBuiltinTopicDataDataReaderTAOPeer.java +/_InternalThreadBuiltinTopicDataDataWriterLocalBase.java +/_InternalThreadBuiltinTopicDataDataWriterTAOPeer.java +/_InternalThreadBuiltinTopicDataTypeSupportLocalBase.java +/_InternalThreadBuiltinTopicDataTypeSupportTAOPeer.java +/_JsonRepresentationFormatLocalBase.java +/_JsonRepresentationFormatTAOPeer.java +/_ParticipantLocationBuiltinTopicDataDataReaderLocalBase.java +/_ParticipantLocationBuiltinTopicDataDataReaderTAOPeer.java +/_ParticipantLocationBuiltinTopicDataDataWriterLocalBase.java +/_ParticipantLocationBuiltinTopicDataDataWriterTAOPeer.java +/_ParticipantLocationBuiltinTopicDataTypeSupportLocalBase.java +/_ParticipantLocationBuiltinTopicDataTypeSupportTAOPeer.java +/_RepresentationFormatLocalBase.java +/_RepresentationFormatTAOPeer.java +/_SubscriberExtLocalBase.java +/_SubscriberExtTAOPeer.java +/_TypeSupportLocalBase.java +/_TypeSupportTAOPeer.java +/AddDomainStatus.java +/AddDomainStatusHelper.java +/AddDomainStatusHolder.java /ALL_STATUS_MASK.java /BudgetExceededStatus.java /BudgetExceededStatusHelper.java @@ -46,7 +93,9 @@ /ConnectionRecordTypeSupportHolder.java /ConnectionRecordTypeSupportImpl.java /ConnectionRecordTypeSupportOperations.java -/DEFAULT_STATUS_MASK.java +/ContentFilterProperty_t.java +/ContentFilterProperty_tHelper.java +/ContentFilterProperty_tHolder.java /DataReaderEx.java /DataReaderExHelper.java /DataReaderExHolder.java @@ -62,7 +111,14 @@ /DataWriterListenerHelper.java /DataWriterListenerHolder.java /DataWriterListenerOperations.java +/DEFAULT_STATUS_MASK.java /DisassociationStatusHelper.java +/DiscoveredReaderData.java +/DiscoveredReaderDataHelper.java +/DiscoveredReaderDataHolder.java +/DiscoveredWriterData.java +/DiscoveredWriterDataHelper.java +/DiscoveredWriterDataHolder.java /DomainParticipantExt.java /DomainParticipantExtHelper.java /DomainParticipantExtHolder.java @@ -70,6 +126,11 @@ /DurabilityQosPolicyExt.java /DurabilityQosPolicyExtHelper.java /DurabilityQosPolicyExtHolder.java +/EntityId_t.java +/EntityId_tHelper.java +/EntityId_tHolder.java +/EntityKey_tHelper.java +/EntityKey_tHolder.java /ENTITYKIND_BUILTIN_PARTICIPANT.java /ENTITYKIND_BUILTIN_READER_NO_KEY.java /ENTITYKIND_BUILTIN_READER_WITH_KEY.java @@ -87,13 +148,6 @@ /ENTITYKIND_USER_UNKNOWN.java /ENTITYKIND_USER_WRITER_NO_KEY.java /ENTITYKIND_USER_WRITER_WITH_KEY.java -/EntityId_t.java -/EntityId_tHelper.java -/EntityId_tHolder.java -/EntityKey_tHelper.java -/EntityKey_tHolder.java -/GUIDSeqHelper.java -/GUIDSeqHolder.java /GUID_t.java /GUID_tHelper.java /GUID_tHolder.java @@ -104,8 +158,13 @@ /GuidCountSequenceHolder.java /GuidPrefix_tHelper.java /GuidPrefix_tHolder.java +/GUIDSeqHelper.java +/GUIDSeqHolder.java /GuidVendorId_tHelper.java /GuidVendorId_tHolder.java +/IncompatibleQosStatus.java +/IncompatibleQosStatusHelper.java +/IncompatibleQosStatusHolder.java /InternalThreadBuiltinTopicData.java /InternalThreadBuiltinTopicDataDataReader.java /InternalThreadBuiltinTopicDataDataReaderHelper.java @@ -129,6 +188,11 @@ /JsonRepresentationFormatHelper.java /JsonRepresentationFormatHolder.java /JsonRepresentationFormatOperations.java +/LatencyStatistics.java +/LatencyStatisticsHelper.java +/LatencyStatisticsHolder.java +/LatencyStatisticsSeqHelper.java +/LatencyStatisticsSeqHolder.java /LOCATION_ICE.java /LOCATION_ICE6.java /LOCATION_LOCAL.java @@ -140,16 +204,11 @@ /LOCATOR_KIND_UDPv4.java /LOCATOR_KIND_UDPv6.java /LOCATOR_PORT_INVALID.java -/LatencyStatistics.java -/LatencyStatisticsHelper.java -/LatencyStatisticsHolder.java -/LatencyStatisticsSeqHelper.java -/LatencyStatisticsSeqHolder.java -/LocatorSeqHelper.java -/LocatorSeqHolder.java /Locator_t.java /Locator_tHelper.java /Locator_tHolder.java +/LocatorSeqHelper.java +/LocatorSeqHolder.java /MCK_RTPS.java /MCK_STUN.java /MessageCount.java @@ -188,11 +247,20 @@ /PublicationLostStatusHelper.java /PublicationLostStatusHolder.java /PublicationReconnectedStatusHelper.java -/RTPS_RELAY_STUN_PROTOCOL.java +/ReaderAssociation.java +/ReaderAssociationHelper.java +/ReaderAssociationHolder.java +/ReaderIdSeqHelper.java +/ReaderIdSeqHolder.java +/ReaderProxy_t.java +/ReaderProxy_tHelper.java +/ReaderProxy_tHolder.java /RepresentationFormat.java /RepresentationFormatHelper.java /RepresentationFormatHolder.java /RepresentationFormatOperations.java +/RTPS_RELAY_STUN_PROTOCOL.java +/String256Helper.java /SubscriberExt.java /SubscriberExtHelper.java /SubscriberExtHolder.java @@ -202,6 +270,15 @@ /SubscriptionLostStatusHelper.java /SubscriptionLostStatusHolder.java /SubscriptionReconnectedStatusHelper.java +/TopicStatus.java +/TopicStatusHelper.java +/TopicStatusHolder.java +/TransportBLOBHelper.java +/TransportLocator.java +/TransportLocatorHelper.java +/TransportLocatorHolder.java +/TransportLocatorSeqHelper.java +/TransportLocatorSeqHolder.java /TransportStatistics.java /TransportStatisticsHelper.java /TransportStatisticsHolder.java @@ -213,47 +290,11 @@ /TypeSupportOperations.java /UNALIGNED_CDR_DATA_REPRESENTATION.java /UNALIGNED_CDR_DATA_REPRESENTATION.java -/_CdrRepresentationFormatLocalBase.java -/_CdrRepresentationFormatTAOPeer.java -/_ConfigStoreLocalBase.java -/_ConfigStoreTAOPeer.java -/_ConnectionDataDataReaderLocalBase.java -/_ConnectionDataDataReaderTAOPeer.java -/_ConnectionDataDataWriterLocalBase.java -/_ConnectionDataDataWriterTAOPeer.java -/_ConnectionDataTypeSupportLocalBase.java -/_ConnectionDataTypeSupportTAOPeer.java -/_ConnectionRecordDataReaderLocalBase.java -/_ConnectionRecordDataReaderTAOPeer.java -/_ConnectionRecordDataWriterLocalBase.java -/_ConnectionRecordDataWriterTAOPeer.java -/_ConnectionRecordTypeSupportLocalBase.java -/_ConnectionRecordTypeSupportTAOPeer.java -/_DataReaderExLocalBase.java -/_DataReaderExTAOPeer.java -/_DataReaderListenerLocalBase.java -/_DataReaderListenerTAOPeer.java -/_DataWriterListenerLocalBase.java -/_DataWriterListenerTAOPeer.java -/_DomainParticipantExtLocalBase.java -/_DomainParticipantExtTAOPeer.java -/_InternalThreadBuiltinTopicDataDataReaderLocalBase.java -/_InternalThreadBuiltinTopicDataDataReaderTAOPeer.java -/_InternalThreadBuiltinTopicDataDataWriterLocalBase.java -/_InternalThreadBuiltinTopicDataDataWriterTAOPeer.java -/_InternalThreadBuiltinTopicDataTypeSupportLocalBase.java -/_InternalThreadBuiltinTopicDataTypeSupportTAOPeer.java -/_JsonRepresentationFormatLocalBase.java -/_JsonRepresentationFormatTAOPeer.java -/_ParticipantLocationBuiltinTopicDataDataReaderLocalBase.java -/_ParticipantLocationBuiltinTopicDataDataReaderTAOPeer.java -/_ParticipantLocationBuiltinTopicDataDataWriterLocalBase.java -/_ParticipantLocationBuiltinTopicDataDataWriterTAOPeer.java -/_ParticipantLocationBuiltinTopicDataTypeSupportLocalBase.java -/_ParticipantLocationBuiltinTopicDataTypeSupportTAOPeer.java -/_RepresentationFormatLocalBase.java -/_RepresentationFormatTAOPeer.java -/_SubscriberExtLocalBase.java -/_SubscriberExtTAOPeer.java -/_TypeSupportLocalBase.java -/_TypeSupportTAOPeer.java +/WriterAssociation.java +/WriterAssociationHelper.java +/WriterAssociationHolder.java +/WriterIdSeqHelper.java +/WriterIdSeqHolder.java +/WriterProxy_t.java +/WriterProxy_tHelper.java +/WriterProxy_tHolder.java diff --git a/java/dds/dcps_java.mpc b/java/dds/dcps_java.mpc index 8bed02fdf28..d9d5f91d118 100644 --- a/java/dds/dcps_java.mpc +++ b/java/dds/dcps_java.mpc @@ -24,7 +24,8 @@ project: idl2jni, javah, dcpslib, optional_jni_check, dcps_java_optional, dcps_m Idl2Jni_Files { $(DDS_ROOT)/dds/DdsDcpsCore.idl - $(DDS_ROOT)/dds/OpenddsDcpsExt.idl + $(DDS_ROOT)/dds/DdsDcpsInfoUtils.idl + $(DDS_ROOT)/dds/OpenddsDcpsExt.idl << DdsDcpsInfoUtilsJC.h $(DDS_ROOT)/dds/DdsDcpsInfrastructure.idl << DdsDcpsConditionSeqJC.h $(DDS_ROOT)/dds/DdsDcpsDomain.idl << DdsDcpsTopicJC.h DdsDcpsSubscriptionJC.h DdsDcpsPublicationJC.h $(DDS_ROOT)/dds/DdsDcpsGuid.idl diff --git a/java/tests/internal_thread_status/InternalThreadListener.java b/java/tests/internal_thread_status/InternalThreadListener.java index 76fc50e8c80..628c8e8e611 100644 --- a/java/tests/internal_thread_status/InternalThreadListener.java +++ b/java/tests/internal_thread_status/InternalThreadListener.java @@ -36,7 +36,7 @@ public synchronized void on_data_available(DDS.DataReader reader) { InternalThreadBuiltinTopicDataHolder info = new InternalThreadBuiltinTopicDataHolder( - new InternalThreadBuiltinTopicData("", 0.0)); + new InternalThreadBuiltinTopicData("", 0.0, new MonotonicTime_t())); SampleInfoHolder si = new SampleInfoHolder(new SampleInfo(0, 0, 0, new DDS.Time_t(), 0, 0, 0, 0, 0, 0, 0, false, 0)); @@ -48,6 +48,7 @@ public synchronized void on_data_available(DDS.DataReader reader) { System.out.println("== " + id + " Thread Info =="); System.out.println(" tid: " + info.value.thread_id); System.out.println("utilization: " + info.value.utilization); + System.out.println(" monotonic: " + info.value.monotonic_timestamp.sec); System.out.println(" time: " + si.value.source_timestamp.sec); } } diff --git a/tests/DCPS/InternalThreadStatus/InternalThreadStatusListenerImpl.cpp b/tests/DCPS/InternalThreadStatus/InternalThreadStatusListenerImpl.cpp index ca1043547a4..9f21a0138bc 100644 --- a/tests/DCPS/InternalThreadStatus/InternalThreadStatusListenerImpl.cpp +++ b/tests/DCPS/InternalThreadStatus/InternalThreadStatusListenerImpl.cpp @@ -58,6 +58,7 @@ void InternalThreadStatusListenerImpl::on_data_available(DDS::DataReader_ptr rea std::cout << " tid: " << thread_info.thread_id << "\n" + << "mtime: " << thread_info.monotonic_timestamp.sec << '\n' << " time: " << si.source_timestamp.sec << std::endl; } } From ec9b87429c2a0312388b0593f63b949bd2f6fdab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 07:41:48 +0000 Subject: [PATCH 37/60] Bump docker/login-action from 3.1.0 to 3.2.0 Bumps [docker/login-action](https://github.com/docker/login-action) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/e92390c5fb421da1463c202d546fed0ec5c39f20...0d4c9c5ea7693da7b068278f7b52bda2a190a446) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_image.yml b/.github/workflows/docker_image.yml index 49dda7dbc81..e839981b014 100644 --- a/.github/workflows/docker_image.yml +++ b/.github/workflows/docker_image.yml @@ -31,7 +31,7 @@ jobs: submodules: true - name: Log in to the Container registry - uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} From 83529ddc190aff74d4970c8691e19056f01acabb Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 3 Jun 2024 18:54:21 -0500 Subject: [PATCH 38/60] Check HOST_TOOLS_ONLY and Test with CMake 3.23 --- .github/workflows/cmake.yml | 16 ++++++++++++---- cmake/build_ace_tao.cmake | 15 ++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index e5844185c41..e851fb6c86d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -168,8 +168,10 @@ jobs: with: repository: DOCGroup/ACE_TAO path: OpenDDS/build/ACE_TAO - - name: Install Ninja - run: sudo apt-get -y install ninja-build + - uses: lukka/get-cmake@latest + with: + cmakeVersion: "3.23" + ninjaVersion: "latest" - name: Configure run: | cd OpenDDS @@ -213,8 +215,10 @@ jobs: with: ndk-version: r25c add-to-path: false - - name: Install Ninja - run: sudo apt-get -y install ninja-build + - uses: lukka/get-cmake@latest + with: + cmakeVersion: "3.23" + ninjaVersion: "latest" - name: Configure Host Tools run: | cd OpenDDS @@ -315,6 +319,10 @@ jobs: with: vcpkgGitCommitId: '${{ env.VCPKG_GIT_COMMIT }}' runVcpkgInstall: true + - uses: lukka/get-cmake@latest + with: + cmakeVersion: "3.23" + ninjaVersion: "latest" - name: Checkout OpenDDS uses: actions/checkout@v4 with: diff --git a/cmake/build_ace_tao.cmake b/cmake/build_ace_tao.cmake index 98022b6f517..c1cba68d12c 100644 --- a/cmake/build_ace_tao.cmake +++ b/cmake/build_ace_tao.cmake @@ -1,5 +1,6 @@ include(ExternalProject) +set(_opendds_std_target OpenDDS_Dcps) if(OPENDDS_JUST_BUILD_HOST_TOOLS) set(ws "${OPENDDS_BUILD_DIR}/host-tools.mwc") file(WRITE "${ws}" @@ -10,8 +11,13 @@ if(OPENDDS_JUST_BUILD_HOST_TOOLS) "}\n" ) list(APPEND _OPENDDS_CONFIGURE_ACE_TAO_ARGS "--workspace-file=${ws}") + set(_opendds_std_target opendds_idl) endif() +# Get the C++ standard OpenDDS is going to be built with. We are going to force +# the ACE/TAO build to use the same standard. +set(_opendds_std "$") + find_package(Perl REQUIRED) if(OPENDDS_STATIC) list(APPEND _OPENDDS_CONFIGURE_ACE_TAO_ARGS --static=1) @@ -34,15 +40,6 @@ execute_process( COMMAND_ERROR_IS_FATAL ANY ) -# Get the C++ standard OpenDDS is going to be built with. We are going to force -# the ACE/TAO build to use the same standard. -if(TARGET OpenDDS_Dcps) - set(_opendds_std_target OpenDDS_Dcps) -else() - set(_opendds_std_target opendds_idl) -endif() -set(_opendds_std "$") - set(_build_cmd "${CMAKE_COMMAND}" -E env "ACE_ROOT=${OPENDDS_ACE}" "TAO_ROOT=${OPENDDS_TAO}") if(_OPENDDS_XERCES3_FOR_ACE) list(APPEND _build_cmd "XERCESCROOT=${_OPENDDS_XERCES3_FOR_ACE}") From cd8856e728c94e14dcc56fa367edefe57d0eb851 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 3 Jun 2024 19:39:24 -0500 Subject: [PATCH 39/60] Fix OMG-Related Link Checking Issues - Ignore `dds-foundation.org` and `corba.org`, which have been returning 403 for a while - Ignore login redirect on spec issues - Completely omit generating links to all the spec sections when running `linkcheck` --- docs/build.py | 7 ++++--- docs/conf.py | 4 ++++ docs/sphinx_extensions/links.py | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/build.py b/docs/build.py index 85c4b9c150b..4df22267a48 100755 --- a/docs/build.py +++ b/docs/build.py @@ -8,6 +8,7 @@ import os import venv import webbrowser +import itertools from subprocess import check_call from shutil import rmtree from argparse import ArgumentParser @@ -80,9 +81,9 @@ def setup(self, force_new=False): self.venv_path.touch() self.rm_build() - def sphinx_build(self, builder, *args): + def sphinx_build(self, builder, *args, defines=[]): args = list(args) - for define in self.conf_defines: + for define in itertools.chain(self.conf_defines, defines): args.append('-D' + define) if self.debug: args.append('-vv') @@ -118,7 +119,7 @@ def do_test(self): def do_strict(self): self.do(['test'], because_of='strict') self.sphinx_build('dummy', '-W') - self.sphinx_build('linkcheck') + self.sphinx_build('linkcheck', defines=['gen_all_omg_spec_links=False']) return None def do_html(self): diff --git a/docs/conf.py b/docs/conf.py index f9c5e13e753..855c79e8f00 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -145,8 +145,12 @@ def setup(app): r'^https?://github\.com/.*#.+$', # Returns 403 for some reason r'^https?://docs\.github\.com/.*$', + r'^https://www.dds-foundation.org/.*$', + r'^https://www.corba.org/.*$', # UTF-8 decode errors (trying to parse PDF as HTML?), shouldn't check these anyways r'^https?://www\.omg\.org/spec/.*/PDF.*$', + # OMG Member link, will always redirect to a login page + r'https://issues.omg.org/browse/.*$' ] intersphinx_mapping = { diff --git a/docs/sphinx_extensions/links.py b/docs/sphinx_extensions/links.py index 8d4222abbd3..63d321f39c8 100644 --- a/docs/sphinx_extensions/links.py +++ b/docs/sphinx_extensions/links.py @@ -375,7 +375,7 @@ def run(self): p += nodes.literal('', spec_name) p += nodes.inline('', ')') spec_node += p - if 'debug-links' in self.options: + if 'debug-links' in self.options and not self.env.app.config.gen_all_omg_spec_links: self.spec_sections(spec, spec_node, spec['sections']) specs_node += spec_node return [specs_node] @@ -395,6 +395,7 @@ def setup(app): app.add_role('acetaorel', acetaorel_role) app.add_config_value('omg_specs', {}, 'env', types=[dict]) + app.add_config_value('gen_all_omg_spec_links', True, 'env', types=[bool]) app.add_role('omgissue', omgissue_role) app.add_role('omgspec', omgspec_role) app.add_directive("omgspecs", OmgSpecsDirective) From 82908f3ae98afde2d5b225ea2435ef5e533e4a60 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Mon, 3 Jun 2024 19:52:18 -0500 Subject: [PATCH 40/60] Ninja needs CMake 3.24 to build ACE/TAO --- .github/workflows/cmake.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index e851fb6c86d..c4269529c05 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -82,6 +82,10 @@ jobs: path: OpenDDS/build/ACE_TAO - name: Install xerces run: sudo apt-get -y install libxerces-c-dev + - uses: lukka/get-cmake@latest + with: + cmakeVersion: "3.23" + ninjaVersion: "latest" - name: Configure run: | cd OpenDDS @@ -170,7 +174,7 @@ jobs: path: OpenDDS/build/ACE_TAO - uses: lukka/get-cmake@latest with: - cmakeVersion: "3.23" + cmakeVersion: "latest" ninjaVersion: "latest" - name: Configure run: | @@ -217,7 +221,7 @@ jobs: add-to-path: false - uses: lukka/get-cmake@latest with: - cmakeVersion: "3.23" + cmakeVersion: "3.24" ninjaVersion: "latest" - name: Configure Host Tools run: | From ca47c82eb4333050a803916c33f5e32e918ecbbe Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Tue, 4 Jun 2024 09:44:43 +0200 Subject: [PATCH 41/60] Add feature to disable inlcude of dds/OpenDDSConfig.h when compiling an IDL file * MPC/config/dcps_optional_features.mpb: --- MPC/config/dcps_optional_features.mpb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MPC/config/dcps_optional_features.mpb b/MPC/config/dcps_optional_features.mpb index 2040b65b555..8fe6e6f2203 100644 --- a/MPC/config/dcps_optional_features.mpb +++ b/MPC/config/dcps_optional_features.mpb @@ -59,5 +59,10 @@ feature (!no_opendds_security) : taoidldefaults, dcps_ts_defaults { dcps_ts_flags += -DOPENDDS_SECURITY } +feature (!openddsconfig_h_file) : taoidldefaults, dcps_ts_defaults { + idlflags += -DOPENDDS_IGNORE_OPENDDSCONFIG_H_FILE + dcps_ts_flags += -DOPENDDS_IGNORE_OPENDDSCONFIG_H_FILE +} + project: dcps_optional_bidir_giop { } From 5d7cbb4514cc30bf65dfd9c280990b6fc9ea62c6 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Mon, 3 Jun 2024 19:24:41 +0000 Subject: [PATCH 42/60] Add more CI testing --- .github/workflows/bootime.yaml | 288 +++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 .github/workflows/bootime.yaml diff --git a/.github/workflows/bootime.yaml b/.github/workflows/bootime.yaml new file mode 100644 index 00000000000..aacd9ce7d95 --- /dev/null +++ b/.github/workflows/bootime.yaml @@ -0,0 +1,288 @@ +name: "Bootime Builds" + +on: + push: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + TRIGGERING_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }} + +jobs: + ACE_TAO_u22_i0_xer0: + + runs-on: ubuntu-22.04 + + steps: + - name: checkout OpenDDS + uses: actions/checkout@v4 + with: + path: OpenDDS + submodules: true + - name: checkout ACE_TAO + uses: actions/checkout@v4 + with: + repository: DOCGroup/ACE_TAO + ref: ace6tao2 + path: OpenDDS/ACE_TAO + - name: get ACE_TAO commit + shell: bash + run: | + cd OpenDDS/ACE_TAO + export ACE_COMMIT=$(git rev-parse HEAD) + echo "ACE_COMMIT=$ACE_COMMIT" >> $GITHUB_ENV + - name: get compiler version + shell: bash + run: | + export COMPILER_VERSION=$(g++ --version 2>&1 | head -n 1) + echo "COMPILER_VERSION=$COMPILER_VERSION" >> $GITHUB_ENV + - name: Cache Artifact + id: cache-artifact + uses: actions/cache@v4 + with: + path: ${{ github.job }}.tar.xz + key: c01_${{ github.job }}_ace6tao2_${{ env.ACE_COMMIT }}_${{ env.COMPILER_VERSION }} + - name: checkout MPC + if: steps.cache-artifact.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: DOCGroup/MPC + path: MPC + - name: configure OpenDDS + if: steps.cache-artifact.outputs.cache-hit != 'true' + run: | + cd OpenDDS + ./configure --std=c++20 --no-inline --tests --ace=$GITHUB_WORKSPACE/OpenDDS/ACE_TAO/ACE --mpc=$GITHUB_WORKSPACE/MPC --compile-warnings=WARNING + - name: build ACE and TAO + if: steps.cache-artifact.outputs.cache-hit != 'true' + run: | + cd OpenDDS + . setenv.sh + cd ACE_TAO/ACE + make -j4 + cd ../TAO + make -j4 + - name: create ACE_TAO tar.xz artifact + if: steps.cache-artifact.outputs.cache-hit != 'true' + shell: bash + run: | + cd OpenDDS/ACE_TAO + perl -ni.bak -e "print unless /opendds/" ACE/bin/MakeProjectCreator/config/default.features # remove opendds features from here, let individual build configure scripts handle those + find . -iname "*\.o" | xargs rm + tar cvf ../../${{ github.job }}.tar ACE/ace/config.h + git clean -xdfn | cut -d ' ' -f 3- | xargs tar uvf ../../${{ github.job }}.tar + xz -3 ../../${{ github.job }}.tar + - name: upload ACE_TAO artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ github.job }}_artifact + path: ${{ github.job }}.tar.xz + + build_u22_i0_xer0: + + runs-on: ubuntu-22.04 + + needs: ACE_TAO_u22_i0_xer0 + + steps: + - name: checkout MPC + uses: actions/checkout@v4 + with: + repository: DOCGroup/MPC + path: MPC + - name: checkout ACE_TAO + uses: actions/checkout@v4 + with: + repository: DOCGroup/ACE_TAO + ref: ace6tao2 + path: ACE_TAO + - name: download ACE_TAO artifact + uses: actions/download-artifact@v4 + with: + name: ACE_TAO_u22_i0_xer0_artifact + path: ACE_TAO + - name: extract ACE_TAO artifact + shell: bash + run: | + cd ACE_TAO + tar xvfJ ACE_TAO_u22_i0_xer0.tar.xz + - name: checkout OpenDDS + uses: actions/checkout@v4 + with: + path: OpenDDS + submodules: true + - name: configure OpenDDS + run: | + cd OpenDDS + ./configure --std=c++20 --no-inline --tests --rapidjson --boottime --ace=$GITHUB_WORKSPACE/ACE_TAO/ACE --mpc=$GITHUB_WORKSPACE/MPC --compile-warnings=WARNING + - name: check build configuration + shell: bash + run: | + cd OpenDDS + . setenv.sh + tools/scripts/show_build_config.pl + - uses: ammaraskar/gcc-problem-matcher@0.3.0 + - name: build OpenDDS + shell: bash + run: | + cd OpenDDS + . setenv.sh + make -j4 + - name: Build CMake Tests + run: | + source OpenDDS/setenv.sh + mkdir OpenDDS/tests/cmake/build + cd OpenDDS/tests/cmake/build + cmake .. + cmake --build . -- -j4 + - name: create OpenDDS tar.xz artifact + shell: bash + run: | + cd OpenDDS + rm -rf ACE_TAO + find . -iname "*\.o" | xargs rm + tar cvf ../${{ github.job }}.tar setenv.sh + git clean -xdfn | cut -d ' ' -f 3- | xargs tar uvf ../${{ github.job }}.tar + xz -3 ../${{ github.job }}.tar + - name: upload OpenDDS artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ github.job }}_artifact + path: ${{ github.job }}.tar.xz + + test_u22_i0_xer0: + + runs-on: ubuntu-22.04 + + needs: build_u22_i0_xer0 + + permissions: + contents: read + id-token: write + + steps: + - name: update apt + run: sudo apt-get update + - name: install dependencies + run: sudo apt-get -y install libxerces-c-dev wireshark-dev tshark qtbase5-dev + - name: checkout MPC + uses: actions/checkout@v4 + with: + repository: DOCGroup/MPC + path: MPC + - name: checkout autobuild + uses: actions/checkout@v4 + with: + repository: DOCGroup/autobuild + path: autobuild + - name: checkout ACE_TAO + uses: actions/checkout@v4 + with: + repository: DOCGroup/ACE_TAO + ref: ace6tao2 + path: ACE_TAO + - name: download ACE_TAO artifact + uses: actions/download-artifact@v4 + with: + name: ACE_TAO_u22_i0_xer0_artifact + path: ACE_TAO + - name: extract ACE_TAO artifact + shell: bash + run: | + cd ACE_TAO + tar xvfJ ACE_TAO_u22_i0_xer0.tar.xz + - name: checkout OpenDDS + uses: actions/checkout@v4 + with: + path: OpenDDS + submodules: true + - name: download OpenDDS artifact + uses: actions/download-artifact@v4 + with: + name: build_u22_i0_xer0_artifact + path: OpenDDS + - name: extract OpenDDS artifact + shell: bash + run: | + cd OpenDDS + tar xvfJ build_u22_i0_xer0.tar.xz + - name: check build configuration + shell: bash + run: | + cd OpenDDS + . setenv.sh + tools/scripts/show_build_config.pl + - name: install gdb + shell: bash + run: | + sudo apt-get update + sudo apt-get install gdb + echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope + - name: change core file pattern + shell: bash + run: | + sudo sysctl -w kernel.core_pattern=core.%e.%p + echo Core file pattern set to: + cat /proc/sys/kernel/core_pattern + - name: run OpenDDS tests + shell: bash + run: | + ulimit -c unlimited + cd OpenDDS + echo "export ACE_TEST_LOG_STUCK_STACKS=1" >> setenv.sh + . setenv.sh + mkdir ${{ github.job }}_autobuild_workspace + cd ${{ github.job }}_autobuild_workspace + echo using commit $TRIGGERING_COMMIT for SHA + echo $TRIGGERING_COMMIT >> ./SHA + cat > config.xml < + + + + + + + + + + + + + + + + + + + + EOF + $GITHUB_WORKSPACE/autobuild/autobuild.pl "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/config.xml" + - name: upload autobuild output + uses: actions/upload-artifact@v4 + with: + name: ${{ github.job }}_autobuild_output + path: OpenDDS/${{ github.job }}_autobuild_workspace + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v2 + with: + workload_identity_provider: projects/30587790497/locations/global/workloadIdentityPools/gha-scoreboard-upload/providers/gha-provider + service_account: gha-scoreboard-uploader@opendds-support.iam.gserviceaccount.com + if: ${{ github.repository == 'OpenDDS/OpenDDS' && github.ref == 'refs/heads/master' }} + - name: upload to Google Cloud + uses: 'google-github-actions/upload-cloud-storage@v2' + with: + path: OpenDDS/${{ github.job }}_autobuild_workspace/logs + destination: opendds-gha-scoreboard-uploads/${{ github.job }} + parent: false + process_gcloudignore: false + if: ${{ github.repository == 'OpenDDS/OpenDDS' && github.ref == 'refs/heads/master' }} + - name: check results + shell: bash + run: | + $GITHUB_WORKSPACE/OpenDDS/tools/scripts/autobuild_brief_html_to_text.pl "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/"*_Brief.html + cat "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" + grep -q 'Failures: 0' "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" From de5ffa42110f2bc6b4b89fdbdb8e03f0f91a8cc3 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Tue, 4 Jun 2024 20:42:04 +0000 Subject: [PATCH 43/60] Update GitHub Actions CI Run complete test suite for build_u22_gcc11_i0_xer0. Renamed it to build_u22_i0_xer0 since the default compiler on Ubuntu 22.04 is GCC 11 --- .github/workflows/build_and_test.yml | 38 ++++++++++++---------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index d436ed6bc8a..7c4dadae6aa 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -2636,14 +2636,11 @@ jobs: cat "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" grep -q 'Failures: 0' "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" - ACE_TAO_u22_gcc11_i0_xer0: + ACE_TAO_u22_i0_xer0: runs-on: ubuntu-22.04 steps: - - name: install gcc and g++ - run: | - sudo apt-get install g++-11 - name: checkout OpenDDS uses: actions/checkout@v4 with: @@ -2664,7 +2661,7 @@ jobs: - name: get compiler version shell: bash run: | - export COMPILER_VERSION=$(g++-11 --version 2>&1 | head -n 1) + export COMPILER_VERSION=$(g++ --version 2>&1 | head -n 1) echo "COMPILER_VERSION=$COMPILER_VERSION" >> $GITHUB_ENV - name: Cache Artifact id: cache-artifact @@ -2682,7 +2679,7 @@ jobs: if: steps.cache-artifact.outputs.cache-hit != 'true' run: | cd OpenDDS - ./configure --compiler=g++-11 --std=c++20 --no-inline --tests --ace=$GITHUB_WORKSPACE/OpenDDS/ACE_TAO/ACE --mpc=$GITHUB_WORKSPACE/MPC --compile-warnings=WARNING + ./configure --std=c++20 --no-inline --tests --ace=$GITHUB_WORKSPACE/OpenDDS/ACE_TAO/ACE --mpc=$GITHUB_WORKSPACE/MPC --compile-warnings=WARNING - name: build ACE and TAO if: steps.cache-artifact.outputs.cache-hit != 'true' run: | @@ -2708,16 +2705,13 @@ jobs: name: ${{ github.job }}_artifact path: ${{ github.job }}.tar.xz - build_u22_gcc11_i0_xer0: + build_u22_i0_xer0: runs-on: ubuntu-22.04 - needs: ACE_TAO_u22_gcc11_i0_xer0 + needs: ACE_TAO_u22_i0_xer0 steps: - - name: install gcc and g++ - run: | - sudo apt-get install g++-11 - name: checkout MPC uses: actions/checkout@v4 with: @@ -2732,13 +2726,13 @@ jobs: - name: download ACE_TAO artifact uses: actions/download-artifact@v4 with: - name: ACE_TAO_u22_gcc11_i0_xer0_artifact + name: ACE_TAO_u22_i0_xer0_artifact path: ACE_TAO - name: extract ACE_TAO artifact shell: bash run: | cd ACE_TAO - tar xvfJ ACE_TAO_u22_gcc11_i0_xer0.tar.xz + tar xvfJ ACE_TAO_u22_i0_xer0.tar.xz - name: checkout OpenDDS uses: actions/checkout@v4 with: @@ -2747,7 +2741,7 @@ jobs: - name: configure OpenDDS run: | cd OpenDDS - ./configure --compiler=g++-11 --std=c++20 --no-inline --tests --rapidjson --boottime --ace=$GITHUB_WORKSPACE/ACE_TAO/ACE --mpc=$GITHUB_WORKSPACE/MPC --compile-warnings=WARNING + ./configure --std=c++20 --no-inline --tests --rapidjson --boottime --ace=$GITHUB_WORKSPACE/ACE_TAO/ACE --mpc=$GITHUB_WORKSPACE/MPC --compile-warnings=WARNING - name: check build configuration shell: bash run: | @@ -2766,7 +2760,7 @@ jobs: source OpenDDS/setenv.sh mkdir OpenDDS/tests/cmake/build cd OpenDDS/tests/cmake/build - cmake -DCMAKE_CXX_COMPILER=g++-11 .. + cmake .. cmake --build . -- -j4 - name: create OpenDDS tar.xz artifact shell: bash @@ -2783,11 +2777,11 @@ jobs: name: ${{ github.job }}_artifact path: ${{ github.job }}.tar.xz - cmake_u22_gcc11_i0_xer0: + test_u22_i0_xer0: runs-on: ubuntu-22.04 - needs: build_u22_gcc11_i0_xer0 + needs: build_u22_i0_xer0 permissions: contents: read @@ -2813,13 +2807,13 @@ jobs: - name: download ACE_TAO artifact uses: actions/download-artifact@v4 with: - name: ACE_TAO_u22_gcc11_i0_xer0_artifact + name: ACE_TAO_u22_i0_xer0_artifact path: ACE_TAO - name: extract ACE_TAO artifact shell: bash run: | cd ACE_TAO - tar xvfJ ACE_TAO_u22_gcc11_i0_xer0.tar.xz + tar xvfJ ACE_TAO_u22_i0_xer0.tar.xz - name: checkout OpenDDS uses: actions/checkout@v4 with: @@ -2828,13 +2822,13 @@ jobs: - name: download OpenDDS artifact uses: actions/download-artifact@v4 with: - name: build_u22_gcc11_i0_xer0_artifact + name: build_u22_i0_xer0_artifact path: OpenDDS - name: extract OpenDDS artifact shell: bash run: | cd OpenDDS - tar xvfJ build_u22_gcc11_i0_xer0.tar.xz + tar xvfJ build_u22_i0_xer0.tar.xz - name: check build configuration shell: bash run: | @@ -2881,7 +2875,7 @@ jobs: - + From 9881fd52cc98430286e1335724384588892ac9ac Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Tue, 4 Jun 2024 20:48:21 +0000 Subject: [PATCH 44/60] updated test config file for faster SPDP --- tests/DCPS/InternalThreadStatus/rtps.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/DCPS/InternalThreadStatus/rtps.ini b/tests/DCPS/InternalThreadStatus/rtps.ini index 6c77fe6aa01..a865ae6c39e 100644 --- a/tests/DCPS/InternalThreadStatus/rtps.ini +++ b/tests/DCPS/InternalThreadStatus/rtps.ini @@ -11,3 +11,4 @@ transport_type=rtps_udp DiscoveryConfig=application_rtps_discovery [rtps_discovery/application_rtps_discovery] +ResendPeriod=2 From 2cb7414f81d3ddfaa7825d4219716d45a7bd609a Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Tue, 4 Jun 2024 22:34:44 +0000 Subject: [PATCH 45/60] Allow constructing a TimePoint_T (which should be using a monotonic clock) from MonotonicTime_T --- dds/DCPS/TimePoint_T.h | 1 + dds/DCPS/TimePoint_T.inl | 7 +++++++ dds/DCPS/Time_Helper.h | 8 ++++++-- dds/DCPS/Time_Helper.inl | 7 ------- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dds/DCPS/TimePoint_T.h b/dds/DCPS/TimePoint_T.h index 783edc8d132..5d5432030df 100644 --- a/dds/DCPS/TimePoint_T.h +++ b/dds/DCPS/TimePoint_T.h @@ -58,6 +58,7 @@ class TimePoint_T : public SafeBool_T > { explicit TimePoint_T(const ACE_Time_Value& ace_time_value); explicit TimePoint_T(const ACE_Time_Value_T& ace_time_value); explicit TimePoint_T(const DDS::Time_t& dds_time); + explicit TimePoint_T(const MonotonicTime_t& monotonic_time); ///@} /** diff --git a/dds/DCPS/TimePoint_T.inl b/dds/DCPS/TimePoint_T.inl index 8567f6a0eab..b98317682d5 100644 --- a/dds/DCPS/TimePoint_T.inl +++ b/dds/DCPS/TimePoint_T.inl @@ -35,6 +35,13 @@ TimePoint_T::TimePoint_T(const DDS::Time_t& dds_time) { } +template +ACE_INLINE +TimePoint_T::TimePoint_T(const MonotonicTime_t& monotonic_time) +: value_(time_to_time_value(monotonic_time)) +{ +} + template ACE_INLINE TimePoint_T diff --git a/dds/DCPS/Time_Helper.h b/dds/DCPS/Time_Helper.h index aa20ab12445..7878545ce11 100644 --- a/dds/DCPS/Time_Helper.h +++ b/dds/DCPS/Time_Helper.h @@ -23,8 +23,12 @@ OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { namespace DCPS { -ACE_INLINE OpenDDS_Dcps_Export -ACE_Time_Value time_to_time_value(const DDS::Time_t& t); +template +ACE_Time_Value time_to_time_value(const TimeT& t) +{ + ACE_Time_Value tv(t.sec, t.nanosec / 1000); + return tv; +} ACE_INLINE OpenDDS_Dcps_Export DDS::Time_t time_value_to_time(const ACE_Time_Value& tv); diff --git a/dds/DCPS/Time_Helper.inl b/dds/DCPS/Time_Helper.inl index 83c850e60bb..a4589a6684d 100644 --- a/dds/DCPS/Time_Helper.inl +++ b/dds/DCPS/Time_Helper.inl @@ -191,13 +191,6 @@ operator==(const MonotonicTime_t& t1, const MonotonicTime_t& t2) } #endif -ACE_INLINE -ACE_Time_Value time_to_time_value(const DDS::Time_t& t) -{ - ACE_Time_Value tv(t.sec, t.nanosec / 1000); - return tv; -} - ACE_INLINE DDS::Time_t time_value_to_time(const ACE_Time_Value& tv) { From bb6c53bcb8ed64dedf584cec1a8c6842dbf22e41 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Wed, 5 Jun 2024 14:25:35 +0000 Subject: [PATCH 46/60] fixed compiler warning --- dds/DCPS/Hash.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dds/DCPS/Hash.cpp b/dds/DCPS/Hash.cpp index fbf4846112e..9aeae185226 100644 --- a/dds/DCPS/Hash.cpp +++ b/dds/DCPS/Hash.cpp @@ -251,7 +251,7 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) } memcpy(&ctx->buffer[used], data, free); - data = (unsigned char *)data + free; + data = (const unsigned char *)data + free; size -= free; body(ctx, ctx->buffer, 64); } From 2b06e3e8b33168d651818868027112576e469357 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Wed, 5 Jun 2024 15:00:27 +0000 Subject: [PATCH 47/60] Boottime timers: allow negative delay values --- dds/DCPS/Timers.cpp | 9 ++++++--- tests/unit-tests/dds/DCPS/Timers.cpp | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dds/DCPS/Timers.cpp b/dds/DCPS/Timers.cpp index d935d4abe9f..87bc8cf8624 100644 --- a/dds/DCPS/Timers.cpp +++ b/dds/DCPS/Timers.cpp @@ -90,13 +90,16 @@ TimerId schedule(ACE_Reactor* reactor, } return InvalidTimerId; } + static const timespec one_ns = {0, 1}; itimerspec ts; ts.it_interval = interval.value(); - if (delay == TimeDuration()) { + if (delay < TimeDuration::zero_value) { + // expiration in the past, execute as soon as possible (see note about zeros below) + ts.it_value = one_ns; + } else if (delay == TimeDuration::zero_value) { // avoid zeros since that would disarm the timer // if the interval is positive, use that as the initial expiration - static const timespec one = {0, 1}; - ts.it_value = (interval == TimeDuration()) ? one : interval.value(); + ts.it_value = (interval == TimeDuration::zero_value) ? one_ns : interval.value(); } else { ts.it_value = delay.value(); } diff --git a/tests/unit-tests/dds/DCPS/Timers.cpp b/tests/unit-tests/dds/DCPS/Timers.cpp index e466857ee85..1d86c648001 100644 --- a/tests/unit-tests/dds/DCPS/Timers.cpp +++ b/tests/unit-tests/dds/DCPS/Timers.cpp @@ -64,3 +64,18 @@ TEST(dds_DCPS_Timers, test_immediate) ASSERT_EQ(handler->calls_, 1); Timers::cancel(&reactor, id); } + +TEST(dds_DCPS_Timers, test_negative) +{ + RcHandle handler = make_rch(); + ACE_Reactor reactor(new ACE_Select_Reactor, true); + + const Timers::TimerId id = Timers::schedule(&reactor, *handler, 0, TimeDuration(-23)); + ASSERT_NE(id, Timers::InvalidTimerId); + + ACE_Time_Value one_sec(1); + reactor.handle_events(one_sec); + + ASSERT_EQ(handler->calls_, 1); + Timers::cancel(&reactor, id); +} From 151be8b43048d1e2ee02834a92cac30c2418c7cb Mon Sep 17 00:00:00 2001 From: Justin Wilson Date: Wed, 5 Jun 2024 13:55:06 -0500 Subject: [PATCH 48/60] Clarify windows build instructions --- docs/devguide/building/index.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/devguide/building/index.rst b/docs/devguide/building/index.rst index caf04045057..173782552b8 100644 --- a/docs/devguide/building/index.rst +++ b/docs/devguide/building/index.rst @@ -84,6 +84,8 @@ If configure runs successfully it will end with a message about the next steps f .. tab:: Windows The configure script will say how to open the solution file for OpenDDS in Visual Studio using ``devenv``. + Before building, check that the "Configuration" and "Platform" are correct. + In Visual Studio, select "Build" and then "Build Solution". It can also be built directly from the command prompt by using MSBuild. For example, if the configure script was ran without any arguments, to do a Debug x64 build: From 9d4dd9e7d99d61a0d89c087d073a2701c8b0413c Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 5 Jun 2024 14:55:32 -0500 Subject: [PATCH 49/60] README: Fix Link and Use Direct Quick Start Links --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7bdf2fb3ac8..b74a14058b0 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ If you wish to file a bug report: 4. Add a launcher script `run_test.pl`. Be sure to document the options. See `tests/DCPS/HelloWorld/run_test.pl` for inspiration. 5. Add a `README.rst` file that gives a high-level overview of the example and the problem that it illustrates. -It should be possible to build and run the example using `run_test.pl` as in the quickstarts for [Windows](https://opendds.org/quickstart/GettingStartedWindows.html) and [Linux](https://opendds.org/quickstart/GettingStartedLinux.html). +It should be possible to build and run the example using `run_test.pl` as in the quickstarts for [Windows](https://opendds.readthedocs.io/en/latest-release/devguide/quickstart/windows.html) and [Linux](https://opendds.readthedocs.io/en/latest-release/devguide/quickstart/linux.html). If the problem lies in the example, then GitHub's Pull Request interface will allow people to discuss, comment on, and propose changes to get the example working. If the problem lies in OpenDDS, then the example is a new test case. @@ -83,7 +83,7 @@ formal/2019-04-03 (version 2.3)](https://www.omg.org/spec/DDSI-RTPS/2.3). See the OpenDDS Developer's Guide and the file [docs/design/RTPS](docs/design/RTPS) for more details on RTPS. -See the [Developer's Guide](https://opendds.readthedocs.io/en/latest-release/devguide/building/introduction.html) for +See the [Developer's Guide](https://opendds.readthedocs.io/en/latest-release/devguide/introduction.html#specifications) for information on OpenDDS compliance with the DDS specification. If you would like to contribute a feature or sponsor the developers to add a feature please see the Support section above for contact information. @@ -133,7 +133,7 @@ Windows family: Embedded/Mobile/IoT: * LynxOS-178 (OpenDDS Safety Profile) * VxWorks 6.9, 7, 21.03 (see below) -* [Linux on Raspberry Pi](https://opendds.org/quickstart/GettingStartedPi.html) +* [Linux on Raspberry Pi](https://opendds.readthedocs.io/en/latest-release/devguide/quickstart/pi.html) * [Android 9.0 "Pie" (API Level 28) NDK r18b](https://opendds.readthedocs.io/en/latest-release/devguide/building/android.html) We have built OpenDDS for VxWorks 6.9, 7, and 21.03 and have run basic @@ -169,5 +169,5 @@ https://opendds.readthedocs.io/en/latest-release/devguide/building/index.html ## Quick Start with Docker See the [Docker Quick -Start](https://opendds.org/quickstart/GettingStartedDocker.html) for +Start](https://opendds.readthedocs.io/en/latest-release/devguide/quickstart/docker.html) for how to use the pre-built docker image. From 8fcb40dabce1432ddb49b1957cc81417f9389dc1 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 5 Jun 2024 15:02:45 -0500 Subject: [PATCH 50/60] Use OCI instead of Unity in .mailmap --- .mailmap | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.mailmap b/.mailmap index eab9a093afa..d7c689d3c44 100644 --- a/.mailmap +++ b/.mailmap @@ -8,9 +8,9 @@ # what's printed by: # git shortlog --summary --numbered --email -Justin Wilson -Justin Wilson Justin R. Wilson -Justin Wilson +Justin Wilson +Justin Wilson Justin R. Wilson +Justin Wilson Jeff Schmitz Jeff Schmitz iamtheschmitzer @@ -21,10 +21,10 @@ Paul Calabrese Huang-Ming Huang -Fred Hornsey -Fred Hornsey Frederick Hornsey -Fred Hornsey -Fred Hornsey iguessthislldo +Fred Hornsey +Fred Hornsey Frederick Hornsey +Fred Hornsey +Fred Hornsey iguessthislldo Doug Lewis unknown From 3079427cb66649fd6e8e80783af1b855f1f09bc7 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Wed, 5 Jun 2024 20:36:52 +0000 Subject: [PATCH 51/60] Thrasher aggressive creates too many timers for select reactor --- .github/workflows/bootime.yaml | 288 --------------------------- .github/workflows/build_and_test.yml | 2 +- tests/dcps_tests.lst | 4 +- 3 files changed, 3 insertions(+), 291 deletions(-) delete mode 100644 .github/workflows/bootime.yaml diff --git a/.github/workflows/bootime.yaml b/.github/workflows/bootime.yaml deleted file mode 100644 index aacd9ce7d95..00000000000 --- a/.github/workflows/bootime.yaml +++ /dev/null @@ -1,288 +0,0 @@ -name: "Bootime Builds" - -on: - push: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - TRIGGERING_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }} - -jobs: - ACE_TAO_u22_i0_xer0: - - runs-on: ubuntu-22.04 - - steps: - - name: checkout OpenDDS - uses: actions/checkout@v4 - with: - path: OpenDDS - submodules: true - - name: checkout ACE_TAO - uses: actions/checkout@v4 - with: - repository: DOCGroup/ACE_TAO - ref: ace6tao2 - path: OpenDDS/ACE_TAO - - name: get ACE_TAO commit - shell: bash - run: | - cd OpenDDS/ACE_TAO - export ACE_COMMIT=$(git rev-parse HEAD) - echo "ACE_COMMIT=$ACE_COMMIT" >> $GITHUB_ENV - - name: get compiler version - shell: bash - run: | - export COMPILER_VERSION=$(g++ --version 2>&1 | head -n 1) - echo "COMPILER_VERSION=$COMPILER_VERSION" >> $GITHUB_ENV - - name: Cache Artifact - id: cache-artifact - uses: actions/cache@v4 - with: - path: ${{ github.job }}.tar.xz - key: c01_${{ github.job }}_ace6tao2_${{ env.ACE_COMMIT }}_${{ env.COMPILER_VERSION }} - - name: checkout MPC - if: steps.cache-artifact.outputs.cache-hit != 'true' - uses: actions/checkout@v4 - with: - repository: DOCGroup/MPC - path: MPC - - name: configure OpenDDS - if: steps.cache-artifact.outputs.cache-hit != 'true' - run: | - cd OpenDDS - ./configure --std=c++20 --no-inline --tests --ace=$GITHUB_WORKSPACE/OpenDDS/ACE_TAO/ACE --mpc=$GITHUB_WORKSPACE/MPC --compile-warnings=WARNING - - name: build ACE and TAO - if: steps.cache-artifact.outputs.cache-hit != 'true' - run: | - cd OpenDDS - . setenv.sh - cd ACE_TAO/ACE - make -j4 - cd ../TAO - make -j4 - - name: create ACE_TAO tar.xz artifact - if: steps.cache-artifact.outputs.cache-hit != 'true' - shell: bash - run: | - cd OpenDDS/ACE_TAO - perl -ni.bak -e "print unless /opendds/" ACE/bin/MakeProjectCreator/config/default.features # remove opendds features from here, let individual build configure scripts handle those - find . -iname "*\.o" | xargs rm - tar cvf ../../${{ github.job }}.tar ACE/ace/config.h - git clean -xdfn | cut -d ' ' -f 3- | xargs tar uvf ../../${{ github.job }}.tar - xz -3 ../../${{ github.job }}.tar - - name: upload ACE_TAO artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ github.job }}_artifact - path: ${{ github.job }}.tar.xz - - build_u22_i0_xer0: - - runs-on: ubuntu-22.04 - - needs: ACE_TAO_u22_i0_xer0 - - steps: - - name: checkout MPC - uses: actions/checkout@v4 - with: - repository: DOCGroup/MPC - path: MPC - - name: checkout ACE_TAO - uses: actions/checkout@v4 - with: - repository: DOCGroup/ACE_TAO - ref: ace6tao2 - path: ACE_TAO - - name: download ACE_TAO artifact - uses: actions/download-artifact@v4 - with: - name: ACE_TAO_u22_i0_xer0_artifact - path: ACE_TAO - - name: extract ACE_TAO artifact - shell: bash - run: | - cd ACE_TAO - tar xvfJ ACE_TAO_u22_i0_xer0.tar.xz - - name: checkout OpenDDS - uses: actions/checkout@v4 - with: - path: OpenDDS - submodules: true - - name: configure OpenDDS - run: | - cd OpenDDS - ./configure --std=c++20 --no-inline --tests --rapidjson --boottime --ace=$GITHUB_WORKSPACE/ACE_TAO/ACE --mpc=$GITHUB_WORKSPACE/MPC --compile-warnings=WARNING - - name: check build configuration - shell: bash - run: | - cd OpenDDS - . setenv.sh - tools/scripts/show_build_config.pl - - uses: ammaraskar/gcc-problem-matcher@0.3.0 - - name: build OpenDDS - shell: bash - run: | - cd OpenDDS - . setenv.sh - make -j4 - - name: Build CMake Tests - run: | - source OpenDDS/setenv.sh - mkdir OpenDDS/tests/cmake/build - cd OpenDDS/tests/cmake/build - cmake .. - cmake --build . -- -j4 - - name: create OpenDDS tar.xz artifact - shell: bash - run: | - cd OpenDDS - rm -rf ACE_TAO - find . -iname "*\.o" | xargs rm - tar cvf ../${{ github.job }}.tar setenv.sh - git clean -xdfn | cut -d ' ' -f 3- | xargs tar uvf ../${{ github.job }}.tar - xz -3 ../${{ github.job }}.tar - - name: upload OpenDDS artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ github.job }}_artifact - path: ${{ github.job }}.tar.xz - - test_u22_i0_xer0: - - runs-on: ubuntu-22.04 - - needs: build_u22_i0_xer0 - - permissions: - contents: read - id-token: write - - steps: - - name: update apt - run: sudo apt-get update - - name: install dependencies - run: sudo apt-get -y install libxerces-c-dev wireshark-dev tshark qtbase5-dev - - name: checkout MPC - uses: actions/checkout@v4 - with: - repository: DOCGroup/MPC - path: MPC - - name: checkout autobuild - uses: actions/checkout@v4 - with: - repository: DOCGroup/autobuild - path: autobuild - - name: checkout ACE_TAO - uses: actions/checkout@v4 - with: - repository: DOCGroup/ACE_TAO - ref: ace6tao2 - path: ACE_TAO - - name: download ACE_TAO artifact - uses: actions/download-artifact@v4 - with: - name: ACE_TAO_u22_i0_xer0_artifact - path: ACE_TAO - - name: extract ACE_TAO artifact - shell: bash - run: | - cd ACE_TAO - tar xvfJ ACE_TAO_u22_i0_xer0.tar.xz - - name: checkout OpenDDS - uses: actions/checkout@v4 - with: - path: OpenDDS - submodules: true - - name: download OpenDDS artifact - uses: actions/download-artifact@v4 - with: - name: build_u22_i0_xer0_artifact - path: OpenDDS - - name: extract OpenDDS artifact - shell: bash - run: | - cd OpenDDS - tar xvfJ build_u22_i0_xer0.tar.xz - - name: check build configuration - shell: bash - run: | - cd OpenDDS - . setenv.sh - tools/scripts/show_build_config.pl - - name: install gdb - shell: bash - run: | - sudo apt-get update - sudo apt-get install gdb - echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope - - name: change core file pattern - shell: bash - run: | - sudo sysctl -w kernel.core_pattern=core.%e.%p - echo Core file pattern set to: - cat /proc/sys/kernel/core_pattern - - name: run OpenDDS tests - shell: bash - run: | - ulimit -c unlimited - cd OpenDDS - echo "export ACE_TEST_LOG_STUCK_STACKS=1" >> setenv.sh - . setenv.sh - mkdir ${{ github.job }}_autobuild_workspace - cd ${{ github.job }}_autobuild_workspace - echo using commit $TRIGGERING_COMMIT for SHA - echo $TRIGGERING_COMMIT >> ./SHA - cat > config.xml < - - - - - - - - - - - - - - - - - - - - EOF - $GITHUB_WORKSPACE/autobuild/autobuild.pl "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/config.xml" - - name: upload autobuild output - uses: actions/upload-artifact@v4 - with: - name: ${{ github.job }}_autobuild_output - path: OpenDDS/${{ github.job }}_autobuild_workspace - - name: Authenticate to Google Cloud - uses: google-github-actions/auth@v2 - with: - workload_identity_provider: projects/30587790497/locations/global/workloadIdentityPools/gha-scoreboard-upload/providers/gha-provider - service_account: gha-scoreboard-uploader@opendds-support.iam.gserviceaccount.com - if: ${{ github.repository == 'OpenDDS/OpenDDS' && github.ref == 'refs/heads/master' }} - - name: upload to Google Cloud - uses: 'google-github-actions/upload-cloud-storage@v2' - with: - path: OpenDDS/${{ github.job }}_autobuild_workspace/logs - destination: opendds-gha-scoreboard-uploads/${{ github.job }} - parent: false - process_gcloudignore: false - if: ${{ github.repository == 'OpenDDS/OpenDDS' && github.ref == 'refs/heads/master' }} - - name: check results - shell: bash - run: | - $GITHUB_WORKSPACE/OpenDDS/tools/scripts/autobuild_brief_html_to_text.pl "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/"*_Brief.html - cat "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" - grep -q 'Failures: 0' "$GITHUB_WORKSPACE/OpenDDS/${{ github.job }}_autobuild_workspace/logs/latest.txt" diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 7c4dadae6aa..685fe3e6675 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -2875,7 +2875,7 @@ jobs: - + diff --git a/tests/dcps_tests.lst b/tests/dcps_tests.lst index efe998a25c7..df79cd9044c 100644 --- a/tests/dcps_tests.lst +++ b/tests/dcps_tests.lst @@ -344,7 +344,7 @@ tests/DCPS/Thrasher/run_test.pl default rtps: !DCPS_MIN RTPS !LYNXOS tests/DCPS/Thrasher/run_test.pl low rtps: !DCPS_MIN RTPS !LYNXOS tests/DCPS/Thrasher/run_test.pl medium rtps: !DCPS_MIN RTPS !LYNXOS tests/DCPS/Thrasher/run_test.pl high rtps: !DCPS_MIN RTPS !LYNXOS !OPENDDS_SAFETY_PROFILE !GH_ACTIONS_ASAN -tests/DCPS/Thrasher/run_test.pl aggressive rtps: !DCPS_MIN RTPS !LYNXOS !OPENDDS_SAFETY_PROFILE !GH_ACTIONS_ASAN +tests/DCPS/Thrasher/run_test.pl aggressive rtps: !DCPS_MIN RTPS !LYNXOS !OPENDDS_SAFETY_PROFILE !GH_ACTIONS_ASAN !BOOTTIME_TIMERS tests/DCPS/Thrasher/run_test.pl single durable: !DCPS_MIN !LYNXOS !OPENDDS_SAFETY_PROFILE tests/DCPS/Thrasher/run_test.pl double durable: !DCPS_MIN !LYNXOS !OPENDDS_SAFETY_PROFILE tests/DCPS/Thrasher/run_test.pl triangle durable: !DCPS_MIN !LYNXOS !OPENDDS_SAFETY_PROFILE @@ -360,7 +360,7 @@ tests/DCPS/Thrasher/run_test.pl default rtps durable: !DCPS_MIN RTPS !LYNXOS tests/DCPS/Thrasher/run_test.pl low rtps durable: !DCPS_MIN RTPS !LYNXOS tests/DCPS/Thrasher/run_test.pl medium rtps durable: !DCPS_MIN RTPS !LYNXOS tests/DCPS/Thrasher/run_test.pl high rtps durable: !DCPS_MIN RTPS !LYNXOS !OPENDDS_SAFETY_PROFILE !GH_ACTIONS_ASAN -tests/DCPS/Thrasher/run_test.pl aggressive rtps durable: !DCPS_MIN RTPS !LYNXOS !OPENDDS_SAFETY_PROFILE !GH_ACTIONS_ASAN +tests/DCPS/Thrasher/run_test.pl aggressive rtps durable: !DCPS_MIN RTPS !LYNXOS !OPENDDS_SAFETY_PROFILE !GH_ACTIONS_ASAN !BOOTTIME_TIMERS tests/DCPS/DPFactoryQos/run_test.pl: !DCPS_MIN tests/DCPS/DPFactoryQos/run_test.pl rtps_disc: !DCPS_MIN RTPS tests/DCPS/ManualAssertLiveliness/run_test.pl: !DCPS_MIN !OPENDDS_SAFETY_PROFILE From 68b9b6f3eedcd187042bad0340358c5133b90469 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Wed, 5 Jun 2024 20:38:59 +0000 Subject: [PATCH 52/60] added error message --- dds/DCPS/ReactorTask.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dds/DCPS/ReactorTask.cpp b/dds/DCPS/ReactorTask.cpp index c7e510854af..4fd70265ca5 100644 --- a/dds/DCPS/ReactorTask.cpp +++ b/dds/DCPS/ReactorTask.cpp @@ -170,7 +170,10 @@ int ReactorTask::svc() period, period); if (thread_status_timer == Timers::InvalidTimerId) { - //TODO: log error + if (log_level >= LogLevel::Notice) { + ACE_ERROR((LM_NOTICE, "(%P|%t) NOTICE: ReactorTask::svc: failed to " + "schedule timer for ThreadStatusManager::Updater\n")); + } } } From 37209381b2a3152833cb332ae255daac650cf99d Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Thu, 6 Jun 2024 19:47:26 +0000 Subject: [PATCH 53/60] Added a template parameter to TimePoint_T so each instantiation can use a distinct IDL struct --- dds/DCPS/DataReaderImpl_T.h | 4 +- dds/DCPS/DataWriterImpl.cpp | 12 +- dds/DCPS/DataWriterImpl_T.h | 8 +- dds/DCPS/DomainParticipantImpl.cpp | 2 +- dds/DCPS/InternalDataReader.h | 8 +- dds/DCPS/Logging.cpp | 2 +- dds/DCPS/RTPS/Spdp.cpp | 40 +++--- dds/DCPS/ReceivedDataElementList.h | 3 +- dds/DCPS/RecorderImpl.cpp | 2 +- dds/DCPS/ReplayerImpl.cpp | 2 +- dds/DCPS/TimePoint_T.cpp | 16 +-- dds/DCPS/TimePoint_T.h | 79 +++++------ dds/DCPS/TimePoint_T.inl | 131 ++++++++---------- dds/DCPS/TimeTypes.h | 6 +- dds/DCPS/Time_Helper.h | 3 +- dds/DCPS/Time_Helper.inl | 2 +- dds/DCPS/XTypes/DynamicDataWriterImpl.h | 8 +- dds/DCPS/transport/tcp/TcpDataLink.cpp | 2 +- dds/FACE/FaceTSS.cpp | 2 +- .../RelayParticipantStatusReporter.cpp | 8 +- 20 files changed, 159 insertions(+), 181 deletions(-) diff --git a/dds/DCPS/DataReaderImpl_T.h b/dds/DCPS/DataReaderImpl_T.h index 6b656b7d367..82e58bafcd5 100644 --- a/dds/DCPS/DataReaderImpl_T.h +++ b/dds/DCPS/DataReaderImpl_T.h @@ -850,7 +850,7 @@ namespace OpenDDS { bool filtered = false; SubscriptionInstance_rch instance; - const DDS::Time_t now = timestamp.to_dds_time(); + const DDS::Time_t now = timestamp.to_idl_struct(); DataSampleHeader header; header.source_timestamp_sec_ = now.sec; header.source_timestamp_nanosec_ = now.nanosec; @@ -898,7 +898,7 @@ namespace OpenDDS { SubscriptionInstance_rch si = get_handle_instance(instance); if (si && state != DDS::ALIVE_INSTANCE_STATE) { - const DDS::Time_t now = timestamp.to_dds_time(); + const DDS::Time_t now = timestamp.to_idl_struct(); DataSampleHeader header; header.publication_id_ = publication_id; header.source_timestamp_sec_ = now.sec; diff --git a/dds/DCPS/DataWriterImpl.cpp b/dds/DCPS/DataWriterImpl.cpp index 4624a389fa0..041e0265852 100644 --- a/dds/DCPS/DataWriterImpl.cpp +++ b/dds/DCPS/DataWriterImpl.cpp @@ -543,7 +543,7 @@ DataWriterImpl::association_complete_i(const GUID_t& remote_id) Message_Block_Ptr end_historic_samples( create_control_message( END_HISTORIC_SAMPLES, header, move(data), - SystemTimePoint::now().to_dds_time())); + SystemTimePoint::now().to_idl_struct())); this->controlTracker.message_sent(); guard.release(); @@ -776,7 +776,7 @@ void DataWriterImpl::replay_durable_data_for(const GUID_t& remote_id) DataSampleHeader header; Message_Block_Ptr end_historic_samples(create_control_message(END_HISTORIC_SAMPLES, header, move(data), - SystemTimePoint::now().to_dds_time())); + SystemTimePoint::now().to_idl_struct())); this->controlTracker.message_sent(); guard.release(); @@ -1075,7 +1075,7 @@ DataWriterImpl::send_request_ack() REQUEST_ACK, element->get_header(), move(blk), - SystemTimePoint::now().to_dds_time())); + SystemTimePoint::now().to_idl_struct())); element->set_sample(move(sample)); @@ -2426,7 +2426,7 @@ DataWriterImpl::end_coherent_changes(const GroupCoherentSamples& group_samples) Message_Block_Ptr control( create_control_message( END_COHERENT_CHANGES, header, move(data), - SystemTimePoint::now().to_dds_time())); + SystemTimePoint::now().to_idl_struct())); this->coherent_ = false; this->coherent_samples_ = 0; @@ -2550,7 +2550,7 @@ DataWriterImpl::send_liveliness(const MonotonicTimePoint& now) Message_Block_Ptr liveliness_msg( create_control_message( DATAWRITER_LIVELINESS, header, move(empty), - SystemTimePoint::now().to_dds_time())); + SystemTimePoint::now().to_idl_struct())); if (this->send_control(header, move(liveliness_msg)) == SEND_CONTROL_ERROR) { ACE_ERROR_RETURN((LM_ERROR, @@ -2582,7 +2582,7 @@ DataWriterImpl::prepare_to_delete() #endif // Unregister all registered instances prior to deletion. - unregister_instances(SystemTimePoint::now().to_dds_time()); + unregister_instances(SystemTimePoint::now().to_idl_struct()); const Observer_rch observer = get_observer(Observer::e_DELETED); if (observer) { diff --git a/dds/DCPS/DataWriterImpl_T.h b/dds/DCPS/DataWriterImpl_T.h index 73d1aa7c31c..86b902a8adc 100644 --- a/dds/DCPS/DataWriterImpl_T.h +++ b/dds/DCPS/DataWriterImpl_T.h @@ -52,7 +52,7 @@ DataWriterImpl_T DDS::InstanceHandle_t register_instance(const MessageType& instance) { - return register_instance_w_timestamp(instance, SystemTimePoint::now().to_dds_time()); + return register_instance_w_timestamp(instance, SystemTimePoint::now().to_idl_struct()); } DDS::InstanceHandle_t register_instance_w_timestamp( @@ -64,7 +64,7 @@ DataWriterImpl_T DDS::ReturnCode_t unregister_instance(const MessageType& instance, DDS::InstanceHandle_t handle) { - return unregister_instance_w_timestamp(instance, handle, SystemTimePoint::now().to_dds_time()); + return unregister_instance_w_timestamp(instance, handle, SystemTimePoint::now().to_idl_struct()); } DDS::ReturnCode_t unregister_instance_w_timestamp( @@ -81,7 +81,7 @@ DataWriterImpl_T // This lack of safety helps performance. DDS::ReturnCode_t write(const MessageType& instance_data, DDS::InstanceHandle_t handle) { - return write_w_timestamp(instance_data, handle, SystemTimePoint::now().to_dds_time()); + return write_w_timestamp(instance_data, handle, SystemTimePoint::now().to_idl_struct()); } //WARNING: If the handle is non-nil and the instance is not registered @@ -98,7 +98,7 @@ DataWriterImpl_T DDS::ReturnCode_t dispose(const MessageType& instance_data, DDS::InstanceHandle_t instance_handle) { - return dispose_w_timestamp(instance_data, instance_handle, SystemTimePoint::now().to_dds_time()); + return dispose_w_timestamp(instance_data, instance_handle, SystemTimePoint::now().to_idl_struct()); } DDS::ReturnCode_t dispose_w_timestamp( diff --git a/dds/DCPS/DomainParticipantImpl.cpp b/dds/DCPS/DomainParticipantImpl.cpp index 5719b5b5155..175e82191e7 100644 --- a/dds/DCPS/DomainParticipantImpl.cpp +++ b/dds/DCPS/DomainParticipantImpl.cpp @@ -1518,7 +1518,7 @@ DomainParticipantImpl::get_default_topic_qos( DDS::ReturnCode_t DomainParticipantImpl::get_current_time(DDS::Time_t& current_time) { - current_time = SystemTimePoint::now().to_dds_time(); + current_time = SystemTimePoint::now().to_idl_struct(); return DDS::RETCODE_OK; } diff --git a/dds/DCPS/InternalDataReader.h b/dds/DCPS/InternalDataReader.h index db078975a32..22db3515d15 100644 --- a/dds/DCPS/InternalDataReader.h +++ b/dds/DCPS/InternalDataReader.h @@ -340,7 +340,7 @@ class InternalDataReader : public InternalEntity { { if (instance_state_ == DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE && !is_infinite(qos.reader_data_lifecycle.autopurge_disposed_samples_delay) && - SystemTimePoint::now().to_dds_time() > disposed_expiration_date_) { + SystemTimePoint::now().to_idl_struct() > disposed_expiration_date_) { not_read_samples_.clear(); read_samples_.clear(); } @@ -357,7 +357,7 @@ class InternalDataReader : public InternalEntity { if (instance_state_ == DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE && !is_infinite(qos.reader_data_lifecycle.autopurge_nowriter_samples_delay) && - SystemTimePoint::now().to_dds_time() > no_writers_expiration_date_) { + SystemTimePoint::now().to_idl_struct() > no_writers_expiration_date_) { return true; } @@ -511,7 +511,7 @@ class InternalDataReader : public InternalEntity { if (instance_state_ == DDS::ALIVE_INSTANCE_STATE) { instance_state_ = DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE; - disposed_expiration_date_ = SystemTimePoint::now().to_dds_time() + qos.reader_data_lifecycle.autopurge_disposed_samples_delay; + disposed_expiration_date_ = SystemTimePoint::now().to_idl_struct() + qos.reader_data_lifecycle.autopurge_disposed_samples_delay; informed_of_not_alive_ = false; return true; } @@ -526,7 +526,7 @@ class InternalDataReader : public InternalEntity { if (publication_set_.empty() && instance_state_ == DDS::ALIVE_INSTANCE_STATE) { instance_state_ = DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE; - no_writers_expiration_date_ = SystemTimePoint::now().to_dds_time() + qos.reader_data_lifecycle.autopurge_nowriter_samples_delay; + no_writers_expiration_date_ = SystemTimePoint::now().to_idl_struct() + qos.reader_data_lifecycle.autopurge_nowriter_samples_delay; informed_of_not_alive_ = false; return true; } diff --git a/dds/DCPS/Logging.cpp b/dds/DCPS/Logging.cpp index 8cde3732a79..5dd2389e0a9 100644 --- a/dds/DCPS/Logging.cpp +++ b/dds/DCPS/Logging.cpp @@ -25,7 +25,7 @@ void OpenDDS_Dcps_Export log_progress(const char* activity, { ACE_DEBUG((LM_INFO, "(%P|%t) {transport_debug.log_progress} local: %C remote: %C reference: %C time(ms): %Lu activity: %C\n", DCPS::LogGuid(local).c_str(), DCPS::LogGuid(remote).c_str(), DCPS::LogGuid(reference).c_str(), - duration_to_time_value(MonotonicTimePoint::now().to_monotonic_time() - start_time).msec(), + duration_to_time_value(MonotonicTimePoint::now().to_idl_struct() - start_time).msec(), activity)); } diff --git a/dds/DCPS/RTPS/Spdp.cpp b/dds/DCPS/RTPS/Spdp.cpp index 6f53263fd9f..4a3cb6f7f6b 100644 --- a/dds/DCPS/RTPS/Spdp.cpp +++ b/dds/DCPS/RTPS/Spdp.cpp @@ -247,7 +247,7 @@ Spdp::Spdp(DDS::DomainId_t domain, #endif , domain_(domain) , guid_(guid) - , participant_discovered_at_(MonotonicTimePoint::now().to_monotonic_time()) + , participant_discovered_at_(MonotonicTimePoint::now().to_idl_struct()) , is_application_participant_(false) , ipv4_participant_port_id_(0) #ifdef ACE_HAS_IPV6 @@ -310,7 +310,7 @@ Spdp::Spdp(DDS::DomainId_t domain, , secure_participant_user_data_(disco->config()->secure_participant_user_data()) , domain_(domain) , guid_(guid) - , participant_discovered_at_(MonotonicTimePoint::now().to_monotonic_time()) + , participant_discovered_at_(MonotonicTimePoint::now().to_idl_struct()) , is_application_participant_(false) , ipv4_participant_port_id_(0) #ifdef ACE_HAS_IPV6 @@ -561,56 +561,56 @@ void Spdp::process_location_updates_i(const DiscoveredParticipantIter& iter, con case DCPS::LOCATION_LOCAL: address_change = addr.compare(location_data.local_addr.in()) != 0; location_data.local_addr = addr.c_str(); - location_data.local_timestamp = pos->timestamp_.to_dds_time(); + location_data.local_timestamp = pos->timestamp_.to_idl_struct(); break; case DCPS::LOCATION_ICE: address_change = addr.compare(location_data.ice_addr.in()) != 0; location_data.ice_addr = addr.c_str(); - location_data.ice_timestamp = pos->timestamp_.to_dds_time(); + location_data.ice_timestamp = pos->timestamp_.to_idl_struct(); break; case DCPS::LOCATION_RELAY: address_change = addr.compare(location_data.relay_addr.in()) != 0; location_data.relay_addr = addr.c_str(); - location_data.relay_timestamp = pos->timestamp_.to_dds_time(); + location_data.relay_timestamp = pos->timestamp_.to_idl_struct(); break; case DCPS::LOCATION_LOCAL6: address_change = addr.compare(location_data.local6_addr.in()) != 0; location_data.local6_addr = addr.c_str(); - location_data.local6_timestamp = pos->timestamp_.to_dds_time(); + location_data.local6_timestamp = pos->timestamp_.to_idl_struct(); break; case DCPS::LOCATION_ICE6: address_change = addr.compare(location_data.ice6_addr.in()) != 0; location_data.ice6_addr = addr.c_str(); - location_data.ice6_timestamp = pos->timestamp_.to_dds_time(); + location_data.ice6_timestamp = pos->timestamp_.to_idl_struct(); break; case DCPS::LOCATION_RELAY6: address_change = addr.compare(location_data.relay6_addr.in()) != 0; location_data.relay6_addr = addr.c_str(); - location_data.relay6_timestamp = pos->timestamp_.to_dds_time(); + location_data.relay6_timestamp = pos->timestamp_.to_idl_struct(); break; } - const DDS::Time_t expr = (pos->timestamp_ - leaseDuration).to_dds_time(); + const DDS::Time_t expr = (pos->timestamp_ - leaseDuration).to_idl_struct(); if ((location_data.location & DCPS::LOCATION_LOCAL) && DCPS::operator<(location_data.local_timestamp, expr)) { location_data.location &= ~(DCPS::LOCATION_LOCAL); location_data.change_mask |= DCPS::LOCATION_LOCAL; - location_data.local_timestamp = pos->timestamp_.to_dds_time(); + location_data.local_timestamp = pos->timestamp_.to_idl_struct(); } if ((location_data.location & DCPS::LOCATION_RELAY) && DCPS::operator<(location_data.relay_timestamp, expr)) { location_data.location &= ~(DCPS::LOCATION_RELAY); location_data.change_mask |= DCPS::LOCATION_RELAY; - location_data.relay_timestamp = pos->timestamp_.to_dds_time(); + location_data.relay_timestamp = pos->timestamp_.to_idl_struct(); } if ((location_data.location & DCPS::LOCATION_LOCAL6) && DCPS::operator<(location_data.local6_timestamp, expr)) { location_data.location &= ~(DCPS::LOCATION_LOCAL6); location_data.change_mask |= DCPS::LOCATION_LOCAL6; - location_data.local6_timestamp = pos->timestamp_.to_dds_time(); + location_data.local6_timestamp = pos->timestamp_.to_idl_struct(); } if ((location_data.location & DCPS::LOCATION_RELAY6) && DCPS::operator<(location_data.relay6_timestamp, expr)) { location_data.location &= ~(DCPS::LOCATION_RELAY6); location_data.change_mask |= DCPS::LOCATION_RELAY6; - location_data.relay6_timestamp = pos->timestamp_.to_dds_time(); + location_data.relay6_timestamp = pos->timestamp_.to_idl_struct(); } if (old_mask != location_data.location || address_change) { @@ -870,7 +870,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, } if (DCPS::transport_debug.log_progress) { - log_progress("participant discovery", guid_, guid, iter->second.discovered_at_.to_monotonic_time()); + log_progress("participant discovery", guid_, guid, iter->second.discovered_at_.to_idl_struct()); } #ifndef DDS_HAS_MINIMUM_BIT @@ -957,7 +957,7 @@ Spdp::handle_participant_data(DCPS::MessageId id, } else { // Existing Participant if (from_sedp && DCPS::transport_debug.log_progress) { - log_progress("secure participant discovery", guid_, guid, iter->second.discovered_at_.to_monotonic_time()); + log_progress("secure participant discovery", guid_, guid, iter->second.discovered_at_.to_idl_struct()); } #ifndef DDS_HAS_MINIMUM_BIT @@ -1096,7 +1096,7 @@ Spdp::data_received(const DataSubmessage& data, ParticipantData_t pdata; pdata.participantProxy.domainId = domain_; - pdata.discoveredAt = now.to_monotonic_time(); + pdata.discoveredAt = now.to_idl_struct(); #if OPENDDS_CONFIG_SECURITY pdata.ddsParticipantDataSecure.base.base.key = DCPS::BUILTIN_TOPIC_KEY_UNKNOWN; #endif @@ -1950,7 +1950,7 @@ Spdp::handle_participant_crypto_tokens(const DDS::Security::ParticipantVolatileM } if (DCPS::transport_debug.log_progress) { - log_progress("participant crypto token", guid_, src_participant, iter->second.discovered_at_.to_monotonic_time()); + log_progress("participant crypto token", guid_, src_participant, iter->second.discovered_at_.to_idl_struct()); } const DDS::Security::ParticipantCryptoTokenSeq& inboundTokens = @@ -2117,7 +2117,7 @@ Spdp::match_authenticated(const DCPS::GUID_t& guid, DiscoveredParticipantIter& i } if (DCPS::transport_debug.log_progress) { - log_progress("authentication", guid_, guid, iter->second.discovered_at_.to_monotonic_time()); + log_progress("authentication", guid_, guid, iter->second.discovered_at_.to_idl_struct()); } DDS::Security::ParticipantCryptoHandle dp_crypto_handle = @@ -4430,7 +4430,7 @@ void Spdp::SpdpTransport::thread_status_task(const DCPS::MonotonicTimePoint& now DCPS::InternalThreadBuiltinTopicData data; data.thread_id = i->bit_key().c_str(); data.utilization = i->utilization(now); - data.monotonic_timestamp = i->last_update().to_monotonic_time(); + data.monotonic_timestamp = i->last_update().to_idl_struct(); outer->bit_subscriber_->add_thread_status(data, DDS::NEW_VIEW_STATE, i->timestamp()); } @@ -4597,7 +4597,7 @@ DCPS::MonotonicTime_t Spdp::get_participant_discovered_at(const DCPS::GUID_t& gu { const DiscoveredParticipantConstIter iter = participants_.find(make_part_guid(guid)); if (iter != participants_.end()) { - return iter->second.discovered_at_.to_monotonic_time(); + return iter->second.discovered_at_.to_idl_struct(); } return DCPS::MonotonicTime_t(); diff --git a/dds/DCPS/ReceivedDataElementList.h b/dds/DCPS/ReceivedDataElementList.h index b97cf12dea2..c6bedde00fd 100644 --- a/dds/DCPS/ReceivedDataElementList.h +++ b/dds/DCPS/ReceivedDataElementList.h @@ -36,6 +36,7 @@ class OpenDDS_Dcps_Export ReceivedDataElement { : pub_(header.publication_id_), registered_data_(received_data), sample_state_(DDS::NOT_READ_SAMPLE_STATE), + destination_timestamp_(SystemTimePoint::now().to_idl_struct()), #ifndef OPENDDS_NO_OBJECT_MODEL_PROFILE coherent_change_(header.coherent_change_), group_coherent_(header.group_coherent_), @@ -51,8 +52,6 @@ class OpenDDS_Dcps_Export ReceivedDataElement { ref_count_(1), mx_(mx) { - destination_timestamp_ = SystemTimePoint::now().to_dds_time(); - source_timestamp_.sec = header.source_timestamp_sec_; source_timestamp_.nanosec = header.source_timestamp_nanosec_; diff --git a/dds/DCPS/RecorderImpl.cpp b/dds/DCPS/RecorderImpl.cpp index 25f053bbaaa..6cb024d17ff 100644 --- a/dds/DCPS/RecorderImpl.cpp +++ b/dds/DCPS/RecorderImpl.cpp @@ -364,7 +364,7 @@ RecorderImpl::add_association(const WriterAssociation& writer, // // if (where->second->should_ack(now)) { // const SequenceNumber sequence = where->second->ack_sequence(); - // if (send_sample_ack(writer.writerId, sequence, now.to_dds_time())) { + // if (send_sample_ack(writer.writerId, sequence, now.to_idl_struct())) { // where->second->clear_acks(sequence); // } // } diff --git a/dds/DCPS/ReplayerImpl.cpp b/dds/DCPS/ReplayerImpl.cpp index 5fb7f51308f..b035b213968 100644 --- a/dds/DCPS/ReplayerImpl.cpp +++ b/dds/DCPS/ReplayerImpl.cpp @@ -102,7 +102,7 @@ ReplayerImpl::cleanup() { // // Unregister all registered instances prior to deletion. - // // this->unregister_instances(SystemTimePoint::now().to_dds_time()); + // // this->unregister_instances(SystemTimePoint::now().to_idl_struct()); // // // CORBA::String_var topic_name = this->get_Atopic_name(); { diff --git a/dds/DCPS/TimePoint_T.cpp b/dds/DCPS/TimePoint_T.cpp index 92ce6621460..77a9689bf99 100644 --- a/dds/DCPS/TimePoint_T.cpp +++ b/dds/DCPS/TimePoint_T.cpp @@ -11,19 +11,19 @@ OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { namespace DCPS { -template -const TimePoint_T TimePoint_T::zero_value(ACE_Time_Value(0, 0)); +template +const TimePoint_T TimePoint_T::zero_value(ACE_Time_Value(0, 0)); #ifdef ACE_HAS_CPP11 -template -const TimePoint_T TimePoint_T::max_value(ACE_Time_Value(std::numeric_limits::max(), ACE_ONE_SECOND_IN_USECS - 1)); +template +const TimePoint_T TimePoint_T::max_value(ACE_Time_Value(std::numeric_limits::max(), ACE_ONE_SECOND_IN_USECS - 1)); #else -template -const TimePoint_T TimePoint_T::max_value(ACE_Time_Value(ACE_Numeric_Limits::max(), ACE_ONE_SECOND_IN_USECS - 1)); +template +const TimePoint_T TimePoint_T::max_value(ACE_Time_Value(ACE_Numeric_Limits::max(), ACE_ONE_SECOND_IN_USECS - 1)); #endif /* ACE_HAS_CPP11 */ -template -AceClock TimePoint_T::clock; +template +AceClock TimePoint_T::clock; } } diff --git a/dds/DCPS/TimePoint_T.h b/dds/DCPS/TimePoint_T.h index 5d5432030df..b508770f917 100644 --- a/dds/DCPS/TimePoint_T.h +++ b/dds/DCPS/TimePoint_T.h @@ -4,8 +4,6 @@ #include "TimeDuration.h" #include "SafeBool_T.h" -#include - #include #if !defined (ACE_LACKS_PRAGMA_ONCE) @@ -31,14 +29,15 @@ namespace DCPS { * (or docs/internal/dev_guidelines.rst) for background and reasoning for this * class. */ -template -class TimePoint_T : public SafeBool_T > { +template +class TimePoint_T : public SafeBool_T > { public: typedef AceClock ClockType; + typedef IdlType IdlStruct; typedef ACE_Time_Value_T ValueType; - const static TimePoint_T zero_value; - const static TimePoint_T max_value; + const static TimePoint_T zero_value; + const static TimePoint_T max_value; /** * Set to zero_value, which is equal to the epoch (the starting point) of the @@ -51,20 +50,18 @@ class TimePoint_T : public SafeBool_T > { * necessary. * * \warning Use these carefully. Make sure ACE_Time_Value is a point in time - * and of the right clock type. DDS::Time_t should be in system clock time - * and so shouldn't be used with MonotonicTimePoint. + * and of the right clock type. */ ///@{ explicit TimePoint_T(const ACE_Time_Value& ace_time_value); - explicit TimePoint_T(const ACE_Time_Value_T& ace_time_value); - explicit TimePoint_T(const DDS::Time_t& dds_time); - explicit TimePoint_T(const MonotonicTime_t& monotonic_time); + explicit TimePoint_T(const ValueType& ace_time_value); + explicit TimePoint_T(const IdlType& from_idl); ///@} /** * Get a TimePoint representing the current time of the AceClock. */ - static TimePoint_T now(); + static TimePoint_T now(); /** * Get and set the inner ACE_Time_Value based value. Use value() to pass this @@ -72,8 +69,8 @@ class TimePoint_T : public SafeBool_T > { * type. */ ///@{ - const ACE_Time_Value_T& value() const; - void value(const ACE_Time_Value_T& ace_time_value); + const ValueType& value() const; + void value(const ValueType& ace_time_value); ///@} /** @@ -97,18 +94,12 @@ class TimePoint_T : public SafeBool_T > { void set_to_now(); /** - * Convert to DDS::Time_t. This is probably only desirable for the system - * time version of this template class, SystemTimePoint. - */ - DDS::Time_t to_dds_time() const; - - /** - * Convert to OpenDDS::DCPS::MonotonicTime_t. + * Convert to the corresponding IDL struct type. */ - MonotonicTime_t to_monotonic_time() const; + IdlType to_idl_struct() const; - TimePoint_T& operator+=(const TimeDuration& td); - TimePoint_T& operator-=(const TimeDuration& td); + TimePoint_T& operator+=(const TimeDuration& td); + TimePoint_T& operator-=(const TimeDuration& td); protected: /** @@ -120,35 +111,35 @@ class TimePoint_T : public SafeBool_T > { ValueType value_; }; -template -TimePoint_T operator+(const TimeDuration& x, const TimePoint_T& y); +template +TimePoint_T operator+(const TimeDuration& x, const TimePoint_T& y); -template -TimePoint_T operator+(const TimePoint_T& x, const TimeDuration& y); +template +TimePoint_T operator+(const TimePoint_T& x, const TimeDuration& y); -template -TimeDuration operator-(const TimePoint_T& x, const TimePoint_T& y); +template +TimeDuration operator-(const TimePoint_T& x, const TimePoint_T& y); -template -TimePoint_T operator-(const TimePoint_T& x, const TimeDuration& y); +template +TimePoint_T operator-(const TimePoint_T& x, const TimeDuration& y); -template -bool operator<(const TimePoint_T& x, const TimePoint_T& y); +template +bool operator<(const TimePoint_T& x, const TimePoint_T& y); -template -bool operator>(const TimePoint_T& x, const TimePoint_T& y); +template +bool operator>(const TimePoint_T& x, const TimePoint_T& y); -template -bool operator<=(const TimePoint_T& x, const TimePoint_T& y); +template +bool operator<=(const TimePoint_T& x, const TimePoint_T& y); -template -bool operator>=(const TimePoint_T& x, const TimePoint_T& y); +template +bool operator>=(const TimePoint_T& x, const TimePoint_T& y); -template -bool operator==(const TimePoint_T& x, const TimePoint_T& y); +template +bool operator==(const TimePoint_T& x, const TimePoint_T& y); -template -bool operator!=(const TimePoint_T& x, const TimePoint_T& y); +template +bool operator!=(const TimePoint_T& x, const TimePoint_T& y); } // namespace DCPS } // namespace OpenDDS diff --git a/dds/DCPS/TimePoint_T.inl b/dds/DCPS/TimePoint_T.inl index b98317682d5..693c054fcbb 100644 --- a/dds/DCPS/TimePoint_T.inl +++ b/dds/DCPS/TimePoint_T.inl @@ -7,199 +7,184 @@ OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL namespace OpenDDS { namespace DCPS { -template +template ACE_INLINE -TimePoint_T::TimePoint_T() +TimePoint_T::TimePoint_T() : value_(zero_value.value()) { } -template +template ACE_INLINE -TimePoint_T::TimePoint_T(const ACE_Time_Value& ace_time_value) +TimePoint_T::TimePoint_T(const ACE_Time_Value& ace_time_value) : value_(ace_time_value) { } -template +template ACE_INLINE -TimePoint_T::TimePoint_T(const ACE_Time_Value_T& ace_time_value) +TimePoint_T::TimePoint_T(const ACE_Time_Value_T& ace_time_value) : value_(ace_time_value) { } -template +template ACE_INLINE -TimePoint_T::TimePoint_T(const DDS::Time_t& dds_time) -: value_(time_to_time_value(dds_time)) +TimePoint_T::TimePoint_T(const IdlType& idl_time) +: value_(time_to_time_value(idl_time)) { } -template +template ACE_INLINE -TimePoint_T::TimePoint_T(const MonotonicTime_t& monotonic_time) -: value_(time_to_time_value(monotonic_time)) +TimePoint_T +TimePoint_T::now() { + return TimePoint_T(clock()); } -template -ACE_INLINE -TimePoint_T -TimePoint_T::now() -{ - return TimePoint_T(clock()); -} - -template +template ACE_INLINE const ACE_Time_Value_T& -TimePoint_T::value() const +TimePoint_T::value() const { return value_; } -template +template ACE_INLINE void -TimePoint_T::value(const ACE_Time_Value_T& ace_time_value) +TimePoint_T::value(const ACE_Time_Value_T& ace_time_value) { value_ = ace_time_value; } -template +template ACE_INLINE bool -TimePoint_T::is_zero() const +TimePoint_T::is_zero() const { return *this == zero_value; } -template +template ACE_INLINE bool -TimePoint_T::is_max() const +TimePoint_T::is_max() const { return *this == max_value; } -template +template ACE_INLINE void -TimePoint_T::set_to_now() +TimePoint_T::set_to_now() { value_ = clock(); } -template +template ACE_INLINE -DDS::Time_t -TimePoint_T::to_dds_time() const +IdlType +TimePoint_T::to_idl_struct() const { return time_value_to_time(value_); } -template -ACE_INLINE -MonotonicTime_t -TimePoint_T::to_monotonic_time() const -{ - return time_value_to_monotonic_time(value_); -} - -template +template ACE_INLINE -TimePoint_T& -TimePoint_T::operator+=(const TimeDuration& td) +TimePoint_T& +TimePoint_T::operator+=(const TimeDuration& td) { value_ += td.value(); return *this; } -template +template ACE_INLINE -TimePoint_T& -TimePoint_T::operator-=(const TimeDuration& td) +TimePoint_T& +TimePoint_T::operator-=(const TimeDuration& td) { value_ -= td.value(); return *this; } -template +template ACE_INLINE -TimePoint_T -operator+(const TimeDuration& x, const TimePoint_T& y) +TimePoint_T +operator+(const TimeDuration& x, const TimePoint_T& y) { - return TimePoint_T(x.value() + y.value()); + return TimePoint_T(x.value() + y.value()); } -template +template ACE_INLINE -TimePoint_T -operator+(const TimePoint_T& x, const TimeDuration& y) +TimePoint_T +operator+(const TimePoint_T& x, const TimeDuration& y) { - return TimePoint_T(x.value() + y.value()); + return TimePoint_T(x.value() + y.value()); } -template +template ACE_INLINE TimeDuration -operator-(const TimePoint_T& x, const TimePoint_T& y) +operator-(const TimePoint_T& x, const TimePoint_T& y) { return TimeDuration(x.value() - y.value()); } -template +template ACE_INLINE -TimePoint_T -operator-(const TimePoint_T& x, const TimeDuration& y) +TimePoint_T +operator-(const TimePoint_T& x, const TimeDuration& y) { - return TimePoint_T(x.value() - y.value()); + return TimePoint_T(x.value() - y.value()); } -template +template ACE_INLINE bool -operator<(const TimePoint_T& x, const TimePoint_T& y) +operator<(const TimePoint_T& x, const TimePoint_T& y) { return x.value() < y.value(); } -template +template ACE_INLINE bool -operator>(const TimePoint_T& x, const TimePoint_T& y) +operator>(const TimePoint_T& x, const TimePoint_T& y) { return x.value() > y.value(); } -template +template ACE_INLINE bool -operator<=(const TimePoint_T& x, const TimePoint_T& y) +operator<=(const TimePoint_T& x, const TimePoint_T& y) { return x.value() <= y.value(); } -template +template ACE_INLINE bool -operator>=(const TimePoint_T& x, const TimePoint_T& y) +operator>=(const TimePoint_T& x, const TimePoint_T& y) { return x.value() >= y.value(); } -template +template ACE_INLINE bool -operator==(const TimePoint_T& x, const TimePoint_T& y) +operator==(const TimePoint_T& x, const TimePoint_T& y) { return x.value() == y.value(); } -template +template ACE_INLINE bool -operator!=(const TimePoint_T& x, const TimePoint_T& y) +operator!=(const TimePoint_T& x, const TimePoint_T& y) { return x.value() != y.value(); } diff --git a/dds/DCPS/TimeTypes.h b/dds/DCPS/TimeTypes.h index 3b627108317..6404d2fc0f1 100644 --- a/dds/DCPS/TimeTypes.h +++ b/dds/DCPS/TimeTypes.h @@ -11,6 +11,8 @@ #include "TimeDuration.h" #include "TimePoint_T.h" +#include + #include #include @@ -29,7 +31,7 @@ namespace DCPS { */ ///@{ typedef ACE_System_Time_Policy SystemClock; -typedef TimePoint_T SystemTimePoint; +typedef TimePoint_T SystemTimePoint; ///@} /** @@ -48,7 +50,7 @@ typedef ACE_Monotonic_Time_Policy MonotonicClock; #else typedef SystemClock MonotonicClock; #endif -typedef TimePoint_T MonotonicTimePoint; +typedef TimePoint_T MonotonicTimePoint; ///@} } // namespace DCPS diff --git a/dds/DCPS/Time_Helper.h b/dds/DCPS/Time_Helper.h index 7878545ce11..170282fcc26 100644 --- a/dds/DCPS/Time_Helper.h +++ b/dds/DCPS/Time_Helper.h @@ -12,6 +12,7 @@ #include #include +#include #include #ifndef ACE_LACKS_PRAGMA_ONCE @@ -34,7 +35,7 @@ ACE_INLINE OpenDDS_Dcps_Export DDS::Time_t time_value_to_time(const ACE_Time_Value& tv); ACE_INLINE OpenDDS_Dcps_Export -MonotonicTime_t time_value_to_monotonic_time(const ACE_Time_Value& tv); +MonotonicTime_t time_value_to_time(const ACE_Time_Value_T& tv); ACE_INLINE OpenDDS_Dcps_Export ACE_Time_Value duration_to_time_value(const DDS::Duration_t& t); diff --git a/dds/DCPS/Time_Helper.inl b/dds/DCPS/Time_Helper.inl index a4589a6684d..aa4807079db 100644 --- a/dds/DCPS/Time_Helper.inl +++ b/dds/DCPS/Time_Helper.inl @@ -201,7 +201,7 @@ DDS::Time_t time_value_to_time(const ACE_Time_Value& tv) } ACE_INLINE -MonotonicTime_t time_value_to_monotonic_time(const ACE_Time_Value& tv) +MonotonicTime_t time_value_to_time(const ACE_Time_Value_T& tv) { MonotonicTime_t t; t.sec = ACE_Utils::truncate_cast(tv.sec()); diff --git a/dds/DCPS/XTypes/DynamicDataWriterImpl.h b/dds/DCPS/XTypes/DynamicDataWriterImpl.h index e7240481e55..e661e5f79b9 100644 --- a/dds/DCPS/XTypes/DynamicDataWriterImpl.h +++ b/dds/DCPS/XTypes/DynamicDataWriterImpl.h @@ -26,7 +26,7 @@ class OpenDDS_Dcps_Export DynamicDataWriterImpl public: DDS::InstanceHandle_t register_instance(DDS::DynamicData_ptr instance) { - return register_instance_w_timestamp(instance, DCPS::SystemTimePoint::now().to_dds_time()); + return register_instance_w_timestamp(instance, DCPS::SystemTimePoint::now().to_idl_struct()); } DDS::InstanceHandle_t register_instance_w_timestamp( @@ -40,7 +40,7 @@ class OpenDDS_Dcps_Export DynamicDataWriterImpl DDS::DynamicData_ptr instance, DDS::InstanceHandle_t handle) { return unregister_instance_w_timestamp(instance, handle, - DCPS::SystemTimePoint::now().to_dds_time()); + DCPS::SystemTimePoint::now().to_idl_struct()); } DDS::ReturnCode_t unregister_instance_w_timestamp( @@ -52,7 +52,7 @@ class OpenDDS_Dcps_Export DynamicDataWriterImpl DDS::ReturnCode_t write(DDS::DynamicData_ptr instance_data, DDS::InstanceHandle_t handle) { - return write_w_timestamp(instance_data, handle, DCPS::SystemTimePoint::now().to_dds_time()); + return write_w_timestamp(instance_data, handle, DCPS::SystemTimePoint::now().to_idl_struct()); } DDS::ReturnCode_t write_w_timestamp(DDS::DynamicData_ptr instance_data, @@ -66,7 +66,7 @@ class OpenDDS_Dcps_Export DynamicDataWriterImpl DDS::DynamicData_ptr instance_data, DDS::InstanceHandle_t instance_handle) { return dispose_w_timestamp(instance_data, instance_handle, - DCPS::SystemTimePoint::now().to_dds_time()); + DCPS::SystemTimePoint::now().to_idl_struct()); } DDS::ReturnCode_t dispose_w_timestamp(DDS::DynamicData_ptr instance_data, diff --git a/dds/DCPS/transport/tcp/TcpDataLink.cpp b/dds/DCPS/transport/tcp/TcpDataLink.cpp index 628181c3c7e..b4897c38d24 100644 --- a/dds/DCPS/transport/tcp/TcpDataLink.cpp +++ b/dds/DCPS/transport/tcp/TcpDataLink.cpp @@ -321,7 +321,7 @@ OpenDDS::DCPS::TcpDataLink::send_graceful_disconnect_message() //header_data.message_length_ = 0; //header_data.sequence_ = 0; //DDS::Time_t source_timestamp - // = SystemTimePoint::now().to_dds_time(); + // = SystemTimePoint::now().to_idl_struct(); //header_data.source_timestamp_sec_ = source_timestamp.sec; //header_data.source_timestamp_nanosec_ = source_timestamp.nanosec; //header_data.coherency_group_ = 0; diff --git a/dds/FACE/FaceTSS.cpp b/dds/FACE/FaceTSS.cpp index 573bd14e745..edf1a80208e 100644 --- a/dds/FACE/FaceTSS.cpp +++ b/dds/FACE/FaceTSS.cpp @@ -878,7 +878,7 @@ void populate_header_received(const FACE::CONNECTION_ID_TYPE& connection_id, header.message_timestamp = convertTime(sinfo.source_timestamp); const OpenDDS::DCPS::SystemTimePoint now = OpenDDS::DCPS::SystemTimePoint::now(); - readers[connection_id]->sum_recvd_msgs_latency += (convertTime(now.to_dds_time()) - header.message_timestamp); + readers[connection_id]->sum_recvd_msgs_latency += (convertTime(now.to_idl_struct()) - header.message_timestamp); ++readers[connection_id]->total_msgs_recvd; if (OpenDDS::DCPS::DCPS_debug_level > 8) { diff --git a/tools/rtpsrelay/RelayParticipantStatusReporter.cpp b/tools/rtpsrelay/RelayParticipantStatusReporter.cpp index c7ee2630bbb..1c65d6ac1db 100644 --- a/tools/rtpsrelay/RelayParticipantStatusReporter.cpp +++ b/tools/rtpsrelay/RelayParticipantStatusReporter.cpp @@ -7,7 +7,7 @@ void RelayParticipantStatusReporter::add_participant(const OpenDDS::DCPS::GUID_t { const auto monotonic_now = OpenDDS::DCPS::MonotonicTimePoint::now(); const auto system_now = OpenDDS::DCPS::SystemTimePoint::now(); - const DDS::Time_t timestamp = system_now.to_dds_time(); + const DDS::Time_t timestamp = system_now.to_idl_struct(); RelayParticipantStatus status; status.relay_id(config_.relay_id()); @@ -94,7 +94,7 @@ void RelayParticipantStatusReporter::set_alive(const OpenDDS::DCPS::GUID_t& repo } pos->second.alive(alive); - pos->second.alive_ts(system_now.to_dds_time()); + pos->second.alive_ts(system_now.to_idl_struct()); if (writer_->write(pos->second, DDS::HANDLE_NIL) != DDS::RETCODE_OK) { ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: " @@ -120,7 +120,7 @@ void RelayParticipantStatusReporter::set_active(const OpenDDS::DCPS::GUID_t& rep } pos->second.active(active); - pos->second.active_ts(system_now.to_dds_time()); + pos->second.active_ts(system_now.to_idl_struct()); if (writer_->write(pos->second, DDS::HANDLE_NIL) != DDS::RETCODE_OK) { ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: " @@ -146,7 +146,7 @@ void RelayParticipantStatusReporter::set_alive_active(const OpenDDS::DCPS::GUID_ return; } - const DDS::Time_t timestamp = system_now.to_dds_time(); + const DDS::Time_t timestamp = system_now.to_idl_struct(); if (pos->second.alive() != alive) { pos->second.alive(alive); pos->second.alive_ts(timestamp); From 2c1c94b6fb89eabfdde67adc0730464f70684a27 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Thu, 6 Jun 2024 20:27:21 +0000 Subject: [PATCH 54/60] added NEWS --- docs/news.d/thread-status-boottime.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 docs/news.d/thread-status-boottime.rst diff --git a/docs/news.d/thread-status-boottime.rst b/docs/news.d/thread-status-boottime.rst new file mode 100644 index 00000000000..2d69a865feb --- /dev/null +++ b/docs/news.d/thread-status-boottime.rst @@ -0,0 +1,12 @@ +.. news-prs: 4677 + +.. news-start-section: Additions +- Added a new data member, monotonic_timestamp to the InternalThreadBuiltInTopic IDL struct. + - monotonic_timestamp is the time of the sample was written (time of last update of this instance) on the monotonic clock. + - On systems that don't support a monotonic clock, this will be the same value as the corresponding SampleInfo's source_timestamp. +.. news-end-section + +.. news-start-section: Fixes +- When :cfg:prop:`DCPSThreadStatusInterval` is enabled, threads that run the ACE Reactor now use timers instead of a time-limited select() system call to update the InternalThreadBuiltInTopic. + - This allows the InternalThreadBuiltInTopic to be updated accurately on systems that suspend/resume and are configured for boottime timers. +.. news-end-section From b2d528331b51441350aacf6f8b07c14beced6e4a Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Thu, 6 Jun 2024 21:10:46 +0000 Subject: [PATCH 55/60] Updated for platforms that don't have OPENDDS_USES_MONOTONIC_TIME --- dds/DCPS/TimePoint_T.inl | 4 +++- dds/DCPS/Time_Helper.h | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dds/DCPS/TimePoint_T.inl b/dds/DCPS/TimePoint_T.inl index 693c054fcbb..176a9e4cd53 100644 --- a/dds/DCPS/TimePoint_T.inl +++ b/dds/DCPS/TimePoint_T.inl @@ -88,7 +88,9 @@ ACE_INLINE IdlType TimePoint_T::to_idl_struct() const { - return time_value_to_time(value_); + IdlType i; + time_value_to_time(i, value_); + return i; } template diff --git a/dds/DCPS/Time_Helper.h b/dds/DCPS/Time_Helper.h index 170282fcc26..07874ae5434 100644 --- a/dds/DCPS/Time_Helper.h +++ b/dds/DCPS/Time_Helper.h @@ -31,6 +31,13 @@ ACE_Time_Value time_to_time_value(const TimeT& t) return tv; } +template +void time_value_to_time(IdlType& t, const ACE_Time_Value& tv) +{ + t.sec = ACE_Utils::truncate_cast(tv.sec()); + t.nanosec = ACE_Utils::truncate_cast(tv.usec() * 1000); +} + ACE_INLINE OpenDDS_Dcps_Export DDS::Time_t time_value_to_time(const ACE_Time_Value& tv); From df9e1b8a7b69a2a577ad7342d722c46acce02ae5 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Thu, 6 Jun 2024 21:27:47 +0000 Subject: [PATCH 56/60] configure: updated for Visual Studio 2022 17.10 version of cl --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 619d7ae87f3..7b7732633b1 100755 --- a/configure +++ b/configure @@ -62,7 +62,7 @@ my %platforminfo = 'cl_versions' => {13.1 => 'vc71', 14 => 'vc8', 15 => 'vc9', 16 => 'vc10', 17 => 'vc11', 18 => 'vc12', 19 => 'vc14', 19.1 => 'vs2017', - 19.2 => 'vs2019', 19.3 => 'vs2022'}, + 19.2 => 'vs2019', 19.3 => 'vs2022', 19.4 => 'vs2022'}, 'cl_archs' => {'x64' => 1, 'Win32' => 1, 'ARM64' => 0, 'ARM' => 0}, # 1 if supported }, 'macos' => { From d46f463f974567f5d961877281c93a5a05fec70a Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Thu, 6 Jun 2024 18:01:39 -0500 Subject: [PATCH 57/60] TypeSupportPlugin Should Use ConsolidatedMessenger --- tests/DCPS/TypeSupportPlugin/.gitignore | 15 +-------------- .../DCPS/TypeSupportPlugin/TypeSupportPlugin.cpp | 4 ++-- .../DCPS/TypeSupportPlugin/TypeSupportPlugin.idl | 5 ----- .../DCPS/TypeSupportPlugin/TypeSupportPlugin.mpc | 13 +------------ tests/DCPS/TypeSupportPlugin/run_test.pl | 4 +++- 5 files changed, 7 insertions(+), 34 deletions(-) delete mode 100644 tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.idl diff --git a/tests/DCPS/TypeSupportPlugin/.gitignore b/tests/DCPS/TypeSupportPlugin/.gitignore index 96684813881..a9d51f1adaa 100644 --- a/tests/DCPS/TypeSupportPlugin/.gitignore +++ b/tests/DCPS/TypeSupportPlugin/.gitignore @@ -1,14 +1 @@ -/TypeSupportPluginUser -/TypeSupportPluginC.cpp -/TypeSupportPluginC.h -/TypeSupportPluginC.inl -/TypeSupportPluginS.cpp -/TypeSupportPluginS.h -/TypeSupportPluginTypeSupportC.cpp -/TypeSupportPluginTypeSupportC.h -/TypeSupportPluginTypeSupportC.inl -/TypeSupportPluginTypeSupport.idl -/TypeSupportPluginTypeSupportImpl.cpp -/TypeSupportPluginTypeSupportImpl.h -/TypeSupportPluginTypeSupportS.cpp -/TypeSupportPluginTypeSupportS.h +/TypeSupportPlugin diff --git a/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.cpp b/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.cpp index bc11fcf43a7..357710ca3ab 100644 --- a/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.cpp +++ b/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.cpp @@ -20,12 +20,12 @@ int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); ACE_DLL ts_plugin; - if (ts_plugin.open(ACE_TEXT("TypeSupportPlugin"))) { + if (ts_plugin.open(ACE_TEXT("ConsolidatedMessengerIdl"))) { ACE_ERROR((LM_ERROR, "ERROR: Failed to open the type support library\n")); return 1; } - const char* type_name = "TopicType"; + const char* const type_name = "Messenger::Message"; ACE_DEBUG((LM_DEBUG, "Getting TypeSupport for %C\n", type_name)); DDS::TypeSupport_var ts = Registered_Data_Types->lookup(0, type_name); if (!ts) { diff --git a/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.idl b/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.idl deleted file mode 100644 index c13c2781640..00000000000 --- a/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.idl +++ /dev/null @@ -1,5 +0,0 @@ -@topic -struct TopicType { - @key long key; - string value; -}; diff --git a/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.mpc b/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.mpc index c8a381b3266..e8a4b6b125d 100644 --- a/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.mpc +++ b/tests/DCPS/TypeSupportPlugin/TypeSupportPlugin.mpc @@ -1,15 +1,4 @@ -project(TypeSupportPlugin): dcps_test { - TypeSupport_Files { - dcps_ts_flags += -Gxtypes-complete - TypeSupportPlugin.idl - } - - Source_Files { - } -} - -project(TypeSupportPluginUser): dcps_test { - exename = TypeSupportPluginUser +project: dcps_cm { Source_Files { TypeSupportPlugin.cpp } diff --git a/tests/DCPS/TypeSupportPlugin/run_test.pl b/tests/DCPS/TypeSupportPlugin/run_test.pl index c81011934cc..f02c10e0e4d 100755 --- a/tests/DCPS/TypeSupportPlugin/run_test.pl +++ b/tests/DCPS/TypeSupportPlugin/run_test.pl @@ -8,7 +8,9 @@ use lib "$ENV{DDS_ROOT}/bin"; use PerlDDS::Run_Test; +PerlDDS::add_lib_path('../ConsolidatedMessengerIdl'); + my $test = new PerlDDS::TestFramework(); -$test->process('test', 'TypeSupportPluginUser', join(' ', @ARGV)); +$test->process('test', 'TypeSupportPlugin', join(' ', @ARGV)); $test->start_process('test'); exit $test->finish(60); From 10c6b35a7243bb6ba156f75ad0854fd009870c1a Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Thu, 6 Jun 2024 19:18:42 -0500 Subject: [PATCH 58/60] Make CMake and Configure Fallback To Last Known VS --- cmake/get_ace_tao.cmake | 40 +++++++++++++++++++++++++++++----------- configure | 24 +++++++++++++++--------- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/cmake/get_ace_tao.cmake b/cmake/get_ace_tao.cmake index 54b3b9b187e..28b723d0fba 100644 --- a/cmake/get_ace_tao.cmake +++ b/cmake/get_ace_tao.cmake @@ -4,22 +4,40 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) cmake_policy(SET CMP0135 NEW) endif() +function(_opendds_set_vs_mpc_type) + set(vs_vers + "Visual Studio 14 2015" vc14 + "Visual Studio 15 2017" vs2017 + "Visual Studio 16 2019" vs2019 + "Visual Studio 17 2022" vs2022 + ) + + set(mpc_vs_name) + list(LENGTH vs_vers vs_vers_count) + math(EXPR vs_vers_count_end "${vs_vers_count} - 1") + foreach(i RANGE 0 ${vs_vers_count_end} 2) + list(GET vs_vers ${i} cmake_name) + math(EXPR next "${i} + 1") + list(GET vs_vers ${next} mpc_name) + if(cmake_name STREQUAL CMAKE_GENERATOR) + set(mpc_vs_name "${mpc_name}") + break() + endif() + endforeach() + if(NOT mpc_vs_name) + message(STATUS "Missing a MPC project type for \"${CMAKE_GENERATOR}\", " + "using last known: \"${cmake_name}\"/${mpc_name}") + set(mpc_vs_name "${mpc_name}") + endif() + set(_OPENDDS_MPC_TYPE "${mpc_vs_name}" PARENT_SCOPE) +endfunction() + set(_OPENDDS_CONFIGURE_ACE_TAO_ARGS) set(ACE_IS_BEING_BUILT MPC CACHE INTERNAL "") set(TAO_IS_BEING_BUILT MPC CACHE INTERNAL "") if(WIN32) set(ext "zip") - if(CMAKE_GENERATOR STREQUAL "Visual Studio 17 2022") - set(_OPENDDS_MPC_TYPE vs2022) - elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 16 2019") - set(_OPENDDS_MPC_TYPE vs2019) - elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 15 2017") - set(_OPENDDS_MPC_TYPE vs2017) - elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 14 2015") - set(_OPENDDS_MPC_TYPE vc14) - else() - set(_OPENDDS_MPC_TYPE vs2022) - endif() + _opendds_set_vs_mpc_type() set(_OPENDDS_ACE_CONFIG_FILE "config-win32.h") else() set(ext "tar.bz2") diff --git a/configure b/configure index 619d7ae87f3..1c5a8e08856 100755 --- a/configure +++ b/configure @@ -773,20 +773,26 @@ EOF if ($arch eq 'Unknown') { die "cl version probe failed, no known architecture macro was defined\nStopped"; } - if (!exists $platforminfo{'win32'}->{'cl_archs'}->{$arch}) { - die "cl version probe failed, invalid architecture \"$arch\"\nStopped"; + + my $archs = $platforminfo{'win32'}->{'cl_archs'}; + if (!exists($archs->{$arch})) { + die "cl version probe failed, unknown architecture \"$arch\"\nStopped"; } - if (!$platforminfo{'win32'}->{'cl_archs'}->{$arch}) { + if (!$archs->{$arch}) { die "ERROR: Windows for $arch isn't supported\nStopped"; } - if (!exists $platforminfo{'win32'}->{'cl_versions'}->{$ver}) { - die "ERROR: Unknown or unsupported Visual C++ compiler version: $ver\n" - . "Stopped"; - } - - $opts{'compiler_version'} = $platforminfo{'win32'}->{'cl_versions'}->{$ver}; $opts{'compiler_target_architecture'} = $arch; + my $vers = $platforminfo{'win32'}->{'cl_versions'}; + if (!exists($vers->{$ver})) { + my @vers_sorted = sort(keys(%{$vers})); + my $last_cl = $vers_sorted[-1]; + print "$ver isn't a known version of cl, using the last known version: $last_cl\n" + if $opts{'verbose'}; + $ver = $last_cl; + } + $opts{'compiler_version'} = $vers->{$ver}; + if ($ver >= 19) { push(@features, 'no_cxx11=0'); print "Visual C++ has >= C++11 support\n" if $opts{'verbose'}; From 9d812c8233adda58172b368d012afaa299f99a6f Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 7 Jun 2024 08:03:22 -0500 Subject: [PATCH 59/60] Apply suggestions from code review Co-authored-by: Fred Hornsey --- dds/DCPS/ThreadStatusManager.h | 1 - dds/DCPS/Time_Helper.h | 2 +- docs/news.d/thread-status-boottime.rst | 12 +++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dds/DCPS/ThreadStatusManager.h b/dds/DCPS/ThreadStatusManager.h index f25eef55b43..c0c917933d8 100644 --- a/dds/DCPS/ThreadStatusManager.h +++ b/dds/DCPS/ThreadStatusManager.h @@ -199,7 +199,6 @@ class OpenDDS_Dcps_Export ThreadStatusManager { mutable ACE_Thread_Mutex lock_; }; - } // namespace DCPS } // namespace OpenDDS diff --git a/dds/DCPS/Time_Helper.h b/dds/DCPS/Time_Helper.h index 07874ae5434..e083ec1c5e2 100644 --- a/dds/DCPS/Time_Helper.h +++ b/dds/DCPS/Time_Helper.h @@ -42,7 +42,7 @@ ACE_INLINE OpenDDS_Dcps_Export DDS::Time_t time_value_to_time(const ACE_Time_Value& tv); ACE_INLINE OpenDDS_Dcps_Export -MonotonicTime_t time_value_to_time(const ACE_Time_Value_T& tv); +MonotonicTime_t time_value_to_time(const ACE_Time_Value_T& tv); ACE_INLINE OpenDDS_Dcps_Export ACE_Time_Value duration_to_time_value(const DDS::Duration_t& t); diff --git a/docs/news.d/thread-status-boottime.rst b/docs/news.d/thread-status-boottime.rst index 2d69a865feb..78310d40f48 100644 --- a/docs/news.d/thread-status-boottime.rst +++ b/docs/news.d/thread-status-boottime.rst @@ -1,12 +1,14 @@ .. news-prs: 4677 .. news-start-section: Additions -- Added a new data member, monotonic_timestamp to the InternalThreadBuiltInTopic IDL struct. - - monotonic_timestamp is the time of the sample was written (time of last update of this instance) on the monotonic clock. - - On systems that don't support a monotonic clock, this will be the same value as the corresponding SampleInfo's source_timestamp. +- Added a new data member, ``monotonic_timestamp`` to the ``InternalThreadBuiltInTopic`` IDL struct. + + - ``monotonic_timestamp`` is the time of the sample was written (time of last update of this instance) on the monotonic clock. + - On systems that don't support a monotonic clock, this will be the same value as the corresponding ``SampleInfo``'s ``source_timestamp``. .. news-end-section .. news-start-section: Fixes -- When :cfg:prop:`DCPSThreadStatusInterval` is enabled, threads that run the ACE Reactor now use timers instead of a time-limited select() system call to update the InternalThreadBuiltInTopic. - - This allows the InternalThreadBuiltInTopic to be updated accurately on systems that suspend/resume and are configured for boottime timers. +- When :cfg:prop:`DCPSThreadStatusInterval` is enabled, threads that run the ACE Reactor now use timers instead of a time-limited ``select()`` system call to update the ``InternalThreadBuiltInTopic``. + + - This allows the ``InternalThreadBuiltInTopic`` to be updated accurately on systems that suspend/resume and are configured for boottime timers. .. news-end-section From a7c8efd9d19ae759bc7a2c93e5d1202d5f8e15e4 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 7 Jun 2024 13:49:36 +0000 Subject: [PATCH 60/60] reverted change from review - didn't compile --- dds/DCPS/Time_Helper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dds/DCPS/Time_Helper.h b/dds/DCPS/Time_Helper.h index e083ec1c5e2..07874ae5434 100644 --- a/dds/DCPS/Time_Helper.h +++ b/dds/DCPS/Time_Helper.h @@ -42,7 +42,7 @@ ACE_INLINE OpenDDS_Dcps_Export DDS::Time_t time_value_to_time(const ACE_Time_Value& tv); ACE_INLINE OpenDDS_Dcps_Export -MonotonicTime_t time_value_to_time(const ACE_Time_Value_T& tv); +MonotonicTime_t time_value_to_time(const ACE_Time_Value_T& tv); ACE_INLINE OpenDDS_Dcps_Export ACE_Time_Value duration_to_time_value(const DDS::Duration_t& t);