summaryrefslogtreecommitdiff
path: root/implementation/routing/include
diff options
context:
space:
mode:
Diffstat (limited to 'implementation/routing/include')
-rw-r--r--implementation/routing/include/event.hpp50
-rw-r--r--implementation/routing/include/eventgroupinfo.hpp4
-rw-r--r--implementation/routing/include/function_types.hpp7
-rw-r--r--implementation/routing/include/remote_subscription.hpp3
-rw-r--r--implementation/routing/include/routing_host.hpp13
-rw-r--r--implementation/routing/include/routing_manager.hpp43
-rw-r--r--implementation/routing/include/routing_manager_adapter.hpp2
-rw-r--r--implementation/routing/include/routing_manager_base.hpp126
-rw-r--r--implementation/routing/include/routing_manager_client.hpp (renamed from implementation/routing/include/routing_manager_proxy.hpp)107
-rw-r--r--implementation/routing/include/routing_manager_host.hpp30
-rw-r--r--implementation/routing/include/routing_manager_impl.hpp155
-rw-r--r--implementation/routing/include/routing_manager_stub.hpp136
-rw-r--r--implementation/routing/include/routing_manager_stub_host.hpp96
-rw-r--r--implementation/routing/include/serviceinfo.hpp8
-rw-r--r--implementation/routing/include/types.hpp18
15 files changed, 513 insertions, 285 deletions
diff --git a/implementation/routing/include/event.hpp b/implementation/routing/include/event.hpp
index b22b6ed..97adb89 100644
--- a/implementation/routing/include/event.hpp
+++ b/implementation/routing/include/event.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -13,7 +13,6 @@
#include <set>
#include <atomic>
-#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/address.hpp>
#include <boost/asio/steady_timer.hpp>
@@ -35,6 +34,8 @@ class message;
class payload;
class routing_manager;
+struct debounce_filter_t;
+
class event
: public std::enable_shared_from_this<event> {
public:
@@ -52,16 +53,19 @@ public:
event_t get_event() const;
void set_event(event_t _event);
- const std::shared_ptr<payload> get_payload() const;
+ std::shared_ptr<payload> get_payload() const;
void set_payload(const std::shared_ptr<payload> &_payload,
const client_t _client, bool _force);
void set_payload(const std::shared_ptr<payload> &_payload,
const client_t _client,
- const std::shared_ptr<endpoint_definition>& _target, bool _force);
+ const std::shared_ptr<endpoint_definition>& _target);
+
+ bool prepare_update_payload(const std::shared_ptr<payload> &_payload,
+ bool _force);
+ void update_payload();
- bool set_payload_dont_notify(const std::shared_ptr<payload> &_payload);
bool set_payload_notify_pending(const std::shared_ptr<payload> &_payload);
void set_payload(const std::shared_ptr<payload> &_payload, bool _force);
@@ -90,20 +94,25 @@ public:
void set_epsilon_change_function(
const epsilon_change_func_t &_epsilon_change_func);
- const std::set<eventgroup_t> get_eventgroups() const;
+ std::set<eventgroup_t> get_eventgroups() const;
std::set<eventgroup_t> get_eventgroups(client_t _client) const;
void add_eventgroup(eventgroup_t _eventgroup);
void set_eventgroups(const std::set<eventgroup_t> &_eventgroups);
void notify_one(client_t _client,
const std::shared_ptr<endpoint_definition> &_target);
- void notify_one(client_t _client);
+ void notify_one(client_t _client, bool _force);
- bool add_subscriber(eventgroup_t _eventgroup, client_t _client, bool _force);
+ bool add_subscriber(eventgroup_t _eventgroup,
+ const std::shared_ptr<debounce_filter_t> &_filter,
+ client_t _client, bool _force);
void remove_subscriber(eventgroup_t _eventgroup, client_t _client);
bool has_subscriber(eventgroup_t _eventgroup, client_t _client);
std::set<client_t> get_subscribers();
+ std::set<client_t> get_filtered_subscribers(bool _force);
+ std::set<client_t> update_and_get_filtered_subscribers(
+ const std::shared_ptr<payload> &_payload, bool _force);
VSOMEIP_EXPORT std::set<client_t> get_subscribers(eventgroup_t _eventgroup);
void clear_subscribers();
@@ -122,30 +131,34 @@ public:
void remove_pending(const std::shared_ptr<endpoint_definition> &_target);
+ void set_session();
+
private:
void update_cbk(boost::system::error_code const &_error);
- void notify();
+ void notify(bool _force);
void notify(client_t _client,
const std::shared_ptr<endpoint_definition> &_target);
void start_cycle();
void stop_cycle();
- bool compare(const std::shared_ptr<payload> &_lhs,
+ bool has_changed(const std::shared_ptr<payload> &_lhs,
const std::shared_ptr<payload> &_rhs) const;
- bool set_payload_helper(const std::shared_ptr<payload> &_payload,
- bool _force);
- void reset_payload(const std::shared_ptr<payload> &_payload);
-
- void notify_one_unlocked(client_t _client);
+ void notify_one_unlocked(client_t _client, bool _force);
void notify_one_unlocked(client_t _client,
const std::shared_ptr<endpoint_definition> &_target);
+ bool prepare_update_payload_unlocked(
+ const std::shared_ptr<payload> &_payload, bool _force);
+ void update_payload_unlocked();
+
private:
routing_manager *routing_;
mutable std::mutex mutex_;
- std::shared_ptr<message> message_;
+
+ std::shared_ptr<message> current_;
+ std::shared_ptr<message> update_;
std::atomic<event_type_e> type_;
@@ -172,6 +185,11 @@ private:
std::atomic<reliability_type_e> reliability_;
std::set<std::shared_ptr<endpoint_definition> > pending_;
+
+ std::mutex filters_mutex_;
+ std::map<client_t, epsilon_change_func_t> filters_;
+ std::mutex last_forwarded_mutex_;
+ std::map<client_t, std::chrono::steady_clock::time_point> last_forwarded_;
};
} // namespace vsomeip_v3
diff --git a/implementation/routing/include/eventgroupinfo.hpp b/implementation/routing/include/eventgroupinfo.hpp
index 8ec1ac6..1a5a1b9 100644
--- a/implementation/routing/include/eventgroupinfo.hpp
+++ b/implementation/routing/include/eventgroupinfo.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -67,7 +67,7 @@ public:
uint16_t _port);
VSOMEIP_EXPORT bool is_sending_multicast() const;
- VSOMEIP_EXPORT const std::set<std::shared_ptr<event> > get_events() const;
+ VSOMEIP_EXPORT std::set<std::shared_ptr<event> > get_events() const;
VSOMEIP_EXPORT void add_event(const std::shared_ptr<event>& _event);
VSOMEIP_EXPORT void remove_event(const std::shared_ptr<event>& _event);
VSOMEIP_EXPORT reliability_type_e get_reliability() const;
diff --git a/implementation/routing/include/function_types.hpp b/implementation/routing/include/function_types.hpp
index 3f89c08..f74ff37 100644
--- a/implementation/routing/include/function_types.hpp
+++ b/implementation/routing/include/function_types.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2018-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -10,9 +10,8 @@ namespace vsomeip_v3 {
class remote_subscription;
-typedef std::function<
- void (const std::shared_ptr<remote_subscription> &_subscription)
-> remote_subscription_callback_t;
+using remote_subscription_callback_t =
+ std::function<void (const std::shared_ptr<remote_subscription> &_subscription)>;
} // namespace vsomeip_v3
diff --git a/implementation/routing/include/remote_subscription.hpp b/implementation/routing/include/remote_subscription.hpp
index ff94d5b..f5bf2a2 100644
--- a/implementation/routing/include/remote_subscription.hpp
+++ b/implementation/routing/include/remote_subscription.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2018-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -100,7 +100,6 @@ private:
std::weak_ptr<eventgroupinfo> eventgroupinfo_;
- major_version_t major_;
ttl_t ttl_;
std::uint16_t reserved_;
std::uint8_t counter_;
diff --git a/implementation/routing/include/routing_host.hpp b/implementation/routing/include/routing_host.hpp
index 337e4a7..1decea3 100644
--- a/implementation/routing/include/routing_host.hpp
+++ b/implementation/routing/include/routing_host.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -11,6 +11,7 @@
#include <boost/asio/ip/address.hpp>
#include <vsomeip/primitive_types.hpp>
+#include <vsomeip/vsomeip_sec.h>
#ifdef ANDROID
#include "../../configuration/include/internal_android.hpp"
@@ -28,15 +29,19 @@ public:
virtual void on_message(const byte_t *_data, length_t _length,
endpoint *_receiver,
- const boost::asio::ip::address &_destination =
- boost::asio::ip::address(),
+ bool _is_multicast = false,
client_t _bound_client = VSOMEIP_ROUTING_CLIENT,
- credentials_t _credentials = {ANY_UID, ANY_GID},
+ const vsomeip_sec_client_t *_sec_client = nullptr,
const boost::asio::ip::address &_remote_address =
boost::asio::ip::address(),
std::uint16_t _remote_port = 0) = 0;
virtual client_t get_client() const = 0;
+ virtual void add_known_client(client_t _client, const std::string &_client_host) = 0;
+
+ virtual void remove_subscriptions(port_t _local_port,
+ const boost::asio::ip::address &_remote_address,
+ port_t _remote_port) = 0;
};
} // namespace vsomeip_v3
diff --git a/implementation/routing/include/routing_manager.hpp b/implementation/routing/include/routing_manager.hpp
index fa0e675..6fa7693 100644
--- a/implementation/routing/include/routing_manager.hpp
+++ b/implementation/routing/include/routing_manager.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -10,11 +10,19 @@
#include <set>
#include <vector>
-#include <boost/asio/io_service.hpp>
+#if VSOMEIP_BOOST_VERSION < 106600
+# include <boost/asio/io_service.hpp>
+# define io_context io_service
+#else
+# include <boost/asio/io_context.hpp>
+#endif
#include <vsomeip/function_types.hpp>
+#include <vsomeip/structured_types.hpp>
#include <vsomeip/message.hpp>
#include <vsomeip/handler.hpp>
+#include <vsomeip/vsomeip_sec.h>
+
#include "types.hpp"
namespace vsomeip_v3 {
@@ -30,10 +38,12 @@ public:
virtual ~routing_manager() {
}
- virtual boost::asio::io_service & get_io() = 0;
+ virtual boost::asio::io_context &get_io() = 0;
virtual client_t get_client() const = 0;
- virtual void set_client(const client_t &_client) = 0;
- virtual session_t get_session() = 0;
+// virtual void set_client(const client_t &_client) = 0;
+ virtual session_t get_session(bool _is_request) = 0;
+
+ virtual const vsomeip_sec_client_t *get_sec_client() const = 0;
virtual void init() = 0;
virtual void start() = 0;
@@ -54,24 +64,29 @@ public:
virtual void release_service(client_t _client, service_t _service,
instance_t _instance) = 0;
- virtual void subscribe(client_t _client, uid_t _uid, gid_t _gid, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup,
- major_version_t _major, event_t _event) = 0;
+ virtual void subscribe(client_t _client, const vsomeip_sec_client_t *_sec_client,
+ service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup, major_version_t _major,
+ event_t _event, const std::shared_ptr<debounce_filter_t> &_filter) = 0;
- virtual void unsubscribe(client_t _client, uid_t _uid, gid_t _gid, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup, event_t _event) = 0;
+ virtual void unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client,
+ service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup, event_t _event) = 0;
- virtual bool send(client_t _client, std::shared_ptr<message> _message) = 0;
+ virtual bool send(client_t _client, std::shared_ptr<message> _message,
+ bool _force) = 0;
virtual bool send(client_t _client, const byte_t *_data, uint32_t _size,
instance_t _instance, bool _reliable,
client_t _bound_client = VSOMEIP_ROUTING_CLIENT,
- credentials_t _credentials = {ANY_UID, ANY_GID},
- uint8_t _status_check = 0, bool _sent_from_remote = false) = 0;
+ const vsomeip_sec_client_t *_sec_client = nullptr,
+ uint8_t _status_check = 0,
+ bool _sent_from_remote = false,
+ bool _force = true) = 0;
virtual bool send_to(const client_t _client,
const std::shared_ptr<endpoint_definition> &_target,
- std::shared_ptr<message>) = 0;
+ std::shared_ptr<message> _message) = 0;
virtual bool send_to(const std::shared_ptr<endpoint_definition> &_target,
const byte_t *_data, uint32_t _size, instance_t _instance) = 0;
diff --git a/implementation/routing/include/routing_manager_adapter.hpp b/implementation/routing/include/routing_manager_adapter.hpp
index a2195ee..26154b0 100644
--- a/implementation/routing/include/routing_manager_adapter.hpp
+++ b/implementation/routing/include/routing_manager_adapter.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
diff --git a/implementation/routing/include/routing_manager_base.hpp b/implementation/routing/include/routing_manager_base.hpp
index 270f4c4..e4f9073 100644
--- a/implementation/routing/include/routing_manager_base.hpp
+++ b/implementation/routing/include/routing_manager_base.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -12,16 +12,19 @@
#include <condition_variable>
#include <vsomeip/constants.hpp>
+#include <vsomeip/vsomeip_sec.h>
-#include "routing_host.hpp"
-#include "routing_manager.hpp"
-#include "routing_manager_host.hpp"
#include "types.hpp"
-#include "serviceinfo.hpp"
#include "event.hpp"
+#include "serviceinfo.hpp"
+#include "routing_host.hpp"
#include "eventgroupinfo.hpp"
+#include "routing_manager.hpp"
+#include "routing_manager_host.hpp"
+
#include "../../message/include/serializer.hpp"
#include "../../message/include/deserializer.hpp"
+#include "../../protocol/include/protocol.hpp"
#include "../../configuration/include/configuration.hpp"
#include "../../endpoints/include/endpoint_manager_base.hpp"
@@ -43,10 +46,19 @@ public:
routing_manager_base(routing_manager_host *_host);
virtual ~routing_manager_base() = default;
- virtual boost::asio::io_service & get_io();
+ virtual boost::asio::io_context &get_io();
virtual client_t get_client() const;
+
+ virtual std::string get_client_host() const;
+ virtual void set_client_host(const std::string &_client_host);
virtual void set_client(const client_t &_client);
- virtual session_t get_session();
+ virtual session_t get_session(bool _is_request);
+
+ virtual const vsomeip_sec_client_t *get_sec_client() const;
+
+ virtual std::string get_env(client_t _client) const = 0;
+
+ virtual bool is_routing_manager() const;
virtual void init() = 0;
void init(const std::shared_ptr<endpoint_manager_base>& _endpoint_manager);
@@ -83,11 +95,14 @@ public:
virtual std::set<std::shared_ptr<event>> find_events(service_t _service,
instance_t _instance, eventgroup_t _eventgroup) const;
- virtual void subscribe(client_t _client, uid_t _uid, gid_t _gid,
+ virtual void subscribe(client_t _client,
+ const vsomeip_sec_client_t *_sec_client,
service_t _service, instance_t _instance,
- eventgroup_t _eventgroup, major_version_t _major, event_t _event);
+ eventgroup_t _eventgroup, major_version_t _major,
+ event_t _event, const std::shared_ptr<debounce_filter_t> &_filter);
- virtual void unsubscribe(client_t _client, uid_t _uid, gid_t _gid,
+ virtual void unsubscribe(client_t _client,
+ const vsomeip_sec_client_t *_sec_client,
service_t _service, instance_t _instance,
eventgroup_t _eventgroup, event_t _event);
@@ -102,23 +117,22 @@ public:
#endif
);
- virtual bool send(client_t _client, std::shared_ptr<message> _message);
+ virtual bool send(client_t _client, std::shared_ptr<message> _message,
+ bool _force);
virtual bool send(client_t _client, const byte_t *_data, uint32_t _size,
instance_t _instance, bool _reliable,
- client_t _bound_client = VSOMEIP_ROUTING_CLIENT,
- credentials_t _credentials = {ANY_UID, ANY_GID},
- uint8_t _status_check = 0, bool _sent_from_remote = false) = 0;
+ client_t _bound_client, const vsomeip_sec_client_t *_sec_client,
+ uint8_t _status_check, bool _sent_from_remote,
+ bool _force) = 0;
// routing host -> will be implemented by routing_manager_impl/_proxy/
virtual void on_message(const byte_t *_data, length_t _length,
- endpoint *_receiver, const boost::asio::ip::address &_destination
- = boost::asio::ip::address(), client_t _bound_client = VSOMEIP_ROUTING_CLIENT,
- credentials_t _credentials = {ANY_UID, ANY_GID},
- const boost::asio::ip::address &_remote_address = boost::asio::ip::address(),
+ endpoint *_receiver, bool _is_multicast,
+ client_t _bound_client, const vsomeip_sec_client_t *_sec_client,
+ const boost::asio::ip::address &_remote_address,
std::uint16_t _remote_port = 0) = 0;
-
virtual void set_routing_state(routing_state_e _routing_state) = 0;
virtual routing_state_e get_routing_state();
@@ -138,6 +152,17 @@ public:
std::shared_ptr<event> find_event(service_t _service, instance_t _instance,
event_t _event) const;
+ // address data for vsomeip routing via TCP
+ bool get_guest(client_t _client, boost::asio::ip::address &_address,
+ port_t &_port) const;
+ void add_guest(client_t _client, const boost::asio::ip::address &_address,
+ port_t _port);
+ void remove_guest(client_t _client);
+
+ void remove_subscriptions(port_t _local_port,
+ const boost::asio::ip::address &_remote_address,
+ port_t _remote_port);
+
virtual void on_connect(const std::shared_ptr<endpoint>& _endpoint) = 0;
virtual void on_disconnect(const std::shared_ptr<endpoint>& _endpoint) = 0;
protected:
@@ -150,10 +175,12 @@ protected:
services_t get_services_remote() const;
bool is_available(service_t _service, instance_t _instance, major_version_t _major);
- void remove_local(client_t _client, bool _remove_uid);
+ void remove_local(client_t _client, bool _remove_sec_client);
void remove_local(client_t _client,
- const std::set<std::tuple<service_t, instance_t, eventgroup_t>>& _subscribed_eventgroups,
- bool _remove_uid);
+ const std::set<
+ std::tuple<service_t, instance_t, eventgroup_t>
+ > &_subscribed_eventgroups,
+ bool _remove_sec_client);
std::shared_ptr<eventgroupinfo> find_eventgroup(service_t _service,
instance_t _instance, eventgroup_t _eventgroup) const;
@@ -163,15 +190,16 @@ protected:
bool send_local_notification(client_t _client,
const byte_t *_data, uint32_t _size, instance_t _instance,
- bool _reliable = false, uint8_t _status_check = 0);
+ bool _reliable, uint8_t _status_check, bool _force);
bool send_local(
std::shared_ptr<endpoint> &_target, client_t _client,
const byte_t *_data, uint32_t _size, instance_t _instance,
- bool _reliable, uint8_t _command, uint8_t _status_check = 0) const;
+ bool _reliable, protocol::id_e _command, uint8_t _status_check) const;
bool insert_subscription(service_t _service, instance_t _instance,
- eventgroup_t _eventgroup, event_t _event, client_t _client,
+ eventgroup_t _eventgroup, event_t _event,
+ const std::shared_ptr<debounce_filter_t> &_filter, client_t _client,
std::set<event_t> *_already_subscribed_events);
std::shared_ptr<serializer> get_serializer();
@@ -182,9 +210,10 @@ protected:
void send_pending_subscriptions(service_t _service,
instance_t _instance, major_version_t _major);
- virtual void send_subscribe(client_t _client, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup,
- major_version_t _major, event_t _event) = 0;
+ virtual void send_subscribe(client_t _client,
+ service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup, major_version_t _major,
+ event_t _event, const std::shared_ptr<debounce_filter_t> &_filter) = 0;
void remove_pending_subscription(service_t _service, instance_t _instance,
eventgroup_t _eventgroup, event_t _event);
@@ -209,9 +238,11 @@ protected:
bool is_response_allowed(client_t _sender, service_t _service,
instance_t _instance, method_t _method);
- bool is_subscribe_to_any_event_allowed(credentials_t _credentials, client_t _client,
+ 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);
- void unsubscribe_all(service_t _service, instance_t _instance);
+
+ 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,
@@ -227,12 +258,12 @@ protected:
private:
virtual bool create_placeholder_event_and_subscribe(
service_t _service, instance_t _instance, eventgroup_t _eventgroup,
- event_t _event, client_t _client) = 0;
+ event_t _event, const std::shared_ptr<debounce_filter_t> &_filter,
+ client_t _client) = 0;
protected:
routing_manager_host *host_;
- boost::asio::io_service &io_;
- std::atomic<client_t> client_;
+ boost::asio::io_context &io_;
std::shared_ptr<configuration> configuration_;
@@ -245,8 +276,9 @@ protected:
std::condition_variable deserializer_condition_;
mutable std::mutex local_services_mutex_;
- typedef std::map<service_t, std::map<instance_t,
- std::tuple<major_version_t, minor_version_t, client_t>>> local_services_map_t;
+ using local_services_map_t =
+ std::map<service_t, std::map<instance_t,
+ std::tuple<major_version_t, minor_version_t, client_t>>>;
local_services_map_t local_services_;
std::map<service_t, std::map<instance_t, std::set<client_t> > > local_services_history_;
@@ -264,9 +296,6 @@ protected:
std::mutex event_registration_mutex_;
- std::mutex routing_state_mutex_;
- routing_state_e routing_state_;
-
#ifdef USE_DLT
std::shared_ptr<trace::connector_impl> tc_;
#endif
@@ -277,8 +306,8 @@ protected:
eventgroup_t eventgroup_;
major_version_t major_;
event_t event_;
- uid_t uid_;
- gid_t gid_;
+ std::shared_ptr<debounce_filter_t> filter_;
+ vsomeip_sec_client_t sec_client_;
bool operator<(const subscription_data_t &_other) const {
return (service_ < _other.service_
@@ -300,13 +329,26 @@ protected:
std::shared_ptr<endpoint_manager_base> ep_mgr_;
- std::uint32_t own_uid_;
- std::uint32_t own_gid_;
+ mutable std::mutex known_clients_mutex_;
+ std::map<client_t, std::string> known_clients_;
+
+ mutable std::mutex env_mutex_;
+ std::string env_;
+
+ std::mutex routing_state_mutex_;
+ routing_state_e routing_state_;
private:
services_t services_;
mutable std::mutex services_mutex_;
+ mutable std::mutex guests_mutex_;
+ std::map<client_t,
+ std::pair<boost::asio::ip::address, port_t>
+ > guests_;
+
+ std::mutex add_known_client_mutex_;
+
#ifdef VSOMEIP_ENABLE_COMPAT
std::map<service_t,
std::map<instance_t,
diff --git a/implementation/routing/include/routing_manager_proxy.hpp b/implementation/routing/include/routing_manager_client.hpp
index 2b5335a..fb56ec7 100644
--- a/implementation/routing/include/routing_manager_proxy.hpp
+++ b/implementation/routing/include/routing_manager_client.hpp
@@ -1,41 +1,53 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef VSOMEIP_V3_ROUTING_MANAGER_PROXY_HPP
-#define VSOMEIP_V3_ROUTING_MANAGER_PROXY_HPP
+#ifndef VSOMEIP_V3_ROUTING_MANAGER_CLIENT_HPP
+#define VSOMEIP_V3_ROUTING_MANAGER_CLIENT_HPP
#include <map>
#include <mutex>
#include <atomic>
#include <tuple>
-#include <boost/asio/io_service.hpp>
#include <boost/asio/steady_timer.hpp>
-#include "routing_manager_base.hpp"
-#include "types.hpp"
#include <vsomeip/enumeration_types.hpp>
#include <vsomeip/handler.hpp>
+#include "routing_manager_base.hpp"
+#include "types.hpp"
+#include "../../protocol/include/protocol.hpp"
+
namespace vsomeip_v3 {
class configuration;
class event;
+#ifdef __linux__
+class netlink_connector;
+#endif
class routing_manager_host;
-class routing_manager_proxy: public routing_manager_base {
+namespace protocol {
+ class offered_services_response_command;
+ class update_security_credentials_command;
+}
+
+class routing_manager_client
+ : public routing_manager_base {
public:
- routing_manager_proxy(routing_manager_host *_host, bool _client_side_logging,
+ routing_manager_client(routing_manager_host *_host, bool _client_side_logging,
const std::set<std::tuple<service_t, instance_t> > & _client_side_logging_filter);
- virtual ~routing_manager_proxy();
+ virtual ~routing_manager_client();
void init();
void start();
void stop();
std::shared_ptr<configuration> get_configuration() const;
+ std::string get_env(client_t _client) const;
+ std::string get_env_unlocked(client_t _client) const;
bool offer_service(client_t _client,
service_t _service, instance_t _instance,
@@ -52,20 +64,20 @@ public:
void release_service(client_t _client,
service_t _service, instance_t _instance);
- void subscribe(client_t _client, uid_t _uid, gid_t _gid,
+ void subscribe(client_t _client, const vsomeip_sec_client_t *_sec_client,
service_t _service, instance_t _instance,
eventgroup_t _eventgroup, major_version_t _major,
- event_t _event);
+ event_t _event, const std::shared_ptr<debounce_filter_t> &_filter);
- void unsubscribe(client_t _client, uid_t _uid, gid_t _gid,
+ void unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client,
service_t _service, instance_t _instance,
eventgroup_t _eventgroup, event_t _event);
bool send(client_t _client, const byte_t *_data, uint32_t _size,
instance_t _instance, bool _reliable,
- client_t _bound_client = VSOMEIP_ROUTING_CLIENT,
- credentials_t _credentials = {ANY_UID, ANY_GID},
- uint8_t _status_check = 0, bool _sent_from_remote = false);
+ client_t _bound_client, const vsomeip_sec_client_t *_sec_client,
+ uint8_t _status_check, bool _sent_from_remote,
+ bool _force);
bool send_to(const client_t _client,
const std::shared_ptr<endpoint_definition> &_target,
@@ -91,9 +103,8 @@ public:
void on_connect(const std::shared_ptr<endpoint>& _endpoint);
void on_disconnect(const std::shared_ptr<endpoint>& _endpoint);
void on_message(const byte_t *_data, length_t _size, endpoint *_receiver,
- const boost::asio::ip::address &_destination,
- client_t _bound_client,
- credentials_t _credentials,
+ bool _is_multicast,
+ client_t _bound_client, const vsomeip_sec_client_t *_sec_client,
const boost::asio::ip::address &_remote_address,
std::uint16_t _remote_port);
@@ -103,7 +114,7 @@ public:
const std::shared_ptr<endpoint> &_endpoint);
void handle_client_error(client_t _client);
- void on_offered_services_info(const byte_t *_data, uint32_t _size);
+ void on_offered_services_info(protocol::offered_services_response_command &_command);
void send_get_offered_services_info(client_t _client, offer_type_e _offer_type);
@@ -112,23 +123,30 @@ private:
void register_application();
void deregister_application();
- void reconnect(const std::unordered_set<client_t> &_clients);
+ void reconnect(const std::map<client_t, std::string> &_clients);
void send_pong() const;
+
void send_offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major,
minor_version_t _minor);
+
void send_release_service(client_t _client,
service_t _service, instance_t _instance);
+
+ void send_pending_event_registrations(client_t _client);
+
void send_register_event(client_t _client,
service_t _service, instance_t _instance,
event_t _notifier,
const std::set<eventgroup_t> &_eventgroups,
const event_type_e _type, reliability_type_e _reliability,
- bool _is_provided);
- void send_subscribe(client_t _client, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup,
- major_version_t _major, event_t _event);
+ bool _is_provided, bool _is_cyclic);
+
+ void send_subscribe(client_t _client,
+ service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup, major_version_t _major,
+ event_t _event, const std::shared_ptr<debounce_filter_t> &_filter);
void send_subscribe_nack(client_t _subscriber, service_t _service,
instance_t _instance, eventgroup_t _eventgroup, event_t _event,
@@ -176,12 +194,13 @@ private:
bool is_client_known(client_t _client);
bool create_placeholder_event_and_subscribe(
- service_t _service, instance_t _instance,
- eventgroup_t _eventgroup, event_t _notifier, client_t _client);
+ service_t _service, instance_t _instance, eventgroup_t _eventgroup,
+ event_t _notifier, const std::shared_ptr<debounce_filter_t> &_filter,
+ client_t _client);
void request_debounce_timeout_cbk(boost::system::error_code const &_error);
- void send_request_services(std::set<service_data_t>& _requests);
+ void send_request_services(const std::set<protocol::service> &_requests);
void send_unsubscribe_ack(service_t _service, instance_t _instance,
eventgroup_t _eventgroup, remote_subscription_id_t _id);
@@ -189,14 +208,23 @@ private:
void resend_provided_event_registrations();
void send_resend_provided_event_response(pending_remote_offer_id_t _id);
+#ifndef VSOMEIP_DISABLE_SECURITY
void send_update_security_policy_response(pending_security_update_id_t _update_id);
void send_remove_security_policy_response(pending_security_update_id_t _update_id);
- void on_update_security_credentials(const byte_t *_data, uint32_t _size);
+ void on_update_security_credentials(const protocol::update_security_credentials_command &_command);
+#endif
void on_client_assign_ack(const client_t &_client);
+ port_t get_routing_port();
+
void on_suspend();
+#if defined(__linux__) || defined(ANDROID)
+ void on_net_state_change(bool _is_interface, const std::string &_name, bool _is_available);
+#endif
+
private:
+
enum class inner_state_type_e : std::uint8_t {
ST_REGISTERED = 0x0,
ST_DEREGISTERED = 0x1,
@@ -212,12 +240,9 @@ private:
std::shared_ptr<endpoint> sender_; // --> stub
std::shared_ptr<endpoint> receiver_; // --> from everybody
- std::mutex known_clients_mutex_;
- std::unordered_set<client_t> known_clients_;
-
- std::set<service_data_t> pending_offers_;
- std::set<service_data_t> requests_;
- std::set<service_data_t> requests_to_debounce_;
+ std::set<protocol::service> pending_offers_;
+ std::set<protocol::service> requests_;
+ std::set<protocol::service> requests_to_debounce_;
struct event_data_t {
service_t service_;
@@ -226,19 +251,20 @@ private:
event_type_e type_;
reliability_type_e reliability_;
bool is_provided_;
+ bool is_cyclic_;
std::set<eventgroup_t> eventgroups_;
bool operator<(const event_data_t &_other) const {
return std::tie(service_, instance_, notifier_,
- type_, reliability_, is_provided_, eventgroups_)
+ type_, reliability_, is_provided_, is_cyclic_, eventgroups_)
< std::tie(_other.service_, _other.instance_,
_other.notifier_, _other.type_, _other.reliability_,
- _other.is_provided_, _other.eventgroups_);
+ _other.is_provided_, _other.is_cyclic_, _other.eventgroups_);
}
};
std::set<event_data_t> pending_event_registrations_;
- std::map<client_t, std::set<subscription_data_t>> pending_incoming_subscripitons_;
+ std::map<client_t, std::set<subscription_data_t>> pending_incoming_subscriptions_;
std::recursive_mutex incoming_subscriptions_mutex_;
std::mutex state_mutex_;
@@ -260,8 +286,13 @@ private:
const std::set<std::tuple<service_t, instance_t> > client_side_logging_filter_;
std::mutex stop_mutex_;
+
+#if defined(__linux__) || defined(ANDROID)
+ std::shared_ptr<netlink_connector> local_link_connector_;
+ bool is_local_link_available_;
+#endif
};
} // namespace vsomeip_v3
-#endif // VSOMEIP_V3_ROUTING_MANAGER_PROXY_HPP_
+#endif // VSOMEIP_V3_ROUTING_MANAGER_CLIENT_HPP_
diff --git a/implementation/routing/include/routing_manager_host.hpp b/implementation/routing/include/routing_manager_host.hpp
index 69133e2..18a74af 100644
--- a/implementation/routing/include/routing_manager_host.hpp
+++ b/implementation/routing/include/routing_manager_host.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -8,9 +8,15 @@
#include <memory>
-#include <boost/asio/io_service.hpp>
+#if VSOMEIP_BOOST_VERSION < 106600
+# include <boost/asio/io_service.hpp>
+# define io_context io_service
+#else
+# include <boost/asio/io_context.hpp>
+#endif
#include <vsomeip/error.hpp>
+#include <vsomeip/vsomeip_sec.h>
namespace vsomeip_v3 {
@@ -24,22 +30,30 @@ public:
virtual client_t get_client() const = 0;
virtual void set_client(const client_t &_client) = 0;
- virtual session_t get_session() = 0;
+ virtual session_t get_session(bool _is_request) = 0;
+
+ virtual const vsomeip_sec_client_t *get_sec_client() const = 0;
+
virtual const std::string & get_name() const = 0;
virtual std::shared_ptr<configuration> get_configuration() const = 0;
- virtual boost::asio::io_service & get_io() = 0;
+ virtual boost::asio::io_context &get_io() = 0;
virtual void on_availability(service_t _service, instance_t _instance,
- bool _is_available, major_version_t _major = DEFAULT_MAJOR, minor_version_t _minor = DEFAULT_MINOR) = 0;
+ availability_state_e _state,
+ major_version_t _major = DEFAULT_MAJOR,
+ minor_version_t _minor = DEFAULT_MINOR) = 0;
virtual void on_state(state_type_e _state) = 0;
virtual void on_message(std::shared_ptr<message> &&_message) = 0;
virtual void on_subscription(service_t _service, instance_t _instance,
- eventgroup_t _eventgroup, client_t _client, uid_t _uid, gid_t _gid, bool _subscribed,
- std::function<void(bool)> _accepted_cb) = 0;
+ eventgroup_t _eventgroup,
+ client_t _client, const vsomeip_sec_client_t *_sec_client,
+ const std::string &_env, bool _subscribed,
+ const std::function<void(bool)> &_accepted_cb) = 0;
virtual void on_subscription_status(service_t _service, instance_t _instance,
eventgroup_t _eventgroup, event_t _event, uint16_t _error) = 0;
virtual void send(std::shared_ptr<message> _message) = 0;
- virtual void on_offered_services_info(std::vector<std::pair<service_t, instance_t>> &_services) = 0;
+ virtual void on_offered_services_info(
+ std::vector<std::pair<service_t, instance_t>> &_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 3fd6eed..3c105c2 100644
--- a/implementation/routing/include/routing_manager_impl.hpp
+++ b/implementation/routing/include/routing_manager_impl.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2018 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -14,7 +14,6 @@
#include <unordered_set>
#include <boost/asio/ip/address.hpp>
-#include <boost/asio/io_service.hpp>
#include <boost/asio/steady_timer.hpp>
#include <vsomeip/primitive_types.hpp>
@@ -36,7 +35,6 @@ class deserializer;
class eventgroupinfo;
class routing_manager_host;
class routing_manager_stub;
-class servicegroup;
class serializer;
class service_endpoint;
@@ -55,8 +53,13 @@ public:
routing_manager_impl(routing_manager_host *_host);
~routing_manager_impl();
- boost::asio::io_service & get_io();
+ boost::asio::io_context &get_io();
client_t get_client() const;
+ const vsomeip_sec_client_t *get_sec_client() const;
+ std::string get_client_host() const;
+ void set_client_host(const std::string &_client_host);
+
+ bool is_routing_manager() const;
void init();
void start();
@@ -77,21 +80,23 @@ public:
void release_service(client_t _client,
service_t _service, instance_t _instance);
- void subscribe(client_t _client, uid_t _uid, gid_t _gid,
+ void subscribe(client_t _client, const vsomeip_sec_client_t *_sec_client,
service_t _service, instance_t _instance,
- eventgroup_t _eventgroup, major_version_t _major, event_t _event);
+ eventgroup_t _eventgroup, major_version_t _major,
+ event_t _event, const std::shared_ptr<debounce_filter_t> &_filter);
- void unsubscribe(client_t _client, uid_t _uid, gid_t _gid,
+ void unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client,
service_t _service, instance_t _instance,
eventgroup_t _eventgroup, event_t _event);
- bool send(client_t _client, std::shared_ptr<message> _message);
+ bool send(client_t _client, std::shared_ptr<message> _message,
+ bool _force);
bool send(client_t _client, const byte_t *_data, uint32_t _size,
instance_t _instance, bool _reliable,
- client_t _bound_client = VSOMEIP_ROUTING_CLIENT,
- credentials_t _credentials = {ANY_UID, ANY_GID},
- uint8_t _status_check = 0, bool _sent_from_remote = false);
+ client_t _bound_client, const vsomeip_sec_client_t *_sec_client,
+ uint8_t _status_check, bool _sent_from_remote,
+ bool _force);
bool send_to(const client_t _client,
const std::shared_ptr<endpoint_definition> &_target,
@@ -120,7 +125,7 @@ public:
event_t _notifier,
const std::set<eventgroup_t> &_eventgroups,
event_type_e _type, reliability_type_e _reliability,
- bool _is_provided);
+ bool _is_provided, bool _is_cyclic);
void unregister_shadow_event(client_t _client, service_t _service,
instance_t _instance, event_t _event,
@@ -140,7 +145,7 @@ public:
void on_subscribe_nack(client_t _client, service_t _service,
instance_t _instance, eventgroup_t _eventgroup, event_t _event,
- remote_subscription_id_t _id, bool _simulated);
+ remote_subscription_id_t _id);
// interface to stub
@@ -161,7 +166,7 @@ public:
major_version_t _major, minor_version_t _minor);
void on_availability(service_t _service, instance_t _instance,
- bool _is_available,
+ availability_state_e _state,
major_version_t _major, minor_version_t _minor);
void on_pong(client_t _client);
@@ -178,13 +183,13 @@ public:
void on_disconnect(const std::shared_ptr<endpoint>& _endpoint);
void on_message(const byte_t *_data, length_t _size, endpoint *_receiver,
- const boost::asio::ip::address &_destination,
- client_t _bound_client, credentials_t _credentials,
- const boost::asio::ip::address &_remote_address,
- std::uint16_t _remote_port);
+ bool _is_multicast,
+ 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,
const byte_t *_data, length_t _size, bool _reliable,
- client_t _bound_client, credentials_t _credentials,
+ 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,
@@ -199,8 +204,6 @@ public:
bool _magic_cookies_enabled);
// interface "service_discovery_host"
- typedef std::map<std::string, std::shared_ptr<servicegroup> > servicegroups_t;
- const servicegroups_t & get_servicegroups() const;
std::shared_ptr<eventgroupinfo> find_eventgroup(service_t _service,
instance_t _instance, eventgroup_t _eventgroup) const;
services_t get_offered_services() const;
@@ -285,15 +288,27 @@ public:
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<client_t> find_local_clients(service_t _service, instance_t _instance);
- bool is_subscribe_to_any_event_allowed(credentials_t _credentials, client_t _client,
+ 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);
+#ifndef VSOMEIP_DISABLE_SECURITY
bool update_security_policy_configuration(uint32_t _uid, uint32_t _gid,
const std::shared_ptr<policy> &_policy,
const std::shared_ptr<payload> &_payload,
const security_update_handler_t &_handler);
bool remove_security_policy_configuration(uint32_t _uid, uint32_t _gid,
const security_update_handler_t &_handler);
+#endif
+
+ void add_known_client(client_t _client, const std::string &_client_host);
+
+ void register_message_acceptance_handler(
+ const message_acceptance_handler_t &_handler);
+
+ void remove_subscriptions(port_t _local_port,
+ const boost::asio::ip::address &_remote_address,
+ port_t _remote_port);
private:
bool offer_service(client_t _client,
@@ -307,12 +322,12 @@ private:
bool _must_queue);
bool deliver_message(const byte_t *_data, length_t _size,
- instance_t _instance, bool _reliable, client_t _bound_client,
- credentials_t _credentials,
+ 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,
- const byte_t *_data, length_t _length, bool _reliable, client_t _bound_client,
- credentials_t _credentials,
+ 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);
@@ -351,38 +366,49 @@ private:
bool handle_local_offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major,minor_version_t _minor);
- void send_subscribe(client_t _client, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup,
- major_version_t _major, event_t _event);
+ void send_subscribe(client_t _client,
+ service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup, major_version_t _major,
+ event_t _event, const std::shared_ptr<debounce_filter_t> &_filter);
void on_net_interface_or_route_state_changed(bool _is_interface,
- std::string _if,
+ const std::string &_if,
bool _available);
void start_ip_routing();
- void requested_service_add(client_t _client, service_t _service,
+ void add_requested_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major,
minor_version_t _minor);
- void requested_service_remove(client_t _client, service_t _service,
- instance_t _instance);
-
- void call_sd_endpoint_connected(const boost::system::error_code& _error,
- service_t _service, instance_t _instance,
- const std::shared_ptr<endpoint>& _endpoint,
- std::shared_ptr<boost::asio::steady_timer> _timer);
+ void remove_requested_service(client_t _client, service_t _service,
+ instance_t _instance, major_version_t _major,
+ minor_version_t _minor);
+ std::vector<std::pair<service_t, instance_t>> get_requested_services(client_t _client);
+ std::set<client_t> get_requesters(service_t _service,
+ instance_t _instance, major_version_t _major,
+ minor_version_t _minor);
+ std::set<client_t> get_requesters_unlocked(service_t _service,
+ instance_t _instance, major_version_t _major,
+ minor_version_t _minor);
+ bool has_requester_unlocked(service_t _service,
+ instance_t _instance, major_version_t _major,
+ minor_version_t _minor);
+
+ void call_sd_endpoint_connected(const boost::system::error_code &_error,
+ service_t _service, instance_t _instance,
+ const std::shared_ptr<endpoint> &_endpoint,
+ std::shared_ptr<boost::asio::steady_timer> _timer);
- bool create_placeholder_event_and_subscribe(service_t _service,
- instance_t _instance,
- eventgroup_t _eventgroup,
- event_t _event,
- client_t _client);
+ bool create_placeholder_event_and_subscribe(
+ service_t _service, instance_t _instance, eventgroup_t _eventgroup,
+ event_t _event, const std::shared_ptr<debounce_filter_t> &_filter,
+ client_t _client);
void handle_subscription_state(client_t _client, service_t _service, instance_t _instance,
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 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,
@@ -416,25 +442,48 @@ private:
bool is_last_stop_callback(const uint32_t _callback_id);
+ 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,
method_t _method, length_t _length);
void statistics_log_timer_cbk(boost::system::error_code const & _error);
+ bool get_guest(client_t _client, boost::asio::ip::address &_address,
+ port_t &_port) const;
+ void add_guest(client_t _client, const boost::asio::ip::address &_address,
+ port_t _port);
+ void remove_guest(client_t _client);
+
void send_suspend() const;
+ void clear_local_services();
+
+ bool is_acl_message_allowed(endpoint *_receiver,
+ service_t _service, instance_t _instance,
+ const boost::asio::ip::address &_remote_address) const;
+
private:
std::shared_ptr<routing_manager_stub> stub_;
std::shared_ptr<sd::service_discovery> discovery_;
std::mutex requested_services_mutex_;
- std::map<client_t,
- std::map<service_t,
- std::map<instance_t,
- std::set<std::pair<major_version_t, minor_version_t>>>>> requested_services_;
+ std::map<service_t,
+ std::map<instance_t,
+ std::map<major_version_t,
+ std::map<minor_version_t, std::set<client_t> >
+ >
+ >
+ > requested_services_;
std::mutex remote_subscribers_mutex_;
- std::map<service_t, std::map<instance_t, std::map<client_t,
- std::set<std::shared_ptr<endpoint_definition>>>>> remote_subscribers_;
+ std::map<service_t,
+ std::map<instance_t,
+ std::map<client_t,
+ std::set<std::shared_ptr<endpoint_definition> >
+ >
+ >
+ > remote_subscribers_;
std::shared_ptr<serviceinfo> sd_info_;
@@ -446,7 +495,7 @@ private:
bool routing_running_;
std::mutex pending_sd_offers_mutex_;
std::vector<std::pair<service_t, instance_t>> pending_sd_offers_;
-#ifndef _WIN32
+#if defined(__linux__) || defined(ANDROID)
std::shared_ptr<netlink_connector> netlink_connector_;
#endif
@@ -503,6 +552,8 @@ private:
// synchronize update_remote_subscription() and send_(un)subscription()
std::mutex update_remote_subscription_mutex_;
+
+ message_acceptance_handler_t message_acceptance_handler_;
};
} // namespace vsomeip_v3
diff --git a/implementation/routing/include/routing_manager_stub.hpp b/implementation/routing/include/routing_manager_stub.hpp
index aa5796e..4209eec 100644
--- a/implementation/routing/include/routing_manager_stub.hpp
+++ b/implementation/routing/include/routing_manager_stub.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -16,22 +16,34 @@
#include <atomic>
#include <unordered_set>
-#include <boost/asio/io_service.hpp>
+#if VSOMEIP_BOOST_VERSION < 106600
+# include <boost/asio/io_service.hpp>
+# define io_context io_service
+#else
+# include <boost/asio/io_context.hpp>
+#endif
#include <boost/asio/steady_timer.hpp>
#include <vsomeip/handler.hpp>
-
-#include "../../endpoints/include/endpoint_host.hpp"
-#include "../include/routing_host.hpp"
+#include <vsomeip/vsomeip_sec.h>
#include "types.hpp"
+#include "../include/routing_host.hpp"
+#include "../../endpoints/include/endpoint_host.hpp"
+#include "../../protocol/include/protocol.hpp"
+#include "../../protocol/include/routing_info_entry.hpp"
namespace vsomeip_v3 {
class configuration;
-struct policy;
+#if defined(__linux__) || defined(ANDROID)
+class netlink_connector;
+#endif // __linux__ || ANDROID
class routing_manager_stub_host;
+struct debounce_filter_t;
+struct policy;
+
class routing_manager_stub: public routing_host,
public std::enable_shared_from_this<routing_manager_stub> {
public:
@@ -44,10 +56,9 @@ public:
void start();
void stop();
- void on_message(const byte_t *_data, length_t _size, endpoint *_receiver,
- const boost::asio::ip::address &_destination,
- client_t _bound_client,
- credentials_t _credentials,
+ void on_message(const byte_t *_data, length_t _size,
+ endpoint *_receiver, bool _is_multicast,
+ client_t _bound_client, const vsomeip_sec_client_t *_sec_client,
const boost::asio::ip::address &_remote_address,
std::uint16_t _remote_port);
@@ -56,9 +67,11 @@ public:
void on_stop_offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major, minor_version_t _minor);
- bool send_subscribe(const std::shared_ptr<endpoint>& _target,
- client_t _client, service_t _service, instance_t _instance,
- eventgroup_t _eventgroup, major_version_t _major, event_t _event,
+ bool send_subscribe(
+ const std::shared_ptr<endpoint> &_target, client_t _client,
+ service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup, major_version_t _major,
+ event_t _event, const std::shared_ptr<debounce_filter_t> &_filter,
remote_subscription_id_t _id);
bool send_unsubscribe(const std::shared_ptr<endpoint>& _target,
@@ -85,16 +98,18 @@ public:
bool send_ping(client_t _client);
bool is_registered(client_t _client) const;
client_t get_client() const;
- void handle_credentials(const client_t _client, std::set<service_data_t>& _requests);
- void handle_requests(const client_t _client, std::set<service_data_t>& _requests);
+ void handle_credentials(const client_t _client, std::set<protocol::service> &_requests);
+ void handle_requests(const client_t _client, std::set<protocol::service> &_requests);
- void update_registration(client_t _client, registration_type_e _type);
+ void update_registration(client_t _client, registration_type_e _type,
+ const boost::asio::ip::address &_address, port_t _port);
void print_endpoint_status() const;
bool send_provided_event_resend_request(client_t _client,
pending_remote_offer_id_t _id);
+#ifndef VSOMEIP_DISABLE_SECURITY
bool update_security_policy_configuration(uint32_t _uid, uint32_t _gid,
const std::shared_ptr<policy> &_policy,
const std::shared_ptr<payload> &_payload,
@@ -119,23 +134,29 @@ public:
bool add_requester_policies(uid_t _uid, gid_t _gid,
const std::set<std::shared_ptr<policy> > &_policies);
void remove_requester_policies(uid_t _uid, gid_t _gid);
+#endif // !VSOMEIP_DISABLE_SECURITY
+
+ void add_known_client(client_t _client, const std::string &_client_host);
void send_suspend() const;
+ void remove_subscriptions(port_t _local_port,
+ const boost::asio::ip::address &_remote_address,
+ port_t _remote_port);
+
private:
void broadcast(const std::vector<byte_t> &_command) const;
void on_register_application(client_t _client);
void on_deregister_application(client_t _client);
+ void 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 inform_provider(client_t _hoster, service_t _service,
- instance_t _instance, major_version_t _major, minor_version_t _minor,
- routing_info_entry_e _entry);
void inform_requesters(client_t _hoster, service_t _service,
instance_t _instance, major_version_t _major,
- minor_version_t _minor, routing_info_entry_e _entry,
+ minor_version_t _minor, protocol::routing_info_entry_type_e _entry,
bool _inform_service);
void broadcast_ping() const;
@@ -151,27 +172,35 @@ private:
(void)_routing_state;
};
- bool is_already_connected(client_t _source, client_t _sink);
- void create_client_routing_info(const client_t _target);
- void insert_client_routing_info(client_t _target, routing_info_entry_e _entry,
- client_t _client, service_t _service = ANY_SERVICE,
- instance_t _instance = ANY_INSTANCE,
- major_version_t _major = ANY_MAJOR,
- minor_version_t _minor = ANY_MINOR);
- void send_client_routing_info(const client_t _target);
-
- void create_offered_services_info(const client_t _target);
- void insert_offered_services_info(client_t _target,
- routing_info_entry_e _entry,
- service_t _service,
- instance_t _instance,
- major_version_t _major,
- minor_version_t _minor);
- void send_offered_services_info(const client_t _target);
-
- void create_client_credentials_info(const client_t _target);
- void insert_client_credentials_info(client_t _target, std::set<std::pair<uint32_t, uint32_t>> _credentials);
- void send_client_credentials_info(const client_t _target);
+ inline bool is_connected(client_t _source, client_t _sink) const {
+
+ auto find_source = connection_matrix_.find(_source);
+ if (find_source != connection_matrix_.end())
+ return (find_source->second.find(_sink)
+ != find_source->second.end());
+
+ return (false);
+ }
+ inline void add_connection(client_t _source, client_t _sink) {
+
+ connection_matrix_[_source].insert(_sink);
+ }
+ inline void remove_connection(client_t _source, client_t _sink) {
+
+ auto find_source = connection_matrix_.find(_source);
+ if (find_source != connection_matrix_.end())
+ find_source->second.erase(_sink);
+ }
+ inline void remove_source(client_t _source) {
+
+ connection_matrix_.erase(_source);
+ }
+
+ void send_client_routing_info(const client_t _target,
+ protocol::routing_info_entry &_entry);
+ void send_client_routing_info(const client_t _target,
+ std::vector<protocol::routing_info_entry> &&_entries);
+ void send_client_credentials(client_t _target, std::set<std::pair<uint32_t, uint32_t>> &_credentials);
void on_client_id_timer_expired(boost::system::error_code const &_error);
@@ -199,13 +228,17 @@ private:
void add_pending_security_update_handler(
pending_security_update_id_t _id,
- security_update_handler_t _handler);
+ const security_update_handler_t &_handler);
void add_pending_security_update_timer(
pending_security_update_id_t _id);
+#if defined(__linux__) || defined(ANDROID)
+ void on_net_state_change(bool _is_interface, const std::string &_name, bool _is_available);
+#endif
+
private:
routing_manager_stub_host *host_;
- boost::asio::io_service &io_;
+ boost::asio::io_context &io_;
std::mutex watchdog_timer_mutex_;
boost::asio::steady_timer watchdog_timer_;
@@ -213,7 +246,8 @@ private:
std::set<client_t> used_client_ids_;
std::mutex used_client_ids_mutex_;
- std::shared_ptr<endpoint> endpoint_;
+ std::shared_ptr<endpoint> root_; // Routing manager endpoint
+
std::shared_ptr<endpoint> local_receiver_;
std::mutex local_receiver_mutex_;
@@ -229,8 +263,8 @@ private:
std::condition_variable client_registration_condition_;
std::map<client_t, std::vector<registration_type_e>> pending_client_registrations_;
+ std::map<client_t, std::pair<boost::asio::ip::address, port_t> > internal_client_ports_;
const std::uint32_t max_local_message_size_;
- static const std::vector<byte_t> its_ping_;
const std::chrono::milliseconds configured_watchdog_timeout_;
boost::asio::steady_timer pinged_clients_timer_;
std::mutex pinged_clients_mutex_;
@@ -239,10 +273,6 @@ private:
std::map<client_t, std::map<service_t, std::map<instance_t, std::pair<major_version_t, minor_version_t> > > > service_requests_;
std::map<client_t, std::set<client_t>> connection_matrix_;
- std::map<client_t, std::vector<byte_t>> client_routing_info_;
- std::map<client_t, std::vector<byte_t>> offered_services_info_;
- std::map<client_t, std::vector<byte_t>> client_credentials_info_;
-
std::mutex pending_security_updates_mutex_;
pending_security_update_id_t pending_security_update_id_;
std::map<pending_security_update_id_t, std::unordered_set<client_t>> pending_security_updates_;
@@ -262,6 +292,14 @@ private:
std::set<std::shared_ptr<policy> >
>
> requester_policies_;
+
+
+#if defined(__linux__) || defined(ANDROID)
+ // netlink connector for internal network
+ // (replacement for Unix Domain Sockets if configured)
+ std::shared_ptr<netlink_connector> local_link_connector_;
+ bool is_local_link_available_;
+#endif
};
} // namespace vsomeip_v3
diff --git a/implementation/routing/include/routing_manager_stub_host.hpp b/implementation/routing/include/routing_manager_stub_host.hpp
index 6ad0ab1..c55dd86 100644
--- a/implementation/routing/include/routing_manager_stub_host.hpp
+++ b/implementation/routing/include/routing_manager_stub_host.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -6,9 +6,16 @@
#ifndef VSOMEIP_V3_ROUTING_MANAGER_STUB_HOST_
#define VSOMEIP_V3_ROUTING_MANAGER_STUB_HOST_
-#include <boost/asio/io_service.hpp>
+#if VSOMEIP_BOOST_VERSION < 106600
+# include <boost/asio/io_service.hpp>
+# define io_context io_service
+#else
+# include <boost/asio/io_context.hpp>
+#endif
#include <vsomeip/handler.hpp>
+#include <vsomeip/vsomeip_sec.h>
+
#include "types.hpp"
namespace vsomeip_v3 {
@@ -28,57 +35,59 @@ public:
instance_t _instance, 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, minor_version_t _minor) = 0;
+ virtual void request_service(client_t _client, service_t _service,
+ instance_t _instance, major_version_t _major,
+ minor_version_t _minor) = 0;
- virtual void release_service(client_t _client,
- service_t _service, instance_t _instance) = 0;
+ virtual void release_service(client_t _client, service_t _service,
+ instance_t _instance) = 0;
- virtual void register_shadow_event(client_t _client,
- service_t _service, instance_t _instance,
- event_t _notifier,
- const std::set<eventgroup_t> &_eventgroups,
- event_type_e _type, reliability_type_e _reliability,
- bool _is_provided) = 0;
+ virtual void register_shadow_event(client_t _client, service_t _service,
+ instance_t _instance, event_t _notifier,
+ const std::set<eventgroup_t> &_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;
- virtual void subscribe(client_t _client, uid_t _uid, gid_t _gid, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup,
- major_version_t _major, event_t _event) = 0;
+ virtual void subscribe(client_t _client, const vsomeip_sec_client_t *_sec_client,
+ service_t _service, instance_t _instance, eventgroup_t _eventgroup,
+ major_version_t _major, event_t _event,
+ const std::shared_ptr<debounce_filter_t> &_filter) = 0;
virtual void on_subscribe_nack(client_t _client, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup, event_t _event,
- remote_subscription_id_t _subscription_id, bool _simulated) = 0;
+ instance_t _instance, eventgroup_t _eventgroup, event_t _event,
+ remote_subscription_id_t _subscription_id) = 0;
virtual void on_subscribe_ack(client_t _client, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup, event_t _event,
- remote_subscription_id_t _subscription_id) = 0;
+ instance_t _instance, eventgroup_t _eventgroup, event_t _event,
+ remote_subscription_id_t _subscription_id) = 0;
- virtual void unsubscribe(client_t _client, uid_t _uid, gid_t _gid, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup, event_t _event) = 0;
+ virtual void unsubscribe(client_t _client, const vsomeip_sec_client_t *_sec_client,
+ service_t _service, instance_t _instance, eventgroup_t _eventgroup,
+ event_t _event) = 0;
virtual void on_unsubscribe_ack(client_t _client, service_t _service,
instance_t _instance, eventgroup_t _eventgroup,
remote_subscription_id_t _unsubscription_id) = 0;
virtual bool on_message(service_t _service, instance_t _instance,
- const byte_t *_data, length_t _size, bool _reliable, client_t _bound_client,
- credentials_t _credentials,
+ 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, bool _notify_one = false) = 0;
+ virtual void on_notification(client_t _client, service_t _service,
+ instance_t _instance, const byte_t *_data, length_t _size,
+ bool _notify_one = false) = 0;
virtual void on_stop_offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major,
minor_version_t _minor) = 0;
virtual void on_availability(service_t _service, instance_t _instance,
- bool _is_available, major_version_t _major, minor_version_t _minor) = 0;
+ availability_state_e _state, major_version_t _major,
+ minor_version_t _minor) = 0;
virtual std::shared_ptr<endpoint> find_local(client_t _client) = 0;
@@ -86,8 +95,9 @@ public:
client_t _client) = 0;
virtual void remove_local(client_t _client, bool _remove_local) = 0;
- virtual boost::asio::io_service & get_io() = 0;
+ virtual boost::asio::io_context& get_io() = 0;
virtual client_t get_client() const = 0;
+ virtual const vsomeip_sec_client_t *get_sec_client() const = 0;
virtual void on_pong(client_t _client) = 0;
@@ -95,14 +105,32 @@ public:
virtual std::shared_ptr<endpoint_manager_impl> get_endpoint_manager() const = 0;
- virtual void on_resend_provided_events_response(pending_remote_offer_id_t _id) = 0;
+ virtual void on_resend_provided_events_response(
+ pending_remote_offer_id_t _id) = 0;
+
+ virtual client_t find_local_client(service_t _service,
+ instance_t _instance) = 0;
+
+ virtual std::set<client_t> find_local_clients(service_t _service,
+ instance_t _instance) = 0;
+
+ virtual bool is_subscribe_to_any_event_allowed(
+ const vsomeip_sec_client_t *_sec_client,
+ client_t _client, service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup) = 0;
+
+ virtual void add_known_client(client_t _client,
+ const std::string &_client_host) = 0;
- virtual client_t find_local_client(service_t _service, instance_t _instance) = 0;
+ virtual void set_client_host(const std::string &_client_host) = 0;
- virtual std::set<client_t> find_local_clients(service_t _service, instance_t _instance) = 0;
+ virtual bool get_guest(client_t _client,
+ boost::asio::ip::address &_address, port_t &_port) const = 0;
+ virtual void add_guest(client_t _client,
+ const boost::asio::ip::address &_address, port_t _port) = 0;
+ virtual void remove_guest(client_t _client) = 0;
- virtual bool is_subscribe_to_any_event_allowed(credentials_t _credentials, client_t _client,
- service_t _service, instance_t _instance, eventgroup_t _eventgroup) = 0;
+ virtual void clear_local_services() = 0;
};
} // namespace vsomeip_v3
diff --git a/implementation/routing/include/serviceinfo.hpp b/implementation/routing/include/serviceinfo.hpp
index a405cf0..5ea4c18 100644
--- a/implementation/routing/include/serviceinfo.hpp
+++ b/implementation/routing/include/serviceinfo.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -18,7 +18,6 @@
namespace vsomeip_v3 {
class endpoint;
-class servicegroup;
class serviceinfo {
public:
@@ -28,9 +27,6 @@ public:
VSOMEIP_EXPORT serviceinfo(const serviceinfo& _other);
VSOMEIP_EXPORT ~serviceinfo();
- VSOMEIP_EXPORT servicegroup * get_group() const;
- VSOMEIP_EXPORT void set_group(servicegroup *_group);
-
VSOMEIP_EXPORT service_t get_service() const;
VSOMEIP_EXPORT instance_t get_instance() const;
@@ -57,8 +53,6 @@ public:
VSOMEIP_EXPORT void set_is_in_mainphase(bool _in_mainphase);
private:
- servicegroup *group_;
-
service_t service_;
instance_t instance_;
diff --git a/implementation/routing/include/types.hpp b/implementation/routing/include/types.hpp
index c301b33..d59015c 100644
--- a/implementation/routing/include/types.hpp
+++ b/implementation/routing/include/types.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -18,18 +18,13 @@ namespace vsomeip_v3 {
class serviceinfo;
class endpoint_definition;
-
-typedef std::map<service_t,
- std::map<instance_t,
- std::shared_ptr<serviceinfo> > > services_t;
+using services_t = std::map<service_t, std::map<instance_t, std::shared_ptr<serviceinfo>>>;
class eventgroupinfo;
-typedef std::map<service_t,
- std::map<instance_t,
- std::map<eventgroup_t,
- std::shared_ptr<
- eventgroupinfo> > > > eventgroups_t;
+using eventgroups_t =
+ std::map<service_t,
+ std::map<instance_t, std::map<eventgroup_t, std::shared_ptr<eventgroupinfo>>>>;
enum class registration_type_e : std::uint8_t {
REGISTER = 0x1,
@@ -47,8 +42,7 @@ enum class remote_subscription_state_e : std::uint8_t {
SUBSCRIPTION_UNKNOWN = 0xFF
};
-typedef std::uint16_t remote_subscription_id_t;
-typedef std::uint32_t pending_remote_offer_id_t;
+using remote_subscription_id_t = std::uint16_t;
struct msg_statistic_t {
uint32_t counter_;