From 57db79afb8ce65791450f9859f28c36e43088e4c Mon Sep 17 00:00:00 2001 From: Peguen <73380451+Peguen@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:57:29 +0100 Subject: [PATCH] Revert "rework tl" This reverts commit 128ae8f5eab89032352713361c020b7c7de1fe2e. --- .../include/ecal/config/transport_layer.h | 51 ++++++++++++------- .../core/src/config/configuration_to_yaml.cpp | 6 +-- ecal/core/src/config/configuration_to_yaml.h | 6 +-- ecal/core/src/config/transport_layer.cpp | 15 +++++- 4 files changed, 53 insertions(+), 25 deletions(-) diff --git a/ecal/core/include/ecal/config/transport_layer.h b/ecal/core/include/ecal/config/transport_layer.h index 3b2605c6f2..0a30caedc2 100644 --- a/ecal/core/include/ecal/config/transport_layer.h +++ b/ecal/core/include/ecal/config/transport_layer.h @@ -33,32 +33,47 @@ namespace eCAL { namespace UDP { - struct MulticastConfiguration + namespace Network { - Types::IpAddressV4 group{"239.0.0.1"}; //!< UDP multicast group base - unsigned int ttl; /*!< UDP ttl value, also known as hop limit, is used in determining - the intermediate routers being traversed towards the destination */ - }; + struct Configuration + { + Types::IpAddressV4 group { "239.0.0.1" }; //!< UDP multicast group base (Default: 239.0.0.1) + unsigned int ttl { 3U }; /*!< UDP ttl value, also known as hop limit, is used in determining + the intermediate routers being traversed towards the destination (Default: 3) */ + }; + } + + namespace Local + { + struct Configuration + { + Types::IpAddressV4 group { "127.255.255.255" }; //!< UDP multicast group base (Default: 127.255.255.255) + unsigned int ttl { 1U }; /*!< UDP ttl value, also known as hop limit, is used in determining + the intermediate routers being traversed towards the destination (Default: 1) */ + }; + } struct Configuration { - Types::UdpConfigVersion config_version { Types::UdpConfigVersion::V2 }; /*!< UDP configuration version (Since eCAL 5.12.) - v1: default behavior - v2: new behavior, comes with a bit more intuitive handling regarding masking of the groups (Default: v2) */ - unsigned int port { 14002 }; /*!< UDP multicast port number (Default: 14002) */ - Types::UDPMode mode { Types::UDPMode::LOCAL }; /*!< Valid modes: local, network (Default: local)*/ - Types::IpAddressV4 mask { "255.255.255.240" }; /*!< v1: Mask maximum number of dynamic multicast group (Default: 0.0.0.1-0.0.0.255) - v2: masks are now considered like routes masking (Default: 255.0.0.0-255.255.255.255)*/ + Types::UdpConfigVersion config_version { Types::UdpConfigVersion::V2 }; /*!< UDP configuration version (Since eCAL 5.12.) + v1: default behavior + v2: new behavior, comes with a bit more intuitive handling regarding masking of the groups (Default: v2) */ + unsigned int port { 14002 }; /*!< UDP multicast port number (Default: 14002) */ + Types::UDPMode mode { Types::UDPMode::LOCAL }; /*!< Valid modes: local, network (Default: local)*/ + Types::IpAddressV4 mask { "255.255.255.240" }; /*!< v1: Mask maximum number of dynamic multicast group (Default: 0.0.0.1-0.0.0.255) + v2: masks are now considered like routes masking (Default: 255.0.0.0-255.255.255.255)*/ - unsigned int send_buffer { 5242880 }; //!< UDP send buffer in bytes (Default: 5242880) - unsigned int receive_buffer { 5242880 }; //!< UDP receive buffer in bytes (Default: 5242880) - bool join_all_interfaces { false }; /*!< Linux specific setting to enable joining multicast groups on all network interfacs + unsigned int send_buffer { 5242880 }; //!< UDP send buffer in bytes (Default: 5242880) + unsigned int receive_buffer { 5242880 }; //!< UDP receive buffer in bytes (Default: 5242880) + bool join_all_interfaces { false }; /*!< Linux specific setting to enable joining multicast groups on all network interfacs independent of their link state. Enabling this makes sure that eCAL processes receive data if they are started before network devices are up and running. (Default: false)*/ - bool npcap_enabled { false }; //!< Enable to receive UDP traffic with the Npcap based receiver (Default: false) + bool npcap_enabled { false }; //!< Enable to receive UDP traffic with the Npcap based receiver (Default: false) - MulticastConfiguration network { "239.0.0.1", 3U }; //!< default: "239.0.0.1", 3U - static const MulticastConfiguration local; //!< default: "127.255.255.255", 1U + Network::Configuration network; + const Local::Configuration local; + + ECAL_API Configuration& operator=(const Configuration& other); }; } diff --git a/ecal/core/src/config/configuration_to_yaml.cpp b/ecal/core/src/config/configuration_to_yaml.cpp index f36c908d3e..e49f2d85ff 100644 --- a/ecal/core/src/config/configuration_to_yaml.cpp +++ b/ecal/core/src/config/configuration_to_yaml.cpp @@ -220,7 +220,7 @@ namespace YAML return true; } - Node convert::encode(const eCAL::TransportLayer::UDP::MulticastConfiguration& config_) + Node convert::encode(const eCAL::TransportLayer::UDP::Network::Configuration& config_) { Node node; node["group"] = config_.group.Get(); @@ -228,7 +228,7 @@ namespace YAML return node; } - bool convert::decode(const Node& node_, eCAL::TransportLayer::UDP::MulticastConfiguration& config_) + bool convert::decode(const Node& node_, eCAL::TransportLayer::UDP::Network::Configuration& config_) { AssignValue(config_.group, node_, "group"); AssignValue(config_.ttl, node_, "ttl"); @@ -265,7 +265,7 @@ namespace YAML AssignValue(config_.join_all_interfaces, node_, "join_all_interfaces"); AssignValue(config_.npcap_enabled, node_, "npcap_enabled"); - AssignValue(config_.network, node_, "network"); + AssignValue(config_.network, node_, "network"); return true; } diff --git a/ecal/core/src/config/configuration_to_yaml.h b/ecal/core/src/config/configuration_to_yaml.h index 438b294ae0..b983f350f8 100644 --- a/ecal/core/src/config/configuration_to_yaml.h +++ b/ecal/core/src/config/configuration_to_yaml.h @@ -110,11 +110,11 @@ namespace YAML }; template<> - struct convert + struct convert { - static Node encode(const eCAL::TransportLayer::UDP::MulticastConfiguration& config_); + static Node encode(const eCAL::TransportLayer::UDP::Network::Configuration& config_); - static bool decode(const Node& node_, eCAL::TransportLayer::UDP::MulticastConfiguration& config_); + static bool decode(const Node& node_, eCAL::TransportLayer::UDP::Network::Configuration& config_); }; template<> diff --git a/ecal/core/src/config/transport_layer.cpp b/ecal/core/src/config/transport_layer.cpp index 9fb2f47403..7661d47e60 100644 --- a/ecal/core/src/config/transport_layer.cpp +++ b/ecal/core/src/config/transport_layer.cpp @@ -25,7 +25,20 @@ namespace eCAL { namespace UDP { - const MulticastConfiguration Configuration::local { "127.255.255.255", 1U }; + Configuration& Configuration::operator=(const Configuration& other) + { + config_version = other.config_version; + join_all_interfaces = other.join_all_interfaces; + mask = other.mask; + mode = other.mode; + network = other.network; + npcap_enabled = other.npcap_enabled; + port = other.port; + receive_buffer = other.receive_buffer; + send_buffer = other.send_buffer; + + return *this; + } } } } \ No newline at end of file