diff options
author | Juergen Gehring <juergen.gehring@bmw.de> | 2018-05-22 02:56:40 -0700 |
---|---|---|
committer | Juergen Gehring <juergen.gehring@bmw.de> | 2018-05-22 02:56:40 -0700 |
commit | 2f0fdc596d24621c2bd4223cc63c8c1fb5b4c2d8 (patch) | |
tree | 9bcfdaa7f58c4928b21964e00fdc995929032738 /implementation/routing/include | |
parent | 3f591262507bbce2a57e182ef8a1c40951a31018 (diff) | |
download | vSomeIP-2f0fdc596d24621c2bd4223cc63c8c1fb5b4c2d8.tar.gz |
vsomeip 2.10.112.10.11
Diffstat (limited to 'implementation/routing/include')
-rw-r--r-- | implementation/routing/include/event.hpp | 163 | ||||
-rw-r--r-- | implementation/routing/include/eventgroupinfo.hpp | 119 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager.hpp | 109 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_adapter.hpp | 24 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_base.hpp | 284 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_host.hpp | 47 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_impl.hpp | 469 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_proxy.hpp | 250 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_stub.hpp | 190 | ||||
-rw-r--r-- | implementation/routing/include/routing_manager_stub_host.hpp | 98 | ||||
-rw-r--r-- | implementation/routing/include/serviceinfo.hpp | 76 | ||||
-rw-r--r-- | implementation/routing/include/types.hpp | 124 |
12 files changed, 1953 insertions, 0 deletions
diff --git a/implementation/routing/include/event.hpp b/implementation/routing/include/event.hpp new file mode 100644 index 0000000..ac483ab --- /dev/null +++ b/implementation/routing/include/event.hpp @@ -0,0 +1,163 @@ +// 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_EVENT_IMPL_HPP +#define VSOMEIP_EVENT_IMPL_HPP + +#include <map> +#include <memory> +#include <mutex> +#include <set> +#include <atomic> + +#include <boost/asio/io_service.hpp> +#include <boost/asio/ip/address.hpp> +#include <boost/asio/steady_timer.hpp> + +#include <vsomeip/primitive_types.hpp> +#include <vsomeip/function_types.hpp> +#include <vsomeip/payload.hpp> + +namespace vsomeip { + +class endpoint; +class endpoint_definition; +class message; +class payload; +class routing_manager; + +class event: public std::enable_shared_from_this<event> { +public: + event(routing_manager *_routing, bool _is_shadow = false); + + service_t get_service() const; + void set_service(service_t _service); + + instance_t get_instance() const; + void set_instance(instance_t _instance); + + major_version_t get_version() const; + void set_version(major_version_t _major); + + event_t get_event() const; + void set_event(event_t _event); + + 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); + + void set_payload(const std::shared_ptr<payload> &_payload, + const std::shared_ptr<endpoint_definition> _target, + bool _force, bool _flush); + + bool set_payload_dont_notify(const std::shared_ptr<payload> &_payload); + + void set_payload(const std::shared_ptr<payload> &_payload, + bool _force, bool _flush); + void unset_payload(bool _force = false); + + bool is_field() const; + void set_field(bool _is_field); + + bool is_provided() const; + void set_provided(bool _is_provided); + + bool is_set() const; + + // SIP_RPC_357 + void set_update_cycle(std::chrono::milliseconds &_cycle); + void set_change_resets_cycle(bool _change_resets_cycle); + + // SIP_RPC_358 + void set_update_on_change(bool _is_on); + + // SIP_RPC_359 (epsilon change) + 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); + + bool add_subscriber(eventgroup_t _eventgroup, client_t _client); + void remove_subscriber(eventgroup_t _eventgroup, client_t _client); + bool has_subscriber(eventgroup_t _eventgroup, client_t _client); + std::set<client_t> get_subscribers(); + 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 is_shadow() const; + void set_shadow(bool _shadow); + + 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); + +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 start_cycle(); + void stop_cycle(); + + 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); + void reset_payload(const std::shared_ptr<payload> &_payload); + +private: + routing_manager *routing_; + mutable std::mutex mutex_; + std::shared_ptr<message> message_; + + std::atomic<bool> is_field_; + + boost::asio::steady_timer cycle_timer_; + std::chrono::milliseconds cycle_; + + std::atomic<bool> change_resets_cycle_; + std::atomic<bool> is_updating_on_change_; + + mutable std::mutex eventgroups_mutex_; + std::map<eventgroup_t, std::set<client_t>> eventgroups_; + + std::atomic<bool> is_set_; + std::atomic<bool> is_provided_; + + std::mutex refs_mutex_; + std::map<client_t, std::map<bool, uint32_t>> refs_; + + std::atomic<bool> is_shadow_; + std::atomic<bool> is_cache_placeholder_; + + epsilon_change_func_t epsilon_change_func_; + + std::atomic<bool> is_reliable_; + + std::atomic<bool> remote_notification_pending_; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_EVENT_IMPL_HPP diff --git a/implementation/routing/include/eventgroupinfo.hpp b/implementation/routing/include/eventgroupinfo.hpp new file mode 100644 index 0000000..8420fd3 --- /dev/null +++ b/implementation/routing/include/eventgroupinfo.hpp @@ -0,0 +1,119 @@ +// 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_EVENTGROUPINFO_HPP +#define VSOMEIP_EVENTGROUPINFO_HPP + +#include <chrono> +#include <list> +#include <memory> +#include <set> +#include <mutex> +#include <atomic> + +#include <boost/asio/ip/address.hpp> + +#include <vsomeip/export.hpp> +#include <vsomeip/primitive_types.hpp> + +#include "types.hpp" + +namespace vsomeip { + +class endpoint_definition; +class event; + +class eventgroupinfo { +public: + struct target_t { + std::shared_ptr<endpoint_definition> endpoint_; + std::chrono::steady_clock::time_point expiration_; + + bool operator==(const target_t &_other) const { + return (endpoint_ == _other.endpoint_); + } + }; + + VSOMEIP_EXPORT eventgroupinfo(); + VSOMEIP_EXPORT eventgroupinfo(major_version_t _major, ttl_t _ttl); + VSOMEIP_EXPORT ~eventgroupinfo(); + + VSOMEIP_EXPORT major_version_t get_major() const; + VSOMEIP_EXPORT void set_major(major_version_t _major); + + VSOMEIP_EXPORT ttl_t get_ttl() const; + VSOMEIP_EXPORT void set_ttl(ttl_t _ttl); + + VSOMEIP_EXPORT bool is_multicast() const; + VSOMEIP_EXPORT bool get_multicast(boost::asio::ip::address &_address, + uint16_t &_port) const; + VSOMEIP_EXPORT void set_multicast(const boost::asio::ip::address &_address, + uint16_t _port); + 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 uint8_t get_threshold() const; + VSOMEIP_EXPORT void set_threshold(uint8_t _threshold); + + VSOMEIP_EXPORT std::unique_lock<std::mutex> get_subscription_lock(); + + VSOMEIP_EXPORT pending_subscription_id_t add_pending_subscription( + pending_subscription_t _pending_subscription); + + VSOMEIP_EXPORT std::vector<pending_subscription_t> remove_pending_subscription( + pending_subscription_id_t _subscription_id); + + VSOMEIP_EXPORT void clear_pending_subscriptions(); +private: + std::atomic<major_version_t> major_; + std::atomic<ttl_t> ttl_; + + mutable std::mutex address_mutex_; + boost::asio::ip::address address_; + uint16_t port_; + + 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_; + + std::mutex pending_subscriptions_mutex_; + std::map<pending_subscription_id_t, pending_subscription_t> pending_subscriptions_; + std::map<std::pair<boost::asio::ip::address, std::uint16_t>, + std::vector<pending_subscription_id_t>> pending_subscriptions_by_remote_; + pending_subscription_id_t subscription_id_; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_EVENTGROUPINFO_HPP diff --git a/implementation/routing/include/routing_manager.hpp b/implementation/routing/include/routing_manager.hpp new file mode 100644 index 0000000..f02c533 --- /dev/null +++ b/implementation/routing/include/routing_manager.hpp @@ -0,0 +1,109 @@ +// 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_ROUTING_MANAGER +#define VSOMEIP_ROUTING_MANAGER + +#include <memory> +#include <set> +#include <vector> + +#include <boost/asio/io_service.hpp> + +#include <vsomeip/function_types.hpp> +#include <vsomeip/message.hpp> +#include <vsomeip/handler.hpp> + +namespace vsomeip { + +class endpoint; +class endpoint_definition; +class event; +class payload; + +class routing_manager { +public: + virtual ~routing_manager() { + } + + virtual boost::asio::io_service & get_io() = 0; + virtual client_t get_client() const = 0; + + virtual void init() = 0; + virtual void start() = 0; + virtual void stop() = 0; + + virtual bool offer_service(client_t _client, service_t _service, + instance_t _instance, major_version_t _major, + minor_version_t _minor) = 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; + + virtual void release_service(client_t _client, service_t _service, + instance_t _instance) = 0; + + 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) = 0; + + virtual void unsubscribe(client_t _client, 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, const byte_t *_data, uint32_t _size, + instance_t _instance, bool _flush, bool _reliable, bool _is_valid_crc = true) = 0; + + virtual bool send_to(const std::shared_ptr<endpoint_definition> &_target, + std::shared_ptr<message>, bool _flush) = 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, + 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) = 0; + + virtual void unregister_event(client_t _client, service_t _service, + instance_t _instance, event_t _event, bool _is_provided) = 0; + + virtual std::shared_ptr<event> find_event(service_t _service, + instance_t _instance, event_t _event) const = 0; + + virtual std::set<std::shared_ptr<event>> find_events(service_t _service, + instance_t _instance, eventgroup_t _eventgroup) const = 0; + + virtual void notify(service_t _service, instance_t _instance, + event_t _event, std::shared_ptr<payload> _payload, + bool _force, bool _flush) = 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) = 0; + + virtual void on_identify_response(client_t _client, service_t _service, + instance_t _instance, bool _reliable) = 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 + +#endif diff --git a/implementation/routing/include/routing_manager_adapter.hpp b/implementation/routing/include/routing_manager_adapter.hpp new file mode 100644 index 0000000..3d81120 --- /dev/null +++ b/implementation/routing/include/routing_manager_adapter.hpp @@ -0,0 +1,24 @@ +// 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_ROUTING_MANAGER_ADAPTER +#define VSOMEIP_ROUTING_MANAGER_ADAPTER + +namespace vsomeip { + +class routing_manager; + +class routing_manager_adapter { +public: + virtual ~routing_manager_adapter() { + } + + virtual routing_manager * get_manager() = 0; + virtual void process_command(const byte_t *_data, length_t _length) = 0; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_ROUTING_MANAGER_ADAPTER_HPP diff --git a/implementation/routing/include/routing_manager_base.hpp b/implementation/routing/include/routing_manager_base.hpp new file mode 100644 index 0000000..7bf3a4d --- /dev/null +++ b/implementation/routing/include/routing_manager_base.hpp @@ -0,0 +1,284 @@ +// 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_ROUTING_MANAGER_BASE +#define VSOMEIP_ROUTING_MANAGER_BASE + +#include <mutex> +#include <unordered_set> +#include <queue> +#include <condition_variable> + +#include <vsomeip/constants.hpp> +#include "routing_manager.hpp" +#include "routing_manager_host.hpp" +#include "types.hpp" +#include "serviceinfo.hpp" +#include "event.hpp" +#include "eventgroupinfo.hpp" +#include "../../message/include/serializer.hpp" +#include "../../message/include/deserializer.hpp" +#include "../../configuration/include/configuration.hpp" +#include "../../endpoints/include/endpoint_host.hpp" + +#ifdef USE_DLT +#include "../../tracing/include/trace_connector.hpp" +#endif + +#ifdef USE_DLT +namespace tc { +class trace_connector; +} // namespace tc +#endif + +namespace vsomeip { + +class serializer; + +class routing_manager_base : public routing_manager, + public endpoint_host, + public std::enable_shared_from_this<routing_manager_base>{ + +public: + routing_manager_base(routing_manager_host *_host); + virtual ~routing_manager_base(); + + virtual boost::asio::io_service & get_io(); + virtual client_t get_client() const; + + virtual void init(); + + 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 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 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, + 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); + + 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 unsubscribe(client_t _client, 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); + + 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); + + virtual bool send(client_t _client, std::shared_ptr<message> _message, + bool _flush); + + virtual bool send(client_t _client, const byte_t *_data, uint32_t _size, + instance_t _instance, bool _flush, bool _reliable, bool _is_valid_crc = true) = 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; + 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, + 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; + + virtual void send_get_offered_services_info(client_t _client, offer_type_e _offer_type) = 0; + +protected: + std::shared_ptr<serviceinfo> find_service(service_t _service, instance_t _instance) const; + 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); + + void clear_service_info(service_t _service, instance_t _instance, bool _reliable); + services_t get_services() 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); + void remove_local(client_t _client, + const std::set<std::tuple<service_t, instance_t, eventgroup_t>>& _subscribed_eventgroups); + + 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; + + void remove_eventgroup_info(service_t _service, instance_t _instance, + eventgroup_t _eventgroup); + + 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 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 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<deserializer> get_deserializer(); + void put_deserializer(std::shared_ptr<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; + + void remove_pending_subscription(service_t _service, instance_t _instance, + eventgroup_t _eventgroup, event_t _event); + + void send_pending_notify_ones(service_t _service, instance_t _instance, + eventgroup_t _eventgroup, client_t _client); + + void unset_all_eventpayloads(service_t _service, instance_t _instance); + void unset_all_eventpayloads(service_t _service, instance_t _instance, + eventgroup_t _eventgroup); + + void notify_one_current_value(client_t _client, service_t _service, + instance_t _instance, + 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); +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; + +protected: + routing_manager_host *host_; + boost::asio::io_service &io_; + client_t client_; + + std::shared_ptr<configuration> configuration_; + std::shared_ptr<serializer> serializer_; + std::mutex serialize_mutex_; + + 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_; + + // Eventgroups + mutable std::mutex eventgroups_mutex_; + std::map<service_t, + std::map<instance_t, + std::map<eventgroup_t, std::shared_ptr<eventgroupinfo> > > > eventgroups_; + // 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_; + +#ifdef USE_DLT + std::shared_ptr<tc::trace_connector> tc_; +#endif + + struct subscription_data_t { + service_t service_; + instance_t instance_; + eventgroup_t eventgroup_; + major_version_t major_; + event_t event_; + subscription_type_e subscription_type_; + + bool operator<(const subscription_data_t &_other) const { + return (service_ < _other.service_ + || (service_ == _other.service_ + && instance_ < _other.instance_) + || (service_ == _other.service_ + && instance_ == _other.instance_ + && eventgroup_ < _other.eventgroup_) + || (service_ == _other.service_ + && instance_ == _other.instance_ + && eventgroup_ == _other.eventgroup_ + && event_ < _other.event_)); + } + }; + std::set<subscription_data_t> pending_subscriptions_; + + services_t services_remote_; + std::mutex services_remote_mutex_; + +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_; + + std::map<service_t, + std::map<instance_t, + std::map<eventgroup_t, + std::shared_ptr<message> > > > pending_notify_ones_; + std::mutex pending_notify_ones_mutex_; +}; + +} // namespace vsomeip + +#endif //VSOMEIP_ROUTING_MANAGER_BASE diff --git a/implementation/routing/include/routing_manager_host.hpp b/implementation/routing/include/routing_manager_host.hpp new file mode 100644 index 0000000..c9f8841 --- /dev/null +++ b/implementation/routing/include/routing_manager_host.hpp @@ -0,0 +1,47 @@ +// 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_ROUTING_MANAGER_HOST +#define VSOMEIP_ROUTING_MANAGER_HOST + +#include <memory> + +#include <boost/asio/io_service.hpp> + +#include <vsomeip/error.hpp> + +namespace vsomeip { + +class configuration; +class message; + +class routing_manager_host { +public: + virtual ~routing_manager_host() { + } + + virtual client_t get_client() const = 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; + + 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_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; + 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 on_offered_services_info(std::vector<std::pair<service_t, instance_t>> &_services) = 0; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_ROUTING_MANAGER_HOST diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp new file mode 100644 index 0000000..2e90077 --- /dev/null +++ b/implementation/routing/include/routing_manager_impl.hpp @@ -0,0 +1,469 @@ +// 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_ROUTING_MANAGER_IMPL_HPP +#define VSOMEIP_ROUTING_MANAGER_IMPL_HPP + +#include <map> +#include <memory> +#include <mutex> +#include <vector> +#include <list> +#include <unordered_set> + +#include <boost/asio/ip/address.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/steady_timer.hpp> + +#include <vsomeip/primitive_types.hpp> +#include <vsomeip/handler.hpp> + +#include "routing_manager_base.hpp" +#include "routing_manager_stub_host.hpp" +#include "types.hpp" + +#include "../../endpoints/include/netlink_connector.hpp" +#include "../../service_discovery/include/service_discovery_host.hpp" + +namespace vsomeip { + +class configuration; +class deserializer; +class eventgroupinfo; +class routing_manager_host; +class routing_manager_stub; +class servicegroup; +class serializer; +class service_endpoint; + +namespace sd { +class service_discovery; +} // namespace sd + + +// TODO: encapsulate common parts of classes "routing_manager_impl" +// and "routing_manager_proxy" into a base class. + +class routing_manager_impl: public routing_manager_base, + public routing_manager_stub_host, + public sd::service_discovery_host { +public: + routing_manager_impl(routing_manager_host *_host); + ~routing_manager_impl(); + + 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); + + 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 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 unsubscribe(client_t _client, 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, const byte_t *_data, uint32_t _size, + instance_t _instance, bool _flush, bool _reliable, bool _is_valid_crc = true); + + bool send_to(const std::shared_ptr<endpoint_definition> &_target, + std::shared_ptr<message> _message, bool _flush); + + bool send_to(const std::shared_ptr<endpoint_definition> &_target, + const byte_t *_data, uint32_t _size, + instance_t _instance, bool _flush); + + bool send_to(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, + std::chrono::milliseconds _cycle, bool _change_resets_cycle, + 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, + const std::set<eventgroup_t> &_eventgroups, + bool _is_field, bool _is_provided); + + void unregister_shadow_event(client_t _client, service_t _service, + instance_t _instance, event_t _event, + bool _is_provided); + + void notify_one(service_t _service, instance_t _instance, + event_t _event, std::shared_ptr<payload> _payload, + client_t _client, bool _force, bool _flush); + + 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); + + 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); + + 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); + } + inline std::shared_ptr<endpoint> find_or_create_local( + client_t _client) { + return routing_manager_base::find_or_create_local(_client); + } + + void remove_local(client_t _client); + 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); + + void on_pong(client_t _client); + + 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); + void on_message(const byte_t *_data, length_t _length, endpoint *_receiver, + const boost::asio::ip::address &_destination, + client_t _bound_client, + 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, bool _is_valid_crc = true); + 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); + + // interface "service_discovery_host" + typedef std::map<std::string, std::shared_ptr<servicegroup> > servicegroups_t; + const servicegroups_t & get_servicegroups() const; + std::shared_ptr<eventgroupinfo> find_eventgroup(service_t _service, + instance_t _instance, eventgroup_t _eventgroup) const; + services_t get_offered_services() const; + std::shared_ptr<serviceinfo> get_offered_service( + service_t _service, instance_t _instance) const; + std::map<instance_t, std::shared_ptr<serviceinfo>> get_offered_service_instances( + service_t _service) const; + + std::shared_ptr<endpoint> create_service_discovery_endpoint(const std::string &_address, + uint16_t _port, bool _reliable); + void init_routing_info(); + void add_routing_info(service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor, ttl_t _ttl, + const boost::asio::ip::address &_reliable_address, + uint16_t _reliable_port, + const boost::asio::ip::address &_unreliable_address, + uint16_t _unreliable_port); + void del_routing_info(service_t _service, instance_t _instance, + 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); + + 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 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); + + void set_routing_state(routing_state_e _routing_state); + + void send_get_offered_services_info(client_t _client, offer_type_e _offer_type) { + (void) _client; + (void) _offer_type; + } + + void send_initial_events(service_t _service, instance_t _instance, + eventgroup_t _eventgroup, + const std::shared_ptr<endpoint_definition> &_subscriber); + +private: + bool deliver_message(const byte_t *_data, length_t _length, + instance_t _instance, bool _reliable, bool _is_valid_crc = true); + bool deliver_notification(service_t _service, instance_t _instance, + const byte_t *_data, length_t _length, bool _reliable, bool _is_valid_crc = true); + + 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; + + std::shared_ptr<endpoint> find_remote_client(service_t _service, + instance_t _instance, bool _reliable, client_t _client); + + 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); +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); + + void on_net_interface_or_route_state_changed(bool _is_interface, + std::string _if, + bool _available); + + void start_ip_routing(); + + void requested_service_add(client_t _client, service_t _service, + instance_t _instance, major_version_t _major, + minor_version_t _minor); + void requested_service_remove(client_t _client, service_t _service, + instance_t _instance); + + void call_sd_endpoint_connected(const boost::system::error_code& _error, + service_t _service, instance_t _instance, + std::shared_ptr<endpoint> _endpoint, + std::shared_ptr<boost::asio::steady_timer> _timer); + + bool create_placeholder_event_and_subscribe(service_t _service, + instance_t _instance, + eventgroup_t _eventgroup, + event_t _event, + client_t _client); + + 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_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); + + + + 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_; + + // Multicast endpoint info (notifications) + std::map<service_t, std::map<instance_t, std::shared_ptr<endpoint_definition> > > multicast_info; + + // 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_; + + 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::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_; + + bool if_state_running_; + bool sd_route_set_; + bool routing_running_; + std::mutex pending_sd_offers_mutex_; + std::vector<std::pair<service_t, instance_t>> pending_sd_offers_; +#ifndef _WIN32 + 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 + // 2nd client id in tuple: client id of previously/stored offering application + std::map<service_t, + std::map<instance_t, + std::tuple<major_version_t, minor_version_t, + client_t, client_t>>> pending_offers_; + + std::mutex pending_subscription_mutex_; + + std::mutex remote_subscription_state_mutex_; + std::map<std::tuple<service_t, instance_t, eventgroup_t, client_t>, + subscription_state_e> remote_subscription_state_; + + std::map<e2exf::data_identifier, std::shared_ptr<e2e::profile_interface::protector>> custom_protectors; + std::map<e2exf::data_identifier, std::shared_ptr<e2e::profile_interface::checker>> custom_checkers; + + std::mutex status_log_timer_mutex_; + boost::asio::steady_timer status_log_timer_; + + std::mutex memory_log_timer_mutex_; + boost::asio::steady_timer memory_log_timer_; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_ROUTING_MANAGER_IMPL_HPP diff --git a/implementation/routing/include/routing_manager_proxy.hpp b/implementation/routing/include/routing_manager_proxy.hpp new file mode 100644 index 0000000..a9f0762 --- /dev/null +++ b/implementation/routing/include/routing_manager_proxy.hpp @@ -0,0 +1,250 @@ +// 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_ROUTING_MANAGER_PROXY_HPP +#define VSOMEIP_ROUTING_MANAGER_PROXY_HPP + +#include <map> +#include <mutex> +#include <atomic> +#include <tuple> + +#include <boost/asio/io_service.hpp> +#include <boost/asio/steady_timer.hpp> + +#include "routing_manager_base.hpp" +#include "types.hpp" +#include <vsomeip/enumeration_types.hpp> +#include <vsomeip/handler.hpp> + +namespace vsomeip { + +class configuration; +class event; +class routing_manager_host; + +class logger; + +class routing_manager_proxy: public routing_manager_base { +public: + routing_manager_proxy(routing_manager_host *_host, bool _client_side_logging, + const std::set<std::tuple<service_t, instance_t> > & _client_side_logging_filter); + virtual ~routing_manager_proxy(); + + void init(); + void start(); + void stop(); + + 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); + + 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 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 unsubscribe(client_t _client, 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 = true, bool _reliable = false, bool _is_valid_crc= true); + + bool send_to(const std::shared_ptr<endpoint_definition> &_target, + std::shared_ptr<message> _message, bool _flush); + + bool send_to(const std::shared_ptr<endpoint_definition> &_target, + const byte_t *_data, uint32_t _size, instance_t _instance, bool _flush); + + void register_event(client_t _client, service_t _service, + instance_t _instance, event_t _event, + const std::set<eventgroup_t> &_eventgroups, bool _is_field, + std::chrono::milliseconds _cycle, bool _change_resets_cycle, + 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); + + 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 _length, endpoint *_receiver, + const boost::asio::ip::address &_destination, + client_t _bound_client, + 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); + + void on_offered_services_info(const byte_t *_data, uint32_t _size); + + void send_get_offered_services_info(client_t _client, offer_type_e _offer_type); + +private: + void register_application(); + void deregister_application(); + + void reconnect(const std::unordered_set<client_t> &_clients); + + void send_pong() const; + 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, + const std::set<eventgroup_t> &_eventgroup, + bool _is_field, 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); + + 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); + + 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); + + bool is_field(service_t _service, instance_t _instance, + event_t _event) const; + + void on_subscribe_nack(client_t _client, service_t _service, + instance_t _instance, eventgroup_t _eventgroup, event_t _event); + + void on_subscribe_ack(client_t _client, service_t _service, + instance_t _instance, eventgroup_t _eventgroup, event_t _event); + + void cache_event_payload(const std::shared_ptr<message> &_message); + + void on_stop_offer_service(service_t _service, instance_t _instance, + major_version_t _major, minor_version_t _minor); + + void send_pending_commands(); + + void init_receiver(); + + void notify_remote_initially(service_t _service, instance_t _instance, + eventgroup_t _eventgroup, const std::set<event_t> &_events_to_exclude); + + uint32_t get_remote_subscriber_count(service_t _service, instance_t _instance, + eventgroup_t _eventgroup, bool _increment); + + void register_application_timeout_cbk(boost::system::error_code const &_error); + + void send_registered_ack(); + + void set_routing_state(routing_state_e _routing_state) { + (void)_routing_state; + }; + + 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); + + 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); + +private: + enum class inner_state_type_e : std::uint8_t { + ST_REGISTERED = 0x0, + ST_DEREGISTERED = 0x1, + ST_REGISTERING = 0x2 + }; + + bool is_connected_; + std::atomic<bool> is_started_; + inner_state_type_e state_; + + std::shared_ptr<endpoint> sender_; // --> stub + std::shared_ptr<endpoint> receiver_; // --> from everybody + + std::mutex known_clients_mutex_; + std::unordered_set<client_t> known_clients_; + + std::set<service_data_t> pending_offers_; + std::set<service_data_t> requests_; + std::set<service_data_t> requests_to_debounce_; + + struct event_data_t { + service_t service_; + instance_t instance_; + event_t event_; + bool is_field_; + 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_); + } + }; + std::set<event_data_t> pending_event_registrations_; + + std::map<client_t, std::set<subscription_data_t>> pending_incoming_subscripitons_; + std::recursive_mutex incoming_subscriptions_mutex_; + + std::mutex state_mutex_; + std::condition_variable state_condition_; + + std::map<service_t, + std::map<instance_t, std::map<eventgroup_t, uint32_t > > > remote_subscriber_count_; + std::mutex remote_subscriber_count_mutex_; + + mutable std::mutex sender_mutex_; + + boost::asio::steady_timer register_application_timer_; + + std::shared_ptr<logger> logger_; + + std::mutex request_timer_mutex_; + boost::asio::steady_timer request_debounce_timer_; + bool request_debounce_timer_running_; + + const bool client_side_logging_; + const std::set<std::tuple<service_t, instance_t> > client_side_logging_filter_; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_ROUTING_MANAGER_PROXY_HPP diff --git a/implementation/routing/include/routing_manager_stub.hpp b/implementation/routing/include/routing_manager_stub.hpp new file mode 100644 index 0000000..3e97a5f --- /dev/null +++ b/implementation/routing/include/routing_manager_stub.hpp @@ -0,0 +1,190 @@ +// 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_ROUTING_MANAGER_STUB +#define VSOMEIP_ROUTING_MANAGER_STUB + +#include <condition_variable> +#include <list> +#include <map> +#include <memory> +#include <mutex> +#include <set> +#include <thread> +#include <atomic> + +#include <boost/asio/io_service.hpp> +#include <boost/asio/steady_timer.hpp> + +#include "../../endpoints/include/endpoint_host.hpp" +#include "../../configuration/include/internal.hpp" +#include "types.hpp" + +namespace vsomeip { + +class configuration; +class routing_manager_stub_host; + +class routing_manager_stub: public endpoint_host, + public std::enable_shared_from_this<routing_manager_stub> { +public: + routing_manager_stub( + routing_manager_stub_host *_host, + 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 _length, endpoint *_receiver, + const boost::asio::ip::address &_destination, + client_t _bound_client, + 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); + + void send_subscribe(std::shared_ptr<vsomeip::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); + + void send_unsubscribe(std::shared_ptr<vsomeip::endpoint> _target, + client_t _client, service_t _service, + instance_t _instance, eventgroup_t _eventgroup, + event_t _event, pending_subscription_id_t _unsubscription_id); + + void send_subscribe_nack(client_t _client, service_t _service, + instance_t _instance, eventgroup_t _eventgroup, event_t _event); + + void send_subscribe_ack(client_t _client, service_t _service, + instance_t _instance, eventgroup_t _eventgroup, event_t _event); + + bool contained_in_routing_info(client_t _client, service_t _service, + instance_t _instance, major_version_t _major, + minor_version_t _minor) const; + + void create_local_receiver(); + bool send_ping(client_t _client); + bool is_registered(client_t _client) const; + client_t get_client() const; + 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; +private: + void broadcast(const std::vector<byte_t> &_command) const; + + void on_register_application(client_t _client); + void on_deregister_application(client_t _client); + + void inform_requesters(client_t _hoster, service_t _service, + instance_t _instance, major_version_t _major, + minor_version_t _minor, routing_info_entry_e _entry, + bool _inform_service); + + void broadcast_ping() const; + 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(); + void on_ping_timer_expired(boost::system::error_code const &_error); + void remove_from_pinged_clients(client_t _client); + void set_routing_state(routing_state_e _routing_state) { + (void)_routing_state; + }; + + bool is_already_connected(client_t _source, client_t _sink); + void create_client_routing_info(const client_t _target); + void insert_client_routing_info(client_t _target, routing_info_entry_e _entry, + client_t _client, service_t _service = ANY_SERVICE, + instance_t _instance = ANY_INSTANCE, + major_version_t _major = ANY_MAJOR, + minor_version_t _minor = ANY_MINOR); + void send_client_routing_info(const client_t _target); + + void create_offered_services_info(const client_t _target); + void insert_offered_services_info(client_t _target, + routing_info_entry_e _entry, + service_t _service, + instance_t _instance, + major_version_t _major, + minor_version_t _minor); + void send_offered_services_info(const client_t _target); + + void on_client_id_timer_expired(boost::system::error_code const &_error); + +private: + routing_manager_stub_host *host_; + boost::asio::io_service &io_; + std::mutex watchdog_timer_mutex_; + boost::asio::steady_timer watchdog_timer_; + + boost::asio::steady_timer client_id_timer_; + 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_; + + std::map<client_t, + std::pair<uint8_t, std::map<service_t, std::map<instance_t, std::pair<major_version_t, minor_version_t>> > > > routing_info_; + 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_; + std::mutex client_registration_mutex_; + std::condition_variable client_registration_condition_; + + std::map<client_t, std::vector<registration_type_e>> pending_client_registrations_; + const std::uint32_t max_local_message_size_; + static const std::vector<byte_t> its_ping_; + const std::chrono::milliseconds configured_watchdog_timeout_; + boost::asio::steady_timer pinged_clients_timer_; + std::mutex pinged_clients_mutex_; + std::map<client_t, boost::asio::steady_timer::time_point> pinged_clients_; + + std::map<client_t, std::map<service_t, std::map<instance_t, std::pair<major_version_t, minor_version_t> > > > service_requests_; + std::map<client_t, std::set<client_t>> connection_matrix_; + + std::map<client_t, std::vector<byte_t>> client_routing_info_; + std::map<client_t, std::vector<byte_t>> offered_services_info_; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_ROUTING_MANAGER_STUB + diff --git a/implementation/routing/include/routing_manager_stub_host.hpp b/implementation/routing/include/routing_manager_stub_host.hpp new file mode 100644 index 0000000..a6d461e --- /dev/null +++ b/implementation/routing/include/routing_manager_stub_host.hpp @@ -0,0 +1,98 @@ +// 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_ROUTING_MANAGER_STUB_HOST +#define VSOMEIP_ROUTING_MANAGER_STUB_HOST + +#include <boost/asio/io_service.hpp> +#include <vsomeip/handler.hpp> + +#include "types.hpp" + +namespace vsomeip { + +class routing_manager_stub_host { +public: + virtual ~routing_manager_stub_host() { + } + + virtual bool offer_service(client_t _client, service_t _service, + instance_t _instance, major_version_t _major, + minor_version_t _minor) = 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; + + 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, + const std::set<eventgroup_t> &_eventgroups, + bool _is_field, 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, + instance_t _instance, eventgroup_t _eventgroup, + major_version_t _major, event_t _event, + subscription_type_e _subscription_type) = 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; + + 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; + + virtual void unsubscribe(client_t _client, 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; + + virtual bool on_message(service_t _service, instance_t _instance, + const byte_t *_data, length_t _size, bool _reliable, bool _is_valid_crc = true) = 0; + + virtual void on_notification(client_t _client, + service_t _service, instance_t _instance, + const byte_t *_data, length_t _size, bool _notify_one = false) = 0; + + virtual void on_stop_offer_service(client_t _client, service_t _service, + instance_t _instance, major_version_t _major, + minor_version_t _minor) = 0; + + virtual void on_availability(service_t _service, instance_t _instance, + bool _is_available, major_version_t _major, minor_version_t _minor) = 0; + + virtual std::shared_ptr<endpoint> find_local(client_t _client) = 0; + + virtual std::shared_ptr<endpoint> find_or_create_local( + client_t _client) = 0; + virtual void remove_local(client_t _client) = 0; + + 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; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_ROUTING_MANAGER_STUB_HOST diff --git a/implementation/routing/include/serviceinfo.hpp b/implementation/routing/include/serviceinfo.hpp new file mode 100644 index 0000000..7eab1ec --- /dev/null +++ b/implementation/routing/include/serviceinfo.hpp @@ -0,0 +1,76 @@ +// 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_SERVICEINFO_HPP +#define VSOMEIP_SERVICEINFO_HPP + +#include <memory> +#include <set> +#include <string> +#include <chrono> +#include <mutex> + +#include <vsomeip/export.hpp> +#include <vsomeip/primitive_types.hpp> + +namespace vsomeip { + +class endpoint; +class servicegroup; + +class serviceinfo { +public: + VSOMEIP_EXPORT serviceinfo(major_version_t _major, minor_version_t _minor, + ttl_t _ttl, bool _is_local); + VSOMEIP_EXPORT ~serviceinfo(); + + VSOMEIP_EXPORT servicegroup * get_group() const; + VSOMEIP_EXPORT void set_group(servicegroup *_group); + + VSOMEIP_EXPORT major_version_t get_major() const; + VSOMEIP_EXPORT minor_version_t get_minor() const; + + VSOMEIP_EXPORT ttl_t get_ttl() const; + VSOMEIP_EXPORT void set_ttl(ttl_t _ttl); + + VSOMEIP_EXPORT std::chrono::milliseconds get_precise_ttl() const; + VSOMEIP_EXPORT void set_precise_ttl(std::chrono::milliseconds _ttl); + + VSOMEIP_EXPORT std::shared_ptr<endpoint> get_endpoint(bool _reliable) const; + VSOMEIP_EXPORT void set_endpoint(std::shared_ptr<endpoint> _endpoint, + bool _reliable); + + VSOMEIP_EXPORT void add_client(client_t _client); + VSOMEIP_EXPORT void remove_client(client_t _client); + VSOMEIP_EXPORT uint32_t get_requesters_size(); + + VSOMEIP_EXPORT bool is_local() const; + + VSOMEIP_EXPORT bool is_in_mainphase() const; + VSOMEIP_EXPORT void set_is_in_mainphase(bool _in_mainphase); + +private: + servicegroup *group_; + + major_version_t major_; + minor_version_t minor_; + + mutable std::mutex ttl_mutex_; + std::chrono::milliseconds ttl_; + + std::shared_ptr<endpoint> reliable_; + std::shared_ptr<endpoint> unreliable_; + + mutable std::mutex endpoint_mutex_; + std::mutex requesters_mutex_; + std::set<client_t> requesters_; + + bool is_local_; + bool is_in_mainphase_; +}; + +} // namespace vsomeip + +#endif // VSOMEIP_SERVICEINFO_HPP diff --git a/implementation/routing/include/types.hpp b/implementation/routing/include/types.hpp new file mode 100644 index 0000000..f33a944 --- /dev/null +++ b/implementation/routing/include/types.hpp @@ -0,0 +1,124 @@ +// 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_ROUTING_TYPES_HPP +#define VSOMEIP_ROUTING_TYPES_HPP + +#include <map> +#include <memory> +#include <boost/asio/ip/address.hpp> + +#include <vsomeip/primitive_types.hpp> +#include <vsomeip/constants.hpp> + +#include "../../service_discovery/include/message_impl.hpp" +#include "../../configuration/include/internal.hpp" + +namespace vsomeip { + +class serviceinfo; +class endpoint_definition; + + +typedef std::map<service_t, + std::map<instance_t, + std::shared_ptr<serviceinfo> > > services_t; + +class eventgroupinfo; + +typedef std::map<service_t, + std::map<instance_t, + std::map<eventgroup_t, + std::shared_ptr< + eventgroupinfo> > > > eventgroups_t; + +enum class registration_type_e : std::uint8_t { + REGISTER = 0x1, + DEREGISTER = 0x2, + 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_; +}; + +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_; +}; + +enum remote_subscription_state_e : std::uint8_t { + SUBSCRIPTION_ACKED, + SUBSCRIPTION_NACKED, + SUBSCRIPTION_PENDING, + SUBSCRIPTION_ERROR +}; + +} +// namespace vsomeip + +#endif // VSOMEIP_ROUTING_TYPES_HPP |