diff --git a/implementation/compat/runtime/include/application_impl.hpp b/implementation/compat/runtime/include/application_impl.hpp index 8c3b4e0d5..14d4ebe59 100644 --- a/implementation/compat/runtime/include/application_impl.hpp +++ b/implementation/compat/runtime/include/application_impl.hpp @@ -33,41 +33,41 @@ class application_impl void start(); void stop(); - void offer_service(service_t _service, instance_t _instance, + void offer_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); - void stop_offer_service(service_t _service, instance_t _instance, + void stop_offer_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); - void offer_event(service_t _service, instance_t _instance, event_t _event, + void offer_event(service_t _service, unique_version_t _unique, event_t _event, const std::set &_eventgroups, bool _is_field); - void stop_offer_event(service_t _service, instance_t _instance, + void stop_offer_event(service_t _service, unique_version_t _unique, event_t _event); - void request_service(service_t _service, instance_t _instance, + void request_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, bool _use_exclusive_proxy); - void release_service(service_t _service, instance_t _instance); + void release_service(service_t _service, unique_version_t _unique); - void request_event(service_t _service, instance_t _instance, + void request_event(service_t _service, unique_version_t _unique, event_t _event, const std::set &_eventgroups, bool _is_field); - void release_event(service_t _service, instance_t _instance, + void release_event(service_t _service, unique_version_t _unique, event_t _event); - void subscribe(service_t _service, instance_t _instance, + void subscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, subscription_type_e _subscription_type, event_t _event); - void unsubscribe(service_t _service, instance_t _instance, + void unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup); - bool is_available(service_t _service, instance_t _instance, + bool is_available(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) const; void send(std::shared_ptr _message, bool _flush); - void notify(service_t _service, instance_t _instance, + void notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload) const; - void notify_one(service_t _service, instance_t _instance, + void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client) const; @@ -75,10 +75,10 @@ class application_impl void unregister_state_handler(); void register_message_handler(service_t _service, - instance_t _instance, method_t _method, + unique_version_t _unique, method_t _method, message_handler_t _handler); void unregister_message_handler(service_t _service, - instance_t _instance, method_t _method); + unique_version_t _unique, method_t _method); void register_availability_handler(service_t _service, instance_t _instance, availability_handler_t _handler, @@ -88,60 +88,60 @@ class application_impl major_version_t _major, minor_version_t _minor); void register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, subscription_handler_t _handler); void unregister_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup); + unique_version_t _unique, eventgroup_t _eventgroup); void register_subscription_error_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, error_handler_t _handler); void unregister_subscription_error_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup); + unique_version_t _unique, eventgroup_t _eventgroup); void clear_all_handler(); bool is_routing() const; void offer_event(service_t _service, - instance_t _instance, event_t _event, + unique_version_t _unique, event_t _event, const std::set &_eventgroups, bool _is_field, std::chrono::milliseconds _cycle, bool _change_resets_cycle, const epsilon_change_func_t &_epsilon_change_func); - void notify(service_t _service, instance_t _instance, + void notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force) const; - void notify_one(service_t _service, instance_t _instance, + void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force) const; bool are_available(available_t &_available, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) const; - void notify(service_t _service, instance_t _instance, + void notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force, bool _flush) const; - void notify_one(service_t _service, instance_t _instance, + void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force, bool _flush) const; void set_routing_state(routing_state_e _routing_state); - void unsubscribe(service_t _service, instance_t _instance, + void unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); void register_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, subscription_status_handler_t _handler); void register_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, subscription_status_handler_t _handler, bool _is_selective); void get_offered_services_async( @@ -151,7 +151,7 @@ class application_impl watchdog_handler_t _handler, std::chrono::seconds _interval); virtual void register_async_subscription_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, async_subscription_handler_t _handler); virtual void set_offer_acceptance_required( @@ -172,7 +172,7 @@ class application_impl routing_state_handler_t _handler); virtual bool update_service_configuration( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled, bool _offer); @@ -186,14 +186,14 @@ class application_impl private: bool is_selective_event( - vsomeip::service_t _service, vsomeip::instance_t _instance, + vsomeip::service_t _service, vsomeip::unique_version_t _unique, const std::set &_eventgroups); private: std::shared_ptr impl_; std::map > > eventgroups_; + std::map > > eventgroups_; std::mutex eventgroups_mutex_; }; diff --git a/implementation/compat/runtime/src/application_impl.cpp b/implementation/compat/runtime/src/application_impl.cpp index f1934e446..b6f811027 100644 --- a/implementation/compat/runtime/src/application_impl.cpp +++ b/implementation/compat/runtime/src/application_impl.cpp @@ -68,21 +68,21 @@ application_impl::stop() { } void -application_impl::offer_service(service_t _service, instance_t _instance, +application_impl::offer_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { - impl_->offer_service(_service, _instance, _major, _minor); + impl_->offer_service(_service, _unique, _major, _minor); } void -application_impl::stop_offer_service(service_t _service, instance_t _instance, +application_impl::stop_offer_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { - impl_->stop_offer_service(_service, _instance, _major, _minor); + impl_->stop_offer_service(_service, _unique, _major, _minor); } void -application_impl::offer_event(service_t _service, instance_t _instance, +application_impl::offer_event(service_t _service, unique_version_t _unique, event_t _event, const std::set &_eventgroups, bool _is_field) { @@ -96,76 +96,76 @@ application_impl::offer_event(service_t _service, instance_t _instance, // Note: The check can be done on the eventgroup(s) as selective // events own an exclusive eventgroup. const bool is_selective - = is_selective_event(_service, _instance, _eventgroups); + = is_selective_event(_service, _unique, _eventgroups); if (is_selective) its_type = vsomeip_v3::event_type_e::ET_SELECTIVE_EVENT; } - impl_->offer_event(_service, _instance, _event, _eventgroups, its_type); + impl_->offer_event(_service, _unique, _event, _eventgroups, its_type); } void -application_impl::stop_offer_event(service_t _service, instance_t _instance, +application_impl::stop_offer_event(service_t _service, unique_version_t _unique, event_t _event) { - impl_->stop_offer_event(_service, _instance, _event); + impl_->stop_offer_event(_service, _unique, _event); } void -application_impl::request_service(service_t _service, instance_t _instance, +application_impl::request_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, bool _use_exclusive_proxy) { (void)_use_exclusive_proxy; - impl_->request_service(_service, _instance, _major, _minor); + impl_->request_service(_service, _unique, _major, _minor); } void -application_impl::release_service(service_t _service, instance_t _instance) { +application_impl::release_service(service_t _service, unique_version_t _unique) { - impl_->release_service(_service, _instance); + impl_->release_service(_service, _unique); } void -application_impl::request_event(service_t _service, instance_t _instance, +application_impl::request_event(service_t _service, unique_version_t _unique, event_t _event, const std::set &_eventgroups, bool _is_field) { const vsomeip_v3::event_type_e its_type = (_is_field) ? vsomeip_v3::event_type_e::ET_FIELD : vsomeip_v3::event_type_e::ET_EVENT; - impl_->request_event(_service, _instance, _event, _eventgroups, its_type); + impl_->request_event(_service, _unique, _event, _eventgroups, its_type); } void -application_impl::release_event(service_t _service, instance_t _instance, +application_impl::release_event(service_t _service, unique_version_t _unique, event_t _event) { - impl_->release_event(_service, _instance, _event); + impl_->release_event(_service, _unique, _event); } void -application_impl::subscribe(service_t _service, instance_t _instance, +application_impl::subscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, subscription_type_e _subscription_type, event_t _event) { (void)_subscription_type; // unused in v3 - impl_->subscribe(_service, _instance, _eventgroup, _major, _event); + impl_->subscribe(_service, _unique, _eventgroup, _major, _event); } void -application_impl::unsubscribe(service_t _service, instance_t _instance, +application_impl::unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) { - impl_->unsubscribe(_service, _instance, _eventgroup); + impl_->unsubscribe(_service, _unique, _eventgroup); } bool -application_impl::is_available(service_t _service, instance_t _instance, +application_impl::is_available(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) const { - return impl_->is_available(_service, _instance, _major, _minor); + return impl_->is_available(_service, _unique, _major, _minor); } void @@ -179,27 +179,27 @@ application_impl::send(std::shared_ptr _message, bool _flush = true) { } void -application_impl::notify(service_t _service, instance_t _instance, +application_impl::notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload) const { if (_payload) { auto its_payload = std::dynamic_pointer_cast(_payload); - impl_->notify(_service, _instance, _event, its_payload->get_impl()); + impl_->notify(_service, _unique, _event, its_payload->get_impl()); } else { - impl_->notify(_service, _instance, _event, nullptr); + impl_->notify(_service, _unique, _event, nullptr); } } void -application_impl::notify_one(service_t _service, instance_t _instance, +application_impl::notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client) const { if (_payload) { auto its_payload = std::dynamic_pointer_cast(_payload); - impl_->notify_one(_service, _instance, _event, its_payload->get_impl(), _client); + impl_->notify_one(_service, _unique, _event, its_payload->get_impl(), _client); } else { - impl_->notify_one(_service, _instance, _event, nullptr, _client); + impl_->notify_one(_service, _unique, _event, nullptr, _client); } } @@ -221,10 +221,10 @@ application_impl::unregister_state_handler() { void application_impl::register_message_handler( - service_t _service, instance_t _instance, method_t _method, + service_t _service, unique_version_t _unique, method_t _method, message_handler_t _handler) { - impl_->register_message_handler(_service, _instance, _method, + impl_->register_message_handler(_service, _unique, _method, [_handler](const std::shared_ptr &_message) { auto its_message = std::make_shared(_message); _handler(its_message); @@ -234,9 +234,9 @@ application_impl::register_message_handler( void application_impl::unregister_message_handler( - service_t _service, instance_t _instance, method_t _method) { + service_t _service, unique_version_t _unique, method_t _method) { - impl_->unregister_message_handler(_service, _instance, _method); + impl_->unregister_message_handler(_service, _unique, _method); } void @@ -259,14 +259,14 @@ application_impl::unregister_availability_handler( void application_impl::register_subscription_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, subscription_handler_t _handler) { { std::lock_guard its_lock(eventgroups_mutex_); - eventgroups_[_service][_instance].insert(_eventgroup); + eventgroups_[_service][_unique].insert(_eventgroup); } - impl_->register_subscription_handler(_service, _instance, _eventgroup, + impl_->register_subscription_handler(_service, _unique, _eventgroup, [_handler](client_t _client, vsomeip::uid_t _uid, vsomeip::gid_t _gid, bool _accepted){ (void)_uid; @@ -278,9 +278,9 @@ application_impl::register_subscription_handler( void application_impl::unregister_subscription_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup) { + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) { - impl_->unregister_subscription_handler(_service, _instance, _eventgroup); + impl_->unregister_subscription_handler(_service, _unique, _eventgroup); } @@ -291,16 +291,16 @@ application_impl::unregister_subscription_handler( void application_impl::register_subscription_error_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, error_handler_t _handler) { impl_->register_subscription_status_handler( - _service, _instance, _eventgroup, ERROR_HANDLER_DUMMY_EVENT, - [_handler](service_t _service, instance_t _instance, + _service, _unique, _eventgroup, ERROR_HANDLER_DUMMY_EVENT, + [_handler](service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, uint16_t _error) { (void)_service; - (void)_instance; + (void)_unique; (void)_eventgroup; (void)_event; @@ -312,9 +312,9 @@ application_impl::register_subscription_error_handler( void application_impl::unregister_subscription_error_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup) { + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) { - impl_->unregister_subscription_status_handler(_service, _instance, + impl_->unregister_subscription_status_handler(_service, _unique, _eventgroup, ERROR_HANDLER_DUMMY_EVENT); } @@ -332,7 +332,7 @@ application_impl::is_routing() const { void application_impl::offer_event( - service_t _service, instance_t _instance, event_t _event, + service_t _service, unique_version_t _unique, event_t _event, const std::set &_eventgroups, bool _is_field, std::chrono::milliseconds _cycle, @@ -349,13 +349,13 @@ application_impl::offer_event( // Note: The check can be done on the eventgroup(s) as selective // events own an exclusive eventgroup. const bool is_selective - = is_selective_event(_service, _instance, _eventgroups); + = is_selective_event(_service, _unique, _eventgroups); if (is_selective) its_type = vsomeip_v3::event_type_e::ET_SELECTIVE_EVENT; } - impl_->offer_event(_service, _instance, _event, _eventgroups, + impl_->offer_event(_service, _unique, _event, _eventgroups, its_type, _cycle, _change_resets_cycle, true, [_epsilon_change_func]( const std::shared_ptr &_lhs, @@ -368,44 +368,44 @@ application_impl::offer_event( } void -application_impl::notify(service_t _service, instance_t _instance, +application_impl::notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force) const { if (_payload) { auto its_payload = std::dynamic_pointer_cast(_payload); - impl_->notify(_service, _instance, _event, its_payload->get_impl(), + impl_->notify(_service, _unique, _event, its_payload->get_impl(), _force); } else { - impl_->notify(_service, _instance, _event, nullptr, _force); + impl_->notify(_service, _unique, _event, nullptr, _force); } } void -application_impl::notify_one(service_t _service, instance_t _instance, +application_impl::notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force) const { if (_payload) { auto its_payload = std::dynamic_pointer_cast(_payload); - impl_->notify_one(_service, _instance, _event, its_payload->get_impl(), + impl_->notify_one(_service, _unique, _event, its_payload->get_impl(), _client, _force); } else { - impl_->notify_one(_service, _instance, _event, nullptr, _client, + impl_->notify_one(_service, _unique, _event, nullptr, _client, _force); } } bool application_impl::are_available(available_t &_available, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) const { - return impl_->are_available(_available, _service, _instance, _major, + return impl_->are_available(_available, _service, _unique, _major, _minor); } void -application_impl::notify(service_t _service, instance_t _instance, +application_impl::notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force, bool _flush) const { @@ -413,15 +413,15 @@ application_impl::notify(service_t _service, instance_t _instance, if (_payload) { auto its_payload = std::dynamic_pointer_cast(_payload); - impl_->notify(_service, _instance, _event, its_payload->get_impl(), + impl_->notify(_service, _unique, _event, its_payload->get_impl(), _force); } else { - impl_->notify(_service, _instance, _event, nullptr, _force); + impl_->notify(_service, _unique, _event, nullptr, _force); } } void -application_impl::notify_one(service_t _service, instance_t _instance, +application_impl::notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force, bool _flush) const { @@ -429,10 +429,10 @@ application_impl::notify_one(service_t _service, instance_t _instance, if (_payload) { auto its_payload = std::dynamic_pointer_cast(_payload); - impl_->notify_one(_service, _instance, _event, its_payload->get_impl(), + impl_->notify_one(_service, _unique, _event, its_payload->get_impl(), _client, _force); } else { - impl_->notify_one(_service, _instance, _event, nullptr, _client, + impl_->notify_one(_service, _unique, _event, nullptr, _client, _force); } } @@ -445,24 +445,24 @@ application_impl::set_routing_state(routing_state_e _routing_state) { } void -application_impl::unsubscribe(service_t _service, instance_t _instance, +application_impl::unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { - impl_->unsubscribe(_service, _instance, _eventgroup, _event); + impl_->unsubscribe(_service, _unique, _eventgroup, _event); } void application_impl::register_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, subscription_status_handler_t _handler) { - register_subscription_status_handler(_service, _instance, + register_subscription_status_handler(_service, _unique, _eventgroup, _event, _handler, false); } void application_impl::register_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, subscription_status_handler_t _handler, bool _is_selective) { if (_is_selective) { std::set its_eventgroups; @@ -473,20 +473,20 @@ application_impl::register_subscription_status_handler(service_t _service, // whether an event is selective, the call to "register_event" does // not. Therefore, we re-register the event with correct event type // here. - impl_->request_event(_service, _instance, _event, its_eventgroups, + impl_->request_event(_service, _unique, _event, its_eventgroups, vsomeip_v3::event_type_e::ET_SELECTIVE_EVENT); } - impl_->register_subscription_status_handler(_service, _instance, + impl_->register_subscription_status_handler(_service, _unique, _eventgroup, _event, [_handler](const vsomeip_v3::service_t _service, - const vsomeip_v3::instance_t _instance, + const vsomeip_v3::unique_version_t _unique, const vsomeip_v3::eventgroup_t _eventgroup, const vsomeip_v3::event_t _event, const uint16_t _error) { if (_handler) - _handler(_service, _instance, _eventgroup, _event, _error); + _handler(_service, _unique, _eventgroup, _event, _error); }, _is_selective); } @@ -508,14 +508,14 @@ application_impl::set_watchdog_handler( void application_impl::register_async_subscription_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, async_subscription_handler_t _handler) { { std::lock_guard its_lock(eventgroups_mutex_); - eventgroups_[_service][_instance].insert(_eventgroup); + eventgroups_[_service][_unique].insert(_eventgroup); } - impl_->register_async_subscription_handler(_service, _instance, + impl_->register_async_subscription_handler(_service, _unique, _eventgroup, [_handler](client_t _client, vsomeip::uid_t _uid, vsomeip::gid_t _gid, bool _accepted, std::function _handler2) { @@ -581,12 +581,12 @@ application_impl::register_routing_state_handler( bool application_impl::update_service_configuration( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled, bool _offer) { (void)_service; - (void)_instance; + (void)_unique; (void)_port; (void)_reliable; (void)_magic_cookies_enabled; @@ -628,7 +628,7 @@ application_impl::remove_security_policy_configuration( bool application_impl::is_selective_event( - vsomeip::service_t _service, vsomeip::instance_t _instance, + vsomeip::service_t _service, vsomeip::unique_version_t _unique, const std::set &_eventgroups) { bool is_selective(false); @@ -636,11 +636,11 @@ application_impl::is_selective_event( std::lock_guard its_events_lock(eventgroups_mutex_); const auto its_service = eventgroups_.find(_service); if (its_service != eventgroups_.end()) { - const auto its_instance = its_service->second.find(_instance); - if (its_instance != its_service->second.end()) { + const auto its_unique = its_service->second.find(_unique); + if (its_unique != its_service->second.end()) { for (const auto eg : _eventgroups) { - const auto its_egrp = its_instance->second.find(eg); - if (its_egrp != its_instance->second.end()) { + const auto its_egrp = its_unique->second.find(eg); + if (its_egrp != its_unique->second.end()) { is_selective = true; break; } diff --git a/implementation/configuration/include/client.hpp b/implementation/configuration/include/client.hpp index 5c0805dda..aa8675c0e 100644 --- a/implementation/configuration/include/client.hpp +++ b/implementation/configuration/include/client.hpp @@ -17,12 +17,12 @@ namespace cfg { struct client { client() : service_(ANY_SERVICE), - instance_(ANY_INSTANCE) { + unique_(ANY_INSTANCE) { } // ports for specific service / instance service_t service_; - instance_t instance_; + unique_version_t unique_; std::map > ports_; std::map last_used_specific_client_port_; diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index dc445b4c2..9383818cb 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -58,12 +58,12 @@ class configuration { virtual bool lazy_load_security(const std::string &_client_host) = 0; #endif // !VSOMEIP_DISABLE_SECURITY virtual bool remote_offer_info_add(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled) = 0; virtual bool remote_offer_info_remove(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled, @@ -99,13 +99,13 @@ class configuration { virtual routing_state_e get_initial_routing_state() const = 0; virtual std::string get_unicast_address(service_t _service, - instance_t _instance) const = 0; + unique_version_t _unique) const = 0; virtual uint16_t get_reliable_port(service_t _service, - instance_t _instance) const = 0; + unique_version_t _unique) const = 0; virtual bool has_enabled_magic_cookies(const std::string &_address, uint16_t _port) const = 0; virtual uint16_t get_unreliable_port(service_t _service, - instance_t _instance) const = 0; + unique_version_t _unique) const = 0; virtual void get_configured_timing_requests( service_t _service, const std::string &_ip_target, @@ -118,22 +118,22 @@ class configuration { std::chrono::nanoseconds *_debounce_time, std::chrono::nanoseconds *_max_retention_time) const = 0; - virtual bool is_someip(service_t _service, instance_t _instance) const = 0; + virtual bool is_someip(service_t _service, unique_version_t _unique) const = 0; - virtual bool get_client_port(service_t _service, instance_t _instance, + virtual bool get_client_port(service_t _service, unique_version_t _unique, uint16_t _remote_port, bool _reliable, std::map > &_used_client_ports, uint16_t &_client_port) const = 0; - virtual std::set > get_remote_services() const = 0; + virtual std::set > get_remote_services() const = 0; - virtual bool get_multicast(service_t _service, instance_t _instance, + virtual bool get_multicast(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, std::string &_address, uint16_t &_port) const = 0; - virtual uint8_t get_threshold(service_t _service, instance_t _instance, + virtual uint8_t get_threshold(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) const = 0; virtual void get_event_update_properties( - service_t _service, instance_t _instance, event_t _event, + service_t _service, unique_version_t _unique, event_t _event, std::chrono::milliseconds &_cycle, bool &_change_resets_cycle, bool &_update_on_change_) const = 0; @@ -156,14 +156,14 @@ class configuration { virtual bool supports_selective_broadcasts(const boost::asio::ip::address &_address) const = 0; - virtual bool is_offered_remote(service_t _service, instance_t _instance) const = 0; + virtual bool is_offered_remote(service_t _service, unique_version_t _unique) const = 0; - virtual bool is_local_service(service_t _service, instance_t _instance) const = 0; + virtual bool is_local_service(service_t _service, unique_version_t _unique) const = 0; virtual reliability_type_e get_event_reliability( - service_t _service, instance_t _instance, event_t _event) const = 0; + service_t _service, unique_version_t _unique, event_t _event) const = 0; virtual reliability_type_e get_service_reliability( - service_t _service, instance_t _instance) const = 0; + service_t _service, unique_version_t _unique) const = 0; // Service Discovery configuration virtual bool is_sd_enabled() const = 0; @@ -218,14 +218,14 @@ class configuration { // TTL factor typedef std::uint32_t ttl_factor_t; - typedef std::map> ttl_map_t; + typedef std::map> ttl_map_t; virtual ttl_map_t get_ttl_factor_offers() const = 0; virtual ttl_map_t get_ttl_factor_subscribes() const = 0; // Debouncing virtual std::shared_ptr get_debounce( const std::string &_name, - service_t _service, instance_t _instance, event_t _event) const = 0; + service_t _service, unique_version_t _unique, event_t _event) const = 0; // Queue size limit endpoints typedef std::uint32_t endpoint_queue_limit_t; @@ -269,7 +269,7 @@ class configuration { virtual void set_sd_acceptance_rules_active( const boost::asio::ip::address& _address, bool _enable) = 0; - virtual bool is_secure_service(service_t _service, instance_t _instance) const = 0; + virtual bool is_secure_service(service_t _service, unique_version_t _unique) const = 0; virtual int get_udp_receive_buffer_size() const = 0; @@ -277,17 +277,17 @@ class configuration { const vsomeip_sec_client_t *_sec_client) const = 0; virtual bool check_suppress_events(service_t _service, - instance_t _instance, event_t _event) const = 0; + unique_version_t _unique, event_t _event) const = 0; // SOME/IP-TP virtual bool is_tp_client( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, method_t _method) const = 0; virtual bool is_tp_service( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, method_t _method) const = 0; virtual void get_tp_configuration( - service_t _service, instance_t _instance, method_t _method, bool _is_client, + service_t _service, unique_version_t _unique, method_t _method, bool _is_client, std::uint16_t &_max_segment_length, std::uint32_t &_separation_time) const = 0; // routing shutdown timeout @@ -301,7 +301,7 @@ class configuration { virtual uint8_t get_max_remote_subscribers() const = 0; virtual partition_id_t get_partition_id( - service_t _service, instance_t _instance) const = 0; + service_t _service, unique_version_t _unique) const = 0; virtual reliability_type_e get_reliability_type( const boost::asio::ip::address &_reliable_address, diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index da8cf2e74..4348766ad 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -40,15 +40,15 @@ struct watchdog; struct suppress_t { service_t service; - instance_t instance; + unique_version_t unique; event_t event; inline bool operator<(const suppress_t& entry_) const { if(service != entry_.service) { return service < entry_.service; } - if(instance != entry_.instance) { - return instance < entry_.instance; + if(unique != entry_.unique) { + return unique < entry_.unique; } if(event != entry_.event) { return event < entry_.event; @@ -70,12 +70,12 @@ class configuration_impl: VSOMEIP_EXPORT bool lazy_load_security(const std::string &_client_host); #endif // !VSOMEIP_DISABLE_SECURITY VSOMEIP_EXPORT bool remote_offer_info_add(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled); VSOMEIP_EXPORT bool remote_offer_info_remove(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled, @@ -100,12 +100,12 @@ class configuration_impl: VSOMEIP_EXPORT const std::string & get_logfile() const; VSOMEIP_EXPORT vsomeip_v3::logger::level_e get_loglevel() const; - VSOMEIP_EXPORT std::string get_unicast_address(service_t _service, instance_t _instance) const; + VSOMEIP_EXPORT std::string get_unicast_address(service_t _service, unique_version_t _unique) const; - VSOMEIP_EXPORT uint16_t get_reliable_port(service_t _service, instance_t _instance) const; + VSOMEIP_EXPORT uint16_t get_reliable_port(service_t _service, unique_version_t _unique) const; VSOMEIP_EXPORT bool has_enabled_magic_cookies(const std::string &_address, uint16_t _port) const; VSOMEIP_EXPORT uint16_t get_unreliable_port(service_t _service, - instance_t _instance) const; + unique_version_t _unique) const; VSOMEIP_EXPORT void get_configured_timing_requests( service_t _service, const std::string &_ip_target, @@ -118,9 +118,9 @@ class configuration_impl: std::chrono::nanoseconds *_debounce_time, std::chrono::nanoseconds *_max_retention_time) const; - VSOMEIP_EXPORT bool is_someip(service_t _service, instance_t _instance) const; + VSOMEIP_EXPORT bool is_someip(service_t _service, unique_version_t _unique) const; - VSOMEIP_EXPORT bool get_client_port(service_t _service, instance_t _instance, + VSOMEIP_EXPORT bool get_client_port(service_t _service, unique_version_t _unique, uint16_t _remote_port, bool _reliable, std::map > &_used_client_ports, uint16_t &_client_port) const; @@ -147,16 +147,16 @@ class configuration_impl: VSOMEIP_EXPORT std::size_t get_request_debouncing(const std::string &_name) const; VSOMEIP_EXPORT bool has_session_handling(const std::string &_name) const; - VSOMEIP_EXPORT std::set > get_remote_services() const; + VSOMEIP_EXPORT std::set > get_remote_services() const; - VSOMEIP_EXPORT bool get_multicast(service_t _service, instance_t _instance, + VSOMEIP_EXPORT bool get_multicast(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, std::string &_address, uint16_t &_port) const; - VSOMEIP_EXPORT uint8_t get_threshold(service_t _service, instance_t _instance, + VSOMEIP_EXPORT uint8_t get_threshold(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) const; VSOMEIP_EXPORT void get_event_update_properties( - service_t _service, instance_t _instance, event_t _event, + service_t _service, unique_version_t _unique, event_t _event, std::chrono::milliseconds &_cycle, bool &_change_resets_cycle, bool &_update_on_change_) const; @@ -168,18 +168,18 @@ class configuration_impl: VSOMEIP_EXPORT bool supports_selective_broadcasts(const boost::asio::ip::address &_address) const; - VSOMEIP_EXPORT bool is_offered_remote(service_t _service, instance_t _instance) const; + VSOMEIP_EXPORT bool is_offered_remote(service_t _service, unique_version_t _unique) const; VSOMEIP_EXPORT bool log_version() const; VSOMEIP_EXPORT uint32_t get_log_version_interval() const; - VSOMEIP_EXPORT bool is_local_service(service_t _service, instance_t _instance) const; + VSOMEIP_EXPORT bool is_local_service(service_t _service, unique_version_t _unique) const; VSOMEIP_EXPORT reliability_type_e get_event_reliability( - service_t _service, instance_t _instance, event_t _event) const; + service_t _service, unique_version_t _unique, event_t _event) const; VSOMEIP_EXPORT reliability_type_e get_service_reliability( - service_t _service, instance_t _instance) const; + service_t _service, unique_version_t _unique) const; // Service Discovery configuration VSOMEIP_EXPORT bool is_sd_enabled() const; @@ -211,7 +211,7 @@ class configuration_impl: const vsomeip_sec_client_t *_sec_client) const; VSOMEIP_EXPORT bool check_suppress_events(service_t _service, - instance_t _instance, event_t _event) const; + unique_version_t _unique, event_t _event) const; VSOMEIP_EXPORT std::map> get_plugins( const std::string &_name) const; @@ -230,7 +230,7 @@ class configuration_impl: VSOMEIP_EXPORT std::shared_ptr get_debounce( const std::string &_name, - service_t _service, instance_t _instance, event_t _event) const; + service_t _service, unique_version_t _unique, event_t _event) const; VSOMEIP_EXPORT endpoint_queue_limit_t get_endpoint_queue_limit( const std::string& _address, std::uint16_t _port) const; @@ -258,18 +258,18 @@ class configuration_impl: VSOMEIP_EXPORT void set_sd_acceptance_rules_active( const boost::asio::ip::address& _address, bool _enable); - VSOMEIP_EXPORT bool is_secure_service(service_t _service, instance_t _instance) const; + VSOMEIP_EXPORT bool is_secure_service(service_t _service, unique_version_t _unique) const; VSOMEIP_EXPORT int get_udp_receive_buffer_size() const; VSOMEIP_EXPORT bool is_tp_client( service_t _service, - instance_t _instance, + unique_version_t _unique, method_t _method) const; VSOMEIP_EXPORT bool is_tp_service( - service_t _service, instance_t _instance, method_t _method) const; + service_t _service, unique_version_t _unique, method_t _method) const; VSOMEIP_EXPORT void get_tp_configuration( - service_t _service, instance_t _instance, method_t _method, bool _is_client, + service_t _service, unique_version_t _unique, method_t _method, bool _is_client, std::uint16_t &_max_segment_length, std::uint32_t &_separation_time) const; VSOMEIP_EXPORT std::uint32_t get_shutdown_timeout() const; @@ -282,7 +282,7 @@ class configuration_impl: VSOMEIP_EXPORT uint8_t get_max_remote_subscribers() const; VSOMEIP_EXPORT partition_id_t get_partition_id( - service_t _service, instance_t _instance) const; + service_t _service, unique_version_t _unique) const; VSOMEIP_EXPORT std::map get_additional_data( const std::string &_application_name, @@ -357,7 +357,7 @@ class configuration_impl: std::shared_ptr &_filter); void load_trace_filter_match( const boost::property_tree::ptree &_data, - std::tuple &_match); + std::tuple &_match); void load_suppress_events(const configuration_element &_element); void load_suppress_events_data( @@ -368,7 +368,7 @@ class configuration_impl: std::set load_range_events(event_t _first_event, event_t _last_event) const ; void insert_suppress_events(service_t _service, - instance_t _instance, event_t _event); + unique_version_t _unique, event_t _event); void print_suppress_events(void) const; void load_network(const configuration_element &_element); @@ -435,17 +435,17 @@ class configuration_impl: servicegroup *find_servicegroup(const std::string &_name) const; std::shared_ptr find_client(service_t _service, - instance_t _instance) const; - std::shared_ptr find_service(service_t _service, instance_t _instance) const; - std::shared_ptr find_service_unlocked(service_t _service, instance_t _instance) const; + unique_version_t _unique) const; + std::shared_ptr find_service(service_t _service, unique_version_t _unique) const; + std::shared_ptr find_service_unlocked(service_t _service, unique_version_t _unique) const; std::shared_ptr find_service(service_t _service, const std::string &_address, std::uint16_t _port) const; std::shared_ptr find_eventgroup(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) const; + unique_version_t _unique, eventgroup_t _eventgroup) const; bool find_port(uint16_t &_port, uint16_t _remote, bool _reliable, std::map > &_used_client_ports) const; bool find_specific_port(uint16_t &_port, service_t _service, - instance_t _instance, bool _reliable, + unique_version_t _unique, bool _reliable, std::map > &_used_client_ports) const; void set_magic_cookies_unicast_address(); @@ -510,7 +510,7 @@ class configuration_impl: mutable std::mutex services_mutex_; std::map > > services_; std::map > secure_services_; + std::map > secure_services_; bool log_statistics_; uint32_t statistics_interval_; @@ -666,7 +666,7 @@ class configuration_impl: mutable std::mutex partitions_mutex_; std::map > partitions_; diff --git a/implementation/configuration/include/debounce_filter_impl.hpp b/implementation/configuration/include/debounce_filter_impl.hpp index 80696af83..517751dc3 100644 --- a/implementation/configuration/include/debounce_filter_impl.hpp +++ b/implementation/configuration/include/debounce_filter_impl.hpp @@ -27,7 +27,7 @@ struct debounce_filter_impl_t : debounce_filter_t { using debounce_configuration_t = std::map>>>; diff --git a/implementation/configuration/include/service.hpp b/implementation/configuration/include/service.hpp index 982e52486..4ae9b44c5 100644 --- a/implementation/configuration/include/service.hpp +++ b/implementation/configuration/include/service.hpp @@ -18,7 +18,7 @@ struct eventgroup; struct service { service_t service_; - instance_t instance_; + unique_version_t unique_; std::string unicast_address_; diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 21c708b60..792f5ca3b 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -379,7 +379,7 @@ configuration_impl::check_routing_credentials( } bool configuration_impl::remote_offer_info_add(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled) { @@ -390,7 +390,7 @@ bool configuration_impl::remote_offer_info_add(service_t _service, } else { auto its_service = std::make_shared(); its_service->service_ = _service; - its_service->instance_ = _instance; + its_service->unique_ = _unique; its_service->reliable_ = its_service->unreliable_ = ILLEGAL_PORT; _reliable ? its_service->reliable_ = _port : @@ -405,25 +405,25 @@ bool configuration_impl::remote_offer_info_add(service_t _service, bool updated(false); auto found_service = services_.find(its_service->service_); if (found_service != services_.end()) { - auto found_instance = found_service->second.find(its_service->instance_); - if (found_instance != found_service->second.end()) { + auto found_unique = found_service->second.find(its_service->unique_); + if (found_unique != found_service->second.end()) { VSOMEIP_INFO << "Updating remote configuration for service [" << std::hex << std::setfill('0') << std::setw(4) - << its_service->service_ << "." << its_service->instance_ << "]"; + << its_service->service_ << "." << its_service->unique_ << "]"; if (_reliable) { - found_instance->second->reliable_ = its_service->reliable_; + found_unique->second->reliable_ = its_service->reliable_; } else { - found_instance->second->unreliable_ = its_service->unreliable_; + found_unique->second->unreliable_ = its_service->unreliable_; } updated = true; } } if (!updated) { - services_[_service][_instance] = its_service; + services_[_service][_unique] = its_service; VSOMEIP_INFO << "Added new remote configuration for service [" << std::hex << std::setfill('0') << std::setw(4) << its_service->service_ << "." - << std::setw(4) << its_service->instance_ << "]"; + << std::setw(4) << its_service->unique_ << "]"; } if (_magic_cookies_enabled) { magic_cookies_[its_service->unicast_address_].insert(its_service->reliable_); @@ -435,7 +435,7 @@ bool configuration_impl::remote_offer_info_add(service_t _service, } bool configuration_impl::remote_offer_info_remove(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled, @@ -450,21 +450,21 @@ bool configuration_impl::remote_offer_info_remove(service_t _service, std::lock_guard its_lock(services_mutex_); auto found_service = services_.find(_service); if (found_service != services_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { VSOMEIP_INFO << "Removing remote configuration for service [" << std::hex << std::setfill('0') << std::setw(4) - << _service << "." << _instance << "]"; + << _service << "." << get_instance_from_unique(_unique) << "]"; if (_reliable) { - found_instance->second->reliable_ = ILLEGAL_PORT; + found_unique->second->reliable_ = ILLEGAL_PORT; // TODO delete from magic_cookies_map without overwriting // configurations from other services offered on the same port } else { - found_instance->second->unreliable_ = ILLEGAL_PORT; + found_unique->second->unreliable_ = ILLEGAL_PORT; } *_still_offered_remote = ( - found_instance->second->unreliable_ != ILLEGAL_PORT || - found_instance->second->reliable_ != ILLEGAL_PORT); + found_unique->second->unreliable_ != ILLEGAL_PORT || + found_unique->second->reliable_ != ILLEGAL_PORT); ret = true; } } @@ -1342,6 +1342,15 @@ void configuration_impl::load_trace_filter_match( } its_converter >> its_instance; std::get<1>(_match) = its_instance; + } else if (i->first == "major") { + major_version_t its_major(DEFAULT_MAJOR); + if (its_value.find("0x") == 0) { + its_converter << std::hex << its_value; + } else { + its_converter << std::dec << its_value; + } + its_converter >> its_major; + std::get<1>(_match) = get_unique_version(static_cast(std::get<1>(_match)), its_major); } else if (i->first == "method") { method_t its_method(ANY_METHOD); if (its_value.find("0x") == 0) { @@ -1384,6 +1393,8 @@ void configuration_impl::load_suppress_events_data( //Default everything to ANY, and change with the provided values service_t its_service(ANY_SERVICE); instance_t its_instance(ANY_INSTANCE); + unique_version_t its_unique(ANY_INSTANCE); + major_version_t its_major(DEFAULT_MAJOR); event_t its_event(ANY_EVENT); std::set events; @@ -1396,6 +1407,8 @@ void configuration_impl::load_suppress_events_data( its_service = load_suppress_data(its_value); } else if (its_key == "instance") { its_instance = load_suppress_data(its_value); + } else if (its_key == "major") { + its_major = static_cast(load_suppress_data(its_value)); } else if (its_key == "events") { if (i->second.empty()) { //Single Event its_event = load_suppress_data(its_value); @@ -1406,12 +1419,14 @@ void configuration_impl::load_suppress_events_data( } } + its_unique = get_unique_version(its_instance, its_major); + //If no event is present in the configuration, use ANY_EVENT! if(events.empty()) events.insert(ANY_EVENT); for(const auto& event : events) { - insert_suppress_events(its_service, its_instance, event); + insert_suppress_events(its_service, its_unique, event); } } @@ -1487,25 +1502,25 @@ std::set configuration_impl::load_range_events(event_t _first_event, } void configuration_impl::insert_suppress_events(service_t _service, - instance_t _instance, event_t _event) { + unique_version_t _unique, event_t _event) { - suppress_t new_event = {_service, _instance, _event}; + suppress_t new_event = {_service, _unique, _event}; suppress_events_.insert(new_event); } -bool configuration_impl::check_suppress_events(service_t _service, instance_t _instance, +bool configuration_impl::check_suppress_events(service_t _service, unique_version_t _unique, event_t _event) const { if (!is_suppress_events_enabled_) return false; std::set event_combinations = { - {_service, _instance, _event}, - {_service, _instance, ANY_EVENT}, + {_service, _unique, _event}, + {_service, _unique, ANY_EVENT}, {_service, ANY_INSTANCE, _event}, {_service, ANY_INSTANCE, ANY_EVENT}, - {ANY_SERVICE, _instance, _event}, - {ANY_SERVICE, _instance, ANY_EVENT}, + {ANY_SERVICE, _unique, _event}, + {ANY_SERVICE, _unique, ANY_EVENT}, {ANY_SERVICE, ANY_INSTANCE, _event} }; @@ -1524,7 +1539,7 @@ void configuration_impl::print_suppress_events(void) const { for (const auto& its_log : suppress_events_) { VSOMEIP_INFO << std::hex << std::setfill('0') << "+[" << std::setw(4) << its_log.service - << "." << std::setw(4) << its_log.instance + << "." << std::setw(4) << its_log.unique << "." << its_log.event << "]"; } } @@ -2004,6 +2019,7 @@ void configuration_impl::load_service( its_service->multicast_address_ = ""; its_service->multicast_port_ = ILLEGAL_PORT; its_service->protocol_ = "someip"; + major_version_t its_major(DEFAULT_MAJOR); for (auto i = _tree.begin(); i != _tree.end(); ++i) { std::string its_key(i->first); @@ -2067,25 +2083,29 @@ void configuration_impl::load_service( if (its_key == "service") { its_converter >> its_service->service_; } else if (its_key == "instance") { - its_converter >> its_service->instance_; + its_converter >> its_service->unique_; + } else if (its_key == "major") { + its_converter >> its_major; } } } + its_service->unique_ = get_unique_version(static_cast(its_service->unique_), its_major); + auto found_service = services_.find(its_service->service_); if (found_service != services_.end()) { - auto found_instance = found_service->second.find( - its_service->instance_); - if (found_instance != found_service->second.end()) { + auto found_unique = found_service->second.find( + its_service->unique_); + if (found_unique != found_service->second.end()) { VSOMEIP_WARNING << "Multiple configurations for service [" << std::hex << its_service->service_ << "." - << its_service->instance_ << "]"; + << get_instance_from_unique(its_service->unique_) << "]"; is_loaded = false; } } if (is_loaded) { - services_[its_service->service_][its_service->instance_] = + services_[its_service->service_][its_service->unique_] = its_service; if (use_magic_cookies) { magic_cookies_[its_service->unicast_address_].insert(its_service->reliable_); @@ -2177,7 +2197,7 @@ void configuration_impl::load_event( if (found_event != _service->events_.end()) { VSOMEIP_INFO << "Multiple configurations for event [" << std::hex << _service->service_ << "." - << _service->instance_ << "." + << _service->unique_ << "." << its_event_id << "]."; } else { // If event reliability type was not configured, @@ -2189,7 +2209,7 @@ void configuration_impl::load_event( } VSOMEIP_WARNING << "Reliability type for event [" << std::hex << _service->service_ << "." - << _service->instance_ << "." + << _service->unique_ << "." << its_event_id << "] was not configured Using : " << ((its_reliability == reliability_type_e::RT_RELIABLE) ? "RT_RELIABLE" : "RT_UNRELIABLE"); @@ -2376,6 +2396,7 @@ void configuration_impl::load_client(const boost::property_tree::ptree &_tree) { its_client->last_used_specific_client_port_[false] = ILLEGAL_PORT; its_client->last_used_client_port_[true] = ILLEGAL_PORT; its_client->last_used_client_port_[false] = ILLEGAL_PORT; + major_version_t its_major(DEFAULT_MAJOR); for (auto i = _tree.begin(); i != _tree.end(); ++i) { std::string its_key(i->first); @@ -2405,10 +2426,13 @@ void configuration_impl::load_client(const boost::property_tree::ptree &_tree) { if (its_key == "service") { its_converter >> its_client->service_; } else if (its_key == "instance") { - its_converter >> its_client->instance_; + its_converter >> its_client->unique_; + } else if (its_key == "major") { + its_converter >> its_major; } } } + its_client->unique_ = get_unique_version(static_cast(its_client->unique_), its_major); clients_.push_back(its_client); } catch (...) { } @@ -2728,12 +2752,13 @@ configuration_impl::load_partition(const boost::property_tree::ptree &_tree) { try { std::stringstream its_converter; - std::map > its_partition_members; + std::map > its_partition_members; for (auto i = _tree.begin(); i != _tree.end(); ++i) { service_t its_service(0x0); - instance_t its_instance(0x0); - std::string its_service_s, its_instance_s; + unique_version_t its_unique(0x0); + major_version_t its_major(DEFAULT_MAJOR); + std::string its_service_s, its_unique_s, its_major_s; for (auto j = i->second.begin(); j != i->second.end(); ++j) { std::string its_key(j->first); @@ -2752,16 +2777,21 @@ configuration_impl::load_partition(const boost::property_tree::ptree &_tree) { its_converter >> its_service; its_service_s = its_data; } else if (its_key == "instance") { - its_converter >> its_instance; - its_instance_s = its_data; + its_converter >> its_unique; + its_unique_s = its_data; + } else if (its_key == "major") { + its_converter >> its_major; + its_major_s = its_data; } } - if (its_service > 0 && its_instance > 0) - its_partition_members[its_service].insert(its_instance); + its_unique = get_unique_version(static_cast(its_unique), its_major); + + if (its_service > 0 && its_unique > 0) + its_partition_members[its_service].insert(its_unique); else - VSOMEIP_ERROR << "P: <" << its_service_s << "." - << its_instance_s << "> is no valid service instance."; + VSOMEIP_ERROR << "P: <" << its_unique_s << "." + << its_unique_s << "> is no valid service instance."; } @@ -2893,9 +2923,9 @@ vsomeip_v3::logger::level_e configuration_impl::get_loglevel() const { } std::string configuration_impl::get_unicast_address(service_t _service, - instance_t _instance) const { + unique_version_t _unique) const { std::string its_unicast_address(""); - auto its_service = find_service(_service, _instance); + auto its_service = find_service(_service, _unique); if (its_service) { its_unicast_address = its_service->unicast_address_; } @@ -2907,10 +2937,10 @@ std::string configuration_impl::get_unicast_address(service_t _service, } uint16_t configuration_impl::get_reliable_port(service_t _service, - instance_t _instance) const { + unique_version_t _unique) const { std::lock_guard its_lock(services_mutex_); uint16_t its_reliable(ILLEGAL_PORT); - auto its_service = find_service_unlocked(_service, _instance); + auto its_service = find_service_unlocked(_service, _unique); if (its_service) its_reliable = its_service->reliable_; @@ -2918,10 +2948,10 @@ uint16_t configuration_impl::get_reliable_port(service_t _service, } uint16_t configuration_impl::get_unreliable_port(service_t _service, - instance_t _instance) const { + unique_version_t _unique) const { std::lock_guard its_lock(services_mutex_); uint16_t its_unreliable = ILLEGAL_PORT; - auto its_service = find_service_unlocked(_service, _instance); + auto its_service = find_service_unlocked(_service, _unique); if (its_service) its_unreliable = its_service->unreliable_; @@ -2976,8 +3006,8 @@ void configuration_impl::get_configured_timing_responses( } bool configuration_impl::is_someip(service_t _service, - instance_t _instance) const { - auto its_service = find_service(_service, _instance); + unique_version_t _unique) const { + auto its_service = find_service(_service, _unique); if (its_service) return (its_service->protocol_ == "someip"); return true; // we need to explicitely configure a service to @@ -2985,7 +3015,7 @@ bool configuration_impl::is_someip(service_t _service, } bool configuration_impl::get_client_port( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, uint16_t _remote_port, bool _reliable, std::map > &_used_client_ports, uint16_t &_client_port) const { @@ -2993,7 +3023,7 @@ bool configuration_impl::get_client_port( _client_port = ILLEGAL_PORT; uint16_t its_specific_port(ILLEGAL_PORT); - if (find_specific_port(its_specific_port, _service, _instance, _reliable, _used_client_ports)) { + if (find_specific_port(its_specific_port, _service, _unique, _reliable, _used_client_ports)) { is_configured = true; if (its_specific_port != ILLEGAL_PORT) { _client_port = its_specific_port; @@ -3022,7 +3052,7 @@ bool configuration_impl::get_client_port( VSOMEIP_ERROR << "Cannot find free client port for communication to service [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << _remote_port << "." << std::boolalpha <<_reliable << "]"; @@ -3199,10 +3229,10 @@ bool configuration_impl::has_session_handling(const std::string &_name) const { return its_value; } -std::set > +std::set > configuration_impl::get_remote_services() const { std::lock_guard its_lock(services_mutex_); - std::set > its_remote_services; + std::set > its_remote_services; for (const auto& i : services_) { for (const auto& j : i.second) { if (is_remote(j.second)) { @@ -3278,11 +3308,11 @@ bool configuration_impl::is_remote(const std::shared_ptr& _service) con } bool configuration_impl::get_multicast(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, std::string &_address, uint16_t &_port) const { std::shared_ptr its_eventgroup - = find_eventgroup(_service, _instance, _eventgroup); + = find_eventgroup(_service, _unique, _eventgroup); if (!its_eventgroup) return false; @@ -3295,20 +3325,20 @@ bool configuration_impl::get_multicast(service_t _service, } uint8_t configuration_impl::get_threshold(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) const { + unique_version_t _unique, eventgroup_t _eventgroup) const { std::shared_ptr its_eventgroup - = find_eventgroup(_service, _instance, _eventgroup); + = find_eventgroup(_service, _unique, _eventgroup); return (its_eventgroup ? its_eventgroup->threshold_ : 0); } std::shared_ptr configuration_impl::find_client(service_t _service, - instance_t _instance) const { + unique_version_t _unique) const { std::list>::const_iterator it; for (it = clients_.begin(); it != clients_.end(); ++it){ // client was configured for specific service / instance if ((*it)->service_ == _service - && (*it)->instance_ == _instance) { + && (*it)->unique_ == _unique) { return *it; } } @@ -3316,15 +3346,15 @@ std::shared_ptr configuration_impl::find_client(service_t _service, } void configuration_impl::get_event_update_properties( - service_t _service, instance_t _instance, event_t _event, + service_t _service, unique_version_t _unique, event_t _event, std::chrono::milliseconds &_cycle, bool &_change_resets_cycle, bool &_update_on_change) const { auto find_service = services_.find(_service); if (find_service != services_.end()) { - auto find_instance = find_service->second.find(_instance); - if (find_instance != find_service->second.end()) { - auto its_service = find_instance->second; + auto find_unique = find_service->second.find(_unique); + if (find_unique != find_service->second.end()) { + auto its_service = find_unique->second; auto find_event = its_service->events_.find(_event); if (find_event != its_service->events_.end()) { _cycle = find_event->second->cycle_; @@ -3406,12 +3436,12 @@ bool configuration_impl::find_port(uint16_t &_port, uint16_t _remote, bool _reli } bool configuration_impl::find_specific_port(uint16_t &_port, service_t _service, - instance_t _instance, bool _reliable, + unique_version_t _unique, bool _reliable, std::map > &_used_client_ports) const { bool is_configured(false); bool check_all(false); std::list>::const_iterator it; - auto its_client = find_client(_service, _instance); + auto its_client = find_client(_service, _unique); // Check for service, instance specific port configuration if (its_client && !its_client->ports_[_reliable].empty()) { @@ -3437,7 +3467,7 @@ bool configuration_impl::find_specific_port(uint16_t &_port, service_t _service, its_client->last_used_specific_client_port_[_reliable] = *it; VSOMEIP_INFO << "configuration_impl:find_specific_port #1:" << " service: " << std::hex << _service - << " instance: " << _instance + << " instance: " << get_instance_from_unique(_unique) << " reliable: " << std::dec << _reliable << " return specific port: " << (uint32_t)_port; return true; @@ -3454,7 +3484,7 @@ bool configuration_impl::find_specific_port(uint16_t &_port, service_t _service, its_client->last_used_specific_client_port_[_reliable] = its_port; VSOMEIP_INFO << "configuration_impl:find_specific_port #2:" << " service: " << std::hex << _service - << " instance: " << _instance + << " instance: " << get_instance_from_unique(_unique) << " reliable: " << std::dec << _reliable << " return specific port: " << (uint32_t)_port; return true; @@ -3468,10 +3498,10 @@ bool configuration_impl::find_specific_port(uint16_t &_port, service_t _service, reliability_type_e configuration_impl::get_event_reliability(service_t _service, - instance_t _instance, event_t _event) const { + unique_version_t _unique, event_t _event) const { std::lock_guard its_lock(services_mutex_); reliability_type_e its_reliability(reliability_type_e::RT_UNKNOWN); - auto its_service = find_service_unlocked(_service, _instance); + auto its_service = find_service_unlocked(_service, _unique); if (its_service) { auto its_event = its_service->events_.find(_event); if (its_event != its_service->events_.end()) { @@ -3483,10 +3513,10 @@ configuration_impl::get_event_reliability(service_t _service, reliability_type_e configuration_impl::get_service_reliability(service_t _service, - instance_t _instance) const { + unique_version_t _unique) const { std::lock_guard its_lock(services_mutex_); reliability_type_e its_reliability(reliability_type_e::RT_UNKNOWN); - auto its_service = find_service_unlocked(_service, _instance); + auto its_service = find_service_unlocked(_service, _unique); if (its_service) { if (its_service->reliable_ != ILLEGAL_PORT) { if (its_service->unreliable_ != ILLEGAL_PORT) { @@ -3502,19 +3532,19 @@ configuration_impl::get_service_reliability(service_t _service, } std::shared_ptr configuration_impl::find_service(service_t _service, - instance_t _instance) const { + unique_version_t _unique) const { std::lock_guard its_lock(services_mutex_); - return find_service_unlocked(_service, _instance); + return find_service_unlocked(_service, _unique); } std::shared_ptr configuration_impl::find_service_unlocked(service_t _service, - instance_t _instance) const { + unique_version_t _unique) const { std::shared_ptr its_service; auto find_service = services_.find(_service); if (find_service != services_.end()) { - auto find_instance = find_service->second.find(_instance); - if (find_instance != find_service->second.end()) { - its_service = find_instance->second; + auto find_unique = find_service->second.find(_unique); + if (find_unique != find_service->second.end()) { + its_service = find_unique->second; } } return its_service; @@ -3541,10 +3571,10 @@ configuration_impl::find_service(service_t _service, } std::shared_ptr configuration_impl::find_eventgroup( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) const { std::shared_ptr its_eventgroup; - auto its_service = find_service(_service, _instance); + auto its_service = find_service(_service, _unique); if (its_service) { auto find_eventgroup = its_service->eventgroups_.find(_eventgroup); if (find_eventgroup != its_service->eventgroups_.end()) { @@ -3614,18 +3644,18 @@ uint32_t configuration_impl::get_log_version_interval() const { return log_version_interval_; } -bool configuration_impl::is_offered_remote(service_t _service, instance_t _instance) const { - uint16_t reliable_port = get_reliable_port(_service, _instance); - uint16_t unreliable_port = get_unreliable_port(_service, _instance); +bool configuration_impl::is_offered_remote(service_t _service, unique_version_t _unique) const { + uint16_t reliable_port = get_reliable_port(_service, _unique); + uint16_t unreliable_port = get_unreliable_port(_service, _unique); return (reliable_port != ILLEGAL_PORT || unreliable_port != ILLEGAL_PORT); } -bool configuration_impl::is_local_service(service_t _service, instance_t _instance) const { - std::shared_ptr s = find_service(_service, _instance); +bool configuration_impl::is_local_service(service_t _service, unique_version_t _unique) const { + std::shared_ptr s = find_service(_service, _unique); if (s && !is_remote(s)) { return true; } - if (is_internal_service(_service, _instance)) { + if (is_internal_service(_service, get_instance_from_unique(_unique))) { return true; } @@ -3836,6 +3866,8 @@ void configuration_impl::load_ttl_factors( for (const auto& i : _tree) { service_t its_service(ILLEGAL_VALUE); instance_t its_instance(ILLEGAL_VALUE); + unique_version_t its_unique(ILLEGAL_VALUE); + major_version_t its_major(DEFAULT_MAJOR); configuration::ttl_factor_t its_ttl_factor(0); for (const auto& j : i.second) { @@ -3858,13 +3890,16 @@ void configuration_impl::load_ttl_factors( its_converter >> its_service; } else if (its_key == "instance") { its_converter >> its_instance; + } else if (its_key == "major") { + its_converter >> its_major; } } } if (its_service != ILLEGAL_VALUE && its_instance != ILLEGAL_VALUE && its_ttl_factor > 0) { - (*_target)[its_service][its_instance] = its_ttl_factor; + its_unique = get_unique_version(its_instance, its_major); + (*_target)[its_service][its_unique] = its_ttl_factor; } else { VSOMEIP_ERROR << "Invalid ttl factor configuration"; } @@ -4014,6 +4049,8 @@ configuration_impl::load_service_debounce( service_t its_service(0); instance_t its_instance(0); + unique_version_t its_unique(0); + major_version_t its_major(DEFAULT_MAJOR); std::map> its_debounces; for (auto i = _tree.begin(); i != _tree.end(); ++i) { @@ -4035,11 +4072,20 @@ configuration_impl::load_service_debounce( its_converter << std::dec << its_value; } its_converter >> its_instance; + } else if (its_key == "major") { + if (its_value.size() > 1 && its_value[0] == '0' && its_value[1] == 'x') { + its_converter << std::hex << its_value; + } else { + its_converter << std::dec << its_value; + } + its_converter >> its_major; } else if (its_key == "events") { load_events_debounce(i->second, its_debounces); } } + its_unique = get_unique_version(its_instance, its_major); + // TODO: Improve error handling! if (its_service > 0 && its_instance > 0 && !its_debounces.empty()) { auto find_service = debounces_.find(its_service); @@ -4053,7 +4099,7 @@ configuration_impl::load_service_debounce( return; } } - _debounces[its_service][its_instance] = its_debounces; + _debounces[its_service][its_unique] = its_debounces; } } @@ -4459,7 +4505,7 @@ void configuration_impl::load_someip_tp_for_service( VSOMEIP_WARNING << "SOME/IP-TP: Multiple client configurations for method [" << std::hex << std::setfill('0') << std::setw(4) << _service->service_ << "." - << std::setw(4) << _service->instance_ << "." + << std::setw(4) << get_instance_from_unique(_service->unique_) << "." << std::setw(4) << its_method << "]:" << " using (" << std::dec << its_entry->second.first << ", " @@ -4474,7 +4520,7 @@ void configuration_impl::load_someip_tp_for_service( VSOMEIP_WARNING << "SOME/IP-TP: Multiple service configurations for method [" << std::hex << std::setfill('0') << std::setw(4) << _service->service_ << "." - << std::setw(4) << _service->instance_ << "." + << std::setw(4) << get_instance_from_unique(_service->unique_) << "." << std::setw(4) << its_method << "]:" << " using (" << std::dec << its_entry->second.first << ", " @@ -4528,6 +4574,8 @@ void configuration_impl::load_secure_service(const boost::property_tree::ptree & try { service_t its_service(0); instance_t its_instance(0); + major_version_t its_major(DEFAULT_MAJOR); + unique_version_t its_unique(0); for (auto i = _tree.begin(); i != _tree.end(); ++i) { std::string its_key(i->first); @@ -4545,15 +4593,19 @@ void configuration_impl::load_secure_service(const boost::property_tree::ptree & its_converter >> its_service; } else if (its_key == "instance") { its_converter >> its_instance; + } else if (its_key == "major") { + its_converter >> its_major; } } - if (its_service != 0 && its_instance != 0) { + its_unique = get_unique_version(its_instance, its_major); + + if (its_service != 0 && its_unique != 0) { auto find_service = secure_services_.find(its_service); if (find_service != secure_services_.end()) { - find_service->second.insert(its_instance); + find_service->second.insert(its_unique); } else { - secure_services_[its_service].insert(its_instance); + secure_services_[its_service].insert(its_unique); } } @@ -4564,17 +4616,17 @@ void configuration_impl::load_secure_service(const boost::property_tree::ptree & std::shared_ptr configuration_impl::get_debounce(const std::string &_name, - service_t _service, instance_t _instance, event_t _event) const { + service_t _service, unique_version_t _unique, event_t _event) const { // Try to find application (client) specific debounce configuration auto found_application = applications_.find(_name); if (found_application != applications_.end()) { auto found_service = found_application->second.debounces_.find(_service); if (found_service != found_application->second.debounces_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_event = found_instance->second.find(_event); - if (found_event != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_event = found_unique->second.find(_event); + if (found_event != found_unique->second.end()) { return found_event->second; } } @@ -4585,10 +4637,10 @@ configuration_impl::get_debounce(const std::string &_name, // generic auto found_service = debounces_.find(_service); if (found_service != debounces_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_event = found_instance->second.find(_event); - if (found_event != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_event = found_unique->second.find(_event); + if (found_event != found_unique->second.end()) { return found_event->second; } } @@ -4869,11 +4921,11 @@ void configuration_impl::set_sd_acceptance_rules_active( } } -bool configuration_impl::is_secure_service(service_t _service, instance_t _instance) const { +bool configuration_impl::is_secure_service(service_t _service, unique_version_t _unique) const { std::lock_guard its_lock(secure_services_mutex_); const auto its_service = secure_services_.find(_service); if (its_service != secure_services_.end()) - return (its_service->second.find(_instance) != its_service->second.end()); + return (its_service->second.find(_unique) != its_service->second.end()); return false; } @@ -4884,13 +4936,13 @@ int configuration_impl::get_udp_receive_buffer_size() const { bool configuration_impl::is_tp_client( service_t _service, - instance_t _instance, + unique_version_t _unique, method_t _method) const { bool ret(false); const auto its_service - = find_service(_service, _instance); + = find_service(_service, _unique); if (its_service) { ret = (its_service->tp_client_config_.find(_method) @@ -4902,12 +4954,12 @@ bool configuration_impl::is_tp_client( bool configuration_impl::is_tp_service( service_t _service, - instance_t _instance, + unique_version_t _unique, method_t _method) const { bool ret(false); const auto its_service - = find_service(_service, _instance); + = find_service(_service, _unique); if (its_service) { ret = (its_service->tp_service_config_.find(_method) != its_service->tp_service_config_.end()); @@ -4917,11 +4969,11 @@ bool configuration_impl::is_tp_service( } void configuration_impl::get_tp_configuration( - service_t _service, instance_t _instance, method_t _method, + service_t _service, unique_version_t _unique, method_t _method, bool _is_client, std::uint16_t &_max_segment_length, std::uint32_t &_separation_time) const { - const auto its_info = find_service(_service, _instance); + const auto its_info = find_service(_service, _unique); if (its_info) { if (_is_client) { auto its_method = its_info->tp_client_config_.find(_method); @@ -4983,16 +5035,16 @@ uint8_t configuration_impl::get_max_remote_subscribers() const { partition_id_t configuration_impl::get_partition_id( - service_t _service, instance_t _instance) const { + service_t _service, unique_version_t _unique) const { partition_id_t its_id(VSOMEIP_DEFAULT_PARTITION_ID); std::lock_guard its_lock(partitions_mutex_); auto find_service = partitions_.find(_service); if (find_service != partitions_.end()) { - auto find_instance = find_service->second.find(_instance); - if (find_instance != find_service->second.end()) { - its_id = find_instance->second; + auto find_unique = find_service->second.find(_unique); + if (find_unique != find_service->second.end()) { + its_id = find_unique->second; } } diff --git a/implementation/endpoints/include/client_endpoint_impl.hpp b/implementation/endpoints/include/client_endpoint_impl.hpp index a634019e5..eef68ab81 100644 --- a/implementation/endpoints/include/client_endpoint_impl.hpp +++ b/implementation/endpoints/include/client_endpoint_impl.hpp @@ -151,7 +151,7 @@ class client_endpoint_impl: public endpoint_impl, public client_endpoi virtual void set_local_port() = 0; virtual std::string get_remote_information() const = 0; virtual bool tp_segmentation_enabled(service_t _service, - instance_t _instance, + unique_version_t _unique, method_t _method) const; virtual std::uint32_t get_max_allowed_reconnects() const = 0; virtual void max_allowed_reconnects_reached() = 0; diff --git a/implementation/endpoints/include/endpoint_definition.hpp b/implementation/endpoints/include/endpoint_definition.hpp index 2dca226ea..0f3338f4a 100644 --- a/implementation/endpoints/include/endpoint_definition.hpp +++ b/implementation/endpoints/include/endpoint_definition.hpp @@ -22,7 +22,7 @@ class endpoint_definition { public: VSOMEIP_EXPORT static std::shared_ptr get( const boost::asio::ip::address &_address, - uint16_t _port, bool _is_reliable, service_t _service, instance_t _instance); + uint16_t _port, bool _is_reliable, service_t _service, unique_version_t _unique); VSOMEIP_EXPORT const boost::asio::ip::address &get_address() const; @@ -44,7 +44,7 @@ class endpoint_definition { static std::mutex definitions_mutex_; static std::map< - std::tuple, + std::tuple, std::shared_ptr > definitions_; }; diff --git a/implementation/endpoints/include/endpoint_host.hpp b/implementation/endpoints/include/endpoint_host.hpp index e5ca6d131..7f4def3d4 100644 --- a/implementation/endpoints/include/endpoint_host.hpp +++ b/implementation/endpoints/include/endpoint_host.hpp @@ -45,7 +45,7 @@ class endpoint_host { virtual void release_port(uint16_t _port, bool _reliable) = 0; virtual client_t get_client() const = 0; virtual std::string get_client_host() const = 0; - virtual instance_t find_instance(service_t _service, + virtual unique_version_t find_unique(service_t _service, endpoint * const _endpoint) const = 0; virtual void add_multicast_option(const multicast_option_t &_option) = 0; }; diff --git a/implementation/endpoints/include/endpoint_impl.hpp b/implementation/endpoints/include/endpoint_impl.hpp index 598174dd0..83ca48d4d 100644 --- a/implementation/endpoints/include/endpoint_impl.hpp +++ b/implementation/endpoints/include/endpoint_impl.hpp @@ -57,7 +57,7 @@ class endpoint_impl: public virtual endpoint { protected: uint32_t find_magic_cookie(byte_t *_buffer, size_t _size); - instance_t get_instance(service_t _service); + unique_version_t get_unique(service_t _service); protected: enum class cms_ret_e : uint8_t { diff --git a/implementation/endpoints/include/endpoint_manager_base.hpp b/implementation/endpoints/include/endpoint_manager_base.hpp index b892cec33..bd6d69913 100644 --- a/implementation/endpoints/include/endpoint_manager_base.hpp +++ b/implementation/endpoints/include/endpoint_manager_base.hpp @@ -38,7 +38,7 @@ class endpoint_manager_base std::shared_ptr find_or_create_local(client_t _client); std::shared_ptr find_local(client_t _client); - std::shared_ptr find_local(service_t _service, instance_t _instance); + std::shared_ptr find_local(service_t _service, unique_version_t _unique); std::unordered_set get_connected_clients() const; @@ -58,7 +58,7 @@ class endpoint_manager_base virtual void release_port(uint16_t _port, bool _reliable); client_t get_client() const; std::string get_client_host() const; - instance_t find_instance(service_t _service, + unique_version_t find_unique(service_t _service, endpoint* const _endpoint) const; // Statistics diff --git a/implementation/endpoints/include/endpoint_manager_impl.hpp b/implementation/endpoints/include/endpoint_manager_impl.hpp index 3aca55e11..0fed6e727 100644 --- a/implementation/endpoints/include/endpoint_manager_impl.hpp +++ b/implementation/endpoints/include/endpoint_manager_impl.hpp @@ -24,25 +24,25 @@ class endpoint_manager_impl : public endpoint_manager_base { ~endpoint_manager_impl(); std::shared_ptr find_or_create_remote_client(service_t _service, - instance_t _instance, + unique_version_t _unique, bool _reliable); - void find_or_create_remote_client(service_t _service, instance_t _instance); + void find_or_create_remote_client(service_t _service, unique_version_t _unique); void is_remote_service_known( - service_t _service, instance_t _instance, major_version_t _major, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, const boost::asio::ip::address &_reliable_address, uint16_t _reliable_port, bool* _reliable_known, const boost::asio::ip::address &_unreliable_address, uint16_t _unreliable_port, bool* _unreliable_known) const; void add_remote_service_info( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const std::shared_ptr& _ep_definition); void add_remote_service_info( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const std::shared_ptr& _ep_definition_reliable, const std::shared_ptr& _ep_definition_unreliable); - void clear_remote_service_info(service_t _service, instance_t _instance, + void clear_remote_service_info(service_t _service, unique_version_t _unique, bool _reliable); std::shared_ptr create_server_endpoint(uint16_t _port, @@ -54,19 +54,19 @@ class endpoint_manager_impl : public endpoint_manager_base { std::shared_ptr find_or_create_server_endpoint( uint16_t _port, bool _reliable, bool _start, service_t _service, - instance_t _instance, bool &_is_found, bool _is_multicast = false); + unique_version_t _unique, bool &_is_found, bool _is_multicast = false); bool remove_server_endpoint(uint16_t _port, bool _reliable); - void clear_client_endpoints(service_t _service, instance_t _instance, + void clear_client_endpoints(service_t _service, unique_version_t _unique, bool _reliable); void find_or_create_multicast_endpoint( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const boost::asio::ip::address &_sender, const boost::asio::ip::address &_address, uint16_t _port); - void clear_multicast_endpoints(service_t _service, instance_t _instance); + void clear_multicast_endpoints(service_t _service, unique_version_t _unique); - bool supports_selective(service_t _service, instance_t _instance) const; + bool supports_selective(service_t _service, unique_version_t _unique) const; void print_status() const; @@ -75,13 +75,13 @@ class endpoint_manager_impl : public endpoint_manager_base { bool &_is_socket_activated, const std::shared_ptr &_host); - instance_t find_instance(service_t _service, + unique_version_t find_unique(service_t _service, endpoint* const _endpoint) const; - instance_t find_instance_multicast(service_t _service, + unique_version_t find_unique_multicast(service_t _service, const boost::asio::ip::address &_sender) const; bool remove_instance(service_t _service, endpoint* const _endpoint); - bool remove_instance_multicast(service_t _service, instance_t _instance); + bool remove_instance_multicast(service_t _service, unique_version_t _unique); // endpoint_host interface @@ -117,10 +117,10 @@ class endpoint_manager_impl : public endpoint_manager_base { private: std::shared_ptr find_remote_client(service_t _service, - instance_t _instance, + unique_version_t _unique, bool _reliable); std::shared_ptr create_remote_client(service_t _service, - instance_t _instance, + unique_version_t _unique, bool _reliable); std::shared_ptr create_client_endpoint( const boost::asio::ip::address &_address, uint16_t _local_port, @@ -134,10 +134,10 @@ class endpoint_manager_impl : public endpoint_manager_base { private: mutable std::recursive_mutex endpoint_mutex_; // Client endpoints for remote services - std::map>>> remote_service_info_; - typedef std::map>>> remote_services_t; remote_services_t remote_services_; @@ -147,8 +147,8 @@ class endpoint_manager_impl : public endpoint_manager_base { std::map>>>>; client_endpoints_t client_endpoints_; - std::map > service_instances_; - std::map > service_instances_multicast_; + std::map > service_instances_; + std::map > service_instances_multicast_; std::map>> multicast_info_; + std::map>> multicast_info_; // Socket option processing (join, leave) std::mutex options_mutex_; diff --git a/implementation/endpoints/include/server_endpoint_impl.hpp b/implementation/endpoints/include/server_endpoint_impl.hpp index f918b3e7b..1e529679b 100644 --- a/implementation/endpoints/include/server_endpoint_impl.hpp +++ b/implementation/endpoints/include/server_endpoint_impl.hpp @@ -142,7 +142,7 @@ class server_endpoint_impl : public endpoint_impl, virtual std::string get_remote_information(const target_data_iterator_type _queue_iterator) const = 0; virtual std::string get_remote_information(const endpoint_type& _remote) const = 0; - virtual bool tp_segmentation_enabled(service_t _service, instance_t _instance, + virtual bool tp_segmentation_enabled(service_t _service, unique_version_t _unique, method_t _method) const; void schedule_train(endpoint_data_type& _target); diff --git a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp index 9820004cd..03a647044 100644 --- a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp @@ -83,7 +83,7 @@ class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl { const std::chrono::steady_clock::time_point _start); std::string get_remote_information() const; std::shared_ptr get_timing( - const service_t& _service, const instance_t& _instance) const; + const service_t& _service, const unique_version_t& _unique) const; std::uint32_t get_max_allowed_reconnects() const; void max_allowed_reconnects_reached(); diff --git a/implementation/endpoints/include/udp_client_endpoint_impl.hpp b/implementation/endpoints/include/udp_client_endpoint_impl.hpp index 02d7cd028..83ff34099 100644 --- a/implementation/endpoints/include/udp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/udp_client_endpoint_impl.hpp @@ -67,7 +67,7 @@ class udp_client_endpoint_impl: virtual public udp_client_endpoint_base_impl { std::string get_remote_information() const; bool tp_segmentation_enabled( service_t _service, - instance_t _instance, + unique_version_t _unique, method_t _method) const; std::uint32_t get_max_allowed_reconnects() const; void max_allowed_reconnects_reached(); diff --git a/implementation/endpoints/include/udp_server_endpoint_impl.hpp b/implementation/endpoints/include/udp_server_endpoint_impl.hpp index 9cddac1dc..b510b5aa0 100644 --- a/implementation/endpoints/include/udp_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/udp_server_endpoint_impl.hpp @@ -89,7 +89,7 @@ class udp_server_endpoint_impl: public udp_server_endpoint_base_impl { std::string get_address_port_local() const; bool tp_segmentation_enabled( service_t _service, - instance_t _instance, + unique_version_t _unique, method_t _method) const; void on_unicast_received(boost::system::error_code const &_error, diff --git a/implementation/endpoints/src/client_endpoint_impl.cpp b/implementation/endpoints/src/client_endpoint_impl.cpp index 05c66efe3..2066a60eb 100644 --- a/implementation/endpoints/src/client_endpoint_impl.cpp +++ b/implementation/endpoints/src/client_endpoint_impl.cpp @@ -284,7 +284,7 @@ bool client_endpoint_impl::send(const uint8_t *_data, uint32_t _size) template bool client_endpoint_impl::tp_segmentation_enabled( - service_t /*_service*/, instance_t /*_instance*/, method_t /*_method*/) const { + service_t /*_service*/, unique_version_t /*_instance*/, method_t /*_method*/) const { return false; } @@ -777,14 +777,14 @@ typename endpoint_impl::cms_ret_e client_endpoint_impl::chec if (endpoint_impl::is_supporting_someip_tp_ && _data != nullptr) { const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); const method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); - instance_t its_instance = this->get_instance(its_service); + unique_version_t its_unique = this->get_unique(its_service); - if (its_instance != ANY_INSTANCE) { - if (tp_segmentation_enabled(its_service, its_instance, its_method)) { + if (get_instance_from_unique(its_unique) != ANY_INSTANCE) { + if (tp_segmentation_enabled(its_service, its_unique, its_method)) { std::uint16_t its_max_segment_length; std::uint32_t its_separation_time; this->configuration_->get_tp_configuration( - its_service, its_instance, its_method, true, + its_service, its_unique, its_method, true, its_max_segment_length, its_separation_time); send_segments(tp::tp::tp_split_message(_data, _size, its_max_segment_length), its_separation_time); diff --git a/implementation/endpoints/src/endpoint_definition.cpp b/implementation/endpoints/src/endpoint_definition.cpp index ff6ff7bdc..bd4ac16d3 100644 --- a/implementation/endpoints/src/endpoint_definition.cpp +++ b/implementation/endpoints/src/endpoint_definition.cpp @@ -9,15 +9,15 @@ namespace vsomeip_v3 { -std::map, +std::map, std::shared_ptr > endpoint_definition::definitions_; std::mutex endpoint_definition::definitions_mutex_; std::shared_ptr endpoint_definition::get(const boost::asio::ip::address &_address, - uint16_t _port, bool _is_reliable, service_t _service, instance_t _instance) { - auto key = std::make_tuple(_service, _instance, _address, _port, _is_reliable); + uint16_t _port, bool _is_reliable, service_t _service, unique_version_t _unique) { + auto key = std::make_tuple(_service, _unique, _address, _port, _is_reliable); std::lock_guard its_lock(definitions_mutex_); std::shared_ptr its_result; diff --git a/implementation/endpoints/src/endpoint_impl.cpp b/implementation/endpoints/src/endpoint_impl.cpp index b69943bca..2a0e68e09 100644 --- a/implementation/endpoints/src/endpoint_impl.cpp +++ b/implementation/endpoints/src/endpoint_impl.cpp @@ -100,15 +100,15 @@ void endpoint_impl::register_error_handler(const error_handler_t &_err } template -instance_t endpoint_impl::get_instance(service_t _service) { +unique_version_t endpoint_impl::get_unique(service_t _service) { - instance_t its_instance(0xFFFF); + unique_version_t its_unique(0xFFFF); auto its_host = endpoint_host_.lock(); if (its_host) - its_instance = its_host->find_instance(_service, this); + its_unique = its_host->find_unique(_service, this); - return its_instance; + return its_unique; } // Instantiate template diff --git a/implementation/endpoints/src/endpoint_manager_base.cpp b/implementation/endpoints/src/endpoint_manager_base.cpp index 22736bf64..09be30c8d 100644 --- a/implementation/endpoints/src/endpoint_manager_base.cpp +++ b/implementation/endpoints/src/endpoint_manager_base.cpp @@ -74,8 +74,8 @@ std::shared_ptr endpoint_manager_base::find_local(client_t _client) { } std::shared_ptr endpoint_manager_base::find_local(service_t _service, - instance_t _instance) { - return find_local(rm_->find_local_client(_service, _instance)); + unique_version_t _unique) { + return find_local(rm_->find_local_client(_service, _unique)); } @@ -357,7 +357,7 @@ std::shared_ptr endpoint_manager_base::find_local_unlocked(client_t _c return its_endpoint; } -instance_t endpoint_manager_base::find_instance( +unique_version_t endpoint_manager_base::find_unique( service_t _service, endpoint* const _endpoint) const { (void)_service; diff --git a/implementation/endpoints/src/endpoint_manager_impl.cpp b/implementation/endpoints/src/endpoint_manager_impl.cpp index 3f7597af8..f26d22dee 100644 --- a/implementation/endpoints/src/endpoint_manager_impl.cpp +++ b/implementation/endpoints/src/endpoint_manager_impl.cpp @@ -59,18 +59,18 @@ endpoint_manager_impl::~endpoint_manager_impl() { } std::shared_ptr endpoint_manager_impl::find_or_create_remote_client( - service_t _service, instance_t _instance, bool _reliable) { + service_t _service, unique_version_t _unique, bool _reliable) { std::shared_ptr its_endpoint; bool start_endpoint(false); { std::lock_guard its_lock(endpoint_mutex_); - its_endpoint = find_remote_client(_service, _instance, _reliable); + its_endpoint = find_remote_client(_service, _unique, _reliable); if (!its_endpoint) { - its_endpoint = create_remote_client(_service, _instance, _reliable); + its_endpoint = create_remote_client(_service, _unique, _reliable); start_endpoint = true; } } - if (start_endpoint && its_endpoint && configuration_->is_someip(_service, _instance) + if (start_endpoint && its_endpoint && configuration_->is_someip(_service, _unique) && rm_->get_routing_state() != routing_state_e::RS_SUSPENDED) { its_endpoint->start(); } @@ -78,25 +78,25 @@ std::shared_ptr endpoint_manager_impl::find_or_create_remote_client( } void endpoint_manager_impl::find_or_create_remote_client( - service_t _service, instance_t _instance) { + service_t _service, unique_version_t _unique) { std::shared_ptr its_reliable_endpoint; std::shared_ptr its_unreliable_endpoint; bool start_reliable_endpoint(false); bool start_unreliable_endpoint(false); { std::lock_guard its_lock(endpoint_mutex_); - its_reliable_endpoint = find_remote_client(_service, _instance, true); + its_reliable_endpoint = find_remote_client(_service, _unique, true); if (!its_reliable_endpoint) { - its_reliable_endpoint = create_remote_client(_service, _instance, true); + its_reliable_endpoint = create_remote_client(_service, _unique, true); start_reliable_endpoint = true; } - its_unreliable_endpoint = find_remote_client(_service, _instance, false); + its_unreliable_endpoint = find_remote_client(_service, _unique, false); if (!its_unreliable_endpoint) { - its_unreliable_endpoint = create_remote_client(_service, _instance, false); + its_unreliable_endpoint = create_remote_client(_service, _unique, false); start_unreliable_endpoint = true; } } - const bool is_someip {configuration_->is_someip(_service, _instance)}; + const bool is_someip {configuration_->is_someip(_service, _unique)}; const bool is_suspended {rm_->get_routing_state() == routing_state_e::RS_SUSPENDED}; if (start_reliable_endpoint && its_reliable_endpoint && is_someip && !is_suspended) { @@ -108,7 +108,7 @@ void endpoint_manager_impl::find_or_create_remote_client( } void endpoint_manager_impl::is_remote_service_known( - service_t _service, instance_t _instance, major_version_t _major, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, const boost::asio::ip::address &_reliable_address, uint16_t _reliable_port, bool* _reliable_known, @@ -118,12 +118,12 @@ void endpoint_manager_impl::is_remote_service_known( std::lock_guard its_lock(endpoint_mutex_); auto found_service = remote_service_info_.find(_service); if (found_service != remote_service_info_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { std::shared_ptr its_definition; if (_reliable_port != ILLEGAL_PORT) { - auto found_reliable = found_instance->second.find(true); - if (found_reliable != found_instance->second.end()) { + auto found_reliable = found_unique->second.find(true); + if (found_reliable != found_unique->second.end()) { its_definition = found_reliable->second; if (its_definition->get_address() == _reliable_address && its_definition->get_port() == _reliable_port) { @@ -132,7 +132,7 @@ void endpoint_manager_impl::is_remote_service_known( VSOMEIP_WARNING << "Reliable service endpoint has changed: [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << static_cast(_major) << "." << _minor << "] old: " << its_definition->get_address().to_string() << ":" @@ -143,8 +143,8 @@ void endpoint_manager_impl::is_remote_service_known( } } if (_unreliable_port != ILLEGAL_PORT) { - auto found_unreliable = found_instance->second.find(false); - if (found_unreliable != found_instance->second.end()) { + auto found_unreliable = found_unique->second.find(false); + if (found_unreliable != found_unique->second.end()) { its_definition = found_unreliable->second; if (its_definition->get_address() == _unreliable_address && its_definition->get_port() == _unreliable_port) { @@ -153,7 +153,7 @@ void endpoint_manager_impl::is_remote_service_known( VSOMEIP_WARNING << "Unreliable service endpoint has changed: [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << static_cast(_major) << "." << _minor << "] old: " << its_definition->get_address().to_string() << ":" @@ -168,7 +168,7 @@ void endpoint_manager_impl::is_remote_service_known( } void endpoint_manager_impl::add_remote_service_info( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const std::shared_ptr& _ep_definition) { std::shared_ptr its_info; @@ -176,25 +176,25 @@ void endpoint_manager_impl::add_remote_service_info( bool must_report(false); { std::lock_guard its_lock(endpoint_mutex_); - remote_service_info_[_service][_instance][_ep_definition->is_reliable()] = + remote_service_info_[_service][_unique][_ep_definition->is_reliable()] = _ep_definition; if (_ep_definition->is_reliable()) { - its_endpoint = find_remote_client(_service, _instance, true); + its_endpoint = find_remote_client(_service, _unique, true); must_report = (its_endpoint && its_endpoint->is_established_or_connected()); if (must_report) - its_info = rm_->find_service(_service, _instance); + its_info = rm_->find_service(_service, _unique); } } if (must_report) static_cast(rm_)->service_endpoint_connected( - _service, _instance, its_info->get_major(), its_info->get_minor(), + _service, _unique, its_info->get_major(), its_info->get_minor(), its_endpoint, false); } void endpoint_manager_impl::add_remote_service_info( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const std::shared_ptr& _ep_definition_reliable, const std::shared_ptr& _ep_definition_unreliable) { @@ -203,40 +203,40 @@ void endpoint_manager_impl::add_remote_service_info( bool must_report(false); { std::lock_guard its_lock(endpoint_mutex_); - remote_service_info_[_service][_instance][false] = _ep_definition_unreliable; - remote_service_info_[_service][_instance][true] = _ep_definition_reliable; + remote_service_info_[_service][_unique][false] = _ep_definition_unreliable; + remote_service_info_[_service][_unique][true] = _ep_definition_reliable; - its_unreliable = find_remote_client(_service, _instance, false); - its_reliable = find_remote_client(_service, _instance, true); + its_unreliable = find_remote_client(_service, _unique, false); + its_reliable = find_remote_client(_service, _unique, true); must_report = (its_unreliable && its_unreliable->is_established_or_connected() && its_reliable && its_reliable->is_established_or_connected()); if (must_report) - its_info = rm_->find_service(_service, _instance); + its_info = rm_->find_service(_service, _unique); } if (must_report) { static_cast(rm_)->service_endpoint_connected( - _service, _instance, its_info->get_major(), its_info->get_minor(), + _service, _unique, its_info->get_major(), its_info->get_minor(), its_unreliable, false); static_cast(rm_)->service_endpoint_connected( - _service, _instance, its_info->get_major(), its_info->get_minor(), + _service, _unique, its_info->get_major(), its_info->get_minor(), its_reliable, false); } } void endpoint_manager_impl::clear_remote_service_info(service_t _service, - instance_t _instance, + unique_version_t _unique, bool _reliable) { std::lock_guard its_lock(endpoint_mutex_); const auto found_service = remote_service_info_.find(_service); if (found_service != remote_service_info_.end()) { - const auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - if (found_instance->second.erase(_reliable)) { - if (!found_instance->second.size()) { - found_service->second.erase(found_instance); + const auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + if (found_unique->second.erase(_reliable)) { + if (!found_unique->second.size()) { + found_service->second.erase(found_unique); if (!found_service->second.size()) { remote_service_info_.erase(found_service); } @@ -319,7 +319,7 @@ std::shared_ptr endpoint_manager_impl::find_server_endpoint( std::shared_ptr endpoint_manager_impl::find_or_create_server_endpoint( uint16_t _port, bool _reliable, bool _start, service_t _service, - instance_t _instance, bool &_is_found, bool _is_multicast) { + unique_version_t _unique, bool &_is_found, bool _is_multicast) { std::shared_ptr its_endpoint = find_server_endpoint(_port, _reliable); _is_found = false; @@ -331,7 +331,7 @@ std::shared_ptr endpoint_manager_impl::find_or_create_server_endpoint( if (its_endpoint) { std::lock_guard its_lock(endpoint_mutex_); if (!_is_multicast) { - service_instances_[_service][its_endpoint.get()] = _instance; + service_instances_[_service][its_endpoint.get()] = _unique; } } return its_endpoint; @@ -369,7 +369,7 @@ bool endpoint_manager_impl::remove_server_endpoint(uint16_t _port, bool _reliabl void endpoint_manager_impl::clear_client_endpoints( - service_t _service, instance_t _instance, bool _reliable) { + service_t _service, unique_version_t _unique, bool _reliable) { std::shared_ptr its_endpoint; @@ -384,15 +384,15 @@ endpoint_manager_impl::clear_client_endpoints( // Clear client endpoints for remote services (generic and specific ones) const auto found_service = remote_services_.find(_service); if (found_service != remote_services_.end()) { - const auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - const auto found_reliability = found_instance->second.find(_reliable); - if (found_reliability != found_instance->second.end()) { + const auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + const auto found_reliability = found_unique->second.find(_reliable); + if (found_reliability != found_unique->second.end()) { service_instances_[_service].erase(found_reliability->second.get()); its_endpoint = found_reliability->second; - found_instance->second.erase(found_reliability); - if (found_instance->second.empty()) { - found_service->second.erase(found_instance); + found_unique->second.erase(found_reliability); + if (found_unique->second.empty()) { + found_service->second.erase(found_unique); if (found_service->second.empty()) { remote_services_.erase(found_service); } @@ -405,9 +405,9 @@ endpoint_manager_impl::clear_client_endpoints( // reachable through it is online anymore. if (its_endpoint) { for (const auto& service : remote_services_) { - for (const auto& instance : service.second) { - const auto found_reliability = instance.second.find(_reliable); - if (found_reliability != instance.second.end() + for (const auto& unique : service.second) { + const auto found_reliability = unique.second.find(_reliable); + if (found_reliability != unique.second.end() && found_reliability->second == its_endpoint) { other_services_reachable_through_endpoint = true; break; @@ -419,7 +419,7 @@ endpoint_manager_impl::clear_client_endpoints( if (!other_services_reachable_through_endpoint) { partition_id_t its_partition; - its_partition = configuration_->get_partition_id(_service, _instance); + its_partition = configuration_->get_partition_id(_service, _unique); if (_reliable) { std::shared_ptr its_tcp_client_endpoint = @@ -475,7 +475,7 @@ endpoint_manager_impl::clear_client_endpoints( } void endpoint_manager_impl::find_or_create_multicast_endpoint( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const boost::asio::ip::address &_sender, const boost::asio::ip::address &_address, uint16_t _port) { bool is_known_multicast(false); @@ -483,9 +483,9 @@ void endpoint_manager_impl::find_or_create_multicast_endpoint( std::lock_guard its_lock(endpoint_mutex_); const auto found_service = multicast_info_.find(_service); if (found_service != multicast_info_.end()) { - const auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - const auto& endpoint_def = found_instance->second; + const auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + const auto& endpoint_def = found_unique->second; if (endpoint_def->get_address() == _address && endpoint_def->get_port() == _port) { // Multicast info and endpoint already created before @@ -495,25 +495,25 @@ void endpoint_manager_impl::find_or_create_multicast_endpoint( } } } - const bool is_someip = configuration_->is_someip(_service, _instance); + const bool is_someip = configuration_->is_someip(_service, _unique); bool _is_found(false); // Create multicast endpoint & join multicase group std::shared_ptr its_endpoint = find_or_create_server_endpoint( - _port, false, is_someip, _service, _instance, _is_found, true); + _port, false, is_someip, _service, _unique, _is_found, true); if (!_is_found) { // Only save multicast info if we created a new endpoint // to be able to delete the new endpoint // as soon as the instance stops offering its service std::lock_guard its_lock(endpoint_mutex_); std::shared_ptr endpoint_def = - endpoint_definition::get(_address, _port, false, _service, _instance); - multicast_info_[_service][_instance] = endpoint_def; + endpoint_definition::get(_address, _port, false, _service, _unique); + multicast_info_[_service][_unique] = endpoint_def; } if (its_endpoint) { if (!is_known_multicast) { std::lock_guard its_lock(endpoint_mutex_); - service_instances_multicast_[_service][_sender] = _instance; + service_instances_multicast_[_service][_sender] = _unique; } auto its_udp_server_endpoint = @@ -525,7 +525,7 @@ void endpoint_manager_impl::find_or_create_multicast_endpoint( } } -void endpoint_manager_impl::clear_multicast_endpoints(service_t _service, instance_t _instance) { +void endpoint_manager_impl::clear_multicast_endpoints(service_t _service, unique_version_t _unique) { std::shared_ptr its_multicast_endpoint; std::string its_address; @@ -533,9 +533,9 @@ void endpoint_manager_impl::clear_multicast_endpoints(service_t _service, instan std::lock_guard its_lock(endpoint_mutex_); // Clear multicast info and endpoint and multicast instance (remote service) if (multicast_info_.find(_service) != multicast_info_.end()) { - if (multicast_info_[_service].find(_instance) != multicast_info_[_service].end()) { - its_address = multicast_info_[_service][_instance]->get_address().to_string(); - uint16_t its_port = multicast_info_[_service][_instance]->get_port(); + if (multicast_info_[_service].find(_unique) != multicast_info_[_service].end()) { + its_address = multicast_info_[_service][_unique]->get_address().to_string(); + uint16_t its_port = multicast_info_[_service][_unique]->get_port(); auto found_port = server_endpoints_.find(its_port); if (found_port != server_endpoints_.end()) { auto found_unreliable = found_port->second.find(false); @@ -547,11 +547,11 @@ void endpoint_manager_impl::clear_multicast_endpoints(service_t _service, instan server_endpoints_.erase(its_port); } } - multicast_info_[_service].erase(_instance); + multicast_info_[_service].erase(_unique); if (0 >= multicast_info_[_service].size()) { multicast_info_.erase(_service); } - (void)remove_instance_multicast(_service, _instance); + (void)remove_instance_multicast(_service, _unique); } } } @@ -567,14 +567,14 @@ void endpoint_manager_impl::clear_multicast_endpoints(service_t _service, instan } bool endpoint_manager_impl::supports_selective(service_t _service, - instance_t _instance) const { + unique_version_t _unique) const { bool supports_selective(false); std::lock_guard its_lock(endpoint_mutex_); const auto its_service = remote_service_info_.find(_service); if (its_service != remote_service_info_.end()) { - const auto its_instance = its_service->second.find(_instance); - if (its_instance != its_service->second.end()) { - for (const auto& its_reliable : its_instance->second) { + const auto its_unique = its_service->second.find(_unique); + if (its_unique != its_service->second.end()) { + for (const auto& its_reliable : its_unique->second) { supports_selective |= configuration_-> supports_selective_broadcasts( its_reliable.second->get_address()); @@ -804,32 +804,32 @@ bool endpoint_manager_impl::create_routing_root(std::shared_ptr& _root return true; } -instance_t endpoint_manager_impl::find_instance( +unique_version_t endpoint_manager_impl::find_unique( service_t _service, endpoint* const _endpoint) const { - instance_t its_instance(0xFFFF); + unique_version_t its_unique(0xFFFF); std::lock_guard its_lock(endpoint_mutex_); auto found_service = service_instances_.find(_service); if (found_service != service_instances_.end()) { auto found_endpoint = found_service->second.find(_endpoint); if (found_endpoint != found_service->second.end()) { - its_instance = found_endpoint->second; + its_unique = found_endpoint->second; } } - return its_instance; + return its_unique; } -instance_t endpoint_manager_impl::find_instance_multicast( +unique_version_t endpoint_manager_impl::find_unique_multicast( service_t _service, const boost::asio::ip::address &_sender) const { - instance_t its_instance(0xFFFF); + unique_version_t its_unique(0xFFFF); std::lock_guard its_lock(endpoint_mutex_); auto found_service = service_instances_multicast_.find(_service); if (found_service != service_instances_multicast_.end()) { auto found_sender = found_service->second.find(_sender); if (found_sender != found_service->second.end()) { - its_instance = found_sender->second; + its_unique = found_sender->second; } } - return its_instance; + return its_unique; } bool endpoint_manager_impl::remove_instance(service_t _service, @@ -849,12 +849,12 @@ bool endpoint_manager_impl::remove_instance(service_t _service, } bool endpoint_manager_impl::remove_instance_multicast(service_t _service, - instance_t _instance) { + unique_version_t _unique) { std::lock_guard its_lock(endpoint_mutex_); auto found_service = service_instances_multicast_.find(_service); if (found_service != service_instances_multicast_.end()) { for (auto &its_sender : found_service->second) { - if (its_sender.second == _instance) { + if (its_sender.second == _unique) { if (found_service->second.erase(its_sender.first)) { if (!found_service->second.size()) { service_instances_multicast_.erase(_service); @@ -889,13 +889,13 @@ void endpoint_manager_impl::on_connect(std::shared_ptr _endpoint) { const bool endpoint_is_reliable = _endpoint->is_reliable(); std::lock_guard its_lock(endpoint_mutex_); for (auto &its_service : remote_services_) { - for (auto &its_instance : its_service.second) { - auto found_endpoint = its_instance.second.find(endpoint_is_reliable); - if (found_endpoint != its_instance.second.end()) { + for (auto &its_unique : its_service.second) { + auto found_endpoint = its_unique.second.find(endpoint_is_reliable); + if (found_endpoint != its_unique.second.end()) { if (found_endpoint->second == _endpoint) { std::shared_ptr its_info( rm_->find_service(its_service.first, - its_instance.first)); + its_unique.first)); if (!its_info) { _endpoint->set_established(true); return; @@ -909,7 +909,7 @@ void endpoint_manager_impl::on_connect(std::shared_ptr _endpoint) { && its_other_endpoint->is_established_or_connected())) { services_to_report_.push_front( { its_service.first, - its_instance.first, + get_instance_from_unique(its_unique.first), its_info->get_major(), its_info->get_minor(), _endpoint, @@ -923,7 +923,7 @@ void endpoint_manager_impl::on_connect(std::shared_ptr _endpoint) { } for (const auto &s : services_to_report_) { static_cast(rm_)->service_endpoint_connected( - s.service_id_, s.instance_id_, s.major_, s.minor_, s.endpoint_, + s.service_id_, get_unique_version(s.instance_id_, s.major_), s.major_, s.minor_, s.endpoint_, s.service_is_unreliable_only_); } if (services_to_report_.empty()) { @@ -935,25 +935,25 @@ void endpoint_manager_impl::on_disconnect(std::shared_ptr _endpoint) { // Is called when endpoint->connect fails! std::lock_guard its_lock(endpoint_mutex_); for (auto &its_service : remote_services_) { - for (auto &its_instance : its_service.second) { + for (auto &its_unique : its_service.second) { const bool is_reliable = _endpoint->is_reliable(); - auto found_endpoint = its_instance.second.find(is_reliable); - if (found_endpoint != its_instance.second.end()) { + auto found_endpoint = its_unique.second.find(is_reliable); + if (found_endpoint != its_unique.second.end()) { if (found_endpoint->second == _endpoint) { std::shared_ptr its_info( rm_->find_service(its_service.first, - its_instance.first)); + its_unique.first)); if(!its_info){ return; } if (!is_reliable) { static_cast(rm_)->on_availability( - its_service.first, its_instance.first, + its_service.first, get_instance_from_unique(its_unique.first), availability_state_e::AS_UNAVAILABLE, its_info->get_major(), its_info->get_minor()); } static_cast(rm_)->service_endpoint_disconnected( - its_service.first, its_instance.first, + its_service.first, its_unique.first, its_info->get_major(), its_info->get_minor(), _endpoint); } @@ -967,10 +967,10 @@ bool endpoint_manager_impl::on_bind_error(std::shared_ptr _endpoint, std::lock_guard its_ep_lock(endpoint_mutex_); for (auto &its_service : remote_services_) { - for (auto &its_instance : its_service.second) { + for (auto &its_unique : its_service.second) { const bool is_reliable = _endpoint->is_reliable(); - auto found_endpoint = its_instance.second.find(is_reliable); - if (found_endpoint != its_instance.second.end()) { + auto found_endpoint = its_unique.second.find(is_reliable); + if (found_endpoint != its_unique.second.end()) { if (found_endpoint->second == _endpoint) { // get a new client port using service / instance / remote port uint16_t its_old_local_port = _endpoint->get_local_port(); @@ -980,7 +980,7 @@ bool endpoint_manager_impl::on_bind_error(std::shared_ptr _endpoint, std::map > its_used_client_ports; get_used_client_ports(_remote_address, _remote_port, its_used_client_ports); if (configuration_->get_client_port( - its_service.first, its_instance.first, + its_service.first, its_unique.first, _remote_port, is_reliable, its_used_client_ports, its_new_local_port)) { _endpoint->set_local_port(its_new_local_port); @@ -1000,13 +1000,13 @@ void endpoint_manager_impl::on_error( const byte_t *_data, length_t _length, endpoint* const _receiver, const boost::asio::ip::address &_remote_address, std::uint16_t _remote_port) { - instance_t its_instance = 0; + unique_version_t its_unique = 0; if (_length >= VSOMEIP_SERVICE_POS_MAX) { service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); - its_instance = find_instance(its_service, _receiver); + its_unique = find_unique(its_service, _receiver); } static_cast(rm_)->send_error( - return_code_e::E_MALFORMED_MESSAGE, _data, _length, its_instance, + return_code_e::E_MALFORMED_MESSAGE, _data, _length, get_instance_from_unique(its_unique), _receiver->is_reliable(), _receiver, _remote_address, _remote_port); } @@ -1051,15 +1051,15 @@ endpoint_manager_impl::release_used_client_port( std::shared_ptr endpoint_manager_impl::find_remote_client( - service_t _service, instance_t _instance, bool _reliable) { + service_t _service, unique_version_t _unique, bool _reliable) { std::shared_ptr its_endpoint; auto found_service = remote_services_.find(_service); if (found_service != remote_services_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_reliability = found_instance->second.find(_reliable); - if (found_reliability != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_reliability = found_unique->second.find(_reliable); + if (found_reliability != found_unique->second.end()) { its_endpoint = found_reliability->second; } } @@ -1071,16 +1071,16 @@ endpoint_manager_impl::find_remote_client( // Endpoint did not yet exist. Get the partition id to check // whether the client endpoint for the partition does exist. partition_id_t its_partition_id - = configuration_->get_partition_id(_service, _instance); + = configuration_->get_partition_id(_service, _unique); // If another service within the same partition is hosted on the // same server_endpoint reuse the existing client_endpoint. auto found_service_info = remote_service_info_.find(_service); if (found_service_info != remote_service_info_.end()) { - auto found_instance = found_service_info->second.find(_instance); - if (found_instance != found_service_info->second.end()) { - auto found_reliable = found_instance->second.find(_reliable); - if (found_reliable != found_instance->second.end()) { + auto found_unique = found_service_info->second.find(_unique); + if (found_unique != found_service_info->second.end()) { + auto found_reliable = found_unique->second.find(_reliable); + if (found_reliable != found_unique->second.end()) { std::shared_ptr its_ep_def = found_reliable->second; auto found_address = client_endpoints_.find( @@ -1099,12 +1099,12 @@ endpoint_manager_impl::find_remote_client( // store the endpoint under this service/instance id // as well - needed for later cleanup - remote_services_[_service][_instance][_reliable] + remote_services_[_service][_unique][_reliable] = its_endpoint; - service_instances_[_service][its_endpoint.get()] = _instance; + service_instances_[_service][its_endpoint.get()] = _unique; // add endpoint to serviceinfo object - auto found_service_info = rm_->find_service(_service,_instance); + auto found_service_info = rm_->find_service(_service,_unique); if (found_service_info) { found_service_info->set_endpoint(its_endpoint, _reliable); } @@ -1120,7 +1120,7 @@ endpoint_manager_impl::find_remote_client( } std::shared_ptr endpoint_manager_impl::create_remote_client( - service_t _service, instance_t _instance, bool _reliable) { + service_t _service, unique_version_t _unique, bool _reliable) { std::shared_ptr its_endpoint; std::shared_ptr its_endpoint_def; uint16_t its_local_port; @@ -1130,10 +1130,10 @@ std::shared_ptr endpoint_manager_impl::create_remote_client( auto found_service = remote_service_info_.find(_service); if (found_service != remote_service_info_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_reliability = found_instance->second.find(_reliable); - if (found_reliability != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_reliability = found_unique->second.find(_reliable); + if (found_reliability != found_unique->second.end()) { its_endpoint_def = found_reliability->second; its_remote_address = its_endpoint_def->get_address(); its_remote_port = its_endpoint_def->get_port(); @@ -1149,7 +1149,7 @@ std::shared_ptr endpoint_manager_impl::create_remote_client( std::lock_guard its_lock(used_client_ports_mutex_); get_used_client_ports(its_remote_address, its_remote_port, its_used_client_ports); } - if (configuration_->get_client_port(_service, _instance, + if (configuration_->get_client_port(_service, _unique, its_remote_port, _reliable, its_used_client_ports, its_local_port)) { if (its_endpoint_def) { @@ -1164,17 +1164,17 @@ std::shared_ptr endpoint_manager_impl::create_remote_client( request_used_client_port(its_remote_address, its_remote_port, _reliable, its_local_port); - service_instances_[_service][its_endpoint.get()] = _instance; - remote_services_[_service][_instance][_reliable] = its_endpoint; + service_instances_[_service][its_endpoint.get()] = _unique; + remote_services_[_service][_unique][_reliable] = its_endpoint; partition_id_t its_partition - = configuration_->get_partition_id(_service, _instance); + = configuration_->get_partition_id(_service, _unique); client_endpoints_[its_endpoint_def->get_address()] [its_endpoint_def->get_port()] [_reliable] [its_partition]= its_endpoint; // Set the basic route to the service in the service info - auto found_service_info = rm_->find_service(_service, _instance); + auto found_service_info = rm_->find_service(_service, _unique); if (found_service_info) { found_service_info->set_endpoint(its_endpoint, _reliable); } diff --git a/implementation/endpoints/src/server_endpoint_impl.cpp b/implementation/endpoints/src/server_endpoint_impl.cpp index b9311f2f6..43bc9a89e 100644 --- a/implementation/endpoints/src/server_endpoint_impl.cpp +++ b/implementation/endpoints/src/server_endpoint_impl.cpp @@ -361,7 +361,7 @@ bool server_endpoint_impl::send_intern(endpoint_type _target, const by template bool server_endpoint_impl::tp_segmentation_enabled(service_t /*_service*/, - instance_t /*_instance*/, + unique_version_t /*_instance*/, method_t /*_method*/) const { return false; @@ -453,15 +453,15 @@ typename endpoint_impl::cms_ret_e server_endpoint_impl::chec const service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); const method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); - instance_t its_instance = this->get_instance(its_service); + unique_version_t its_unique = this->get_unique(its_service); - if (its_instance != ANY_INSTANCE) { - if (tp_segmentation_enabled(its_service, its_instance, its_method)) { + if (get_instance_from_unique(its_unique) != ANY_INSTANCE) { + if (tp_segmentation_enabled(its_service, its_unique, its_method)) { std::uint16_t its_max_segment_length; std::uint32_t its_separation_time; this->configuration_->get_tp_configuration( - its_service, its_instance, its_method, false, its_max_segment_length, + its_service, its_unique, its_method, false, its_max_segment_length, its_separation_time); send_segments(tp::tp::tp_split_message(_data, _size, its_max_segment_length), its_separation_time, _target); diff --git a/implementation/endpoints/src/udp_client_endpoint_impl.cpp b/implementation/endpoints/src/udp_client_endpoint_impl.cpp index 890c2082d..7ba1d13a3 100644 --- a/implementation/endpoints/src/udp_client_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_client_endpoint_impl.cpp @@ -651,9 +651,9 @@ void udp_client_endpoint_impl::send_cbk(boost::system::error_code const &_error, } bool udp_client_endpoint_impl::tp_segmentation_enabled( - service_t _service, instance_t _instance, method_t _method) const { + service_t _service, unique_version_t _unique, method_t _method) const { - return configuration_->is_tp_client(_service, _instance, _method); + return configuration_->is_tp_client(_service, _unique, _method); } bool udp_client_endpoint_impl::is_reliable() const { diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index f614da45c..137f61e96 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -582,10 +582,10 @@ void udp_server_endpoint_impl::on_message_received(boost::system::error_code con if (tp::tp::tp_flag_is_set(_buffer[i + VSOMEIP_MESSAGE_TYPE_POS])) { const method_t its_method = bithelper::read_uint16_be(&_buffer[i + VSOMEIP_METHOD_POS_MIN]); - instance_t its_instance = this->get_instance(its_service); + unique_version_t its_unique = this->get_unique(its_service); - if (its_instance != ANY_INSTANCE) { - if (!tp_segmentation_enabled(its_service, its_instance, its_method)) { + if (get_instance_from_unique(its_unique) != ANY_INSTANCE) { + if (!tp_segmentation_enabled(its_service, its_unique, its_method)) { VSOMEIP_WARNING << "use: Received a SomeIP/TP message for service: 0x" << std::hex << its_service << " method: 0x" << its_method @@ -733,10 +733,10 @@ std::string udp_server_endpoint_impl::get_address_port_local() const { return its_address_port; } -bool udp_server_endpoint_impl::tp_segmentation_enabled(service_t _service, instance_t _instance, +bool udp_server_endpoint_impl::tp_segmentation_enabled(service_t _service, unique_version_t _unique, method_t _method) const { - return configuration_->is_tp_service(_service, _instance, _method); + return configuration_->is_tp_service(_service, _unique, _method); } void udp_server_endpoint_impl::set_multicast_option(const boost::asio::ip::address& _address, diff --git a/implementation/protocol/include/command.hpp b/implementation/protocol/include/command.hpp index ccb8bdf28..0ce8e1ac3 100644 --- a/implementation/protocol/include/command.hpp +++ b/implementation/protocol/include/command.hpp @@ -22,6 +22,7 @@ class command { public: inline id_e get_id() const { return id_; } inline version_t get_version() const { return version_; } + inline void set_version(version_t _version) { version_ = _version; } inline client_t get_client() const { return client_; } inline void set_client(client_t _client) { client_ = _client; } inline command_size_t get_size() const { return size_; } diff --git a/implementation/routing/include/routing_manager.hpp b/implementation/routing/include/routing_manager.hpp index 58f38ca4b..832e66049 100644 --- a/implementation/routing/include/routing_manager.hpp +++ b/implementation/routing/include/routing_manager.hpp @@ -51,34 +51,34 @@ class routing_manager { virtual void stop() = 0; virtual bool offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, + unique_version_t _unique, 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, + unique_version_t _unique, 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, + unique_version_t _unique, major_version_t _major, minor_version_t _minor) = 0; virtual void release_service(client_t _client, service_t _service, - instance_t _instance) = 0; + unique_version_t _unique) = 0; virtual void subscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter) = 0; virtual void unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) = 0; virtual bool send(client_t _client, std::shared_ptr _message, bool _force) = 0; virtual bool send(client_t _client, const byte_t *_data, uint32_t _size, - instance_t _instance, bool _reliable, + unique_version_t _unique, bool _reliable, client_t _bound_client = VSOMEIP_ROUTING_CLIENT, const vsomeip_sec_client_t *_sec_client = nullptr, uint8_t _status_check = 0, @@ -90,10 +90,10 @@ class routing_manager { std::shared_ptr _message) = 0; virtual bool send_to(const std::shared_ptr &_target, - const byte_t *_data, uint32_t _size, instance_t _instance) = 0; + const byte_t *_data, uint32_t _size, unique_version_t _unique) = 0; virtual void register_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, const event_type_e _type, @@ -105,19 +105,19 @@ class routing_manager { 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; + unique_version_t _unique, event_t _event, bool _is_provided) = 0; virtual std::shared_ptr find_event(service_t _service, - instance_t _instance, event_t _event) const = 0; + unique_version_t _unique, event_t _event) const = 0; virtual std::set> find_events(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) const = 0; + unique_version_t _unique, eventgroup_t _eventgroup) const = 0; - virtual void notify(service_t _service, instance_t _instance, + virtual void notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force) = 0; - virtual void notify_one(service_t _service, instance_t _instance, + virtual void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force #ifdef VSOMEIP_ENABLE_COMPAT diff --git a/implementation/routing/include/routing_manager_base.hpp b/implementation/routing/include/routing_manager_base.hpp index 9d6fbd03c..855c0f53a 100644 --- a/implementation/routing/include/routing_manager_base.hpp +++ b/implementation/routing/include/routing_manager_base.hpp @@ -74,22 +74,22 @@ class routing_manager_base : public routing_manager, void init(const std::shared_ptr& _endpoint_manager); virtual bool offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); virtual void stop_offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); virtual void request_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); virtual void release_service(client_t _client, - service_t _service, instance_t _instance); + service_t _service, unique_version_t _unique); virtual void register_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, const event_type_e _type, reliability_type_e _reliability, @@ -99,27 +99,27 @@ class routing_manager_base : public routing_manager, bool _is_cache_placeholder = false); virtual void unregister_event(client_t _client, - service_t _service, instance_t _instance, event_t _event, + service_t _service, unique_version_t _unique, event_t _event, bool _is_provided); virtual std::set> find_events(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) const; + unique_version_t _unique, eventgroup_t _eventgroup) const; virtual void subscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter); virtual void unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); - virtual void notify(service_t _service, instance_t _instance, + virtual void notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force); - virtual void notify_one(service_t _service, instance_t _instance, + virtual void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force #ifdef VSOMEIP_ENABLE_COMPAT @@ -131,7 +131,7 @@ class routing_manager_base : public routing_manager, bool _force); virtual bool send(client_t _client, const byte_t *_data, uint32_t _size, - instance_t _instance, bool _reliable, + unique_version_t _unique, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check, bool _sent_from_remote, bool _force) = 0; @@ -152,14 +152,14 @@ class routing_manager_base : public routing_manager, virtual void send_get_offered_services_info(client_t _client, offer_type_e _offer_type) = 0; - std::set find_local_clients(service_t _service, instance_t _instance); + std::set find_local_clients(service_t _service, unique_version_t _unique); - std::shared_ptr find_service(service_t _service, instance_t _instance) const; + std::shared_ptr find_service(service_t _service, unique_version_t _unique) const; - client_t find_local_client(service_t _service, instance_t _instance) const; - client_t find_local_client_unlocked(service_t _service, instance_t _instance) const; + client_t find_local_client(service_t _service, unique_version_t _unique) const; + client_t find_local_client_unlocked(service_t _service, unique_version_t _unique) const; - std::shared_ptr find_event(service_t _service, instance_t _instance, + std::shared_ptr find_event(service_t _service, unique_version_t _unique, event_t _event) const; // address data for vsomeip routing via TCP @@ -177,41 +177,41 @@ class routing_manager_base : public routing_manager, virtual void on_disconnect(const std::shared_ptr& _endpoint) = 0; protected: std::shared_ptr create_service_info(service_t _service, - instance_t _instance, major_version_t _major, + unique_version_t _unique, 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); + void clear_service_info(service_t _service, unique_version_t _unique, bool _reliable); services_t get_services() const; services_t get_services_remote() const; - virtual bool is_available(service_t _service, instance_t _instance, + virtual bool is_available(service_t _service, unique_version_t _unique, major_version_t _major) const; void remove_local(client_t _client, bool _remove_sec_client); void remove_local(client_t _client, const std::set< - std::tuple + std::tuple > &_subscribed_eventgroups, bool _remove_sec_client); std::set > find_eventgroups(service_t _service, - instance_t _instance) const; + unique_version_t _unique) const; std::shared_ptr find_eventgroup(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) const; + unique_version_t _unique, eventgroup_t _eventgroup) const; - void remove_eventgroup_info(service_t _service, instance_t _instance, + void remove_eventgroup_info(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup); bool send_local_notification(client_t _client, - const byte_t *_data, uint32_t _size, instance_t _instance, + const byte_t *_data, uint32_t _size, unique_version_t _unique, bool _reliable, uint8_t _status_check, bool _force); bool send_local( std::shared_ptr &_target, client_t _client, - const byte_t *_data, uint32_t _size, instance_t _instance, + const byte_t *_data, uint32_t _size, unique_version_t _unique, bool _reliable, protocol::id_e _command, uint8_t _status_check) const; - bool insert_subscription(service_t _service, instance_t _instance, + bool insert_subscription(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, const std::shared_ptr &_filter, client_t _client, std::set *_already_subscribed_events); @@ -227,53 +227,53 @@ class routing_manager_base : public routing_manager, instance_t _instance, major_version_t _major); virtual void send_subscribe(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter) = 0; - void remove_pending_subscription(service_t _service, instance_t _instance, + void remove_pending_subscription(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); #ifdef VSOMEIP_ENABLE_COMPAT - void send_pending_notify_ones(service_t _service, instance_t _instance, + void send_pending_notify_ones(service_t _service, unique_version_t _unique, 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, + void unset_all_eventpayloads(service_t _service, unique_version_t _unique); + void unset_all_eventpayloads(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup); void notify_one_current_value(client_t _client, service_t _service, - instance_t _instance, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, const std::set &_events_to_exclude); - std::set> + std::set> get_subscriptions(const client_t _client); - std::vector find_events(service_t _service, instance_t _instance) const; + std::vector find_events(service_t _service, unique_version_t _unique) const; bool is_response_allowed(client_t _sender, service_t _service, - instance_t _instance, method_t _method); + unique_version_t _unique, method_t _method); bool is_subscribe_to_any_event_allowed( const vsomeip_sec_client_t *_sec_client, client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup); + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup); void add_known_client(client_t _client, const std::string &_client_host); #ifdef VSOMEIP_ENABLE_COMPAT - void set_incoming_subscription_state(client_t _client, service_t _service, instance_t _instance, + void set_incoming_subscription_state(client_t _client, service_t _service, unique_version_t _unique _unique, eventgroup_t _eventgroup, event_t _event, subscription_state_e _state); - subscription_state_e get_incoming_subscription_state(client_t _client, service_t _service, instance_t _instance, + subscription_state_e get_incoming_subscription_state(client_t _client, service_t _service, unique_version_t _unique _unique, eventgroup_t _eventgroup, event_t _event); - void erase_incoming_subscription_state(client_t _client, service_t _service, instance_t _instance, + void erase_incoming_subscription_state(client_t _client, service_t _service, unique_version_t _unique _unique, eventgroup_t _eventgroup, event_t _event); #endif private: virtual bool create_placeholder_event_and_subscribe( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, const std::shared_ptr &_filter, client_t _client) = 0; @@ -292,20 +292,20 @@ class routing_manager_base : public routing_manager, std::condition_variable deserializer_condition_; mutable std::mutex local_services_mutex_; - typedef std::map>> local_services_map_t; local_services_map_t local_services_; - std::map > > local_services_history_; + std::map > > local_services_history_; // Eventgroups mutable std::mutex eventgroups_mutex_; std::map > > > eventgroups_; // Events (part of one or more eventgroups) mutable std::mutex events_mutex_; std::map > > > events_; @@ -370,13 +370,13 @@ class routing_manager_base : public routing_manager, #ifdef VSOMEIP_ENABLE_COMPAT std::map > > > pending_notify_ones_; std::recursive_mutex pending_notify_ones_mutex_; std::map > > > > incoming_subscription_state_; diff --git a/implementation/routing/include/routing_manager_client.hpp b/implementation/routing/include/routing_manager_client.hpp index 28cf11ddb..0a8f2c96b 100644 --- a/implementation/routing/include/routing_manager_client.hpp +++ b/implementation/routing/include/routing_manager_client.hpp @@ -50,31 +50,31 @@ class routing_manager_client std::string get_env_unlocked(client_t _client) const; bool offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); void stop_offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); void request_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); void release_service(client_t _client, - service_t _service, instance_t _instance); + service_t _service, unique_version_t _unique); void subscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter); void unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); bool send(client_t _client, const byte_t *_data, uint32_t _size, - instance_t _instance, bool _reliable, + unique_version_t _unique, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check, bool _sent_from_remote, bool _force); @@ -84,10 +84,10 @@ class routing_manager_client std::shared_ptr _message); bool send_to(const std::shared_ptr &_target, - const byte_t *_data, uint32_t _size, instance_t _instance); + const byte_t *_data, uint32_t _size, unique_version_t _unique); void register_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, const event_type_e _type, @@ -98,7 +98,7 @@ class routing_manager_client bool _is_provided, bool _is_shadow, bool _is_cache_placeholder); void unregister_event(client_t _client, service_t _service, - instance_t _instance, event_t _notifier, bool _is_provided); + unique_version_t _unique, event_t _notifier, bool _is_provided); void on_connect(const std::shared_ptr& _endpoint); void on_disconnect(const std::shared_ptr& _endpoint); @@ -132,54 +132,54 @@ class routing_manager_client minor_version_t _minor); void send_release_service(client_t _client, - service_t _service, instance_t _instance); + service_t _service, unique_version_t _unique); void send_pending_event_registrations(client_t _client); void send_register_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, const event_type_e _type, reliability_type_e _reliability, bool _is_provided, bool _is_cyclic); void send_subscribe(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter); void send_subscribe_nack(client_t _subscriber, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _id); void send_subscribe_ack(client_t _subscriber, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _id); - bool is_field(service_t _service, instance_t _instance, + bool is_field(service_t _service, unique_version_t _unique, event_t _event) const; void on_subscribe_nack(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event); + unique_version_t _unique, 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); + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); - void cache_event_payload(const std::shared_ptr &_message); + void cache_event_payload(const std::shared_ptr &_message, major_version_t _major); - void on_stop_offer_service(service_t _service, instance_t _instance, + void on_stop_offer_service(service_t _service, unique_version_t _unique, 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, + void notify_remote_initially(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, const std::set &_events_to_exclude); - uint32_t get_remote_subscriber_count(service_t _service, instance_t _instance, + uint32_t get_remote_subscriber_count(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, bool _increment); - void clear_remote_subscriber_count(service_t _service, instance_t _instance); + void clear_remote_subscriber_count(service_t _service, unique_version_t _unique); void assign_client_timeout_cbk(boost::system::error_code const &_error); @@ -194,7 +194,7 @@ class routing_manager_client bool is_client_known(client_t _client); bool create_placeholder_event_and_subscribe( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _notifier, const std::shared_ptr &_filter, client_t _client); @@ -202,7 +202,7 @@ class routing_manager_client void send_request_services(const std::set &_requests); - void send_unsubscribe_ack(service_t _service, instance_t _instance, + void send_unsubscribe_ack(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, remote_subscription_id_t _id); void resend_provided_event_registrations(); @@ -246,7 +246,7 @@ class routing_manager_client struct event_data_t { service_t service_; - instance_t instance_; + unique_version_t unique_; event_t notifier_; event_type_e type_; reliability_type_e reliability_; @@ -255,9 +255,9 @@ class routing_manager_client std::set eventgroups_; bool operator<(const event_data_t &_other) const { - return std::tie(service_, instance_, notifier_, + return std::tie(service_, unique_, notifier_, type_, reliability_, is_provided_, is_cyclic_, eventgroups_) - < std::tie(_other.service_, _other.instance_, + < std::tie(_other.service_, _other.unique_, _other.notifier_, _other.type_, _other.reliability_, _other.is_provided_, _other.is_cyclic_, _other.eventgroups_); } @@ -272,7 +272,7 @@ class routing_manager_client std::condition_variable state_condition_; std::map > > remote_subscriber_count_; + std::map > > remote_subscriber_count_; std::mutex remote_subscriber_count_mutex_; mutable std::mutex sender_mutex_; diff --git a/implementation/routing/include/routing_manager_host.hpp b/implementation/routing/include/routing_manager_host.hpp index ec9788b2d..f314410cf 100644 --- a/implementation/routing/include/routing_manager_host.hpp +++ b/implementation/routing/include/routing_manager_host.hpp @@ -39,16 +39,16 @@ class routing_manager_host { minor_version_t _minor = DEFAULT_MINOR) = 0; virtual void on_state(state_type_e _state) = 0; virtual void on_message(std::shared_ptr &&_message) = 0; - virtual void on_subscription(service_t _service, instance_t _instance, + virtual void on_subscription(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, client_t _client, const vsomeip_sec_client_t *_sec_client, const std::string &_env, bool _subscribed, const std::function &_accepted_cb) = 0; - virtual void on_subscription_status(service_t _service, instance_t _instance, + virtual void on_subscription_status(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, uint16_t _error) = 0; virtual void send(std::shared_ptr _message) = 0; virtual void on_offered_services_info( - std::vector> &_services) = 0; + std::vector> &_services) = 0; virtual bool is_routing() const = 0; }; diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp index b62cc4bc6..45215768f 100644 --- a/implementation/routing/include/routing_manager_impl.hpp +++ b/implementation/routing/include/routing_manager_impl.hpp @@ -66,34 +66,34 @@ class routing_manager_impl: public routing_manager_base, void stop(); bool offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); void stop_offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); void request_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); void release_service(client_t _client, - service_t _service, instance_t _instance); + service_t _service, unique_version_t _unique); void subscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter); void unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); bool send(client_t _client, std::shared_ptr _message, bool _force); bool send(client_t _client, const byte_t *_data, uint32_t _size, - instance_t _instance, bool _reliable, + unique_version_t _unique, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check, bool _sent_from_remote, bool _force); @@ -104,13 +104,13 @@ class routing_manager_impl: public routing_manager_base, bool send_to(const std::shared_ptr &_target, const byte_t *_data, uint32_t _size, - instance_t _instance); + unique_version_t _unique); bool send_via_sd(const std::shared_ptr &_target, const byte_t *_data, uint32_t _size, uint16_t _sd_port); void register_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, const event_type_e _type, @@ -121,17 +121,17 @@ class routing_manager_impl: public routing_manager_base, bool _is_provided, bool _is_shadow, bool _is_cache_placeholder); void register_shadow_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, event_type_e _type, reliability_type_e _reliability, bool _is_provided, bool _is_cyclic); void unregister_shadow_event(client_t _client, service_t _service, - instance_t _instance, event_t _event, + unique_version_t _unique, event_t _event, bool _is_provided); - void notify_one(service_t _service, instance_t _instance, + void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force #ifdef VSOMEIP_ENABLE_COMPAT @@ -140,11 +140,11 @@ class routing_manager_impl: public routing_manager_base, ); void on_subscribe_ack(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _id); void on_subscribe_nack(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, bool _remove, remote_subscription_id_t _id); @@ -158,11 +158,11 @@ class routing_manager_impl: public routing_manager_base, } std::shared_ptr find_or_create_remote_client( - service_t _service, instance_t _instance, bool _reliable); + service_t _service, unique_version_t _unique, bool _reliable); void remove_local(client_t _client, bool _remove_uid); void on_stop_offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); void on_availability(service_t _service, instance_t _instance, @@ -172,11 +172,11 @@ class routing_manager_impl: public routing_manager_base, void on_pong(client_t _client); void on_subscribe_ack_with_multicast( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const boost::asio::ip::address &_sender, 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, + unique_version_t _unique, eventgroup_t _eventgroup, remote_subscription_id_t _id); void on_connect(const std::shared_ptr& _endpoint); @@ -187,29 +187,29 @@ class routing_manager_impl: public routing_manager_base, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, const boost::asio::ip::address &_remote_address, std::uint16_t _remote_port); - bool on_message(service_t _service, instance_t _instance, + bool on_message(service_t _service, unique_version_t _unique, const byte_t *_data, length_t _size, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, 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, + unique_version_t _unique, const byte_t *_data, length_t _size, bool _notify_one); - bool offer_service_remotely(service_t _service, instance_t _instance, + bool offer_service_remotely(service_t _service, unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled); - bool stop_offer_service_remotely(service_t _service, instance_t _instance, + bool stop_offer_service_remotely(service_t _service, unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled); // interface "service_discovery_host" std::shared_ptr find_eventgroup(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) const; + unique_version_t _unique, eventgroup_t _eventgroup) const; services_t get_offered_services() const; std::shared_ptr get_offered_service( - service_t _service, instance_t _instance) const; - std::map> get_offered_service_instances( + service_t _service, unique_version_t _unique) const; + std::map> get_offered_service_instances( service_t _service) const; std::shared_ptr create_service_discovery_endpoint(const std::string &_address, @@ -221,7 +221,7 @@ class routing_manager_impl: public routing_manager_base, 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, + void del_routing_info(service_t _service, unique_version_t _unique, bool _has_reliable, bool _has_unreliable); void update_routing_info(std::chrono::milliseconds _elapsed); @@ -259,7 +259,7 @@ class routing_manager_impl: public routing_manager_base, (void) _offer_type; } - void send_initial_events(service_t _service, instance_t _instance, + void send_initial_events(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, const std::shared_ptr &_subscriber); @@ -270,11 +270,11 @@ class routing_manager_impl: public routing_manager_base, 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, + void service_endpoint_connected(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, const std::shared_ptr& _endpoint, bool _unreliable_only); - void service_endpoint_disconnected(service_t _service, instance_t _instance, + void service_endpoint_disconnected(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, const std::shared_ptr& _endpoint); @@ -287,11 +287,11 @@ class routing_manager_impl: public routing_manager_base, bool _reliable); void on_resend_provided_events_response(pending_remote_offer_id_t _id); - client_t find_local_client(service_t _service, instance_t _instance); - std::set find_local_clients(service_t _service, instance_t _instance); + client_t find_local_client(service_t _service, unique_version_t _unique); + std::set find_local_clients(service_t _service, unique_version_t _unique); bool is_subscribe_to_any_event_allowed( const vsomeip_sec_client_t *_sec_client, client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup); + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup); #ifndef VSOMEIP_DISABLE_SECURITY bool update_security_policy_configuration(uid_t _uid, gid_t _gid, @@ -313,17 +313,17 @@ class routing_manager_impl: public routing_manager_base, std::vector get_requested_services(client_t _client) const; - virtual bool is_available(service_t _service, instance_t _instance, + virtual bool is_available(service_t _service, unique_version_t _unique, major_version_t _major) const; private: bool offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, bool _must_queue); void stop_offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, bool _must_queue); @@ -331,51 +331,51 @@ class routing_manager_impl: public routing_manager_base, instance_t _instance, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check = 0, bool _is_from_remote = false); - bool deliver_notification(service_t _service, instance_t _instance, + bool deliver_notification(service_t _service, unique_version_t _unique, const byte_t *_data, length_t _length, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check = 0, bool _is_from_remote = false); - bool is_suppress_event(service_t _service, instance_t _instance, + bool is_suppress_event(service_t _service, unique_version_t _unique, event_t _event) const; void init_service_info(service_t _service, - instance_t _instance, bool _is_local_service); + unique_version_t _unique, bool _is_local_service); - bool is_field(service_t _service, instance_t _instance, + bool is_field(service_t _service, unique_version_t _unique, event_t _event) const; std::shared_ptr find_remote_client(service_t _service, - instance_t _instance, bool _reliable, client_t _client); + unique_version_t _unique, bool _reliable, client_t _client); std::shared_ptr create_remote_client(service_t _service, - instance_t _instance, bool _reliable, client_t _client); + unique_version_t _unique, bool _reliable, client_t _client); - void clear_client_endpoints(service_t _service, instance_t _instance, bool _reliable); - void clear_multicast_endpoints(service_t _service, instance_t _instance); + void clear_client_endpoints(service_t _service, unique_version_t _unique, bool _reliable); + void clear_multicast_endpoints(service_t _service, unique_version_t _unique); std::set get_subscribed_eventgroups(service_t _service, - instance_t _instance); + unique_version_t _unique); - void clear_targets_and_pending_sub_from_eventgroups(service_t _service, instance_t _instance); - void clear_remote_subscriber(service_t _service, instance_t _instance); + void clear_targets_and_pending_sub_from_eventgroups(service_t _service, unique_version_t _unique); + void clear_remote_subscriber(service_t _service, unique_version_t _unique); return_code_e check_error(const byte_t *_data, length_t _size, - instance_t _instance); + unique_version_t _unique); - bool supports_selective(service_t _service, instance_t _instance); + bool supports_selective(service_t _service, unique_version_t _unique); - void clear_remote_subscriber(service_t _service, instance_t _instance, + void clear_remote_subscriber(service_t _service, unique_version_t _unique, client_t _client, const std::shared_ptr &_target); void log_version_timer_cbk(boost::system::error_code const & _error); bool handle_local_offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major,minor_version_t _minor); + unique_version_t _unique, major_version_t _major,minor_version_t _minor); void send_subscribe(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter); @@ -402,35 +402,35 @@ class routing_manager_impl: public routing_manager_base, minor_version_t _minor); void call_sd_endpoint_connected(const boost::system::error_code &_error, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const std::shared_ptr &_endpoint, std::shared_ptr _timer); bool create_placeholder_event_and_subscribe( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, const std::shared_ptr &_filter, client_t _client); - void handle_subscription_state(client_t _client, service_t _service, instance_t _instance, + void handle_subscription_state(client_t _client, service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); 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(const client_t _offering_client, - const service_t _service, const instance_t _instance, + const service_t _service, const unique_version_t _unique, const eventgroup_t _eventgroup, const major_version_t _major, const std::set &_clients, const remote_subscription_id_t _id); void send_unsubscription(client_t _offering_client, - const service_t _service, const instance_t _instance, + const service_t _service, const unique_version_t _unique, const eventgroup_t _eventgroup, const major_version_t _major, const std::set &_removed, const remote_subscription_id_t _id); void send_expired_subscription(client_t _offering_client, - const service_t _service, const instance_t _instance, + const service_t _service, const unique_version_t _unique, const eventgroup_t _eventgroup, const std::set &_removed, const remote_subscription_id_t _id); @@ -439,18 +439,18 @@ class routing_manager_impl: public routing_manager_base, const std::shared_ptr& _endpoint); pending_remote_offer_id_t pending_remote_offer_add(service_t _service, - instance_t _instance); - std::pair pending_remote_offer_remove( + unique_version_t _unique); + std::pair pending_remote_offer_remove( pending_remote_offer_id_t _id); - bool insert_offer_command(service_t _service, instance_t _instance, uint8_t _command, + bool insert_offer_command(service_t _service, unique_version_t _unique, uint8_t _command, client_t _client, major_version_t _major, minor_version_t _minor); - bool erase_offer_command(service_t _service, instance_t _instance); + bool erase_offer_command(service_t _service, unique_version_t _unique); std::string get_env(client_t _client) const; std::string get_env_unlocked(client_t _client) const; - bool insert_event_statistics(service_t _service, instance_t _instance, + bool insert_event_statistics(service_t _service, unique_version_t _unique, method_t _method, length_t _length); void statistics_log_timer_cbk(boost::system::error_code const & _error); @@ -465,12 +465,12 @@ class routing_manager_impl: public routing_manager_base, void clear_local_services(); bool is_acl_message_allowed(endpoint *_receiver, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const boost::asio::ip::address &_remote_address) const; #ifdef VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING bool has_subscribed_eventgroup( - service_t _service, instance_t _instance) const; + service_t _service, unique_version_t _unique) const; #endif // VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING private: @@ -488,7 +488,7 @@ class routing_manager_impl: public routing_manager_base, std::mutex remote_subscribers_mutex_; std::map > > @@ -504,7 +504,7 @@ class routing_manager_impl: public routing_manager_base, bool sd_route_set_; bool routing_running_; std::mutex pending_sd_offers_mutex_; - std::vector> pending_sd_offers_; + std::vector> pending_sd_offers_; #if defined(__linux__) || defined(ANDROID) std::shared_ptr netlink_connector_; #endif @@ -514,14 +514,14 @@ class routing_manager_impl: public routing_manager_base, // 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>> pending_offers_; std::mutex pending_subscription_mutex_; std::mutex remote_subscription_state_mutex_; - std::map, + std::map, subscription_state_e> remote_subscription_state_; std::shared_ptr e2e_provider_; @@ -541,12 +541,12 @@ class routing_manager_impl: public routing_manager_base, std::mutex pending_remote_offers_mutex_; pending_remote_offer_id_t pending_remote_offer_id_; - std::map> pending_remote_offers_; + std::map> pending_remote_offers_; std::chrono::steady_clock::time_point last_resume_; std::mutex offer_serialization_mutex_; - std::map, std::deque>> offer_commands_; + std::map, std::deque>> offer_commands_; std::mutex callback_counts_mutex_; std::map callback_counts_; @@ -555,9 +555,9 @@ class routing_manager_impl: public routing_manager_base, boost::asio::steady_timer statistics_log_timer_; std::mutex message_statistics_mutex_; - std::map, + std::map, msg_statistic_t> message_statistics_; - std::tuple message_to_discard_; + std::tuple message_to_discard_; uint32_t ignored_statistics_counter_; // synchronize update_remote_subscription() and send_(un)subscription() diff --git a/implementation/routing/include/routing_manager_stub.hpp b/implementation/routing/include/routing_manager_stub.hpp index c419a4dd9..d7b4a2318 100644 --- a/implementation/routing/include/routing_manager_stub.hpp +++ b/implementation/routing/include/routing_manager_stub.hpp @@ -58,9 +58,9 @@ class routing_manager_stub: public routing_host, std::uint16_t _remote_port); void on_offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, minor_version_t _minor); + unique_version_t _unique, 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); + unique_version_t _unique, major_version_t _major, minor_version_t _minor); bool send_subscribe( const std::shared_ptr &_target, client_t _client, @@ -71,22 +71,22 @@ class routing_manager_stub: public routing_host, bool send_unsubscribe(const std::shared_ptr& _target, client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _id); bool send_expired_subscription(const std::shared_ptr& _target, client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, 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); + unique_version_t _unique, 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); + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); bool contained_in_routing_info(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, + unique_version_t _unique, major_version_t _major, minor_version_t _minor) const; void create_local_receiver(); @@ -150,10 +150,10 @@ class routing_manager_stub: public routing_host, void on_offered_service_request(client_t _client, offer_type_e _offer_type); - void distribute_credentials(client_t _hoster, service_t _service, instance_t _instance); + void distribute_credentials(client_t _hoster, service_t _service, unique_version_t _unique); void inform_requesters(client_t _hoster, service_t _service, - instance_t _instance, major_version_t _major, + unique_version_t _unique, major_version_t _major, minor_version_t _minor, protocol::routing_info_entry_type_e _entry, bool _inform_service); @@ -250,7 +250,7 @@ class routing_manager_stub: public routing_host, std::mutex local_receiver_mutex_; std::map> > > > routing_info_; + std::pair> > > > routing_info_; mutable std::mutex routing_info_mutex_; std::shared_ptr configuration_; @@ -268,7 +268,7 @@ class routing_manager_stub: public routing_host, std::mutex pinged_clients_mutex_; std::map pinged_clients_; - std::map > > > service_requests_; + std::map > > > service_requests_; std::map> connection_matrix_; std::mutex pending_security_updates_mutex_; diff --git a/implementation/routing/include/routing_manager_stub_host.hpp b/implementation/routing/include/routing_manager_stub_host.hpp index de6a0ddf8..b4461acf6 100644 --- a/implementation/routing/include/routing_manager_stub_host.hpp +++ b/implementation/routing/include/routing_manager_stub_host.hpp @@ -22,61 +22,61 @@ class routing_manager_stub_host { } virtual bool offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, + unique_version_t _unique, major_version_t _major, 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, + unique_version_t _unique, major_version_t _major, 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, + unique_version_t _unique, major_version_t _major, minor_version_t _minor) = 0; virtual void release_service(client_t _client, service_t _service, - instance_t _instance) = 0; + unique_version_t _unique) = 0; virtual void register_shadow_event(client_t _client, service_t _service, - instance_t _instance, event_t _notifier, + unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, event_type_e _type, reliability_type_e _reliability, bool _is_provided, bool _is_cyclic) = 0; virtual void unregister_shadow_event(client_t _client, service_t _service, - instance_t _instance, event_t _event, bool _is_provided) = 0; + unique_version_t _unique, event_t _event, bool _is_provided) = 0; virtual void subscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter) = 0; virtual void on_subscribe_ack(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _subscription_id) = 0; virtual void on_subscribe_nack(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, bool _remove, remote_subscription_id_t _subscription_id) = 0; virtual void unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) = 0; virtual void on_unsubscribe_ack(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, remote_subscription_id_t _unsubscription_id) = 0; - virtual bool on_message(service_t _service, instance_t _instance, + virtual bool on_message(service_t _service, unique_version_t _unique, const byte_t *_data, length_t _size, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check = 0, bool _is_from_remote = false) = 0; virtual void on_notification(client_t _client, service_t _service, - instance_t _instance, const byte_t *_data, length_t _size, + unique_version_t _unique, 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, + unique_version_t _unique, major_version_t _major, minor_version_t _minor) = 0; virtual void on_availability(service_t _service, instance_t _instance, @@ -103,14 +103,14 @@ class routing_manager_stub_host { pending_remote_offer_id_t _id) = 0; virtual client_t find_local_client(service_t _service, - instance_t _instance) = 0; + unique_version_t _unique) = 0; virtual std::set find_local_clients(service_t _service, - instance_t _instance) = 0; + unique_version_t _unique) = 0; virtual bool is_subscribe_to_any_event_allowed( const vsomeip_sec_client_t *_sec_client, - client_t _client, service_t _service, instance_t _instance, + client_t _client, service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) = 0; virtual void add_known_client(client_t _client, @@ -130,7 +130,7 @@ class routing_manager_stub_host { virtual std::vector get_requested_services(client_t _client) const = 0; - virtual bool is_available(service_t _service, instance_t _instance, + virtual bool is_available(service_t _service, unique_version_t _unique, major_version_t _major) const = 0; }; diff --git a/implementation/routing/include/types.hpp b/implementation/routing/include/types.hpp index 3a955018a..7f3fd7d3f 100644 --- a/implementation/routing/include/types.hpp +++ b/implementation/routing/include/types.hpp @@ -20,13 +20,13 @@ class endpoint_definition; typedef std::map > > services_t; class eventgroupinfo; typedef std::map > > > eventgroups_t; diff --git a/implementation/routing/src/routing_manager_base.cpp b/implementation/routing/src/routing_manager_base.cpp index 229d7a223..476d2e5cf 100644 --- a/implementation/routing/src/routing_manager_base.cpp +++ b/implementation/routing/src/routing_manager_base.cpp @@ -221,12 +221,12 @@ void routing_manager_base::init(const std::shared_ptr& _e } bool routing_manager_base::offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { (void)_client; // Remote route (incoming only) - auto its_info = find_service(_service, _instance); + auto its_info = find_service(_service, _unique); if (its_info) { if (!its_info->is_local()) { return false; @@ -238,7 +238,7 @@ bool routing_manager_base::offer_service(client_t _client, << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << ":" + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << static_cast(its_info->get_major()) << ":" << its_info->get_minor() << "] passed: " @@ -247,7 +247,7 @@ bool routing_manager_base::offer_service(client_t _client, return false; } } else { - its_info = create_service_info(_service, _instance, _major, _minor, + its_info = create_service_info(_service, _unique, _major, _minor, DEFAULT_TTL, true); } { @@ -255,9 +255,9 @@ bool routing_manager_base::offer_service(client_t _client, // Set major version for all registered events of this service and instance const auto found_service = events_.find(_service); if (found_service != events_.end()) { - const auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - for (const auto &j : found_instance->second) { + const auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + for (const auto &j : found_unique->second) { j.second->set_version(_major); } } @@ -267,7 +267,7 @@ bool routing_manager_base::offer_service(client_t _client, } void routing_manager_base::stop_offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { (void)_client; (void)_major; @@ -278,9 +278,9 @@ void routing_manager_base::stop_offer_service(client_t _client, std::lock_guard its_lock(events_mutex_); auto its_events_service = events_.find(_service); if (its_events_service != events_.end()) { - auto its_events_instance = its_events_service->second.find(_instance); - if (its_events_instance != its_events_service->second.end()) { - for (auto &e : its_events_instance->second) + auto its_events_unique = its_events_service->second.find(_unique); + if (its_events_unique != its_events_service->second.end()) { + for (auto &e : its_events_unique->second) events[e.first] = e.second; } @@ -293,9 +293,9 @@ void routing_manager_base::stop_offer_service(client_t _client, } void routing_manager_base::request_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { - auto its_info = find_service(_service, _instance); + auto its_info = find_service(_service, _unique); if (its_info) { if ((_major == its_info->get_major() || DEFAULT_MAJOR == its_info->get_major() @@ -309,7 +309,7 @@ void routing_manager_base::request_service(client_t _client, << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << ":" + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << static_cast(its_info->get_major()) << ":" << its_info->get_minor() << "] passed: " @@ -320,8 +320,8 @@ void routing_manager_base::request_service(client_t _client, } void routing_manager_base::release_service(client_t _client, - service_t _service, instance_t _instance) { - auto its_info = find_service(_service, _instance); + service_t _service, unique_version_t _unique) { + auto its_info = find_service(_service, _unique); if (its_info) { its_info->remove_client(_client); } @@ -329,9 +329,9 @@ void routing_manager_base::release_service(client_t _client, std::lock_guard its_service_guard(local_services_mutex_); auto found_service = local_services_history_.find(_service); if (found_service != local_services_history_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - found_service->second.erase(_instance); + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + found_service->second.erase(_unique); if (found_service->second.empty()) { local_services_history_.erase(_service); } @@ -341,7 +341,7 @@ void routing_manager_base::release_service(client_t _client, } void routing_manager_base::register_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, const event_type_e _type, @@ -352,10 +352,10 @@ void routing_manager_base::register_event(client_t _client, bool _is_provided, bool _is_shadow, bool _is_cache_placeholder) { std::lock_guard its_registration_lock(event_registration_mutex_); - auto determine_event_reliability = [this, &_service, &_instance, + auto determine_event_reliability = [this, &_service, &_unique, &_notifier, &_reliability]() { reliability_type_e its_reliability = - configuration_->get_event_reliability(_service, _instance, _notifier); + configuration_->get_event_reliability(_service, _unique, _notifier); if (its_reliability != reliability_type_e::RT_UNKNOWN) { // event was explicitly configured -> overwrite value passed via API return its_reliability; @@ -363,11 +363,11 @@ void routing_manager_base::register_event(client_t _client, // use value provided via API return _reliability; } else { // automatic mode, user service' reliability - return configuration_->get_service_reliability(_service, _instance); + return configuration_->get_service_reliability(_service, _unique); } }; - std::shared_ptr its_event = find_event(_service, _instance, _notifier); + std::shared_ptr its_event = find_event(_service, _unique, _notifier); bool transfer_subscriptions_from_any_event(false); if (its_event) { if (!its_event->is_cache_placeholder()) { @@ -414,7 +414,7 @@ void routing_manager_base::register_event(client_t _client, its_event->set_reliability(determine_event_reliability()); its_event->set_provided(_is_provided); its_event->set_cache_placeholder(false); - std::shared_ptr its_service = find_service(_service, _instance); + std::shared_ptr its_service = find_service(_service, _unique); if (its_service) { its_event->set_version(its_service->get_major()); } @@ -435,13 +435,13 @@ void routing_manager_base::register_event(client_t _client, } else { its_event = std::make_shared(this, _is_shadow); its_event->set_service(_service); - its_event->set_instance(_instance); + its_event->set_instance(get_instance_from_unique(_unique)); its_event->set_event(_notifier); its_event->set_type(_type); its_event->set_reliability(determine_event_reliability()); its_event->set_provided(_is_provided); its_event->set_cache_placeholder(_is_cache_placeholder); - std::shared_ptr its_service = find_service(_service, _instance); + std::shared_ptr its_service = find_service(_service, _unique); if (its_service) { its_event->set_version(its_service->get_major()); } @@ -456,7 +456,7 @@ void routing_manager_base::register_event(client_t _client, if ((_is_shadow || is_routing_manager()) && !_epsilon_change_func) { std::shared_ptr its_debounce - = configuration_->get_debounce(host_->get_name(), _service, _instance, _notifier); + = configuration_->get_debounce(host_->get_name(), _service, _unique, _notifier); if (its_debounce) { std::stringstream its_debounce_parameters; its_debounce_parameters << "(on_change=" @@ -472,7 +472,7 @@ void routing_manager_base::register_event(client_t _client, << " SOME/IP event " << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _notifier << "." << " Debounce parameters: " << its_debounce_parameters.str(); @@ -571,7 +571,7 @@ void routing_manager_base::register_event(client_t _client, // was stored in the cache placeholder. Move the subscribers // into new event std::shared_ptr its_any_event = - find_event(_service, _instance, ANY_EVENT); + find_event(_service, _unique, ANY_EVENT); if (its_any_event) { std::set any_events_eventgroups = its_any_event->get_eventgroups(); @@ -593,25 +593,25 @@ void routing_manager_base::register_event(client_t _client, for (auto eg : _eventgroups) { std::shared_ptr its_eventgroupinfo - = find_eventgroup(_service, _instance, eg); + = find_eventgroup(_service, _unique, eg); if (!its_eventgroupinfo) { its_eventgroupinfo = std::make_shared(); its_eventgroupinfo->set_service(_service); - its_eventgroupinfo->set_instance(_instance); + its_eventgroupinfo->set_instance(get_instance_from_unique(_unique)); its_eventgroupinfo->set_eventgroup(eg); its_eventgroupinfo->set_max_remote_subscribers( configuration_->get_max_remote_subscribers()); std::lock_guard its_lock(eventgroups_mutex_); - eventgroups_[_service][_instance][eg] = its_eventgroupinfo; + eventgroups_[_service][_unique][eg] = its_eventgroupinfo; } its_eventgroupinfo->add_event(its_event); } std::lock_guard its_lock(events_mutex_); - events_[_service][_instance][_notifier] = its_event; + events_[_service][_unique][_notifier] = its_event; } -void routing_manager_base::unregister_event(client_t _client, service_t _service, instance_t _instance, +void routing_manager_base::unregister_event(client_t _client, service_t _service, unique_version_t _unique, event_t _event, bool _is_provided) { (void)_client; std::shared_ptr its_unrefed_event; @@ -619,15 +619,15 @@ void routing_manager_base::unregister_event(client_t _client, service_t _service std::lock_guard its_lock(events_mutex_); auto found_service = events_.find(_service); if (found_service != events_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_event = found_instance->second.find(_event); - if (found_event != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_event = found_unique->second.find(_event); + if (found_event != found_unique->second.end()) { auto its_event = found_event->second; its_event->remove_ref(_client, _is_provided); if (!its_event->has_ref()) { its_unrefed_event = its_event; - found_instance->second.erase(found_event); + found_unique->second.erase(found_event); } else if (_is_provided) { its_event->set_provided(false); } @@ -639,11 +639,11 @@ void routing_manager_base::unregister_event(client_t _client, service_t _service auto its_eventgroups = its_unrefed_event->get_eventgroups(); for (auto eg : its_eventgroups) { std::shared_ptr its_eventgroup_info - = find_eventgroup(_service, _instance, eg); + = find_eventgroup(_service, _unique, eg); if (its_eventgroup_info) { its_eventgroup_info->remove_event(its_unrefed_event); if (0 == its_eventgroup_info->get_events().size()) { - remove_eventgroup_info(_service, _instance, eg); + remove_eventgroup_info(_service, _unique, eg); } } } @@ -651,16 +651,16 @@ void routing_manager_base::unregister_event(client_t _client, service_t _service } std::set> routing_manager_base::find_events( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) const { std::lock_guard its_lock(eventgroups_mutex_); std::set > its_events; auto found_service = eventgroups_.find(_service); if (found_service != eventgroups_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_eventgroup = found_instance->second.find(_eventgroup); - if (found_eventgroup != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_eventgroup = found_unique->second.find(_eventgroup); + if (found_eventgroup != found_unique->second.end()) { return found_eventgroup->second->get_events(); } } @@ -669,14 +669,14 @@ std::set> routing_manager_base::find_events( } std::vector routing_manager_base::find_events( - service_t _service, instance_t _instance) const { + service_t _service, unique_version_t _unique) const { std::vector its_events; std::lock_guard its_lock(events_mutex_); const auto found_service = events_.find(_service); if (found_service != events_.end()) { - const auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - for (const auto& e : found_instance->second) { + const auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + for (const auto& e : found_unique->second) { its_events.push_back(e.first); } } @@ -685,7 +685,7 @@ std::vector routing_manager_base::find_events( } bool routing_manager_base::is_response_allowed(client_t _sender, service_t _service, - instance_t _instance, method_t _method) { + unique_version_t _unique, method_t _method) { if (!configuration_->is_security_enabled() || !configuration_->is_local_routing()) { @@ -694,17 +694,17 @@ bool routing_manager_base::is_response_allowed(client_t _sender, service_t _serv { std::lock_guard its_lock(local_services_mutex_); - if (_sender == find_local_client_unlocked(_service, _instance)) { + if (_sender == find_local_client_unlocked(_service, _unique)) { // sender is still offering the service return true; } auto found_service = local_services_history_.find(_service); if (found_service != local_services_history_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_client = found_instance->second.find(_sender); - if (found_client != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_client = found_unique->second.find(_sender); + if (found_client != found_unique->second.end()) { // sender was offering the service and is still connected return true; } @@ -723,7 +723,7 @@ bool routing_manager_base::is_response_allowed(client_t _sender, service_t _serv << " : routing_manager_base::is_response_allowed: " << "received a response from client 0x" << _sender << " which does not offer service/instance/method " - << _service << "/" << _instance << "/" << _method + << _service << "/" << get_instance_from_unique(_unique) << "/" << _method << security_mode_text; return !configuration_->is_security_audit(); @@ -731,19 +731,19 @@ bool routing_manager_base::is_response_allowed(client_t _sender, service_t _serv bool routing_manager_base::is_subscribe_to_any_event_allowed( const vsomeip_sec_client_t *_sec_client, client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup) { + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) { bool is_allowed(true); - auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); + auto its_eventgroup = find_eventgroup(_service, _unique, _eventgroup); if (its_eventgroup) { for (const auto& e : its_eventgroup->get_events()) { if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( - _sec_client, _service, _instance, e->get_event())) { + _sec_client, _service, get_instance_from_unique(_unique), e->get_event())) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << _client << " : routing_manager_base::is_subscribe_to_any_event_allowed: " << "subscribes to service/instance/event " - << _service << "/" << _instance << "/" << e->get_event() + << _service << "/" << get_instance_from_unique(_unique) << "/" << e->get_event() << " which violates the security policy!"; is_allowed = false; break; @@ -789,7 +789,7 @@ void routing_manager_base::add_known_client(client_t _client, const std::string void routing_manager_base::subscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter) { @@ -797,28 +797,28 @@ void routing_manager_base::subscribe(client_t _client, (void)_sec_client; std::set its_already_subscribed_events; - bool inserted = insert_subscription(_service, _instance, _eventgroup, + bool inserted = insert_subscription(_service, _unique, _eventgroup, _event, _filter, _client, &its_already_subscribed_events); if (inserted) { - notify_one_current_value(_client, _service, _instance, _eventgroup, + notify_one_current_value(_client, _service, _unique, _eventgroup, _event, its_already_subscribed_events); } } void routing_manager_base::unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { (void)_sec_client; if (_event != ANY_EVENT) { - auto its_event = find_event(_service, _instance, _event); + auto its_event = find_event(_service, _unique, _event); if (its_event) { its_event->remove_subscriber(_eventgroup, _client); } } else { - auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); + auto its_eventgroup = find_eventgroup(_service, _unique, _eventgroup); if (its_eventgroup) { for (const auto &e : its_eventgroup->get_events()) { if (e) @@ -828,28 +828,28 @@ void routing_manager_base::unsubscribe(client_t _client, } } -void routing_manager_base::notify(service_t _service, instance_t _instance, +void routing_manager_base::notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force) { - std::shared_ptr its_event = find_event(_service, _instance, _event); + std::shared_ptr its_event = find_event(_service, _unique, _event); if (its_event) { its_event->set_payload(_payload, _force); } else { VSOMEIP_WARNING << "Attempt to update the undefined event/field [" - << std::hex << _service << "." << _instance << "." << _event + << std::hex << _service << "." << get_instance_from_unique(_unique) << "." << _event << "]"; } } -void routing_manager_base::notify_one(service_t _service, instance_t _instance, +void routing_manager_base::notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force #ifdef VSOMEIP_ENABLE_COMPAT , bool _remote_subscriber #endif ) { - std::shared_ptr its_event = find_event(_service, _instance, _event); + std::shared_ptr its_event = find_event(_service, _unique, _event); if (its_event) { // Event is valid for service/instance bool found_eventgroup(false); @@ -861,14 +861,14 @@ void routing_manager_base::notify_one(service_t _service, instance_t _instance, // Iterate over all groups of the event to ensure at least // one valid eventgroup for service/instance exists. for (auto its_group : its_event->get_eventgroups()) { - auto its_eventgroup = find_eventgroup(_service, _instance, its_group); + auto its_eventgroup = find_eventgroup(_service, _unique, its_group); if (its_eventgroup) { // Eventgroup is valid for service/instance found_eventgroup = true; #ifdef VSOMEIP_ENABLE_COMPAT valid_group = its_group; its_subscription_state = get_incoming_subscription_state(_client, _service, - _instance, valid_group, _event); + _unique, valid_group, _event); #endif if (ep_mgr_->find_local(_client)) { already_subscribed = its_event->has_subscriber(its_group, _client); @@ -897,23 +897,23 @@ void routing_manager_base::notify_one(service_t _service, instance_t _instance, << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << valid_group << "." << std::setw(4) << _event << "]" << " insert pending notification!"; std::shared_ptr its_notification = runtime::get()->create_notification(); its_notification->set_service(_service); - its_notification->set_instance(_instance); + its_notification->set_instance(get_instance_from_unique(_unique)); its_notification->set_method(_event); its_notification->set_payload(_payload); - auto service_info = find_service(_service, _instance); + auto service_info = find_service(_service, _unique); if (service_info) { its_notification->set_interface_version(service_info->get_major()); } { std::lock_guard its_lock(pending_notify_ones_mutex_); - pending_notify_ones_[_service][_instance][valid_group] = its_notification; + pending_notify_ones_[_service][_unique][valid_group] = its_notification; } } } @@ -921,32 +921,32 @@ void routing_manager_base::notify_one(service_t _service, instance_t _instance, } } else { VSOMEIP_WARNING << "Attempt to update the undefined event/field [" - << std::hex << _service << "." << _instance << "." << _event + << std::hex << _service << "." << get_instance_from_unique(_unique) << "." << _event << "]"; } } #ifdef VSOMEIP_ENABLE_COMPAT -void routing_manager_base::send_pending_notify_ones(service_t _service, instance_t _instance, +void routing_manager_base::send_pending_notify_ones(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, client_t _client, bool _remote_subscriber) { std::lock_guard its_lock(pending_notify_ones_mutex_); auto its_service = pending_notify_ones_.find(_service); if (its_service != pending_notify_ones_.end()) { - auto its_instance = its_service->second.find(_instance); - if (its_instance != its_service->second.end()) { - auto its_group = its_instance->second.find(_eventgroup); - if (its_group != its_instance->second.end()) { + auto its_unique = its_service->second.find(_unique); + if (its_unique != its_service->second.end()) { + auto its_group = its_unique->second.find(_eventgroup); + if (its_group != its_unique->second.end()) { VSOMEIP_INFO << "routing_manager_base::send_pending_notify_ones(" << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "." << std::setw(4) << its_group->second->get_method() << "]"; - notify_one(_service, _instance, its_group->second->get_method(), + notify_one(_service, _unique, its_group->second->get_method(), its_group->second->get_payload(), _client, false, _remote_subscriber); - its_instance->second.erase(_eventgroup); + its_unique->second.erase(_eventgroup); } } } @@ -954,15 +954,15 @@ void routing_manager_base::send_pending_notify_ones(service_t _service, instance #endif void routing_manager_base::unset_all_eventpayloads(service_t _service, - instance_t _instance) { + unique_version_t _unique) { std::set> its_events; { std::lock_guard its_lock(eventgroups_mutex_); const auto found_service = eventgroups_.find(_service); if (found_service != eventgroups_.end()) { - const auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - for (const auto &eventgroupinfo : found_instance->second) { + const auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + for (const auto &eventgroupinfo : found_unique->second) { for (const auto &event : eventgroupinfo.second->get_events()) { its_events.insert(event); } @@ -976,17 +976,17 @@ void routing_manager_base::unset_all_eventpayloads(service_t _service, } void routing_manager_base::unset_all_eventpayloads(service_t _service, - instance_t _instance, + unique_version_t _unique, eventgroup_t _eventgroup) { std::set> its_events; { std::lock_guard its_lock(eventgroups_mutex_); const auto found_service = eventgroups_.find(_service); if (found_service != eventgroups_.end()) { - const auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - const auto found_eventgroup = found_instance->second.find(_eventgroup); - if (found_eventgroup != found_instance->second.end()) { + const auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + const auto found_eventgroup = found_unique->second.find(_eventgroup); + if (found_eventgroup != found_unique->second.end()) { for (const auto &event : found_eventgroup->second->get_events()) { its_events.insert(event); } @@ -1000,15 +1000,15 @@ void routing_manager_base::unset_all_eventpayloads(service_t _service, } void routing_manager_base::notify_one_current_value( - client_t _client, service_t _service, instance_t _instance, + client_t _client, service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, const std::set &_events_to_exclude) { if (_event != ANY_EVENT) { - std::shared_ptr its_event = find_event(_service, _instance, _event); + std::shared_ptr its_event = find_event(_service, _unique, _event); if (its_event && its_event->is_field()) its_event->notify_one(_client, false); } else { - auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); + auto its_eventgroup = find_eventgroup(_service, _unique, _eventgroup); if (its_eventgroup) { std::set > its_events = its_eventgroup->get_events(); for (const auto &e : its_events) { @@ -1045,39 +1045,39 @@ bool routing_manager_base::send(client_t _client, // ********************************* PROTECTED ************************************** std::shared_ptr routing_manager_base::create_service_info( - service_t _service, instance_t _instance, major_version_t _major, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, ttl_t _ttl, bool _is_local_service) { std::shared_ptr its_info = - std::make_shared(_service, _instance, + std::make_shared(_service, _unique, _major, _minor, _ttl, _is_local_service); { std::lock_guard its_lock(services_mutex_); - services_[_service][_instance] = its_info; + services_[_service][_unique] = its_info; } if (!_is_local_service) { std::lock_guard its_lock(services_remote_mutex_); - services_remote_[_service][_instance] = its_info; + services_remote_[_service][_unique] = its_info; } return its_info; } std::shared_ptr routing_manager_base::find_service( - service_t _service, instance_t _instance) const { + service_t _service, unique_version_t _unique) const { std::shared_ptr its_info; std::lock_guard its_lock(services_mutex_); auto found_service = services_.find(_service); if (found_service != services_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - its_info = found_instance->second; + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + its_info = found_unique->second; } } return its_info; } -void routing_manager_base::clear_service_info(service_t _service, instance_t _instance, +void routing_manager_base::clear_service_info(service_t _service, unique_version_t _unique, bool _reliable) { - std::shared_ptr its_info(find_service(_service, _instance)); + std::shared_ptr its_info(find_service(_service, _unique)); if (!its_info) { return; } @@ -1094,7 +1094,7 @@ void routing_manager_base::clear_service_info(service_t _service, instance_t _in services_.erase(_service); deleted_service = true; } else { - services_[_service].erase(_instance); + services_[_service].erase(_unique); deleted_instance = true; } } else { @@ -1107,7 +1107,7 @@ void routing_manager_base::clear_service_info(service_t _service, instance_t _in if (deleted_service) { services_remote_.erase(_service); } else if (deleted_instance) { - services_remote_[_service].erase(_instance); + services_remote_[_service].erase(_unique); } } } @@ -1122,21 +1122,21 @@ services_t routing_manager_base::get_services_remote() const { return services_remote_; } -bool routing_manager_base::is_available(service_t _service, instance_t _instance, +bool routing_manager_base::is_available(service_t _service, unique_version_t _unique, major_version_t _major) const { bool available(false); std::lock_guard its_lock(local_services_mutex_); auto its_service = local_services_.find(_service); if (its_service != local_services_.end()) { - if (_instance == ANY_INSTANCE) { + if (get_instance_from_unique(_unique) == ANY_INSTANCE) { return true; } - auto its_instance = its_service->second.find(_instance); - if (its_instance != its_service->second.end()) { + auto its_unique = its_service->second.find(_unique); + if (its_unique != its_service->second.end()) { if (_major == ANY_MAJOR) { return true; } - if (std::get<0>(its_instance->second) == _major) { + if (std::get<0>(its_unique->second) == _major) { available = true; } } @@ -1144,19 +1144,19 @@ bool routing_manager_base::is_available(service_t _service, instance_t _instance return available; } -std::set routing_manager_base::find_local_clients(service_t _service, instance_t _instance) { +std::set routing_manager_base::find_local_clients(service_t _service, unique_version_t _unique) { std::set its_clients; std::lock_guard its_lock(local_services_mutex_); auto its_service = local_services_.find(_service); if (its_service != local_services_.end()) { - if (_instance == ANY_INSTANCE) { - for (auto its_instance : its_service->second) { - its_clients.insert(std::get<2>(its_instance.second)); + if (get_instance_from_unique(_unique) == ANY_INSTANCE) { + for (auto its_unique : its_service->second) { + its_clients.insert(std::get<2>(its_unique.second)); } } else { - auto its_instance = its_service->second.find(_instance); - if (its_instance != its_service->second.end()) { - its_clients.insert(std::get<2>(its_instance->second)); + auto its_unique = its_service->second.find(_unique); + if (its_unique != its_service->second.end()) { + its_clients.insert(std::get<2>(its_unique->second)); } } } @@ -1164,19 +1164,19 @@ std::set routing_manager_base::find_local_clients(service_t _service, } client_t routing_manager_base::find_local_client(service_t _service, - instance_t _instance) const { + unique_version_t _unique) const { std::lock_guard its_lock(local_services_mutex_); - return find_local_client_unlocked(_service, _instance); + return find_local_client_unlocked(_service, _unique); } client_t routing_manager_base::find_local_client_unlocked(service_t _service, - instance_t _instance) const { + unique_version_t _unique) const { client_t its_client(VSOMEIP_ROUTING_CLIENT); auto its_service = local_services_.find(_service); if (its_service != local_services_.end()) { - auto its_instance = its_service->second.find(_instance); - if (its_instance != its_service->second.end()) { - its_client = std::get<2>(its_instance->second); + auto its_unique = its_service->second.find(_unique); + if (its_unique != its_service->second.end()) { + its_client = std::get<2>(its_unique->second); } } return its_client; @@ -1187,7 +1187,7 @@ void routing_manager_base::remove_local(client_t _client, bool _remove_uid) { } void routing_manager_base::remove_local(client_t _client, - const std::set>& _subscribed_eventgroups, + const std::set>& _subscribed_eventgroups, bool _remove_sec_client) { vsomeip_sec_client_t its_sec_client; @@ -1208,12 +1208,12 @@ void routing_manager_base::remove_local(client_t _client, { std::lock_guard its_lock(local_services_mutex_); // Finally remove all services that are implemented by the client. - std::set> its_services; + std::set> its_services; for (const auto& s : local_services_) { for (const auto& i : s.second) { if (std::get<2>(i.second) == _client) { its_services.insert({ s.first, i.first }); - host_->on_availability(s.first, i.first, availability_state_e::AS_UNAVAILABLE, + host_->on_availability(s.first, get_instance_from_unique(i.first), availability_state_e::AS_UNAVAILABLE, std::get<0>(i.second), std::get<1>(i.second)); } } @@ -1226,7 +1226,7 @@ void routing_manager_base::remove_local(client_t _client, } // remove disconnected client from offer service history - std::set> its_clients; + std::set> its_clients; for (const auto& s : local_services_history_) { for (const auto& i : s.second) { for (const auto& c : i.second) { @@ -1247,15 +1247,15 @@ void routing_manager_base::remove_local(client_t _client, } std::shared_ptr routing_manager_base::find_event(service_t _service, - instance_t _instance, event_t _event) const { + unique_version_t _unique, event_t _event) const { std::lock_guard its_lock(events_mutex_); std::shared_ptr its_event; auto find_service = events_.find(_service); if (find_service != events_.end()) { - auto find_instance = find_service->second.find(_instance); - if (find_instance != find_service->second.end()) { - auto find_event = find_instance->second.find(_event); - if (find_event != find_instance->second.end()) { + auto find_unique = find_service->second.find(_unique); + if (find_unique != find_service->second.end()) { + auto find_event = find_unique->second.find(_event); + if (find_event != find_unique->second.end()) { its_event = find_event->second; } } @@ -1265,16 +1265,16 @@ std::shared_ptr routing_manager_base::find_event(service_t _service, std::set > routing_manager_base::find_eventgroups( - service_t _service, instance_t _instance) const { + service_t _service, unique_version_t _unique) const { std::set > its_eventgroups; std::lock_guard its_lock{eventgroups_mutex_}; auto found_service = eventgroups_.find(_service); if (found_service != eventgroups_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - for (const auto &e : found_instance->second) + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + for (const auto &e : found_unique->second) its_eventgroups.insert(e.second); } } @@ -1283,24 +1283,24 @@ routing_manager_base::find_eventgroups( } std::shared_ptr routing_manager_base::find_eventgroup( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) const { std::lock_guard its_lock(eventgroups_mutex_); std::shared_ptr its_info(nullptr); auto found_service = eventgroups_.find(_service); if (found_service != eventgroups_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_eventgroup = found_instance->second.find(_eventgroup); - if (found_eventgroup != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_eventgroup = found_unique->second.find(_eventgroup); + if (found_eventgroup != found_unique->second.end()) { its_info = found_eventgroup->second; std::shared_ptr its_service_info - = find_service(_service, _instance); + = find_service(_service, _unique); if (its_service_info) { std::string its_multicast_address; uint16_t its_multicast_port; - if (configuration_->get_multicast(_service, _instance, + if (configuration_->get_multicast(_service, _unique, _eventgroup, its_multicast_address, its_multicast_port)) { try { @@ -1312,7 +1312,7 @@ std::shared_ptr routing_manager_base::find_eventgroup( catch (...) { VSOMEIP_ERROR << "Eventgroup [" << std::hex << std::setfill('0') << std::setw(4) - << _service << "." << _instance << "." << _eventgroup + << _service << "." << get_instance_from_unique(_unique) << "." << _eventgroup << "] is configured as multicast, but no valid " "multicast address is configured!"; } @@ -1322,7 +1322,7 @@ std::shared_ptr routing_manager_base::find_eventgroup( its_info->set_major(its_service_info->get_major()); its_info->set_ttl(its_service_info->get_ttl()); its_info->set_threshold(configuration_->get_threshold( - _service, _instance, _eventgroup)); + _service, get_instance_from_unique(_unique), _eventgroup)); } } } @@ -1331,19 +1331,19 @@ std::shared_ptr routing_manager_base::find_eventgroup( } void routing_manager_base::remove_eventgroup_info(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) { + unique_version_t _unique, eventgroup_t _eventgroup) { std::lock_guard its_lock(eventgroups_mutex_); auto found_service = eventgroups_.find(_service); if (found_service != eventgroups_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - found_instance->second.erase(_eventgroup); + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + found_unique->second.erase(_eventgroup); } } } bool routing_manager_base::send_local_notification(client_t _client, - const byte_t *_data, uint32_t _size, instance_t _instance, + const byte_t *_data, uint32_t _size, unique_version_t _unique, bool _reliable, uint8_t _status_check, bool _force) { #ifdef USE_DLT bool has_local(false); @@ -1353,7 +1353,7 @@ bool routing_manager_base::send_local_notification(client_t _client, service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); - std::shared_ptr its_event = find_event(its_service, _instance, its_method); + std::shared_ptr its_event = find_event(its_service, _unique, its_method); if (its_event && !its_event->is_shadow()) { for (auto its_client : its_event->get_filtered_subscribers(_force)) { @@ -1370,7 +1370,7 @@ bool routing_manager_base::send_local_notification(client_t _client, std::shared_ptr its_local_target = ep_mgr_->find_local(its_client); if (its_local_target) { - send_local(its_local_target, its_client, _data, _size, _instance, _reliable, + send_local(its_local_target, its_client, _data, _size, _unique, _reliable, protocol::id_e::SEND_ID, _status_check); } } @@ -1379,7 +1379,7 @@ bool routing_manager_base::send_local_notification(client_t _client, // Trace the message if a local client but will _not_ be forwarded to the routing manager if (has_local && !has_remote) { trace::header its_header; - if (its_header.prepare(nullptr, true, _instance)) + if (its_header.prepare(nullptr, true, get_instance_from_unique(_unique))) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, _data, _size); } @@ -1389,18 +1389,19 @@ bool routing_manager_base::send_local_notification(client_t _client, bool routing_manager_base::send_local( std::shared_ptr &_target, client_t _client, - const byte_t *_data, uint32_t _size, instance_t _instance, + const byte_t *_data, uint32_t _size, unique_version_t _unique, bool _reliable, protocol::id_e _command, uint8_t _status_check) const { bool has_sent(false); protocol::send_command its_command(_command); its_command.set_client(get_client()); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_reliable(_reliable); its_command.set_status(_status_check); its_command.set_target(_client); its_command.set_message(std::vector(_data, _data + _size)); + its_command.set_version(get_major_from_unique(_unique)); std::vector its_buffer; protocol::error_e its_error; @@ -1413,13 +1414,13 @@ bool routing_manager_base::send_local( } bool routing_manager_base::insert_subscription( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, const std::shared_ptr &_filter, client_t _client, std::set *_already_subscribed_events) { bool is_inserted(false); if (_event != ANY_EVENT) { // subscribe to specific event - std::shared_ptr its_event = find_event(_service, _instance, _event); + std::shared_ptr its_event = find_event(_service, _unique, _event); if (its_event) { is_inserted = its_event->add_subscriber(_eventgroup, _filter, _client, host_->is_routing()); @@ -1428,18 +1429,18 @@ bool routing_manager_base::insert_subscription( << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "." << std::setw(4) << _event << "]" << " received subscription for unknown (unrequested / " << "unoffered) event. Creating placeholder event holding " << "subscription until event is requested/offered."; is_inserted = create_placeholder_event_and_subscribe(_service, - _instance, _eventgroup, _event, _filter, _client); + _unique, _eventgroup, _event, _filter, _client); } } else { // subscribe to all events of the eventgroup std::shared_ptr its_eventgroup - = find_eventgroup(_service, _instance, _eventgroup); + = find_eventgroup(_service, _unique, _eventgroup); bool create_place_holder(false); if (its_eventgroup) { std::set> its_events = its_eventgroup->get_events(); @@ -1465,14 +1466,14 @@ bool routing_manager_base::insert_subscription( << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "." << std::setw(4) << _event << "]" << " received subscription for unknown (unrequested / " << "unoffered) eventgroup. Creating placeholder event holding " << "subscription until event is requested/offered."; is_inserted = create_placeholder_event_and_subscribe(_service, - _instance, _eventgroup, _event, _filter, _client); + _unique, _eventgroup, _event, _filter, _client); } } return is_inserted; @@ -1544,12 +1545,13 @@ void routing_manager_base::send_pending_subscriptions(service_t _service, } void routing_manager_base::remove_pending_subscription(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event) { + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { if (_eventgroup == 0xFFFF) { for (auto it = pending_subscriptions_.begin(); it != pending_subscriptions_.end();) { if (it->service_ == _service - && it->instance_ == _instance) { + && it->instance_ == get_instance_from_unique(_unique) + && it->major_ == get_major_from_unique(_unique)) { it = pending_subscriptions_.erase(it); } else { it++; @@ -1559,7 +1561,8 @@ void routing_manager_base::remove_pending_subscription(service_t _service, for (auto it = pending_subscriptions_.begin(); it != pending_subscriptions_.end();) { if (it->service_ == _service - && it->instance_ == _instance + && it->instance_ == get_instance_from_unique(_unique) + && it->major_ == get_major_from_unique(_unique) && it->eventgroup_ == _eventgroup) { it = pending_subscriptions_.erase(it); } else { @@ -1570,7 +1573,8 @@ void routing_manager_base::remove_pending_subscription(service_t _service, for (auto it = pending_subscriptions_.begin(); it != pending_subscriptions_.end();) { if (it->service_ == _service - && it->instance_ == _instance + && it->instance_ == get_instance_from_unique(_unique) + && it->major_ == get_major_from_unique(_unique) && it->eventgroup_ == _eventgroup && it->event_ == _event) { it = pending_subscriptions_.erase(it); @@ -1582,18 +1586,18 @@ void routing_manager_base::remove_pending_subscription(service_t _service, } } -std::set> +std::set> routing_manager_base::get_subscriptions(const client_t _client) { - std::set> result; + std::set> result; std::lock_guard its_lock(events_mutex_); for (const auto& its_service : events_) { - for (const auto& its_instance : its_service.second) { - for (const auto& its_event : its_instance.second) { + for (const auto& its_unique : its_service.second) { + for (const auto& its_event : its_unique.second) { auto its_eventgroups = its_event.second->get_eventgroups(_client); for (const auto& e : its_eventgroups) { result.insert(std::make_tuple( its_service.first, - its_instance.first, + its_unique.first, e)); } } @@ -1606,8 +1610,8 @@ routing_manager_base::get_subscriptions(const client_t _client) { void routing_manager_base::clear_shadow_subscriptions(void) { std::lock_guard its_lock(events_mutex_); for (const auto& its_service : events_) { - for (const auto& its_instance : its_service.second) { - for (const auto& its_event : its_instance.second) { + for (const auto& its_unique : its_service.second) { + for (const auto& its_event : its_unique.second) { if (its_event.second->is_shadow()) its_event.second->clear_subscribers(); } @@ -1662,24 +1666,24 @@ routing_manager_base::get_routing_state() { } #ifdef VSOMEIP_ENABLE_COMPAT -void routing_manager_base::set_incoming_subscription_state(client_t _client, service_t _service, instance_t _instance, +void routing_manager_base::set_incoming_subscription_state(client_t _client, service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, subscription_state_e _state) { std::lock_guard its_lock(incoming_subscription_state_mutex_); - incoming_subscription_state_[_client][_service][_instance][_eventgroup][_event] = _state; + incoming_subscription_state_[_client][_service][_unique][_eventgroup][_event] = _state; } subscription_state_e routing_manager_base::get_incoming_subscription_state(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { std::lock_guard its_lock(incoming_subscription_state_mutex_); const auto its_client = incoming_subscription_state_.find(_client); if (its_client != incoming_subscription_state_.end()) { const auto its_service = its_client->second.find(_service); if (its_service != its_client->second.end()) { - const auto its_instance = its_service->second.find(_instance); - if (its_instance != its_service->second.end()) { - const auto its_group = its_instance->second.find(_eventgroup); - if (its_group != its_instance->second.end()) { + const auto its_unique = its_service->second.find(_unique); + if (its_unique != its_service->second.end()) { + const auto its_group = its_unique->second.find(_eventgroup); + if (its_group != its_unique->second.end()) { const auto its_event = its_group->second.find(_event); if (its_event != its_group->second.end()) { return its_event->second; @@ -1696,24 +1700,24 @@ subscription_state_e routing_manager_base::get_incoming_subscription_state(clien return subscription_state_e::SUBSCRIPTION_NOT_ACKNOWLEDGED; } -void routing_manager_base::erase_incoming_subscription_state(client_t _client, service_t _service, instance_t _instance, +void routing_manager_base::erase_incoming_subscription_state(client_t _client, service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { std::lock_guard its_lock(incoming_subscription_state_mutex_); const auto its_client = incoming_subscription_state_.find(_client); if (its_client != incoming_subscription_state_.end()) { const auto its_service = its_client->second.find(_service); if (its_service != its_client->second.end()) { - const auto its_instance = its_service->second.find(_instance); - if (its_instance != its_service->second.end()) { - const auto its_group = its_instance->second.find(_eventgroup); - if (its_group != its_instance->second.end()) { + const auto its_unique = its_service->second.find(_unique); + if (its_unique != its_service->second.end()) { + const auto its_group = its_unique->second.find(_eventgroup); + if (its_group != its_unique->second.end()) { const auto its_event = its_group->second.find(_event); if (its_event != its_group->second.end()) { its_group->second.erase(_event); if (its_group->second.empty()) { - its_instance->second.erase(its_group); - if (its_instance->second.empty()) { - its_service->second.erase(its_instance); + its_unique->second.erase(its_group); + if (its_unique->second.empty()) { + its_service->second.erase(its_unique); if (its_service->second.empty()) { its_client->second.erase(its_service); if (its_client->second.empty()) { diff --git a/implementation/routing/src/routing_manager_client.cpp b/implementation/routing/src/routing_manager_client.cpp index b56aa62c9..26057c020 100644 --- a/implementation/routing/src/routing_manager_client.cpp +++ b/implementation/routing/src/routing_manager_client.cpp @@ -334,19 +334,19 @@ std::string routing_manager_client::get_env_unlocked(client_t _client) const { } bool routing_manager_client::offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { - if (!routing_manager_base::offer_service(_client, _service, _instance, _major, _minor)) { + if (!routing_manager_base::offer_service(_client, _service, _unique, _major, _minor)) { VSOMEIP_WARNING << "routing_manager_client::offer_service," << "routing_manager_base::offer_service returned false"; } { std::lock_guard its_lock(state_mutex_); if (state_ == inner_state_type_e::ST_REGISTERED) { - send_offer_service(_client, _service, _instance, _major, _minor); + send_offer_service(_client, _service, get_instance_from_unique(_unique), _major, _minor); } - protocol::service offer(_service, _instance, _major, _minor ); + protocol::service offer(_service, get_instance_from_unique(_unique), _major, _minor ); pending_offers_.insert(offer); } return true; @@ -382,7 +382,7 @@ void routing_manager_client::send_offer_service(client_t _client, } void routing_manager_client::stop_offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { (void)_client; @@ -391,12 +391,12 @@ void routing_manager_client::stop_offer_service(client_t _client, // Hold the mutex to ensure no placeholder event is created in between. std::lock_guard its_lock(stop_mutex_); - routing_manager_base::stop_offer_service(_client, _service, _instance, _major, _minor); - clear_remote_subscriber_count(_service, _instance); + routing_manager_base::stop_offer_service(_client, _service, _unique, _major, _minor); + clear_remote_subscriber_count(_service, _unique); // Note: The last argument does not matter here as a proxy // does not manage endpoints to the external network. - clear_service_info(_service, _instance, false); + clear_service_info(_service, _unique, false); } { @@ -406,7 +406,7 @@ void routing_manager_client::stop_offer_service(client_t _client, protocol::stop_offer_service_command its_command; its_command.set_client(get_client()); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_major(_major); its_command.set_minor(_minor); @@ -427,7 +427,7 @@ void routing_manager_client::stop_offer_service(client_t _client, auto it = pending_offers_.begin(); while (it != pending_offers_.end()) { if (it->service_ == _service - && it->instance_ == _instance) { + && get_unique_version(it->instance_, it->major_) == _unique) { break; } it++; @@ -437,14 +437,14 @@ void routing_manager_client::stop_offer_service(client_t _client, } void routing_manager_client::request_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { routing_manager_base::request_service(_client, - _service, _instance, _major, _minor); + _service, _unique, _major, _minor); { std::lock_guard its_lock(state_mutex_); size_t request_debouncing_time = configuration_->get_request_debouncing(host_->get_name()); - protocol::service request = { _service, _instance, _major, _minor }; + protocol::service request = { _service, get_instance_from_unique(_unique), _major, _minor }; if (!request_debouncing_time) { if (state_ == inner_state_type_e::ST_REGISTERED) { std::set requests; @@ -469,17 +469,17 @@ void routing_manager_client::request_service(client_t _client, } void routing_manager_client::release_service(client_t _client, - service_t _service, instance_t _instance) { - routing_manager_base::release_service(_client, _service, _instance); + service_t _service, unique_version_t _unique) { + routing_manager_base::release_service(_client, _service, _unique); { std::lock_guard its_lock(state_mutex_); - remove_pending_subscription(_service, _instance, 0xFFFF, ANY_EVENT); + remove_pending_subscription(_service, _unique, 0xFFFF, ANY_EVENT); bool pending(false); auto it = requests_to_debounce_.begin(); while (it != requests_to_debounce_.end()) { if (it->service_ == _service - && it->instance_ == _instance) { + && it->instance_ == get_instance_from_unique(_unique)) { pending = true; } it++; @@ -487,14 +487,14 @@ void routing_manager_client::release_service(client_t _client, if (it != requests_to_debounce_.end()) requests_to_debounce_.erase(it); if (!pending && state_ == inner_state_type_e::ST_REGISTERED) { - send_release_service(_client, _service, _instance); + send_release_service(_client, _service, _unique); } { auto it = requests_.begin(); while (it != requests_.end()) { if (it->service_ == _service - && it->instance_ == _instance) { + && it->instance_ == get_instance_from_unique(_unique)) { break; } it++; @@ -506,7 +506,7 @@ void routing_manager_client::release_service(client_t _client, void routing_manager_client::register_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, const event_type_e _type, reliability_type_e _reliability, @@ -521,7 +521,7 @@ void routing_manager_client::register_event(client_t _client, const event_data_t registration = { _service, - _instance, + _unique, _notifier, _type, _reliability, @@ -544,7 +544,7 @@ void routing_manager_client::register_event(client_t _client, for (auto iter = pending_event_registrations_.begin(); iter != pending_event_registrations_.end();) { if (iter->service_ == _service - && iter->instance_ == _instance + && iter->unique == _unique && iter->notifier_ == _notifier && iter->is_provided_ == _is_provided && iter->type_ == event_type_e::ET_EVENT @@ -566,7 +566,7 @@ void routing_manager_client::register_event(client_t _client, } if (is_first || _is_provided) { routing_manager_base::register_event(_client, - _service, _instance, + _service, _unique, _notifier, _eventgroups, _type, _reliability, _cycle, _change_resets_cycle, _update_on_change, @@ -576,7 +576,7 @@ void routing_manager_client::register_event(client_t _client, { std::lock_guard its_lock(state_mutex_); if (state_ == inner_state_type_e::ST_REGISTERED && is_first) { - send_register_event(get_client(), _service, _instance, + send_register_event(get_client(), _service, _unique, _notifier, _eventgroups, _type, _reliability, _is_provided, is_cyclic); } @@ -584,10 +584,10 @@ void routing_manager_client::register_event(client_t _client, } void routing_manager_client::unregister_event(client_t _client, - service_t _service, instance_t _instance, event_t _notifier, + service_t _service, unique_version_t _unique, event_t _notifier, bool _is_provided) { - routing_manager_base::unregister_event(_client, _service, _instance, + routing_manager_base::unregister_event(_client, _service, _unique, _notifier, _is_provided); { @@ -597,9 +597,10 @@ void routing_manager_client::unregister_event(client_t _client, protocol::unregister_event_command its_command; its_command.set_client(get_client()); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_event(_notifier); its_command.set_provided(_is_provided); + its_command.set_version(static_cast(get_major_from_unique(_unique))); std::vector its_buffer; protocol::error_e its_error; @@ -615,7 +616,7 @@ void routing_manager_client::unregister_event(client_t _client, for (auto iter = pending_event_registrations_.begin(); iter != pending_event_registrations_.end(); ) { if (iter->service_ == _service - && iter->instance_ == _instance + && iter->unique_ == _unique && iter->notifier_ == _notifier && iter->is_provided_ == _is_provided) { pending_event_registrations_.erase(iter); @@ -627,9 +628,9 @@ void routing_manager_client::unregister_event(client_t _client, } } -bool routing_manager_client::is_field(service_t _service, instance_t _instance, +bool routing_manager_client::is_field(service_t _service, unique_version_t _unique, event_t _event) const { - auto event = find_event(_service, _instance, _event); + auto event = find_event(_service, _unique, _event); if (event && event->is_field()) { return true; } @@ -638,18 +639,18 @@ bool routing_manager_client::is_field(service_t _service, instance_t _instance, void routing_manager_client::subscribe( client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter) { (void)_client; std::lock_guard its_lock(state_mutex_); - if (state_ == inner_state_type_e::ST_REGISTERED && is_available(_service, _instance, _major)) { - send_subscribe(get_client(), _service, _instance, _eventgroup, _major, _event, _filter ); + if (state_ == inner_state_type_e::ST_REGISTERED && is_available(_service, _unique, _major)) { + send_subscribe(get_client(), _service, _unique, _eventgroup, _major, _event, _filter ); } subscription_data_t subscription = { - _service, _instance, + _service, get_instance_from_unique(_unique), _eventgroup, _major, _event, _filter, *_sec_client @@ -658,26 +659,26 @@ void routing_manager_client::subscribe( } void routing_manager_client::send_subscribe(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter) { if (_event == ANY_EVENT) { - if (!is_subscribe_to_any_event_allowed(get_sec_client(), _client, _service, _instance, _eventgroup)) { + if (!is_subscribe_to_any_event_allowed(get_sec_client(), _client, _service, get_instance_from_unique(_unique), _eventgroup)) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << _client << " : routing_manager_proxy::subscribe: " << " isn't allowed to subscribe to service/instance/event " - << _service << "/" << _instance << "/ANY_EVENT" + << _service << "/" << get_instance_from_unique(_unique) << "/ANY_EVENT" << " which violates the security policy ~> Skip subscribe!"; return; } } else { if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_access_member( - get_sec_client(), _service, _instance, _event)) { + get_sec_client(), _service, get_instance_from_unique(_unique), _event)) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << _client << " : routing_manager_proxy::subscribe: " << " isn't allowed to subscribe to service/instance/event " - << _service << "/" << _instance + << _service << "/" << get_instance_from_unique(_unique) << "/" << _event; return; } @@ -686,7 +687,7 @@ void routing_manager_client::send_subscribe(client_t _client, protocol::subscribe_command its_command; its_command.set_client(_client); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_eventgroup(_eventgroup); its_command.set_major(_major); its_command.set_event(_event); @@ -698,7 +699,7 @@ void routing_manager_client::send_subscribe(client_t _client, its_command.serialize(its_buffer, its_error); if (its_error == protocol::error_e::ERROR_OK) { - client_t its_target_client = find_local_client(_service, _instance); + client_t its_target_client = find_local_client(_service, _unique); if (its_target_client != VSOMEIP_ROUTING_CLIENT) { std::shared_ptr its_target = ep_mgr_->find_or_create_local(its_target_client); @@ -709,7 +710,7 @@ void routing_manager_client::send_subscribe(client_t _client, << ": no target available to send subscription." << " client=" << std::setw(4) << _client << " service=" << std::setw(4) << _service << "." << std::setw(4) - << _instance << "." << std::setw(2) + << get_instance_from_unique(_unique) << "." << std::setw(2) << static_cast(_major) << " event=" << std::setw(4) << _event; } @@ -726,17 +727,18 @@ void routing_manager_client::send_subscribe(client_t _client, } void routing_manager_client::send_subscribe_nack(client_t _subscriber, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _id) { protocol::subscribe_nack_command its_command; its_command.set_client(get_client()); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_eventgroup(_eventgroup); its_command.set_subscriber(_subscriber); its_command.set_event(_event); its_command.set_pending_id(_id); + its_command.set_version(static_cast(get_major_from_unique(_unique))); std::vector its_buffer; protocol::error_e its_error; @@ -763,17 +765,18 @@ void routing_manager_client::send_subscribe_nack(client_t _subscriber, } void routing_manager_client::send_subscribe_ack(client_t _subscriber, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _id) { protocol::subscribe_ack_command its_command; its_command.set_client(get_client()); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_eventgroup(_eventgroup); its_command.set_subscriber(_subscriber); its_command.set_event(_event); its_command.set_pending_id(_id); + its_command.set_version(static_cast(get_major_from_unique(_unique))); std::vector its_buffer; protocol::error_e its_error; @@ -801,21 +804,21 @@ void routing_manager_client::send_subscribe_ack(client_t _subscriber, void routing_manager_client::unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event) { + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { (void)_client; (void)_sec_client; { std::lock_guard its_lock(state_mutex_); - remove_pending_subscription(_service, _instance, _eventgroup, _event); + remove_pending_subscription(_service, _unique, _eventgroup, _event); if (state_ == inner_state_type_e::ST_REGISTERED) { protocol::unsubscribe_command its_command; its_command.set_client(_client); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_eventgroup(_eventgroup); its_command.set_major(ANY_MAJOR); its_command.set_event(_event); @@ -827,7 +830,7 @@ void routing_manager_client::unsubscribe(client_t _client, if (its_error == protocol::error_e::ERROR_OK) { - auto its_target = ep_mgr_->find_local(_service, _instance); + auto its_target = ep_mgr_->find_local(_service, _unique); if (its_target) { its_target->send(&its_buffer[0], uint32_t(its_buffer.size())); } else { @@ -847,7 +850,7 @@ void routing_manager_client::unsubscribe(client_t _client, } bool routing_manager_client::send(client_t _client, const byte_t *_data, - length_t _size, instance_t _instance, bool _reliable, + length_t _size, unique_version_t _unique, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check, bool _sent_from_remote, bool _force) { @@ -868,7 +871,7 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); if (client_side_logging_filter_.empty() || (1 == client_side_logging_filter_.count(std::make_tuple(its_service, ANY_INSTANCE))) - || (1 == client_side_logging_filter_.count(std::make_tuple(its_service, _instance)))) { + || (1 == client_side_logging_filter_.count(std::make_tuple(its_service, get_instance_from_unique(_unique))))) { method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); session_t its_session = bithelper::read_uint16_be(&_data[VSOMEIP_SESSION_POS_MIN]); client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); @@ -876,7 +879,7 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, << std::hex << std::setfill('0') << std::setw(4) << get_client() << "): [" << std::setw(4) << its_service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_method << ":" << std::setw(4) << its_session << ":" << std::setw(4) << its_client << "] " @@ -894,7 +897,7 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, if (utility::is_request(_data[VSOMEIP_MESSAGE_TYPE_POS])) { // Request service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); - client_t its_client = find_local_client(its_service, _instance); + client_t its_client = find_local_client(its_service, _unique); if (its_client != VSOMEIP_ROUTING_CLIENT) { if (is_client_known(its_client)) { its_target = ep_mgr_->find_or_create_local(its_client); @@ -912,7 +915,7 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, _client == VSOMEIP_ROUTING_CLIENT) { // notify has_remote_subscribers = send_local_notification(get_client(), _data, _size, - _instance, _reliable, _status_check, _force); + _unique, _reliable, _status_check, _force); } else if (utility::is_notification(_data[VSOMEIP_MESSAGE_TYPE_POS]) && _client != VSOMEIP_ROUTING_CLIENT) { // notify_one @@ -920,12 +923,12 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, if (its_target) { #ifdef USE_DLT trace::header its_header; - if (its_header.prepare(nullptr, true, _instance)) + if (its_header.prepare(nullptr, true, get_instance_from_unique(_unique))) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, _data, _size); #endif return send_local(its_target, get_client(), _data, _size, - _instance, _reliable, protocol::id_e::SEND_ID, _status_check); + _unique, _reliable, protocol::id_e::SEND_ID, _status_check); } } // If no direct endpoint could be found @@ -961,7 +964,7 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, #ifdef USE_DLT else if (!message_to_stub) { trace::header its_header; - if (its_header.prepare(nullptr, true, _instance)) + if (its_header.prepare(nullptr, true, get_instance_from_unique(_unique))) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, _data, _size); } @@ -969,7 +972,7 @@ bool routing_manager_client::send(client_t _client, const byte_t *_data, if (send) { is_sent = send_local(its_target, (its_command == protocol::id_e::NOTIFY_ONE_ID ? _client : get_client()), - _data, _size, _instance, _reliable, its_command, _status_check); + _data, _size, _unique, _reliable, its_command, _status_check); } } return is_sent; @@ -988,12 +991,12 @@ bool routing_manager_client::send_to(const client_t _client, bool routing_manager_client::send_to( const std::shared_ptr &_target, - const byte_t *_data, uint32_t _size, instance_t _instance) { + const byte_t *_data, uint32_t _size, unique_version_t _unique) { (void)_target; (void)_data; (void)_size; - (void)_instance; + (void)_unique; return false; } @@ -1106,6 +1109,8 @@ void routing_manager_client::on_message( { protocol::send_command its_send_command(protocol::id_e::SEND_ID); its_send_command.deserialize(its_buffer, its_error); + its_major = static_cast(its_send_command.get_version()); + if (its_error == protocol::error_e::ERROR_OK) { auto a_deserializer = get_deserializer(); @@ -1149,7 +1154,7 @@ void routing_manager_client::on_message( << " ~> Skip message!"; return; } - cache_event_payload(its_message); + cache_event_payload(its_message, its_major); } } else if (utility::is_request(its_message->get_message_type())) { if (configuration_->is_security_enabled() @@ -1236,7 +1241,7 @@ void routing_manager_client::on_message( << " ~> Skip message!"; return; } - cache_event_payload(its_message); + cache_event_payload(its_message, its_major); } } #ifdef USE_DLT @@ -1328,14 +1333,14 @@ void routing_manager_client::on_message( its_lock.unlock(); #ifdef VSOMEIP_ENABLE_COMPAT routing_manager_base::set_incoming_subscription_state(its_client, its_service, - its_instance, its_eventgroup, its_event, subscription_state_e::IS_SUBSCRIBING); + get_unique_version(its_instance, its_major), its_eventgroup, its_event, subscription_state_e::IS_SUBSCRIBING); #endif - auto its_info = find_service(its_service, its_instance); + auto its_info = find_service(its_service, get_unique_version(its_instance, its_major)); if (its_info) { // Remote subscriber: Notify routing manager initially + count subscribes auto self = shared_from_this(); host_->on_subscription( - its_service, its_instance, its_eventgroup, its_client, _sec_client, + its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_client, _sec_client, get_env(its_client), true, [this, self, its_client, its_service, its_instance, its_eventgroup, its_event, its_filter, its_pending_id, @@ -1347,22 +1352,22 @@ void routing_manager_client::on_message( its_pending_id); std::set its_already_subscribed_events; bool inserted = insert_subscription( - its_service, its_instance, its_eventgroup, + its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_event, its_filter, VSOMEIP_ROUTING_CLIENT, &its_already_subscribed_events); if (inserted) { - notify_remote_initially(its_service, its_instance, + notify_remote_initially(its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_already_subscribed_events); } #ifdef VSOMEIP_ENABLE_COMPAT - send_pending_notify_ones(its_service, its_instance, + send_pending_notify_ones(its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_client, true); #endif its_count = get_remote_subscriber_count( - its_service, its_instance, its_eventgroup, true); + its_service, get_unique_version(its_instance, its_major), its_eventgroup, true); } else { - send_subscribe_nack(its_client, its_service, its_instance, + send_subscribe_nack(its_client, its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_event, its_pending_id); } @@ -1380,7 +1385,7 @@ void routing_manager_client::on_message( std::to_string(its_count) + " accepted." : "not accepted."); }); } else { - send_subscribe_nack(its_client, its_service, its_instance, its_eventgroup, + send_subscribe_nack(its_client, its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_event, its_pending_id); } #ifdef VSOMEIP_ENABLE_COMPAT @@ -1391,7 +1396,7 @@ void routing_manager_client::on_message( its_lock.unlock(); if (!is_from_routing) { if (its_event == ANY_EVENT) { - if (!is_subscribe_to_any_event_allowed(_sec_client, its_client, its_service, its_instance, its_eventgroup)) { + if (!is_subscribe_to_any_event_allowed(_sec_client, its_client, its_service, get_unique_version(its_instance, its_major), its_eventgroup)) { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << its_client << " : routing_manager_client::on_message: " << " isn't allowed to subscribe to service/instance/event " @@ -1434,16 +1439,16 @@ void routing_manager_client::on_message( auto self = shared_from_this(); auto its_env = get_env(its_client); - auto its_info = find_service(its_service, its_instance); + auto its_info = find_service(its_service, get_unique_version(its_instance, its_major)); if (its_info) { host_->on_subscription( - its_service, its_instance, its_eventgroup, its_client, _sec_client, + its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_client, _sec_client, its_env, true, [this, self, its_client, its_filter, _sec_client, its_env, its_service, its_instance, its_eventgroup, its_event, its_major](const bool _subscription_accepted) { if (!_subscription_accepted) { - send_subscribe_nack(its_client, its_service, its_instance, + send_subscribe_nack(its_client, its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_event, PENDING_SUBSCRIPTION_ID); } else { @@ -1451,16 +1456,16 @@ void routing_manager_client::on_message( its_eventgroup, its_event, PENDING_SUBSCRIPTION_ID); routing_manager_base::subscribe( - its_client, _sec_client, its_service, its_instance, + its_client, _sec_client, its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_major, its_event, its_filter); #ifdef VSOMEIP_ENABLE_COMPAT - send_pending_notify_ones(its_service, its_instance, + send_pending_notify_ones(its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_client); #endif } }); } else { - send_subscribe_nack(its_client, its_service, its_instance, its_eventgroup, + send_subscribe_nack(its_client, its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_event, PENDING_SUBSCRIPTION_ID); } #ifdef VSOMEIP_ENABLE_COMPAT @@ -1513,8 +1518,9 @@ void routing_manager_client::on_message( its_eventgroup = its_unsubscribe.get_eventgroup(); its_event = its_unsubscribe.get_event(); its_pending_id = its_unsubscribe.get_pending_id(); + its_major = static_cast(its_unsubscribe.get_version()); - host_->on_subscription(its_service, its_instance, its_eventgroup, + host_->on_subscription(its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_client, _sec_client, get_env(its_client), false, [](const bool _subscription_accepted){ (void)_subscription_accepted; @@ -1522,16 +1528,16 @@ void routing_manager_client::on_message( ); if (its_pending_id == PENDING_SUBSCRIPTION_ID) { // Local subscriber: withdraw subscription - routing_manager_base::unsubscribe(its_client, _sec_client, its_service, its_instance, its_eventgroup, its_event); + routing_manager_base::unsubscribe(its_client, _sec_client, its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_event); } else { // Remote subscriber: withdraw subscription only if no more remote subscriber exists its_remote_subscriber_count = get_remote_subscriber_count(its_service, - its_instance, its_eventgroup, false); + get_unique_version(its_instance, its_major), its_eventgroup, false); if (!its_remote_subscriber_count) { routing_manager_base::unsubscribe(VSOMEIP_ROUTING_CLIENT, nullptr, its_service, - its_instance, its_eventgroup, its_event); + get_unique_version(its_instance, its_major), its_eventgroup, its_event); } - send_unsubscribe_ack(its_service, its_instance, its_eventgroup, its_pending_id); + send_unsubscribe_ack(its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_pending_id); } VSOMEIP_INFO << "UNSUBSCRIBE(" << std::hex << std::setfill('0') @@ -1562,21 +1568,22 @@ void routing_manager_client::on_message( its_eventgroup = its_expire.get_eventgroup(); its_event = its_expire.get_event(); its_pending_id = its_expire.get_pending_id(); + its_major = static_cast(its_expire.get_version()); - host_->on_subscription(its_service, its_instance, its_eventgroup, its_client, + host_->on_subscription(its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_client, _sec_client, get_env(its_client), false, [](const bool _subscription_accepted){ (void)_subscription_accepted; }); if (its_pending_id == PENDING_SUBSCRIPTION_ID) { // Local subscriber: withdraw subscription routing_manager_base::unsubscribe(its_client, _sec_client, - its_service, its_instance, its_eventgroup, its_event); + its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_event); } else { // Remote subscriber: withdraw subscription only if no more remote subscriber exists its_remote_subscriber_count = get_remote_subscriber_count(its_service, - its_instance, its_eventgroup, false); + get_unique_version(its_instance, its_major), its_eventgroup, false); if (!its_remote_subscriber_count) { routing_manager_base::unsubscribe(VSOMEIP_ROUTING_CLIENT, nullptr, - its_service, its_instance, its_eventgroup, its_event); + its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_event); } } VSOMEIP_INFO << "EXPIRED SUBSCRIPTION(" @@ -1607,8 +1614,9 @@ void routing_manager_client::on_message( its_eventgroup = its_subscribe_nack.get_eventgroup(); its_subscriber = its_subscribe_nack.get_subscriber(); its_event = its_subscribe_nack.get_event(); + its_major = static_cast(its_subscribe_nack.get_version()); - on_subscribe_nack(its_subscriber, its_service, its_instance, its_eventgroup, its_event); + on_subscribe_nack(its_subscriber, its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_event); VSOMEIP_INFO << "SUBSCRIBE NACK(" << std::hex << std::setfill('0') << std::setw(4) << its_client << "): [" @@ -1634,8 +1642,9 @@ void routing_manager_client::on_message( its_eventgroup = its_subscribe_ack.get_eventgroup(); its_subscriber = its_subscribe_ack.get_subscriber(); its_event = its_subscribe_ack.get_event(); + its_major = static_cast (its_subscribe_ack.get_version()); - on_subscribe_ack(its_subscriber, its_service, its_instance, its_eventgroup, its_event); + on_subscribe_ack(its_subscriber, its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_event); VSOMEIP_INFO << "SUBSCRIBE ACK(" << std::hex << std::setfill('0') << std::setw(4) << its_client << "): [" @@ -1956,11 +1965,11 @@ void routing_manager_client::on_routing_info( // continue with the next service within the routing info. auto found_service = local_services_.find(its_service); if (found_service != local_services_.end()) { - if (found_service->second.find(its_instance) != found_service->second.end()) + if (found_service->second.find(get_unique_version(its_instance, its_major)) != found_service->second.end()) continue; } - local_services_[its_service][its_instance] + local_services_[its_service][get_unique_version(its_instance, its_major)] = std::make_tuple(its_major, its_minor, its_client); } { @@ -1991,15 +2000,15 @@ void routing_manager_client::on_routing_info( std::lock_guard its_lock(local_services_mutex_); auto found_service = local_services_.find(its_service); if (found_service != local_services_.end()) { - found_service->second.erase(its_instance); + found_service->second.erase(get_unique_version(its_instance, its_major)); // move previously offering client to history - local_services_history_[its_service][its_instance].insert(its_client); + local_services_history_[its_service][get_unique_version(its_instance, its_major)].insert(its_client); if (found_service->second.size() == 0) { local_services_.erase(its_service); } } } - on_stop_offer_service(its_service, its_instance, its_major, its_minor); + on_stop_offer_service(its_service, get_unique_version(its_instance, its_major), its_major, its_minor); host_->on_availability(its_service, its_instance, availability_state_e::AS_UNAVAILABLE, its_major, its_minor); VSOMEIP_INFO << "ON_UNAVAILABLE(" @@ -2061,7 +2070,7 @@ void routing_manager_client::on_routing_info( (void) ep_mgr_->find_or_create_local(si.client_id_); auto self = shared_from_this(); host_->on_subscription( - si.service_id_, si.instance_id_, si.eventgroup_id_, + si.service_id_, get_unique_version(si.instance_id_, si.major_), si.eventgroup_id_, si.client_id_, &si.sec_client_, si.env_, true, [this, self, si](const bool _subscription_accepted) { if (!_subscription_accepted) { @@ -2075,12 +2084,12 @@ void routing_manager_client::on_routing_info( si.major_, si.event_, si.filter_); #ifdef VSOMEIP_ENABLE_COMPAT send_pending_notify_ones(si.service_id_, - si.instance_id_, si.eventgroup_id_, si.client_id_); + get_unique_version(si.instance_id_, si.major_), si.eventgroup_id_, si.client_id_); #endif } #ifdef VSOMEIP_ENABLE_COMPAT routing_manager_base::erase_incoming_subscription_state(si.client_id_, si.service_id_, - si.instance_id_, si.eventgroup_id_, si.event_); + get_unique_version(si.instance_id_, si.major_), si.eventgroup_id_, si.event_); #endif { std::lock_guard its_lock2(incoming_subscriptions_mutex_); @@ -2095,10 +2104,10 @@ void routing_manager_client::on_routing_info( void routing_manager_client::on_offered_services_info( protocol::offered_services_response_command &_command) { - std::vector> its_offered_services_info; + std::vector> its_offered_services_info; for (const auto &s : _command.get_services()) - its_offered_services_info.push_back(std::make_pair(s.service_, s.instance_)); + its_offered_services_info.push_back(std::make_pair(s.service_, get_unique_version(s.instance_, s.major_))); host_->on_offered_services_info(its_offered_services_info); } @@ -2336,14 +2345,15 @@ void routing_manager_client::send_request_services(const std::set(get_major_from_unique(_unique))); std::vector its_buffer; protocol::error_e its_error; @@ -2365,7 +2375,7 @@ void routing_manager_client::send_pending_event_registrations(client_t _client) while(it != pending_event_registrations_.end()) { for(; it!=pending_event_registrations_.end(); it++) { - protocol::register_event reg(it->service_, it->instance_, it->notifier_, it->type_, + protocol::register_event reg(it->service_, get_instance_from_unique(it->unique_), it->notifier_, it->type_, it->is_provided_, it->reliability_, it->is_cyclic_ , (uint16_t)it->eventgroups_.size(), it->eventgroups_); if(!its_command.add_registration(reg)) {break;} @@ -2388,7 +2398,7 @@ void routing_manager_client::send_pending_event_registrations(client_t _client) } void routing_manager_client::send_register_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, const event_type_e _type, reliability_type_e _reliability, @@ -2399,7 +2409,7 @@ void routing_manager_client::send_register_event(client_t _client, protocol::register_events_command its_command; its_command.set_client(get_client()); - protocol::register_event reg(_service, _instance, _notifier, _type, + protocol::register_event reg(_service, get_instance_from_unique(_unique), _notifier, _type, _is_provided, _reliability, _is_cyclic, (uint16_t)_eventgroups.size(), _eventgroups); @@ -2407,6 +2417,8 @@ void routing_manager_client::send_register_event(client_t _client, VSOMEIP_ERROR << __func__ << ": register event command is too long."; } + its_command.set_version(static_cast(get_major_from_unique(_unique))); + std::vector its_buffer; protocol::error_e its_error; its_command.serialize(its_buffer, its_error); @@ -2422,7 +2434,7 @@ void routing_manager_client::send_register_event(client_t _client, << std::hex << std::setfill('0') << std::setw(4) << get_client() << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _notifier << ":is_provider=" << std::boolalpha << _is_provided << "]"; } @@ -2433,7 +2445,7 @@ void routing_manager_client::send_register_event(client_t _client, } void routing_manager_client::on_subscribe_ack(client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event) { + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { (void)_client; #if 0 VSOMEIP_ERROR << "routing_manager_client::" << __func__ @@ -2441,43 +2453,45 @@ void routing_manager_client::on_subscribe_ack(client_t _client, << "(" << std::setw(4) << host_->get_client() << "):" << "event=" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "." << std::setw(4) << _event; #endif if (_event == ANY_EVENT) { - auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); + auto its_eventgroup = find_eventgroup(_service, _unique, _eventgroup); if (its_eventgroup) { for (const auto& its_event : its_eventgroup->get_events()) { - host_->on_subscription_status(_service, _instance, _eventgroup, its_event->get_event(), 0x0 /*OK*/); + host_->on_subscription_status(_service, _unique, _eventgroup, its_event->get_event(), 0x0 /*OK*/); } } } else { - host_->on_subscription_status(_service, _instance, _eventgroup, _event, 0x0 /*OK*/); + host_->on_subscription_status(_service, _unique, _eventgroup, _event, 0x0 /*OK*/); } } void routing_manager_client::on_subscribe_nack(client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, event_t _event) { + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { (void)_client; if (_event == ANY_EVENT) { - auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); + auto its_eventgroup = find_eventgroup(_service, _unique, _eventgroup); if (its_eventgroup) { for (const auto& its_event : its_eventgroup->get_events()) { - host_->on_subscription_status(_service, _instance, _eventgroup, its_event->get_event(), 0x7 /*Rejected*/); + host_->on_subscription_status(_service, _unique, _eventgroup, its_event->get_event(), 0x7 /*Rejected*/); } } } else { - host_->on_subscription_status(_service, _instance, _eventgroup, _event, 0x7 /*Rejected*/); + host_->on_subscription_status(_service, _unique, _eventgroup, _event, 0x7 /*Rejected*/); } } void routing_manager_client::cache_event_payload( - const std::shared_ptr &_message) { + const std::shared_ptr &_message, major_version_t _major) { const service_t its_service(_message->get_service()); const instance_t its_instance(_message->get_instance()); const method_t its_method(_message->get_method()); - std::shared_ptr its_event = find_event(its_service, its_instance, its_method); + unique_version_t its_unique = get_unique_version(its_instance, _major); + + std::shared_ptr its_event = find_event(its_service, its_unique, its_method); if (its_event) { if (its_event->is_field()) { its_event->prepare_update_payload(_message->get_payload(), true); @@ -2489,14 +2503,14 @@ void routing_manager_client::cache_event_payload( // create a placeholder field until someone requests this event with // full information like eventgroup, field or not etc. routing_manager_base::register_event(host_->get_client(), - its_service, its_instance, + its_service, its_unique, its_method, its_eventgroups, event_type_e::ET_UNKNOWN, reliability_type_e::RT_UNKNOWN, std::chrono::milliseconds::zero(), false, true, nullptr, false, false, true); - std::shared_ptr its_event = find_event(its_service, its_instance, its_method); + std::shared_ptr its_event = find_event(its_service, its_unique, its_method); if (its_event) { its_event->prepare_update_payload(_message->get_payload(), true); its_event->update_payload(); @@ -2505,7 +2519,7 @@ void routing_manager_client::cache_event_payload( } void routing_manager_client::on_stop_offer_service(service_t _service, - instance_t _instance, + unique_version_t _unique, major_version_t _major, minor_version_t _minor) { (void) _major; @@ -2515,9 +2529,9 @@ void routing_manager_client::on_stop_offer_service(service_t _service, std::lock_guard its_lock(events_mutex_); auto its_events_service = events_.find(_service); if (its_events_service != events_.end()) { - auto its_events_instance = its_events_service->second.find(_instance); - if (its_events_instance != its_events_service->second.end()) { - for (auto &e : its_events_instance->second) + auto its_events_unique = its_events_service->second.find(_unique); + if (its_events_unique != its_events_service->second.end()) { + for (auto &e : its_events_unique->second) events[e.first] = e.second; } } @@ -2557,11 +2571,11 @@ void routing_manager_client::init_receiver() { } } -void routing_manager_client::notify_remote_initially(service_t _service, instance_t _instance, +void routing_manager_client::notify_remote_initially(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, const std::set &_events_to_exclude) { - auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); + auto its_eventgroup = find_eventgroup(_service, _unique, _eventgroup); if (its_eventgroup) { - auto service_info = find_service(_service, _instance); + auto service_info = find_service(_service, _unique); for (const auto &e : its_eventgroup->get_events()) { if (e->is_field() && e->is_set() && _events_to_exclude.find(e->get_event()) @@ -2569,7 +2583,7 @@ void routing_manager_client::notify_remote_initially(service_t _service, instanc std::shared_ptr its_notification = runtime::get()->create_notification(); its_notification->set_service(_service); - its_notification->set_instance(_instance); + its_notification->set_instance(get_instance_from_unique(_unique)); its_notification->set_method(e->get_event()); its_notification->set_payload(e->get_payload()); if (service_info) { @@ -2583,7 +2597,7 @@ void routing_manager_client::notify_remote_initially(service_t _service, instanc if (sender_) { send_local(sender_, VSOMEIP_ROUTING_CLIENT, its_serializer->get_data(), its_serializer->get_size(), - _instance, false, protocol::id_e::NOTIFY_ID, 0); + _unique, false, protocol::id_e::NOTIFY_ID, 0); } } its_serializer->reset(); @@ -2598,16 +2612,16 @@ void routing_manager_client::notify_remote_initially(service_t _service, instanc } uint32_t routing_manager_client::get_remote_subscriber_count(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, bool _increment) { + unique_version_t _unique, eventgroup_t _eventgroup, bool _increment) { std::lock_guard its_lock(remote_subscriber_count_mutex_); uint32_t count (0); bool found(false); auto found_service = remote_subscriber_count_.find(_service); if (found_service != remote_subscriber_count_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_group = found_instance->second.find(_eventgroup); - if (found_group != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_group = found_unique->second.find(_eventgroup); + if (found_group != found_unique->second.end()) { found = true; if (_increment) { found_group->second = found_group->second + 1; @@ -2622,7 +2636,7 @@ uint32_t routing_manager_client::get_remote_subscriber_count(service_t _service, } if (!found) { if (_increment) { - remote_subscriber_count_[_service][_instance][_eventgroup] = 1; + remote_subscriber_count_[_service][_unique][_eventgroup] = 1; count = 1; } } @@ -2630,11 +2644,11 @@ uint32_t routing_manager_client::get_remote_subscriber_count(service_t _service, } void routing_manager_client::clear_remote_subscriber_count( - service_t _service, instance_t _instance) { + service_t _service, unique_version_t _unique) { std::lock_guard its_lock(remote_subscriber_count_mutex_); auto found_service = remote_subscriber_count_.find(_service); if (found_service != remote_subscriber_count_.end()) { - if (found_service->second.erase(_instance)) { + if (found_service->second.erase(_unique)) { if (!found_service->second.size()) { remote_subscriber_count_.erase(found_service); } @@ -2725,7 +2739,7 @@ bool routing_manager_client::is_client_known(client_t _client) { } bool routing_manager_client::create_placeholder_event_and_subscribe( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _notifier, const std::shared_ptr &_filter, client_t _client) { @@ -2733,7 +2747,7 @@ bool routing_manager_client::create_placeholder_event_and_subscribe( bool is_inserted(false); - if (find_service(_service, _instance)) { + if (find_service(_service, _unique)) { // We received an event for an existing service which was not yet // requested/offered. Create a placeholder field until someone // requests/offers this event with full information like eventgroup, @@ -2741,12 +2755,12 @@ bool routing_manager_client::create_placeholder_event_and_subscribe( std::set its_eventgroups({ _eventgroup }); // routing_manager_client: Always register with own client id and shadow = false routing_manager_base::register_event(host_->get_client(), - _service, _instance, _notifier, + _service, _unique, _notifier, its_eventgroups, event_type_e::ET_UNKNOWN, reliability_type_e::RT_UNKNOWN, std::chrono::milliseconds::zero(), false, true, nullptr, false, false, true); - std::shared_ptr its_event = find_event(_service, _instance, _notifier); + std::shared_ptr its_event = find_event(_service, _unique, _notifier); if (its_event) { is_inserted = its_event->add_subscriber(_eventgroup, _filter, _client, false); } @@ -2841,15 +2855,16 @@ void routing_manager_client::send_get_offered_services_info(client_t _client, of } void routing_manager_client::send_unsubscribe_ack( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, remote_subscription_id_t _id) { protocol::unsubscribe_ack_command its_command; its_command.set_client(get_client()); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_eventgroup(_eventgroup); its_command.set_pending_id(_id); + its_command.set_version(static_cast(get_major_from_unique(_unique))); std::vector its_buffer; protocol::error_e its_error; @@ -2870,7 +2885,7 @@ void routing_manager_client::resend_provided_event_registrations() { std::lock_guard its_lock(state_mutex_); for (const event_data_t& ed : pending_event_registrations_) { if (ed.is_provided_) { - send_register_event(get_client(), ed.service_, ed.instance_, + send_register_event(get_client(), ed.service_, ed.unique_, ed.notifier_, ed.eventgroups_, ed.type_, ed.reliability_, ed.is_provided_, ed.is_cyclic_); } diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index be946e96d..26a779b8d 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -130,20 +130,20 @@ std::string routing_manager_impl::get_env_unlocked(client_t _client) const { return ""; } -std::set routing_manager_impl::find_local_clients(service_t _service, instance_t _instance) { - return routing_manager_base::find_local_clients(_service, _instance); +std::set routing_manager_impl::find_local_clients(service_t _service, unique_version_t _unique) { + return routing_manager_base::find_local_clients(_service, _unique); } -client_t routing_manager_impl::find_local_client(service_t _service, instance_t _instance) { - return routing_manager_base::find_local_client(_service, _instance); +client_t routing_manager_impl::find_local_client(service_t _service, unique_version_t _unique) { + return routing_manager_base::find_local_client(_service, _unique); } bool routing_manager_impl::is_subscribe_to_any_event_allowed( const vsomeip_sec_client_t *_sec_client, client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup) { + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) { return routing_manager_base::is_subscribe_to_any_event_allowed(_sec_client, _client, - _service, _instance, _eventgroup); + _service, _unique, _eventgroup); } void routing_manager_impl::add_known_client(client_t _client, const std::string &_client_host) { @@ -343,46 +343,46 @@ void routing_manager_impl::stop() { } } -bool routing_manager_impl::insert_offer_command(service_t _service, instance_t _instance, uint8_t _command, +bool routing_manager_impl::insert_offer_command(service_t _service, unique_version_t _unique, uint8_t _command, client_t _client, major_version_t _major, minor_version_t _minor) { std::lock_guard its_lock(offer_serialization_mutex_); // flag to indicate whether caller of this function can start directly processing the command bool must_process(false); - auto found_service_instance = offer_commands_.find(std::make_pair(_service, _instance)); - if (found_service_instance != offer_commands_.end()) { + auto found_service_unique = offer_commands_.find(std::make_pair(_service, _unique)); + if (found_service_unique != offer_commands_.end()) { // if nothing is queued - if (found_service_instance->second.empty()) { + if (found_service_unique->second.empty()) { must_process = true; } - found_service_instance->second.push_back( + found_service_unique->second.push_back( std::make_tuple(_command, _client, _major, _minor)); } else { // nothing is queued -> add command to queue and process command directly - offer_commands_[std::make_pair(_service, _instance)].push_back( + offer_commands_[std::make_pair(_service, _unique)].push_back( std::make_tuple(_command, _client, _major, _minor)); must_process = true; } return must_process; } -bool routing_manager_impl::erase_offer_command(service_t _service, instance_t _instance) { +bool routing_manager_impl::erase_offer_command(service_t _service, unique_version_t _unique) { std::lock_guard its_lock(offer_serialization_mutex_); - auto found_service_instance = offer_commands_.find(std::make_pair(_service, _instance)); - if (found_service_instance != offer_commands_.end()) { + auto found_service_unique = offer_commands_.find(std::make_pair(_service, _unique)); + if (found_service_unique != offer_commands_.end()) { // erase processed command - if (!found_service_instance->second.empty()) { - found_service_instance->second.pop_front(); - if (!found_service_instance->second.empty()) { + if (!found_service_unique->second.empty()) { + found_service_unique->second.pop_front(); + if (!found_service_unique->second.empty()) { // check for other commands to be processed - auto its_command = found_service_instance->second.front(); + auto its_command = found_service_unique->second.front(); if (std::get<0>(its_command) == uint8_t(protocol::id_e::OFFER_SERVICE_ID)) { - io_.post([&, its_command, _service, _instance](){ - offer_service(std::get<1>(its_command), _service, _instance, + io_.post([&, its_command, _service, _unique](){ + offer_service(std::get<1>(its_command), _service, _unique, std::get<2>(its_command), std::get<3>(its_command), false); }); } else { - io_.post([&, its_command, _service, _instance](){ - stop_offer_service(std::get<1>(its_command), _service, _instance, + io_.post([&, its_command, _service, _unique](){ + stop_offer_service(std::get<1>(its_command), _service, _unique, std::get<2>(its_command), std::get<3>(its_command), false); }); } @@ -393,26 +393,26 @@ bool routing_manager_impl::erase_offer_command(service_t _service, instance_t _i } bool routing_manager_impl::offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { - return offer_service(_client, _service, _instance, _major, _minor, true); + return offer_service(_client, _service, _unique, _major, _minor, true); } bool routing_manager_impl::offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, bool _must_queue) { // only queue commands if method was NOT called via erase_offer_command() if (_must_queue) { - if (!insert_offer_command(_service, _instance, + if (!insert_offer_command(_service, _unique, uint8_t(protocol::id_e::OFFER_SERVICE_ID), _client, _major, _minor)) { VSOMEIP_INFO << "rmi::" << __func__ << std::hex << std::setfill('0') << " (" << std::setw(4) << _client <<"): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << int(_major) << "." << _minor << "]" << " (" << std::boolalpha << _must_queue << ")" << " not offering service, because insert_offer_command returned false!"; @@ -424,23 +424,23 @@ bool routing_manager_impl::offer_service(client_t _client, // offer_service requests of local proxies are checked in rms::on:message if (_client == get_client()) { if (VSOMEIP_SEC_OK != configuration_->get_security()->is_client_allowed_to_offer( - get_sec_client(), _service, _instance)) { + get_sec_client(), _service, get_instance_from_unique(_unique))) { VSOMEIP_WARNING << "routing_manager_impl::offer_service: " << std::hex << "Security: Client 0x" << _client << " isn't allowed to offer the following service/instance " - << _service << "/" << _instance + << _service << "/" << get_instance_from_unique(_unique) << " ~> Skip offer!"; - erase_offer_command(_service, _instance); + erase_offer_command(_service, _unique); return false; } } - if (!handle_local_offer_service(_client, _service, _instance, _major, _minor)) { - erase_offer_command(_service, _instance); + if (!handle_local_offer_service(_client, _service, _unique, _major, _minor)) { + erase_offer_command(_service, _unique); VSOMEIP_INFO << "rmi::" << __func__ << std::hex << std::setfill('0') << " (" << std::setw(4) << _client <<"): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << int(_major) << "." << _minor << "]" << " (" << std::boolalpha << _must_queue << ")" << " not offering, returned from handle_local_offer_service!"; @@ -450,14 +450,14 @@ bool routing_manager_impl::offer_service(client_t _client, { std::lock_guard its_lock(pending_sd_offers_mutex_); if (if_state_running_) { - init_service_info(_service, _instance, true); + init_service_info(_service, _unique, true); } else { - pending_sd_offers_.push_back(std::make_pair(_service, _instance)); + pending_sd_offers_.push_back(std::make_pair(_service, _unique)); } } if (discovery_) { - std::shared_ptr its_info = find_service(_service, _instance); + std::shared_ptr its_info = find_service(_service, _unique); if (its_info) { discovery_->offer_service(its_info); } @@ -468,7 +468,7 @@ bool routing_manager_impl::offer_service(client_t _client, std::set its_already_subscribed_events; for (auto &ps : pending_subscriptions_) { if (ps.service_ == _service - && ps.instance_ == _instance + && ps.instance_ == get_instance_from_unique(_unique) && ps.major_ == _major) { insert_subscription(ps.service_, ps.instance_, ps.eventgroup_, ps.event_, nullptr, @@ -483,32 +483,32 @@ bool routing_manager_impl::offer_service(client_t _client, } } - send_pending_subscriptions(_service, _instance, _major); + send_pending_subscriptions(_service, get_instance_from_unique(_unique), _major); } if (stub_) - stub_->on_offer_service(_client, _service, _instance, _major, _minor); - on_availability(_service, _instance, availability_state_e::AS_AVAILABLE, _major, _minor); - erase_offer_command(_service, _instance); + stub_->on_offer_service(_client, _service, _unique, _major, _minor); + on_availability(_service, get_instance_from_unique(_unique), availability_state_e::AS_AVAILABLE, _major, _minor); + erase_offer_command(_service, _unique); VSOMEIP_INFO << "OFFER(" << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << int(_major) << "." << _minor << "]" << " (" << std::boolalpha << _must_queue << ")"; return true; } void routing_manager_impl::stop_offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { - stop_offer_service(_client, _service, _instance, _major, _minor, true); + stop_offer_service(_client, _service, _unique, _major, _minor, true); } void routing_manager_impl::stop_offer_service(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, bool _must_queue) { @@ -516,19 +516,19 @@ void routing_manager_impl::stop_offer_service(client_t _client, << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << int(_major) << "." << _minor << "]" << " (" << std::boolalpha << _must_queue << ")"; if (_must_queue) { - if (!insert_offer_command(_service, _instance, + if (!insert_offer_command(_service, _unique, uint8_t(protocol::id_e::STOP_OFFER_SERVICE_ID), _client, _major, _minor)) { VSOMEIP_INFO << "rmi::" << __func__ << " (" << std::hex << std::setfill('0') << std::setw(4) << _client <<"): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << int(_major) << "." << _minor << "]" << " (" << std::boolalpha << _must_queue << ")" << " STOP-OFFER NOT INSERTED!"; @@ -538,14 +538,14 @@ void routing_manager_impl::stop_offer_service(client_t _client, bool is_local(false); { - std::shared_ptr its_info = find_service(_service, _instance); + std::shared_ptr its_info = find_service(_service, _unique); is_local = (its_info && its_info->is_local()); } if (is_local) { { std::lock_guard its_lock(pending_sd_offers_mutex_); for (auto it = pending_sd_offers_.begin(); it != pending_sd_offers_.end(); ) { - if (it->first == _service && it->second == _instance) { + if (it->first == _service && it->second == _unique) { it = pending_sd_offers_.erase(it); break; } else { @@ -554,48 +554,48 @@ void routing_manager_impl::stop_offer_service(client_t _client, } } - on_stop_offer_service(_client, _service, _instance, _major, _minor); + on_stop_offer_service(_client, _service, _unique, _major, _minor); if (stub_) - stub_->on_stop_offer_service(_client, _service, _instance, _major, _minor); - on_availability(_service, _instance, availability_state_e::AS_UNAVAILABLE, _major, _minor); + stub_->on_stop_offer_service(_client, _service, _unique, _major, _minor); + on_availability(_service, get_instance_from_unique(_unique), availability_state_e::AS_UNAVAILABLE, _major, _minor); } else { VSOMEIP_WARNING << __func__ << " received STOP_OFFER(" << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << int(_major) << "." << _minor << "] " << "for remote service --> ignore"; - erase_offer_command(_service, _instance); + erase_offer_command(_service, _unique); } } void routing_manager_impl::request_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, minor_version_t _minor) { + unique_version_t _unique, major_version_t _major, minor_version_t _minor) { VSOMEIP_INFO << "REQUEST(" << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << ":" + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << int(_major) << "." << _minor << "]"; routing_manager_base::request_service(_client, - _service, _instance, _major, _minor); + _service, _unique, _major, _minor); - auto its_info = find_service(_service, _instance); + auto its_info = find_service(_service, _unique); if (!its_info) { - add_requested_service(_client, _service, _instance, _major, _minor); + add_requested_service(_client, _service, get_instance_from_unique(_unique), _major, _minor); if (discovery_) { - if (!configuration_->is_local_service(_service, _instance)) { + if (!configuration_->is_local_service(_service, _unique)) { // Non local service instance ~> tell SD to find it! - discovery_->request_service(_service, _instance, _major, _minor, + discovery_->request_service(_service, _unique, _major, _minor, DEFAULT_TTL); } else { VSOMEIP_INFO << std::hex << "Avoid trigger SD find-service message" << " for local service/instance/major/minor: " - << _service << "/" << _instance << std::dec + << _service << "/" << get_instance_from_unique(_unique) << std::dec << "/" << (uint32_t)_major << "/" << _minor; } } @@ -607,14 +607,14 @@ void routing_manager_impl::request_service(client_t _client, service_t _service, || DEFAULT_MINOR == its_info->get_minor() || _minor == ANY_MINOR)) { if(!its_info->is_local()) { - add_requested_service(_client, _service, _instance, _major, _minor); + add_requested_service(_client, _service, get_instance_from_unique(_unique), _major, _minor); if (discovery_) { // Non local service instance ~> tell SD to find it! - discovery_->request_service(_service, _instance, _major, + discovery_->request_service(_service, _unique, _major, _minor, DEFAULT_TTL); } its_info->add_client(_client); - ep_mgr_impl_->find_or_create_remote_client(_service, _instance); + ep_mgr_impl_->find_or_create_remote_client(_service, _unique); } } } @@ -623,7 +623,7 @@ void routing_manager_impl::request_service(client_t _client, service_t _service, if (stub_) stub_->create_local_receiver(); - protocol::service its_request(_service, _instance, _major, _minor); + protocol::service its_request(_service, get_instance_from_unique(_unique), _major, _minor); std::set requests; requests.insert(its_request); @@ -633,25 +633,25 @@ void routing_manager_impl::request_service(client_t _client, service_t _service, } void routing_manager_impl::release_service(client_t _client, service_t _service, - instance_t _instance) { + unique_version_t _unique) { VSOMEIP_INFO << "RELEASE(" << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "]"; + << std::setw(4) << get_instance_from_unique(_unique) << "]"; if (host_->get_client() == _client) { std::lock_guard its_lock(pending_subscription_mutex_); - remove_pending_subscription(_service, _instance, 0xFFFF, ANY_EVENT); + remove_pending_subscription(_service, _unique, 0xFFFF, ANY_EVENT); } - routing_manager_base::release_service(_client, _service, _instance); - remove_requested_service(_client, _service, _instance, ANY_MAJOR, ANY_MINOR); + routing_manager_base::release_service(_client, _service, _unique); + remove_requested_service(_client, _service, get_instance_from_unique(_unique), ANY_MAJOR, ANY_MINOR); - std::shared_ptr its_info(find_service(_service, _instance)); + std::shared_ptr its_info(find_service(_service, _unique)); if (its_info && !its_info->is_local()) { if (0 == its_info->get_requesters_size()) { - auto its_eventgroups = find_eventgroups(_service, _instance); + auto its_eventgroups = find_eventgroups(_service, _unique); for (const auto &eg : its_eventgroups) { auto its_events = eg->get_events(); for (auto &e : its_events) { @@ -660,16 +660,16 @@ void routing_manager_impl::release_service(client_t _client, service_t _service, } if (discovery_) { - discovery_->release_service(_service, _instance); - discovery_->unsubscribe_all(_service, _instance); + discovery_->release_service(_service, _unique); + discovery_->unsubscribe_all(_service, _unique); } - ep_mgr_impl_->clear_client_endpoints(_service, _instance, true); - ep_mgr_impl_->clear_client_endpoints(_service, _instance, false); + ep_mgr_impl_->clear_client_endpoints(_service, _unique, true); + ep_mgr_impl_->clear_client_endpoints(_service, _unique, false); its_info->set_endpoint(nullptr, true); its_info->set_endpoint(nullptr, false); - unset_all_eventpayloads(_service, _instance); + unset_all_eventpayloads(_service, _unique); } else { - auto its_eventgroups = find_eventgroups(_service, _instance); + auto its_eventgroups = find_eventgroups(_service, _unique); for (const auto &eg : its_eventgroups) { auto its_id = eg->get_eventgroup(); auto its_events = eg->get_events(); @@ -681,7 +681,7 @@ void routing_manager_impl::release_service(client_t _client, service_t _service, } } if (discovery_) { - discovery_->unsubscribe(_service, _instance, its_id, _client); + discovery_->unsubscribe(_service, _unique, its_id, _client); } if (!eg_has_subscribers) { for (const auto &e : its_events) { @@ -692,14 +692,14 @@ void routing_manager_impl::release_service(client_t _client, service_t _service, } } else { if (discovery_) { - discovery_->release_service(_service, _instance); + discovery_->release_service(_service, _unique); } } } void routing_manager_impl::subscribe( client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter) { @@ -712,39 +712,39 @@ void routing_manager_impl::subscribe( << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << ":" << std::setw(4) << _event << ":" << std::dec << (uint16_t)_major << "]"; - const client_t its_local_client = find_local_client(_service, _instance); + const client_t its_local_client = find_local_client(_service, _unique); if (get_client() == its_local_client) { #ifdef VSOMEIP_ENABLE_COMPAT - routing_manager_base::set_incoming_subscription_state(_client, _service, _instance, + routing_manager_base::set_incoming_subscription_state(_client, _service, _unique, _eventgroup, _event, subscription_state_e::IS_SUBSCRIBING); #endif auto self = shared_from_this(); - host_->on_subscription(_service, _instance, _eventgroup, _client, + host_->on_subscription(_service, _unique, _eventgroup, _client, _sec_client, get_env(_client), true, - [this, self, _client, _sec_client, _service, _instance, _eventgroup, + [this, self, _client, _sec_client, _service, _unique, _eventgroup, _major, _event, _filter] (const bool _subscription_accepted) { (void) ep_mgr_->find_or_create_local(_client); if (!_subscription_accepted) { if (stub_) - stub_->send_subscribe_nack(_client, _service, _instance, _eventgroup, _event); + stub_->send_subscribe_nack(_client, _service, get_instance_from_unique(_unique), _eventgroup, _event); VSOMEIP_INFO << "Subscription request from client: 0x" << std::hex << _client << std::dec << " for eventgroup: 0x" << _eventgroup << " rejected from application handler."; return; } else if (stub_) { - stub_->send_subscribe_ack(_client, _service, _instance, _eventgroup, _event); + stub_->send_subscribe_ack(_client, _service, get_instance_from_unique(_unique), _eventgroup, _event); } routing_manager_base::subscribe(_client, _sec_client, - _service, _instance, _eventgroup, _major, + _service, _unique, _eventgroup, _major, _event, _filter); #ifdef VSOMEIP_ENABLE_COMPAT - send_pending_notify_ones(_service, _instance, _eventgroup, _client); - routing_manager_base::erase_incoming_subscription_state(_client, _service, _instance, + send_pending_notify_ones(_service, _unique, _eventgroup, _client); + routing_manager_base::erase_incoming_subscription_state(_client, _service, _unique, _eventgroup, _event); #endif }); @@ -757,33 +757,33 @@ void routing_manager_impl::subscribe( // before calling insert_subscription and released after the call to // handle_subscription_state. std::unique_lock its_critical(remote_subscription_state_mutex_); - bool inserted = insert_subscription(_service, _instance, _eventgroup, + bool inserted = insert_subscription(_service, _unique, _eventgroup, _event, _filter, _client, &its_already_subscribed_events); const bool subscriber_is_rm_host = (get_client() == _client); if (inserted) { if (0 == its_local_client) { - handle_subscription_state(_client, _service, _instance, _eventgroup, _event); + handle_subscription_state(_client, _service, _unique, _eventgroup, _event); its_critical.unlock(); static const ttl_t configured_ttl(configuration_->get_sd_ttl()); - notify_one_current_value(_client, _service, _instance, + notify_one_current_value(_client, _service, _unique, _eventgroup, _event, its_already_subscribed_events); - auto its_info = find_eventgroup(_service, _instance, _eventgroup); + auto its_info = find_eventgroup(_service, _unique, _eventgroup); // if the subscriber is the rm_host itself: check if service // is available before subscribing via SD otherwise we sent // a StopSubscribe/Subscribe once the first offer is received if (its_info && - (!subscriber_is_rm_host || find_service(_service, _instance))) { - discovery_->subscribe(_service, _instance, _eventgroup, + (!subscriber_is_rm_host || find_service(_service, _unique))) { + discovery_->subscribe(_service, _unique, _eventgroup, _major, configured_ttl, its_info->is_selective() ? _client : VSOMEIP_ROUTING_CLIENT, its_info); } } else { its_critical.unlock(); - if (is_available(_service, _instance, _major) && stub_) { - stub_->send_subscribe(ep_mgr_->find_local(_service, _instance), - _client, _service, _instance, _eventgroup, _major, + if (is_available(_service, _unique, _major) && stub_) { + stub_->send_subscribe(ep_mgr_->find_local(_service, _unique), + _client, _service, get_instance_from_unique(_unique), _eventgroup, _major, _event, _filter, PENDING_SUBSCRIPTION_ID); } } @@ -791,7 +791,7 @@ void routing_manager_impl::subscribe( if (subscriber_is_rm_host) { std::lock_guard ist_lock(pending_subscription_mutex_); subscription_data_t subscription = { - _service, _instance, + _service, get_instance_from_unique(_unique), _eventgroup, _major, _event, _filter, *_sec_client @@ -806,21 +806,21 @@ void routing_manager_impl::subscribe( void routing_manager_impl::unsubscribe( client_t _client, const vsomeip_sec_client_t *_sec_client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { VSOMEIP_INFO << "UNSUBSCRIBE(" << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "." << std::setw(4) << _event << "]"; bool last_subscriber_removed(true); std::shared_ptr its_info - = find_eventgroup(_service, _instance, _eventgroup); + = find_eventgroup(_service, _unique, _eventgroup); if (its_info) { for (const auto& e : its_info->get_events()) { if (e->get_event() == _event || ANY_EVENT == _event) @@ -835,18 +835,18 @@ void routing_manager_impl::unsubscribe( } if (discovery_) { - host_->on_subscription(_service, _instance, _eventgroup, _client, + host_->on_subscription(_service, _unique, _eventgroup, _client, _sec_client, get_env(_client), false, [](const bool _subscription_accepted){ (void)_subscription_accepted; }); - if (0 == find_local_client(_service, _instance)) { + if (0 == find_local_client(_service, _unique)) { if (get_client() == _client) { std::lock_guard ist_lock(pending_subscription_mutex_); - remove_pending_subscription(_service, _instance, _eventgroup, _event); + remove_pending_subscription(_service, _unique, _eventgroup, _event); } if (last_subscriber_removed) { - unset_all_eventpayloads(_service, _instance, _eventgroup); + unset_all_eventpayloads(_service, _unique, _eventgroup); { - auto tuple = std::make_tuple(_service, _instance, _eventgroup, _client); + auto tuple = std::make_tuple(_service, _unique, _eventgroup, _client); std::lock_guard its_lock(remote_subscription_state_mutex_); remote_subscription_state_.erase(tuple); } @@ -855,21 +855,21 @@ void routing_manager_impl::unsubscribe( if (its_info && (last_subscriber_removed || its_info->is_selective())) { - discovery_->unsubscribe(_service, _instance, _eventgroup, + discovery_->unsubscribe(_service, _unique, _eventgroup, its_info->is_selective() ? _client : VSOMEIP_ROUTING_CLIENT); } } else { if (get_client() == _client) { std::lock_guard ist_lock(pending_subscription_mutex_); - remove_pending_subscription(_service, _instance, _eventgroup, _event); + remove_pending_subscription(_service, _unique, _eventgroup, _event); if (stub_) stub_->send_unsubscribe( - ep_mgr_->find_local(_service, _instance), - _client, _service, _instance, _eventgroup, _event, + ep_mgr_->find_local(_service, _unique), + _client, _service, _unique, _eventgroup, _event, PENDING_SUBSCRIPTION_ID); } } - ep_mgr_impl_->clear_multicast_endpoints(_service, _instance); + ep_mgr_impl_->clear_multicast_endpoints(_service, _unique); } else { VSOMEIP_ERROR<< "SOME/IP eventgroups require SD to be enabled!"; @@ -883,7 +883,7 @@ bool routing_manager_impl::send(client_t _client, } bool routing_manager_impl::send(client_t _client, const byte_t *_data, - length_t _size, instance_t _instance, bool _reliable, + length_t _size, unique_version_t _unique, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check, bool _sent_from_remote, bool _force) { @@ -902,7 +902,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, = (its_service == sd::service && its_method == sd::method); if (is_request) { - its_target_client = find_local_client(its_service, _instance); + its_target_client = find_local_client(its_service, _unique); its_target = find_local(its_target_client); } else if (!is_notification) { its_target = find_local(its_client); @@ -912,11 +912,11 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, if (_client == get_client()) { #ifdef USE_DLT trace::header its_header; - if (its_header.prepare(its_target, true, _instance)) + if (its_header.prepare(its_target, true, get_instance_from_unique(_unique))) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, _data, _size); #endif - deliver_message(_data, _size, _instance, _reliable, + deliver_message(_data, _size, get_instance_from_unique(_unique), _reliable, _bound_client, _sec_client, _status_check, _sent_from_remote); return true; @@ -928,25 +928,25 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, if (its_target) { #ifdef USE_DLT if ((is_request && its_client == get_client()) || - (is_response && find_local_client(its_service, _instance) == get_client()) || - (is_notification && find_local_client(its_service, _instance) == VSOMEIP_ROUTING_CLIENT)) { + (is_response && find_local_client(its_service, _unique) == get_client()) || + (is_notification && find_local_client(its_service, _unique) == VSOMEIP_ROUTING_CLIENT)) { trace::header its_header; - if (its_header.prepare(its_target, true, _instance)) + if (its_header.prepare(its_target, true, get_instance_from_unique(_unique))) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, _data, _size); } #endif - is_sent = send_local(its_target, its_target_client, _data, _size, _instance, _reliable, + is_sent = send_local(its_target, its_target_client, _data, _size, _unique, _reliable, protocol::id_e::SEND_ID, _status_check); } else { // Check whether hosting application should get the message // If not, check routes to external if ((its_client == host_->get_client() && is_response) - || (find_local_client(its_service, _instance) + || (find_local_client(its_service, _unique) == host_->get_client() && is_request)) { // TODO: Find out how to handle session id here - is_sent = deliver_message(_data, _size, _instance, _reliable, + is_sent = deliver_message(_data, _size, get_instance_from_unique(_unique), _reliable, VSOMEIP_ROUTING_CLIENT, _sec_client, _status_check); } else { e2e_buffer its_buffer; @@ -963,7 +963,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, // Build a corresponding buffer its_buffer.assign(_data + its_base, _data + _size); - e2e_provider_->protect({ its_service, its_method }, its_buffer, _instance); + e2e_provider_->protect({ its_service, its_method }, its_buffer, get_instance_from_unique(_unique)); // Prepend header its_buffer.insert(its_buffer.begin(), _data, _data + its_base); @@ -975,7 +975,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, } if (is_request) { its_target = ep_mgr_impl_->find_or_create_remote_client( - its_service, _instance, _reliable); + its_service, _unique, _reliable); if (its_target) { #ifdef USE_DLT trace::header its_header; @@ -990,18 +990,18 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, << std::hex << std::setfill('0') << std::setw(4) << its_client << "): [" << std::setw(4) << its_service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_method << "] " << std::setw(4) << its_session; } } else { - std::shared_ptr its_info(find_service(its_service, _instance)); + std::shared_ptr its_info(find_service(its_service, _unique)); if (its_info || is_service_discovery) { if (is_notification && !is_service_discovery) { - (void)send_local_notification(get_client(), _data, _size, _instance, + (void)send_local_notification(get_client(), _data, _size, _unique, _reliable, _status_check, _force); method_t its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); - std::shared_ptr its_event = find_event(its_service, _instance, its_method); + std::shared_ptr its_event = find_event(its_service, _unique, its_method); if (its_event) { #ifdef USE_DLT bool has_sent(false); @@ -1014,7 +1014,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, if (its_udp_server_endpoint || its_tcp_server_endpoint) { const auto its_reliability = its_event->get_reliability(); for (auto its_group : its_event->get_eventgroups()) { - auto its_eventgroup = find_eventgroup(its_service, _instance, its_group); + auto its_eventgroup = find_eventgroup(its_service, _unique, its_group); if (its_eventgroup) { // Unicast targets for (const auto &its_remote : its_eventgroup->get_unicast_targets()) { @@ -1039,7 +1039,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, if (its_eventgroup->get_multicast(its_address, its_port)) { std::shared_ptr its_multicast_target; its_multicast_target = endpoint_definition::get(its_address, - its_port, false, its_service, _instance); + its_port, false, its_service, _unique); its_targets.insert(its_multicast_target); } } @@ -1061,7 +1061,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, #ifdef USE_DLT if (has_sent) { trace::header its_header; - if (its_header.prepare(nullptr, true, _instance)) + if (its_header.prepare(nullptr, true, get_instance_from_unique(_unique))) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, _data, _size); } @@ -1079,7 +1079,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, << std::hex << std::setfill('0') << std::setw(4) << its_client << "): [" << std::setw(4) << its_service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_method << "] " << std::setw(4) << its_session; return false; @@ -1089,7 +1089,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, if (its_target) { #ifdef USE_DLT trace::header its_header; - if (its_header.prepare(its_target, true, _instance)) + if (its_header.prepare(its_target, true, get_instance_from_unique(_unique))) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, _data, _size); #endif @@ -1100,7 +1100,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, << std::hex << std::setfill('0') << std::setw(4) << its_client << "): [" << std::setw(4) << its_service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_method << "] " << std::setw(4) << its_session << " could not be found!"; @@ -1113,7 +1113,7 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, << std::hex << std::setfill('0') << std::setw(4) << its_client << "): [" << std::setw(4) << its_service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_method << "] " << std::setw(4) << its_session; } @@ -1169,7 +1169,7 @@ bool routing_manager_impl::send_to( bool routing_manager_impl::send_to( const std::shared_ptr &_target, - const byte_t *_data, uint32_t _size, instance_t _instance) { + const byte_t *_data, uint32_t _size, unique_version_t _unique) { std::shared_ptr its_endpoint = ep_mgr_impl_->find_server_endpoint( @@ -1178,11 +1178,11 @@ bool routing_manager_impl::send_to( if (its_endpoint) { #ifdef USE_DLT trace::header its_header; - if (its_header.prepare(its_endpoint, true, _instance)) + if (its_header.prepare(its_endpoint, true, get_instance_from_unique(_unique))) tc_->trace(its_header.data_, VSOMEIP_TRACE_HEADER_SIZE, _data, _size); #else - (void) _instance; + (void) get_instance_from_unique(_unique); #endif return its_endpoint->send_to(_target, _data, _size); } @@ -1213,7 +1213,7 @@ bool routing_manager_impl::send_via_sd( } void routing_manager_impl::register_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, const event_type_e _type, reliability_type_e _reliability, @@ -1221,7 +1221,7 @@ void routing_manager_impl::register_event(client_t _client, bool _update_on_change, epsilon_change_func_t _epsilon_change_func, bool _is_provided, bool _is_shadow, bool _is_cache_placeholder) { - auto its_event = find_event(_service, _instance, _notifier); + auto its_event = find_event(_service, _unique, _notifier); bool is_first(false); if (its_event) { if (!its_event->has_ref(_client, _is_provided)) { @@ -1232,7 +1232,7 @@ void routing_manager_impl::register_event(client_t _client, } if (is_first) { routing_manager_base::register_event(_client, - _service, _instance, + _service, _unique, _notifier, _eventgroups, _type, _reliability, _cycle, _change_resets_cycle, _update_on_change, @@ -1243,19 +1243,19 @@ void routing_manager_impl::register_event(client_t _client, << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _notifier << ":is_provider=" << std::boolalpha << _is_provided << "]"; } void routing_manager_impl::register_shadow_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, event_type_e _type, reliability_type_e _reliability, bool _is_provided, bool _is_cyclic) { routing_manager_base::register_event(_client, - _service, _instance, + _service, _unique, _notifier, _eventgroups, _type, _reliability, (_is_cyclic ? std::chrono::milliseconds(1) @@ -1265,13 +1265,13 @@ void routing_manager_impl::register_shadow_event(client_t _client, } void routing_manager_impl::unregister_shadow_event(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, event_t _event, bool _is_provided) { - routing_manager_base::unregister_event(_client, _service, _instance, + routing_manager_base::unregister_event(_client, _service, _unique, _event, _is_provided); } -void routing_manager_impl::notify_one(service_t _service, instance_t _instance, +void routing_manager_impl::notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force #ifdef VSOMEIP_ENABLE_COMPAT @@ -1279,19 +1279,19 @@ void routing_manager_impl::notify_one(service_t _service, instance_t _instance, #endif ) { if (find_local(_client)) { - routing_manager_base::notify_one(_service, _instance, _event, _payload, + routing_manager_base::notify_one(_service, _unique, _event, _payload, _client, _force #ifdef VSOMEIP_ENABLE_COMPAT , _remote_subscriber #endif ); } else { - std::shared_ptr its_event = find_event(_service, _instance, _event); + std::shared_ptr its_event = find_event(_service, _unique, _event); if (its_event) { std::set > its_targets; const auto its_reliability = its_event->get_reliability(); for (const auto g : its_event->get_eventgroups()) { - const auto its_eventgroup = find_eventgroup(_service, _instance, g); + const auto its_eventgroup = find_eventgroup(_service, _unique, g); if (its_eventgroup) { const auto its_subscriptions = its_eventgroup->get_remote_subscriptions(); for (const auto &s : its_subscriptions) { @@ -1320,7 +1320,7 @@ void routing_manager_impl::notify_one(service_t _service, instance_t _instance, } } else { VSOMEIP_WARNING << "Attempt to update the undefined event/field [" - << std::hex << _service << "." << _instance << "." << _event + << std::hex << _service << "." << get_instance_from_unique(_unique) << "." << _event << "]"; } } @@ -1330,9 +1330,11 @@ void routing_manager_impl::on_availability(service_t _service, instance_t _insta availability_state_e _state, major_version_t _major, minor_version_t _minor) { // insert subscriptions of routing manager into service discovery // to send SubscribeEventgroup after StopOffer / Offer was received + unique_version_t its_unique = get_unique_version(_instance, _major); + if (_state == availability_state_e::AS_AVAILABLE) { if (discovery_) { - const client_t its_local_client = find_local_client(_service, _instance); + const client_t its_local_client = find_local_client(_service, its_unique); // remote service if (VSOMEIP_ROUTING_CLIENT == its_local_client) { static const ttl_t configured_ttl(configuration_->get_sd_ttl()); @@ -1342,11 +1344,11 @@ void routing_manager_impl::on_availability(service_t _service, instance_t _insta if (ps.service_ == _service && ps.instance_ == _instance && ps.major_ == _major) { - auto its_info = find_eventgroup(_service, _instance, ps.eventgroup_); + auto its_info = find_eventgroup(_service, its_unique, ps.eventgroup_); if (its_info) { discovery_->subscribe( _service, - _instance, + its_unique, ps.eventgroup_, _major, configured_ttl, @@ -1358,47 +1360,47 @@ void routing_manager_impl::on_availability(service_t _service, instance_t _insta } } } - host_->on_availability(_service, _instance, _state, _major, _minor); + host_->on_availability(_service, get_instance_from_unique(its_unique), _state, _major, _minor); } bool routing_manager_impl::offer_service_remotely(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled) { bool ret = true; - if(!is_available(_service, _instance, ANY_MAJOR)) { + if(!is_available(_service, _unique, ANY_MAJOR)) { VSOMEIP_ERROR << __func__ << ": Service [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << "] is not offered locally! Won't offer it remotely."; ret = false; } else { // update service info in configuration - if (!configuration_->remote_offer_info_add(_service, _instance, _port, + if (!configuration_->remote_offer_info_add(_service, _unique, _port, _reliable, _magic_cookies_enabled)) { ret = false; } else { // trigger event registration again to create shadow events - const client_t its_offering_client = find_local_client(_service, _instance); + const client_t its_offering_client = find_local_client(_service, _unique); if (its_offering_client == VSOMEIP_ROUTING_CLIENT) { VSOMEIP_ERROR << __func__ << " didn't find offering client for service [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << "]"; ret = false; } else { if (stub_ && !stub_->send_provided_event_resend_request(its_offering_client, - pending_remote_offer_add(_service, _instance))) { + pending_remote_offer_add(_service, _unique))) { VSOMEIP_ERROR << __func__ << ": Couldn't send event resend" << std::hex << std::setfill('0') << "request to client 0x" << std::setw(4) << its_offering_client << " providing service [" << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << "]"; ret = false; @@ -1410,30 +1412,30 @@ bool routing_manager_impl::offer_service_remotely(service_t _service, } bool routing_manager_impl::stop_offer_service_remotely(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled) { bool ret = true; bool service_still_offered_remote(false); // update service configuration - if (!configuration_->remote_offer_info_remove(_service, _instance, _port, + if (!configuration_->remote_offer_info_remove(_service, _unique, _port, _reliable, _magic_cookies_enabled, &service_still_offered_remote)) { VSOMEIP_ERROR << __func__ << " couldn't remove remote offer info for service [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << "] from configuration"; ret = false; } - std::shared_ptr its_info = find_service(_service, _instance); + std::shared_ptr its_info = find_service(_service, _unique); std::shared_ptr its_server_endpoint; if (its_info) { its_server_endpoint = its_info->get_endpoint(_reliable); } // don't deregister events if the service is still offered remotely if (!service_still_offered_remote) { - const client_t its_offering_client = find_local_client(_service, _instance); + const client_t its_offering_client = find_local_client(_service, _unique); major_version_t its_major(0); minor_version_t its_minor(0); if (its_info) { @@ -1442,14 +1444,14 @@ bool routing_manager_impl::stop_offer_service_remotely(service_t _service, } // unset payload and clear subcribers routing_manager_base::stop_offer_service(its_offering_client, - _service, _instance, its_major, its_minor); + _service, _unique, its_major, its_minor); // unregister events - for (const event_t its_event_id : find_events(_service, _instance)) { - unregister_shadow_event(its_offering_client, _service, _instance, + for (const event_t its_event_id : find_events(_service, _unique)) { + unregister_shadow_event(its_offering_client, _service, _unique, its_event_id, true); } - clear_targets_and_pending_sub_from_eventgroups(_service, _instance); - clear_remote_subscriber(_service, _instance); + clear_targets_and_pending_sub_from_eventgroups(_service, _unique); + clear_remote_subscriber(_service, _unique); if (discovery_ && its_info) { discovery_->stop_offer_service(its_info, true); @@ -1468,7 +1470,7 @@ bool routing_manager_impl::stop_offer_service_remotely(service_t _service, VSOMEIP_INFO << __func__ << std::hex << std::setfill('0') << " only sending the StopOffer to [" << std::setw(4) << _service << '.' - << std::setw(4) << _instance << ']' + << std::setw(4) << get_instance_from_unique(_unique) << ']' << " with reliability (" << std::boolalpha << !_reliable << ')' << " as the service is still partly offered!"; } @@ -1495,6 +1497,7 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, method_t its_method; uint8_t its_check_status = e2e::profile_interface::generic_check_status::E2E_OK; instance_t its_instance(0x0); + unique_version_t its_unique; message_type_e its_message_type; #ifdef USE_DLT bool is_forwarded(true); @@ -1522,10 +1525,11 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, } } else { if (_is_multicast) { - its_instance = ep_mgr_impl_->find_instance_multicast(its_service, _remote_address); + its_unique = ep_mgr_impl_->find_unique_multicast(its_service, _remote_address); } else { - its_instance = ep_mgr_impl_->find_instance(its_service, _receiver); + its_unique = ep_mgr_impl_->find_unique(its_service, _receiver); } + its_instance = get_instance_from_unique(its_unique); if (its_instance == 0xFFFF) { its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); const client_t its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); @@ -1547,7 +1551,7 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, return; } } - return_code_e return_code = check_error(_data, _size, its_instance); + return_code_e return_code = check_error(_data, _size, its_unique); if(!(_size >= VSOMEIP_MESSAGE_TYPE_POS && utility::is_request_no_return(_data[VSOMEIP_MESSAGE_TYPE_POS]))) { if (return_code != return_code_e::E_OK && return_code != return_code_e::E_NOT_OK) { send_error(return_code, _data, _size, its_instance, @@ -1565,7 +1569,7 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, if (utility::is_request(_data[VSOMEIP_MESSAGE_TYPE_POS])) { client_t requester = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); its_method = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); - if (!configuration_->is_offered_remote(its_service, its_instance)) { + if (!configuration_->is_offered_remote(its_service, its_unique)) { VSOMEIP_WARNING << std::hex << "Security: Received a remote request " << "for service/instance " << its_service << "/" << its_instance << " which isn't offered remote ~> Skip message!"; @@ -1606,7 +1610,7 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, } // ACL check message - if(!is_acl_message_allowed(_receiver, its_service, its_instance, _remote_address)) { + if(!is_acl_message_allowed(_receiver, its_service, its_unique, _remote_address)) { return; } @@ -1614,7 +1618,7 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, #ifdef USE_DLT is_forwarded = #endif - on_message(its_service, its_instance, _data, _size, _receiver->is_reliable(), + on_message(its_service, its_unique, _data, _size, _receiver->is_reliable(), _bound_client, _sec_client, its_check_status, true); } } @@ -1636,7 +1640,7 @@ void routing_manager_impl::on_message(const byte_t *_data, length_t _size, #endif } -bool routing_manager_impl::on_message(service_t _service, instance_t _instance, +bool routing_manager_impl::on_message(service_t _service, unique_version_t _unique, const byte_t *_data, length_t _size, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _check_status, bool _is_from_remote) { @@ -1644,7 +1648,7 @@ bool routing_manager_impl::on_message(service_t _service, instance_t _instance, std::stringstream msg; msg << "rmi::on_message(" << std::hex << std::setfill('0') << std::setw(4) - << _service << ", " << _instance << "): "; + << _service << ", " << get_instance_from_unique(_unique) << "): "; for (uint32_t i = 0; i < _size; ++i) msg << std::hex << std::setfill('0') << std::setw(2) << static_cast(_data[i]) << " "; VSOMEIP_INFO << msg.str(); @@ -1653,18 +1657,18 @@ bool routing_manager_impl::on_message(service_t _service, instance_t _instance, bool is_forwarded(true); if (utility::is_request(_data[VSOMEIP_MESSAGE_TYPE_POS])) { - its_client = find_local_client(_service, _instance); + its_client = find_local_client(_service, _unique); } else { its_client = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); } #if 0 // ACL message check for local test purpouse - std::shared_ptr its_info = find_service(_service, _instance); + std::shared_ptr its_info = find_service(_service, _unique); if (its_info) { std::shared_ptr _receiver = its_info->get_endpoint(_reliable); if (_receiver && _receiver.get()) { - if(!is_acl_message_allowed(_receiver.get(), _service, _instance, + if(!is_acl_message_allowed(_receiver.get(), _service, _unique, boost::asio::ip::address_v4::from_string("127.0.0.1"))) { return false; } @@ -1673,23 +1677,23 @@ bool routing_manager_impl::on_message(service_t _service, instance_t _instance, #endif if (utility::is_notification(_data[VSOMEIP_MESSAGE_TYPE_POS])) { - is_forwarded = deliver_notification(_service, _instance, _data, _size, + is_forwarded = deliver_notification(_service, _unique, _data, _size, _reliable, _bound_client, _sec_client, _check_status, _is_from_remote); } else if (its_client == host_->get_client()) { - deliver_message(_data, _size, _instance, + deliver_message(_data, _size, get_instance_from_unique(_unique), _reliable, _bound_client, _sec_client, _check_status, _is_from_remote); } else { - send(its_client, _data, _size, _instance, _reliable, + send(its_client, _data, _size, _unique, _reliable, _bound_client, _sec_client, _check_status, _is_from_remote, false); //send to proxy } return is_forwarded; } void routing_manager_impl::on_notification(client_t _client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const byte_t *_data, length_t _size, bool _notify_one) { event_t its_event_id = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); - std::shared_ptr its_event = find_event(_service, _instance, its_event_id); + std::shared_ptr its_event = find_event(_service, _unique, its_event_id); if (its_event) { uint32_t its_length = utility::get_payload_size(_data, _size); std::shared_ptr its_payload = @@ -1698,7 +1702,7 @@ void routing_manager_impl::on_notification(client_t _client, its_length); if (_notify_one) { - notify_one(_service, _instance, its_event->get_event(), + notify_one(_service, _unique, its_event->get_event(), its_payload, _client, true #ifdef VSOMEIP_ENABLE_COMPAT , false @@ -1717,37 +1721,37 @@ void routing_manager_impl::on_notification(client_t _client, } void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major, minor_version_t _minor) { + unique_version_t _unique, major_version_t _major, minor_version_t _minor) { { std::lock_guard its_lock(local_services_mutex_); auto found_service = local_services_.find(_service); if (found_service != local_services_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - if ( std::get<0>(found_instance->second) != _major - || std::get<1>(found_instance->second) != _minor - || std::get<2>(found_instance->second) != _client) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + if ( std::get<0>(found_unique->second) != _major + || std::get<1>(found_unique->second) != _minor + || std::get<2>(found_unique->second) != _client) { VSOMEIP_WARNING << "routing_manager_impl::on_stop_offer_service: " << "trying to delete service not matching exactly " << "the one offered previously: " << "[" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << _instance << "." << std::dec << static_cast(_major) + << get_instance_from_unique(_unique) << "." << std::dec << static_cast(_major) << "." << _minor << "] by application: " << std::hex << std::setw(4) << _client << ". Stored: [" << std::setw(4) << _service - << "." << _instance << "." + << "." << get_instance_from_unique(_unique) << "." << std::dec - << static_cast(std::get<0>(found_instance->second)) << "." - << std::get<1>(found_instance->second) + << static_cast(std::get<0>(found_unique->second)) << "." + << std::get<1>(found_unique->second) << "] by application: " << std::hex - << std::setw(4) << std::get<2>(found_instance->second); + << std::setw(4) << std::get<2>(found_unique->second); } - if (std::get<2>(found_instance->second) == _client) { - found_service->second.erase(_instance); + if (std::get<2>(found_unique->second) == _client) { + found_service->second.erase(_unique); if (found_service->second.size() == 0) { local_services_.erase(_service); } @@ -1756,7 +1760,7 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se } } - routing_manager_base::stop_offer_service(_client, _service, _instance, + routing_manager_base::stop_offer_service(_client, _service, _unique, _major, _minor); /** @@ -1768,7 +1772,7 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se */ std::shared_ptr its_reliable_endpoint; std::shared_ptr its_unreliable_endpoint; - std::shared_ptr its_info(find_service(_service, _instance)); + std::shared_ptr its_info(find_service(_service, _unique)); if (its_info) { its_reliable_endpoint = its_info->get_endpoint(true); its_unreliable_endpoint = its_info->get_endpoint(false); @@ -1792,7 +1796,7 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se auto ptr = shared_from_this(); auto callback = [this, ptr, its_info, its_reliable_endpoint, its_unreliable_endpoint, - ready_to_stop, _service, _instance, _major, _minor] + ready_to_stop, _service, _unique, _major, _minor] (std::shared_ptr _endpoint) { if (its_reliable_endpoint && its_reliable_endpoint == _endpoint) @@ -1805,7 +1809,7 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se if (its_info->get_major() == _major && its_info->get_minor() == _minor) discovery_->stop_offer_service(its_info, true); } - del_routing_info(_service, _instance, + del_routing_info(_service, _unique, its_reliable_endpoint != nullptr, its_unreliable_endpoint != nullptr); for (const auto& ep: {its_reliable_endpoint, its_unreliable_endpoint}) { @@ -1822,12 +1826,12 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se }, ANY_SERVICE); } // Clear service info and service group - clear_service_info(_service, _instance, ep->is_reliable()); + clear_service_info(_service, _unique, ep->is_reliable()); } } if (ready_to_stop->is_ready()) - erase_offer_command(_service, _instance); + erase_offer_command(_service, _unique); }; for (const auto& ep : { its_reliable_endpoint, its_unreliable_endpoint }) { @@ -1836,7 +1840,7 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se } if (!its_reliable_endpoint && !its_unreliable_endpoint) { - erase_offer_command(_service, _instance); + erase_offer_command(_service, _unique); } std::set > its_eventgroup_info_set; @@ -1844,9 +1848,9 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se std::lock_guard its_eventgroups_lock(eventgroups_mutex_); auto find_service = eventgroups_.find(_service); if (find_service != eventgroups_.end()) { - auto find_instance = find_service->second.find(_instance); - if (find_instance != find_service->second.end()) { - for (auto e : find_instance->second) { + auto find_unique = find_service->second.find(_unique); + if (find_unique != find_service->second.end()) { + for (auto e : find_unique->second) { its_eventgroup_info_set.insert(e.second); } } @@ -1857,7 +1861,7 @@ void routing_manager_impl::on_stop_offer_service(client_t _client, service_t _se e->clear_remote_subscriptions(); } } else { - erase_offer_command(_service, _instance); + erase_offer_command(_service, _unique); } } @@ -2001,14 +2005,14 @@ bool routing_manager_impl::deliver_message(const byte_t *_data, length_t _size, #ifdef VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING bool routing_manager_impl::has_subscribed_eventgroup( - service_t _service, instance_t _instance) const { + service_t _service, unique_version_t _unique) const { std::lock_guard its_lock(eventgroups_mutex_); auto found_service = eventgroups_.find(_service); if (found_service != eventgroups_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) - for (const auto &its_eventgroup : found_instance->second) + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) + for (const auto &its_eventgroup : found_unique->second) for (const auto &e : its_eventgroup.second->get_events()) if (!e->get_subscribers().empty()) return true; @@ -2019,7 +2023,7 @@ routing_manager_impl::has_subscribed_eventgroup( #endif // VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING bool routing_manager_impl::deliver_notification( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const byte_t *_data, length_t _length, bool _reliable, client_t _bound_client, const vsomeip_sec_client_t *_sec_client, uint8_t _status_check, bool _is_from_remote) { @@ -2027,7 +2031,7 @@ bool routing_manager_impl::deliver_notification( event_t its_event_id = bithelper::read_uint16_be(&_data[VSOMEIP_METHOD_POS_MIN]); client_t its_client_id = bithelper::read_uint16_be(&_data[VSOMEIP_CLIENT_POS_MIN]); - std::shared_ptr its_event = find_event(_service, _instance, its_event_id); + std::shared_ptr its_event = find_event(_service, _unique, its_event_id); if (its_event) { if (!its_event->is_provided()) { if (its_event->get_subscribers().size() == 0) { @@ -2035,7 +2039,7 @@ bool routing_manager_impl::deliver_notification( // to other events of the event's eventgroups bool cache_event = false; for (const auto eg : its_event->get_eventgroups()) { - std::shared_ptr egi = find_eventgroup(_service, _instance, eg); + std::shared_ptr egi = find_eventgroup(_service, _unique, eg); if (egi) { for (const auto &e : egi->get_events()) { cache_event = (e->get_subscribers().size() > 0); @@ -2052,7 +2056,7 @@ bool routing_manager_impl::deliver_notification( VSOMEIP_WARNING << __func__ << ": dropping [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_event_id << "]. No subscription to corresponding eventgroup."; return true; // as there is nothing to do @@ -2066,7 +2070,7 @@ bool routing_manager_impl::deliver_notification( // incoming events statistics (void) insert_event_statistics( - _service, _instance, its_event_id, its_length); + _service, _unique, its_event_id, its_length); // Ignore the filter for messages coming from other local clients // as the filter was already applied there. @@ -2075,13 +2079,13 @@ bool routing_manager_impl::deliver_notification( if (its_event->get_type() != event_type_e::ET_SELECTIVE_EVENT) { for (const auto its_local_client : its_subscribers) { if (its_local_client == host_->get_client()) { - deliver_message(_data, _length, _instance, _reliable, + deliver_message(_data, _length, get_instance_from_unique(_unique), _reliable, _bound_client, _sec_client, _status_check, _is_from_remote); } else { std::shared_ptr its_local_target = find_local(its_local_client); if (its_local_target) { send_local(its_local_target, VSOMEIP_ROUTING_CLIENT, _data, _length, - _instance, _reliable, protocol::id_e::SEND_ID, _status_check); + _unique, _reliable, protocol::id_e::SEND_ID, _status_check); } } } @@ -2094,13 +2098,13 @@ bool routing_manager_impl::deliver_notification( if (its_subscribers.find(its_client_id) != its_subscribers.end()) { if (its_client_id == host_->get_client()) { - deliver_message(_data, _length, _instance, _reliable, + deliver_message(_data, _length, get_instance_from_unique(_unique), _reliable, _bound_client, _sec_client, _status_check, _is_from_remote); } else { std::shared_ptr its_local_target = find_local(its_client_id); if (its_local_target) { send_local(its_local_target, VSOMEIP_ROUTING_CLIENT, - _data, _length, _instance, _reliable, protocol::id_e::SEND_ID, _status_check); + _data, _length, _unique, _reliable, protocol::id_e::SEND_ID, _status_check); } } } @@ -2108,24 +2112,24 @@ bool routing_manager_impl::deliver_notification( } else { #ifdef VSOMEIP_ENABLE_DEFAULT_EVENT_CACHING - if (has_subscribed_eventgroup(_service, _instance)) { - if (!is_suppress_event(_service, _instance, its_event_id)) { + if (has_subscribed_eventgroup(_service, _unique)) { + if (!is_suppress_event(_service, _unique, its_event_id)) { VSOMEIP_WARNING << __func__ << ": Caching unregistered event [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_event_id << "]"; } routing_manager_base::register_event(host_->get_client(), - _service, _instance, its_event_id, { }, + _service, _unique, its_event_id, { }, event_type_e::ET_UNKNOWN, _reliable ? reliability_type_e::RT_RELIABLE : reliability_type_e::RT_UNRELIABLE, std::chrono::milliseconds::zero(), false, true, nullptr, true, true, true); - its_event = find_event(_service, _instance, its_event_id); + its_event = find_event(_service, _unique, its_event_id); if (its_event) { auto its_length = utility::get_payload_size(_data, _length); auto its_payload = runtime::get()->create_payload( @@ -2135,22 +2139,22 @@ bool routing_manager_impl::deliver_notification( VSOMEIP_ERROR << __func__ << ": Event registration failed [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_event_id << "]"; - } else if (!is_suppress_event(_service, _instance, its_event_id)) { + } else if (!is_suppress_event(_service, _unique, its_event_id)) { VSOMEIP_WARNING << __func__ << ": Dropping unregistered event [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_event_id << "] " << "Service has no subscribed eventgroup."; } #else - if (!is_suppress_event(_service, _instance, its_event_id)) { + if (!is_suppress_event(_service, _unique, its_event_id)) { VSOMEIP_WARNING << __func__ << ": Event [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_event_id << "]" << " is not registered. The message is dropped."; } @@ -2160,16 +2164,16 @@ bool routing_manager_impl::deliver_notification( } bool routing_manager_impl::is_suppress_event(service_t _service, - instance_t _instance, event_t _event) const { - bool status = configuration_->check_suppress_events(_service, _instance, _event); + unique_version_t _unique, event_t _event) const { + bool status = configuration_->check_suppress_events(_service, _unique, _event); return status; } std::shared_ptr routing_manager_impl::find_eventgroup( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) const { - return routing_manager_base::find_eventgroup(_service, _instance, _eventgroup); + return routing_manager_base::find_eventgroup(_service, _unique, _eventgroup); } std::shared_ptr routing_manager_impl::create_service_discovery_endpoint( @@ -2237,46 +2241,46 @@ services_t routing_manager_impl::get_offered_services() const { } std::shared_ptr routing_manager_impl::get_offered_service( - service_t _service, instance_t _instance) const { + service_t _service, unique_version_t _unique) const { std::shared_ptr its_info; - its_info = find_service(_service, _instance); + its_info = find_service(_service, _unique); if (its_info && !its_info->is_local()) { its_info.reset(); } return its_info; } -std::map> +std::map> routing_manager_impl::get_offered_service_instances(service_t _service) const { - std::map> its_instances; + std::map> its_uniques; const services_t its_services(get_services()); const auto found_service = its_services.find(_service); if (found_service != its_services.end()) { for (const auto& i : found_service->second) { if (i.second->is_local()) { - its_instances[i.first] = i.second; + its_uniques[i.first] = i.second; } } } - return its_instances; + return its_uniques; } bool routing_manager_impl::is_acl_message_allowed(endpoint *_receiver, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const boost::asio::ip::address &_remote_address) const { if (message_acceptance_handler_ && _receiver) { // Check the ACL whitelist rules if shall accepts the message - std::shared_ptr its_info(find_service(_service, _instance)); + std::shared_ptr its_info(find_service(_service, _unique)); const bool is_local = its_info && its_info->is_local(); message_acceptance_t message_acceptance { _remote_address.to_v4().to_uint(), - _receiver->get_local_port(), is_local, _service, _instance + _receiver->get_local_port(), is_local, _service, get_instance_from_unique(_unique) }; if (!message_acceptance_handler_(message_acceptance)) { VSOMEIP_WARNING << "Message from " << _remote_address.to_string() - << std::hex << " with service/instance " << _instance << "/" - << _instance << " was rejected by the ACL check."; + << std::hex << " with service/instance " << get_instance_from_unique(_unique) << "/" + << get_instance_from_unique(_unique) << " was rejected by the ACL check."; return false; } } @@ -2287,40 +2291,40 @@ bool routing_manager_impl::is_acl_message_allowed(endpoint *_receiver, // PRIVATE /////////////////////////////////////////////////////////////////////////////// void routing_manager_impl::init_service_info( - service_t _service, instance_t _instance, bool _is_local_service) { - std::shared_ptr its_info = find_service(_service, _instance); + service_t _service, unique_version_t _unique, bool _is_local_service) { + std::shared_ptr its_info = find_service(_service, _unique); if (!its_info) { VSOMEIP_ERROR << "routing_manager_impl::init_service_info: couldn't " "find serviceinfo for service: [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "]" + << std::setw(4) << get_instance_from_unique(_unique) << "]" << " is_local_service=" << _is_local_service; return; } if (configuration_) { // Create server endpoints for local services only if (_is_local_service) { - const bool is_someip = configuration_->is_someip(_service, _instance); + const bool is_someip = configuration_->is_someip(_service, _unique); uint16_t its_reliable_port = configuration_->get_reliable_port( - _service, _instance); + _service, _unique); bool _is_found(false); if (ILLEGAL_PORT != its_reliable_port) { std::shared_ptr its_reliable_endpoint = ep_mgr_impl_->find_or_create_server_endpoint( its_reliable_port, true, is_someip, _service, - _instance, _is_found); + _unique, _is_found); if (its_reliable_endpoint) { its_info->set_endpoint(its_reliable_endpoint, true); } } uint16_t its_unreliable_port = configuration_->get_unreliable_port( - _service, _instance); + _service, _unique); if (ILLEGAL_PORT != its_unreliable_port) { std::shared_ptr its_unreliable_endpoint = ep_mgr_impl_->find_or_create_server_endpoint( its_unreliable_port, false, is_someip, _service, - _instance, _is_found); + _unique, _is_found); if (its_unreliable_endpoint) { its_info->set_endpoint(its_unreliable_endpoint, false); } @@ -2329,7 +2333,7 @@ void routing_manager_impl::init_service_info( if (ILLEGAL_PORT == its_reliable_port && ILLEGAL_PORT == its_unreliable_port) { VSOMEIP_INFO << "Port configuration missing for [" - << std::hex << _service << "." << _instance + << std::hex << _service << "." << get_instance_from_unique(_unique) << "]. Service is internal."; } } @@ -2349,19 +2353,19 @@ void routing_manager_impl::remove_local(client_t _client, bool _remove_uid) { routing_manager_base::remove_local(_client, clients_subscriptions, _remove_uid); for (const auto &s : get_requested_services(_client)) { - release_service(_client, s.service_, s.instance_); + release_service(_client, s.service_, get_unique_version(s.instance_, s.major_)); } } -bool routing_manager_impl::is_field(service_t _service, instance_t _instance, +bool routing_manager_impl::is_field(service_t _service, unique_version_t _unique, event_t _event) const { std::lock_guard its_lock(events_mutex_); auto find_service = events_.find(_service); if (find_service != events_.end()) { - auto find_instance = find_service->second.find(_instance); - if (find_instance != find_service->second.end()) { - auto find_event = find_instance->second.find(_event); - if (find_event != find_instance->second.end()) + auto find_unique = find_service->second.find(_unique); + if (find_unique != find_service->second.end()) { + auto find_event = find_unique->second.find(_event); + if (find_event != find_unique->second.end()) return find_event->second->is_field(); } } @@ -2378,13 +2382,14 @@ void routing_manager_impl::add_routing_info( uint16_t _unreliable_port) { std::lock_guard its_lock(routing_state_mutex_); + unique_version_t its_unique = get_unique_version(_instance, _major); if (routing_state_ == routing_state_e::RS_SUSPENDED) { VSOMEIP_INFO << "rmi::" << __func__ << " We are suspended --> do nothing."; return; } // Create/Update service info - std::shared_ptr its_info(find_service(_service, _instance)); + std::shared_ptr its_info(find_service(_service, its_unique)); if (!its_info) { boost::asio::ip::address its_unicast_address = configuration_->get_unicast_address(); @@ -2396,8 +2401,8 @@ void routing_manager_impl::add_routing_info( && its_unicast_address == _unreliable_address) is_local = true; - its_info = create_service_info(_service, _instance, _major, _minor, _ttl, is_local); - init_service_info(_service, _instance, is_local); + its_info = create_service_info(_service, its_unique, _major, _minor, _ttl, is_local); + init_service_info(_service, its_unique, is_local); } else if (its_info->is_local()) { // We received a service info for a service which is already offered locally VSOMEIP_ERROR << "routing_manager_impl::add_routing_info: " @@ -2425,7 +2430,7 @@ void routing_manager_impl::add_routing_info( // Check whether remote services are unchanged bool is_reliable_known(false); bool is_unreliable_known(false); - ep_mgr_impl_->is_remote_service_known(_service, _instance, _major, + ep_mgr_impl_->is_remote_service_known(_service, its_unique, _major, _minor, _reliable_address, _reliable_port, &is_reliable_known, _unreliable_address, _unreliable_port, &is_unreliable_known); @@ -2434,16 +2439,16 @@ void routing_manager_impl::add_routing_info( // Add endpoint(s) if necessary if (_reliable_port != ILLEGAL_PORT && !is_reliable_known) { std::shared_ptr endpoint_def_tcp - = endpoint_definition::get(_reliable_address, _reliable_port, true, _service, _instance); + = endpoint_definition::get(_reliable_address, _reliable_port, true, _service, its_unique); if (_unreliable_port != ILLEGAL_PORT && !is_unreliable_known) { std::shared_ptr endpoint_def_udp - = endpoint_definition::get(_unreliable_address, _unreliable_port, false, _service, _instance); - ep_mgr_impl_->add_remote_service_info(_service, _instance, + = endpoint_definition::get(_unreliable_address, _unreliable_port, false, _service, its_unique); + ep_mgr_impl_->add_remote_service_info(_service, its_unique, endpoint_def_tcp, endpoint_def_udp); udp_inserted = true; tcp_inserted = true; } else { - ep_mgr_impl_->add_remote_service_info(_service, _instance, + ep_mgr_impl_->add_remote_service_info(_service, its_unique, endpoint_def_tcp); tcp_inserted = true; } @@ -2460,10 +2465,10 @@ void routing_manager_impl::add_routing_info( if (udp_inserted) { // atomically create reliable and unreliable endpoint ep_mgr_impl_->find_or_create_remote_client( - _service, _instance); + _service, its_unique); } else { ep_mgr_impl_->find_or_create_remote_client( - _service, _instance, true); + _service, its_unique, true); } connected = true; } @@ -2478,19 +2483,19 @@ void routing_manager_impl::add_routing_info( if (ep->is_established() && stub_ && !stub_->contained_in_routing_info( - VSOMEIP_ROUTING_CLIENT, _service, _instance, + VSOMEIP_ROUTING_CLIENT, _service, its_unique, its_info->get_major(), its_info->get_minor())) { - on_availability(_service, _instance, + on_availability(_service, get_instance_from_unique(its_unique), availability_state_e::AS_AVAILABLE, its_info->get_major(), its_info->get_minor()); stub_->on_offer_service(VSOMEIP_ROUTING_CLIENT, - _service, _instance, + _service, its_unique, its_info->get_major(), its_info->get_minor()); if (discovery_) { discovery_->on_endpoint_connected( - _service, _instance, ep); + _service, its_unique, ep); } } } else { @@ -2499,14 +2504,14 @@ void routing_manager_impl::add_routing_info( // SWS_SD_00376 establish TCP connection to service // service is marked as available later in on_connect() ep_mgr_impl_->find_or_create_remote_client( - _service, _instance, true); + _service, its_unique, true); for (const client_t its_client : get_requesters_unlocked( _service, _instance, _major, _minor)) { its_info->add_client(its_client); } } } else { - on_availability(_service, _instance, + on_availability(_service, get_instance_from_unique(its_unique), availability_state_e::AS_OFFERED, its_info->get_major(), its_info->get_minor()); } @@ -2515,8 +2520,8 @@ void routing_manager_impl::add_routing_info( if (_unreliable_port != ILLEGAL_PORT && !is_unreliable_known) { if (!udp_inserted) { std::shared_ptr endpoint_def - = endpoint_definition::get(_unreliable_address, _unreliable_port, false, _service, _instance); - ep_mgr_impl_->add_remote_service_info(_service, _instance, endpoint_def); + = endpoint_definition::get(_unreliable_address, _unreliable_port, false, _service, its_unique); + ep_mgr_impl_->add_remote_service_info(_service, its_unique, endpoint_def); // check if service was requested and increase requester count if necessary { bool connected(false); @@ -2524,7 +2529,7 @@ void routing_manager_impl::add_routing_info( for (const client_t its_client : get_requesters_unlocked( _service, _instance, _major, _minor)) { if (!connected) { - ep_mgr_impl_->find_or_create_remote_client(_service, _instance, + ep_mgr_impl_->find_or_create_remote_client(_service, its_unique, false); connected = true; } @@ -2535,19 +2540,19 @@ void routing_manager_impl::add_routing_info( if (!is_reliable_known && !tcp_inserted) { // UDP only service can be marked as available instantly if (has_requester_unlocked(_service, _instance, _major, _minor)) { - on_availability(_service, _instance, + on_availability(_service, get_instance_from_unique(its_unique), availability_state_e::AS_AVAILABLE, _major, _minor); if (stub_) - stub_->on_offer_service(VSOMEIP_ROUTING_CLIENT, _service, _instance, _major, _minor); + stub_->on_offer_service(VSOMEIP_ROUTING_CLIENT, _service, its_unique, _major, _minor); } else { - on_availability(_service, _instance, + on_availability(_service, get_instance_from_unique(its_unique), availability_state_e::AS_OFFERED, _major, _minor); } } if (discovery_) { std::shared_ptr ep = its_info->get_endpoint(false); if (ep && ep->is_established()) { - discovery_->on_endpoint_connected(_service, _instance, ep); + discovery_->on_endpoint_connected(_service, its_unique, ep); } } } else if (_unreliable_port != ILLEGAL_PORT && is_unreliable_known) { @@ -2556,44 +2561,44 @@ void routing_manager_impl::add_routing_info( if (_reliable_port == ILLEGAL_PORT && !is_reliable_known && stub_ && !stub_->contained_in_routing_info( - VSOMEIP_ROUTING_CLIENT, _service, _instance, + VSOMEIP_ROUTING_CLIENT, _service, its_unique, its_info->get_major(), its_info->get_minor())) { - on_availability(_service, _instance, + on_availability(_service, get_instance_from_unique(its_unique), availability_state_e::AS_AVAILABLE, its_info->get_major(), its_info->get_minor()); stub_->on_offer_service(VSOMEIP_ROUTING_CLIENT, - _service, _instance, + _service, its_unique, its_info->get_major(), its_info->get_minor()); if (discovery_) { std::shared_ptr ep = its_info->get_endpoint(false); if (ep && ep->is_established()) { discovery_->on_endpoint_connected( - _service, _instance, + _service, its_unique, ep); } } } } else { - on_availability(_service, _instance, + on_availability(_service, get_instance_from_unique(its_unique), availability_state_e::AS_OFFERED, _major, _minor); } } } -void routing_manager_impl::del_routing_info(service_t _service, instance_t _instance, +void routing_manager_impl::del_routing_info(service_t _service, unique_version_t _unique, bool _has_reliable, bool _has_unreliable) { - std::shared_ptr its_info(find_service(_service, _instance)); + std::shared_ptr its_info(find_service(_service, _unique)); if(!its_info) return; - on_availability(_service, _instance, + on_availability(_service, get_instance_from_unique(_unique), availability_state_e::AS_UNAVAILABLE, its_info->get_major(), its_info->get_minor()); if (stub_) - stub_->on_stop_offer_service(VSOMEIP_ROUTING_CLIENT, _service, _instance, + stub_->on_stop_offer_service(VSOMEIP_ROUTING_CLIENT, _service, _unique, its_info->get_major(), its_info->get_minor()); // Implicit unsubscribe @@ -2602,9 +2607,9 @@ void routing_manager_impl::del_routing_info(service_t _service, instance_t _inst std::lock_guard its_lock(eventgroups_mutex_); auto found_service = eventgroups_.find(_service); if (found_service != eventgroups_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - for (auto &its_eventgroup : found_instance->second) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + for (auto &its_eventgroup : found_unique->second) { // As the service is gone, all subscriptions to its events // do no longer exist and the last received payload is no // longer valid. @@ -2629,11 +2634,11 @@ void routing_manager_impl::del_routing_info(service_t _service, instance_t _inst { std::lock_guard its_lock(remote_subscription_state_mutex_); std::set > its_invalid; + service_t, unique_version_t, eventgroup_t, client_t> > its_invalid; for (const auto &its_state : remote_subscription_state_) { if (std::get<0>(its_state.first) == _service - && std::get<1>(its_state.first) == _instance) { + && std::get<1>(its_state.first) == _unique) { its_invalid.insert(its_state.first); } } @@ -2646,7 +2651,7 @@ void routing_manager_impl::del_routing_info(service_t _service, instance_t _inst std::lock_guard its_lock(remote_subscribers_mutex_); auto found_service = remote_subscribers_.find(_service); if (found_service != remote_subscribers_.end()) { - if (found_service->second.erase(_instance) > 0 && + if (found_service->second.erase(_unique) > 0 && !found_service->second.size()) { remote_subscribers_.erase(found_service); } @@ -2654,32 +2659,32 @@ void routing_manager_impl::del_routing_info(service_t _service, instance_t _inst } if (_has_reliable) { - ep_mgr_impl_->clear_client_endpoints(_service, _instance, true); - ep_mgr_impl_->clear_remote_service_info(_service, _instance, true); + ep_mgr_impl_->clear_client_endpoints(_service, _unique, true); + ep_mgr_impl_->clear_remote_service_info(_service, _unique, true); } if (_has_unreliable) { - ep_mgr_impl_->clear_client_endpoints(_service, _instance, false); - ep_mgr_impl_->clear_remote_service_info(_service, _instance, false); + ep_mgr_impl_->clear_client_endpoints(_service, _unique, false); + ep_mgr_impl_->clear_remote_service_info(_service, _unique, false); } - ep_mgr_impl_->clear_multicast_endpoints(_service, _instance); + ep_mgr_impl_->clear_multicast_endpoints(_service, _unique); if (_has_reliable) - clear_service_info(_service, _instance, true); + clear_service_info(_service, _unique, true); if (_has_unreliable) - clear_service_info(_service, _instance, false); + clear_service_info(_service, _unique, false); // For expired services using only unreliable endpoints that have never been created before if (!_has_reliable && !_has_unreliable) { - ep_mgr_impl_->clear_remote_service_info(_service, _instance, true); - ep_mgr_impl_->clear_remote_service_info(_service, _instance, false); - clear_service_info(_service, _instance, true); - clear_service_info(_service, _instance, false); + ep_mgr_impl_->clear_remote_service_info(_service, _unique, true); + ep_mgr_impl_->clear_remote_service_info(_service, _unique, false); + clear_service_info(_service, _unique, true); + clear_service_info(_service, _unique, false); } } void routing_manager_impl::update_routing_info(std::chrono::milliseconds _elapsed) { - std::map > its_expired_offers; + std::map > its_expired_offers; { std::lock_guard its_lock(services_remote_mutex_); @@ -2709,7 +2714,7 @@ void routing_manager_impl::update_routing_info(std::chrono::milliseconds _elapse VSOMEIP_INFO << "update_routing_info: elapsed=" << _elapsed.count() << " : delete service/instance " << std::hex << std::setfill('0') - << std::setw(4) << s.first << "." << std::setw(4) << i; + << std::setw(4) << s.first << "." << std::setw(4) << get_instance_from_unique(i); } } } @@ -2730,7 +2735,7 @@ void routing_manager_impl::expire_services( void routing_manager_impl::expire_services( const boost::asio::ip::address &_address, const configuration::port_range_t& _range, bool _reliable) { - std::map > its_expired_offers; + std::map > its_expired_offers; const bool expire_all = (_range.first == ANY_PORT && _range.second == ANY_PORT); @@ -2764,7 +2769,7 @@ void routing_manager_impl::expire_services( VSOMEIP_INFO << "expire_services for address: " << _address << " : delete service/instance " << std::hex << std::setfill('0') - << std::setw(4) << s.first << "." << std::setw(4) << i + << std::setw(4) << s.first << "." << std::setw(4) << get_instance_from_unique(i) << " port [" << std::dec << _range.first << "," << _range.second << "] reliability=" << std::boolalpha << _reliable; del_routing_info(s.first, i, true, true); @@ -2795,7 +2800,7 @@ routing_manager_impl::expire_subscriptions( && _range.second == ANY_PORT); std::map > > >its_eventgroups; { @@ -2803,8 +2808,8 @@ routing_manager_impl::expire_subscriptions( its_eventgroups = eventgroups_; } for (const auto &its_service : its_eventgroups) { - for (const auto &its_instance : its_service.second) { - for (const auto &its_eventgroup : its_instance.second) { + for (const auto &its_unique : its_service.second) { + for (const auto &its_eventgroup : its_unique.second) { const auto its_info = its_eventgroup.second; for (auto its_subscription : its_info->get_remote_subscriptions()) { @@ -2812,7 +2817,7 @@ routing_manager_impl::expire_subscriptions( VSOMEIP_WARNING << __func__ << ": New remote subscription replaced expired [" << std::hex << std::setfill('0') << std::setw(4) << its_service.first << "." - << std::setw(4) << its_instance.first << "." + << std::setw(4) << get_instance_from_unique(its_unique.first) << "." << std::setw(4) << its_eventgroup.first << "]"; continue; } @@ -2888,7 +2893,7 @@ void routing_manager_impl::init_routing_info() { if (its_reliable_port != ILLEGAL_PORT || its_unreliable_port != ILLEGAL_PORT) { - add_routing_info(i.first, i.second, + add_routing_info(i.first, get_instance_from_unique(i.second), DEFAULT_MAJOR, DEFAULT_MINOR, DEFAULT_TTL, its_address, its_reliable_port, its_address, its_unreliable_port); @@ -2922,18 +2927,20 @@ void routing_manager_impl::on_remote_subscribe( const auto its_eventgroup = its_eventgroupinfo->get_eventgroup(); const auto its_major = its_eventgroupinfo->get_major(); + const auto its_unique = get_unique_version(its_instance, its_major); + // Get remote port(s) auto its_reliable = _subscription->get_reliable(); if (its_reliable) { uint16_t its_port - = configuration_->get_reliable_port(its_service, its_instance); + = configuration_->get_reliable_port(its_service, its_unique); its_reliable->set_remote_port(its_port); } auto its_unreliable = _subscription->get_unreliable(); if (its_unreliable) { uint16_t its_port - = configuration_->get_unreliable_port(its_service, its_instance); + = configuration_->get_unreliable_port(its_service, its_unique); its_unreliable->set_remote_port(its_port); } @@ -2961,7 +2968,7 @@ void routing_manager_impl::on_remote_subscribe( _callback(_subscription); } else if (!its_added.empty()) { // new clients for a selective subscription const client_t its_offering_client - = find_local_client(its_service, its_instance); + = find_local_client(its_service, its_unique); send_subscription(its_offering_client, its_service, its_instance, its_eventgroup, its_major, its_added, _subscription->get_id()); @@ -3006,7 +3013,7 @@ void routing_manager_impl::on_remote_subscribe( = its_eventgroupinfo->add_remote_subscription(_subscription); const client_t its_offering_client - = find_local_client(its_service, its_instance); + = find_local_client(its_service, its_unique); send_subscription(its_offering_client, its_service, its_instance, its_eventgroup, its_major, _subscription->get_clients(), its_id); @@ -3029,18 +3036,20 @@ void routing_manager_impl::on_remote_unsubscribe( const auto its_eventgroup = its_info->get_eventgroup(); const auto its_major = its_info->get_major(); + const auto its_unique = get_unique_version(its_instance, its_major); + // Get remote port(s) auto its_reliable = _subscription->get_reliable(); if (its_reliable) { uint16_t its_port - = configuration_->get_reliable_port(its_service, its_instance); + = configuration_->get_reliable_port(its_service, its_unique); its_reliable->set_remote_port(its_port); } auto its_unreliable = _subscription->get_unreliable(); if (its_unreliable) { uint16_t its_port - = configuration_->get_unreliable_port(its_service, its_instance); + = configuration_->get_unreliable_port(its_service, its_unique); its_unreliable->set_remote_port(its_port); } @@ -3053,7 +3062,7 @@ void routing_manager_impl::on_remote_unsubscribe( if (its_result) { const client_t its_offering_client - = find_local_client(its_service, its_instance); + = find_local_client(its_service, its_unique); send_unsubscription(its_offering_client, its_service, its_instance, its_eventgroup, its_major, its_removed, its_id); @@ -3061,18 +3070,18 @@ void routing_manager_impl::on_remote_unsubscribe( } void routing_manager_impl::on_subscribe_ack_with_multicast( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const boost::asio::ip::address &_sender, const boost::asio::ip::address &_address, uint16_t _port) { ep_mgr_impl_->find_or_create_multicast_endpoint(_service, - _instance, _sender, _address, _port); + _unique, _sender, _address, _port); } void routing_manager_impl::on_subscribe_ack(client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _id) { std::lock_guard its_lock(remote_subscription_state_mutex_); - auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); + auto its_eventgroup = find_eventgroup(_service, _unique, _eventgroup); if (its_eventgroup) { auto its_subscription = its_eventgroup->get_remote_subscription(_id); if (its_subscription) { @@ -3090,7 +3099,7 @@ void routing_manager_impl::on_subscribe_ack(client_t _client, if (discovery_) { std::lock_guard its_lock(remote_subscribers_mutex_); - remote_subscribers_[_service][_instance][VSOMEIP_ROUTING_CLIENT].insert( + remote_subscribers_[_service][_unique][VSOMEIP_ROUTING_CLIENT].insert( its_subscription->get_subscriber()); discovery_->update_remote_subscription(its_subscription); @@ -3098,7 +3107,7 @@ void routing_manager_impl::on_subscribe_ack(client_t _client, << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "]" << " from " << its_subscription->get_subscriber()->get_address() << ":" << std::dec << its_subscription->get_subscriber()->get_port() @@ -3108,7 +3117,7 @@ void routing_manager_impl::on_subscribe_ack(client_t _client, return; } } else { - const auto its_tuple = std::make_tuple(_service, _instance, _eventgroup, _client); + const auto its_tuple = std::make_tuple(_service, _unique, _eventgroup, _client); const auto its_state = remote_subscription_state_.find(its_tuple); if (its_state != remote_subscription_state_.end()) { if (its_state->second == subscription_state_e::SUBSCRIPTION_ACKNOWLEDGED) { @@ -3135,33 +3144,33 @@ void routing_manager_impl::on_subscribe_ack(client_t _client, if (its_subscriber == get_client()) { if (_event == ANY_EVENT) { for (const auto &its_event : its_eventgroup->get_events()) { - host_->on_subscription_status(_service, _instance, + host_->on_subscription_status(_service, _unique, _eventgroup, its_event->get_event(), 0x0 /*OK*/); } } else { - host_->on_subscription_status(_service, _instance, + host_->on_subscription_status(_service, _unique, _eventgroup, _event, 0x0 /*OK*/); } } else if (stub_) { stub_->send_subscribe_ack(its_subscriber, _service, - _instance, _eventgroup, _event); + _unique, _eventgroup, _event); } } } } std::shared_ptr routing_manager_impl::find_or_create_remote_client( - service_t _service, instance_t _instance, bool _reliable) { + service_t _service, unique_version_t _unique, bool _reliable) { return ep_mgr_impl_->find_or_create_remote_client(_service, - _instance, _reliable); + _unique, _reliable); } void routing_manager_impl::on_subscribe_nack(client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, bool _remove, remote_subscription_id_t _id) { - auto its_eventgroup = find_eventgroup(_service, _instance, _eventgroup); + auto its_eventgroup = find_eventgroup(_service, _unique, _eventgroup); if (its_eventgroup) { auto its_subscription = its_eventgroup->get_remote_subscription(_id); if (its_subscription) { @@ -3183,7 +3192,7 @@ void routing_manager_impl::on_subscribe_nack(client_t _client, << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "]" << " from " << its_subscription->get_subscriber()->get_address() << ":" << std::dec << its_subscription->get_subscriber()->get_port() @@ -3197,7 +3206,7 @@ void routing_manager_impl::on_subscribe_nack(client_t _client, } return_code_e routing_manager_impl::check_error(const byte_t *_data, length_t _size, - instance_t _instance) { + unique_version_t _unique) { service_t its_service = bithelper::read_uint16_be(&_data[VSOMEIP_SERVICE_POS_MIN]); @@ -3209,13 +3218,13 @@ return_code_e routing_manager_impl::check_error(const byte_t *_data, length_t _s << std::hex << its_service; return return_code_e::E_WRONG_PROTOCOL_VERSION; } - if (_instance == 0xFFFF) { + if (get_instance_from_unique(_unique) == 0xFFFF) { VSOMEIP_WARNING << "Receiving endpoint is not configured for service 0x" << std::hex << its_service; return return_code_e::E_UNKNOWN_SERVICE; } // Check interface version of service/instance - auto its_info = find_service(its_service, _instance); + auto its_info = find_service(its_service, _unique); if (its_info) { major_version_t its_version = _data[VSOMEIP_INTERFACE_VERSION_POS]; if (its_version != its_info->get_major()) { @@ -3306,18 +3315,18 @@ void routing_manager_impl::send_error(return_code_e _return_code, } void routing_manager_impl::clear_remote_subscriber( - service_t _service, instance_t _instance, client_t _client, + service_t _service, unique_version_t _unique, client_t _client, const std::shared_ptr &_target) { std::lock_guard its_lock(remote_subscribers_mutex_); auto its_service = remote_subscribers_.find(_service); if (its_service != remote_subscribers_.end()) { - auto its_instance = its_service->second.find(_instance); - if (its_instance != its_service->second.end()) { - auto its_client = its_instance->second.find(_client); - if (its_client != its_instance->second.end()) { + auto its_unique = its_service->second.find(_unique); + if (its_unique != its_service->second.end()) { + auto its_client = its_unique->second.find(_client); + if (its_client != its_unique->second.end()) { if (its_client->second.erase(_target)) { if (!its_client->second.size()) { - its_instance->second.erase(_client); + its_unique->second.erase(_client); } } } @@ -3328,7 +3337,7 @@ void routing_manager_impl::clear_remote_subscriber( std::chrono::steady_clock::time_point routing_manager_impl::expire_subscriptions(bool _force) { std::map > > >its_eventgroups; std::map, @@ -3344,8 +3353,8 @@ routing_manager_impl::expire_subscriptions(bool _force) { } for (auto &its_service : its_eventgroups) { - for (auto &its_instance : its_service.second) { - for (auto &its_eventgroup : its_instance.second) { + for (auto &its_unique : its_service.second) { + for (auto &its_eventgroup : its_unique.second) { auto its_subscriptions = its_eventgroup.second->get_remote_subscriptions(); for (auto &s : its_subscriptions) { @@ -3354,14 +3363,14 @@ routing_manager_impl::expire_subscriptions(bool _force) { << ": Remote subscription is NULL for eventgroup [" << std::hex << std::setfill('0') << std::setw(4) << its_service.first << "." - << std::setw(4) << its_instance.first << "." + << std::setw(4) << get_instance_from_unique(its_unique.first) << "." << std::setw(4) << its_eventgroup.first << "]"; continue; } else if (s->is_forwarded()) { VSOMEIP_WARNING << __func__ << ": New remote subscription replaced expired [" << std::hex << std::setfill('0') << std::setw(4) << its_service.first << "." - << std::setw(4) << its_instance.first << "." + << std::setw(4) << get_instance_from_unique(its_unique.first) << "." << std::setw(4) << its_eventgroup.first << "]"; continue; } @@ -3391,6 +3400,9 @@ routing_manager_impl::expire_subscriptions(bool _force) { auto its_service = its_info->get_service(); auto its_instance = its_info->get_instance(); auto its_eventgroup = its_info->get_eventgroup(); + auto its_major = its_info->get_major(); + + unique_version_t its_unique = get_unique_version(its_instance, its_major); remote_subscription_id_t its_id; std::unique_lock its_update_lock{update_remote_subscription_mutex_}; @@ -3399,20 +3411,20 @@ routing_manager_impl::expire_subscriptions(bool _force) { s.second, its_id, false); if (its_result) { const client_t its_offering_client - = find_local_client(its_service, its_instance); + = find_local_client(its_service, its_unique); const auto its_subscription = its_info->get_remote_subscription(its_id); if (its_subscription) { its_info->remove_remote_subscription(its_id); std::lock_guard its_lock(remote_subscribers_mutex_); - remote_subscribers_[its_service][its_instance].erase(its_offering_client); + remote_subscribers_[its_service][its_unique].erase(its_offering_client); if (its_info->get_remote_subscriptions().size() == 0) { for (const auto &its_event : its_info->get_events()) { bool has_remote_subscriber(false); for (const auto &its_eventgroup : its_event->get_eventgroups()) { const auto its_eventgroup_info - = find_eventgroup(its_service, its_instance, its_eventgroup); + = find_eventgroup(its_service, its_unique, its_eventgroup); if (its_eventgroup_info && its_eventgroup_info->get_remote_subscriptions().size() > 0) { has_remote_subscriber = true; @@ -3432,7 +3444,7 @@ routing_manager_impl::expire_subscriptions(bool _force) { << std::setw(4) << its_eventgroup << "]"; } send_expired_subscription(its_offering_client, - its_service, its_instance, its_eventgroup, + its_service, its_unique, its_eventgroup, s.second, s.first->get_id()); } @@ -3503,16 +3515,16 @@ void routing_manager_impl::log_version_timer_cbk(boost::system::error_code const } bool routing_manager_impl::handle_local_offer_service(client_t _client, service_t _service, - instance_t _instance, major_version_t _major,minor_version_t _minor) { + unique_version_t _unique, major_version_t _major,minor_version_t _minor) { { std::lock_guard its_lock(local_services_mutex_); auto found_service = local_services_.find(_service); if (found_service != local_services_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - const major_version_t its_stored_major(std::get<0>(found_instance->second)); - const minor_version_t its_stored_minor(std::get<1>(found_instance->second)); - const client_t its_stored_client(std::get<2>(found_instance->second)); + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + const major_version_t its_stored_major(std::get<0>(found_unique->second)); + const minor_version_t its_stored_minor(std::get<1>(found_unique->second)); + const client_t its_stored_client(std::get<2>(found_unique->second)); if ( its_stored_major == _major && its_stored_minor == _minor && its_stored_client == _client) { @@ -3521,7 +3533,7 @@ bool routing_manager_impl::handle_local_offer_service(client_t _client, service_ << std::hex << std::setfill('0') << std::setw(4) << _client << " is offering: [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << static_cast(_major) << "." << _minor << "] offered previously by itself."; return false; @@ -3534,9 +3546,9 @@ bool routing_manager_impl::handle_local_offer_service(client_t _client, service_ std::lock_guard its_lock(pending_offers_mutex_); auto found_service2 = pending_offers_.find(_service); if (found_service2 != pending_offers_.end()) { - auto found_instance2 = found_service2->second.find(_instance); - if (found_instance2 != found_service2->second.end()) { - if(std::get<2>(found_instance2->second) == _client) { + auto found_unique2 = found_service2->second.find(_unique); + if (found_unique2 != found_service2->second.end()) { + if(std::get<2>(found_unique2->second) == _client) { already_pinged = true; } else { VSOMEIP_ERROR << "routing_manager_impl::handle_local_offer_service: " @@ -3544,14 +3556,14 @@ bool routing_manager_impl::handle_local_offer_service(client_t _client, service_ << std::hex << std::setfill('0') << std::setw(4) << _client << " is trying to offer [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << static_cast(_major) << "." << _minor << "] current pending offer by application: " << std::hex << std::setw(4) << its_stored_client << ": [" << std::hex << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << static_cast(its_stored_major) << "." << its_stored_minor << "]"; @@ -3566,14 +3578,14 @@ bool routing_manager_impl::handle_local_offer_service(client_t _client, service_ if (its_old_endpoint) { std::lock_guard its_lock(pending_offers_mutex_); if (stub_ && stub_->send_ping(its_stored_client)) { - pending_offers_[_service][_instance] = + pending_offers_[_service][_unique] = std::make_tuple(_major, _minor, _client, its_stored_client); VSOMEIP_WARNING << "OFFER(" << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << ":" + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << int(_major) << "." << std::dec << _minor << "] is now pending. Waiting for pong from application: " << std::hex << std::setw(4) << its_stored_client; @@ -3585,14 +3597,14 @@ bool routing_manager_impl::handle_local_offer_service(client_t _client, service_ << std::hex << std::setfill('0') << std::setw(4) << _client << " is trying to offer [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << static_cast(_major) << "." << _minor << "] offered previously by routing manager stub itself with application: " << std::hex << std::setw(4) << its_stored_client << ": [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << static_cast(its_stored_major) << "." << its_stored_minor << "] which is still alive"; @@ -3603,7 +3615,7 @@ bool routing_manager_impl::handle_local_offer_service(client_t _client, service_ << std::hex << std::setfill('0') << std::setw(4) << _client <<"): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance + << std::setw(4) << get_instance_from_unique(_unique) << ":" << std::dec << int(_major) << "." << std::dec << _minor << "]" << " client already pinged!"; return false; @@ -3614,14 +3626,14 @@ bool routing_manager_impl::handle_local_offer_service(client_t _client, service_ << std::hex << std::setfill('0') << std::setw(4) << _client << " is trying to offer [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << static_cast(_major) << "." << _minor << "] offered previously by application: " << std::hex << std::setw(4) << its_stored_client << ": [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << static_cast(its_stored_major) << "." << its_stored_minor << "]"; return false; @@ -3630,9 +3642,9 @@ bool routing_manager_impl::handle_local_offer_service(client_t _client, service_ } // check if the same service instance is already offered remotely - if (routing_manager_base::offer_service(_client, _service, _instance, + if (routing_manager_base::offer_service(_client, _service, _unique, _major, _minor)) { - local_services_[_service][_instance] = std::make_tuple(_major, + local_services_[_service][_unique] = std::make_tuple(_major, _minor, _client); } else { VSOMEIP_ERROR << "routing_manager_impl::handle_local_offer_service: " @@ -3640,7 +3652,7 @@ bool routing_manager_impl::handle_local_offer_service(client_t _client, service_ << std::hex << std::setfill('0') << std::setw(4) << _client << " is trying to offer [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::dec << static_cast(_major) << "." << _minor << "]" << "] already offered remotely"; @@ -3657,27 +3669,27 @@ void routing_manager_impl::on_pong(client_t _client) { } for (auto service_iter = pending_offers_.begin(); service_iter != pending_offers_.end(); ) { - for (auto instance_iter = service_iter->second.begin(); - instance_iter != service_iter->second.end(); ) { - if (std::get<3>(instance_iter->second) == _client) { + for (auto unique_iter = service_iter->second.begin(); + unique_iter != service_iter->second.end(); ) { + if (std::get<3>(unique_iter->second) == _client) { // received pong from an application were another application wants // to offer its service, delete the other applications offer as // the current offering application is still alive VSOMEIP_WARNING << "OFFER(" << std::hex << std::setfill('0') - << std::setw(4) << std::get<2>(instance_iter->second) << "): [" + << std::setw(4) << std::get<2>(unique_iter->second) << "): [" << std::setw(4) << service_iter->first << "." - << std::setw(4) << instance_iter->first << ":" + << std::setw(4) << get_instance_from_unique(unique_iter->first) << ":" << std::dec - << std::uint32_t(std::get<0>(instance_iter->second)) - << "." << std::get<1>(instance_iter->second) + << std::uint32_t(std::get<0>(unique_iter->second)) + << "." << std::get<1>(unique_iter->second) << "] was rejected as application: " << std::hex << std::setw(4) << _client << " is still alive"; - instance_iter = service_iter->second.erase(instance_iter); + unique_iter = service_iter->second.erase(unique_iter); } else { - ++instance_iter; + ++unique_iter; } } @@ -3712,30 +3724,30 @@ void routing_manager_impl::handle_client_error(client_t _client) { for (auto service_iter = pending_offers_.begin(); service_iter != pending_offers_.end(); ) { - for (auto instance_iter = service_iter->second.begin(); - instance_iter != service_iter->second.end(); ) { - if (std::get<3>(instance_iter->second) == _client) { + for (auto unique_iter = service_iter->second.begin(); + unique_iter != service_iter->second.end(); ) { + if (std::get<3>(unique_iter->second) == _client) { VSOMEIP_WARNING << "OFFER(" << std::hex << std::setfill('0') - << std::setw(4) << std::get<2>(instance_iter->second) << "): [" + << std::setw(4) << std::get<2>(unique_iter->second) << "): [" << std::setw(4) << service_iter->first << "." - << std::setw(4) << instance_iter->first << ":" + << std::setw(4) << get_instance_from_unique(unique_iter->first) << ":" << std::dec - << std::uint32_t(std::get<0>(instance_iter->second)) - << "." << std::get<1>(instance_iter->second) + << std::uint32_t(std::get<0>(unique_iter->second)) + << "." << std::get<1>(unique_iter->second) << "] is not pending anymore as application: " << std::hex - << std::setw(4) << std::get<3>(instance_iter->second) + << std::setw(4) << std::get<3>(unique_iter->second) << " is dead. Offering again!"; its_offers.push_front(std::make_tuple( - std::get<2>(instance_iter->second), + std::get<2>(unique_iter->second), service_iter->first, - instance_iter->first, - std::get<0>(instance_iter->second), - std::get<1>(instance_iter->second))); - instance_iter = service_iter->second.erase(instance_iter); + get_instance_from_unique(unique_iter->first), + std::get<0>(unique_iter->second), + std::get<1>(unique_iter->second))); + unique_iter = service_iter->second.erase(unique_iter); } else { - ++instance_iter; + ++unique_iter; } } @@ -3757,12 +3769,12 @@ std::shared_ptr routing_manager_impl::get_endpoint_manage } void routing_manager_impl::send_subscribe(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, major_version_t _major, + unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const std::shared_ptr &_filter) { - auto endpoint = ep_mgr_->find_local(_service, _instance); + auto endpoint = ep_mgr_->find_local(_service, _unique); if (endpoint && stub_) { stub_->send_subscribe(endpoint, _client, - _service, _instance, + _service, get_instance_from_unique(_unique), _eventgroup, _major, _event, _filter, PENDING_SUBSCRIPTION_ID); @@ -3803,43 +3815,43 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { std::vector> _service_infos; // send StopOffer messages for remotely offered services on this node for (const auto &its_service : get_offered_services()) { - for (const auto &its_instance : its_service.second) { - bool has_reliable(its_instance.second->get_endpoint(true) != nullptr); - bool has_unreliable(its_instance.second->get_endpoint(false) != nullptr); + for (const auto &its_unique : its_service.second) { + bool has_reliable(its_unique.second->get_endpoint(true) != nullptr); + bool has_unreliable(its_unique.second->get_endpoint(false) != nullptr); if (has_reliable || has_unreliable) { - const client_t its_client(find_local_client(its_service.first, its_instance.first)); + const client_t its_client(find_local_client(its_service.first, its_unique.first)); if (its_client == VSOMEIP_ROUTING_CLIENT) { // Inconsistency between services_ and local_services_ table detected // --> cleanup. VSOMEIP_WARNING << "rmi::" << __func__ << " Found table inconsistency for [" << std::hex << std::setfill('0') << std::setw(4) << its_service.first << "." - << std::setw(4) << its_instance.first << "]"; + << std::setw(4) << get_instance_from_unique(its_unique.first) << "]"; // Remove the service from the offer_commands_ and prepare_stop_handlers_ to force the next offer to be processed - offer_commands_.erase(std::make_pair(its_service.first, its_instance.first)); + offer_commands_.erase(std::make_pair(its_service.first, its_unique.first)); if (has_reliable) - its_instance.second->get_endpoint(true)->remove_stop_handler(its_service.first); + its_unique.second->get_endpoint(true)->remove_stop_handler(its_service.first); if (has_unreliable) - its_instance.second->get_endpoint(false)->remove_stop_handler(its_service.first); + its_unique.second->get_endpoint(false)->remove_stop_handler(its_service.first); - del_routing_info(its_service.first, its_instance.first, has_reliable, has_unreliable); + del_routing_info(its_service.first, its_unique.first, has_reliable, has_unreliable); std::lock_guard its_lock(pending_offers_mutex_); auto its_pending_offer = pending_offers_.find(its_service.first); if (its_pending_offer != pending_offers_.end()) - its_pending_offer->second.erase(its_instance.first); + its_pending_offer->second.erase(its_unique.first); } VSOMEIP_WARNING << "Service " << std::hex << std::setfill('0') << std::setw(4) << its_service.first << "." - << std::setw(4) << its_instance.first << " still offered by " + << std::setw(4) << get_instance_from_unique(its_unique.first) << " still offered by " << std::setw(4) << its_client; } // collect stop offers to be sent out - if (discovery_->stop_offer_service(its_instance.second, false)) { - _service_infos.push_back(its_instance.second); + if (discovery_->stop_offer_service(its_unique.second, false)) { + _service_infos.push_back(its_unique.second); } } } @@ -3898,9 +3910,9 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { // Reset relevant in service info for (const auto &its_service : get_offered_services()) { - for (const auto &its_instance : its_service.second) { - its_instance.second->set_ttl(DEFAULT_TTL); - its_instance.second->set_is_in_mainphase(false); + for (const auto &its_unique : its_service.second) { + its_unique.second->set_ttl(DEFAULT_TTL); + its_unique.second->set_is_in_mainphase(false); } } // Switch SD back to normal operation @@ -3915,8 +3927,8 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { // Trigger initial offer phase for relevant services for (const auto &its_service : get_offered_services()) { - for (const auto &its_instance : its_service.second) { - discovery_->offer_service(its_instance.second); + for (const auto &its_unique : its_service.second) { + discovery_->offer_service(its_unique.second); } } @@ -3931,10 +3943,10 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { // send StopOffer messages for all someip protocol services for (const auto &its_service : get_offered_services()) { - for (const auto &its_instance : its_service.second) { + for (const auto &its_unique : its_service.second) { if (host_->get_configuration()->is_someip( - its_service.first, its_instance.first)) { - discovery_->stop_offer_service(its_instance.second, true); + its_service.first, its_unique.first)) { + discovery_->stop_offer_service(its_unique.second, true); } } } @@ -3948,11 +3960,11 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { // Reset relevant in service info for (const auto &its_service : get_offered_services()) { - for (const auto &its_instance : its_service.second) { + for (const auto &its_unique : its_service.second) { if (host_->get_configuration()->is_someip( - its_service.first, its_instance.first)) { - its_instance.second->set_ttl(DEFAULT_TTL); - its_instance.second->set_is_in_mainphase(false); + its_service.first, its_unique.first)) { + its_unique.second->set_ttl(DEFAULT_TTL); + its_unique.second->set_is_in_mainphase(false); } } } @@ -3961,10 +3973,10 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { // Trigger initial phase for relevant services for (const auto &its_service : get_offered_services()) { - for (const auto &its_instance : its_service.second) { + for (const auto &its_unique : its_service.second) { if (host_->get_configuration()->is_someip( - its_service.first, its_instance.first)) { - discovery_->offer_service(its_instance.second); + its_service.first, its_unique.first)) { + discovery_->offer_service(its_unique.second); } } } @@ -4055,9 +4067,9 @@ void routing_manager_impl::start_ip_routing() { VSOMEIP_INFO << VSOMEIP_ROUTING_READY_MESSAGE; } -bool routing_manager_impl::is_available(service_t _service, instance_t _instance, +bool routing_manager_impl::is_available(service_t _service, unique_version_t _unique, major_version_t _major) const { - return routing_manager_base::is_available(_service, _instance, _major); + return routing_manager_base::is_available(_service, _unique, _major); } void @@ -4267,15 +4279,15 @@ routing_manager_impl::has_requester_unlocked( std::set routing_manager_impl::get_subscribed_eventgroups( - service_t _service, instance_t _instance) { + service_t _service, unique_version_t _unique) { std::set its_eventgroups; std::lock_guard its_lock(eventgroups_mutex_); auto found_service = eventgroups_.find(_service); if (found_service != eventgroups_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - for (const auto& its_group : found_instance->second) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + for (const auto& its_group : found_unique->second) { for (const auto& its_event : its_group.second->get_events()) { if (its_event->has_subscriber(its_group.first, ANY_CLIENT)) { its_eventgroups.insert(its_group.first); @@ -4289,15 +4301,15 @@ routing_manager_impl::get_subscribed_eventgroups( } void routing_manager_impl::clear_targets_and_pending_sub_from_eventgroups( - service_t _service, instance_t _instance) { + service_t _service, unique_version_t _unique) { std::vector> its_events; { std::lock_guard its_lock(eventgroups_mutex_); auto found_service = eventgroups_.find(_service); if (found_service != eventgroups_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - for (const auto &its_eventgroup : found_instance->second) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + for (const auto &its_eventgroup : found_unique->second) { // As the service is gone, all subscriptions to its events // do no longer exist and the last received payload is no // longer valid. @@ -4313,7 +4325,7 @@ void routing_manager_impl::clear_targets_and_pending_sub_from_eventgroups( { std::lock_guard its_lock(remote_subscription_state_mutex_); const auto its_tuple = - std::make_tuple(found_service->first, found_instance->first, + std::make_tuple(found_service->first, found_unique->first, its_eventgroup.first, its_client); remote_subscription_state_.erase(its_tuple); } @@ -4333,11 +4345,11 @@ void routing_manager_impl::clear_targets_and_pending_sub_from_eventgroups( } void routing_manager_impl::clear_remote_subscriber(service_t _service, - instance_t _instance) { + unique_version_t _unique) { std::lock_guard its_lock(remote_subscribers_mutex_); auto found_service = remote_subscribers_.find(_service); if (found_service != remote_subscribers_.end()) { - if (found_service->second.erase(_instance) > 0 && + if (found_service->second.erase(_unique) > 0 && !found_service->second.size()) { remote_subscribers_.erase(found_service); } @@ -4347,7 +4359,7 @@ void routing_manager_impl::clear_remote_subscriber(service_t _service, void routing_manager_impl::call_sd_endpoint_connected( const boost::system::error_code& _error, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const std::shared_ptr& _endpoint, std::shared_ptr _timer) { (void)_timer; @@ -4356,13 +4368,13 @@ void routing_manager_impl::call_sd_endpoint_connected( } _endpoint->set_established(true); if (discovery_) { - discovery_->on_endpoint_connected(_service, _instance, + discovery_->on_endpoint_connected(_service, _unique, _endpoint); } } bool routing_manager_impl::create_placeholder_event_and_subscribe( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, const std::shared_ptr &_filter, client_t _client) { @@ -4372,12 +4384,12 @@ bool routing_manager_impl::create_placeholder_event_and_subscribe( // full information like eventgroup, field or not etc. std::set its_eventgroups({_eventgroup}); - const client_t its_local_client(find_local_client(_service, _instance)); + const client_t its_local_client(find_local_client(_service, _unique)); if (its_local_client == host_->get_client()) { // received subscription for event of a service instance hosted by // application acting as rm_impl register with own client id and shadow = false register_event(host_->get_client(), - _service, _instance, + _service, _unique, _event, its_eventgroups, event_type_e::ET_UNKNOWN, reliability_type_e::RT_UNKNOWN, std::chrono::milliseconds::zero(), false, true, @@ -4386,7 +4398,7 @@ bool routing_manager_impl::create_placeholder_event_and_subscribe( // received subscription for event of a service instance hosted on // this node register with client id of local_client and set shadow to true register_event(its_local_client, - _service, _instance, + _service, _unique, _event, its_eventgroups, event_type_e::ET_UNKNOWN, reliability_type_e::RT_UNKNOWN, std::chrono::milliseconds::zero(), false, true, @@ -4394,12 +4406,12 @@ bool routing_manager_impl::create_placeholder_event_and_subscribe( } else { // received subscription for event of a unknown or remote service instance std::shared_ptr its_info = find_service(_service, - _instance); + _unique); if (its_info && !its_info->is_local()) { // remote service, register shadow event with client ID of subscriber // which should have called register_event register_event(_client, - _service, _instance, + _service, _unique, _event, its_eventgroups, event_type_e::ET_UNKNOWN, reliability_type_e::RT_UNKNOWN, std::chrono::milliseconds::zero(), @@ -4410,14 +4422,14 @@ bool routing_manager_impl::create_placeholder_event_and_subscribe( << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "." << std::setw(4) << _event << "]" << " received subscription for unknown service instance."; } } - std::shared_ptr its_event = find_event(_service, _instance, _event); + std::shared_ptr its_event = find_event(_service, _unique, _event); if (its_event) { is_inserted = its_event->add_subscriber( _eventgroup, _filter, _client, false); @@ -4426,14 +4438,14 @@ bool routing_manager_impl::create_placeholder_event_and_subscribe( } void routing_manager_impl::handle_subscription_state( - client_t _client, service_t _service, instance_t _instance, + client_t _client, service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { #if 0 VSOMEIP_ERROR << "routing_manager_impl::" << __func__ << "(" << std::hex << _client << "): " << "event=" << std::hex << _service << "." - << std::hex << _instance << "." + << std::hex << get_instance_from_unique(_unique) << "." << std::hex << _eventgroup << "." << std::hex << _event << " me=" @@ -4443,7 +4455,7 @@ void routing_manager_impl::handle_subscription_state( // method builds a critical section together with insert_subscription // from routing_manager_base. // Todo: Improve this situation... - auto its_event = find_event(_service, _instance, _event); + auto its_event = find_event(_service, _unique, _event); client_t its_client(VSOMEIP_ROUTING_CLIENT); if (its_event && its_event->get_type() == event_type_e::ET_SELECTIVE_EVENT) { @@ -4451,7 +4463,7 @@ void routing_manager_impl::handle_subscription_state( } auto its_tuple - = std::make_tuple(_service, _instance, _eventgroup, its_client); + = std::make_tuple(_service, _unique, _eventgroup, its_client); auto its_state = remote_subscription_state_.find(its_tuple); if (its_state != remote_subscription_state_.end()) { #if 0 @@ -4459,7 +4471,7 @@ void routing_manager_impl::handle_subscription_state( << "(" << std::hex << _client << "): " << "event=" << std::hex << _service << "." - << std::hex << _instance << "." + << std::hex << get_instance_from_unique(_unique) << "." << std::hex << _eventgroup << "." << std::hex << _event << " state=" << std::hex << (int)its_state->second @@ -4469,9 +4481,9 @@ void routing_manager_impl::handle_subscription_state( if (its_state->second == subscription_state_e::SUBSCRIPTION_ACKNOWLEDGED) { // Subscription already acknowledged! if (_client == get_client()) { - host_->on_subscription_status(_service, _instance, _eventgroup, _event, 0x0 /*OK*/); + host_->on_subscription_status(_service, _unique, _eventgroup, _event, 0x0 /*OK*/); } else if (stub_) { - stub_->send_subscribe_ack(_client, _service, _instance, _eventgroup, _event); + stub_->send_subscribe_ack(_client, _service, _unique, _eventgroup, _event); } } } @@ -4586,10 +4598,10 @@ void routing_manager_impl::status_log_timer_cbk( void routing_manager_impl::on_unsubscribe_ack(client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, remote_subscription_id_t _id) { std::shared_ptr its_info - = find_eventgroup(_service, _instance, _eventgroup); + = find_eventgroup(_service, _unique, _eventgroup); if (its_info) { std::unique_lock its_update_lock{update_remote_subscription_mutex_}; const auto its_subscription = its_info->get_remote_subscription(_id); @@ -4597,14 +4609,14 @@ routing_manager_impl::on_unsubscribe_ack(client_t _client, its_info->remove_remote_subscription(_id); std::lock_guard its_lock(remote_subscribers_mutex_); - remote_subscribers_[_service][_instance].erase(_client); + remote_subscribers_[_service][_unique].erase(_client); if (its_info->get_remote_subscriptions().size() == 0) { for (const auto &its_event : its_info->get_events()) { bool has_remote_subscriber(false); for (const auto &its_eventgroup : its_event->get_eventgroups()) { const auto its_eventgroup_info - = find_eventgroup(_service, _instance, its_eventgroup); + = find_eventgroup(_service, _unique, its_eventgroup); if (its_eventgroup_info && its_eventgroup_info->get_remote_subscriptions().size() > 0) { has_remote_subscriber = true; @@ -4621,7 +4633,7 @@ routing_manager_impl::on_unsubscribe_ack(client_t _client, << ": Unknown StopSubscribe " << std::dec << _id << " for eventgroup [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "]"; } } else { @@ -4630,7 +4642,7 @@ routing_manager_impl::on_unsubscribe_ack(client_t _client, << std::hex << std::setfill('0') << std::setw(4) << _client << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "]"; } } @@ -4643,30 +4655,30 @@ void routing_manager_impl::on_disconnect(const std::shared_ptr& _endpo } void routing_manager_impl::send_subscription( const client_t _offering_client, - const service_t _service, const instance_t _instance, + const service_t _service, const unique_version_t _unique, const eventgroup_t _eventgroup, const major_version_t _major, const std::set &_clients, const remote_subscription_id_t _id) { if (host_->get_client() == _offering_client) { auto self = shared_from_this(); for (const auto its_client : _clients) { - host_->on_subscription(_service, _instance, _eventgroup, its_client, + host_->on_subscription(_service, _unique, _eventgroup, its_client, get_sec_client(), get_env(its_client), true, - [this, self, _service, _instance, _eventgroup, its_client, _id] + [this, self, _service, _unique, _eventgroup, its_client, _id] (const bool _is_accepted) { try { if (!_is_accepted) { const auto its_callback = std::bind( &routing_manager_stub_host::on_subscribe_nack, std::dynamic_pointer_cast(shared_from_this()), - its_client, _service, _instance, + its_client, _service, _unique, _eventgroup, false, _id); io_.post(its_callback); } else { const auto its_callback = std::bind( &routing_manager_stub_host::on_subscribe_ack, std::dynamic_pointer_cast(shared_from_this()), - its_client, _service, _instance, + its_client, _service, _unique, _eventgroup, ANY_EVENT, _id); io_.post(its_callback); } @@ -4678,12 +4690,12 @@ void routing_manager_impl::send_subscription( } else { // service hosted by local client for (const auto its_client : _clients) { if (stub_ && !stub_->send_subscribe(find_local(_offering_client), its_client, - _service, _instance, _eventgroup, _major, ANY_EVENT, nullptr, _id)) { + _service, get_instance_from_unique(_unique), _eventgroup, _major, ANY_EVENT, nullptr, _id)) { try { const auto its_callback = std::bind( &routing_manager_stub_host::on_subscribe_nack, std::dynamic_pointer_cast(shared_from_this()), - its_client, _service, _instance, _eventgroup, + its_client, _service, _unique, _eventgroup, true, _id); io_.post(its_callback); } catch (const std::exception &e) { @@ -4711,21 +4723,21 @@ void routing_manager_impl::cleanup_server_endpoint( } pending_remote_offer_id_t routing_manager_impl::pending_remote_offer_add( - service_t _service, instance_t _instance) { + service_t _service, unique_version_t _unique) { std::lock_guard its_lock(pending_remote_offers_mutex_); if (++pending_remote_offer_id_ == 0) { pending_remote_offer_id_++; } pending_remote_offers_[pending_remote_offer_id_] = std::make_pair(_service, - _instance); + _unique); return pending_remote_offer_id_; } -std::pair routing_manager_impl::pending_remote_offer_remove( +std::pair routing_manager_impl::pending_remote_offer_remove( pending_remote_offer_id_t _id) { std::lock_guard its_lock(pending_remote_offers_mutex_); - std::pair ret = std::make_pair(ANY_SERVICE, - ANY_INSTANCE); + std::pair ret = std::make_pair(ANY_SERVICE, + ANY_INSTANCE); auto found_si = pending_remote_offers_.find(_id); if (found_si != pending_remote_offers_.end()) { ret = found_si->second; @@ -4736,7 +4748,7 @@ std::pair routing_manager_impl::pending_remote_offer_remo void routing_manager_impl::on_resend_provided_events_response( pending_remote_offer_id_t _id) { - const std::pair its_service = + const std::pair its_service = pending_remote_offer_remove(_id); if (its_service.first != ANY_SERVICE) { // create server endpoint @@ -4755,18 +4767,18 @@ void routing_manager_impl::print_stub_status() const { } void routing_manager_impl::service_endpoint_connected( - service_t _service, instance_t _instance, major_version_t _major, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, const std::shared_ptr& _endpoint, bool _unreliable_only) { if (!_unreliable_only) { // Mark only TCP-only and TCP+UDP services available here // UDP-only services are already marked as available in add_routing_info - on_availability(_service, _instance, + on_availability(_service, get_instance_from_unique(_unique), availability_state_e::AS_AVAILABLE, _major, _minor); if (stub_) - stub_->on_offer_service(VSOMEIP_ROUTING_CLIENT, _service, _instance, + stub_->on_offer_service(VSOMEIP_ROUTING_CLIENT, _service, _unique, _major, _minor); } @@ -4779,31 +4791,31 @@ void routing_manager_impl::service_endpoint_connected( std::bind(&routing_manager_impl::call_sd_endpoint_connected, std::static_pointer_cast( shared_from_this()), std::placeholders::_1, - _service, _instance, _endpoint, its_timer)); + _service, _unique, _endpoint, its_timer)); } else { VSOMEIP_ERROR << __func__ << " " << ec.message(); } } void routing_manager_impl::service_endpoint_disconnected( - service_t _service, instance_t _instance, major_version_t _major, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, const std::shared_ptr& _endpoint) { (void)_endpoint; - on_availability(_service, _instance, + on_availability(_service, get_instance_from_unique(_unique), availability_state_e::AS_UNAVAILABLE, _major, _minor); if (stub_) - stub_->on_stop_offer_service(VSOMEIP_ROUTING_CLIENT, _service, _instance, + stub_->on_stop_offer_service(VSOMEIP_ROUTING_CLIENT, _service, _unique, _major, _minor); VSOMEIP_WARNING << __func__ << ": lost connection to remote service: [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "]"; + << std::setw(4) << get_instance_from_unique(_unique) << "]"; } void routing_manager_impl::send_unsubscription(client_t _offering_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, const std::set &_removed, remote_subscription_id_t _id) { @@ -4813,9 +4825,9 @@ routing_manager_impl::send_unsubscription(client_t _offering_client, if (host_->get_client() == _offering_client) { auto self = shared_from_this(); for (const auto its_client : _removed) { - host_->on_subscription(_service, _instance, _eventgroup, + host_->on_subscription(_service, _unique, _eventgroup, its_client, get_sec_client(), get_env(its_client),false, - [this, self, _service, _instance, _eventgroup, + [this, self, _service, _unique, _eventgroup, its_client, _id] (const bool _is_accepted) { (void)_is_accepted; @@ -4823,7 +4835,7 @@ routing_manager_impl::send_unsubscription(client_t _offering_client, const auto its_callback = std::bind( &routing_manager_stub_host::on_unsubscribe_ack, std::dynamic_pointer_cast(shared_from_this()), - its_client, _service, _instance, _eventgroup, _id); + its_client, _service, _unique, _eventgroup, _id); io_.post(its_callback); } catch (const std::exception &e) { VSOMEIP_ERROR << __func__ << e.what(); @@ -4834,12 +4846,12 @@ routing_manager_impl::send_unsubscription(client_t _offering_client, } else { for (const auto its_client : _removed) { if (stub_ && !stub_->send_unsubscribe(find_local(_offering_client), its_client, - _service, _instance, _eventgroup, ANY_EVENT, _id)) { + _service, _unique, _eventgroup, ANY_EVENT, _id)) { try { const auto its_callback = std::bind( &routing_manager_stub_host::on_unsubscribe_ack, std::dynamic_pointer_cast(shared_from_this()), - its_client, _service, _instance, _eventgroup, _id); + its_client, _service, _unique, _eventgroup, _id); io_.post(its_callback); } catch (const std::exception &e) { VSOMEIP_ERROR << __func__ << e.what(); @@ -4851,7 +4863,7 @@ routing_manager_impl::send_unsubscription(client_t _offering_client, void routing_manager_impl::send_expired_subscription(client_t _offering_client, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, const std::set &_removed, remote_subscription_id_t _id) { @@ -4859,7 +4871,7 @@ routing_manager_impl::send_expired_subscription(client_t _offering_client, if (host_->get_client() == _offering_client) { auto self = shared_from_this(); for (const auto its_client : _removed) { - host_->on_subscription(_service, _instance, + host_->on_subscription(_service, _unique, _eventgroup, its_client, get_sec_client(), get_env(its_client), false, [] (const bool _subscription_accepted){ (void)_subscription_accepted; @@ -4869,7 +4881,7 @@ routing_manager_impl::send_expired_subscription(client_t _offering_client, for (const auto its_client : _removed) { if (stub_) stub_->send_expired_subscription(find_local(_offering_client), its_client, - _service, _instance, _eventgroup, ANY_EVENT, _id); + _service, get_instance_from_unique(_unique), _eventgroup, ANY_EVENT, _id); } } } @@ -4902,12 +4914,12 @@ routing_manager_impl::remove_security_policy_configuration( } #endif // !VSOMEIP_DISABLE_SECURITY -bool routing_manager_impl::insert_event_statistics(service_t _service, instance_t _instance, +bool routing_manager_impl::insert_event_statistics(service_t _service, unique_version_t _unique, method_t _method, length_t _length) { static uint32_t its_max_messages = configuration_->get_statistics_max_messages(); std::lock_guard its_lock(message_statistics_mutex_); - const auto its_tuple = std::make_tuple(_service, _instance, _method); + const auto its_tuple = std::make_tuple(_service, _unique, _method); const auto its_main_s = message_statistics_.find(its_tuple); if (its_main_s != message_statistics_.end()) { // increase counter and calculate moving average for payload length @@ -4973,7 +4985,7 @@ void routing_manager_impl::statistics_log_timer_cbk(boost::system::error_code co } its_log << std::hex << std::setfill('0') << std::setw(4) << std::get<0>(s.first) << "." - << std::get<1>(s.first) << "." + << get_instance_from_unique(std::get<1>(s.first)) << "." << std::get<2>(s.first) << ": #=" << std::dec << s.second.counter_ << " L=" << s.second.avg_length_ << " S=" @@ -5046,7 +5058,7 @@ routing_manager_impl::remove_subscriptions(port_t _local_port, port_t _remote_port) { std::map > > >its_eventgroups; { @@ -5054,8 +5066,8 @@ routing_manager_impl::remove_subscriptions(port_t _local_port, its_eventgroups = eventgroups_; } for (const auto &its_service : its_eventgroups) { - for (const auto &its_instance : its_service.second) { - for (const auto &its_eventgroup : its_instance.second) { + for (const auto &its_unique : its_service.second) { + for (const auto &its_eventgroup : its_unique.second) { const auto its_info = its_eventgroup.second; for (auto its_subscription : its_info->get_remote_subscriptions()) { diff --git a/implementation/routing/src/routing_manager_stub.cpp b/implementation/routing/src/routing_manager_stub.cpp index 230a7b3da..2a473fd80 100644 --- a/implementation/routing/src/routing_manager_stub.cpp +++ b/implementation/routing/src/routing_manager_stub.cpp @@ -377,7 +377,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, its_minor = its_command.get_minor(); host_->stop_offer_service(its_client, - its_service, its_instance, + its_service, get_unique_version(its_instance, its_major), its_major, its_minor); } else VSOMEIP_ERROR << __func__ @@ -402,8 +402,8 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, if (its_notifier == ANY_EVENT) { if (host_->is_subscribe_to_any_event_allowed(_sec_client, its_client, its_service, - its_instance, its_eventgroup)) { - host_->subscribe(its_client, _sec_client, its_service, its_instance, + get_unique_version(its_instance, its_major), its_eventgroup)) { + host_->subscribe(its_client, _sec_client, its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_major, its_notifier, its_filter); } else { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << its_client @@ -415,7 +415,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, } else { if (VSOMEIP_SEC_OK == configuration_->get_security()->is_client_allowed_to_access_member( _sec_client, its_service, its_instance, its_notifier)) { - host_->subscribe(its_client, _sec_client, its_service, its_instance, + host_->subscribe(its_client, _sec_client, its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_major, its_notifier, its_filter); } else { VSOMEIP_WARNING << "vSomeIP Security: Client 0x" << std::hex << its_client @@ -443,9 +443,10 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, its_instance = its_command.get_instance(); its_eventgroup = its_command.get_eventgroup(); its_notifier = its_command.get_event(); + its_major = static_cast(its_command.get_version()); host_->unsubscribe(its_client, _sec_client, - its_service, its_instance, its_eventgroup, its_notifier); + its_service, get_unique_version(its_instance, its_major), its_eventgroup, its_notifier); } else VSOMEIP_ERROR << __func__ << ": deserializing unsubscribe failed (" @@ -466,9 +467,10 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, its_subscriber = its_command.get_subscriber(); its_notifier = its_command.get_event(); its_subscription_id = its_command.get_pending_id(); + its_major = static_cast(its_command.get_version()); host_->on_subscribe_ack(its_subscriber, its_service, - its_instance, its_eventgroup, its_notifier, its_subscription_id); + get_unique_version(its_instance, its_major), its_eventgroup, its_notifier, its_subscription_id); VSOMEIP_INFO << "SUBSCRIBE ACK(" << std::hex << std::setfill('0') @@ -498,9 +500,10 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, its_subscriber = its_command.get_subscriber(); its_notifier = its_command.get_event(); its_subscription_id = its_command.get_pending_id(); + its_major = static_cast(its_command.get_version()); host_->on_subscribe_nack(its_subscriber, its_service, - its_instance, its_eventgroup, false, its_subscription_id); + get_unique_version(its_instance, its_major), its_eventgroup, false, its_subscription_id); VSOMEIP_INFO << "SUBSCRIBE NACK(" << std::hex << std::setfill('0') @@ -528,9 +531,10 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, its_instance = its_command.get_instance(); its_eventgroup = its_command.get_eventgroup(); its_subscription_id = its_command.get_pending_id(); + its_major = static_cast(its_command.get_version()); host_->on_unsubscribe_ack(its_client, its_service, - its_instance, its_eventgroup, its_subscription_id); + get_unique_version(its_instance, its_major), its_eventgroup, its_subscription_id); VSOMEIP_INFO << "UNSUBSCRIBE ACK(" << std::hex << std::setfill('0') @@ -561,6 +565,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, its_instance = its_command.get_instance(); is_reliable = its_command.is_reliable(); its_check_status = its_command.get_status(); + its_major = static_cast(its_command.get_version()); // Allow response messages from local proxies as answer to remote requests // but check requests sent by local proxies to remote against policy. @@ -581,7 +586,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, VSOMEIP_WARNING << "Received a SEND command containing message with invalid size -> skip!"; break; } - host_->on_message(its_service, its_instance, + host_->on_message(its_service, get_unique_version(its_instance, its_major), &its_message_data[0], length_t(its_message_data.size()), is_reliable, _bound_client, _sec_client, its_check_status, false); } @@ -602,6 +607,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, its_client = its_command.get_target(); its_service = bithelper::read_uint16_be(&its_message_data[VSOMEIP_SERVICE_POS_MIN]); its_instance = its_command.get_instance(); + its_major = static_cast(its_command.get_version()); uint32_t its_contained_size = bithelper::read_uint32_be(&its_message_data[VSOMEIP_LENGTH_POS_MIN]); @@ -610,7 +616,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, break; } - host_->on_notification(its_client, its_service, its_instance, + host_->on_notification(its_client, its_service, get_unique_version(its_instance, its_major), &its_message_data[0], length_t(its_message_data.size()), its_id == protocol::id_e::NOTIFY_ONE_ID); break; @@ -632,7 +638,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, if (VSOMEIP_SEC_OK == configuration_->get_security()->is_client_allowed_to_request( _sec_client, r.service_, r.instance_)) { host_->request_service(its_client, - r.service_, r.instance_, r.major_, r.minor_); + r.service_, get_unique_version(r.instance_, r.major_), r.major_, r.minor_); its_allowed_requests.insert(r); } } @@ -654,7 +660,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, if (its_error == protocol::error_e::ERROR_OK) { host_->release_service(its_command.get_client(), - its_command.get_service(), its_command.get_instance()); + its_command.get_service(), get_unique_version(its_command.get_instance(), static_cast(its_command.get_version()))); } else VSOMEIP_ERROR << __func__ << ": release service deserialization failed (" << std::dec << static_cast(its_error) << ")"; @@ -676,9 +682,10 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, its_service = register_event.get_service(); its_instance = register_event.get_instance(); + its_major = static_cast(its_command.get_version()); if (register_event.is_provided() - && !configuration_->is_offered_remote(its_service, its_instance)) { + && !configuration_->is_offered_remote(its_service, get_unique_version(its_instance, its_major))) { continue; } @@ -713,7 +720,7 @@ void routing_manager_stub::on_message(const byte_t *_data, length_t _size, if (its_error == protocol::error_e::ERROR_OK) { host_->unregister_shadow_event(its_command.get_client(), - its_command.get_service(), its_command.get_instance(), + its_command.get_service(), get_unique_version(its_command.get_instance(), static_cast(its_command.get_version())), its_command.get_event(), its_command.is_provided()); VSOMEIP_INFO << "UNREGISTER EVENT(" @@ -948,7 +955,7 @@ void routing_manager_stub::on_offered_service_request(client_t _client, || (_offer_type == offer_type_e::OT_LOCAL && !has_port) || (_offer_type == offer_type_e::OT_REMOTE && has_port)) { - protocol::service its_service(s.first, i.first, + protocol::service its_service(s.first, get_instance_from_unique(i.first), i.second.first, i.second.second); its_command.add_service(its_service); } @@ -1127,12 +1134,12 @@ routing_manager_stub::on_net_state_change( #endif // __linux__ || ANDROID void routing_manager_stub::on_offer_service(client_t _client, - service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor) { + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { VSOMEIP_DEBUG << "routing_manager_stub::" << __func__ << ": ON_OFFER_SERVICE(" << std::hex << std::setw(4) << std::setfill('0') << _client <<"): [" << std::hex << std::setw(4) << std::setfill('0') << _service << "." - << std::hex << std::setw(4) << std::setfill('0') << _instance + << std::hex << std::setw(4) << std::setfill('0') << get_instance_from_unique(_unique) << ":" << std::dec << int(_major) << "." << std::dec << _minor << "]"; if (_client == host_->get_client()) { @@ -1140,37 +1147,37 @@ void routing_manager_stub::on_offer_service(client_t _client, } std::lock_guard its_guard(routing_info_mutex_); - routing_info_[_client].second[_service][_instance] = std::make_pair(_major, _minor); + routing_info_[_client].second[_service][_unique] = std::make_pair(_major, _minor); if (configuration_->is_security_enabled()) { - distribute_credentials(_client, _service, _instance); + distribute_credentials(_client, _service, get_instance_from_unique(_unique)); } - inform_requesters(_client, _service, _instance, _major, _minor, + inform_requesters(_client, _service, _unique, _major, _minor, protocol::routing_info_entry_type_e::RIE_ADD_SERVICE_INSTANCE, true); } void routing_manager_stub::on_stop_offer_service(client_t _client, - service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor) { + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { std::lock_guard its_guard(routing_info_mutex_); auto found_client = routing_info_.find(_client); if (found_client != routing_info_.end()) { auto found_service = found_client->second.second.find(_service); if (found_service != found_client->second.second.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_version = found_instance->second; + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_version = found_unique->second; if( _major == found_version.first && _minor == found_version.second) { - found_service->second.erase(_instance); + found_service->second.erase(_unique); if (0 == found_service->second.size()) { found_client->second.second.erase(_service); } - inform_requesters(_client, _service, _instance, _major, _minor, + inform_requesters(_client, _service, _unique, _major, _minor, protocol::routing_info_entry_type_e::RIE_DELETE_SERVICE_INSTANCE, false); } else if( _major == DEFAULT_MAJOR && _minor == DEFAULT_MINOR) { - found_service->second.erase(_instance); + found_service->second.erase(_unique); if (0 == found_service->second.size()) { found_client->second.second.erase(_service); } - inform_requesters(_client, _service, _instance, _major, _minor, + inform_requesters(_client, _service, _unique, _major, _minor, protocol::routing_info_entry_type_e::RIE_DELETE_SERVICE_INSTANCE, false); } } @@ -1257,14 +1264,14 @@ void routing_manager_stub::send_client_routing_info(const client_t _target, << "] failed"; } -void routing_manager_stub::distribute_credentials(client_t _hoster, service_t _service, instance_t _instance) { +void routing_manager_stub::distribute_credentials(client_t _hoster, service_t _service, unique_version_t _unique) { std::set> its_credentials; std::set its_requesting_clients; // search for clients which shall receive the credentials for (auto its_requesting_client : service_requests_) { auto its_service = its_requesting_client.second.find(_service); if (its_service != its_requesting_client.second.end()) { - if (its_service->second.find(_instance) != its_service->second.end() + if (its_service->second.find(_unique) != its_service->second.end() || its_service->second.find(ANY_INSTANCE) != its_service->second.end()) { its_requesting_clients.insert(its_requesting_client.first); } @@ -1290,7 +1297,7 @@ void routing_manager_stub::distribute_credentials(client_t _hoster, service_t _s } void routing_manager_stub::inform_requesters(client_t _hoster, service_t _service, - instance_t _instance, major_version_t _major, minor_version_t _minor, + unique_version_t _unique, major_version_t _major, minor_version_t _minor, protocol::routing_info_entry_type_e _type, bool _inform_service) { boost::asio::ip::address its_address; @@ -1299,7 +1306,7 @@ void routing_manager_stub::inform_requesters(client_t _hoster, service_t _servic for (auto its_client : service_requests_) { auto its_service = its_client.second.find(_service); if (its_service != its_client.second.end()) { - if (its_service->second.find(_instance) != its_service->second.end() + if (its_service->second.find(_unique) != its_service->second.end() || its_service->second.find(ANY_INSTANCE) != its_service->second.end()) { if (_inform_service) { if (_hoster != VSOMEIP_ROUTING_CLIENT && @@ -1329,7 +1336,7 @@ void routing_manager_stub::inform_requesters(client_t _hoster, service_t _servic its_entry.set_address(its_address); its_entry.set_port(its_port); } - its_entry.add_service({ _service, _instance, _major, _minor} ); + its_entry.add_service({ _service, get_instance_from_unique(_unique), _major, _minor} ); send_client_routing_info(its_client.first, its_entry); } } @@ -1398,7 +1405,7 @@ bool routing_manager_stub::send_subscribe( bool routing_manager_stub::send_unsubscribe( const std::shared_ptr& _target, - client_t _client, service_t _service, instance_t _instance, + client_t _client, service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _id) { @@ -1409,10 +1416,11 @@ bool routing_manager_stub::send_unsubscribe( protocol::unsubscribe_command its_command; its_command.set_client(_client); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_eventgroup(_eventgroup); its_command.set_event(_event); its_command.set_pending_id(_id); + its_command.set_version(static_cast(get_major_from_unique(_unique))); std::vector its_buffer; protocol::error_e its_error; @@ -1429,7 +1437,7 @@ bool routing_manager_stub::send_unsubscribe( << " Couldn't send unsubscription to local client [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_major_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "." << std::setw(4) << _event << "]" << " subscriber: "<< std::setw(4) << _client; @@ -1440,7 +1448,7 @@ bool routing_manager_stub::send_unsubscribe( bool routing_manager_stub::send_expired_subscription( const std::shared_ptr& _target, - client_t _client, service_t _service, instance_t _instance, + client_t _client, service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _id) { @@ -1451,10 +1459,11 @@ bool routing_manager_stub::send_expired_subscription( protocol::expire_command its_command; its_command.set_client(_client); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_eventgroup(_eventgroup); its_command.set_event(_event); its_command.set_pending_id(_id); + its_command.set_version(static_cast(get_major_from_unique(_unique))); std::vector its_buffer; protocol::error_e its_error; @@ -1471,7 +1480,7 @@ bool routing_manager_stub::send_expired_subscription( << " Couldn't send expired subscription to local client [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_major_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "." << std::setw(4) << _event << "]" << " subscriber: "<< std::setw(4) << _client; @@ -1481,7 +1490,7 @@ bool routing_manager_stub::send_expired_subscription( } void routing_manager_stub::send_subscribe_ack(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event) { + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { std::shared_ptr its_target = host_->find_local(_client); if (its_target) { @@ -1489,10 +1498,11 @@ void routing_manager_stub::send_subscribe_ack(client_t _client, service_t _servi protocol::subscribe_ack_command its_command; its_command.set_client(get_client()); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_eventgroup(_eventgroup); its_command.set_subscriber(_client); its_command.set_event(_event); + its_command.set_version(static_cast(get_major_from_unique(_unique))); std::vector its_buffer; protocol::error_e its_error; @@ -1508,7 +1518,7 @@ void routing_manager_stub::send_subscribe_ack(client_t _client, service_t _servi } void routing_manager_stub::send_subscribe_nack(client_t _client, service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event) { + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { std::shared_ptr its_target = host_->find_local(_client); if (its_target) { @@ -1516,10 +1526,11 @@ void routing_manager_stub::send_subscribe_nack(client_t _client, service_t _serv protocol::subscribe_nack_command its_command; its_command.set_client(get_client()); its_command.set_service(_service); - its_command.set_instance(_instance); + its_command.set_instance(get_instance_from_unique(_unique)); its_command.set_eventgroup(_eventgroup); its_command.set_subscriber(_client); its_command.set_event(_event); + its_command.set_version(static_cast(get_major_from_unique(_unique))); std::vector its_buffer; protocol::error_e its_error; @@ -1535,17 +1546,17 @@ void routing_manager_stub::send_subscribe_nack(client_t _client, service_t _serv } bool routing_manager_stub::contained_in_routing_info( - client_t _client, service_t _service, instance_t _instance, + client_t _client, service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) const { std::lock_guard its_guard(routing_info_mutex_); auto found_client = routing_info_.find(_client); if (found_client != routing_info_.end()) { auto found_service = found_client->second.second.find(_service); if (found_service != found_client->second.second.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - if (found_instance->second.first == _major - && found_instance->second.second == _minor) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + if (found_unique->second.first == _major + && found_unique->second.second == _minor) { return true; } } @@ -1971,7 +1982,7 @@ void routing_manager_stub::handle_requests(const client_t _client, std::setsecond.second.find(request.service_); if (found_service != found_client->second.second.end()) { - for (auto instance : found_service->second) { + for (auto unique : found_service->second) { add_connection(_client, c); protocol::routing_info_entry its_entry; @@ -1981,8 +1992,8 @@ void routing_manager_stub::handle_requests(const client_t _client, std::set &_eventgroups, event_type_e _type, std::chrono::milliseconds _cycle, bool _change_resets_cycle, @@ -73,43 +73,43 @@ class application_impl: public application, reliability_type_e _reliability); VSOMEIP_EXPORT void stop_offer_event(service_t _service, - instance_t _instance, event_t _event); + unique_version_t _unique, event_t _event); // Consume services / events VSOMEIP_EXPORT void request_service( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor); VSOMEIP_EXPORT void release_service( - service_t _service, instance_t _instance); + service_t _service, unique_version_t _unique); VSOMEIP_EXPORT void request_event(service_t _service, - instance_t _instance, event_t _event, + unique_version_t _unique, event_t _event, const std::set &_eventgroups, event_type_e _type, reliability_type_e _reliability); VSOMEIP_EXPORT void release_event(service_t _service, - instance_t _instance, event_t _event); + unique_version_t _unique, event_t _event); - VSOMEIP_EXPORT void subscribe(service_t _service, instance_t _instance, + VSOMEIP_EXPORT void subscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event); - VSOMEIP_EXPORT void subscribe_with_debounce(service_t _service, instance_t _instance, + VSOMEIP_EXPORT void subscribe_with_debounce(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const debounce_filter_t &_filter); - VSOMEIP_EXPORT void unsubscribe(service_t _service, instance_t _instance, + VSOMEIP_EXPORT void unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup); - VSOMEIP_EXPORT void unsubscribe(service_t _service, instance_t _instance, + VSOMEIP_EXPORT void unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); - VSOMEIP_EXPORT bool is_available(service_t _service, instance_t _instance, + VSOMEIP_EXPORT bool is_available(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) const; VSOMEIP_EXPORT void send(std::shared_ptr _message); - VSOMEIP_EXPORT void notify(service_t _service, instance_t _instance, + VSOMEIP_EXPORT void notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force) const; - VSOMEIP_EXPORT void notify_one(service_t _service, instance_t _instance, + VSOMEIP_EXPORT void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force) const; @@ -117,26 +117,26 @@ class application_impl: public application, VSOMEIP_EXPORT void unregister_state_handler(); VSOMEIP_EXPORT void register_message_handler(service_t _service, - instance_t _instance, method_t _method, const message_handler_t &_handler); + unique_version_t _unique, method_t _method, const message_handler_t &_handler); VSOMEIP_EXPORT void unregister_message_handler(service_t _service, - instance_t _instance, method_t _method); + unique_version_t _unique, method_t _method); VSOMEIP_EXPORT void register_availability_handler(service_t _service, - instance_t _instance, const availability_handler_t &_handler, + unique_version_t _unique, const availability_handler_t &_handler, major_version_t _major, minor_version_t _minor); VSOMEIP_EXPORT void register_availability_handler(service_t _service, - instance_t _instance, const availability_state_handler_t &_handler, + unique_version_t _unique, const availability_state_handler_t &_handler, major_version_t _major, minor_version_t _minor); VSOMEIP_EXPORT void unregister_availability_handler(service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor); VSOMEIP_EXPORT void register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, const subscription_handler_t &_handler); + unique_version_t _unique, eventgroup_t _eventgroup, const subscription_handler_t &_handler); VSOMEIP_EXPORT void register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, const subscription_handler_ext_t &_handler); + unique_version_t _unique, eventgroup_t _eventgroup, const subscription_handler_ext_t &_handler); VSOMEIP_EXPORT void unregister_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup); + unique_version_t _unique, eventgroup_t _eventgroup); VSOMEIP_EXPORT bool is_routing() const; @@ -157,22 +157,22 @@ class application_impl: public application, VSOMEIP_EXPORT void on_availability(service_t _service, instance_t _instance, availability_state_e _state, major_version_t _major, minor_version_t _minor); VSOMEIP_EXPORT void on_message(std::shared_ptr &&_message); - VSOMEIP_EXPORT void on_subscription(service_t _service, instance_t _instance, + VSOMEIP_EXPORT void on_subscription(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, client_t _client, const vsomeip_sec_client_t *_sec_client, const std::string &_env, bool _subscribed, const std::function &_accepted_cb); - VSOMEIP_EXPORT void on_subscription_status(service_t _service, instance_t _instance, + VSOMEIP_EXPORT void on_subscription_status(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, uint16_t _error); VSOMEIP_EXPORT void register_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, subscription_status_handler_t _handler, bool _is_selective); VSOMEIP_EXPORT void unregister_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event); + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); // service_discovery_host VSOMEIP_EXPORT routing_manager * get_routing_manager() const; VSOMEIP_EXPORT bool are_available(available_t &_available, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) const; VSOMEIP_EXPORT void set_routing_state(routing_state_e _routing_state); @@ -181,15 +181,15 @@ class application_impl: public application, VSOMEIP_EXPORT void get_offered_services_async(offer_type_e _offer_type, const offered_services_handler_t &_handler); - VSOMEIP_EXPORT void on_offered_services_info(std::vector> &_services); + VSOMEIP_EXPORT void on_offered_services_info(std::vector> &_services); VSOMEIP_EXPORT void set_watchdog_handler(const watchdog_handler_t &_handler, std::chrono::seconds _interval); VSOMEIP_EXPORT void register_async_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, const async_subscription_handler_t &_handler); + unique_version_t _unique, eventgroup_t _eventgroup, const async_subscription_handler_t &_handler); VSOMEIP_EXPORT void register_async_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, const async_subscription_handler_ext_t &_handler); + unique_version_t _unique, eventgroup_t _eventgroup, const async_subscription_handler_ext_t &_handler); VSOMEIP_EXPORT void set_sd_acceptance_required(const remote_info_t& _remote, const std::string& _path, bool _enable); @@ -206,7 +206,7 @@ class application_impl: public application, VSOMEIP_EXPORT void register_routing_state_handler(const routing_state_handler_t &_handler); VSOMEIP_EXPORT bool update_service_configuration(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled, @@ -227,10 +227,10 @@ class application_impl: public application, get_additional_data(const std::string &_plugin_name); VSOMEIP_EXPORT void register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, const subscription_handler_sec_t &_handler); VSOMEIP_EXPORT void register_async_subscription_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, async_subscription_handler_sec_t _handler); VSOMEIP_EXPORT void register_message_handler_ext( @@ -319,21 +319,21 @@ class application_impl: public application, void shutdown(); - void send_back_cached_event(service_t _service, instance_t _instance, event_t _event); - void send_back_cached_eventgroup(service_t _service, instance_t _instance, eventgroup_t _eventgroup); - void check_send_back_cached_event(service_t _service, instance_t _instance, + void send_back_cached_event(service_t _service, unique_version_t _unique, event_t _event); + void send_back_cached_eventgroup(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup); + void check_send_back_cached_event(service_t _service, unique_version_t _unique, event_t _event, eventgroup_t _eventgroup, bool *_send_back_cached_event, bool *_send_back_cached_eventgroup); - void remove_subscription(service_t _service, instance_t _instance, + void remove_subscription(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); - bool check_for_active_subscription(service_t _service, instance_t _instance, + bool check_for_active_subscription(service_t _service, unique_version_t _unique, event_t _event); - void deliver_subscription_state(service_t _service, instance_t _instance, + void deliver_subscription_state(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, uint16_t _error); - bool check_subscription_state(service_t _service, instance_t _instance, + bool check_subscription_state(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event); void print_blocking_call(const std::shared_ptr& _handler); @@ -421,13 +421,13 @@ class application_impl: public application, // Subscription handlers std::map > > > subscription_; mutable std::mutex subscription_mutex_; std::map > > > eventgroup_error_handlers_; mutable std::mutex subscription_error_mutex_; @@ -480,7 +480,7 @@ class application_impl: public application, // Event subscriptions std::mutex subscriptions_mutex_; - std::map>>> subscriptions_; std::thread::id stop_caller_id_; @@ -488,13 +488,13 @@ class application_impl: public application, bool stopped_called_; - std::map > > > > subscription_status_handlers_; std::mutex subscription_status_handlers_mutex_; std::mutex subscriptions_state_mutex_; std::map > diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp index 203c05fb5..bb2bc897f 100644 --- a/implementation/runtime/src/application_impl.cpp +++ b/implementation/runtime/src/application_impl.cpp @@ -590,84 +590,84 @@ security_mode_e application_impl::get_security_mode() const { return security_mode_; } -void application_impl::offer_service(service_t _service, instance_t _instance, +void application_impl::offer_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { if (routing_) - routing_->offer_service(client_, _service, _instance, _major, _minor); + routing_->offer_service(client_, _service, _unique, _major, _minor); } -void application_impl::stop_offer_service(service_t _service, instance_t _instance, +void application_impl::stop_offer_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { if (routing_) - routing_->stop_offer_service(client_, _service, _instance, _major, _minor); + routing_->stop_offer_service(client_, _service, _unique, _major, _minor); } -void application_impl::request_service(service_t _service, instance_t _instance, +void application_impl::request_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) { - invoke_availability_handler(_service, _instance, _major, _minor); + invoke_availability_handler(_service, get_instance_from_unique(_unique), _major, _minor); if (routing_) - routing_->request_service(client_, _service, _instance, _major, _minor); + routing_->request_service(client_, _service, _unique, _major, _minor); } void application_impl::release_service(service_t _service, - instance_t _instance) { + unique_version_t _unique) { { std::lock_guard its_subscriptions_state_guard(subscriptions_state_mutex_); auto found_service = subscriptions_state_.find(_service); if (found_service != subscriptions_state_.end()) { - found_service->second.erase(_instance); + found_service->second.erase(_unique); if (found_service->second.empty()) { subscriptions_state_.erase(_service); } } } if (routing_) - routing_->release_service(client_, _service, _instance); + routing_->release_service(client_, _service, _unique); } -void application_impl::subscribe(service_t _service, instance_t _instance, +void application_impl::subscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event) { if (routing_) { bool send_back_cached(false); bool send_back_cached_group(false); - check_send_back_cached_event(_service, _instance, _event, _eventgroup, + check_send_back_cached_event(_service, _unique, _event, _eventgroup, &send_back_cached, &send_back_cached_group); if (send_back_cached) { - send_back_cached_event(_service, _instance, _event); + send_back_cached_event(_service, _unique, _event); } else if(send_back_cached_group) { - send_back_cached_eventgroup(_service, _instance, _eventgroup); + send_back_cached_eventgroup(_service, _unique, _eventgroup); } - if (check_subscription_state(_service, _instance, _eventgroup, _event)) { + if (check_subscription_state(_service, _unique, _eventgroup, _event)) { routing_->subscribe(client_, &sec_client_, - _service, _instance, _eventgroup, _major, + _service, _unique, _eventgroup, _major, _event, nullptr); } } } -void application_impl::unsubscribe(service_t _service, instance_t _instance, +void application_impl::unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) { - remove_subscription(_service, _instance, _eventgroup, ANY_EVENT); + remove_subscription(_service, _unique, _eventgroup, ANY_EVENT); if (routing_) - routing_->unsubscribe(client_, &sec_client_, _service, _instance, _eventgroup, ANY_EVENT); + routing_->unsubscribe(client_, &sec_client_, _service, _unique, _eventgroup, ANY_EVENT); } -void application_impl::unsubscribe(service_t _service, instance_t _instance, +void application_impl::unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { - remove_subscription(_service, _instance, _eventgroup, _event); + remove_subscription(_service, _unique, _eventgroup, _event); if (routing_) - routing_->unsubscribe(client_, &sec_client_, _service, _instance, _eventgroup, _event); + routing_->unsubscribe(client_, &sec_client_, _service, _unique, _eventgroup, _event); } bool application_impl::is_available( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) const { std::lock_guard its_lock(availability_mutex_); - return (is_available_unlocked(_service, _instance, _major, _minor) + return (is_available_unlocked(_service, get_instance_from_unique(_unique), _major, _minor) == availability_state_e::AS_AVAILABLE); } @@ -738,10 +738,10 @@ application_impl::is_available_unlocked( bool application_impl::are_available( available_t &_available, - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor) const { std::lock_guard its_lock(availability_mutex_); - return (are_available_unlocked(_available, _service, _instance, _major, _minor) + return (are_available_unlocked(_available, _service, get_instance_from_unique(_unique), _major, _minor) == availability_state_e::AS_AVAILABLE); } @@ -897,23 +897,23 @@ void application_impl::send(std::shared_ptr _message) { } } -void application_impl::notify(service_t _service, instance_t _instance, +void application_impl::notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force) const { if (routing_) { auto its_payload { runtime::get()->create_payload(_payload->get_data(), _payload->get_length())}; - routing_->notify(_service, _instance, _event, its_payload, _force); + routing_->notify(_service, _unique, _event, its_payload, _force); } } -void application_impl::notify_one(service_t _service, instance_t _instance, +void application_impl::notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force) const { if (routing_) { auto its_payload { runtime::get()->create_payload(_payload->get_data(), _payload->get_length())}; - routing_->notify_one(_service, _instance, _event, its_payload, _client, _force + routing_->notify_one(_service, _unique, _event, its_payload, _client, _force #ifdef VSOMEIP_ENABLE_COMPAT , false @@ -933,26 +933,26 @@ void application_impl::unregister_state_handler() { } void application_impl::register_availability_handler(service_t _service, - instance_t _instance, const availability_handler_t &_handler, + unique_version_t _unique, const availability_handler_t &_handler, major_version_t _major, minor_version_t _minor) { std::lock_guard availability_lock(availability_mutex_); - auto its_handler_ext = [_handler](service_t _service, instance_t _instance, + auto its_handler_ext = [_handler](service_t _service, unique_version_t _unique, availability_state_e _state) { - _handler(_service, _instance, + _handler(_service, get_instance_from_unique(_unique), (_state == availability_state_e::AS_AVAILABLE)); }; - register_availability_handler_unlocked(_service, _instance, + register_availability_handler_unlocked(_service, get_instance_from_unique(_unique), its_handler_ext, _major, _minor); } void application_impl::register_availability_handler(service_t _service, - instance_t _instance, const availability_state_handler_t &_handler, + unique_version_t _unique, const availability_state_handler_t &_handler, major_version_t _major, minor_version_t _minor) { std::lock_guard availability_lock(availability_mutex_); - register_availability_handler_unlocked(_service, _instance, + register_availability_handler_unlocked(_service, get_instance_from_unique(_unique), _handler, _major, _minor); } @@ -1070,7 +1070,7 @@ void application_impl::unregister_availability_handler(service_t _service, } void application_impl::on_subscription( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, client_t _client, const vsomeip_sec_client_t *_sec_client, const std::string &_env, bool _subscribed, const std::function &_accepted_cb) { @@ -1081,7 +1081,7 @@ void application_impl::on_subscription( std::lock_guard its_lock(subscription_mutex_); auto found_service = subscription_.find(_service); if (found_service != subscription_.end()) { - auto found_instance = found_service->second.find(_instance); + auto found_instance = found_service->second.find(_unique); if (found_instance != found_service->second.end()) { auto found_eventgroup = found_instance->second.find(_eventgroup); if (found_eventgroup != found_instance->second.end()) { @@ -1106,7 +1106,7 @@ void application_impl::on_subscription( } void application_impl::register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, const subscription_handler_t &_handler) { subscription_handler_ext_t its_handler_ext @@ -1117,12 +1117,12 @@ void application_impl::register_subscription_handler(service_t _service, return _handler(_client, _uid, _gid, _is_subscribed); }; - register_subscription_handler(_service, _instance, _eventgroup, + register_subscription_handler(_service, _unique, _eventgroup, its_handler_ext); } void application_impl::register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, const subscription_handler_ext_t &_handler) { subscription_handler_sec_t its_handler_sec = [_handler]( @@ -1143,24 +1143,24 @@ void application_impl::register_subscription_handler(service_t _service, ); }; - register_subscription_handler(_service, _instance, _eventgroup, its_handler_sec); + register_subscription_handler(_service, _unique, _eventgroup, its_handler_sec); } void application_impl::register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, const subscription_handler_sec_t &_handler) { std::lock_guard its_lock(subscription_mutex_); - subscription_[_service][_instance][_eventgroup] = std::make_pair(_handler, nullptr); + subscription_[_service][_unique][_eventgroup] = std::make_pair(_handler, nullptr); } void application_impl::unregister_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) { + unique_version_t _unique, eventgroup_t _eventgroup) { std::lock_guard its_lock(subscription_mutex_); auto found_service = subscription_.find(_service); if (found_service != subscription_.end()) { - auto found_instance = found_service->second.find(_instance); + auto found_instance = found_service->second.find(_unique); if (found_instance != found_service->second.end()) { auto found_eventgroup = found_instance->second.find(_eventgroup); if (found_eventgroup != found_instance->second.end()) { @@ -1171,7 +1171,7 @@ void application_impl::unregister_subscription_handler(service_t _service, } void application_impl::on_subscription_status( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, uint16_t _error) { bool entry_found(false); @@ -1182,7 +1182,7 @@ void application_impl::on_subscription_status( its_service = subscriptions_state_.find(ANY_SERVICE); } if (its_service != subscriptions_state_.end()) { - auto its_instance = its_service->second.find(_instance); + auto its_instance = its_service->second.find(_unique); if (its_instance == its_service->second.end()) { its_instance = its_service->second.find(ANY_INSTANCE); } @@ -1214,11 +1214,11 @@ void application_impl::on_subscription_status( } } if (entry_found) { - deliver_subscription_state(_service, _instance, _eventgroup, _event, _error); + deliver_subscription_state(_service, _unique, _eventgroup, _event, _error); } } -void application_impl::deliver_subscription_state(service_t _service, instance_t _instance, +void application_impl::deliver_subscription_state(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, uint16_t _error) { std::vector handlers; @@ -1226,7 +1226,7 @@ void application_impl::deliver_subscription_state(service_t _service, instance_t std::lock_guard its_lock(subscription_status_handlers_mutex_); auto found_service = subscription_status_handlers_.find(_service); if (found_service != subscription_status_handlers_.end()) { - auto found_instance = found_service->second.find(_instance); + auto found_instance = found_service->second.find(_unique); if (found_instance != found_service->second.end()) { auto found_eventgroup = found_instance->second.find(_eventgroup); if (found_eventgroup != found_instance->second.end()) { @@ -1295,7 +1295,7 @@ void application_impl::deliver_subscription_state(service_t _service, instance_t } found_service = subscription_status_handlers_.find(ANY_SERVICE); if (found_service != subscription_status_handlers_.end()) { - auto found_instance = found_service->second.find(_instance); + auto found_instance = found_service->second.find(_unique); if (found_instance != found_service->second.end()) { auto found_eventgroup = found_instance->second.find(_eventgroup); if (found_eventgroup != found_instance->second.end()) { @@ -1367,14 +1367,14 @@ void application_impl::deliver_subscription_state(service_t _service, instance_t std::unique_lock handlers_lock(handlers_mutex_); for (auto &handler : handlers) { auto its_sync_handler = std::make_shared([handler, _service, - _instance, _eventgroup, + _unique, _eventgroup, _event, _error]() { - handler(_service, _instance, + handler(_service, get_instance_from_unique(_unique), _eventgroup, _event, _error); }); its_sync_handler->handler_type_ = handler_type_e::SUBSCRIPTION; its_sync_handler->service_id_ = _service; - its_sync_handler->instance_id_ = _instance; + its_sync_handler->instance_id_ = get_instance_from_unique(_unique); its_sync_handler->method_id_ = _event; its_sync_handler->eventgroup_id_ = _eventgroup; handlers_.push_back(its_sync_handler); @@ -1386,11 +1386,11 @@ void application_impl::deliver_subscription_state(service_t _service, instance_t } void application_impl::register_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, subscription_status_handler_t _handler, bool _is_selective) { std::lock_guard its_lock(subscription_status_handlers_mutex_); if (_handler) { - subscription_status_handlers_[_service][_instance][_eventgroup][_event] = + subscription_status_handlers_[_service][_unique][_eventgroup][_event] = std::make_pair(_handler, _is_selective); } else { VSOMEIP_WARNING << @@ -1399,18 +1399,18 @@ void application_impl::register_subscription_status_handler(service_t _service, "application_impl::unregister_subscription_status_handler [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "." << std::setw(4) << _event << "]"; } } void application_impl::unregister_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event) { + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { std::lock_guard its_lock(subscription_status_handlers_mutex_); auto its_service = subscription_status_handlers_.find(_service); if (its_service != subscription_status_handlers_.end()) { - auto its_instance = its_service->second.find(_instance); + auto its_instance = its_service->second.find(_unique); if (its_instance != its_service->second.end()) { auto its_eventgroup = its_instance->second.find(_eventgroup); if (its_eventgroup != its_instance->second.end()) { @@ -1418,7 +1418,7 @@ void application_impl::unregister_subscription_status_handler(service_t _service if (its_eventgroup->second.empty()) { its_instance->second.erase(_eventgroup); if (its_instance->second.empty()) { - its_service->second.erase(_instance); + its_service->second.erase(_unique); if (its_service->second.empty()) { subscription_status_handlers_.erase(_service); } @@ -1430,19 +1430,19 @@ void application_impl::unregister_subscription_status_handler(service_t _service } void application_impl::register_message_handler(service_t _service, - instance_t _instance, method_t _method, const message_handler_t &_handler) { + unique_version_t _unique, method_t _method, const message_handler_t &_handler) { - register_message_handler_ext(_service, _instance, _method, _handler, + register_message_handler_ext(_service, get_instance_from_unique(_unique), _method, _handler, handler_registration_type_e::HRT_REPLACE); } void application_impl::unregister_message_handler(service_t _service, - instance_t _instance, method_t _method) { + unique_version_t _unique, method_t _method) { std::lock_guard its_lock(members_mutex_); - members_.erase(to_members_key(_service, _instance, _method)); + members_.erase(to_members_key(_service, get_instance_from_unique(_unique), _method)); } -void application_impl::offer_event(service_t _service, instance_t _instance, +void application_impl::offer_event(service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, event_type_e _type, std::chrono::milliseconds _cycle, bool _change_resets_cycle, @@ -1456,48 +1456,48 @@ void application_impl::offer_event(service_t _service, instance_t _instance, && _update_on_change == true) { configuration_->get_event_update_properties( - _service, _instance, _notifier, + _service, get_instance_from_unique(_unique), _notifier, _cycle, _change_resets_cycle, _update_on_change); VSOMEIP_INFO << __func__ << std::hex << std::setfill('0') << ": Event [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _notifier << "] uses configured cycle time " << std::dec << _cycle.count() << "ms"; } routing_->register_event(client_, - _service, _instance, + _service, _unique, _notifier, _eventgroups, _type, _reliability, _cycle, _change_resets_cycle, _update_on_change, _epsilon_change_func, true); } } -void application_impl::stop_offer_event(service_t _service, instance_t _instance, +void application_impl::stop_offer_event(service_t _service, unique_version_t _unique, event_t _event) { if (routing_) - routing_->unregister_event(client_, _service, _instance, _event, true); + routing_->unregister_event(client_, _service, _unique, _event, true); } -void application_impl::request_event(service_t _service, instance_t _instance, +void application_impl::request_event(service_t _service, unique_version_t _unique, event_t _event, const std::set &_eventgroups, event_type_e _type, reliability_type_e _reliability) { if (routing_) routing_->register_event(client_, - _service, _instance, + _service, _unique, _event, _eventgroups, _type, _reliability, std::chrono::milliseconds::zero(), false, true, nullptr, false); } -void application_impl::release_event(service_t _service, instance_t _instance, +void application_impl::release_event(service_t _service, unique_version_t _unique, event_t _event) { if (routing_) - routing_->unregister_event(client_, _service, _instance, _event, false); + routing_->unregister_event(client_, _service, _unique, _event, false); } // Interface "routing_manager_host" @@ -2321,15 +2321,15 @@ bool application_impl::is_routing() const { } void application_impl::send_back_cached_event(service_t _service, - instance_t _instance, + unique_version_t _unique, event_t _event) { std::shared_ptr its_event = routing_->find_event(_service, - _instance, _event); + _unique, _event); if (its_event && its_event->is_field() && its_event->is_set()) { std::shared_ptr its_message = runtime_->create_notification(); its_message->set_service(_service); its_message->set_method(_event); - its_message->set_instance(_instance); + its_message->set_instance(get_instance_from_unique(_unique)); its_message->set_payload(its_event->get_payload()); its_message->set_initial(true); on_message(std::move(its_message)); @@ -2337,15 +2337,15 @@ void application_impl::send_back_cached_event(service_t _service, << std::hex << std::setfill('0') << std::setw(4) << client_ << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _event << "]"; } } void application_impl::send_back_cached_eventgroup(service_t _service, - instance_t _instance, + unique_version_t _unique, eventgroup_t _eventgroup) { - std::set> its_events = routing_->find_events(_service, _instance, + std::set> its_events = routing_->find_events(_service, _unique, _eventgroup); for(const auto &its_event : its_events) { if (its_event && its_event->is_field() && its_event->is_set()) { @@ -2353,7 +2353,7 @@ void application_impl::send_back_cached_eventgroup(service_t _service, const event_t its_event_id(its_event->get_event()); its_message->set_service(_service); its_message->set_method(its_event_id); - its_message->set_instance(_instance); + its_message->set_instance(get_instance_from_unique(_unique)); its_message->set_payload(its_event->get_payload()); its_message->set_initial(true); on_message(std::move(its_message)); @@ -2361,7 +2361,7 @@ void application_impl::send_back_cached_eventgroup(service_t _service, << std::hex << std::setfill('0') << std::setw(4) << client_ << "): [" << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << its_event_id << "] from eventgroup " << std::setw(4) << _eventgroup; @@ -2375,7 +2375,7 @@ void application_impl::set_routing_state(routing_state_e _routing_state) { } void application_impl::check_send_back_cached_event( - service_t _service, instance_t _instance, event_t _event, + service_t _service, unique_version_t _unique, event_t _event, eventgroup_t _eventgroup, bool *_send_back_cached_event, bool *_send_back_cached_eventgroup) { std::lock_guard its_lock(subscriptions_mutex_); @@ -2384,7 +2384,7 @@ void application_impl::check_send_back_cached_event( bool already_subscribed(false); auto found_service = subscriptions_.find(_service); if(found_service != subscriptions_.end()) { - auto found_instance = found_service->second.find(_instance); + auto found_instance = found_service->second.find(_unique); if (found_instance != found_service->second.end()) { auto found_event = found_instance->second.find(_event); if (found_event != found_instance->second.end()) { @@ -2406,12 +2406,12 @@ void application_impl::check_send_back_cached_event( } if (!already_subscribed) { - subscriptions_[_service][_instance][_event][_eventgroup] = false; + subscriptions_[_service][_unique][_event][_eventgroup] = false; } } void application_impl::remove_subscription(service_t _service, - instance_t _instance, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { @@ -2419,7 +2419,7 @@ void application_impl::remove_subscription(service_t _service, std::lock_guard its_lock(subscriptions_state_mutex_); auto its_service = subscriptions_state_.find(_service); if (its_service != subscriptions_state_.end()) { - auto its_instance = its_service->second.find(_instance); + auto its_instance = its_service->second.find(_unique); if (its_instance != its_service->second.end()) { if (_event == ANY_EVENT) { its_instance->second.erase(_eventgroup); @@ -2444,7 +2444,7 @@ void application_impl::remove_subscription(service_t _service, auto found_service = subscriptions_.find(_service); if(found_service != subscriptions_.end()) { - auto found_instance = found_service->second.find(_instance); + auto found_instance = found_service->second.find(_unique); if (found_instance != found_service->second.end()) { auto found_event = found_instance->second.find(_event); if (found_event != found_instance->second.end()) { @@ -2452,7 +2452,7 @@ void application_impl::remove_subscription(service_t _service, if (!found_event->second.size()) { found_instance->second.erase(_event); if (!found_instance->second.size()) { - found_service->second.erase(_instance); + found_service->second.erase(_unique); if (!found_service->second.size()) { subscriptions_.erase(_service); } @@ -2465,12 +2465,12 @@ void application_impl::remove_subscription(service_t _service, } bool application_impl::check_for_active_subscription(service_t _service, - instance_t _instance, + unique_version_t _unique, event_t _event) { std::lock_guard its_lock(subscriptions_mutex_); auto found_service = subscriptions_.find(_service); if(found_service != subscriptions_.end()) { - auto found_instance = found_service->second.find(_instance); + auto found_instance = found_service->second.find(_unique); if (found_instance != found_service->second.end()) { auto found_event = found_instance->second.find(_event); if (found_event != found_instance->second.end()) { @@ -2488,7 +2488,7 @@ bool application_impl::check_for_active_subscription(service_t _service, if (found_any_event != found_instance->second.end()) { if (routing_) { std::shared_ptr its_event = routing_->find_event( - _service, _instance, _event); + _service, _unique, _event); if (its_event) { for (const auto eg : its_event->get_eventgroups()) { auto found_eventgroup = found_any_event->second.find(eg); @@ -2514,7 +2514,7 @@ bool application_impl::check_for_active_subscription(service_t _service, return false; } -bool application_impl::check_subscription_state(service_t _service, instance_t _instance, +bool application_impl::check_subscription_state(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) { bool is_acknowledged(false); @@ -2525,7 +2525,7 @@ bool application_impl::check_subscription_state(service_t _service, instance_t _ std::lock_guard its_lock(subscriptions_state_mutex_); auto its_service = subscriptions_state_.find(_service); if (its_service != subscriptions_state_.end()) { - auto its_instance = its_service->second.find(_instance); + auto its_instance = its_service->second.find(_unique); if (its_instance != its_service->second.end()) { auto its_eventgroup = its_instance->second.find(_eventgroup); if (its_eventgroup != its_instance->second.end()) { @@ -2547,14 +2547,14 @@ bool application_impl::check_subscription_state(service_t _service, instance_t _ } if (!has_found) { - subscriptions_state_[_service][_instance][_eventgroup][_event] + subscriptions_state_[_service][_unique][_eventgroup][_event] = subscription_state_e::IS_SUBSCRIBING; } } if (!should_subscribe && is_acknowledged) { // Deliver subscription state only if ACK has already received - deliver_subscription_state(_service, _instance, _eventgroup, _event, 0 /* OK */); + deliver_subscription_state(_service, _unique, _eventgroup, _event, 0 /* OK */); } return should_subscribe; @@ -2617,7 +2617,7 @@ void application_impl::get_offered_services_async(offer_type_e _offer_type, if (!is_routing_manager_host_) { routing_->send_get_offered_services_info(get_client(), _offer_type); } else { - std::vector> its_services; + std::vector> its_services; auto its_routing_manager_host = std::dynamic_pointer_cast(routing_); for (const auto& s : its_routing_manager_host->get_offered_services()) { @@ -2647,7 +2647,7 @@ void application_impl::get_offered_services_async(offer_type_e _offer_type, } -void application_impl::on_offered_services_info(std::vector> &_services) { +void application_impl::on_offered_services_info(std::vector> &_services) { bool has_offered_services_handler(false); offered_services_handler_t handler = nullptr; { @@ -2710,7 +2710,7 @@ void application_impl::set_watchdog_handler(const watchdog_handler_t &_handler, } void application_impl::register_async_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, const async_subscription_handler_t &_handler) { async_subscription_handler_ext_t its_handler_ext @@ -2722,12 +2722,12 @@ void application_impl::register_async_subscription_handler(service_t _service, _handler(_client, _uid, _gid, _is_subscribed, _cb); }; - register_async_subscription_handler(_service, _instance, _eventgroup, + register_async_subscription_handler(_service, _unique, _eventgroup, its_handler_ext); } void application_impl::register_async_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, const async_subscription_handler_ext_t &_handler) { async_subscription_handler_sec_t its_handler_sec = [_handler]( @@ -2750,15 +2750,15 @@ void application_impl::register_async_subscription_handler(service_t _service, ); }; - register_async_subscription_handler(_service, _instance, _eventgroup, its_handler_sec); + register_async_subscription_handler(_service, _unique, _eventgroup, its_handler_sec); } void application_impl::register_async_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, async_subscription_handler_sec_t _handler) { std::lock_guard its_lock(subscription_mutex_); - subscription_[_service][_instance][_eventgroup] = std::make_pair(nullptr, _handler); + subscription_[_service][_unique][_eventgroup] = std::make_pair(nullptr, _handler); } void application_impl::register_sd_acceptance_handler( @@ -2928,7 +2928,7 @@ void application_impl::register_routing_state_handler( } bool application_impl::update_service_configuration(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled, @@ -2943,10 +2943,10 @@ bool application_impl::update_service_configuration(service_t _service, auto rm_impl = std::dynamic_pointer_cast(routing_); if (rm_impl) { if (_offer) { - ret = rm_impl->offer_service_remotely(_service, _instance, + ret = rm_impl->offer_service_remotely(_service, _unique, _port, _reliable, _magic_cookies_enabled); } else { - ret = rm_impl->stop_offer_service_remotely(_service, _instance, + ret = rm_impl->stop_offer_service_remotely(_service, _unique, _port, _reliable, _magic_cookies_enabled); } } @@ -3002,27 +3002,27 @@ void application_impl::remove_security_policy_configuration(uint32_t _uid, #endif // !VSOMEIP_DISABLE_SECURITY } -void application_impl::subscribe_with_debounce(service_t _service, instance_t _instance, +void application_impl::subscribe_with_debounce(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const debounce_filter_t &_filter) { if (routing_) { bool send_back_cached(false); bool send_back_cached_group(false); - check_send_back_cached_event(_service, _instance, _event, _eventgroup, + check_send_back_cached_event(_service, _unique, _event, _eventgroup, &send_back_cached, &send_back_cached_group); if (send_back_cached) { - send_back_cached_event(_service, _instance, _event); + send_back_cached_event(_service, _unique, _event); } else if(send_back_cached_group) { - send_back_cached_eventgroup(_service, _instance, _eventgroup); + send_back_cached_eventgroup(_service, _unique, _eventgroup); } - if (check_subscription_state(_service, _instance, _eventgroup, _event)) { + if (check_subscription_state(_service, _unique, _eventgroup, _event)) { auto its_filter = std::make_shared(_filter); routing_->subscribe(client_, get_sec_client(), - _service, _instance, _eventgroup, _major, + _service, _unique, _eventgroup, _major, _event, its_filter); } } diff --git a/implementation/service_discovery/include/service_discovery.hpp b/implementation/service_discovery/include/service_discovery.hpp index 34a33f277..82d03f374 100644 --- a/implementation/service_discovery/include/service_discovery.hpp +++ b/implementation/service_discovery/include/service_discovery.hpp @@ -33,17 +33,17 @@ class service_discovery { virtual void start() = 0; virtual void stop() = 0; - virtual void request_service(service_t _service, instance_t _instance, + virtual void request_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, ttl_t _ttl) = 0; - virtual void release_service(service_t _service, instance_t _instance) = 0; + virtual void release_service(service_t _service, unique_version_t _unique) = 0; - virtual void subscribe(service_t _service, instance_t _instance, + virtual void subscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, client_t _client, const std::shared_ptr& _info) = 0; - virtual void unsubscribe(service_t _service, instance_t _instance, + virtual void unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, client_t _client) = 0; - virtual void unsubscribe_all(service_t _service, instance_t _instance) = 0; + virtual void unsubscribe_all(service_t _service, unique_version_t _unique) = 0; virtual void unsubscribe_all_on_suspend() = 0; virtual bool send(bool _is_announcing) = 0; @@ -57,7 +57,7 @@ class service_discovery { const boost::asio::ip::address& _remote_address = boost::asio::ip::address()) = 0; virtual void on_endpoint_connected( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const std::shared_ptr &_endpoint) = 0; virtual void offer_service(const std::shared_ptr &_info) = 0; diff --git a/implementation/service_discovery/include/service_discovery_host.hpp b/implementation/service_discovery/include/service_discovery_host.hpp index 14d2267d8..0fda9bec7 100644 --- a/implementation/service_discovery/include/service_discovery_host.hpp +++ b/implementation/service_discovery/include/service_discovery_host.hpp @@ -38,7 +38,7 @@ class service_discovery_host { virtual services_t get_offered_services() const = 0; virtual std::shared_ptr find_eventgroup(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) const = 0; + unique_version_t _unique, eventgroup_t _eventgroup) const = 0; virtual bool send(client_t _client, std::shared_ptr _message, bool _force) = 0; @@ -53,7 +53,7 @@ class service_discovery_host { const boost::asio::ip::address &_unreliable_address, uint16_t _unreliable_port) = 0; - virtual void del_routing_info(service_t _service, instance_t _instance, + virtual void del_routing_info(service_t _service, unique_version_t _unique, bool _has_reliable, bool _has_unreliable) = 0; virtual void update_routing_info(std::chrono::milliseconds _elapsed) = 0; @@ -62,16 +62,16 @@ class service_discovery_host { std::shared_ptr &_subscription) = 0; virtual void on_subscribe_ack(client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, remote_subscription_id_t _subscription_id) = 0; virtual void on_subscribe_ack_with_multicast( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const boost::asio::ip::address &_sender, const boost::asio::ip::address &_address, uint16_t _port) = 0; virtual std::shared_ptr find_or_create_remote_client( - service_t _service, instance_t _instance, bool _reliable) = 0; + service_t _service, unique_version_t _unique, bool _reliable) = 0; virtual void expire_subscriptions(const boost::asio::ip::address &_address) = 0; virtual void expire_subscriptions(const boost::asio::ip::address &_address, @@ -86,18 +86,18 @@ class service_discovery_host { const remote_subscription_callback_t& _callback) = 0; virtual void on_subscribe_nack(client_t _client, - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, bool _remove, remote_subscription_id_t _subscription_id) = 0; virtual std::chrono::steady_clock::time_point expire_subscriptions(bool _force) = 0; virtual std::shared_ptr get_offered_service( - service_t _service, instance_t _instance) const = 0; - virtual std::map> get_offered_service_instances( + service_t _service, unique_version_t _unique) const = 0; + virtual std::map> get_offered_service_instances( service_t _service) const = 0; virtual std::set get_subscribed_eventgroups(service_t _service, - instance_t _instance) = 0; + unique_version_t _unique) = 0; }; } // namespace sd diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp index d07fcb1f7..e5b229c74 100644 --- a/implementation/service_discovery/include/service_discovery_impl.hpp +++ b/implementation/service_discovery/include/service_discovery_impl.hpp @@ -45,7 +45,7 @@ class service_discovery_host; class subscription; typedef std::map > > requests_t; @@ -70,18 +70,18 @@ class service_discovery_impl: public service_discovery, void start(); void stop(); - void request_service(service_t _service, instance_t _instance, + void request_service(service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, ttl_t _ttl); - void release_service(service_t _service, instance_t _instance); + void release_service(service_t _service, unique_version_t _unique); - void subscribe(service_t _service, instance_t _instance, + void subscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, client_t _client, const std::shared_ptr& _info); - void unsubscribe(service_t _service, instance_t _instance, + void unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, client_t _client); - void unsubscribe_all(service_t _service, instance_t _instance); + void unsubscribe_all(service_t _service, unique_version_t _unique); void unsubscribe_all_on_suspend(); - void remove_subscriptions(service_t _service, instance_t _instance); + void remove_subscriptions(service_t _service, unique_version_t _unique); bool send(bool _is_announcing); @@ -93,7 +93,7 @@ class service_discovery_impl: public service_discovery, const boost::asio::ip::address& _remote_address = boost::asio::ip::address()); void on_endpoint_connected( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const std::shared_ptr &_endpoint); void offer_service(const std::shared_ptr &_info); @@ -162,18 +162,18 @@ class service_discovery_impl: public service_discovery, void check_sent_offers(const message_impl::entries_t& _entries, const boost::asio::ip::address& _remote_address) const; void process_offerservice_serviceentry( - service_t _service, instance_t _instance, major_version_t _major, + service_t _service, unique_version_t _unique, 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, std::vector>& _resubscribes, bool _received_via_multicast, const sd_acceptance_state_t& _sd_ac_state); void send_offer_service( const std::shared_ptr &_info, service_t _service, - instance_t _instance, major_version_t _major, minor_version_t _minor, + unique_version_t _unique, major_version_t _major, minor_version_t _minor, bool _unicast_flag); void process_findservice_serviceentry(service_t _service, - instance_t _instance, + unique_version_t _unique, major_version_t _major, minor_version_t _minor, bool _unicast_flag); @@ -186,7 +186,7 @@ class service_discovery_impl: public service_discovery, bool _is_stop_subscribe_subscribe, bool _force_initial_events, const sd_acceptance_state_t& _sd_ac_state); void handle_eventgroup_subscription( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, uint8_t _counter, uint16_t _reserved, const boost::asio::ip::address& _first_address, uint16_t _first_port, bool _is_first_reliable, const boost::asio::ip::address& _second_address, @@ -196,13 +196,13 @@ class service_discovery_impl: public service_discovery, const std::set& _clients, const sd_acceptance_state_t& _sd_ac_state, const std::shared_ptr& _info, const boost::asio::ip::address& _sender); void handle_eventgroup_subscription_ack(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, uint8_t _counter, const std::set &_clients, const boost::asio::ip::address &_sender, const boost::asio::ip::address &_address, uint16_t _port); void handle_eventgroup_subscription_nack(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, uint8_t _counter, + unique_version_t _unique, eventgroup_t _eventgroup, uint8_t _counter, const std::set &_clients); bool send(const std::vector> &_messages); @@ -214,7 +214,7 @@ class service_discovery_impl: public service_discovery, const std::shared_ptr &_acknowledgement); bool is_tcp_connected(service_t _service, - instance_t _instance, + unique_version_t _unique, const std::shared_ptr& its_endpoint); void start_ttl_timer(int _shift = 0); @@ -235,14 +235,14 @@ class service_discovery_impl: public service_discovery, bool check_layer_four_protocol( const std::shared_ptr& _ip_option) const; - void get_subscription_endpoints(service_t _service, instance_t _instance, + void get_subscription_endpoints(service_t _service, unique_version_t _unique, std::shared_ptr& _reliable, std::shared_ptr& _unreliable) const; void get_subscription_address(const std::shared_ptr &_reliable, const std::shared_ptr &_unreliable, boost::asio::ip::address &_address) const; - void update_request(service_t _service, instance_t _instance); + void update_request(service_t _service, unique_version_t _unique); void start_offer_debounce_timer(bool _first_start); void on_offer_debounce_timer_expired(const boost::system::error_code &_error); @@ -285,7 +285,7 @@ class service_discovery_impl: public service_discovery, const std::vector > &_messages); void remote_subscription_acknowledge( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, const std::shared_ptr &_subscription); bool check_stop_subscribe_subscribe( @@ -308,23 +308,23 @@ class service_discovery_impl: public service_discovery, const message_impl::options_t &_options) const; configuration::ttl_factor_t get_ttl_factor( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const configuration::ttl_map_t& _ttl_map) const; void on_last_msg_received_timer_expired(const boost::system::error_code &_error); void stop_last_msg_received_timer(); reliability_type_e get_remote_offer_type( - service_t _service, instance_t _instance) const; + service_t _service, unique_version_t _unique) const; reliability_type_e get_remote_offer_type( const std::shared_ptr &_subscription) const; - bool update_remote_offer_type(service_t _service, instance_t _instance, + bool update_remote_offer_type(service_t _service, unique_version_t _unique, reliability_type_e _offer_type, const boost::asio::ip::address& _reliable_address, std::uint16_t _reliable_port, const boost::asio::ip::address& _unreliable_address, std::uint16_t _unreliable_port, bool _received_via_multicast); - void remove_remote_offer_type(service_t _service, instance_t _instance, + void remove_remote_offer_type(service_t _service, unique_version_t _unique, const boost::asio::ip::address &_reliable_address, std::uint16_t _reliable_port, const boost::asio::ip::address &_unreliable_address, @@ -334,7 +334,7 @@ class service_discovery_impl: public service_discovery, std::uint16_t _port, bool _reliable); // Returns true if the state changes from unicast -> multicast, false any of the other 3 cases - bool set_offer_multicast_state(service_t _service, instance_t _instance, + bool set_offer_multicast_state(service_t _service, unique_version_t _unique, reliability_type_e _offer_type, const boost::asio::ip::address& _reliable_address, port_t _reliable_port, @@ -348,7 +348,7 @@ class service_discovery_impl: public service_discovery, const std::shared_ptr& _info) const; std::shared_ptr get_remote_subscription( - const service_t _service, const instance_t _instance, + const service_t _service, const unique_version_t _unique, const eventgroup_t _eventgroup); void send_subscription_ack( @@ -359,7 +359,7 @@ class service_discovery_impl: public service_discovery, bool _is_reliable) const; void send_subscription(const std::shared_ptr &_subscription, - const service_t _service, const instance_t _instance, + const service_t _service, const unique_version_t _unique, const eventgroup_t _eventgroup, const client_t _client); void add_entry_data(std::vector> &_messages, @@ -369,7 +369,7 @@ class service_discovery_impl: public service_discovery, const std::shared_ptr& _acknowledgement, const entry_data_t &_data); reliability_type_e get_eventgroup_reliability( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, const std::shared_ptr& _subscription); void deserialize_data(const byte_t* _data, const length_t& _size, std::shared_ptr& _message); @@ -390,7 +390,7 @@ class service_discovery_impl: public service_discovery, requests_t requested_; std::mutex requested_mutex_; std::map > @@ -477,10 +477,10 @@ class service_discovery_impl: public service_discovery, std::chrono::milliseconds last_msg_received_timer_timeout_; mutable std::mutex remote_offer_types_mutex_; - std::map, reliability_type_e> remote_offer_types_; + std::map, reliability_type_e> remote_offer_types_; struct remote_offer_info_t { - std::pair service_info; + std::pair service_info; // The goal of this flag is to handle the SOMEIPSD_00577 requirement // To do so we will keep track of the last received offer for a given service+instance pair @@ -489,9 +489,9 @@ class service_discovery_impl: public service_discovery, // It shall be mutable to allow the value to be updated within a std::set mutable bool offer_received_via_multicast; - remote_offer_info_t(service_t _service, instance_t _instance, + remote_offer_info_t(service_t _service, unique_version_t _unique, bool _received_via_multicast = true) : - service_info(std::make_pair(_service, _instance)), + service_info(std::make_pair(_service, _unique)), offer_received_via_multicast(_received_via_multicast) { } // Use the service_info pair as the key for unique values within a std::set diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index 3d7642908..ba73e1c02 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -213,41 +213,41 @@ service_discovery_impl::stop() { void service_discovery_impl::request_service( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, ttl_t _ttl) { std::lock_guard its_lock(requested_mutex_); auto find_service = requested_.find(_service); if (find_service != requested_.end()) { - auto find_instance = find_service->second.find(_instance); - if (find_instance == find_service->second.end()) { - find_service->second[_instance] + auto find_unique = find_service->second.find(_unique); + if (find_unique == find_service->second.end()) { + find_service->second[_unique] = std::make_shared(_major, _minor, _ttl); } } else { - requested_[_service][_instance] + requested_[_service][_unique] = std::make_shared(_major, _minor, _ttl); } } void service_discovery_impl::release_service( - service_t _service, instance_t _instance) { + service_t _service, unique_version_t _unique) { std::lock_guard its_lock(requested_mutex_); auto find_service = requested_.find(_service); if (find_service != requested_.end()) { - find_service->second.erase(_instance); + find_service->second.erase(_unique); } } void -service_discovery_impl::update_request(service_t _service, instance_t _instance) { +service_discovery_impl::update_request(service_t _service, unique_version_t _unique) { std::lock_guard its_lock(requested_mutex_); auto find_service = requested_.find(_service); if (find_service != requested_.end()) { - auto find_instance = find_service->second.find(_instance); - if (find_instance != find_service->second.end()) { - find_instance->second->set_sent_counter( + auto find_unique = find_service->second.find(_unique); + if (find_unique != find_service->second.end()) { + find_unique->second->set_sent_counter( std::uint8_t(repetitions_max_ + 1)); } } @@ -260,7 +260,7 @@ service_discovery_impl::get_subscribed_mutex() { void service_discovery_impl::subscribe( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, client_t _client, const std::shared_ptr &_info) { @@ -278,10 +278,10 @@ service_discovery_impl::subscribe( std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_eventgroup = found_instance->second.find(_eventgroup); - if (found_eventgroup != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_eventgroup = found_unique->second.find(_eventgroup); + if (found_eventgroup != found_unique->second.end()) { auto its_subscription = found_eventgroup->second; #ifdef VSOMEIP_ENABLE_COMPAT if (!its_subscription->is_selective() && is_selective) { @@ -303,7 +303,7 @@ service_discovery_impl::subscribe( its_subscription->set_state(_client, subscription_state_e::ST_NOT_ACKNOWLEDGED); send_subscription(its_subscription, - _service, _instance, _eventgroup, + _service, _unique, _eventgroup, _client); } } @@ -313,7 +313,7 @@ service_discovery_impl::subscribe( } std::shared_ptr its_reliable, its_unreliable; - get_subscription_endpoints(_service, _instance, + get_subscription_endpoints(_service, _unique, its_reliable, its_unreliable); // New subscription @@ -327,21 +327,21 @@ service_discovery_impl::subscribe( return; } - subscribed_[_service][_instance][_eventgroup] = its_subscription; + subscribed_[_service][_unique][_eventgroup] = its_subscription; its_subscription->add_client(_client); its_subscription->set_state(_client, subscription_state_e::ST_NOT_ACKNOWLEDGED); send_subscription(its_subscription, - _service, _instance, _eventgroup, + _service, _unique, _eventgroup, _client); } void service_discovery_impl::send_subscription( const std::shared_ptr &_subscription, - const service_t _service, const instance_t _instance, + const service_t _service, const unique_version_t _unique, const eventgroup_t _eventgroup, const client_t _client) { (void)_client; @@ -349,22 +349,24 @@ service_discovery_impl::send_subscription( auto its_reliable = _subscription->get_endpoint(true); auto its_unreliable = _subscription->get_endpoint(false); + instance_t its_instance = get_instance_from_unique(_unique); + boost::asio::ip::address its_address; get_subscription_address(its_reliable, its_unreliable, its_address); if (!its_address.is_unspecified()) { entry_data_t its_data; const reliability_type_e its_reliability_type = - get_eventgroup_reliability(_service, _instance, _eventgroup, _subscription); + get_eventgroup_reliability(_service, _unique, _eventgroup, _subscription); if (its_reliability_type == reliability_type_e::RT_UNRELIABLE && its_unreliable) { if (its_unreliable->is_established()) { - its_data = create_eventgroup_entry(_service, _instance, + its_data = create_eventgroup_entry(_service, its_instance, _eventgroup, _subscription, its_reliability_type); } else { _subscription->set_udp_connection_established(false); } } else if (its_reliability_type == reliability_type_e::RT_RELIABLE && its_reliable) { if (its_reliable->is_established()) { - its_data = create_eventgroup_entry(_service, _instance, + its_data = create_eventgroup_entry(_service, its_instance, _eventgroup, _subscription, its_reliability_type); } else { _subscription->set_tcp_connection_established(false); @@ -372,7 +374,7 @@ service_discovery_impl::send_subscription( } else if (its_reliability_type == reliability_type_e::RT_BOTH && its_reliable && its_unreliable) { if (its_reliable->is_established() && its_unreliable->is_established()) { - its_data = create_eventgroup_entry(_service, _instance, + its_data = create_eventgroup_entry(_service, its_instance, _eventgroup, _subscription, its_reliability_type); } else { if (!its_reliable->is_established()) { @@ -386,7 +388,7 @@ service_discovery_impl::send_subscription( VSOMEIP_WARNING << "sd::" << __func__ << ": couldn't determine reliability type for subscription to [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << its_instance << "." << std::setw(4) << _eventgroup << "] "; } @@ -405,13 +407,13 @@ service_discovery_impl::send_subscription( void service_discovery_impl::get_subscription_endpoints( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, std::shared_ptr &_reliable, std::shared_ptr &_unreliable) const { _unreliable = host_->find_or_create_remote_client( - _service, _instance, false); + _service, _unique, false); _reliable = host_->find_or_create_remote_client( - _service, _instance, true); + _service, _unique, true); } void @@ -438,7 +440,7 @@ service_discovery_impl::get_subscription_address( void service_discovery_impl::unsubscribe(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, client_t _client) { + unique_version_t _unique, eventgroup_t _eventgroup, client_t _client) { std::shared_ptr < runtime > its_runtime = runtime_.lock(); if (!its_runtime) { return; @@ -451,10 +453,10 @@ service_discovery_impl::unsubscribe(service_t _service, std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_eventgroup = found_instance->second.find(_eventgroup); - if (found_eventgroup != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_eventgroup = found_unique->second.find(_eventgroup); + if (found_eventgroup != found_unique->second.end()) { auto its_subscription = found_eventgroup->second; if (its_subscription->remove_client(_client)) { auto its_reliable = its_subscription->get_endpoint(true); @@ -483,8 +485,8 @@ service_discovery_impl::unsubscribe(service_t _service, its_subscription->add_client(_client); const reliability_type_e its_reliability_type = - get_eventgroup_reliability(_service, _instance, _eventgroup, its_subscription); - auto its_data = create_eventgroup_entry(_service, _instance, + get_eventgroup_reliability(_service, _unique, _eventgroup, its_subscription); + auto its_data = create_eventgroup_entry(_service, get_instance_from_unique(_unique), _eventgroup, its_subscription, its_reliability_type); if (its_data.entry_) its_current_message->add_entry_data(its_data.entry_, its_data.options_); @@ -498,9 +500,9 @@ service_discovery_impl::unsubscribe(service_t _service, // Finally update the subscriptions if (!its_subscription->has_client()) { - found_instance->second.erase(found_eventgroup); - if (found_instance->second.size() == 0) { - found_service->second.erase(found_instance); + found_unique->second.erase(found_eventgroup); + if (found_unique->second.size() == 0) { + found_service->second.erase(found_unique); } } } @@ -516,7 +518,7 @@ service_discovery_impl::unsubscribe(service_t _service, void service_discovery_impl::unsubscribe_all( - service_t _service, instance_t _instance) { + service_t _service, unique_version_t _unique) { auto its_current_message = std::make_shared(); boost::asio::ip::address its_address; @@ -525,17 +527,17 @@ service_discovery_impl::unsubscribe_all( std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - for (auto &its_eventgroup : found_instance->second) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + for (auto &its_eventgroup : found_unique->second) { auto its_subscription = its_eventgroup.second; its_subscription->set_ttl(0); const reliability_type_e its_reliability = - get_eventgroup_reliability(_service, _instance, + get_eventgroup_reliability(_service, _unique, its_eventgroup.first, its_subscription); - auto its_data = create_eventgroup_entry(_service, _instance, + auto its_data = create_eventgroup_entry(_service, get_instance_from_unique(_unique), its_eventgroup.first, its_subscription, its_reliability); auto its_reliable = its_subscription->get_endpoint(true); auto its_unreliable = its_subscription->get_endpoint(false); @@ -545,7 +547,7 @@ service_discovery_impl::unsubscribe_all( its_current_message->add_entry_data(its_data.entry_, its_data.options_); } } - found_instance->second.clear(); + found_unique->second.clear(); } } } @@ -566,16 +568,16 @@ service_discovery_impl::unsubscribe_all_on_suspend() { { std::lock_guard its_lock(subscribed_mutex_); for (auto its_service : subscribed_) { - for (auto its_instance : its_service.second) { - for (auto &its_eventgroup : its_instance.second) { + for (auto its_unique : its_service.second) { + for (auto &its_eventgroup : its_unique.second) { boost::asio::ip::address its_address; auto its_current_message = std::make_shared(); auto its_subscription = its_eventgroup.second; its_subscription->set_ttl(0); const reliability_type_e its_reliability = - get_eventgroup_reliability(its_service.first, its_instance.first, + get_eventgroup_reliability(its_service.first, its_unique.first, its_eventgroup.first, its_subscription); - auto its_data = create_eventgroup_entry(its_service.first, its_instance.first, + auto its_data = create_eventgroup_entry(its_service.first, get_instance_from_unique(its_unique.first), its_eventgroup.first, its_subscription, its_reliability); auto its_reliable = its_subscription->get_endpoint(true); auto its_unreliable = its_subscription->get_endpoint(false); @@ -588,12 +590,12 @@ service_discovery_impl::unsubscribe_all_on_suspend() { VSOMEIP_WARNING << __func__ << ": Failed to create StopSubscribe entry for: " << std::hex << std::setfill('0') << std::setw(4) << its_service.first << "." - << std::setw(4) << its_instance.first << "." + << std::setw(4) << get_instance_from_unique(its_unique.first) << "." << std::setw(4) << its_eventgroup.first << " address: " << its_address.to_string(); } } - its_instance.second.clear(); + its_unique.second.clear(); } its_service.second.clear(); } @@ -610,12 +612,12 @@ service_discovery_impl::unsubscribe_all_on_suspend() { void service_discovery_impl::remove_subscriptions( - service_t _service, instance_t _instance) { + service_t _service, unique_version_t _unique) { std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { - found_service->second.erase(_instance); + found_service->second.erase(_unique); if (found_service->second.empty()) { subscribed_.erase(found_service); } @@ -750,22 +752,22 @@ service_discovery_impl::insert_find_entries( its_data.entry_ = its_data.other_ = nullptr; for (const auto& its_service : _requests) { - for (const auto& its_instance : its_service.second) { + for (const auto& its_unique : its_service.second) { std::lock_guard its_lock(requested_mutex_); - auto its_request = its_instance.second; + auto its_request = its_unique.second; // check if release_service was called / offer was received auto the_service = requested_.find(its_service.first); if ( the_service != requested_.end() ) { - auto the_instance = the_service->second.find(its_instance.first); - if(the_instance != the_service->second.end() ) { + auto the_unique = the_service->second.find(its_unique.first); + if(the_unique != the_service->second.end() ) { uint8_t its_sent_counter = its_request->get_sent_counter(); if (its_sent_counter != repetitions_max_ + 1) { auto its_entry = std::make_shared(); if (its_entry) { its_entry->set_type(entry_type_e::FIND_SERVICE); its_entry->set_service(its_service.first); - its_entry->set_instance(its_instance.first); + its_entry->set_instance(get_instance_from_unique(its_unique.first)); its_entry->set_major_version(its_request->get_major()); its_entry->set_minor_version(its_request->get_minor()); its_entry->set_ttl(its_request->get_ttl()); @@ -790,17 +792,17 @@ service_discovery_impl::insert_offer_entries( std::vector > &_messages, const services_t &_services, bool _ignore_phase) { for (const auto& its_service : _services) { - for (const auto& its_instance : its_service.second) { + for (const auto& its_unique : its_service.second) { if ((!is_suspended_) && ((!is_diagnosis_) || (is_diagnosis_ && !configuration_->is_someip(its_service.first, - its_instance.first)))) { + its_unique.first)))) { // Only insert services with configured endpoint(s) - if ((_ignore_phase || its_instance.second->is_in_mainphase()) - && (its_instance.second->get_endpoint(false) - || its_instance.second->get_endpoint(true))) { - insert_offer_service(_messages, its_instance.second); + if ((_ignore_phase || its_unique.second->is_in_mainphase()) + && (its_unique.second->get_endpoint(false) + || its_unique.second->get_endpoint(true))) { + insert_offer_service(_messages, its_unique.second); } } } @@ -1328,9 +1330,12 @@ void service_discovery_impl::check_sent_offers(const message_impl::entries_t& _e if ((*iter)->get_type() == entry_type_e::OFFER_SERVICE && (*iter)->get_ttl() > 0) { auto its_service = (*iter)->get_service(); auto its_instance = (*iter)->get_instance(); + auto its_major = (*iter)->get_major_version(); + + unique_version_t its_unique = get_unique_version(its_instance, its_major); std::shared_ptr its_info = - host_->get_offered_service(its_service, its_instance); + host_->get_offered_service(its_service, its_unique); if (its_info) { if (_remote_address.is_unspecified()) { // enable proccess remote subscription for the services @@ -1361,6 +1366,8 @@ void service_discovery_impl::process_serviceentry( minor_version_t its_minor = _entry->get_minor_version(); ttl_t its_ttl = _entry->get_ttl(); + unique_version_t its_unique = get_unique_version(its_instance, its_major); + // Read address info from options boost::asio::ip::address its_reliable_address; uint16_t its_reliable_port(ILLEGAL_PORT); @@ -1429,11 +1436,11 @@ void service_discovery_impl::process_serviceentry( if (0 < its_ttl) { switch (its_type) { case entry_type_e::FIND_SERVICE: - process_findservice_serviceentry(its_service, its_instance, its_major, its_minor, + process_findservice_serviceentry(its_service, its_unique, its_major, its_minor, _unicast_flag); break; case entry_type_e::OFFER_SERVICE: - process_offerservice_serviceentry(its_service, its_instance, its_major, its_minor, + process_offerservice_serviceentry(its_service, its_unique, its_major, its_minor, its_ttl, its_reliable_address, its_reliable_port, its_unreliable_address, its_unreliable_port, _resubscribes, _received_via_multicast, _sd_ac_state); @@ -1445,14 +1452,14 @@ void service_discovery_impl::process_serviceentry( } else if (its_type != entry_type_e::FIND_SERVICE && (_sd_ac_state.sd_acceptance_required_ || _sd_ac_state.accept_entries_)) { // stop sending find service in repetition phase - update_request(its_service, its_instance); + update_request(its_service, its_unique); - remove_remote_offer_type(its_service, its_instance, + remove_remote_offer_type(its_service, its_unique, its_reliable_address, its_reliable_port, its_unreliable_address, its_unreliable_port); - remove_subscriptions(its_service, its_instance); + remove_subscriptions(its_service, its_unique); if (!is_diagnosis_ && !is_suspended_) { - host_->del_routing_info(its_service, its_instance, + host_->del_routing_info(its_service, its_unique, (its_reliable_port != ILLEGAL_PORT), (its_unreliable_port != ILLEGAL_PORT)); } @@ -1460,7 +1467,7 @@ void service_discovery_impl::process_serviceentry( } void service_discovery_impl::process_offerservice_serviceentry( - service_t _service, instance_t _instance, major_version_t _major, minor_version_t _minor, + service_t _service, unique_version_t _unique, 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, std::vector>& _resubscribes, bool _received_via_multicast, @@ -1469,7 +1476,7 @@ void service_discovery_impl::process_offerservice_serviceentry( if (!its_runtime) return; - bool is_secure = configuration_->is_secure_service(_service, _instance); + bool is_secure = configuration_->is_secure_service(_service, _unique); if (is_secure && ((_reliable_port != ILLEGAL_PORT && !configuration_->is_secure_port(_reliable_address, _reliable_port, true)) @@ -1478,13 +1485,13 @@ void service_discovery_impl::process_offerservice_serviceentry( VSOMEIP_WARNING << __func__ << ": Ignoring offer of [" << std::hex << std::setfill('0') - << std::setw(4) << _service << "." << std::setw(4) << _instance + << std::setw(4) << _service << "." << std::setw(4) << get_instance_from_unique(_unique) << "]"; return; } // stop sending find service in repetition phase - update_request(_service, _instance); + update_request(_service, _unique); const reliability_type_e offer_type = configuration_->get_reliability_type( _reliable_address, _reliable_port, _unreliable_address,_unreliable_port); @@ -1493,7 +1500,7 @@ void service_discovery_impl::process_offerservice_serviceentry( VSOMEIP_WARNING << __func__ << ": Unknown remote offer type [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "]"; + << std::setw(4) << get_instance_from_unique(_unique) << "]"; return; // Unknown remote offer type --> no way to access it! } @@ -1556,17 +1563,17 @@ void service_discovery_impl::process_offerservice_serviceentry( } } - if (update_remote_offer_type(_service, _instance, offer_type, _reliable_address, _reliable_port, + if (update_remote_offer_type(_service, _unique, offer_type, _reliable_address, _reliable_port, _unreliable_address, _unreliable_port, _received_via_multicast)) { VSOMEIP_WARNING << __func__ << ": Remote offer type changed [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "]"; + << std::setw(4) << get_instance_from_unique(_unique) << "]"; // Only update eventgroup reliability type if it was initially unknown - auto its_eventgroups = host_->get_subscribed_eventgroups(_service, _instance); + auto its_eventgroups = host_->get_subscribed_eventgroups(_service, _unique); for (auto eg : its_eventgroups) { auto its_info = host_->find_eventgroup( - _service, _instance, eg); + _service, _unique, eg); if (its_info) { if (its_info->is_reliability_auto_mode()) { if (offer_type != reliability_type_e::RT_UNKNOWN @@ -1574,7 +1581,7 @@ void service_discovery_impl::process_offerservice_serviceentry( VSOMEIP_WARNING << "sd::" << __func__ << ": eventgroup reliability type changed [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << eg << "]" << " using reliability type: " << std::setw(4) << static_cast(offer_type); @@ -1586,20 +1593,20 @@ void service_discovery_impl::process_offerservice_serviceentry( } const bool was_previously_offered_by_unicast = set_offer_multicast_state( - _service, _instance, offer_type, _reliable_address, _reliable_port, _unreliable_address, + _service, _unique, offer_type, _reliable_address, _reliable_port, _unreliable_address, _unreliable_port, _received_via_multicast); // No need to resubscribe for unicast offers if (_received_via_multicast) { auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - if (0 < found_instance->second.size()) { - for (const auto& its_eventgroup : found_instance->second) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + if (0 < found_unique->second.size()) { + for (const auto& its_eventgroup : found_unique->second) { auto its_subscription = its_eventgroup.second; std::shared_ptr its_reliable, its_unreliable; - get_subscription_endpoints(_service, _instance, its_reliable, + get_subscription_endpoints(_service, _unique, its_reliable, its_unreliable); its_subscription->set_endpoint(its_reliable, true); its_subscription->set_endpoint(its_unreliable, false); @@ -1620,10 +1627,10 @@ void service_discovery_impl::process_offerservice_serviceentry( } } const reliability_type_e its_reliability = get_eventgroup_reliability( - _service, _instance, its_eventgroup.first, its_subscription); + _service, _unique, its_eventgroup.first, its_subscription); auto its_data = - create_eventgroup_entry(_service, _instance, its_eventgroup.first, + create_eventgroup_entry(_service, get_instance_from_unique(_unique), its_eventgroup.first, its_subscription, its_reliability); if (its_data.entry_) { add_entry_data(_resubscribes, its_data); @@ -1638,21 +1645,21 @@ void service_discovery_impl::process_offerservice_serviceentry( } } - host_->add_routing_info(_service, _instance, _major, _minor, - _ttl * get_ttl_factor(_service, _instance, ttl_factor_offers_), + host_->add_routing_info(_service, get_instance_from_unique(_unique), _major, _minor, + _ttl * get_ttl_factor(_service, _unique, ttl_factor_offers_), _reliable_address, _reliable_port, _unreliable_address, _unreliable_port); } void service_discovery_impl::process_findservice_serviceentry( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, major_version_t _major, minor_version_t _minor, bool _unicast_flag) { - if (_instance != ANY_INSTANCE) { + if (get_instance_from_unique(_unique) != ANY_INSTANCE) { std::shared_ptr its_info = host_->get_offered_service( - _service, _instance); + _service, _unique); if (its_info) { if (_major == ANY_MAJOR || _major == its_info->get_major()) { if (_minor == 0xFFFFFFFF || _minor <= its_info->get_minor()) { @@ -1663,11 +1670,11 @@ service_discovery_impl::process_findservice_serviceentry( } } } else { - std::map> offered_instances = + std::map> offered_instances = host_->get_offered_service_instances(_service); // send back all available instances - for (const auto &found_instance : offered_instances) { - auto its_info = found_instance.second; + for (const auto &found_unique : offered_instances) { + auto its_info = found_unique.second; if (_major == ANY_MAJOR || _major == its_info->get_major()) { if (_minor == 0xFFFFFFFF || _minor <= its_info->get_minor()) { if (its_info->get_endpoint(false) || its_info->get_endpoint(true)) { @@ -1710,7 +1717,7 @@ service_discovery_impl::send_multicast_offer_service( void service_discovery_impl::on_endpoint_connected( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const std::shared_ptr &_endpoint) { std::shared_ptr its_runtime = runtime_.lock(); if (!its_runtime) { @@ -1735,10 +1742,10 @@ service_discovery_impl::on_endpoint_connected( std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - if (0 < found_instance->second.size()) { - for (const auto &its_eventgroup : found_instance->second) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + if (0 < found_unique->second.size()) { + for (const auto &its_eventgroup : found_unique->second) { std::shared_ptr its_subscription(its_eventgroup.second); if (its_subscription) { if (!its_subscription->is_tcp_connection_established() || @@ -1770,7 +1777,7 @@ service_discovery_impl::on_endpoint_connected( std::shared_ptr its_unreliable; std::shared_ptr its_reliable; - get_subscription_endpoints(_service, _instance, + get_subscription_endpoints(_service, _unique, its_reliable, its_unreliable); get_subscription_address(its_reliable, its_unreliable, its_address); @@ -1781,8 +1788,8 @@ service_discovery_impl::on_endpoint_connected( subscription_state_e::ST_NOT_ACKNOWLEDGED); const reliability_type_e its_reliability_type = - get_eventgroup_reliability(_service, _instance, its_eventgroup.first, its_subscription); - auto its_data = create_eventgroup_entry(_service, _instance, + get_eventgroup_reliability(_service, _unique, its_eventgroup.first, its_subscription); + auto its_data = create_eventgroup_entry(_service, get_instance_from_unique(_unique), its_eventgroup.first, its_subscription, its_reliability_type); if (its_data.entry_) { @@ -1879,8 +1886,11 @@ service_discovery_impl::process_eventgroupentry( major_version_t its_major = _entry->get_major_version(); ttl_t its_ttl = _entry->get_ttl(); + unique_version_t its_unique = get_unique_version(its_instance, its_major); + + auto its_info = host_->find_eventgroup( - its_service, its_instance, its_eventgroup); + its_service, its_unique, its_eventgroup); if (!its_info) { if (entry_type_e::SUBSCRIBE_EVENTGROUP == its_type) { // We received a subscription for a non-existing eventgroup. @@ -1902,7 +1912,7 @@ service_discovery_impl::process_eventgroupentry( } else { // We received a subscription [n]ack for an eventgroup that does not exist. // --> Remove subscription. - unsubscribe(its_service, its_instance, its_eventgroup, VSOMEIP_ROUTING_CLIENT); + unsubscribe(its_service, its_unique, its_eventgroup, VSOMEIP_ROUTING_CLIENT); boost::system::error_code ec; VSOMEIP_WARNING << __func__ @@ -2295,19 +2305,19 @@ service_discovery_impl::process_eventgroupentry( if (entry_type_e::SUBSCRIBE_EVENTGROUP == its_type) { handle_eventgroup_subscription( - its_service, its_instance, its_eventgroup, its_major, its_ttl, 0, 0, + its_service, its_unique, its_eventgroup, its_major, its_ttl, 0, 0, its_first_address, its_first_port, is_first_reliable, its_second_address, its_second_port, is_second_reliable, _acknowledgement, _is_stop_subscribe_subscribe, _force_initial_events, its_clients, _sd_ac_state, its_info, _sender); } else { if (entry_type_e::SUBSCRIBE_EVENTGROUP_ACK == its_type) { //this type is used for ACK and NACK messages if (its_ttl > 0) { - handle_eventgroup_subscription_ack(its_service, its_instance, + handle_eventgroup_subscription_ack(its_service, its_unique, its_eventgroup, its_major, its_ttl, 0, its_clients, _sender, its_first_address, its_first_port); } else { - handle_eventgroup_subscription_nack(its_service, its_instance, its_eventgroup, + handle_eventgroup_subscription_nack(its_service, its_unique, its_eventgroup, 0, its_clients); } } @@ -2315,7 +2325,7 @@ service_discovery_impl::process_eventgroupentry( } void service_discovery_impl::handle_eventgroup_subscription( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, major_version_t _major, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, uint8_t _counter, uint16_t _reserved, const boost::asio::ip::address& _first_address, uint16_t _first_port, bool _is_first_reliable, const boost::asio::ip::address& _second_address, @@ -2367,7 +2377,7 @@ void service_discovery_impl::handle_eventgroup_subscription( << ": Subscription for [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "]" << " not valid: Event configuration (" << static_cast(_info->get_reliability()) @@ -2381,7 +2391,7 @@ void service_discovery_impl::handle_eventgroup_subscription( #endif if (_ttl > 0) { - std::shared_ptr its_info = host_->get_offered_service(_service, _instance); + std::shared_ptr its_info = host_->get_offered_service(_service, _unique); bool send_nack = false; if (!its_info) { send_nack = true; @@ -2406,7 +2416,7 @@ void service_discovery_impl::handle_eventgroup_subscription( // wrong major version if (_major != _info->get_major()) { // Create a temporary info object with TTL=0 --> send NACK - auto its_info = std::make_shared(_service, _instance, + auto its_info = std::make_shared(_service, get_instance_from_unique(_unique), _eventgroup, _major, 0, VSOMEIP_DEFAULT_MAX_REMOTE_SUBSCRIBERS); boost::system::error_code ec; // TODO: Add session id @@ -2415,7 +2425,7 @@ void service_discovery_impl::handle_eventgroup_subscription( << "] in subscription to service: [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "]" << " does not match with services major version:[" << static_cast(_info->get_major()) << "] subscriber: " @@ -2429,16 +2439,16 @@ void service_discovery_impl::handle_eventgroup_subscription( if (ILLEGAL_PORT != _first_port) { uint16_t its_first_port(0); its_subscriber = endpoint_definition::get( - _first_address, _first_port, _is_first_reliable, _service, _instance); + _first_address, _first_port, _is_first_reliable, _service, _unique); if (!_is_first_reliable && _info->get_multicast(its_first_address, its_first_port) && _info->is_sending_multicast()) { // udp multicast its_unreliable = endpoint_definition::get( - its_first_address, its_first_port, false, _service, _instance); + its_first_address, its_first_port, false, _service, _unique); } else if (_is_first_reliable) { // tcp unicast its_reliable = its_subscriber; // check if TCP connection is established by client - if (_ttl > 0 && !is_tcp_connected(_service, _instance, its_reliable)) { + if (_ttl > 0 && !is_tcp_connected(_service, _unique, its_reliable)) { insert_subscription_ack(_acknowledgement, _info, 0, nullptr, _clients); // TODO: Add sender and session id VSOMEIP_ERROR << "TCP connection to target1: [" @@ -2447,7 +2457,7 @@ void service_discovery_impl::handle_eventgroup_subscription( << "] not established for subscription to: [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "] "; return; } @@ -2459,16 +2469,16 @@ void service_discovery_impl::handle_eventgroup_subscription( if (ILLEGAL_PORT != _second_port) { uint16_t its_second_port(0); its_subscriber = endpoint_definition::get( - _second_address, _second_port, _is_second_reliable, _service, _instance); + _second_address, _second_port, _is_second_reliable, _service, _unique); if (!_is_second_reliable && _info->get_multicast(its_second_address, its_second_port) && _info->is_sending_multicast()) { // udp multicast its_unreliable = endpoint_definition::get( - its_second_address, its_second_port, false, _service, _instance); + its_second_address, its_second_port, false, _service, _unique); } else if (_is_second_reliable) { // tcp unicast its_reliable = its_subscriber; // check if TCP connection is established by client - if (_ttl > 0 && !is_tcp_connected(_service, _instance, its_reliable)) { + if (_ttl > 0 && !is_tcp_connected(_service, _unique, its_reliable)) { insert_subscription_ack(_acknowledgement, _info, 0, nullptr, _clients); // TODO: Add sender and session id VSOMEIP_ERROR << "TCP connection to target2 : [" @@ -2477,7 +2487,7 @@ void service_discovery_impl::handle_eventgroup_subscription( << "] not established for subscription to: [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "] "; return; } @@ -2533,7 +2543,7 @@ void service_discovery_impl::handle_eventgroup_subscription( its_subscription->set_force_initial_events(true); } its_subscription->set_ttl(_ttl - * get_ttl_factor(_service, _instance, ttl_factor_subscriptions_)); + * get_ttl_factor(_service, _unique, ttl_factor_subscriptions_)); { std::lock_guard its_lock(pending_remote_subscriptions_mutex_); @@ -2549,21 +2559,21 @@ void service_discovery_impl::handle_eventgroup_subscription( void service_discovery_impl::handle_eventgroup_subscription_nack( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, uint8_t _counter, const std::set &_clients) { (void)_counter; std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_eventgroup = found_instance->second.find(_eventgroup); - if (found_eventgroup != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_eventgroup = found_unique->second.find(_eventgroup); + if (found_eventgroup != found_unique->second.end()) { auto its_subscription = found_eventgroup->second; for (const auto its_client : _clients) { host_->on_subscribe_nack(its_client, - _service, _instance, _eventgroup, ANY_EVENT, + _service, _unique, _eventgroup, ANY_EVENT, PENDING_SUBSCRIPTION_ID); // TODO: This is a dummy call... } @@ -2580,7 +2590,7 @@ service_discovery_impl::handle_eventgroup_subscription_nack( void service_discovery_impl::handle_eventgroup_subscription_ack( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, ttl_t _ttl, uint8_t _counter, const std::set &_clients, const boost::asio::ip::address &_sender, @@ -2592,23 +2602,23 @@ service_discovery_impl::handle_eventgroup_subscription_ack( std::lock_guard its_lock(subscribed_mutex_); auto found_service = subscribed_.find(_service); if (found_service != subscribed_.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - auto found_eventgroup = found_instance->second.find(_eventgroup); - if (found_eventgroup != found_instance->second.end()) { + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + auto found_eventgroup = found_unique->second.find(_eventgroup); + if (found_eventgroup != found_unique->second.end()) { for (const auto its_client : _clients) { if (found_eventgroup->second->get_state(its_client) == subscription_state_e::ST_NOT_ACKNOWLEDGED) { found_eventgroup->second->set_state(its_client, subscription_state_e::ST_ACKNOWLEDGED); host_->on_subscribe_ack(its_client, - _service, _instance, _eventgroup, + _service, _unique, _eventgroup, ANY_EVENT, PENDING_SUBSCRIPTION_ID); } } if (_address.is_multicast()) { host_->on_subscribe_ack_with_multicast( - _service, _instance, _sender, _address, _port); + _service, _unique, _sender, _address, _port); } } } @@ -2616,11 +2626,11 @@ service_discovery_impl::handle_eventgroup_subscription_ack( } bool service_discovery_impl::is_tcp_connected(service_t _service, - instance_t _instance, + unique_version_t _unique, const std::shared_ptr& its_endpoint) { bool is_connected = false; std::shared_ptr its_info = host_->get_offered_service(_service, - _instance); + _unique); if (its_info) { //get reliable server endpoint auto its_reliable_server_endpoint = std::dynamic_pointer_cast< @@ -2668,11 +2678,12 @@ service_discovery_impl::serialize_and_send( m->set_reboot_flag(its_session.second); if (serializer_->serialize(m.get())) { + if (host_->send_via_sd(endpoint_definition::get(_address, port_, reliable_, m->get_service(), m->get_instance()), serializer_->get_data(), serializer_->get_size(), port_)) { - increment_session(_address); + increment_session(_address); // TODO: Kareem should find a solution for this } } else { VSOMEIP_ERROR << "service_discovery_impl::" << __func__ @@ -2839,19 +2850,22 @@ void service_discovery_impl::offer_service(const std::shared_ptr &_info) { service_t its_service = _info->get_service(); service_t its_instance = _info->get_instance(); + major_version_t its_major = _info->get_major(); + + unique_version_t its_unique = get_unique_version(its_instance, its_major); std::lock_guard its_lock(collected_offers_mutex_); // check if offer is in map bool found(false); const auto its_service_it = collected_offers_.find(its_service); if (its_service_it != collected_offers_.end()) { - const auto its_instance_it = its_service_it->second.find(its_instance); - if (its_instance_it != its_service_it->second.end()) { + const auto its_unique_it = its_service_it->second.find(its_unique); + if (its_unique_it != its_service_it->second.end()) { found = true; } } if (!found) { - collected_offers_[its_service][its_instance] = _info; + collected_offers_[its_service][its_unique] = _info; } } @@ -2906,9 +2920,9 @@ service_discovery_impl::on_find_debounce_timer_expired( { std::lock_guard its_lock(requested_mutex_); for (const auto& its_service : requested_) { - for (const auto& its_instance : its_service.second) { - if( its_instance.second->get_sent_counter() == 0) { - repetition_phase_finds[its_service.first][its_instance.first] = its_instance.second; + for (const auto& its_unique : its_service.second) { + if( its_unique.second->get_sent_counter() == 0) { + repetition_phase_finds[its_service.first][its_unique.first] = its_unique.second; } } } @@ -2970,9 +2984,9 @@ service_discovery_impl::on_offer_debounce_timer_expired( if (is_diagnosis_) { for (services_t::iterator its_service = collected_offers_.begin(); its_service != collected_offers_.end(); its_service++) { - for (const auto& its_instance : its_service->second) { + for (const auto& its_unique : its_service->second) { if (!configuration_->is_someip( - its_service->first, its_instance.first)) { + its_service->first, its_unique.first)) { non_someip_services.push_back(its_service); } } @@ -3157,8 +3171,8 @@ service_discovery_impl::move_offers_into_main_phase( const auto its_timer = repetition_phase_timers_.find(_timer); if (its_timer != repetition_phase_timers_.end()) { for (const auto& its_service : its_timer->second) { - for (const auto& its_instance : its_service.second) { - its_instance.second->set_is_in_mainphase(true); + for (const auto& its_unique : its_service.second) { + its_unique.second->set_is_in_mainphase(true); } } repetition_phase_timers_.erase(_timer); @@ -3174,6 +3188,10 @@ service_discovery_impl::stop_offer_service( _info->set_accepting_remote_subscriptions(false); const service_t its_service = _info->get_service(); const instance_t its_instance = _info->get_instance(); + const major_version_t its_major = _info->get_major(); + + unique_version_t its_unique = get_unique_version(its_instance, its_major); + bool stop_offer_required(false); // Delete from initial phase offers { @@ -3181,10 +3199,10 @@ service_discovery_impl::stop_offer_service( if (collected_offers_.size()) { auto its_service_it = collected_offers_.find(its_service); if (its_service_it != collected_offers_.end()) { - auto its_instance_it = its_service_it->second.find(its_instance); - if (its_instance_it != its_service_it->second.end()) { - if (its_instance_it->second == _info) { - its_service_it->second.erase(its_instance_it); + auto its_unique_it = its_service_it->second.find(its_unique); + if (its_unique_it != its_service_it->second.end()) { + if (its_unique_it->second == _info) { + its_service_it->second.erase(its_unique_it); if (!collected_offers_[its_service].size()) { collected_offers_.erase(its_service_it); @@ -3204,10 +3222,10 @@ service_discovery_impl::stop_offer_service( rpt != repetition_phase_timers_.end();) { auto its_service_it = rpt->second.find(its_service); if (its_service_it != rpt->second.end()) { - auto its_instance_it = its_service_it->second.find(its_instance); - if (its_instance_it != its_service_it->second.end()) { - if (its_instance_it->second == _info) { - its_service_it->second.erase(its_instance_it); + auto its_unique_it = its_service_it->second.find(its_unique); + if (its_unique_it != its_service_it->second.end()) { + if (its_unique_it->second == _info) { + its_service_it->second.erase(its_unique_it); stop_offer_required = true; if (!rpt->second[its_service].size()) { rpt->second.erase(its_service); @@ -3408,7 +3426,7 @@ service_discovery_impl::update_subscription_expiration_timer( const std::chrono::steady_clock::time_point its_expiration = now + std::chrono::seconds(e->get_ttl() * get_ttl_factor( - e->get_service(), e->get_instance(), + e->get_service(), get_unique_version(e->get_instance(), e->get_major_version()), ttl_factor_subscriptions_)); if (its_expiration < next_subscription_expiration_) { next_subscription_expiration_ = its_expiration; @@ -3477,8 +3495,12 @@ service_discovery_impl::is_subscribed( const message_impl::options_t &_options) const { const auto its_service = _entry->get_service(); const auto its_instance = _entry->get_instance(); + const auto its_major = _entry->get_major_version(); + + unique_version_t its_unique = get_unique_version(its_instance, its_major); + auto its_info = host_->find_eventgroup( - its_service, its_instance, _entry->get_eventgroup()); + its_service, its_unique, _entry->get_eventgroup()); if (its_info) { std::shared_ptr its_reliable, its_unreliable; for (const auto& o : _options) { @@ -3493,7 +3515,7 @@ service_discovery_impl::is_subscribed( its_endpoint_option->get_address()), its_endpoint_option->get_port(), true, - its_service, its_instance); + its_service, its_unique); } else if (its_endpoint_option->get_layer_four_protocol() == layer_four_protocol_e::UDP) { its_unreliable = endpoint_definition::get( @@ -3501,7 +3523,7 @@ service_discovery_impl::is_subscribed( its_endpoint_option->get_address()), its_endpoint_option->get_port(), false, - its_service, its_instance); + its_service, its_unique); } } } else if (o->get_type() == option_type_e::IP6_ENDPOINT) { @@ -3514,7 +3536,7 @@ service_discovery_impl::is_subscribed( its_endpoint_option->get_address()), its_endpoint_option->get_port(), true, - its_service, its_instance); + its_service, its_unique); } else if (its_endpoint_option->get_layer_four_protocol() == layer_four_protocol_e::UDP) { its_unreliable = endpoint_definition::get( @@ -3522,7 +3544,7 @@ service_discovery_impl::is_subscribed( its_endpoint_option->get_address()), its_endpoint_option->get_port(), false, - its_service, its_instance); + its_service, its_unique); } } } @@ -3540,14 +3562,14 @@ service_discovery_impl::is_subscribed( configuration::ttl_factor_t service_discovery_impl::get_ttl_factor( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const configuration::ttl_map_t& _ttl_map) const { configuration::ttl_factor_t its_ttl_factor(1); auto found_service = _ttl_map.find(_service); if (found_service != _ttl_map.end()) { - auto found_instance = found_service->second.find(_instance); - if (found_instance != found_service->second.end()) { - its_ttl_factor = found_instance->second; + auto found_unique = found_service->second.find(_unique); + if (found_unique != found_service->second.end()) { + its_ttl_factor = found_unique->second; } } return its_ttl_factor; @@ -3592,9 +3614,9 @@ service_discovery_impl::stop_last_msg_received_timer() { reliability_type_e service_discovery_impl::get_remote_offer_type( - service_t _service, instance_t _instance) const { + service_t _service, unique_version_t _unique) const { std::lock_guard its_lock(remote_offer_types_mutex_); - auto found_si = remote_offer_types_.find(std::make_pair(_service, _instance)); + auto found_si = remote_offer_types_.find(std::make_pair(_service, _unique)); if (found_si != remote_offer_types_.end()) { return found_si->second; } @@ -3618,13 +3640,13 @@ service_discovery_impl::get_remote_offer_type( bool service_discovery_impl::update_remote_offer_type( - service_t _service, instance_t _instance, reliability_type_e _offer_type, + service_t _service, unique_version_t _unique, reliability_type_e _offer_type, const boost::asio::ip::address& _reliable_address, std::uint16_t _reliable_port, const boost::asio::ip::address& _unreliable_address, std::uint16_t _unreliable_port, bool _received_via_multicast) { bool ret(false); std::lock_guard its_lock(remote_offer_types_mutex_); - const remote_offer_info_t its_service_instance(_service, _instance, _received_via_multicast); + const remote_offer_info_t its_service_instance(_service, _unique, _received_via_multicast); auto found_si = remote_offer_types_.find(its_service_instance.service_info); if (found_si != remote_offer_types_.end()) { if (found_si->second != _offer_type ) { @@ -3654,7 +3676,7 @@ bool service_discovery_impl::update_remote_offer_type( VSOMEIP_WARNING << __func__ << ": unknown offer type [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "]" + << std::setw(4) << get_instance_from_unique(_unique) << "]" << static_cast(_offer_type); break; } @@ -3663,13 +3685,13 @@ bool service_discovery_impl::update_remote_offer_type( void service_discovery_impl::remove_remote_offer_type( - service_t _service, instance_t _instance, + service_t _service, unique_version_t _unique, const boost::asio::ip::address &_reliable_address, std::uint16_t _reliable_port, const boost::asio::ip::address &_unreliable_address, std::uint16_t _unreliable_port) { std::lock_guard its_lock(remote_offer_types_mutex_); - const remote_offer_info_t its_service_instance(_service, _instance); + const remote_offer_info_t its_service_instance(_service, _unique); remote_offer_types_.erase(its_service_instance.service_info); @@ -3734,7 +3756,7 @@ void service_discovery_impl::remove_remote_offer_type_by_ip( } bool service_discovery_impl::set_offer_multicast_state( - service_t _service, instance_t _instance, reliability_type_e _offer_type, + service_t _service, unique_version_t _unique, reliability_type_e _offer_type, const boost::asio::ip::address& _reliable_address, port_t _reliable_port, const boost::asio::ip::address& _unreliable_address, std::uint16_t _unreliable_port, bool _received_via_multicast) { @@ -3743,12 +3765,12 @@ bool service_discovery_impl::set_offer_multicast_state( auto check_offer_info = [this, &was_unicast, _received_via_multicast]( const boost::asio::ip::address& address, bool reliable, - port_t port, service_t service_id, instance_t instance_id) { + port_t port, service_t service_id, unique_version_t unique_id) { auto found_address = remote_offers_by_ip_.find(address); if (found_address != remote_offers_by_ip_.end()) { auto found_port = found_address->second.find(std::make_pair(reliable, port)); if (found_port != found_address->second.end()) { - auto found_offer_info = found_port->second.find({service_id, instance_id}); + auto found_offer_info = found_port->second.find({service_id, unique_id}); if (found_offer_info != found_port->second.end()) { if (!found_offer_info->offer_received_via_multicast) { was_unicast = true; @@ -3761,21 +3783,21 @@ bool service_discovery_impl::set_offer_multicast_state( switch (_offer_type) { case reliability_type_e::RT_UNRELIABLE: - check_offer_info(_unreliable_address, false, _unreliable_port, _service, _instance); + check_offer_info(_unreliable_address, false, _unreliable_port, _service, _unique); break; case reliability_type_e::RT_RELIABLE: - check_offer_info(_reliable_address, true, _reliable_port, _service, _instance); + check_offer_info(_reliable_address, true, _reliable_port, _service, _unique); break; case reliability_type_e::RT_BOTH: - check_offer_info(_unreliable_address, false, _unreliable_port, _service, _instance); - check_offer_info(_reliable_address, true, _reliable_port, _service, _instance); + check_offer_info(_unreliable_address, false, _unreliable_port, _service, _unique); + check_offer_info(_reliable_address, true, _reliable_port, _service, _unique); break; case reliability_type_e::RT_UNKNOWN: default: VSOMEIP_WARNING << __func__ << ": unknown offer type [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "]" + << std::setw(4) << get_instance_from_unique(_unique) << "]" << static_cast(_offer_type); break; } @@ -3950,7 +3972,7 @@ service_discovery_impl::register_reboot_notification_handler( } reliability_type_e service_discovery_impl::get_eventgroup_reliability( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, const std::shared_ptr& _subscription) { reliability_type_e its_reliability = reliability_type_e::RT_UNKNOWN; auto its_info = _subscription->get_eventgroupinfo().lock(); @@ -3960,11 +3982,11 @@ reliability_type_e service_discovery_impl::get_eventgroup_reliability( && its_info->is_reliability_auto_mode()) { // fallback: determine how service is offered // and update reliability type of eventgroup - its_reliability = get_remote_offer_type(_service, _instance); + its_reliability = get_remote_offer_type(_service, _unique); VSOMEIP_WARNING << "sd::" << __func__ << ": couldn't determine eventgroup reliability type for [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "]" << " using reliability type: " << std::setw(4) << static_cast(its_reliability); @@ -3974,9 +3996,9 @@ reliability_type_e service_discovery_impl::get_eventgroup_reliability( VSOMEIP_WARNING << "sd::" << __func__ << ": couldn't lock eventgroupinfo [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "] "; - auto its_eg_info = host_->find_eventgroup(_service, _instance, _eventgroup); + auto its_eg_info = host_->find_eventgroup(_service, _unique, _eventgroup); if (its_eg_info) { _subscription->set_eventgroupinfo(its_eg_info); its_reliability = its_eg_info->get_reliability(); @@ -3987,7 +4009,7 @@ reliability_type_e service_discovery_impl::get_eventgroup_reliability( VSOMEIP_WARNING << "sd::" << __func__ << ": eventgroup reliability type is unknown [" << std::hex << std::setfill('0') << std::setw(4) << _service << "." - << std::setw(4) << _instance << "." + << std::setw(4) << get_instance_from_unique(_unique) << "." << std::setw(4) << _eventgroup << "]"; } return its_reliability; diff --git a/interface/compat/vsomeip/application.hpp b/interface/compat/vsomeip/application.hpp index 0d4b671f8..d1c6712b6 100644 --- a/interface/compat/vsomeip/application.hpp +++ b/interface/compat/vsomeip/application.hpp @@ -148,7 +148,7 @@ class application { * \param _minor Minor service version (Default: 0). * */ - virtual void offer_service(service_t _service, instance_t _instance, + virtual void offer_service(service_t _service, unique_version_t _unique, major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0; @@ -164,7 +164,7 @@ class application { * \param _minor Minor service version (Default: 0). * */ - virtual void stop_offer_service(service_t _service, instance_t _instance, + virtual void stop_offer_service(service_t _service, unique_version_t _unique, major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0; @@ -188,7 +188,7 @@ class application { * */ virtual void offer_event(service_t _service, - instance_t _instance, event_t _event, + unique_version_t _unique, event_t _event, const std::set &_eventgroups, bool _is_field) = 0; @@ -207,7 +207,7 @@ class application { * */ virtual void stop_offer_event(service_t _service, - instance_t _instance, event_t _event) = 0; + unique_version_t _unique, event_t _event) = 0; /** * @@ -226,7 +226,7 @@ class application { * used for the communication of this application to the service instance. * */ - virtual void request_service(service_t _service, instance_t _instance, + virtual void request_service(service_t _service, unique_version_t _unique, major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR, bool _use_exclusive_proxy = false) = 0; @@ -247,7 +247,7 @@ class application { * \param _instance Instance identifier of the offered service instance. * */ - virtual void release_service(service_t _service, instance_t _instance) = 0; + virtual void release_service(service_t _service, unique_version_t _unique) = 0; /** * @@ -267,7 +267,7 @@ class application { * \param _is_field Pure event (false) or field (true). * */ - virtual void request_event(service_t _service, instance_t _instance, + virtual void request_event(service_t _service, unique_version_t _unique, event_t _event, const std::set &_eventgroups, bool _is_field) = 0; /** @@ -284,7 +284,7 @@ class application { * \param _event Event identifier of the event or field. * . */ - virtual void release_event(service_t _service, instance_t _instance, + virtual void release_event(service_t _service, unique_version_t _unique, event_t _event) = 0; /** @@ -312,7 +312,7 @@ class application { * \param _event All (Default) or a specific event. * */ - virtual void subscribe(service_t _service, instance_t _instance, + virtual void subscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major = DEFAULT_MAJOR, subscription_type_e _subscription_type = subscription_type_e::SU_RELIABLE_AND_UNRELIABLE, event_t _event = ANY_EVENT) = 0; @@ -328,7 +328,7 @@ class application { * \param _eventgroup Eventgroup identifier of the eventgroup. * */ - virtual void unsubscribe(service_t _service, instance_t _instance, + virtual void unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) = 0; /** @@ -346,7 +346,7 @@ class application { * minor version. * */ - virtual bool is_available(service_t _service, instance_t _instance, + virtual bool is_available(service_t _service, unique_version_t _unique, major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) const = 0; /** @@ -385,7 +385,7 @@ class application { * \param _payload Serialized payload of the event. * */ - virtual void notify(service_t _service, instance_t _instance, + virtual void notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload) const = 0; /** @@ -409,7 +409,7 @@ class application { * \param _client Target client. * */ - virtual void notify_one(service_t _service, instance_t _instance, + virtual void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client) const = 0; @@ -466,7 +466,7 @@ class application { * */ virtual void register_message_handler(service_t _service, - instance_t _instance, method_t _method, + unique_version_t _unique, method_t _method, message_handler_t _handler) = 0; /** * @@ -484,7 +484,7 @@ class application { * all methods and events. */ virtual void unregister_message_handler(service_t _service, - instance_t _instance, method_t _method) = 0; + unique_version_t _unique, method_t _method) = 0; /** * @@ -509,7 +509,7 @@ class application { * */ virtual void register_availability_handler(service_t _service, - instance_t _instance, availability_handler_t _handler, + unique_version_t _unique, availability_handler_t _handler, major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0; /** @@ -549,7 +549,7 @@ class application { * */ virtual void register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, subscription_handler_t _handler) = 0; /** @@ -565,7 +565,7 @@ class application { * */ virtual void unregister_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) = 0; + unique_version_t _unique, eventgroup_t _eventgroup) = 0; // [Un]Register handler for subscription errors /** @@ -586,7 +586,7 @@ class application { * */ virtual void register_subscription_error_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, error_handler_t _handler) = 0; /** @@ -602,7 +602,7 @@ class application { * */ virtual void unregister_subscription_error_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) = 0; + unique_version_t _unique, eventgroup_t _eventgroup) = 0; /** * @@ -667,7 +667,7 @@ class application { * reasons. They will be merged with the next major vsomeip version. */ virtual void offer_event(service_t _service, - instance_t _instance, event_t _event, + unique_version_t _unique, event_t _event, const std::set &_eventgroups, bool _is_field, std::chrono::milliseconds _cycle, @@ -698,7 +698,7 @@ class application { * Note: The different versions of notify do exist for compatibility * reasons. They will be merged with the next major vsomeip release. */ - virtual void notify(service_t _service, instance_t _instance, + virtual void notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force) const = 0; @@ -727,7 +727,7 @@ class application { * Note: The different versions of notify_one do exist for compatibility * reasons. They will be merged with the next major vsomeip release. */ - virtual void notify_one(service_t _service, instance_t _instance, + virtual void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force) const = 0; @@ -754,7 +754,7 @@ class application { * are checked */ virtual bool are_available(available_t &_available, - service_t _service = ANY_SERVICE, instance_t _instance = ANY_INSTANCE, + service_t _service = ANY_SERVICE, unique_version_t _unique = ANY_INSTANCE, major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) const = 0; /** @@ -782,7 +782,7 @@ class application { * Note: The different versions of notify do exist for compatibility * reasons. They will be merged with the next major vsomeip release. */ - virtual void notify(service_t _service, instance_t _instance, + virtual void notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force, bool _flush) const = 0; @@ -812,7 +812,7 @@ class application { * Note: The different versions of notify_one do exist for compatibility * reasons. They will be merged with the next major vsomeip release. */ - virtual void notify_one(service_t _service, instance_t _instance, + virtual void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force, bool _flush) const = 0; @@ -839,7 +839,7 @@ class application { * \param _eventgroup Eventgroup identifier of the eventgroup. * \param _event Event to unsubscribe (pass ANY_EVENT for all events of the eventgroup) */ - virtual void unsubscribe(service_t _service, instance_t _instance, + virtual void unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) = 0; @@ -861,7 +861,7 @@ class application { * as a follow of application::subscribe. */ virtual void register_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, subscription_status_handler_t _handler) = 0; /** @@ -884,7 +884,7 @@ class application { * subscription is answered with a SUBSCRIBE_NACK. */ virtual void register_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, subscription_status_handler_t _handler, bool _is_selective) = 0; /** @@ -946,7 +946,7 @@ class application { * */ virtual void register_async_subscription_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, async_subscription_handler_t _handler) = 0; /** @@ -1044,7 +1044,7 @@ class application { * \param _offer Offer the service or stop offering it remotely */ virtual bool update_service_configuration(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled, diff --git a/interface/compat/vsomeip/handler.hpp b/interface/compat/vsomeip/handler.hpp index 4c742556a..ba9809a4e 100644 --- a/interface/compat/vsomeip/handler.hpp +++ b/interface/compat/vsomeip/handler.hpp @@ -24,7 +24,7 @@ typedef std::function< void (const service_t, const instance_t, const eventgroup const event_t, const uint16_t) > subscription_status_handler_t; typedef std::function< void (client_t, bool, std::function< void (const bool) > )> async_subscription_handler_t; -typedef std::function< void (const std::vector> &_services) > offered_services_handler_t; +typedef std::function< void (const std::vector> &_services) > offered_services_handler_t; typedef std::function< void () > watchdog_handler_t; struct ip_address_t { diff --git a/interface/compat/vsomeip/primitive_types.hpp b/interface/compat/vsomeip/primitive_types.hpp index ce1d4bd10..ee5486ebe 100644 --- a/interface/compat/vsomeip/primitive_types.hpp +++ b/interface/compat/vsomeip/primitive_types.hpp @@ -20,7 +20,8 @@ typedef uint16_t service_t; typedef uint16_t method_t; typedef uint16_t event_t; -typedef uint16_t instance_t; +typedef uint32_t instance_t; +typedef uint64_t unique_version_t; typedef uint16_t eventgroup_t; typedef uint8_t major_version_t; @@ -53,6 +54,18 @@ typedef std::uint32_t pending_remote_offer_id_t; typedef std::uint32_t pending_security_update_id_t; +inline unique_version_t get_unique_version(instance_t _instance, major_version_t _major) { + return static_cast((static_cast(_major << sizeof(instance_t) * 8)) | _instance); +} + +inline major_version_t get_major_from_unique(unique_version_t _unique) { + return static_cast((_unique >> sizeof(instance_t) * 8)); +} + +inline instance_t get_instance_from_unique(unique_version_t _unique) { + return static_cast(_unique & ((1U << (sizeof(instance_t) * 8)) - 1)); +} + #ifdef _WIN32 typedef std::uint32_t uid_t; typedef std::uint32_t gid_t; diff --git a/interface/compat/vsomeip/vsomeip.hpp b/interface/compat/vsomeip/vsomeip.hpp index 101e136ea..802bc7375 100644 --- a/interface/compat/vsomeip/vsomeip.hpp +++ b/interface/compat/vsomeip/vsomeip.hpp @@ -18,4 +18,6 @@ #include "../../compat/vsomeip/runtime.hpp" #include "../../compat/vsomeip/trace.hpp" +#define VSOMEIP_MAKE_UNIQUE_SERVICE_VERSION (_instance_, _major) ((_major << 16) | _instance_) + #endif // VSOMEIP_VSOMEIP_HPP diff --git a/interface/vsomeip/application.hpp b/interface/vsomeip/application.hpp index b81c90e69..cf1b1eb32 100644 --- a/interface/vsomeip/application.hpp +++ b/interface/vsomeip/application.hpp @@ -168,7 +168,7 @@ class application { * \param _minor Minor service version (Default: 0). * */ - virtual void offer_service(service_t _service, instance_t _instance, + virtual void offer_service(service_t _service, unique_version_t _unique, major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0; @@ -184,7 +184,7 @@ class application { * \param _minor Minor service version (Default: 0). * */ - virtual void stop_offer_service(service_t _service, instance_t _instance, + virtual void stop_offer_service(service_t _service, unique_version_t _unique, major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0; @@ -220,7 +220,7 @@ class application { * instance's reliability configuration. This parameter has no effect for * events of local services. */ - virtual void offer_event(service_t _service, instance_t _instance, + virtual void offer_event(service_t _service, unique_version_t _unique, event_t _notifier, const std::set &_eventgroups, event_type_e _type = event_type_e::ET_EVENT, std::chrono::milliseconds _cycle =std::chrono::milliseconds::zero(), @@ -244,7 +244,7 @@ class application { * */ virtual void stop_offer_event(service_t _service, - instance_t _instance, event_t _event) = 0; + unique_version_t _unique, event_t _event) = 0; /** * @@ -261,7 +261,7 @@ class application { * \param _minor Minor service version (Default: 0xFFFFFF). * */ - virtual void request_service(service_t _service, instance_t _instance, + virtual void request_service(service_t _service, unique_version_t _unique, major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) = 0; @@ -281,7 +281,7 @@ class application { * \param _instance Instance identifier of the offered service instance. * */ - virtual void release_service(service_t _service, instance_t _instance) = 0; + virtual void release_service(service_t _service, unique_version_t _unique) = 0; /** * @@ -313,7 +313,7 @@ class application { * belong to the eventgroup. Otherwise, neither event type nor reliability * type are known which might result in missing events. */ - virtual void request_event(service_t _service, instance_t _instance, + virtual void request_event(service_t _service, unique_version_t _unique, event_t _event, const std::set &_eventgroups, event_type_e _type = event_type_e::ET_EVENT, reliability_type_e _reliability = reliability_type_e::RT_UNKNOWN) = 0; @@ -331,7 +331,7 @@ class application { * \param _event Event identifier of the event or field. * . */ - virtual void release_event(service_t _service, instance_t _instance, + virtual void release_event(service_t _service, unique_version_t _unique, event_t _event) = 0; /** @@ -358,7 +358,7 @@ class application { * \param _event All (Default) or a specific event. * */ - virtual void subscribe(service_t _service, instance_t _instance, + virtual void subscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major = DEFAULT_MAJOR, event_t _event = ANY_EVENT) = 0; @@ -373,7 +373,7 @@ class application { * \param _eventgroup Eventgroup identifier of the eventgroup. * */ - virtual void unsubscribe(service_t _service, instance_t _instance, + virtual void unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup) = 0; /** @@ -391,7 +391,7 @@ class application { * minor version. * */ - virtual bool is_available(service_t _service, instance_t _instance, + virtual bool is_available(service_t _service, unique_version_t _unique, major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) const = 0; typedef std::map>> available_t; virtual bool are_available(available_t &_available, - service_t _service = ANY_SERVICE, instance_t _instance = ANY_INSTANCE, + service_t _service = ANY_SERVICE, unique_version_t _unique = ANY_INSTANCE, major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) const = 0; /** @@ -436,7 +436,7 @@ class application { * \param _payload Serialized payload of the event. * */ - virtual void notify(service_t _service, instance_t _instance, + virtual void notify(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, bool _force = false) const = 0; @@ -461,7 +461,7 @@ class application { * \param _client Target client. * */ - virtual void notify_one(service_t _service, instance_t _instance, + virtual void notify_one(service_t _service, unique_version_t _unique, event_t _event, std::shared_ptr _payload, client_t _client, bool _force = false) const = 0; @@ -518,7 +518,7 @@ class application { * */ virtual void register_message_handler(service_t _service, - instance_t _instance, method_t _method, + unique_version_t _unique, method_t _method, const message_handler_t &_handler) = 0; /** * @@ -536,7 +536,7 @@ class application { * all methods and events. */ virtual void unregister_message_handler(service_t _service, - instance_t _instance, method_t _method) = 0; + unique_version_t _unique, method_t _method) = 0; /** * @@ -561,7 +561,7 @@ class application { * */ virtual void register_availability_handler(service_t _service, - instance_t _instance, const availability_handler_t &_handler, + unique_version_t _unique, const availability_handler_t &_handler, major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) = 0; /** @@ -602,7 +602,7 @@ class application { */ VSOMEIP_DEPRECATED_UID_GID virtual void register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, const subscription_handler_t &_handler) = 0; /** @@ -629,7 +629,7 @@ class application { */ VSOMEIP_DEPRECATED_UID_GID virtual void register_async_subscription_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, const async_subscription_handler_t &_handler) = 0; /** @@ -645,7 +645,7 @@ class application { * */ virtual void unregister_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup) = 0; + unique_version_t _unique, eventgroup_t _eventgroup) = 0; /** * @@ -691,7 +691,7 @@ class application { * \param _eventgroup Eventgroup identifier of the eventgroup. * \param _event Event to unsubscribe (pass ANY_EVENT for all events of the eventgroup) */ - virtual void unsubscribe(service_t _service, instance_t _instance, + virtual void unsubscribe(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) = 0; /** @@ -715,7 +715,7 @@ class application { * subscription is answered with a SUBSCRIBE_NACK. */ virtual void register_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event, + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event, subscription_status_handler_t _handler, bool _is_selective = false) = 0; /** @@ -732,7 +732,7 @@ class application { * be removed. */ virtual void unregister_subscription_status_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, event_t _event) = 0; + unique_version_t _unique, eventgroup_t _eventgroup, event_t _event) = 0; /** * @@ -883,7 +883,7 @@ class application { * \param _offer Offer the service or stop offering it remotely */ virtual bool update_service_configuration(service_t _service, - instance_t _instance, + unique_version_t _unique, std::uint16_t _port, bool _reliable, bool _magic_cookies_enabled, @@ -945,7 +945,7 @@ class application { */ VSOMEIP_DEPRECATED_UID_GID virtual void register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, const subscription_handler_ext_t &_handler) = 0; /** @@ -972,7 +972,7 @@ class application { */ VSOMEIP_DEPRECATED_UID_GID virtual void register_async_subscription_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, const async_subscription_handler_ext_t &_handler) = 0; @@ -1001,7 +1001,7 @@ class application { * \param _filter Filter configuration to decide whether or not an * incoming event will be forwarded to the application. */ - virtual void subscribe_with_debounce(service_t _service, instance_t _instance, + virtual void subscribe_with_debounce(service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, major_version_t _major, event_t _event, const debounce_filter_t &_filter) = 0; @@ -1049,7 +1049,7 @@ class application { * */ virtual void register_availability_handler(service_t _service, - instance_t _instance, const availability_state_handler_t &_handler, + unique_version_t _unique, const availability_state_handler_t &_handler, major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) = 0; /** @@ -1073,7 +1073,7 @@ class application { * */ virtual void register_subscription_handler(service_t _service, - instance_t _instance, eventgroup_t _eventgroup, + unique_version_t _unique, eventgroup_t _eventgroup, const subscription_handler_sec_t &_handler) = 0; /** @@ -1100,7 +1100,7 @@ class application { * */ virtual void register_async_subscription_handler( - service_t _service, instance_t _instance, eventgroup_t _eventgroup, + service_t _service, unique_version_t _unique, eventgroup_t _eventgroup, async_subscription_handler_sec_t _handler) = 0; /** diff --git a/interface/vsomeip/handler.hpp b/interface/vsomeip/handler.hpp index f95ed7b0d..35dcc55a4 100644 --- a/interface/vsomeip/handler.hpp +++ b/interface/vsomeip/handler.hpp @@ -32,7 +32,7 @@ VSOMEIP_DEPRECATED_UID_GID typedef std::function< void (client_t, uid_t, gid_t, VSOMEIP_DEPRECATED_UID_GID typedef std::function< void (client_t, uid_t, gid_t, const std::string &, bool, std::function< void (const bool) > )> async_subscription_handler_ext_t; -typedef std::function< void (const std::vector> &_services) > offered_services_handler_t; +typedef std::function< void (const std::vector> &_services) > offered_services_handler_t; typedef std::function< void () > watchdog_handler_t; /* diff --git a/interface/vsomeip/primitive_types.hpp b/interface/vsomeip/primitive_types.hpp index a609f33ff..6f0809b32 100644 --- a/interface/vsomeip/primitive_types.hpp +++ b/interface/vsomeip/primitive_types.hpp @@ -22,6 +22,7 @@ typedef uint16_t method_t; typedef uint16_t event_t; typedef uint16_t instance_t; +typedef uint32_t unique_version_t; typedef uint16_t eventgroup_t; typedef uint8_t major_version_t; @@ -56,6 +57,18 @@ typedef std::uint32_t pending_remote_offer_id_t; typedef std::uint32_t pending_security_update_id_t; +inline unique_version_t get_unique_version(instance_t _instance, major_version_t _major) { + return static_cast((static_cast(_major << sizeof(instance_t) * 8)) | _instance); +} + +inline major_version_t get_major_from_unique(unique_version_t _unique) { + return static_cast((_unique >> sizeof(instance_t) * 8)); +} + +inline instance_t get_instance_from_unique(unique_version_t _unique) { + return static_cast(_unique & ((1U << (sizeof(instance_t) * 8)) - 1)); +} + #if defined(_WIN32) typedef std::uint32_t uid_t; typedef std::uint32_t gid_t; diff --git a/interface/vsomeip/trace.hpp b/interface/vsomeip/trace.hpp index 016dc5a7e..2bb715ad0 100644 --- a/interface/vsomeip/trace.hpp +++ b/interface/vsomeip/trace.hpp @@ -39,7 +39,7 @@ extern const char *VSOMEIP_TC_DEFAULT_CHANNEL_ID; * \brief Filters contain at least one match that specified * which messages are filtered. */ -typedef std::tuple match_t; +typedef std::tuple match_t; /** * \brief Representation of a DLT trace channel.