diff options
author | Lutz Bichler <Lutz.Bichler@bmw.de> | 2020-02-12 13:04:15 +0100 |
---|---|---|
committer | Lutz Bichler <Lutz.Bichler@bmw.de> | 2020-02-12 13:04:15 +0100 |
commit | 8371cdca9463a75220c4de92b47c8df9d3bbe346 (patch) | |
tree | 16b4bf73c284b026b0ac032171110dafd1752196 /implementation/routing/include | |
parent | ee44d19e0a3773adcda3bace073c66e334a3e6a7 (diff) | |
download | vSomeIP-8371cdca9463a75220c4de92b47c8df9d3bbe346.tar.gz |
vsomeip 3.1.7.13.1.7.1
Diffstat (limited to 'implementation/routing/include')
-rw-r--r-- | implementation/routing/include/event.hpp | 83 | ||||
-rw-r--r-- | implementation/routing/include/eventgroupinfo.hpp | 123 | ||||
-rw-r--r-- | implementation/routing/include/function_types.hpp | 19 | ||||
-rw-r--r-- | implementation/routing/include/remote_subscription.hpp | 129 | ||||
-rw-r--r-- | implementation/routing/include/routing_host.hpp | 44 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager.hpp | 61 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_adapter.hpp | 10 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_base.hpp | 191 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_host.hpp | 22 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_impl.hpp | 360 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_proxy.hpp | 133 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_stub.hpp | 54 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_stub_host.hpp | 60 | ||||
-rw-r--r-- | implementation/routing/include/serviceinfo.hpp | 21 | ||||
-rw-r--r-- | implementation/routing/include/types.hpp | 94 |
15 files changed, 762 insertions, 642 deletions
diff --git a/implementation/routing/include/event.hpp b/implementation/routing/include/event.hpp index 668bbf4..684a49b 100644 --- a/implementation/routing/include/event.hpp +++ b/implementation/routing/include/event.hpp @@ -3,9 +3,10 @@ // 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_EVENT_IMPL_HPP -#define VSOMEIP_EVENT_IMPL_HPP +#ifndef VSOMEIP_V3_EVENT_IMPL_HPP_ +#define VSOMEIP_V3_EVENT_IMPL_HPP_ +#include <list> #include <map> #include <memory> #include <mutex> @@ -20,7 +21,13 @@ #include <vsomeip/function_types.hpp> #include <vsomeip/payload.hpp> -namespace vsomeip { +#ifdef ANDROID +#include "../../configuration/include/internal_android.hpp" +#else +#include "../../configuration/include/internal.hpp" +#endif // ANDROID + +namespace vsomeip_v3 { class endpoint; class endpoint_definition; @@ -28,7 +35,8 @@ class message; class payload; class routing_manager; -class event: public std::enable_shared_from_this<event> { +class event + : public std::enable_shared_from_this<event> { public: event(routing_manager *_routing, bool _is_shadow = false); @@ -47,21 +55,25 @@ public: const std::shared_ptr<payload> get_payload() const; void set_payload(const std::shared_ptr<payload> &_payload, - const client_t _client, bool _force, bool _flush); + const client_t _client, bool _force); void set_payload(const std::shared_ptr<payload> &_payload, - const std::shared_ptr<endpoint_definition> _target, - bool _force, bool _flush); + const client_t _client, + const std::shared_ptr<endpoint_definition>& _target, bool _force); bool set_payload_dont_notify(const std::shared_ptr<payload> &_payload); + bool set_payload_notify_pending(const std::shared_ptr<payload> &_payload); - void set_payload(const std::shared_ptr<payload> &_payload, - bool _force, bool _flush); + void set_payload(const std::shared_ptr<payload> &_payload, bool _force); void unset_payload(bool _force = false); - bool is_field() const; - void set_field(bool _is_field); + event_type_e get_type() const; + void set_type(const event_type_e _type); + + reliability_type_e get_reliability() const; + void set_reliability(const reliability_type_e _reliability); + bool is_field() const; bool is_provided() const; void set_provided(bool _is_provided); @@ -75,25 +87,30 @@ public: void set_update_on_change(bool _is_active); // SIP_RPC_359 (epsilon change) - void set_epsilon_change_function(const epsilon_change_func_t &_epsilon_change_func); + void set_epsilon_change_function( + const epsilon_change_func_t &_epsilon_change_func); const std::set<eventgroup_t> get_eventgroups() const; std::set<eventgroup_t> get_eventgroups(client_t _client) const; void add_eventgroup(eventgroup_t _eventgroup); void set_eventgroups(const std::set<eventgroup_t> &_eventgroups); - void notify_one(const std::shared_ptr<endpoint_definition> &_target, bool _flush); - void notify_one(client_t _client, bool _flush); + void notify_one(client_t _client, + const std::shared_ptr<endpoint_definition> &_target); + void notify_one(client_t _client); + bool add_subscriber(eventgroup_t _eventgroup, client_t _client, bool _force); void remove_subscriber(eventgroup_t _eventgroup, client_t _client); bool has_subscriber(eventgroup_t _eventgroup, client_t _client); std::set<client_t> get_subscribers(); + std::set<client_t> get_subscribers(eventgroup_t _eventgroup); void clear_subscribers(); void add_ref(client_t _client, bool _is_provided); void remove_ref(client_t _client, bool _is_provided); bool has_ref(); + bool has_ref(client_t _client, bool _is_provided); bool is_shadow() const; void set_shadow(bool _shadow); @@ -101,40 +118,36 @@ public: bool is_cache_placeholder() const; void set_cache_placeholder(bool _is_cache_place_holder); - bool has_ref(client_t _client, bool _is_provided); - - std::set<client_t> get_subscribers(eventgroup_t _eventgroup); - bool is_subscribed(client_t _client); - bool is_reliable() const; - void set_reliable(bool _is_reliable); - - bool get_remote_notification_pending(); - void set_remote_notification_pending(bool _value); + void remove_pending(const std::shared_ptr<endpoint_definition> &_target); private: void update_cbk(boost::system::error_code const &_error); - void notify(bool _flush); - void notify(client_t _client, const std::shared_ptr<endpoint_definition> &_target); + void notify(); + void notify(client_t _client, + const std::shared_ptr<endpoint_definition> &_target); void start_cycle(); void stop_cycle(); - bool compare(const std::shared_ptr<payload> &_lhs, const std::shared_ptr<payload> &_rhs) const; + bool compare(const std::shared_ptr<payload> &_lhs, + const std::shared_ptr<payload> &_rhs) const; - bool set_payload_helper(const std::shared_ptr<payload> &_payload, bool _force); + bool set_payload_helper(const std::shared_ptr<payload> &_payload, + bool _force); void reset_payload(const std::shared_ptr<payload> &_payload); - void notify_one_unlocked(const std::shared_ptr<endpoint_definition> &_target, bool _flush); - void notify_one_unlocked(client_t _client, bool _flush); + void notify_one_unlocked(client_t _client); + void notify_one_unlocked(client_t _client, + const std::shared_ptr<endpoint_definition> &_target); private: routing_manager *routing_; mutable std::mutex mutex_; std::shared_ptr<message> message_; - std::atomic<bool> is_field_; + std::atomic<event_type_e> type_; boost::asio::steady_timer cycle_timer_; std::chrono::milliseconds cycle_; @@ -143,7 +156,7 @@ private: std::atomic<bool> is_updating_on_change_; mutable std::mutex eventgroups_mutex_; - std::map<eventgroup_t, std::set<client_t>> eventgroups_; + std::map<eventgroup_t, std::set<client_t> > eventgroups_; std::atomic<bool> is_set_; std::atomic<bool> is_provided_; @@ -156,11 +169,11 @@ private: epsilon_change_func_t epsilon_change_func_; - std::atomic<bool> is_reliable_; + std::atomic<reliability_type_e> reliability_; - std::atomic<bool> remote_notification_pending_; + std::set<std::shared_ptr<endpoint_definition> > pending_; }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_EVENT_IMPL_HPP +#endif // VSOMEIP_V3_EVENT_IMPL_HPP_ diff --git a/implementation/routing/include/eventgroupinfo.hpp b/implementation/routing/include/eventgroupinfo.hpp index d6244b5..65f7e89 100644 --- a/implementation/routing/include/eventgroupinfo.hpp +++ b/implementation/routing/include/eventgroupinfo.hpp @@ -3,48 +3,62 @@ // 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_EVENTGROUPINFO_HPP -#define VSOMEIP_EVENTGROUPINFO_HPP +#ifndef VSOMEIP_V3_EVENTGROUPINFO_HPP_ +#define VSOMEIP_V3_EVENTGROUPINFO_HPP_ +#include <atomic> #include <chrono> #include <list> #include <memory> -#include <set> #include <mutex> -#include <atomic> +#include <set> +#include <vector> #include <boost/asio/ip/address.hpp> #include <vsomeip/export.hpp> #include <vsomeip/primitive_types.hpp> +#include "remote_subscription.hpp" #include "types.hpp" -namespace vsomeip { +namespace vsomeip_v3 { class endpoint_definition; class event; class eventgroupinfo { public: - struct target_t { - std::shared_ptr<endpoint_definition> endpoint_; + struct subscription_t { + std::shared_ptr<remote_subscription> subscription_; std::chrono::steady_clock::time_point expiration_; - bool operator==(const target_t &_other) const { - return (endpoint_ == _other.endpoint_); + bool operator==(const subscription_t &_other) const { + return (subscription_ == _other.subscription_); } }; VSOMEIP_EXPORT eventgroupinfo(); - VSOMEIP_EXPORT eventgroupinfo(major_version_t _major, ttl_t _ttl); + VSOMEIP_EXPORT eventgroupinfo( + const service_t _service, const service_t _instance, + const eventgroup_t _eventgroup, const major_version_t _major, + const ttl_t _ttl); VSOMEIP_EXPORT ~eventgroupinfo(); + VSOMEIP_EXPORT service_t get_service() const; + VSOMEIP_EXPORT void set_service(const service_t _service); + + VSOMEIP_EXPORT instance_t get_instance() const; + VSOMEIP_EXPORT void set_instance(const instance_t _instance); + + VSOMEIP_EXPORT eventgroup_t get_eventgroup() const; + VSOMEIP_EXPORT void set_eventgroup(const eventgroup_t _eventgroup); + VSOMEIP_EXPORT major_version_t get_major() const; - VSOMEIP_EXPORT void set_major(major_version_t _major); + VSOMEIP_EXPORT void set_major(const major_version_t _major); VSOMEIP_EXPORT ttl_t get_ttl() const; - VSOMEIP_EXPORT void set_ttl(ttl_t _ttl); + VSOMEIP_EXPORT void set_ttl(const ttl_t _ttl); VSOMEIP_EXPORT bool is_multicast() const; VSOMEIP_EXPORT bool get_multicast(boost::asio::ip::address &_address, @@ -54,39 +68,48 @@ public: VSOMEIP_EXPORT bool is_sending_multicast() const; VSOMEIP_EXPORT const std::set<std::shared_ptr<event> > get_events() const; - VSOMEIP_EXPORT void add_event(std::shared_ptr<event> _event); - VSOMEIP_EXPORT void remove_event(std::shared_ptr<event> _event); - VSOMEIP_EXPORT void get_reliability(bool& _has_reliable, bool& _has_unreliable) const; - - VSOMEIP_EXPORT const std::list<target_t> get_targets() const; - VSOMEIP_EXPORT uint32_t get_unreliable_target_count() const; - - VSOMEIP_EXPORT bool add_target(const target_t &_target); - VSOMEIP_EXPORT bool add_target(const target_t &_target, const target_t &_subscriber); - VSOMEIP_EXPORT bool update_target( - const std::shared_ptr<endpoint_definition> &_target, - const std::chrono::steady_clock::time_point &_expiration); - VSOMEIP_EXPORT bool remove_target( - const std::shared_ptr<endpoint_definition> &_target); - VSOMEIP_EXPORT void clear_targets(); - - VSOMEIP_EXPORT void add_multicast_target(const target_t &_multicast_target); - VSOMEIP_EXPORT void clear_multicast_targets(); - VSOMEIP_EXPORT const std::list<target_t> get_multicast_targets() const; + VSOMEIP_EXPORT void add_event(const std::shared_ptr<event>& _event); + VSOMEIP_EXPORT void remove_event(const std::shared_ptr<event>& _event); + VSOMEIP_EXPORT reliability_type_e get_reliability() const; - VSOMEIP_EXPORT uint8_t get_threshold() const; - VSOMEIP_EXPORT void set_threshold(uint8_t _threshold); + VSOMEIP_EXPORT std::set<std::shared_ptr<remote_subscription>> + get_remote_subscriptions() const; + + std::shared_ptr<remote_subscription> get_remote_subscription( + const remote_subscription_id_t _id); + + bool update_remote_subscription( + const std::shared_ptr<remote_subscription> &_subscription, + const std::chrono::steady_clock::time_point &_expiration, + std::set<client_t> &_changed, remote_subscription_id_t &_id, + const bool _is_subscribe); + + remote_subscription_id_t add_remote_subscription( + const std::shared_ptr<remote_subscription> &_subscription); - VSOMEIP_EXPORT std::unique_lock<std::mutex> get_subscription_lock(); + VSOMEIP_EXPORT void remove_remote_subscription( + const remote_subscription_id_t _id); - VSOMEIP_EXPORT pending_subscription_id_t add_pending_subscription( - pending_subscription_t _pending_subscription); + VSOMEIP_EXPORT std::set<std::shared_ptr<endpoint_definition> > + get_unicast_targets() const; + VSOMEIP_EXPORT std::set<std::shared_ptr<endpoint_definition> > + get_multicast_targets() const; - VSOMEIP_EXPORT std::vector<pending_subscription_t> remove_pending_subscription( - pending_subscription_id_t _subscription_id); + VSOMEIP_EXPORT uint8_t get_threshold() const; + VSOMEIP_EXPORT void set_threshold(uint8_t _threshold); - VSOMEIP_EXPORT void clear_pending_subscriptions(); + VSOMEIP_EXPORT bool is_selective() const; + + VSOMEIP_EXPORT void send_initial_events( + const std::shared_ptr<endpoint_definition> &_reliable, + const std::shared_ptr<endpoint_definition> &_unreliable) const; private: + void update_id(); + uint32_t get_unreliable_target_count() const; + + std::atomic<service_t> service_; + std::atomic<instance_t> instance_; + std::atomic<eventgroup_t> eventgroup_; std::atomic<major_version_t> major_; std::atomic<ttl_t> ttl_; @@ -96,24 +119,18 @@ private: mutable std::mutex events_mutex_; std::set<std::shared_ptr<event> > events_; - mutable std::mutex targets_mutex_; - std::list<target_t> targets_; - mutable std::mutex multicast_targets_mutex_; - std::list<target_t> multicast_targets_; std::atomic<uint8_t> threshold_; - std::mutex subscription_mutex_; - std::atomic<bool> has_reliable_; - std::atomic<bool> has_unreliable_; + mutable std::mutex subscriptions_mutex_; + std::map<remote_subscription_id_t, + std::shared_ptr<remote_subscription> + > subscriptions_; + remote_subscription_id_t id_; - std::mutex pending_subscriptions_mutex_; - std::map<pending_subscription_id_t, pending_subscription_t> pending_subscriptions_; - std::map<std::tuple<boost::asio::ip::address, std::uint16_t, bool>, - std::vector<pending_subscription_id_t>> pending_subscriptions_by_remote_; - pending_subscription_id_t subscription_id_; + std::atomic<reliability_type_e> reliability_; }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_EVENTGROUPINFO_HPP +#endif // VSOMEIP_V3_EVENTGROUPINFO_HPP_ diff --git a/implementation/routing/include/function_types.hpp b/implementation/routing/include/function_types.hpp new file mode 100644 index 0000000..3f89c08 --- /dev/null +++ b/implementation/routing/include/function_types.hpp @@ -0,0 +1,19 @@ +// Copyright (C) 2018 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_ROUTING_FUNCTION_TYPES_HPP_ +#define VSOMEIP_V3_ROUTING_FUNCTION_TYPES_HPP_ + +namespace vsomeip_v3 { + +class remote_subscription; + +typedef std::function< + void (const std::shared_ptr<remote_subscription> &_subscription) +> remote_subscription_callback_t; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_ROUTING_FUNCTION_TYPES_HPP_ diff --git a/implementation/routing/include/remote_subscription.hpp b/implementation/routing/include/remote_subscription.hpp new file mode 100644 index 0000000..00f2b57 --- /dev/null +++ b/implementation/routing/include/remote_subscription.hpp @@ -0,0 +1,129 @@ +// Copyright (C) 2018 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_REMOTE_SUBSCRIPTION_HPP_ +#define VSOMEIP_V3_REMOTE_SUBSCRIPTION_HPP_ + +#include <atomic> +#include <map> +#include <mutex> +#include <set> + +#include <vsomeip/primitive_types.hpp> + +#include "../../endpoints/include/endpoint_definition.hpp" +#include "types.hpp" +#include <vsomeip/export.hpp> + + +namespace vsomeip_v3 { + +class eventgroupinfo; + +const remote_subscription_id_t PENDING_SUBSCRIPTION_ID(0); + +class remote_subscription { +public: + VSOMEIP_EXPORT remote_subscription(); + VSOMEIP_EXPORT ~remote_subscription(); + + bool operator==(const remote_subscription &_other) const; + bool equals(const std::shared_ptr<remote_subscription> &_other) const; + + VSOMEIP_EXPORT void reset(const std::set<client_t> &_clients); + + VSOMEIP_EXPORT bool is_initial() const; + VSOMEIP_EXPORT void set_initial(const bool _is_initial); + + VSOMEIP_EXPORT bool force_initial_events() const; + VSOMEIP_EXPORT void set_force_initial_events(const bool _force_initial_events); + + remote_subscription_id_t get_id() const; + void set_id(const remote_subscription_id_t _id); + + std::shared_ptr<remote_subscription> get_parent() const; + void set_parent(const std::shared_ptr<remote_subscription> &_parent); + + VSOMEIP_EXPORT std::shared_ptr<eventgroupinfo> get_eventgroupinfo() const; + VSOMEIP_EXPORT void set_eventgroupinfo(const std::shared_ptr<eventgroupinfo> &_info); + + VSOMEIP_EXPORT ttl_t get_ttl() const; + VSOMEIP_EXPORT void set_ttl(const ttl_t _ttl); + + uint16_t get_reserved() const; + void set_reserved(const uint16_t _reserved); + + uint8_t get_counter() const; + void set_counter(uint8_t _counter); + + VSOMEIP_EXPORT std::set<client_t> get_clients() const; + bool has_client() const; + bool has_client(const client_t _client) const; + void remove_client(const client_t _client); + + VSOMEIP_EXPORT remote_subscription_state_e get_client_state(const client_t _client) const; + void set_client_state(const client_t _client, + remote_subscription_state_e _state); + void set_all_client_states(remote_subscription_state_e _state); + + std::chrono::steady_clock::time_point get_expiration(const client_t _client) const; + + VSOMEIP_EXPORT std::shared_ptr<endpoint_definition> get_subscriber() const; + VSOMEIP_EXPORT void set_subscriber(const std::shared_ptr<endpoint_definition> &_subscriber); + + VSOMEIP_EXPORT std::shared_ptr<endpoint_definition> get_reliable() const; + VSOMEIP_EXPORT void set_reliable(const std::shared_ptr<endpoint_definition> &_reliable); + + VSOMEIP_EXPORT std::shared_ptr<endpoint_definition> get_unreliable() const; + VSOMEIP_EXPORT void set_unreliable(const std::shared_ptr<endpoint_definition> &_unreliable); + + VSOMEIP_EXPORT bool is_pending() const; + bool is_acknowledged() const; + + std::set<client_t> update(const std::set<client_t> &_clients, + const std::chrono::steady_clock::time_point &_timepoint, + const bool _is_subscribe); + + VSOMEIP_EXPORT std::uint32_t get_answers() const; + void set_answers(const std::uint32_t _answers); + +private: + std::atomic<remote_subscription_id_t> id_; + std::atomic<bool> is_initial_; + std::atomic<bool> force_initial_events_; + std::weak_ptr<remote_subscription> parent_; + + std::weak_ptr<eventgroupinfo> eventgroupinfo_; + + major_version_t major_; + ttl_t ttl_; + std::uint16_t reserved_; + std::uint8_t counter_; + + std::map<client_t, + std::pair<remote_subscription_state_e, + std::chrono::steady_clock::time_point + > + > clients_; + + // The endpoint that sent(!) the subscription + std::shared_ptr<endpoint_definition> subscriber_; + + // The endpoints defined by the endpoint options + std::shared_ptr<endpoint_definition> reliable_; + std::shared_ptr<endpoint_definition> unreliable_; + + // Number of acknowledgements that must be sent + // for the subscriptions. This is usally 1, but + // may be larger if a matching subscription arrived + // before the subscription could be acknowledged + std::uint32_t answers_; + + mutable std::mutex mutex_; +}; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_REMOTE_SUBSCRIPTION_HPP_ diff --git a/implementation/routing/include/routing_host.hpp b/implementation/routing/include/routing_host.hpp new file mode 100644 index 0000000..337e4a7 --- /dev/null +++ b/implementation/routing/include/routing_host.hpp @@ -0,0 +1,44 @@ +// 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_ROUTING_HOST_ +#define VSOMEIP_V3_ROUTING_HOST_ + +#include <memory> + +#include <boost/asio/ip/address.hpp> + +#include <vsomeip/primitive_types.hpp> + +#ifdef ANDROID +#include "../../configuration/include/internal_android.hpp" +#else +#include "../../configuration/include/internal.hpp" +#endif // ANDROID + +namespace vsomeip_v3 { + +class endpoint; + +class routing_host { +public: + virtual ~routing_host() = default; + + virtual void on_message(const byte_t *_data, length_t _length, + endpoint *_receiver, + const boost::asio::ip::address &_destination = + boost::asio::ip::address(), + client_t _bound_client = VSOMEIP_ROUTING_CLIENT, + credentials_t _credentials = {ANY_UID, ANY_GID}, + const boost::asio::ip::address &_remote_address = + boost::asio::ip::address(), + std::uint16_t _remote_port = 0) = 0; + + virtual client_t get_client() const = 0; +}; + +} // namespace vsomeip_v3 + +#endif // VSOMEIP_V3_ROUTING_HOST_ diff --git a/implementation/routing/include/routing_manager.hpp b/implementation/routing/include/routing_manager.hpp index 9ab09f4..fa0e675 100644 --- a/implementation/routing/include/routing_manager.hpp +++ b/implementation/routing/include/routing_manager.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_ROUTING_MANAGER -#define VSOMEIP_ROUTING_MANAGER +#ifndef VSOMEIP_V3_ROUTING_MANAGER_ +#define VSOMEIP_V3_ROUTING_MANAGER_ #include <memory> #include <set> @@ -17,12 +17,13 @@ #include <vsomeip/handler.hpp> #include "types.hpp" -namespace vsomeip { +namespace vsomeip_v3 { class endpoint; class endpoint_definition; class event; class payload; +class security; class routing_manager { public: @@ -31,6 +32,8 @@ public: virtual boost::asio::io_service & get_io() = 0; virtual client_t get_client() const = 0; + virtual void set_client(const client_t &_client) = 0; + virtual session_t get_session() = 0; virtual void init() = 0; virtual void start() = 0; @@ -46,38 +49,41 @@ public: virtual void request_service(client_t _client, service_t _service, instance_t _instance, major_version_t _major, - minor_version_t _minor, bool _use_exclusive_proxy) = 0; + minor_version_t _minor) = 0; virtual void release_service(client_t _client, service_t _service, instance_t _instance) = 0; - virtual void subscribe(client_t _client, service_t _service, + virtual void subscribe(client_t _client, uid_t _uid, gid_t _gid, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - major_version_t _major, event_t _event, - subscription_type_e _subscription_type) = 0; + major_version_t _major, event_t _event) = 0; - virtual void unsubscribe(client_t _client, service_t _service, + virtual void unsubscribe(client_t _client, uid_t _uid, gid_t _gid, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event) = 0; - virtual bool send(client_t _client, std::shared_ptr<message> _message, - bool _flush) = 0; + virtual bool send(client_t _client, std::shared_ptr<message> _message) = 0; virtual bool send(client_t _client, const byte_t *_data, uint32_t _size, - instance_t _instance, bool _flush, bool _reliable, + instance_t _instance, bool _reliable, client_t _bound_client = VSOMEIP_ROUTING_CLIENT, - bool _is_valid_crc = true, bool _sent_from_remote = false) = 0; + credentials_t _credentials = {ANY_UID, ANY_GID}, + uint8_t _status_check = 0, bool _sent_from_remote = false) = 0; - virtual bool send_to(const std::shared_ptr<endpoint_definition> &_target, - std::shared_ptr<message>, bool _flush) = 0; + virtual bool send_to(const client_t _client, + const std::shared_ptr<endpoint_definition> &_target, + std::shared_ptr<message>) = 0; virtual bool send_to(const std::shared_ptr<endpoint_definition> &_target, - const byte_t *_data, uint32_t _size, instance_t _instance, - bool _flush) = 0; - - virtual void register_event(client_t _client, service_t _service, - instance_t _instance, event_t _event, - const std::set<eventgroup_t> &_eventgroups, bool _is_field, + const byte_t *_data, uint32_t _size, instance_t _instance) = 0; + + virtual void register_event(client_t _client, + service_t _service, instance_t _instance, + event_t _notifier, + const std::set<eventgroup_t> &_eventgroups, + const event_type_e _type, + reliability_type_e _reliability, std::chrono::milliseconds _cycle, bool _change_resets_cycle, + bool _update_on_change, epsilon_change_func_t _epsilon_change_func, bool _is_provided, bool _is_shadow = false, bool _is_cache_placeholder = false) = 0; @@ -93,20 +99,21 @@ public: virtual void notify(service_t _service, instance_t _instance, event_t _event, std::shared_ptr<payload> _payload, - bool _force, bool _flush) = 0; + bool _force) = 0; virtual void notify_one(service_t _service, instance_t _instance, event_t _event, std::shared_ptr<payload> _payload, - client_t _client, bool _force, bool _flush, bool _remote_subscriber) = 0; - - virtual void on_identify_response(client_t _client, service_t _service, - instance_t _instance, bool _reliable) = 0; + client_t _client, bool _force +#ifdef VSOMEIP_ENABLE_COMPAT + , bool _remote_subscriber +#endif + ) = 0; virtual void set_routing_state(routing_state_e _routing_state) = 0; virtual void send_get_offered_services_info(client_t _client, offer_type_e _offer_type) = 0; }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif +#endif // VSOMEIP_V3_ROUTING_MANAGER_ diff --git a/implementation/routing/include/routing_manager_adapter.hpp b/implementation/routing/include/routing_manager_adapter.hpp index 3d81120..a2195ee 100644 --- a/implementation/routing/include/routing_manager_adapter.hpp +++ b/implementation/routing/include/routing_manager_adapter.hpp @@ -3,10 +3,10 @@ // 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_ROUTING_MANAGER_ADAPTER -#define VSOMEIP_ROUTING_MANAGER_ADAPTER +#ifndef VSOMEIP_V3_ROUTING_MANAGER_ADAPTER_ +#define VSOMEIP_V3_ROUTING_MANAGER_ADAPTER_ -namespace vsomeip { +namespace vsomeip_v3 { class routing_manager; @@ -19,6 +19,6 @@ public: virtual void process_command(const byte_t *_data, length_t _length) = 0; }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_ROUTING_MANAGER_ADAPTER_HPP +#endif // VSOMEIP_V3_ROUTING_MANAGER_ADAPTER_HPP_ diff --git a/implementation/routing/include/routing_manager_base.hpp b/implementation/routing/include/routing_manager_base.hpp index 6bee10c..acd57fe 100644 --- a/implementation/routing/include/routing_manager_base.hpp +++ b/implementation/routing/include/routing_manager_base.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_ROUTING_MANAGER_BASE -#define VSOMEIP_ROUTING_MANAGER_BASE +#ifndef VSOMEIP_V3_ROUTING_MANAGER_BASE_ +#define VSOMEIP_V3_ROUTING_MANAGER_BASE_ #include <mutex> #include <unordered_set> @@ -12,6 +12,8 @@ #include <condition_variable> #include <vsomeip/constants.hpp> + +#include "routing_host.hpp" #include "routing_manager.hpp" #include "routing_manager_host.hpp" #include "types.hpp" @@ -21,9 +23,10 @@ #include "../../message/include/serializer.hpp" #include "../../message/include/deserializer.hpp" #include "../../configuration/include/configuration.hpp" -#include "../../endpoints/include/endpoint_host.hpp" +#include "../../endpoints/include/endpoint_manager_base.hpp" + +namespace vsomeip_v3 { -namespace vsomeip { #ifdef USE_DLT namespace trace { class connector_impl; @@ -33,90 +36,91 @@ class connector_impl; class serializer; class routing_manager_base : public routing_manager, - public endpoint_host, - public std::enable_shared_from_this<routing_manager_base>{ + public routing_host, + public std::enable_shared_from_this<routing_manager_base> { public: routing_manager_base(routing_manager_host *_host); - virtual ~routing_manager_base(); + virtual ~routing_manager_base() = default; virtual boost::asio::io_service & get_io(); virtual client_t get_client() const; + virtual void set_client(const client_t &_client); + virtual session_t get_session(); - virtual void init(); + virtual void init() = 0; + void init(const std::shared_ptr<endpoint_manager_base>& _endpoint_manager); - virtual bool offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, - minor_version_t _minor); + virtual bool offer_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor); - virtual void stop_offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, minor_version_t _minor); + virtual void stop_offer_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor); - virtual void request_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, - minor_version_t _minor, bool _use_exclusive_proxy); + virtual void request_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor); - virtual void release_service(client_t _client, service_t _service, - instance_t _instance); + virtual void release_service(client_t _client, + service_t _service, instance_t _instance); - virtual void register_event(client_t _client, service_t _service, instance_t _instance, - event_t _event, const std::set<eventgroup_t> &_eventgroups, bool _is_field, + virtual void register_event(client_t _client, + service_t _service, instance_t _instance, + event_t _notifier, + const std::set<eventgroup_t> &_eventgroups, + const event_type_e _type, reliability_type_e _reliability, std::chrono::milliseconds _cycle, bool _change_resets_cycle, - epsilon_change_func_t _epsilon_change_func, - bool _is_provided, bool _is_shadow = false, bool _is_cache_placeholder = false); + bool _update_on_change, epsilon_change_func_t _epsilon_change_func, + bool _is_provided, bool _is_shadow = false, + bool _is_cache_placeholder = false); - virtual void unregister_event(client_t _client, service_t _service, instance_t _instance, - event_t _event, bool _is_provided); + virtual void unregister_event(client_t _client, + service_t _service, instance_t _instance, event_t _event, + bool _is_provided); virtual std::set<std::shared_ptr<event>> find_events(service_t _service, instance_t _instance, eventgroup_t _eventgroup) const; - virtual void subscribe(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, - major_version_t _major, event_t _event, - subscription_type_e _subscription_type); + virtual void subscribe(client_t _client, uid_t _uid, gid_t _gid, + service_t _service, instance_t _instance, + eventgroup_t _eventgroup, major_version_t _major, event_t _event); - virtual void unsubscribe(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event); + virtual void unsubscribe(client_t _client, uid_t _uid, gid_t _gid, + service_t _service, instance_t _instance, + eventgroup_t _eventgroup, event_t _event); virtual void notify(service_t _service, instance_t _instance, - event_t _event, std::shared_ptr<payload> _payload, - bool _force, bool _flush); + event_t _event, std::shared_ptr<payload> _payload, bool _force); virtual void notify_one(service_t _service, instance_t _instance, event_t _event, std::shared_ptr<payload> _payload, - client_t _client, bool _force, bool _flush, bool _remote_subscriber); + client_t _client, bool _force +#ifdef VSOMEIP_ENABLE_COMPAT + , bool _remote_subscriber +#endif + ); - virtual bool send(client_t _client, std::shared_ptr<message> _message, - bool _flush); + virtual bool send(client_t _client, std::shared_ptr<message> _message); virtual bool send(client_t _client, const byte_t *_data, uint32_t _size, - instance_t _instance, bool _flush, bool _reliable, + instance_t _instance, bool _reliable, client_t _bound_client = VSOMEIP_ROUTING_CLIENT, - bool _is_valid_crc = true, bool _sent_from_remote = false) = 0; + credentials_t _credentials = {ANY_UID, ANY_GID}, + uint8_t _status_check = 0, bool _sent_from_remote = false) = 0; - // Endpoint host ~> will be implemented by routing_manager_impl/_proxy/ - virtual void on_connect(std::shared_ptr<endpoint> _endpoint) = 0; - virtual void on_disconnect(std::shared_ptr<endpoint> _endpoint) = 0; + // routing host -> will be implemented by routing_manager_impl/_proxy/ virtual void on_message(const byte_t *_data, length_t _length, endpoint *_receiver, const boost::asio::ip::address &_destination = boost::asio::ip::address(), client_t _bound_client = VSOMEIP_ROUTING_CLIENT, + credentials_t _credentials = {ANY_UID, ANY_GID}, const boost::asio::ip::address &_remote_address = boost::asio::ip::address(), std::uint16_t _remote_port = 0) = 0; - virtual void on_error(const byte_t *_data, length_t _length, - endpoint *_receiver, - const boost::asio::ip::address &_remote_address, - std::uint16_t _remote_port) = 0; -#ifndef _WIN32 - virtual bool check_credentials(client_t _client, uid_t _uid, gid_t _gid); -#endif virtual void set_routing_state(routing_state_e _routing_state) = 0; - virtual std::shared_ptr<event> find_event(service_t _service, instance_t _instance, - event_t _event) const; - virtual void register_client_error_handler(client_t _client, const std::shared_ptr<endpoint> &_endpoint) = 0; @@ -124,8 +128,16 @@ public: std::set<client_t> find_local_clients(service_t _service, instance_t _instance); -protected: std::shared_ptr<serviceinfo> find_service(service_t _service, instance_t _instance) const; + + client_t find_local_client(service_t _service, instance_t _instance) const; + + std::shared_ptr<event> find_event(service_t _service, instance_t _instance, + event_t _event) const; + + virtual void on_connect(const std::shared_ptr<endpoint>& _endpoint) = 0; + virtual void on_disconnect(const std::shared_ptr<endpoint>& _endpoint) = 0; +protected: std::shared_ptr<serviceinfo> create_service_info(service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor, ttl_t _ttl, bool _is_local_service); @@ -134,21 +146,12 @@ protected: services_t get_services() const; services_t get_services_remote() const; bool is_available(service_t _service, instance_t _instance, major_version_t _major); - client_t find_local_client(service_t _service, instance_t _instance); - std::shared_ptr<endpoint> create_local(client_t _client); - std::shared_ptr<endpoint> find_or_create_local(client_t _client); void remove_local(client_t _client, bool _remove_uid); void remove_local(client_t _client, const std::set<std::tuple<service_t, instance_t, eventgroup_t>>& _subscribed_eventgroups, bool _remove_uid); - std::shared_ptr<endpoint> find_local(client_t _client); - std::shared_ptr<endpoint> find_local(service_t _service, - instance_t _instance); - - std::unordered_set<client_t> get_connected_clients(); - std::shared_ptr<eventgroupinfo> find_eventgroup(service_t _service, instance_t _instance, eventgroup_t _eventgroup) const; @@ -157,33 +160,35 @@ protected: bool send_local_notification(client_t _client, const byte_t *_data, uint32_t _size, instance_t _instance, - bool _flush = true, bool _reliable = false, bool _is_valid_crc = true); + bool _reliable = false, uint8_t _status_check = 0); bool send_local( std::shared_ptr<endpoint> &_target, client_t _client, const byte_t *_data, uint32_t _size, instance_t _instance, - bool _flush, bool _reliable, uint8_t _command, bool _is_valid_crc = true) const; + bool _reliable, uint8_t _command, uint8_t _status_check = 0) const; bool insert_subscription(service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, client_t _client, std::set<event_t> *_already_subscribed_events); + std::shared_ptr<serializer> get_serializer(); + void put_serializer(const std::shared_ptr<serializer> &_serializer); std::shared_ptr<deserializer> get_deserializer(); - void put_deserializer(std::shared_ptr<deserializer>); + void put_deserializer(const std::shared_ptr<deserializer> &_deserializer); void send_pending_subscriptions(service_t _service, instance_t _instance, major_version_t _major); virtual void send_subscribe(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - major_version_t _major, event_t _event, - subscription_type_e _subscription_type) = 0; + major_version_t _major, event_t _event) = 0; void remove_pending_subscription(service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event); - +#ifdef VSOMEIP_ENABLE_COMPAT void send_pending_notify_ones(service_t _service, instance_t _instance, eventgroup_t _eventgroup, client_t _client, bool _remote_subscriber = false); +#endif void unset_all_eventpayloads(service_t _service, instance_t _instance); void unset_all_eventpayloads(service_t _service, instance_t _instance, @@ -194,11 +199,6 @@ protected: eventgroup_t _eventgroup, event_t _event, const std::set<event_t> &_events_to_exclude); - void send_identify_request(service_t _service, instance_t _instance, - major_version_t _major, bool _reliable); - - std::map<client_t, std::shared_ptr<endpoint>> get_local_endpoints(); - std::set<std::tuple<service_t, instance_t, eventgroup_t>> get_subscriptions(const client_t _client); @@ -206,9 +206,9 @@ protected: bool is_response_allowed(client_t _sender, service_t _service, instance_t _instance, method_t _method); - bool is_subscribe_to_any_event_allowed(client_t _client, + bool is_subscribe_to_any_event_allowed(credentials_t _credentials, client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup); - +#ifdef VSOMEIP_ENABLE_COMPAT void set_incoming_subscription_state(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, subscription_state_e _state); @@ -217,12 +217,9 @@ protected: void erase_incoming_subscription_state(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event); +#endif private: - std::shared_ptr<endpoint> create_local_unlocked(client_t _client); - std::shared_ptr<endpoint> find_local_unlocked(client_t _client); - - virtual bool create_placeholder_event_and_subscribe( service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, client_t _client) = 0; @@ -230,18 +227,22 @@ private: protected: routing_manager_host *host_; boost::asio::io_service &io_; - client_t client_; + std::atomic<client_t> client_; std::shared_ptr<configuration> configuration_; - std::shared_ptr<serializer> serializer_; - std::mutex serialize_mutex_; + + std::queue<std::shared_ptr<serializer>> serializers_; + std::mutex serializer_mutex_; + std::condition_variable serializer_condition_; std::queue<std::shared_ptr<deserializer>> deserializers_; std::mutex deserializer_mutex_; std::condition_variable deserializer_condition_; - std::mutex local_services_mutex_; - std::map<service_t, std::map<instance_t, std::tuple< major_version_t, minor_version_t, client_t> > > local_services_; + mutable std::mutex local_services_mutex_; + typedef std::map<service_t, std::map<instance_t, + std::tuple<major_version_t, minor_version_t, client_t>>> local_services_map_t; + local_services_map_t local_services_; std::map<service_t, std::map<instance_t, std::set<client_t> > > local_services_history_; // Eventgroups @@ -252,7 +253,11 @@ protected: // Events (part of one or more eventgroups) mutable std::mutex events_mutex_; std::map<service_t, - std::map<instance_t, std::map<event_t, std::shared_ptr<event> > > > events_; + std::map<instance_t, + std::map<event_t, + std::shared_ptr<event> > > > events_; + + std::mutex event_registration_mutex_; #ifdef USE_DLT std::shared_ptr<trace::connector_impl> tc_; @@ -264,7 +269,8 @@ protected: eventgroup_t eventgroup_; major_version_t major_; event_t event_; - subscription_type_e subscription_type_; + uid_t uid_; + gid_t gid_; bool operator<(const subscription_data_t &_other) const { return (service_ < _other.service_ @@ -284,21 +290,21 @@ protected: services_t services_remote_; mutable std::mutex services_remote_mutex_; + std::shared_ptr<endpoint_manager_base> ep_mgr_; + + std::uint32_t own_uid_; + std::uint32_t own_gid_; + private: services_t services_; mutable std::mutex services_mutex_; - std::map<client_t, std::shared_ptr<endpoint> > local_endpoints_; - mutable std::mutex local_endpoint_mutex_; - +#ifdef VSOMEIP_ENABLE_COMPAT std::map<service_t, std::map<instance_t, std::map<eventgroup_t, std::shared_ptr<message> > > > pending_notify_ones_; std::recursive_mutex pending_notify_ones_mutex_; - - std::mutex event_registration_mutex_; - std::map<client_t, std::map<service_t, std::map<instance_t, @@ -306,9 +312,10 @@ private: std::map<event_t, subscription_state_e> > > > > incoming_subscription_state_; std::recursive_mutex incoming_subscription_state_mutex_; +#endif }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif //VSOMEIP_ROUTING_MANAGER_BASE +#endif // VSOMEIP_V3_ROUTING_MANAGER_BASE_ diff --git a/implementation/routing/include/routing_manager_host.hpp b/implementation/routing/include/routing_manager_host.hpp index 7aa767a..69133e2 100644 --- a/implementation/routing/include/routing_manager_host.hpp +++ b/implementation/routing/include/routing_manager_host.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_ROUTING_MANAGER_HOST -#define VSOMEIP_ROUTING_MANAGER_HOST +#ifndef VSOMEIP_V3_ROUTING_MANAGER_HOST_ +#define VSOMEIP_V3_ROUTING_MANAGER_HOST_ #include <memory> @@ -12,7 +12,7 @@ #include <vsomeip/error.hpp> -namespace vsomeip { +namespace vsomeip_v3 { class configuration; class message; @@ -23,6 +23,8 @@ public: } virtual client_t get_client() const = 0; + virtual void set_client(const client_t &_client) = 0; + virtual session_t get_session() = 0; virtual const std::string & get_name() const = 0; virtual std::shared_ptr<configuration> get_configuration() const = 0; virtual boost::asio::io_service & get_io() = 0; @@ -30,19 +32,17 @@ public: virtual void on_availability(service_t _service, instance_t _instance, bool _is_available, major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0; virtual void on_state(state_type_e _state) = 0; - virtual void on_message(const std::shared_ptr<message> &&_message) = 0; - virtual void on_error(error_code_e _error) = 0; + virtual void on_message(std::shared_ptr<message> &&_message) = 0; virtual void on_subscription(service_t _service, instance_t _instance, - eventgroup_t _eventgroup, client_t _client, bool _subscribed, std::function<void(bool)> _accepted_cb) = 0; - virtual void on_subscription_error(service_t _service, instance_t _instance, - eventgroup_t _eventgroup, uint16_t _error) = 0; + eventgroup_t _eventgroup, client_t _client, uid_t _uid, gid_t _gid, bool _subscribed, + std::function<void(bool)> _accepted_cb) = 0; virtual void on_subscription_status(service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, uint16_t _error) = 0; - virtual void send(std::shared_ptr<message> _message, bool _flush) = 0; + virtual void send(std::shared_ptr<message> _message) = 0; virtual void on_offered_services_info(std::vector<std::pair<service_t, instance_t>> &_services) = 0; virtual bool is_routing() const = 0; }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_ROUTING_MANAGER_HOST +#endif // VSOMEIP_V3_ROUTING_MANAGER_HOST_ diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp index 40abf73..bead207 100644 --- a/implementation/routing/include/routing_manager_impl.hpp +++ b/implementation/routing/include/routing_manager_impl.hpp @@ -1,10 +1,10 @@ -// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// Copyright (C) 2014-2018 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_ROUTING_MANAGER_IMPL_HPP -#define VSOMEIP_ROUTING_MANAGER_IMPL_HPP +#ifndef VSOMEIP_V3_ROUTING_MANAGER_IMPL_HPP_ +#define VSOMEIP_V3_ROUTING_MANAGER_IMPL_HPP_ #include <map> #include <memory> @@ -26,8 +26,10 @@ #include "../../endpoints/include/netlink_connector.hpp" #include "../../service_discovery/include/service_discovery_host.hpp" +#include "../../endpoints/include/endpoint_manager_impl.hpp" -namespace vsomeip { + +namespace vsomeip_v3 { class configuration; class deserializer; @@ -42,9 +44,9 @@ namespace sd { class service_discovery; } // namespace sd - -// TODO: encapsulate common parts of classes "routing_manager_impl" -// and "routing_manager_proxy" into a base class. +namespace e2e { +class e2e_provider; +} // namespace e2e class routing_manager_impl: public routing_manager_base, public routing_manager_stub_host, @@ -55,61 +57,70 @@ public: boost::asio::io_service & get_io(); client_t get_client() const; - const std::shared_ptr<configuration> get_configuration() const; void init(); void start(); void stop(); - bool offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, - minor_version_t _minor); + bool offer_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor); - void stop_offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, minor_version_t _minor); + void stop_offer_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor); - void request_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, - minor_version_t _minor, bool _use_exclusive_proxy); + void request_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor); - void release_service(client_t _client, service_t _service, - instance_t _instance); + void release_service(client_t _client, + service_t _service, instance_t _instance); - void subscribe(client_t _client, service_t _service, instance_t _instance, - eventgroup_t _eventgroup, major_version_t _major, event_t _event, - subscription_type_e _subscription_type); + void subscribe(client_t _client, uid_t _uid, gid_t _gid, + service_t _service, instance_t _instance, + eventgroup_t _eventgroup, major_version_t _major, event_t _event); - void unsubscribe(client_t _client, service_t _service, instance_t _instance, + void unsubscribe(client_t _client, uid_t _uid, gid_t _gid, + service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event); - bool send(client_t _client, std::shared_ptr<message> _message, bool _flush); + bool send(client_t _client, std::shared_ptr<message> _message); - virtual bool send(client_t _client, const byte_t *_data, uint32_t _size, - instance_t _instance, bool _flush, bool _reliable, + bool send(client_t _client, const byte_t *_data, uint32_t _size, + instance_t _instance, bool _reliable, client_t _bound_client = VSOMEIP_ROUTING_CLIENT, - bool _is_valid_crc = true, bool _sent_from_remote = false); + credentials_t _credentials = {ANY_UID, ANY_GID}, + uint8_t _status_check = 0, bool _sent_from_remote = false); - bool send_to(const std::shared_ptr<endpoint_definition> &_target, - std::shared_ptr<message> _message, bool _flush); + bool send_to(const client_t _client, + const std::shared_ptr<endpoint_definition> &_target, + std::shared_ptr<message> _message); bool send_to(const std::shared_ptr<endpoint_definition> &_target, const byte_t *_data, uint32_t _size, - instance_t _instance, bool _flush); + instance_t _instance); - bool send_to(const std::shared_ptr<endpoint_definition> &_target, + bool send_via_sd(const std::shared_ptr<endpoint_definition> &_target, const byte_t *_data, uint32_t _size, uint16_t _sd_port); - void register_event(client_t _client, service_t _service, - instance_t _instance, event_t _event, - const std::set<eventgroup_t> &_eventgroups, bool _is_field, + void register_event(client_t _client, + service_t _service, instance_t _instance, + event_t _notifier, + const std::set<eventgroup_t> &_eventgroups, + const event_type_e _type, + reliability_type_e _reliability, std::chrono::milliseconds _cycle, bool _change_resets_cycle, + bool _update_on_change, epsilon_change_func_t _epsilon_change_func, bool _is_provided, bool _is_shadow, bool _is_cache_placeholder); - void register_shadow_event(client_t _client, service_t _service, - instance_t _instance, event_t _event, + void register_shadow_event(client_t _client, + service_t _service, instance_t _instance, + event_t _notifier, const std::set<eventgroup_t> &_eventgroups, - bool _is_field, bool _is_provided); + event_type_e _type, reliability_type_e _reliability, + bool _is_provided); void unregister_shadow_event(client_t _client, service_t _service, instance_t _instance, event_t _event, @@ -117,63 +128,68 @@ public: void notify_one(service_t _service, instance_t _instance, event_t _event, std::shared_ptr<payload> _payload, - client_t _client, bool _force, bool _flush, bool _remote_subscriber); + client_t _client, bool _force +#ifdef VSOMEIP_ENABLE_COMPAT + , bool _remote_subscriber +#endif + ); - void on_subscribe_nack(client_t _client, service_t _service, + void on_subscribe_ack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, - pending_subscription_id_t _subscription_id); + remote_subscription_id_t _id); - void on_subscribe_ack(client_t _client, service_t _service, + void on_subscribe_nack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, - pending_subscription_id_t _subscription_id); + remote_subscription_id_t _id); - void on_identify_response(client_t _client, service_t _service, instance_t _instance, - bool _reliable); // interface to stub inline std::shared_ptr<endpoint> find_local(client_t _client) { - return routing_manager_base::find_local(_client); + return ep_mgr_->find_local(_client); } inline std::shared_ptr<endpoint> find_or_create_local( client_t _client) { - return routing_manager_base::find_or_create_local(_client); + return ep_mgr_->find_or_create_local(_client); } + std::shared_ptr<endpoint> find_or_create_remote_client( + service_t _service, instance_t _instance, bool _reliable, + client_t _client); + void remove_local(client_t _client, bool _remove_uid); - void on_stop_offer_service(client_t _client, service_t _service, instance_t _instance, + void on_stop_offer_service(client_t _client, + service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor); void on_availability(service_t _service, instance_t _instance, - bool _is_available, major_version_t _major, minor_version_t _minor); + bool _is_available, + major_version_t _major, minor_version_t _minor); void on_pong(client_t _client); + void on_subscribe_ack_with_multicast( + service_t _service, instance_t _instance, + const boost::asio::ip::address &_address, uint16_t _port); void on_unsubscribe_ack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - pending_subscription_id_t _unsubscription_id); - - // interface "endpoint_host" - std::shared_ptr<endpoint> find_or_create_remote_client(service_t _service, - instance_t _instance, - bool _reliable, client_t _client); - void on_connect(std::shared_ptr<endpoint> _endpoint); - void on_disconnect(std::shared_ptr<endpoint> _endpoint); - void on_error(const byte_t *_data, length_t _length, endpoint *_receiver, - const boost::asio::ip::address &_remote_address, - std::uint16_t _remote_port); + remote_subscription_id_t _id); + + void on_connect(const std::shared_ptr<endpoint>& _endpoint); + void on_disconnect(const std::shared_ptr<endpoint>& _endpoint); + void on_message(const byte_t *_data, length_t _size, endpoint *_receiver, const boost::asio::ip::address &_destination, - client_t _bound_client, + client_t _bound_client, credentials_t _credentials, const boost::asio::ip::address &_remote_address, std::uint16_t _remote_port); bool on_message(service_t _service, instance_t _instance, const byte_t *_data, length_t _size, bool _reliable, - client_t _bound_client, bool _is_valid_crc = true, + client_t _bound_client, credentials_t _credentials, + uint8_t _check_status = 0, bool _is_from_remote = false); void on_notification(client_t _client, service_t _service, instance_t _instance, const byte_t *_data, length_t _size, bool _notify_one); - void release_port(uint16_t _port, bool _reliable); bool offer_service_remotely(service_t _service, instance_t _instance, std::uint16_t _port, bool _reliable, @@ -206,29 +222,22 @@ public: bool _has_reliable, bool _has_unreliable); void update_routing_info(std::chrono::milliseconds _elapsed); - void on_remote_subscription( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, - const std::shared_ptr<endpoint_definition> &_subscriber, - const std::shared_ptr<endpoint_definition> &_target, ttl_t _ttl, - const std::shared_ptr<sd_message_identifier_t> &_sd_message_id, - const std::function<void(remote_subscription_state_e, client_t)>& _callback); - void on_unsubscribe(service_t _service, instance_t _instance, - eventgroup_t _eventgroup, - std::shared_ptr<endpoint_definition> _target); - void on_subscribe_ack(service_t _service, instance_t _instance, - const boost::asio::ip::address &_address, uint16_t _port); + // Handle remote subscriptions / subscription acks + void on_remote_subscribe( + std::shared_ptr<remote_subscription> &_subscription, + const remote_subscription_callback_t& _callback); + void on_remote_unsubscribe( + std::shared_ptr<remote_subscription> &_subscription); void expire_subscriptions(const boost::asio::ip::address &_address); void expire_services(const boost::asio::ip::address &_address); std::chrono::steady_clock::time_point expire_subscriptions(bool _force); - bool has_identified(client_t _client, service_t _service, - instance_t _instance, bool _reliable); - void register_client_error_handler(client_t _client, const std::shared_ptr<endpoint> &_endpoint); void handle_client_error(client_t _client); + std::shared_ptr<endpoint_manager_impl> get_endpoint_manager() const; void set_routing_state(routing_state_e _routing_state); @@ -241,46 +250,61 @@ public: eventgroup_t _eventgroup, const std::shared_ptr<endpoint_definition> &_subscriber); - void register_offer_acceptance_handler(offer_acceptance_handler_t _handler) const; - void register_reboot_notification_handler(reboot_notification_handler_t _handler) const; - void register_routing_ready_handler(routing_ready_handler_t _handler); - void register_routing_state_handler(routing_state_handler_t _handler); - void offer_acceptance_enabled(boost::asio::ip::address _address); + void print_stub_status() const; + + void send_error(return_code_e _return_code, const byte_t *_data, + length_t _size, instance_t _instance, bool _reliable, + endpoint* const _receiver, + const boost::asio::ip::address &_remote_address, + std::uint16_t _remote_port); + void service_endpoint_connected(service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor, + const std::shared_ptr<endpoint>& _endpoint, + bool _unreliable_only); + void service_endpoint_disconnected(service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor, + const std::shared_ptr<endpoint>& _endpoint); + + void register_sd_acceptance_handler(const sd_acceptance_handler_t& _handler) const; + void register_reboot_notification_handler(const reboot_notification_handler_t& _handler) const; + void register_routing_ready_handler(const routing_ready_handler_t& _handler); + void register_routing_state_handler(const routing_state_handler_t& _handler); + void sd_acceptance_enabled(const boost::asio::ip::address& _address); void on_resend_provided_events_response(pending_remote_offer_id_t _id); - bool update_security_policy_configuration(uint32_t _uid, uint32_t _gid, ::std::shared_ptr<policy> _policy, - std::shared_ptr<payload> _payload, security_update_handler_t _handler); - bool remove_security_policy_configuration(uint32_t _uid, uint32_t _gid, security_update_handler_t _handler); + bool update_security_policy_configuration(uint32_t _uid, uint32_t _gid, const std::shared_ptr<policy>& _policy, + const std::shared_ptr<payload>& _payload, const security_update_handler_t& _handler); + bool remove_security_policy_configuration(uint32_t _uid, uint32_t _gid, const security_update_handler_t& _handler); + client_t find_local_client(service_t _service, instance_t _instance); void on_security_update_response(pending_security_update_id_t _id, client_t _client); std::set<client_t> find_local_clients(service_t _service, instance_t _instance); - bool is_subscribe_to_any_event_allowed(client_t _client, + bool is_subscribe_to_any_event_allowed(credentials_t _credentials, client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup); private: + bool offer_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor, + bool _must_queue); + + void stop_offer_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor, + bool _must_queue); + bool deliver_message(const byte_t *_data, length_t _size, instance_t _instance, bool _reliable, client_t _bound_client, - bool _is_valid_crc = true, bool _is_from_remote = false); + credentials_t _credentials, + uint8_t _status_check = 0, bool _is_from_remote = false); bool deliver_notification(service_t _service, instance_t _instance, const byte_t *_data, length_t _length, bool _reliable, client_t _bound_client, - bool _is_valid_crc = true, bool _is_from_remote = false); + credentials_t _credentials, + uint8_t _status_check = 0, bool _is_from_remote = false); - instance_t find_instance(service_t _service, endpoint *_endpoint); void init_service_info(service_t _service, instance_t _instance, bool _is_local_service); - std::shared_ptr<endpoint> create_client_endpoint( - const boost::asio::ip::address &_address, - uint16_t _local_port, uint16_t _remote_port, - bool _reliable, client_t _client); - - std::shared_ptr<endpoint> create_server_endpoint(uint16_t _port, - bool _reliable, bool _start); - std::shared_ptr<endpoint> find_server_endpoint(uint16_t _port, - bool _reliable) const; - std::shared_ptr<endpoint> find_or_create_server_endpoint(uint16_t _port, - bool _reliable, bool _start); - bool is_field(service_t _service, instance_t _instance, event_t _event) const; @@ -290,74 +314,32 @@ private: std::shared_ptr<endpoint> create_remote_client(service_t _service, instance_t _instance, bool _reliable, client_t _client); - bool deliver_specific_endpoint_message(service_t _service, instance_t _instance, - const byte_t *_data, length_t _size, endpoint *_receiver); - void clear_client_endpoints(service_t _service, instance_t _instance, bool _reliable); void clear_multicast_endpoints(service_t _service, instance_t _instance); - bool is_identifying(client_t _client, service_t _service, - instance_t _instance, bool _reliable); - std::set<eventgroup_t> get_subscribed_eventgroups(service_t _service, instance_t _instance); void clear_targets_and_pending_sub_from_eventgroups(service_t _service, instance_t _instance); void clear_remote_subscriber(service_t _service, instance_t _instance); -private: + return_code_e check_error(const byte_t *_data, length_t _size, instance_t _instance); - void send_error(return_code_e _return_code, const byte_t *_data, - length_t _size, instance_t _instance, bool _reliable, - endpoint *_receiver, - const boost::asio::ip::address &_remote_address, - std::uint16_t _remote_port); - - void identify_for_subscribe(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, - subscription_type_e _subscription_type); - bool send_identify_message(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, - bool _reliable); - bool supports_selective(service_t _service, instance_t _instance); - client_t find_client(service_t _service, instance_t _instance, - const std::shared_ptr<eventgroupinfo> &_eventgroup, - const std::shared_ptr<endpoint_definition> &_target) const; - void clear_remote_subscriber(service_t _service, instance_t _instance, client_t _client, const std::shared_ptr<endpoint_definition> &_target); void log_version_timer_cbk(boost::system::error_code const & _error); - void clear_remote_service_info(service_t _service, instance_t _instance, bool _reliable); - bool handle_local_offer_service(client_t _client, service_t _service, instance_t _instance, major_version_t _major,minor_version_t _minor); - void remove_specific_client_endpoint(client_t _client, service_t _service, instance_t _instance, bool _reliable); - - void clear_identified_clients( service_t _service, instance_t _instance); - - void clear_identifying_clients( service_t _service, instance_t _instance); - - void remove_identified_client(service_t _service, instance_t _instance, client_t _client); - - void remove_identifying_client(service_t _service, instance_t _instance, client_t _client); - - void unsubscribe_specific_client_at_sd(service_t _service, instance_t _instance, client_t _client); - - inline std::shared_ptr<endpoint> find_local(service_t _service, instance_t _instance) { - return routing_manager_base::find_local(_service, _instance); - } - void send_subscribe(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - major_version_t _major, event_t _event, - subscription_type_e _subscription_type); + major_version_t _major, event_t _event); void on_net_interface_or_route_state_changed(bool _is_interface, std::string _if, @@ -373,7 +355,7 @@ private: void call_sd_endpoint_connected(const boost::system::error_code& _error, service_t _service, instance_t _instance, - std::shared_ptr<endpoint> _endpoint, + const std::shared_ptr<endpoint>& _endpoint, std::shared_ptr<boost::asio::steady_timer> _timer); bool create_placeholder_event_and_subscribe(service_t _service, @@ -385,29 +367,26 @@ private: void handle_subscription_state(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event); - client_t is_specific_endpoint_client(client_t _client, service_t _service, instance_t _instance); - std::unordered_set<client_t> get_specific_endpoint_clients(service_t _service, instance_t _instance); - void memory_log_timer_cbk(boost::system::error_code const & _error); void status_log_timer_cbk(boost::system::error_code const & _error); - void send_subscription(client_t _offering_client, - client_t _subscribing_client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, - major_version_t _major, - pending_subscription_id_t _pending_subscription_id); + void send_subscription(const client_t _offering_client, + const service_t _service, const instance_t _instance, + const eventgroup_t _eventgroup, const major_version_t _major, + const std::set<client_t> &_clients, + const remote_subscription_id_t _id); - void send_unsubscription( - client_t _offering_client, client_t _subscribing_client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, - pending_subscription_id_t _pending_unsubscription_id); + void send_unsubscription(client_t _offering_client, + const service_t _service, const instance_t _instance, + const eventgroup_t _eventgroup, const major_version_t _major, + const std::set<client_t> &_removed, + const remote_subscription_id_t _id); void cleanup_server_endpoint(service_t _service, const std::shared_ptr<endpoint>& _endpoint); pending_remote_offer_id_t pending_remote_offer_add(service_t _service, instance_t _instance); - std::pair<service_t, instance_t> pending_remote_offer_remove( pending_remote_offer_id_t _id); @@ -417,7 +396,7 @@ private: std::shared_ptr<boost::asio::steady_timer> _timer); pending_security_update_id_t pending_security_update_add( - std::unordered_set<client_t> _clients); + const std::unordered_set<client_t>& _clients); std::unordered_set<client_t> pending_security_update_get( pending_security_update_id_t _id); @@ -428,54 +407,28 @@ private: bool is_pending_security_update_finished( pending_security_update_id_t _id); - std::shared_ptr<routing_manager_stub> stub_; - std::shared_ptr<sd::service_discovery> discovery_; - - // Server endpoints for local services - typedef std::map<uint16_t, std::map<bool, std::shared_ptr<endpoint>>> server_endpoints_t; - server_endpoints_t server_endpoints_; - std::map<service_t, std::map<endpoint *, instance_t> > service_instances_; + bool insert_offer_command(service_t _service, instance_t _instance, uint8_t _command, + client_t _client, major_version_t _major, minor_version_t _minor); + bool erase_offer_command(service_t _service, instance_t _instance); - // Multicast endpoint info (notifications) - std::map<service_t, std::map<instance_t, std::shared_ptr<endpoint_definition> > > multicast_info; + bool is_last_stop_callback(const uint32_t _callback_id); - // Client endpoints for remote services - std::map<service_t, - std::map<instance_t, std::map<bool, std::shared_ptr<endpoint_definition> > > > remote_service_info_; - - typedef std::map<service_t, std::map<instance_t, std::map<client_t, - std::map<bool, std::shared_ptr<endpoint>>>>> remote_services_t; - remote_services_t remote_services_; +private: + std::shared_ptr<routing_manager_stub> stub_; + std::shared_ptr<sd::service_discovery> discovery_; - typedef std::map<boost::asio::ip::address, std::map<uint16_t, - std::map<bool, std::shared_ptr<endpoint>>>> client_endpoints_by_ip_t; - client_endpoints_by_ip_t client_endpoints_by_ip_; + std::mutex requested_services_mutex_; std::map<client_t, std::map<service_t, std::map<instance_t, std::set<std::pair<major_version_t, minor_version_t>>>>> requested_services_; - // Mutexes - mutable std::recursive_mutex endpoint_mutex_; - std::mutex identified_clients_mutex_; - std::mutex requested_services_mutex_; - std::mutex remote_subscribers_mutex_; std::map<service_t, std::map<instance_t, std::map<client_t, std::set<std::shared_ptr<endpoint_definition>>>>> remote_subscribers_; - std::mutex specific_endpoint_clients_mutex_; - std::map<service_t, std::map<instance_t, std::unordered_set<client_t>>>specific_endpoint_clients_; - std::map<service_t, std::map<instance_t, - std::map<bool, std::unordered_set<client_t> > > > identified_clients_; - std::map<service_t, std::map<instance_t, - std::map<bool, std::unordered_set<client_t> > > > identifying_clients_; - std::shared_ptr<serviceinfo> sd_info_; - std::map<bool, std::set<uint16_t>> used_client_ports_; - std::mutex used_client_ports_mutex_; - std::mutex version_log_timer_mutex_; boost::asio::steady_timer version_log_timer_; @@ -488,12 +441,6 @@ private: std::shared_ptr<netlink_connector> netlink_connector_; #endif -#ifndef WITHOUT_SYSTEMD - std::mutex watchdog_timer_mutex_; - boost::asio::steady_timer watchdog_timer_; - void watchdog_cbk(boost::system::error_code const &_error); -#endif - std::mutex pending_offers_mutex_; // map to store pending offers. // 1st client id in tuple: client id of new offering application @@ -509,8 +456,7 @@ private: std::map<std::tuple<service_t, instance_t, eventgroup_t, client_t>, subscription_state_e> remote_subscription_state_; - std::map<e2exf::data_identifier_t, std::shared_ptr<e2e::profile_interface::protector>> custom_protectors; - std::map<e2exf::data_identifier_t, std::shared_ptr<e2e::profile_interface::checker>> custom_checkers; + std::shared_ptr<e2e::e2e_provider> e2e_provider_; std::mutex status_log_timer_mutex_; boost::asio::steady_timer status_log_timer_; @@ -518,6 +464,10 @@ private: std::mutex memory_log_timer_mutex_; boost::asio::steady_timer memory_log_timer_; + std::shared_ptr<endpoint_manager_impl> ep_mgr_impl_; + + reboot_notification_handler_t reboot_notification_handler_; + routing_ready_handler_t routing_ready_handler_; routing_state_handler_t routing_state_handler_; @@ -537,8 +487,14 @@ private: std::mutex security_update_timers_mutex_; std::map<pending_security_update_id_t, std::shared_ptr<boost::asio::steady_timer>> security_update_timers_; + + std::mutex offer_serialization_mutex_; + std::map<std::pair<service_t, instance_t>, std::deque<std::tuple<uint8_t, client_t, major_version_t, minor_version_t>>> offer_commands_; + + std::mutex callback_counts_mutex_; + std::map<uint32_t, uint16_t> callback_counts_; }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_ROUTING_MANAGER_IMPL_HPP +#endif // VSOMEIP_V3_ROUTING_MANAGER_IMPL_HPP_ diff --git a/implementation/routing/include/routing_manager_proxy.hpp b/implementation/routing/include/routing_manager_proxy.hpp index fbe775d..d1a29df 100644 --- a/implementation/routing/include/routing_manager_proxy.hpp +++ b/implementation/routing/include/routing_manager_proxy.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_ROUTING_MANAGER_PROXY_HPP -#define VSOMEIP_ROUTING_MANAGER_PROXY_HPP +#ifndef VSOMEIP_V3_ROUTING_MANAGER_PROXY_HPP +#define VSOMEIP_V3_ROUTING_MANAGER_PROXY_HPP #include <map> #include <mutex> @@ -19,7 +19,7 @@ #include <vsomeip/enumeration_types.hpp> #include <vsomeip/handler.hpp> -namespace vsomeip { +namespace vsomeip_v3 { class configuration; class event; @@ -37,68 +37,70 @@ public: void start(); void stop(); - const std::shared_ptr<configuration> get_configuration() const; + std::shared_ptr<configuration> get_configuration() const; - bool offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, - minor_version_t _minor); + bool offer_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor); - void stop_offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, minor_version_t _minor); + void stop_offer_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor); - void request_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, - minor_version_t _minor, bool _use_exclusive_proxy); + void request_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor); - void release_service(client_t _client, service_t _service, - instance_t _instance); + void release_service(client_t _client, + service_t _service, instance_t _instance); - void subscribe(client_t _client, service_t _service, instance_t _instance, - eventgroup_t _eventgroup, major_version_t _major, event_t _event, - subscription_type_e _subscription_type); + void subscribe(client_t _client, uid_t _uid, gid_t _gid, + service_t _service, instance_t _instance, + eventgroup_t _eventgroup, major_version_t _major, + event_t _event); - void unsubscribe(client_t _client, service_t _service, instance_t _instance, + void unsubscribe(client_t _client, uid_t _uid, gid_t _gid, + service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event); bool send(client_t _client, const byte_t *_data, uint32_t _size, - instance_t _instance, bool _flush, bool _reliable, + instance_t _instance, bool _reliable, client_t _bound_client = VSOMEIP_ROUTING_CLIENT, - bool _is_valid_crc = true, bool _sent_from_remote = false); + credentials_t _credentials = {ANY_UID, ANY_GID}, + uint8_t _status_check = 0, bool _sent_from_remote = false); - bool send_to(const std::shared_ptr<endpoint_definition> &_target, - std::shared_ptr<message> _message, bool _flush); + bool send_to(const client_t _client, + const std::shared_ptr<endpoint_definition> &_target, + std::shared_ptr<message> _message); bool send_to(const std::shared_ptr<endpoint_definition> &_target, - const byte_t *_data, uint32_t _size, instance_t _instance, bool _flush); + const byte_t *_data, uint32_t _size, instance_t _instance); - void register_event(client_t _client, service_t _service, - instance_t _instance, event_t _event, - const std::set<eventgroup_t> &_eventgroups, bool _is_field, + void register_event(client_t _client, + service_t _service, instance_t _instance, + event_t _notifier, + const std::set<eventgroup_t> &_eventgroups, + const event_type_e _type, + reliability_type_e _reliability, std::chrono::milliseconds _cycle, bool _change_resets_cycle, + bool _update_on_change, epsilon_change_func_t _epsilon_change_func, bool _is_provided, bool _is_shadow, bool _is_cache_placeholder); void unregister_event(client_t _client, service_t _service, - instance_t _instance, event_t _event, - bool _is_provided); + instance_t _instance, event_t _notifier, bool _is_provided); - void on_connect(std::shared_ptr<endpoint> _endpoint); - void on_disconnect(std::shared_ptr<endpoint> _endpoint); + void on_connect(const std::shared_ptr<endpoint>& _endpoint); + void on_disconnect(const std::shared_ptr<endpoint>& _endpoint); void on_message(const byte_t *_data, length_t _size, endpoint *_receiver, const boost::asio::ip::address &_destination, client_t _bound_client, + credentials_t _credentials, const boost::asio::ip::address &_remote_address, std::uint16_t _remote_port); - void on_error(const byte_t *_data, length_t _length, endpoint *_receiver, - const boost::asio::ip::address &_remote_address, - std::uint16_t _remote_port); - void release_port(uint16_t _port, bool _reliable); void on_routing_info(const byte_t *_data, uint32_t _size); - void on_identify_response(client_t _client, service_t _service, instance_t _instance, - bool _reliable); - void register_client_error_handler(client_t _client, const std::shared_ptr<endpoint> &_endpoint); void handle_client_error(client_t _client); @@ -108,6 +110,7 @@ public: void send_get_offered_services_info(client_t _client, offer_type_e _offer_type); private: + void assign_client(); void register_application(); void deregister_application(); @@ -117,24 +120,25 @@ private: void send_offer_service(client_t _client, service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor); - void send_release_service(client_t _client, service_t _service, - instance_t _instance); - void send_register_event(client_t _client, service_t _service, - instance_t _instance, event_t _event, + void send_release_service(client_t _client, + service_t _service, instance_t _instance); + void send_register_event(client_t _client, + service_t _service, instance_t _instance, + event_t _notifier, const std::set<eventgroup_t> &_eventgroups, - bool _is_field, bool _is_provided); + const event_type_e _type, reliability_type_e _reliability, + bool _is_provided); void send_subscribe(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - major_version_t _major, event_t _event, - subscription_type_e _subscription_type); + major_version_t _major, event_t _event); void send_subscribe_nack(client_t _subscriber, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, - pending_subscription_id_t _subscription_id); + remote_subscription_id_t _id); void send_subscribe_ack(client_t _subscriber, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, - pending_subscription_id_t _subscription_id); + remote_subscription_id_t _id); bool is_field(service_t _service, instance_t _instance, event_t _event) const; @@ -161,6 +165,8 @@ private: eventgroup_t _eventgroup, bool _increment); void clear_remote_subscriber_count(service_t _service, instance_t _instance); + void assign_client_timeout_cbk(boost::system::error_code const &_error); + void register_application_timeout_cbk(boost::system::error_code const &_error); void send_registered_ack(); @@ -171,19 +177,16 @@ private: bool is_client_known(client_t _client); - bool create_placeholder_event_and_subscribe(service_t _service, - instance_t _instance, - eventgroup_t _eventgroup, - event_t _event, - client_t _client); + bool create_placeholder_event_and_subscribe( + service_t _service, instance_t _instance, + eventgroup_t _eventgroup, event_t _notifier, client_t _client); void request_debounce_timeout_cbk(boost::system::error_code const &_error); void send_request_services(std::set<service_data_t>& _requests); void send_unsubscribe_ack(service_t _service, instance_t _instance, - eventgroup_t _eventgroup, - pending_subscription_id_t _subscription_id); + eventgroup_t _eventgroup, remote_subscription_id_t _id); void resend_provided_event_registrations(); void send_resend_provided_event_response(pending_remote_offer_id_t _id); @@ -191,12 +194,15 @@ private: void send_update_security_policy_response(pending_security_update_id_t _update_id); void send_remove_security_policy_response(pending_security_update_id_t _update_id); void on_update_security_credentials(const byte_t *_data, uint32_t _size); + void on_client_assign_ack(const client_t &_client); private: enum class inner_state_type_e : std::uint8_t { ST_REGISTERED = 0x0, ST_DEREGISTERED = 0x1, - ST_REGISTERING = 0x2 + ST_REGISTERING = 0x2, + ST_ASSIGNING = 0x3, + ST_ASSIGNED = 0x4 }; std::atomic<bool> is_connected_; @@ -216,17 +222,18 @@ private: struct event_data_t { service_t service_; instance_t instance_; - event_t event_; - bool is_field_; + event_t notifier_; + event_type_e type_; + reliability_type_e reliability_; bool is_provided_; std::set<eventgroup_t> eventgroups_; bool operator<(const event_data_t &_other) const { - return std::tie(service_, instance_, event_, is_field_, - is_provided_, eventgroups_) - < std::tie(_other.service_, _other.instance_, _other.event_, - _other.is_field_, _other.is_provided_, - _other.eventgroups_); + return std::tie(service_, instance_, notifier_, + type_, reliability_, is_provided_, eventgroups_) + < std::tie(_other.service_, _other.instance_, + _other.notifier_, _other.type_, _other.reliability_, + _other.is_provided_, _other.eventgroups_); } }; std::set<event_data_t> pending_event_registrations_; @@ -255,6 +262,6 @@ private: const std::set<std::tuple<service_t, instance_t> > client_side_logging_filter_; }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_ROUTING_MANAGER_PROXY_HPP +#endif // VSOMEIP_V3_ROUTING_MANAGER_PROXY_HPP_ diff --git a/implementation/routing/include/routing_manager_stub.hpp b/implementation/routing/include/routing_manager_stub.hpp index d586518..4a37644 100644 --- a/implementation/routing/include/routing_manager_stub.hpp +++ b/implementation/routing/include/routing_manager_stub.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_ROUTING_MANAGER_STUB -#define VSOMEIP_ROUTING_MANAGER_STUB +#ifndef VSOMEIP_V3_ROUTING_MANAGER_STUB_ +#define VSOMEIP_V3_ROUTING_MANAGER_STUB_ #include <condition_variable> #include <list> @@ -20,54 +20,48 @@ #include <boost/asio/steady_timer.hpp> #include "../../endpoints/include/endpoint_host.hpp" -#include "../../configuration/include/internal.hpp" +#include "../include/routing_host.hpp" + #include "types.hpp" -namespace vsomeip { +namespace vsomeip_v3 { class configuration; class routing_manager_stub_host; -class routing_manager_stub: public endpoint_host, +class routing_manager_stub: public routing_host, public std::enable_shared_from_this<routing_manager_stub> { public: routing_manager_stub( routing_manager_stub_host *_host, - std::shared_ptr<configuration> _configuration); + const std::shared_ptr<configuration>& _configuration); virtual ~routing_manager_stub(); void init(); void start(); void stop(); - const std::shared_ptr<configuration> get_configuration() const; - - void on_connect(std::shared_ptr<endpoint> _endpoint); - void on_disconnect(std::shared_ptr<endpoint> _endpoint); void on_message(const byte_t *_data, length_t _size, endpoint *_receiver, const boost::asio::ip::address &_destination, client_t _bound_client, + credentials_t _credentials, const boost::asio::ip::address &_remote_address, std::uint16_t _remote_port); - void on_error(const byte_t *_data, length_t _length, endpoint *_receiver, - const boost::asio::ip::address &_remote_address, - std::uint16_t _remote_port); - void release_port(uint16_t _port, bool _reliable); void on_offer_service(client_t _client, service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor); void on_stop_offer_service(client_t _client, service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor); - bool send_subscribe(std::shared_ptr<vsomeip::endpoint> _target, + bool send_subscribe(const std::shared_ptr<endpoint>& _target, client_t _client, service_t _service, instance_t _instance, - eventgroup_t _eventgroup, major_version_t _major, - event_t _event, pending_subscription_id_t _subscription_id); + eventgroup_t _eventgroup, major_version_t _major, event_t _event, + remote_subscription_id_t _id); - bool send_unsubscribe(std::shared_ptr<vsomeip::endpoint> _target, + bool send_unsubscribe(const std::shared_ptr<endpoint>& _target, client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - event_t _event, pending_subscription_id_t _unsubscription_id); + event_t _event, remote_subscription_id_t _id); void send_subscribe_nack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event); @@ -86,14 +80,6 @@ public: void handle_credentials(const client_t _client, std::set<service_data_t>& _requests); void handle_requests(const client_t _client, std::set<service_data_t>& _requests); - void send_identify_request_command(std::shared_ptr<vsomeip::endpoint> _target, - service_t _service, instance_t _instance, major_version_t _major, - bool _reliable); - -#ifndef _WIN32 - virtual bool check_credentials(client_t _client, uid_t _uid, gid_t _gid); -#endif - void update_registration(client_t _client, registration_type_e _type); void print_endpoint_status() const; @@ -103,12 +89,12 @@ public: bool is_policy_cached(uint32_t _uid); - void policy_cache_add(uint32_t _uid, std::shared_ptr<payload> _payload); + void policy_cache_add(uint32_t _uid, const std::shared_ptr<payload>& _payload); void policy_cache_remove(uint32_t _uid); bool send_update_security_policy_request(client_t _client, pending_security_update_id_t _update_id, - uint32_t _uid, std::shared_ptr<payload> _payload); + uint32_t _uid, const std::shared_ptr<payload>& _payload); bool send_remove_security_policy_request(client_t _client, pending_security_update_id_t _update_id, uint32_t _uid, uint32_t _gid); @@ -131,7 +117,6 @@ private: void on_pong(client_t _client); void start_watchdog(); void check_watchdog(); - void send_application_lost(std::list<client_t> &_lost); void client_registration_func(void); void init_routing_endpoint(); @@ -175,8 +160,6 @@ private: std::set<client_t> used_client_ids_; std::mutex used_client_ids_mutex_; - std::string endpoint_path_; - std::string local_receiver_path_; std::shared_ptr<endpoint> endpoint_; std::shared_ptr<endpoint> local_receiver_; std::mutex local_receiver_mutex_; @@ -186,8 +169,6 @@ private: mutable std::mutex routing_info_mutex_; std::shared_ptr<configuration> configuration_; - size_t routingCommandSize_; - bool is_socket_activated_; std::atomic<bool> client_registration_running_; std::shared_ptr<std::thread> client_registration_thread_; @@ -215,7 +196,6 @@ private: }; -} // namespace vsomeip - -#endif // VSOMEIP_ROUTING_MANAGER_STUB +} // namespace vsomeip_v3 +#endif // VSOMEIP_V3_ROUTING_MANAGER_STUB_ diff --git a/implementation/routing/include/routing_manager_stub_host.hpp b/implementation/routing/include/routing_manager_stub_host.hpp index 5c474fb..b89134d 100644 --- a/implementation/routing/include/routing_manager_stub_host.hpp +++ b/implementation/routing/include/routing_manager_stub_host.hpp @@ -3,15 +3,17 @@ // 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_ROUTING_MANAGER_STUB_HOST -#define VSOMEIP_ROUTING_MANAGER_STUB_HOST +#ifndef VSOMEIP_V3_ROUTING_MANAGER_STUB_HOST_ +#define VSOMEIP_V3_ROUTING_MANAGER_STUB_HOST_ #include <boost/asio/io_service.hpp> #include <vsomeip/handler.hpp> #include "types.hpp" -namespace vsomeip { +namespace vsomeip_v3 { + +class endpoint_manager_impl; class routing_manager_stub_host { public: @@ -20,49 +22,52 @@ public: virtual bool offer_service(client_t _client, service_t _service, instance_t _instance, major_version_t _major, - minor_version_t _minor) = 0; + minor_version_t _minor, bool _must_queue = true) = 0; virtual void stop_offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, minor_version_t _minor) = 0; - - virtual void request_service(client_t _client, service_t _service, instance_t _instance, major_version_t _major, - minor_version_t _minor, bool _use_exclusive_proxy) = 0; + minor_version_t _minor, bool _must_queue = true) = 0; + + virtual void request_service(client_t _client, + service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor) = 0; - virtual void release_service(client_t _client, service_t _service, - instance_t _instance) = 0; + virtual void release_service(client_t _client, + service_t _service, instance_t _instance) = 0; - virtual void register_shadow_event(client_t _client, service_t _service, - instance_t _instance, event_t _event, + virtual void register_shadow_event(client_t _client, + service_t _service, instance_t _instance, + event_t _notifier, const std::set<eventgroup_t> &_eventgroups, - bool _is_field, bool _is_provided) = 0; + event_type_e _type, reliability_type_e _reliability, + bool _is_provided) = 0; virtual void unregister_shadow_event(client_t _client, service_t _service, instance_t _instance, event_t _event, bool _is_provided) = 0; - virtual void subscribe(client_t _client, service_t _service, + virtual void subscribe(client_t _client, uid_t _uid, gid_t _gid, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - major_version_t _major, event_t _event, - subscription_type_e _subscription_type) = 0; + major_version_t _major, event_t _event) = 0; virtual void on_subscribe_nack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, - pending_subscription_id_t _subscription_id) = 0; + remote_subscription_id_t _subscription_id) = 0; virtual void on_subscribe_ack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event, - pending_subscription_id_t _subscription_id) = 0; + remote_subscription_id_t _subscription_id) = 0; - virtual void unsubscribe(client_t _client, service_t _service, + virtual void unsubscribe(client_t _client, uid_t _uid, gid_t _gid, service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event) = 0; virtual void on_unsubscribe_ack(client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup, - pending_subscription_id_t _unsubscription_id) = 0; + remote_subscription_id_t _unsubscription_id) = 0; virtual bool on_message(service_t _service, instance_t _instance, const byte_t *_data, length_t _size, bool _reliable, client_t _bound_client, - bool _is_valid_crc = true, bool _is_from_remote = false) = 0; + credentials_t _credentials, + uint8_t _status_check = 0, bool _is_from_remote = false) = 0; virtual void on_notification(client_t _client, service_t _service, instance_t _instance, @@ -84,25 +89,24 @@ public: virtual boost::asio::io_service & get_io() = 0; virtual client_t get_client() const = 0; - virtual void on_identify_response(client_t _client, service_t _service, instance_t _instance, - bool _reliable) = 0; - virtual void on_pong(client_t _client) = 0; virtual void handle_client_error(client_t _client) = 0; - virtual void set_routing_state(routing_state_e _routing_state) = 0; + virtual std::shared_ptr<endpoint_manager_impl> get_endpoint_manager() const = 0; virtual void on_resend_provided_events_response(pending_remote_offer_id_t _id) = 0; virtual void on_security_update_response(pending_security_update_id_t _id, client_t _client) = 0; + virtual client_t find_local_client(service_t _service, instance_t _instance) = 0; + virtual std::set<client_t> find_local_clients(service_t _service, instance_t _instance) = 0; - virtual bool is_subscribe_to_any_event_allowed(client_t _client, + virtual bool is_subscribe_to_any_event_allowed(credentials_t _credentials, client_t _client, service_t _service, instance_t _instance, eventgroup_t _eventgroup) = 0; }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_ROUTING_MANAGER_STUB_HOST +#endif // VSOMEIP_V3_ROUTING_MANAGER_STUB_HOST_ diff --git a/implementation/routing/include/serviceinfo.hpp b/implementation/routing/include/serviceinfo.hpp index 72be585..a405cf0 100644 --- a/implementation/routing/include/serviceinfo.hpp +++ b/implementation/routing/include/serviceinfo.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_SERVICEINFO_HPP -#define VSOMEIP_SERVICEINFO_HPP +#ifndef VSOMEIP_V3_SERVICEINFO_HPP_ +#define VSOMEIP_V3_SERVICEINFO_HPP_ #include <memory> #include <set> @@ -15,14 +15,15 @@ #include <vsomeip/export.hpp> #include <vsomeip/primitive_types.hpp> -namespace vsomeip { +namespace vsomeip_v3 { class endpoint; class servicegroup; class serviceinfo { public: - VSOMEIP_EXPORT serviceinfo(major_version_t _major, minor_version_t _minor, + VSOMEIP_EXPORT serviceinfo(service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor, ttl_t _ttl, bool _is_local); VSOMEIP_EXPORT serviceinfo(const serviceinfo& _other); VSOMEIP_EXPORT ~serviceinfo(); @@ -30,6 +31,9 @@ public: VSOMEIP_EXPORT servicegroup * get_group() const; VSOMEIP_EXPORT void set_group(servicegroup *_group); + VSOMEIP_EXPORT service_t get_service() const; + VSOMEIP_EXPORT instance_t get_instance() const; + VSOMEIP_EXPORT major_version_t get_major() const; VSOMEIP_EXPORT minor_version_t get_minor() const; @@ -40,7 +44,7 @@ public: VSOMEIP_EXPORT void set_precise_ttl(std::chrono::milliseconds _precise_ttl); VSOMEIP_EXPORT std::shared_ptr<endpoint> get_endpoint(bool _reliable) const; - VSOMEIP_EXPORT void set_endpoint(std::shared_ptr<endpoint> _endpoint, + VSOMEIP_EXPORT void set_endpoint(const std::shared_ptr<endpoint>& _endpoint, bool _reliable); VSOMEIP_EXPORT void add_client(client_t _client); @@ -55,6 +59,9 @@ public: private: servicegroup *group_; + service_t service_; + instance_t instance_; + major_version_t major_; minor_version_t minor_; @@ -72,6 +79,6 @@ private: bool is_in_mainphase_; }; -} // namespace vsomeip +} // namespace vsomeip_v3 -#endif // VSOMEIP_SERVICEINFO_HPP +#endif // VSOMEIP_V3_SERVICEINFO_HPP_ diff --git a/implementation/routing/include/types.hpp b/implementation/routing/include/types.hpp index 59acfa3..389b226 100644 --- a/implementation/routing/include/types.hpp +++ b/implementation/routing/include/types.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_ROUTING_TYPES_HPP -#define VSOMEIP_ROUTING_TYPES_HPP +#ifndef VSOMEIP_V3_ROUTING_TYPES_HPP_ +#define VSOMEIP_V3_ROUTING_TYPES_HPP_ #include <map> #include <memory> @@ -13,10 +13,7 @@ #include <vsomeip/primitive_types.hpp> #include <vsomeip/constants.hpp> -#include "../../service_discovery/include/message_impl.hpp" -#include "../../configuration/include/internal.hpp" - -namespace vsomeip { +namespace vsomeip_v3 { class serviceinfo; class endpoint_definition; @@ -40,87 +37,20 @@ enum class registration_type_e : std::uint8_t { DEREGISTER_ON_ERROR = 0x3 }; -struct sd_message_identifier_t { - sd_message_identifier_t(session_t _session, - boost::asio::ip::address _sender, - boost::asio::ip::address _destination, - const std::shared_ptr<sd::message_impl> &_response) : - session_(_session), - sender_(_sender), - destination_(_destination), - response_(_response) { - } - - sd_message_identifier_t() : - session_(0), - sender_(boost::asio::ip::address()), - destination_(boost::asio::ip::address()), - response_(std::shared_ptr<sd::message_impl>()) { - } - - bool operator==(const sd_message_identifier_t &_other) const { - return !(session_ != _other.session_ || - sender_ != _other.sender_ || - destination_ != _other.destination_ || - response_ != _other.response_); - } - - bool operator<(const sd_message_identifier_t &_other) const { - return (session_ < _other.session_ - || (session_ == _other.session_ && sender_ < _other.sender_) - || (session_ == _other.session_ && sender_ == _other.sender_ - && destination_ < _other.destination_) - || (session_ == _other.session_ && sender_ == _other.sender_ - && destination_ == _other.destination_ - && response_ < _other.response_)); - } - - session_t session_; - boost::asio::ip::address sender_; - boost::asio::ip::address destination_; - std::shared_ptr<sd::message_impl> response_; -}; +enum class remote_subscription_state_e : std::uint8_t { + SUBSCRIPTION_PENDING = 0x00, -struct pending_subscription_t { - pending_subscription_t( - std::shared_ptr<sd_message_identifier_t> _sd_message_identifier, - std::shared_ptr<endpoint_definition> _subscriber, - std::shared_ptr<endpoint_definition> _target, - ttl_t _ttl, - client_t _subscribing_client) : - sd_message_identifier_(_sd_message_identifier), - subscriber_(_subscriber), - target_(_target), - ttl_(_ttl), - subscribing_client_(_subscribing_client), - pending_subscription_id_(DEFAULT_SUBSCRIPTION) { - } - pending_subscription_t () : - sd_message_identifier_(std::shared_ptr<sd_message_identifier_t>()), - subscriber_(std::shared_ptr<endpoint_definition>()), - target_(std::shared_ptr<endpoint_definition>()), - ttl_(0), - subscribing_client_(VSOMEIP_ROUTING_CLIENT), - pending_subscription_id_(DEFAULT_SUBSCRIPTION) { - } - std::shared_ptr<sd_message_identifier_t> sd_message_identifier_; - std::shared_ptr<endpoint_definition> subscriber_; - std::shared_ptr<endpoint_definition> target_; - ttl_t ttl_; - client_t subscribing_client_; - pending_subscription_id_t pending_subscription_id_; -}; + SUBSCRIPTION_ACKED = 0x01, + SUBSCRIPTION_NACKED = 0x02, -enum remote_subscription_state_e : std::uint8_t { - SUBSCRIPTION_ACKED, - SUBSCRIPTION_NACKED, - SUBSCRIPTION_PENDING, - SUBSCRIPTION_ERROR + SUBSCRIPTION_ERROR = 0x03, + SUBSCRIPTION_UNKNOWN = 0xFF }; +typedef std::uint16_t remote_subscription_id_t; typedef std::uint32_t pending_remote_offer_id_t; } -// namespace vsomeip +// namespace vsomeip_v3 -#endif // VSOMEIP_ROUTING_TYPES_HPP +#endif // VSOMEIP_V3_ROUTING_TYPES_HPP_ |