diff options
Diffstat (limited to 'implementation/configuration/include')
17 files changed, 615 insertions, 335 deletions
diff --git a/implementation/configuration/include/client.hpp b/implementation/configuration/include/client.hpp index 81ed890..7758eca 100644 --- a/implementation/configuration/include/client.hpp +++ b/implementation/configuration/include/client.hpp @@ -3,8 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CFG_CLIENT_HPP -#define VSOMEIP_CFG_CLIENT_HPP +#ifndef VSOMEIP_V3_CFG_CLIENT_HPP +#define VSOMEIP_V3_CFG_CLIENT_HPP #include <map> #include <memory> @@ -12,7 +12,7 @@ #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { namespace cfg { struct client { @@ -29,6 +29,6 @@ struct client { }; } // namespace cfg -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_CFG_CLIENT_HPP +#endif // VSOMEIP_V3_CFG_CLIENT_HPP diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index 9740a79..aac5422 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -3,13 +3,14 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CONFIGURATION_HPP -#define VSOMEIP_CONFIGURATION_HPP +#ifndef VSOMEIP_V3_CONFIGURATION_HPP +#define VSOMEIP_V3_CONFIGURATION_HPP #include <map> #include <memory> #include <set> #include <string> +#include <chrono> #include <boost/asio/ip/address.hpp> #include <boost/log/trivial.hpp> @@ -19,24 +20,35 @@ #include <vsomeip/plugin.hpp> #include <vsomeip/primitive_types.hpp> -#include "internal.hpp" #include "trace.hpp" #include "../../e2e_protection/include/e2exf/config.hpp" #include "e2e.hpp" -#include "policy.hpp" #include "debounce.hpp" +#ifdef ANDROID +#include "internal_android.hpp" +#else +#include "internal.hpp" +#endif // ANDROID + +#include "../../security/include/policy.hpp" + #define VSOMEIP_CONFIG_PLUGIN_VERSION 1 -namespace vsomeip { +namespace vsomeip_v3 { class event; class configuration { public: - virtual ~configuration() {} + virtual ~configuration() +#ifndef ANDROID + {} +#else + ; +#endif virtual bool load(const std::string &_name) = 0; virtual bool remote_offer_info_add(service_t _service, @@ -55,8 +67,9 @@ public: virtual const boost::asio::ip::address & get_unicast_address() const = 0; virtual const boost::asio::ip::address& get_netmask() const = 0; - virtual unsigned short get_diagnosis_address() const = 0; - virtual std::uint16_t get_diagnosis_mask() const = 0; + virtual const std::string &get_device() const = 0; + virtual diagnosis_t get_diagnosis_address() const = 0; + virtual diagnosis_t get_diagnosis_mask() const = 0; virtual bool is_v4() const = 0; virtual bool is_v6() const = 0; @@ -77,6 +90,17 @@ public: virtual uint16_t get_unreliable_port(service_t _service, instance_t _instance) const = 0; + virtual void get_configured_timing_requests( + service_t _service, std::string _ip_target, + std::uint16_t _port_target, method_t _method, + std::chrono::nanoseconds *_debounce_time, + std::chrono::nanoseconds *_max_retention_time) const = 0; + virtual void get_configured_timing_responses( + service_t _service, std::string _ip_service, + std::uint16_t _port_service, method_t _method, + std::chrono::nanoseconds *_debounce_time, + std::chrono::nanoseconds *_max_retention_time) const = 0; + virtual bool is_someip(service_t _service, instance_t _instance) const = 0; virtual bool get_client_port(service_t _service, instance_t _instance, @@ -103,6 +127,7 @@ public: virtual std::uint32_t get_max_message_size_local() const = 0; virtual std::uint32_t get_max_message_size_reliable(const std::string& _address, std::uint16_t _port) const = 0; + virtual std::uint32_t get_max_message_size_unreliable() const = 0; virtual std::uint32_t get_buffer_shrink_threshold() const = 0; virtual bool supports_selective_broadcasts(boost::asio::ip::address _address) const = 0; @@ -111,7 +136,10 @@ public: virtual bool is_local_service(service_t _service, instance_t _instance) const = 0; - virtual bool is_event_reliable(service_t _service, instance_t _instance, event_t _event) const = 0; + virtual reliability_type_e get_event_reliability( + service_t _service, instance_t _instance, event_t _event) const = 0; + virtual reliability_type_e get_service_reliability( + service_t _service, instance_t _instance) const = 0; // Service Discovery configuration virtual bool is_sd_enabled() const = 0; @@ -120,8 +148,8 @@ public: virtual uint16_t get_sd_port() const = 0; virtual const std::string & get_sd_protocol() const = 0; - virtual int32_t get_sd_initial_delay_min() const = 0; - virtual int32_t get_sd_initial_delay_max() const = 0; + virtual uint32_t get_sd_initial_delay_min() const = 0; + virtual uint32_t get_sd_initial_delay_max() const = 0; virtual int32_t get_sd_repetitions_base_delay() const = 0; virtual uint8_t get_sd_repetitions_max() const = 0; virtual ttl_t get_sd_ttl() const = 0; @@ -144,23 +172,6 @@ public: virtual bool log_version() const = 0; virtual uint32_t get_log_version_interval() const = 0; - // Security - virtual bool is_security_enabled() const = 0; - virtual bool is_client_allowed(client_t _client, service_t _service, - instance_t _instance, method_t _method, bool _is_request_service = false) const = 0; - virtual bool is_offer_allowed(client_t _client, service_t _service, - instance_t _instance) const = 0; - virtual bool check_credentials(client_t _client, - uint32_t _uid, uint32_t _gid) = 0; - virtual bool store_client_to_uid_gid_mapping(client_t _client, uint32_t _uid, uint32_t _gid) = 0; - virtual void store_uid_gid_to_client_mapping(uint32_t _uid, uint32_t _gid, client_t _client) = 0; - - virtual bool get_client_to_uid_gid_mapping(client_t _client, - std::pair<uint32_t, uint32_t> &_uid_gid) = 0; - virtual bool remove_client_to_uid_gid_mapping(client_t _client) = 0; - virtual bool get_uid_gid_to_client_mapping(std::pair<uint32_t, uint32_t> _uid_gid, - std::set<client_t> &_clients) = 0; - // Plugins virtual std::map<plugin_type_e, std::set<std::string>> get_plugins( const std::string &_name) const = 0; @@ -196,37 +207,31 @@ public: virtual std::uint32_t get_max_tcp_restart_aborts() const = 0; virtual std::uint32_t get_max_tcp_connect_time() const = 0; - // Offer acceptance - virtual bool offer_acceptance_required( - const boost::asio::ip::address& _address) const = 0; - virtual void set_offer_acceptance_required( - const boost::asio::ip::address& _address, const std::string& _path, - bool _enable) = 0; - virtual std::map<boost::asio::ip::address, std::string> get_offer_acceptance_required() = 0; - - // Security policy - virtual void update_security_policy(uint32_t _uid, uint32_t _gid, ::std::shared_ptr<policy> _policy) = 0; - virtual bool remove_security_policy(uint32_t _uid, uint32_t _gid) = 0; - - virtual void add_security_credentials(uint32_t _uid, uint32_t _gid, - ::std::shared_ptr<policy> _credentials_policy, client_t _client) = 0; - - virtual bool is_remote_client_allowed() const = 0; - - virtual bool is_policy_update_allowed(uint32_t _uid, std::shared_ptr<policy> &_policy) const = 0; - - virtual bool is_policy_removal_allowed(uint32_t _uid) const = 0; + // SD acceptance + virtual bool sd_acceptance_required(const boost::asio::ip::address& _address, + std::uint16_t _port) const = 0; + virtual void set_sd_acceptance_required( + const boost::asio::ip::address& _address, std::uint16_t _port, + const std::string& _path, bool _enable) = 0; + typedef std::map<std::pair<boost::asio::ip::address, std::uint16_t>, std::string> sd_acceptance_required_map_t; + virtual sd_acceptance_required_map_t get_sd_acceptance_required() = 0; virtual std::uint32_t get_udp_receive_buffer_size() const = 0; - virtual bool is_audit_mode_enabled() const = 0; - virtual bool check_routing_credentials(client_t _client, uint32_t _uid, uint32_t _gid) const = 0; + // SOME/IP-TP + virtual bool tp_segment_messages_client_to_service( + service_t _service, std::string _ip_target, + std::uint16_t _port_target, method_t _method) const = 0; + virtual bool tp_segment_messages_service_to_client( + service_t _service, std::string _ip_service, + std::uint16_t _port_service, method_t _method) const = 0; + // routing shutdown timeout virtual std::uint32_t get_shutdown_timeout() const = 0; }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_CONFIGURATION_HPP +#endif // VSOMEIP_V3_CONFIGURATION_HPP diff --git a/implementation/configuration/include/configuration_element.hpp b/implementation/configuration/include/configuration_element.hpp new file mode 100644 index 0000000..7daf9d7 --- /dev/null +++ b/implementation/configuration/include/configuration_element.hpp @@ -0,0 +1,26 @@ +// Copyright (C) 2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef VSOMEIP_V3_CONFIGURATION_CONFIGURATION_ELEMENT_HPP_ +#define VSOMEIP_V3_CONFIGURATION_CONFIGURATION_ELEMENT_HPP_ + +#include <string> + +#include <boost/property_tree/ptree.hpp> + +namespace vsomeip_v3 { + +struct configuration_element { + std::string name_; + boost::property_tree::ptree tree_; + + bool operator<(const configuration_element &_other) const { + return (name_ < _other.name_); + } +}; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_CONFIGURATION_CONFIGURATION_ELEMENT_HPP_ diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index 9bf1188..f43a97a 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -3,8 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CFG_CONFIGURATION_IMPL_HPP -#define VSOMEIP_CFG_CONFIGURATION_IMPL_HPP +#ifndef VSOMEIP_V3_CFG_CONFIGURATION_IMPL_HPP +#define VSOMEIP_V3_CFG_CONFIGURATION_IMPL_HPP #include <map> #include <memory> @@ -17,14 +17,15 @@ #include "trace.hpp" #include "configuration.hpp" +#include "configuration_element.hpp" #include "watchdog.hpp" #include "service_instance_range.hpp" -#include "policy.hpp" #include "../../e2e_protection/include/e2exf/config.hpp" #include "e2e.hpp" #include "debounce.hpp" +#include "../../security/include/policy.hpp" -namespace vsomeip { +namespace vsomeip_v3 { namespace cfg { struct client; @@ -34,18 +35,8 @@ struct event; struct eventgroup; struct watchdog; -struct element { - std::string name_; - boost::property_tree::ptree tree_; - - bool operator<(const element &_other) const { - return (name_ < _other.name_); - } -}; - class configuration_impl: public configuration, - public plugin_impl<configuration_impl>, public std::enable_shared_from_this<configuration_impl> { public: VSOMEIP_EXPORT configuration_impl(); @@ -71,6 +62,7 @@ public: VSOMEIP_EXPORT const boost::asio::ip::address & get_unicast_address() const; VSOMEIP_EXPORT const boost::asio::ip::address& get_netmask() const; + VSOMEIP_EXPORT const std::string &get_device() const; VSOMEIP_EXPORT unsigned short get_diagnosis_address() const; VSOMEIP_EXPORT std::uint16_t get_diagnosis_mask() const; VSOMEIP_EXPORT bool is_v4() const; @@ -89,6 +81,17 @@ public: VSOMEIP_EXPORT uint16_t get_unreliable_port(service_t _service, instance_t _instance) const; + VSOMEIP_EXPORT void get_configured_timing_requests( + service_t _service, std::string _ip_target, + std::uint16_t _port_target, method_t _method, + std::chrono::nanoseconds *_debounce_time, + std::chrono::nanoseconds *_max_retention_time) const; + VSOMEIP_EXPORT void get_configured_timing_responses( + service_t _service, std::string _ip_service, + std::uint16_t _port_service, method_t _method, + std::chrono::nanoseconds *_debounce_time, + std::chrono::nanoseconds *_max_retention_time) const; + VSOMEIP_EXPORT bool is_someip(service_t _service, instance_t _instance) const; VSOMEIP_EXPORT bool get_client_port(service_t _service, instance_t _instance, @@ -117,6 +120,7 @@ public: VSOMEIP_EXPORT std::uint32_t get_max_message_size_local() const; VSOMEIP_EXPORT std::uint32_t get_max_message_size_reliable(const std::string& _address, std::uint16_t _port) const; + VSOMEIP_EXPORT std::uint32_t get_max_message_size_unreliable() const; VSOMEIP_EXPORT std::uint32_t get_buffer_shrink_threshold() const; VSOMEIP_EXPORT bool supports_selective_broadcasts(boost::asio::ip::address _address) const; @@ -128,7 +132,11 @@ public: VSOMEIP_EXPORT bool is_local_service(service_t _service, instance_t _instance) const; - VSOMEIP_EXPORT bool is_event_reliable(service_t _service, instance_t _instance, event_t _event) const; + VSOMEIP_EXPORT reliability_type_e get_event_reliability( + service_t _service, instance_t _instance, event_t _event) const; + + VSOMEIP_EXPORT reliability_type_e get_service_reliability( + service_t _service, instance_t _instance) const; // Service Discovery configuration VSOMEIP_EXPORT bool is_sd_enabled() const; @@ -137,8 +145,8 @@ public: VSOMEIP_EXPORT uint16_t get_sd_port() const; VSOMEIP_EXPORT const std::string & get_sd_protocol() const; - VSOMEIP_EXPORT int32_t get_sd_initial_delay_min() const; - VSOMEIP_EXPORT int32_t get_sd_initial_delay_max() const; + VSOMEIP_EXPORT uint32_t get_sd_initial_delay_min() const; + VSOMEIP_EXPORT uint32_t get_sd_initial_delay_max() const; VSOMEIP_EXPORT int32_t get_sd_repetitions_base_delay() const; VSOMEIP_EXPORT uint8_t get_sd_repetitions_max() const; VSOMEIP_EXPORT ttl_t get_sd_ttl() const; @@ -156,22 +164,7 @@ public: VSOMEIP_EXPORT std::uint32_t get_permissions_uds() const; VSOMEIP_EXPORT std::uint32_t get_permissions_shm() const; - // Policy - VSOMEIP_EXPORT bool is_security_enabled() const; - VSOMEIP_EXPORT bool is_client_allowed(client_t _client, service_t _service, - instance_t _instance, method_t _method, bool _is_request_service = false) const; - VSOMEIP_EXPORT bool is_offer_allowed(client_t _client, service_t _service, - instance_t _instance) const; - VSOMEIP_EXPORT bool check_credentials(client_t _client, - uint32_t _uid, uint32_t _gid); - - VSOMEIP_EXPORT bool store_client_to_uid_gid_mapping(client_t _client, uint32_t _uid, uint32_t _gid); - VSOMEIP_EXPORT void store_uid_gid_to_client_mapping(uint32_t _uid, uint32_t _gid, client_t _client); - VSOMEIP_EXPORT bool get_client_to_uid_gid_mapping(client_t _client, - std::pair<uint32_t, uint32_t> &_uid_gid); - VSOMEIP_EXPORT bool remove_client_to_uid_gid_mapping(client_t _client); - VSOMEIP_EXPORT bool get_uid_gid_to_client_mapping(std::pair<uint32_t, uint32_t> _uid_gid, - std::set<client_t> &_clients); + VSOMEIP_EXPORT bool check_routing_credentials(client_t _client, uint32_t _uid, uint32_t _gid) const; VSOMEIP_EXPORT std::map<plugin_type_e, std::set<std::string>> get_plugins( const std::string &_name) const; @@ -198,52 +191,59 @@ public: VSOMEIP_EXPORT std::uint32_t get_max_tcp_restart_aborts() const; VSOMEIP_EXPORT std::uint32_t get_max_tcp_connect_time() const; - VSOMEIP_EXPORT bool offer_acceptance_required( - const boost::asio::ip::address& _address) const; - - VSOMEIP_EXPORT void set_offer_acceptance_required( - const boost::asio::ip::address& _address, const std::string& _path, - bool _enable); - VSOMEIP_EXPORT std::map<boost::asio::ip::address, std::string> get_offer_acceptance_required(); - - VSOMEIP_EXPORT void update_security_policy(uint32_t _uid, uint32_t _gid, ::std::shared_ptr<policy> _policy); - VSOMEIP_EXPORT bool remove_security_policy(uint32_t _uid, uint32_t _gid); - - VSOMEIP_EXPORT void add_security_credentials(uint32_t _uid, uint32_t _gid, - ::std::shared_ptr<policy> _credentials_policy, client_t _client); + VSOMEIP_EXPORT bool sd_acceptance_required(const boost::asio::ip::address& _address, + std::uint16_t _port) const; - VSOMEIP_EXPORT bool is_remote_client_allowed() const; - - VSOMEIP_EXPORT bool is_policy_update_allowed(uint32_t _uid, std::shared_ptr<policy> &_policy) const; - - VSOMEIP_EXPORT bool is_policy_removal_allowed(uint32_t _uid) const; + VSOMEIP_EXPORT void set_sd_acceptance_required( + const boost::asio::ip::address& _address, std::uint16_t _port, + const std::string& _path, bool _enable); + VSOMEIP_EXPORT sd_acceptance_required_map_t get_sd_acceptance_required(); VSOMEIP_EXPORT std::uint32_t get_udp_receive_buffer_size() const; - VSOMEIP_EXPORT bool is_audit_mode_enabled() const; + VSOMEIP_EXPORT bool has_overlay(const std::string &_name) const; + VSOMEIP_EXPORT void load_overlay(const std::string &_name); - VSOMEIP_EXPORT bool check_routing_credentials(client_t _client, uint32_t _uid, uint32_t _gid) const; + VSOMEIP_EXPORT bool tp_segment_messages_client_to_service( + service_t _service, std::string _ip_target, + std::uint16_t _port_target, method_t _method) const; + VSOMEIP_EXPORT bool tp_segment_messages_service_to_client( + service_t _service, std::string _ip_service, + std::uint16_t _port_service, method_t _method) const; VSOMEIP_EXPORT std::uint32_t get_shutdown_timeout() const; private: void read_data(const std::set<std::string> &_input, - std::vector<element> &_elements, + std::vector<configuration_element> &_elements, std::set<std::string> &_failed, bool _mandatory_only); - bool load_data(const std::vector<element> &_elements, + bool load_data(const std::vector<configuration_element> &_elements, bool _load_mandatory, bool _load_optional); - bool load_logging(const element &_element, + bool load_logging(const configuration_element &_element, std::set<std::string> &_warnings); - bool load_routing(const element &_element); - bool load_routing_credentials(const element &_element); + bool load_routing(const configuration_element &_element); + bool load_routing_credentials(const configuration_element &_element); - bool load_applications(const element &_element); + bool load_applications(const configuration_element &_element); void load_application_data(const boost::property_tree::ptree &_tree, const std::string &_file_name); - void load_tracing(const element &_element); + std::map<plugin_type_e, std::set<std::string>> load_plugins( + const boost::property_tree::ptree &_tree, + const std::string& _application_name); + + struct plugin_config_data_t { + std::string name_; + std::string type_; + }; + + void add_plugin(std::map<plugin_type_e, std::set<std::string>> &_plugins, + const plugin_config_data_t &_plugin_data, + const std::string& _application_name); + + void load_tracing(const configuration_element &_element); void load_trace_channels(const boost::property_tree::ptree &_tree); void load_trace_channel(const boost::property_tree::ptree &_tree); void load_trace_filters(const boost::property_tree::ptree &_tree); @@ -256,17 +256,19 @@ private: const boost::property_tree::ptree &_data, std::tuple<service_t, instance_t, method_t> &_match); - void load_network(const element &_element); + void load_network(const configuration_element &_element); + void load_device(const configuration_element &_element); - void load_unicast_address(const element &_element); - void load_netmask(const element &_element); - void load_diagnosis_address(const element &_element); - void load_shutdown_timeout(const element &_element); + void load_unicast_address(const configuration_element &_element); + void load_netmask(const configuration_element &_element); + void load_diagnosis_address(const configuration_element &_element); + void load_shutdown_timeout(const configuration_element &_element); - void load_service_discovery(const element &_element); + void load_service_discovery(const configuration_element &_element); void load_delays(const boost::property_tree::ptree &_tree); - void load_services(const element &_element); + void load_npdu_default_timings(const configuration_element &_element); + void load_services(const configuration_element &_element); void load_servicegroup(const boost::property_tree::ptree &_tree); void load_service(const boost::property_tree::ptree &_tree, const std::string &_unicast_address); @@ -275,30 +277,24 @@ private: void load_eventgroup(std::shared_ptr<service> &_service, const boost::property_tree::ptree &_tree); - void load_internal_services(const element &_element); + void load_internal_services(const configuration_element &_element); - void load_clients(const element &_element); + void load_clients(const configuration_element &_element); void load_client(const boost::property_tree::ptree &_tree); std::set<uint16_t> load_client_ports(const boost::property_tree::ptree &_tree); std::pair<uint16_t, uint16_t> load_client_port_range(const boost::property_tree::ptree &_tree); - void load_watchdog(const element &_element); + void load_watchdog(const configuration_element &_element); - void load_payload_sizes(const element &_element); - void load_permissions(const element &_element); - void load_selective_broadcasts_support(const element &_element); - void load_policies(const element &_element); - void load_policy(const boost::property_tree::ptree &_tree); - void load_credential(const boost::property_tree::ptree &_tree, ids_t &_ids); - void load_ranges(const boost::property_tree::ptree &_tree, ranges_t &_range); - void load_instance_ranges(const boost::property_tree::ptree &_tree, ranges_t &_range); + void load_payload_sizes(const configuration_element &_element); + void load_permissions(const configuration_element &_element); - void load_security_update_whitelist(const element &_element); - void load_service_ranges(const boost::property_tree::ptree &_tree, - std::set<std::pair<service_t, service_t>> &_ranges); + void load_security(const configuration_element &_element); - void load_debounce(const element &_element); + void load_selective_broadcasts_support(const configuration_element &_element); + + void load_debounce(const configuration_element &_element); void load_service_debounce(const boost::property_tree::ptree &_tree); void load_events_debounce(const boost::property_tree::ptree &_tree, std::map<event_t, std::shared_ptr<debounce>> &_debounces); @@ -306,15 +302,27 @@ private: std::map<event_t, std::shared_ptr<debounce>> &_debounces); void load_event_debounce_ignore(const boost::property_tree::ptree &_tree, std::map<std::size_t, byte_t> &_ignore); - void load_offer_acceptance_required(const element &_element); - void load_udp_receive_buffer_size(const element &_element); - + void load_sd_acceptance_required(const configuration_element &_element); + void load_udp_receive_buffer_size(const configuration_element &_element); + bool load_npdu_debounce_times_configuration( + const std::shared_ptr<service>& _service, + const boost::property_tree::ptree &_tree); + bool load_npdu_debounce_times_for_service( + const std::shared_ptr<service>& _service, bool _is_request, + const boost::property_tree::ptree &_tree); + void load_someip_tp(const std::shared_ptr<service>& _service, + const boost::property_tree::ptree &_tree); + void load_someip_tp_for_service( + const std::shared_ptr<service>& _service, + const boost::property_tree::ptree &_tree, bool _is_request); servicegroup *find_servicegroup(const std::string &_name) const; std::shared_ptr<client> find_client(service_t _service, instance_t _instance) const; std::shared_ptr<service> find_service(service_t _service, instance_t _instance) const; std::shared_ptr<service> find_service_unlocked(service_t _service, instance_t _instance) const; + service * find_service_by_ip_port(service_t _service, const std::string& _ip, + std::uint16_t _port) const; std::shared_ptr<eventgroup> find_eventgroup(service_t _service, instance_t _instance, eventgroup_t _eventgroup) const; bool find_port(uint16_t &_port, uint16_t _remote, bool _reliable, @@ -323,32 +331,30 @@ private: void set_magic_cookies_unicast_address(); bool is_mandatory(const std::string &_name) const; - bool is_remote(std::shared_ptr<service> _service) const; + bool is_remote(const std::shared_ptr<service>& _service) const; bool is_internal_service(service_t _service, instance_t _instance) const; bool is_in_port_range(uint16_t _port, std::pair<uint16_t, uint16_t> _port_range) const; void set_mandatory(const std::string &_input); void trim(std::string &_s); - void load_e2e(const element &_element); + void load_e2e(const configuration_element &_element); void load_e2e_protected(const boost::property_tree::ptree &_tree); void load_ttl_factors(const boost::property_tree::ptree &_tree, ttl_map_t* _target); - void load_endpoint_queue_sizes(const element &_element); + void load_endpoint_queue_sizes(const configuration_element &_element); - void load_tcp_restart_settings(const element &_element); - - std::shared_ptr<policy> find_client_id_policy(client_t _client) const; + void load_tcp_restart_settings(const configuration_element &_element); private: std::mutex mutex_; - mutable std::mutex ids_mutex_; - mutable std::mutex uid_to_clients_mutex_; + const std::string default_unicast_; bool is_loaded_; bool is_logging_loaded_; + bool is_overlay_; std::set<std::string> mandatory_; @@ -356,8 +362,9 @@ protected: // Configuration data boost::asio::ip::address unicast_; boost::asio::ip::address netmask_; - unsigned short diagnosis_; - std::uint16_t diagnosis_mask_; + std::string device_; + diagnosis_t diagnosis_; + diagnosis_t diagnosis_mask_; bool has_console_log_; bool has_file_log_; @@ -365,8 +372,21 @@ protected: std::string logfile_; boost::log::trivial::severity_level loglevel_; - std::map<std::string, std::tuple<client_t, std::size_t, std::size_t, - size_t, size_t, std::map<plugin_type_e, std::set<std::string>>, int>> applications_; + std::map<std::string, + std::tuple< + client_t, + std::size_t, + std::size_t, + std::size_t, + std::size_t, + std::map< + plugin_type_e, + std::set<std::string> + >, + int, + std::string + > + > applications_; std::set<client_t> client_identifiers_; mutable std::mutex services_mutex_; @@ -374,6 +394,11 @@ protected: std::map<instance_t, std::shared_ptr<service> > > services_; + std::map<std::string, // IP + std::map<std::uint16_t, // port + std::map<service_t, + std::shared_ptr<service>>>> services_by_ip_port_; + std::list< std::shared_ptr<client> > clients_; std::string routing_host_; @@ -383,8 +408,8 @@ protected: std::string sd_multicast_; uint16_t sd_port_; - int32_t sd_initial_delay_min_; - int32_t sd_initial_delay_max_; + uint32_t sd_initial_delay_min_; + uint32_t sd_initial_delay_max_; int32_t sd_repetitions_base_delay_; uint8_t sd_repetitions_max_; ttl_t sd_ttl_; @@ -398,6 +423,7 @@ protected: std::uint32_t max_configured_message_size_; std::uint32_t max_local_message_size_; std::uint32_t max_reliable_message_size_; + std::uint32_t max_unreliable_message_size_; std::uint32_t buffer_shrink_threshold_; std::shared_ptr<trace> trace_; @@ -414,6 +440,7 @@ protected: enum element_type_e { ET_NETWORK, ET_UNICAST, + ET_DEVICE, ET_DIAGNOSIS, ET_DIAGNOSIS_MASK, ET_LOGGING_CONSOLE, @@ -445,32 +472,21 @@ protected: ET_ENDPOINT_QUEUE_LIMIT_LOCAL, ET_TCP_RESTART_ABORTS_MAX, ET_TCP_CONNECT_TIME_MAX, - ET_OFFER_ACCEPTANCE_REQUIRED, + ET_SD_ACCEPTANCE_REQUIRED, ET_NETMASK, ET_UDP_RECEIVE_BUFFER_SIZE, + ET_NPDU_DEFAULT_TIMINGS, + ET_PLUGIN_NAME, + ET_PLUGIN_TYPE, ET_ROUTING_CREDENTIALS, ET_SHUTDOWN_TIMEOUT, - ET_MAX = 38 + ET_MAX = 42 }; bool is_configured_[ET_MAX]; std::uint32_t permissions_shm_; std::uint32_t permissions_uds_; - std::map<std::pair<uint16_t, uint16_t>, std::shared_ptr<policy>> policies_; - std::vector<std::shared_ptr<policy> > any_client_policies_; - - mutable std::mutex policies_mutex_; - mutable std::mutex any_client_policies_mutex_; - std::map<client_t, std::pair<uint32_t, uint32_t> > ids_; - std::map<std::pair<uint32_t, uint32_t>, std::set<client_t> > uid_to_clients_; - - bool policy_enabled_; - bool check_credentials_; - bool check_routing_credentials_; - bool allow_remote_clients_; - bool check_whitelist_; - std::string network_; std::string configuration_path_; @@ -495,27 +511,23 @@ protected: uint32_t tcp_restart_aborts_max_; uint32_t tcp_connect_time_max_; - mutable std::mutex offer_acceptance_required_ips_mutex_; - std::map<boost::asio::ip::address, std::string> offer_acceptance_required_ips_; + mutable std::mutex sd_acceptance_required_ips_mutex_; + sd_acceptance_required_map_t sd_acceptance_required_ips_; bool has_issued_methods_warning_; bool has_issued_clients_warning_; std::uint32_t udp_receive_buffer_size_; - mutable std::mutex service_interface_whitelist_mutex_; - std::set<std::pair<service_t, service_t>> service_interface_whitelist_; - - mutable std::mutex uid_whitelist_mutex_; - ranges_t uid_whitelist_; - - mutable std::mutex routing_credentials_mutex_; - std::pair<uint32_t, uint32_t> routing_credentials_; + std::chrono::nanoseconds npdu_default_debounce_requ_; + std::chrono::nanoseconds npdu_default_debounce_resp_; + std::chrono::nanoseconds npdu_default_max_retention_requ_; + std::chrono::nanoseconds npdu_default_max_retention_resp_; std::uint32_t shutdown_timeout_; }; } // namespace cfg -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_CFG_CONFIGURATION_IMPL_HPP +#endif // VSOMEIP_V3_CFG_CONFIGURATION_IMPL_HPP diff --git a/implementation/configuration/include/configuration_plugin.hpp b/implementation/configuration/include/configuration_plugin.hpp new file mode 100644 index 0000000..cbb4685 --- /dev/null +++ b/implementation/configuration/include/configuration_plugin.hpp @@ -0,0 +1,26 @@ +// Copyright (C) 2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef VSOMEIP_V3_CONFIGURATION_PLUGIN_HPP_ +#define VSOMEIP_V3_CONFIGURATION_PLUGIN_HPP_ + +#include <string> +#include <memory> + +#define VSOMEIP_CONFIG_PLUGIN_VERSION 1 + +namespace vsomeip_v3 { + +class configuration; + +class configuration_plugin { +public: + virtual ~configuration_plugin() = default; + virtual std::shared_ptr<configuration> get_configuration(const std::string &_name) = 0; +}; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_CONFIGURATION_PLUGIN_HPP_ diff --git a/implementation/configuration/include/configuration_plugin_impl.hpp b/implementation/configuration/include/configuration_plugin_impl.hpp new file mode 100644 index 0000000..fd95628 --- /dev/null +++ b/implementation/configuration/include/configuration_plugin_impl.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef VSOMEIP_V3_CONFIGURATION_CONFIGURATION_PLUGIN_IMPL_HPP_ +#define VSOMEIP_V3_CONFIGURATION_CONFIGURATION_PLUGIN_IMPL_HPP_ + +#include <map> +#include <mutex> + +#include <vsomeip/plugin.hpp> + +#include "configuration_plugin.hpp" + +namespace vsomeip_v3 { +namespace cfg { + + class configuration_impl; + +} // namespace cfg + +class configuration_plugin_impl + : public configuration_plugin, + public plugin_impl<configuration_plugin_impl> { +public: + configuration_plugin_impl(); + virtual ~configuration_plugin_impl(); + + std::shared_ptr<configuration> get_configuration(const std::string &_name); + +private: + std::mutex mutex_; + std::shared_ptr<cfg::configuration_impl> default_; +#ifdef VSOMEIP_ENABLE_CONFIGURATION_OVERLAYS + std::map<std::string, std::shared_ptr<cfg::configuration_impl> > configurations_; +#endif // VSOMEIP_ENABLE_CONFIGURATION_OVERLAYS +}; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_CONFIGURATION_CONFIGURATION_PLUGIN_IMPL_HPP_ diff --git a/implementation/configuration/include/debounce.hpp b/implementation/configuration/include/debounce.hpp index b4ce6d3..dc61514 100644 --- a/implementation/configuration/include/debounce.hpp +++ b/implementation/configuration/include/debounce.hpp @@ -3,12 +3,12 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CFG_DEBOUNCE_HPP -#define VSOMEIP_CFG_DEBOUNCE_HPP +#ifndef VSOMEIP_V3_CFG_DEBOUNCE_HPP +#define VSOMEIP_V3_CFG_DEBOUNCE_HPP #include <map> -namespace vsomeip { +namespace vsomeip_v3 { namespace cfg { // Messages are forwarded either because their value differs from the @@ -34,6 +34,6 @@ struct debounce { }; } // namespace cfg -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_CFG_DEBOUNCE_HPP +#endif // VSOMEIP_V3_CFG_DEBOUNCE_HPP diff --git a/implementation/configuration/include/e2e.hpp b/implementation/configuration/include/e2e.hpp index 94eb33d..8c873c2 100644 --- a/implementation/configuration/include/e2e.hpp +++ b/implementation/configuration/include/e2e.hpp @@ -3,48 +3,37 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CFG_E2E_HPP_ -#define VSOMEIP_CFG_E2E_HPP_ +#ifndef VSOMEIP_V3_CFG_E2E_HPP_ +#define VSOMEIP_V3_CFG_E2E_HPP_ +#include <map> #include <string> #include <vector> #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { namespace cfg { struct e2e { + typedef std::map<std::string, std::string> custom_parameters_t; e2e() : data_id(0), variant(""), profile(""), service_id(0), - event_id(0), - crc_offset(0), - data_id_mode(0), - data_length(0), - data_id_nibble_offset(0), - counter_offset(0) { + event_id(0) { } - e2e(uint16_t _data_id, std::string _variant, std::string _profile, service_t _service_id, - event_t _event_id,uint16_t _crc_offset, - uint8_t _data_id_mode, uint16_t _data_length, uint16_t _data_id_nibble_offset, uint16_t _counter_offset) : - + event_t _event_id, custom_parameters_t&& _custom_parameters) : data_id(_data_id), variant(_variant), profile(_profile), service_id(_service_id), event_id(_event_id), - crc_offset(_crc_offset), - data_id_mode(_data_id_mode), - data_length(_data_length), - data_id_nibble_offset(_data_id_nibble_offset), - counter_offset(_counter_offset) { - + custom_parameters(_custom_parameters) { } // common config @@ -54,16 +43,11 @@ struct e2e { service_t service_id; event_t event_id; - //profile 1 specific config - // [SWS_E2E_00018] - uint16_t crc_offset; - uint8_t data_id_mode; - uint16_t data_length; - uint16_t data_id_nibble_offset; - uint16_t counter_offset; + // custom parameters + custom_parameters_t custom_parameters; }; } // namespace cfg -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_CFG_E2E_HPP_ +#endif // VSOMEIP_V3_CFG_E2E_HPP_ diff --git a/implementation/configuration/include/event.hpp b/implementation/configuration/include/event.hpp index 499c49a..701ec0c 100644 --- a/implementation/configuration/include/event.hpp +++ b/implementation/configuration/include/event.hpp @@ -3,31 +3,33 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CFG_EVENT_HPP -#define VSOMEIP_CFG_EVENT_HPP +#ifndef VSOMEIP_V3_CFG_EVENT_HPP +#define VSOMEIP_V3_CFG_EVENT_HPP #include <memory> #include <vector> #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { namespace cfg { struct eventgroup; struct event { - event(event_t _id, bool _is_field, bool _is_reliable) - : id_(_id), is_field_(_is_field), is_reliable_(_is_reliable) { + event(event_t _id, bool _is_field, reliability_type_e _reliability) + : id_(_id), + is_field_(_is_field), + reliability_(_reliability) { } event_t id_; bool is_field_; - bool is_reliable_; + reliability_type_e reliability_; std::vector<std::weak_ptr<eventgroup> > groups_; }; } // namespace cfg -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_CFG_EVENT_HPP +#endif // VSOMEIP_V3_CFG_EVENT_HPP diff --git a/implementation/configuration/include/eventgroup.hpp b/implementation/configuration/include/eventgroup.hpp index c26edc0..1402b51 100644 --- a/implementation/configuration/include/eventgroup.hpp +++ b/implementation/configuration/include/eventgroup.hpp @@ -3,14 +3,14 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CFG_EVENTGROUP_HPP -#define VSOMEIP_CFG_EVENTGROUP_HPP +#ifndef VSOMEIP_V3_CFG_EVENTGROUP_HPP +#define VSOMEIP_V3_CFG_EVENTGROUP_HPP #include <memory> #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { namespace cfg { struct event; @@ -24,6 +24,6 @@ struct eventgroup { }; } // namespace cfg -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_CFG_EVENTGROUP_HPP +#endif // VSOMEIP_V3_CFG_EVENTGROUP_HPP diff --git a/implementation/configuration/include/internal.hpp.in b/implementation/configuration/include/internal.hpp.in index b1a1372..36a6355 100644 --- a/implementation/configuration/include/internal.hpp.in +++ b/implementation/configuration/include/internal.hpp.in @@ -1,10 +1,10 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2019 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_INTERNAL_HPP -#define VSOMEIP_INTERNAL_HPP +#ifndef VSOMEIP_V3_INTERNAL_HPP_ +#define VSOMEIP_V3_INTERNAL_HPP_ #include <cstdint> #include <limits> @@ -13,35 +13,42 @@ #define VSOMEIP_ENV_APPLICATION_NAME "VSOMEIP_APPLICATION_NAME" #define VSOMEIP_ENV_CONFIGURATION "VSOMEIP_CONFIGURATION" #define VSOMEIP_ENV_CONFIGURATION_MODULE "VSOMEIP_CONFIGURATION_MODULE" +#define VSOMEIP_ENV_E2E_PROTECTION_MODULE "VSOMEIP_E2E_PROTECTION_MODULE" #define VSOMEIP_ENV_MANDATORY_CONFIGURATION_FILES "VSOMEIP_MANDATORY_CONFIGURATION_FILES" #define VSOMEIP_ENV_LOAD_PLUGINS "VSOMEIP_LOAD_PLUGINS" #define VSOMEIP_ENV_CLIENTSIDELOGGING "VSOMEIP_CLIENTSIDELOGGING" -#define VSOMEIP_DEFAULT_CONFIGURATION_FILE "/etc/vsomeip.json" +#define VSOMEIP_DEFAULT_CONFIGURATION_FILE "@DEFAULT_CONFIGURATION_FILE@" #define VSOMEIP_LOCAL_CONFIGURATION_FILE "./vsomeip.json" #define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json,vsomeip_log.json,vsomeip_security.json,vsomeip_whitelist.json" -#define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip" +#define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "@DEFAULT_CONFIGURATION_FOLDER@" #define VSOMEIP_DEBUG_CONFIGURATION_FOLDER "/var/opt/public/sin/vsomeip/" #define VSOMEIP_LOCAL_CONFIGURATION_FOLDER "./vsomeip" -#define VSOMEIP_BASE_PATH "/tmp/" +#define VSOMEIP_BASE_PATH "@VSOMEIP_BASE_PATH@/" -#ifdef WIN32 -#define VSOMEIP_CFG_LIBRARY "vsomeip-cfg.dll" +#ifdef _WIN32 +#define VSOMEIP_CFG_LIBRARY "vsomeip3-cfg.dll" +#else +#define VSOMEIP_CFG_LIBRARY "libvsomeip3-cfg.so.@VSOMEIP_MAJOR_VERSION@" +#endif + +#ifdef _WIN32 +#define VSOMEIP_SD_LIBRARY "vsomeip3-sd.dll" #else -#define VSOMEIP_CFG_LIBRARY "libvsomeip-cfg.so.@VSOMEIP_MAJOR_VERSION@" +#define VSOMEIP_SD_LIBRARY "libvsomeip3-sd.so.@VSOMEIP_MAJOR_VERSION@" #endif -#ifdef WIN32 -#define VSOMEIP_SD_LIBRARY "vsomeip-sd.dll" +#ifdef _WIN32 +#define VSOMEIP_E2E_LIBRARY "vsomeip3-e2e.dll" #else -#define VSOMEIP_SD_LIBRARY "libvsomeip-sd.so.@VSOMEIP_MAJOR_VERSION@" +#define VSOMEIP_E2E_LIBRARY "libvsomeip3-e2e.so.@VSOMEIP_MAJOR_VERSION@" #endif -#define VSOMEIP_ROUTING "@VSOMEIP_ROUTING@" #define VSOMEIP_ROUTING_CLIENT 0 -#define VSOMEIP_ROUTING_INFO_SIZE_INIT 256 + +#define VSOMEIP_CLIENT_UNSET 0xFFFF #ifdef _WIN32 #define VSOMEIP_INTERNAL_BASE_PORT 51234 @@ -57,6 +64,8 @@ #define VSOMEIP_DEFAULT_SHUTDOWN_TIMEOUT 5000 +#define VSOMEIP_DEFAULT_QUEUE_WARN_SIZE 102400 + #define VSOMEIP_MAX_TCP_CONNECT_TIME 5000 #define VSOMEIP_MAX_TCP_RESTART_ABORTS 5 @@ -73,8 +82,6 @@ #define VSOMEIP_MAX_DISPATCHERS 10 #define VSOMEIP_MAX_DISPATCH_TIME 100 -#define VSOMEIP_MAX_DESERIALIZER 5 - #define VSOMEIP_REQUEST_DEBOUNCE_TIME 10 #define VSOMEIP_COMMAND_HEADER_SIZE 7 @@ -85,11 +92,13 @@ #define VSOMEIP_COMMAND_SIZE_POS_MAX 6 #define VSOMEIP_COMMAND_PAYLOAD_POS 7 -#define VSOMEIP_REGISTER_APPLICATION 0x00 -#define VSOMEIP_DEREGISTER_APPLICATION 0x01 -#define VSOMEIP_APPLICATION_LOST 0x02 -#define VSOMEIP_ROUTING_INFO 0x03 -#define VSOMEIP_REGISTERED_ACK 0x04 +#define VSOMEIP_ASSIGN_CLIENT 0x00 +#define VSOMEIP_ASSIGN_CLIENT_ACK 0x01 +#define VSOMEIP_REGISTER_APPLICATION 0x02 +#define VSOMEIP_DEREGISTER_APPLICATION 0x03 +#define VSOMEIP_APPLICATION_LOST 0x04 +#define VSOMEIP_ROUTING_INFO 0x05 +#define VSOMEIP_REGISTERED_ACK 0x06 #define VSOMEIP_PING 0x0E #define VSOMEIP_PONG 0x0F @@ -123,29 +132,27 @@ #define VSOMEIP_UPDATE_SECURITY_CREDENTIALS 0x27 #define VSOMEIP_DISTRIBUTE_SECURITY_POLICIES 0x28 -#define VSOMEIP_SEND_COMMAND_SIZE 14 +#define VSOMEIP_SEND_COMMAND_SIZE 13 #define VSOMEIP_SEND_COMMAND_INSTANCE_POS_MIN 7 #define VSOMEIP_SEND_COMMAND_INSTANCE_POS_MAX 8 -#define VSOMEIP_SEND_COMMAND_FLUSH_POS 9 -#define VSOMEIP_SEND_COMMAND_RELIABLE_POS 10 -#define VSOMEIP_SEND_COMMAND_VALID_CRC_POS 11 -#define VSOMEIP_SEND_COMMAND_DST_CLIENT_POS_MIN 12 -#define VSOMEIP_SEND_COMMAND_DST_CLIENT_POS_MAX 13 -#define VSOMEIP_SEND_COMMAND_PAYLOAD_POS 14 +#define VSOMEIP_SEND_COMMAND_RELIABLE_POS 9 +#define VSOMEIP_SEND_COMMAND_CHECK_STATUS_POS 10 +#define VSOMEIP_SEND_COMMAND_DST_CLIENT_POS_MIN 11 +#define VSOMEIP_SEND_COMMAND_DST_CLIENT_POS_MAX 12 +#define VSOMEIP_SEND_COMMAND_PAYLOAD_POS 13 +#define VSOMEIP_ASSIGN_CLIENT_ACK_COMMAND_SIZE 9 #define VSOMEIP_OFFER_SERVICE_COMMAND_SIZE 16 -#define VSOMEIP_REQUEST_SERVICE_COMMAND_SIZE 17 +#define VSOMEIP_REQUEST_SERVICE_COMMAND_SIZE 16 #define VSOMEIP_RELEASE_SERVICE_COMMAND_SIZE 11 #define VSOMEIP_STOP_OFFER_SERVICE_COMMAND_SIZE 16 -#define VSOMEIP_SUBSCRIBE_COMMAND_SIZE 19 +#define VSOMEIP_SUBSCRIBE_COMMAND_SIZE 18 #define VSOMEIP_SUBSCRIBE_ACK_COMMAND_SIZE 19 #define VSOMEIP_SUBSCRIBE_NACK_COMMAND_SIZE 19 #define VSOMEIP_UNSUBSCRIBE_COMMAND_SIZE 17 #define VSOMEIP_UNSUBSCRIBE_ACK_COMMAND_SIZE 15 -#define VSOMEIP_REGISTER_EVENT_COMMAND_SIZE 15 +#define VSOMEIP_REGISTER_EVENT_COMMAND_SIZE 16 #define VSOMEIP_UNREGISTER_EVENT_COMMAND_SIZE 14 -#define VSOMEIP_ID_RESPONSE_COMMAND_SIZE 12 -#define VSOMEIP_ID_REQUEST_COMMAND_SIZE 13 #define VSOMEIP_OFFERED_SERVICES_COMMAND_SIZE 8 #define VSOMEIP_RESEND_PROVIDED_EVENTS_COMMAND_SIZE 11 #define VSOMEIP_REMOVE_SECURITY_POLICY_COMMAND_SIZE 19 @@ -170,7 +177,7 @@ #define VSOMEIP_ROUTING_READY_MESSAGE "@VSOMEIP_ROUTING_READY_MESSAGE@" -namespace vsomeip { +namespace vsomeip_v3 { typedef enum { RIE_ADD_CLIENT = 0x0, @@ -184,7 +191,6 @@ struct service_data_t { instance_t instance_; major_version_t major_; minor_version_t minor_; - bool use_exclusive_proxy_; // only used for requests! bool operator<(const service_data_t &_other) const { return (service_ < _other.service_ @@ -199,27 +205,20 @@ typedef enum { IS_SUBSCRIBING } subscription_state_e; -struct configuration_data_t { -#ifndef _WIN32 - volatile char initialized_; - pthread_mutex_t mutex_; - pid_t pid_; -#endif - unsigned short client_base_; - unsigned short max_clients_; - int max_used_client_ids_index_; - unsigned short max_assigned_client_id_; - unsigned short routing_manager_host_; - // array of used client ids here, pointer to it is kept in utility class -}; - const std::uint32_t MESSAGE_SIZE_UNLIMITED = (std::numeric_limits<std::uint32_t>::max)(); const std::uint32_t QUEUE_SIZE_UNLIMITED = (std::numeric_limits<std::uint32_t>::max)(); +#define VSOMEIP_DEFAULT_NPDU_DEBOUNCING_NANO 2 * 1000 * 1000 +#define VSOMEIP_DEFAULT_NPDU_MAXIMUM_RETENTION_NANO 5 * 1000 * 1000 + const std::uint32_t MAX_RECONNECTS_UNLIMITED = (std::numeric_limits<std::uint32_t>::max)(); +const std::uint32_t ANY_UID = 0xFFFFFFFF; +const std::uint32_t ANY_GID = 0xFFFFFFFF; + +typedef std::pair<std::uint32_t, std::uint32_t> credentials_t; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_INTERNAL_HPP +#endif // VSOMEIP_V3_INTERNAL_HPP_ diff --git a/implementation/configuration/include/internal_android.hpp b/implementation/configuration/include/internal_android.hpp new file mode 100644 index 0000000..9f770ac --- /dev/null +++ b/implementation/configuration/include/internal_android.hpp @@ -0,0 +1,206 @@ +// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef VSOMEIP_V3_INTERNAL_HPP_ +#define VSOMEIP_V3_INTERNAL_HPP_ + +#include <cstdint> +#include <limits> +#include <vsomeip/primitive_types.hpp> + +#define VSOMEIP_ENV_APPLICATION_NAME "VSOMEIP_APPLICATION_NAME" +#define VSOMEIP_ENV_CONFIGURATION "VSOMEIP_CONFIGURATION" +#define VSOMEIP_ENV_CONFIGURATION_MODULE "VSOMEIP_CONFIGURATION_MODULE" +#define VSOMEIP_ENV_E2E_PROTECTION_MODULE "VSOMEIP_E2E_PROTECTION_MODULE" +#define VSOMEIP_ENV_MANDATORY_CONFIGURATION_FILES "VSOMEIP_MANDATORY_CONFIGURATION_FILES" +#define VSOMEIP_ENV_LOAD_PLUGINS "VSOMEIP_LOAD_PLUGINS" +#define VSOMEIP_ENV_CLIENTSIDELOGGING "VSOMEIP_CLIENTSIDELOGGING" + +#define VSOMEIP_DEFAULT_CONFIGURATION_FILE "/etc/vsomeip.json" +#define VSOMEIP_LOCAL_CONFIGURATION_FILE "./vsomeip.json" +#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json,vsomeip_log.json,vsomeip_security.json,vsomeip_whitelist.json" + +#define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip" +#define VSOMEIP_DEBUG_CONFIGURATION_FOLDER "/var/opt/public/sin/vsomeip/" +#define VSOMEIP_LOCAL_CONFIGURATION_FOLDER "./vsomeip" + +#define VSOMEIP_BASE_PATH "/storage/" + +#define VSOMEIP_CFG_LIBRARY "libvsomeip_cfg.so" + +#define VSOMEIP_SD_LIBRARY "libvsomeip_sd.so" + +#define VSOMEIP_E2E_LIBRARY "libvsomeip-e2e.so.3" + +#define VSOMEIP_ROUTING_CLIENT 0 + +#define VSOMEIP_CLIENT_UNSET 0xFFFF + +#define VSOMEIP_UNICAST_ADDRESS "127.0.0.1" +#define VSOMEIP_NETMASK "255.255.255.0" + +#define VSOMEIP_DEFAULT_CONNECT_TIMEOUT 100 +#define VSOMEIP_MAX_CONNECT_TIMEOUT 1600 +#define VSOMEIP_DEFAULT_FLUSH_TIMEOUT 1000 + +#define VSOMEIP_DEFAULT_SHUTDOWN_TIMEOUT 5000 + +#define VSOMEIP_DEFAULT_QUEUE_WARN_SIZE 102400 + +#define VSOMEIP_MAX_TCP_CONNECT_TIME 5000 +#define VSOMEIP_MAX_TCP_RESTART_ABORTS 5 + +#define VSOMEIP_DEFAULT_BUFFER_SHRINK_THRESHOLD 5 + +#define VSOMEIP_DEFAULT_WATCHDOG_TIMEOUT 5000 +#define VSOMEIP_DEFAULT_MAX_MISSING_PONGS 3 + +#define VSOMEIP_DEFAULT_UDP_RCV_BUFFER_SIZE 1703936 + +#define VSOMEIP_IO_THREAD_COUNT 2 +#define VSOMEIP_IO_THREAD_NICE_LEVEL 255 + +#define VSOMEIP_MAX_DISPATCHERS 10 +#define VSOMEIP_MAX_DISPATCH_TIME 100 + +#define VSOMEIP_MAX_DESERIALIZER 5 + +#define VSOMEIP_REQUEST_DEBOUNCE_TIME 10 + +#define VSOMEIP_COMMAND_HEADER_SIZE 7 + +#define VSOMEIP_COMMAND_TYPE_POS 0 +#define VSOMEIP_COMMAND_CLIENT_POS 1 +#define VSOMEIP_COMMAND_SIZE_POS_MIN 3 +#define VSOMEIP_COMMAND_SIZE_POS_MAX 6 +#define VSOMEIP_COMMAND_PAYLOAD_POS 7 + +#define VSOMEIP_ASSIGN_CLIENT 0x00 +#define VSOMEIP_ASSIGN_CLIENT_ACK 0x01 +#define VSOMEIP_REGISTER_APPLICATION 0x02 +#define VSOMEIP_DEREGISTER_APPLICATION 0x03 +#define VSOMEIP_APPLICATION_LOST 0x04 +#define VSOMEIP_ROUTING_INFO 0x05 +#define VSOMEIP_REGISTERED_ACK 0x06 + +#define VSOMEIP_PING 0x0E +#define VSOMEIP_PONG 0x0F + +#define VSOMEIP_OFFER_SERVICE 0x10 +#define VSOMEIP_STOP_OFFER_SERVICE 0x11 +#define VSOMEIP_SUBSCRIBE 0x12 +#define VSOMEIP_UNSUBSCRIBE 0x13 +#define VSOMEIP_REQUEST_SERVICE 0x14 +#define VSOMEIP_RELEASE_SERVICE 0x15 +#define VSOMEIP_SUBSCRIBE_NACK 0x16 +#define VSOMEIP_SUBSCRIBE_ACK 0x17 + +#define VSOMEIP_SEND 0x18 +#define VSOMEIP_NOTIFY 0x19 +#define VSOMEIP_NOTIFY_ONE 0x1A + +#define VSOMEIP_REGISTER_EVENT 0x1B +#define VSOMEIP_UNREGISTER_EVENT 0x1C +#define VSOMEIP_ID_RESPONSE 0x1D +#define VSOMEIP_ID_REQUEST 0x1E +#define VSOMEIP_OFFERED_SERVICES_REQUEST 0x1F +#define VSOMEIP_OFFERED_SERVICES_RESPONSE 0x20 +#define VSOMEIP_UNSUBSCRIBE_ACK 0x21 +#define VSOMEIP_RESEND_PROVIDED_EVENTS 0x22 + +#define VSOMEIP_UPDATE_SECURITY_POLICY 0x23 +#define VSOMEIP_UPDATE_SECURITY_POLICY_RESPONSE 0x24 +#define VSOMEIP_REMOVE_SECURITY_POLICY 0x25 +#define VSOMEIP_REMOVE_SECURITY_POLICY_RESPONSE 0x26 +#define VSOMEIP_UPDATE_SECURITY_CREDENTIALS 0x27 +#define VSOMEIP_DISTRIBUTE_SECURITY_POLICIES 0x28 + +#define VSOMEIP_SEND_COMMAND_SIZE 13 +#define VSOMEIP_SEND_COMMAND_INSTANCE_POS_MIN 7 +#define VSOMEIP_SEND_COMMAND_INSTANCE_POS_MAX 8 +#define VSOMEIP_SEND_COMMAND_RELIABLE_POS 9 +#define VSOMEIP_SEND_COMMAND_CHECK_STATUS_POS 10 +#define VSOMEIP_SEND_COMMAND_DST_CLIENT_POS_MIN 11 +#define VSOMEIP_SEND_COMMAND_DST_CLIENT_POS_MAX 12 +#define VSOMEIP_SEND_COMMAND_PAYLOAD_POS 13 + +#define VSOMEIP_ASSIGN_CLIENT_ACK_COMMAND_SIZE 9 +#define VSOMEIP_OFFER_SERVICE_COMMAND_SIZE 16 +#define VSOMEIP_REQUEST_SERVICE_COMMAND_SIZE 16 +#define VSOMEIP_RELEASE_SERVICE_COMMAND_SIZE 11 +#define VSOMEIP_STOP_OFFER_SERVICE_COMMAND_SIZE 16 +#define VSOMEIP_SUBSCRIBE_COMMAND_SIZE 18 +#define VSOMEIP_SUBSCRIBE_ACK_COMMAND_SIZE 19 +#define VSOMEIP_SUBSCRIBE_NACK_COMMAND_SIZE 19 +#define VSOMEIP_UNSUBSCRIBE_COMMAND_SIZE 17 +#define VSOMEIP_UNSUBSCRIBE_ACK_COMMAND_SIZE 15 +#define VSOMEIP_REGISTER_EVENT_COMMAND_SIZE 16 +#define VSOMEIP_UNREGISTER_EVENT_COMMAND_SIZE 14 +#define VSOMEIP_OFFERED_SERVICES_COMMAND_SIZE 8 +#define VSOMEIP_RESEND_PROVIDED_EVENTS_COMMAND_SIZE 11 +#define VSOMEIP_REMOVE_SECURITY_POLICY_COMMAND_SIZE 19 +#define VSOMEIP_UPDATE_SECURITY_POLICY_RESPONSE_COMMAND_SIZE 11 +#define VSOMEIP_REMOVE_SECURITY_POLICY_RESPONSE_COMMAND_SIZE 11 +#define VSOMEIP_PING_COMMAND_SIZE 7 +#define VSOMEIP_PONG_COMMAND_SIZE 7 +#define VSOMEIP_REGISTER_APPLICATION_COMMAND_SIZE 7 +#define VSOMEIP_DEREGISTER_APPLICATION_COMMAND_SIZE 7 +#define VSOMEIP_REGISTERED_ACK_COMMAND_SIZE 7 + +#include <pthread.h> + +#define VSOMEIP_DATA_ID 0x677D +#define VSOMEIP_DIAGNOSIS_ADDRESS 0x01 + +#define VSOMEIP_DEFAULT_SHM_PERMISSION 0666 +#define VSOMEIP_DEFAULT_UDS_PERMISSIONS 0666 + +#define VSOMEIP_ROUTING_READY_MESSAGE "SOME/IP routing ready." + +namespace vsomeip_v3 { + +typedef enum { + RIE_ADD_CLIENT = 0x0, + RIE_ADD_SERVICE_INSTANCE = 0x1, + RIE_DEL_SERVICE_INSTANCE = 0x2, + RIE_DEL_CLIENT = 0x3, +} routing_info_entry_e; + +struct service_data_t { + service_t service_; + instance_t instance_; + major_version_t major_; + minor_version_t minor_; + + bool operator<(const service_data_t &_other) const { + return (service_ < _other.service_ + || (service_ == _other.service_ + && instance_ < _other.instance_)); + } +}; + +typedef enum { + SUBSCRIPTION_ACKNOWLEDGED, + SUBSCRIPTION_NOT_ACKNOWLEDGED, + IS_SUBSCRIBING +} subscription_state_e; + +const std::uint32_t MESSAGE_SIZE_UNLIMITED = (std::numeric_limits<std::uint32_t>::max)(); + +const std::uint32_t QUEUE_SIZE_UNLIMITED = (std::numeric_limits<std::uint32_t>::max)(); + +#define VSOMEIP_DEFAULT_NPDU_DEBOUNCING_NANO 2 * 1000 * 1000 +#define VSOMEIP_DEFAULT_NPDU_MAXIMUM_RETENTION_NANO 5 * 1000 * 1000 + +const std::uint32_t MAX_RECONNECTS_UNLIMITED = (std::numeric_limits<std::uint32_t>::max)(); + +const std::uint32_t ANY_UID = 0xFFFFFFFF; +const std::uint32_t ANY_GID = 0xFFFFFFFF; + +typedef std::pair<std::uint32_t, std::uint32_t> credentials_t; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_INTERNAL_HPP_ diff --git a/implementation/configuration/include/policy.hpp b/implementation/configuration/include/policy.hpp deleted file mode 100644 index c8f649e..0000000 --- a/implementation/configuration/include/policy.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef VSOMEIP_CFG_POLICY_HPP -#define VSOMEIP_CFG_POLICY_HPP - -#include <memory> -#include <set> - -#include <vsomeip/primitive_types.hpp> - -namespace vsomeip { - -typedef std::set<std::pair<uint32_t, uint32_t>> ranges_t; -typedef std::set<std::pair<ranges_t, ranges_t>> ids_t; - -struct policy { - policy() : allow_who_(false), allow_what_(false) {}; - - ids_t ids_; - bool allow_who_; - - std::set<std::pair<service_t, ids_t>> services_; - std::set<std::pair<service_t, ranges_t>> offers_; - bool allow_what_; -}; - -} // namespace vsomeip - -#endif // VSOMEIP_CFG_POLICY_HPP diff --git a/implementation/configuration/include/service.hpp b/implementation/configuration/include/service.hpp index b33cf72..e0e0c72 100644 --- a/implementation/configuration/include/service.hpp +++ b/implementation/configuration/include/service.hpp @@ -3,14 +3,14 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CFG_SERVICE_HPP -#define VSOMEIP_CFG_SERVICE_HPP +#ifndef VSOMEIP_V3_CFG_SERVICE_HPP +#define VSOMEIP_V3_CFG_SERVICE_HPP #include <memory> #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { namespace cfg { struct event; @@ -30,12 +30,22 @@ struct service { std::string protocol_; + // [0] = debounce_time + // [1] = retention_time + typedef std::map<method_t, std::array<std::chrono::nanoseconds, 2>> npdu_time_configuration_t; + npdu_time_configuration_t debounce_times_requests_; + npdu_time_configuration_t debounce_times_responses_; + std::shared_ptr<servicegroup> group_; std::map<event_t, std::shared_ptr<event> > events_; std::map<eventgroup_t, std::shared_ptr<eventgroup> > eventgroups_; + + // SOME/IP-TP + std::set<method_t> tp_segment_messages_client_to_service_; + std::set<method_t> tp_segment_messages_service_to_client_; }; } // namespace cfg -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_CFG_SERVICE_HPP +#endif // VSOMEIP_V3_CFG_SERVICE_HPP diff --git a/implementation/configuration/include/service_instance_range.hpp b/implementation/configuration/include/service_instance_range.hpp index bf5f415..a585d7a 100644 --- a/implementation/configuration/include/service_instance_range.hpp +++ b/implementation/configuration/include/service_instance_range.hpp @@ -3,12 +3,12 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CFG_SERVICE_INSTANCE_RANGE_HPP -#define VSOMEIP_CFG_SERVICE_INSTANCE_RANGE_HPP +#ifndef VSOMEIP_V3_CFG_SERVICE_INSTANCE_RANGE_HPP +#define VSOMEIP_V3_CFG_SERVICE_INSTANCE_RANGE_HPP #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { namespace cfg { struct service_instance_range { @@ -18,7 +18,7 @@ struct service_instance_range { instance_t last_instance_; }; -} -} +} // namespace cfg +} // namespace vsomeip_v3 -#endif // VSOMEIP_CFG_SERVICE_INSTANCE_RANGE_HPP +#endif // VSOMEIP_V3_CFG_SERVICE_INSTANCE_RANGE_HPP diff --git a/implementation/configuration/include/trace.hpp b/implementation/configuration/include/trace.hpp index 3d4e1f4..c9eb8cb 100644 --- a/implementation/configuration/include/trace.hpp +++ b/implementation/configuration/include/trace.hpp @@ -3,8 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef CFG_TRACE_HPP_ -#define CFG_TRACE_HPP_ +#ifndef VSOMEIP_V3_CFG_TRACE_HPP_ +#define VSOMEIP_V3_CFG_TRACE_HPP_ #include <string> #include <vector> @@ -12,7 +12,7 @@ #include <vsomeip/primitive_types.hpp> #include <vsomeip/trace.hpp> -namespace vsomeip { +namespace vsomeip_v3 { namespace cfg { struct trace_channel { @@ -29,7 +29,7 @@ struct trace_filter { std::vector<trace_channel_t> channels_; bool is_positive_; bool is_range_; - std::vector<vsomeip::trace::match_t> matches_; + std::vector<vsomeip_v3::trace::match_t> matches_; }; struct trace { @@ -48,6 +48,6 @@ struct trace { }; } // namespace cfg -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // CFG_TRACE_HPP_ +#endif // VSOMEIP_V3_CFG_TRACE_HPP_ diff --git a/implementation/configuration/include/watchdog.hpp b/implementation/configuration/include/watchdog.hpp index 00fdb69..9fe81ff 100644 --- a/implementation/configuration/include/watchdog.hpp +++ b/implementation/configuration/include/watchdog.hpp @@ -2,10 +2,10 @@ // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef VSOMEIP_CFG_WATCHDOG_HPP_ -#define VSOMEIP_CFG_WATCHDOG_HPP_ +#ifndef VSOMEIP_V3_CFG_WATCHDOG_HPP_ +#define VSOMEIP_V3_CFG_WATCHDOG_HPP_ -namespace vsomeip { +namespace vsomeip_v3 { namespace cfg { struct watchdog { @@ -21,6 +21,6 @@ struct watchdog { }; } // namespace cfg -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif /* VSOMEIP_CFG_WATCHDOG_HPP_ */ +#endif // VSOMEIP_V3_CFG_WATCHDOG_HPP_ |