summaryrefslogtreecommitdiff
path: root/implementation/routing/include
diff options
context:
space:
mode:
authorJürgen Gehring <Juergen.Gehring@bmw.de>2016-10-11 05:20:33 -0700
committerJürgen Gehring <Juergen.Gehring@bmw.de>2016-10-11 05:20:33 -0700
commit1375432503c0a72df7ad5c793c3e1f04e6b9e730 (patch)
tree4b229a9c5a7767db69db015f8e92e01c64614bf0 /implementation/routing/include
parent273814c76be4a8f906dc053492529b8d53b9e807 (diff)
downloadvSomeIP-1375432503c0a72df7ad5c793c3e1f04e6b9e730.tar.gz
vsomeip 2.4.22.4.2
Diffstat (limited to 'implementation/routing/include')
-rw-r--r--implementation/routing/include/event.hpp38
-rw-r--r--implementation/routing/include/eventgroupinfo.hpp12
-rw-r--r--implementation/routing/include/routing_manager.hpp31
-rw-r--r--implementation/routing/include/routing_manager_base.hpp31
-rw-r--r--implementation/routing/include/routing_manager_impl.hpp69
-rw-r--r--implementation/routing/include/routing_manager_proxy.hpp46
-rw-r--r--implementation/routing/include/routing_manager_stub.hpp34
-rw-r--r--implementation/routing/include/routing_manager_stub_host.hpp8
8 files changed, 196 insertions, 73 deletions
diff --git a/implementation/routing/include/event.hpp b/implementation/routing/include/event.hpp
index 9033160..2a76ad8 100644
--- a/implementation/routing/include/event.hpp
+++ b/implementation/routing/include/event.hpp
@@ -13,9 +13,11 @@
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/address.hpp>
-#include <boost/asio/system_timer.hpp>
+#include <boost/asio/steady_timer.hpp>
#include <vsomeip/primitive_types.hpp>
+#include <vsomeip/function_types.hpp>
+#include <vsomeip/payload.hpp>
namespace vsomeip {
@@ -43,14 +45,17 @@ public:
const std::shared_ptr<payload> get_payload() const;
- void set_payload(std::shared_ptr<payload> _payload, const client_t _client);
+ void set_payload(const std::shared_ptr<payload> &_payload,
+ const client_t _client, bool _force = false);
- void set_payload(std::shared_ptr<payload> _payload,
- const std::shared_ptr<endpoint_definition> _target);
+ void set_payload(const std::shared_ptr<payload> &_payload,
+ const std::shared_ptr<endpoint_definition> _target,
+ bool _force = false);
- void set_payload_dont_notify(std::shared_ptr<payload> _payload);
+ void set_payload_dont_notify(const std::shared_ptr<payload> &_payload);
- void set_payload(std::shared_ptr<payload> _payload);
+ void set_payload(const std::shared_ptr<payload> &_payload,
+ bool _force = false);
void unset_payload(bool _force = false);
bool is_field() const;
@@ -63,18 +68,20 @@ public:
// SIP_RPC_357
void set_update_cycle(std::chrono::milliseconds &_cycle);
+ void set_change_resets_cycle(bool _change_resets_cycle);
// SIP_RPC_358
void set_update_on_change(bool _is_on);
- // SIP_RPC_359 (epsilon change) is not supported!
+ // SIP_RPC_359 (epsilon change)
+ void set_epsilon_change_function(const epsilon_change_func_t &_epsilon_change_func);
const std::set<eventgroup_t> & get_eventgroups() const;
void add_eventgroup(eventgroup_t _eventgroup);
void set_eventgroups(const std::set<eventgroup_t> &_eventgroups);
void notify_one(const std::shared_ptr<endpoint_definition> &_target);
- void notify_one(client_t _client, bool _is_initial = false);
+ void notify_one(client_t _client);
void add_ref(client_t _client, bool _is_provided);
void remove_ref(client_t _client, bool _is_provided);
@@ -91,17 +98,24 @@ private:
void notify();
void notify(client_t _client, const std::shared_ptr<endpoint_definition> &_target);
-private:
- bool set_payload_helper(std::shared_ptr<payload> _payload);
+ void start_cycle();
+ void stop_cycle();
+
+ bool compare(const std::shared_ptr<payload> &_lhs, const std::shared_ptr<payload> &_rhs) const;
+
+ bool set_payload_helper(const std::shared_ptr<payload> &_payload, bool _force);
+ void reset_payload(const std::shared_ptr<payload> &_payload);
+private:
routing_manager *routing_;
std::mutex mutex_;
std::shared_ptr<message> message_;
bool is_field_;
- boost::asio::system_timer cycle_timer_;
+ boost::asio::steady_timer cycle_timer_;
std::chrono::milliseconds cycle_;
+ bool change_resets_cycle_;
bool is_updating_on_change_;
@@ -115,6 +129,8 @@ private:
bool is_shadow_;
bool is_cache_placeholder_;
+
+ epsilon_change_func_t epsilon_change_func_;
};
} // namespace vsomeip
diff --git a/implementation/routing/include/eventgroupinfo.hpp b/implementation/routing/include/eventgroupinfo.hpp
index 7e832a1..fc3d321 100644
--- a/implementation/routing/include/eventgroupinfo.hpp
+++ b/implementation/routing/include/eventgroupinfo.hpp
@@ -25,7 +25,7 @@ class eventgroupinfo {
public:
struct target_t {
std::shared_ptr<endpoint_definition> endpoint_;
- std::chrono::high_resolution_clock::time_point expiration_;
+ std::chrono::steady_clock::time_point expiration_;
bool operator==(const target_t &_other) const {
return (endpoint_ == _other.endpoint_);
@@ -47,19 +47,20 @@ public:
uint16_t &_port) const;
VSOMEIP_EXPORT void set_multicast(const boost::asio::ip::address &_address,
uint16_t _port);
+ VSOMEIP_EXPORT bool is_sending_multicast() const;
VSOMEIP_EXPORT const std::set<std::shared_ptr<event> > get_events() const;
VSOMEIP_EXPORT void add_event(std::shared_ptr<event> _event);
VSOMEIP_EXPORT void remove_event(std::shared_ptr<event> _event);
VSOMEIP_EXPORT const std::list<target_t> get_targets() const;
- VSOMEIP_EXPORT uint32_t get_unreliable_target_count();
+ VSOMEIP_EXPORT uint32_t get_unreliable_target_count() const;
VSOMEIP_EXPORT bool add_target(const target_t &_target);
VSOMEIP_EXPORT bool add_target(const target_t &_target, const target_t &_subscriber);
VSOMEIP_EXPORT bool update_target(
const std::shared_ptr<endpoint_definition> &_target,
- const std::chrono::high_resolution_clock::time_point &_expiration);
+ const std::chrono::steady_clock::time_point &_expiration);
VSOMEIP_EXPORT bool remove_target(
const std::shared_ptr<endpoint_definition> &_target);
VSOMEIP_EXPORT void clear_targets();
@@ -68,6 +69,9 @@ public:
VSOMEIP_EXPORT void clear_multicast_targets();
VSOMEIP_EXPORT const std::list<target_t> get_multicast_targets() const;
+ VSOMEIP_EXPORT uint8_t get_threshold() const;
+ VSOMEIP_EXPORT void set_threshold(uint8_t _threshold);
+
private:
major_version_t major_;
ttl_t ttl_;
@@ -78,6 +82,8 @@ private:
std::set<std::shared_ptr<event> > events_;
std::list<target_t> targets_;
std::list<target_t> multicast_targets_;
+
+ uint8_t threshold_;
};
} // namespace vsomeip
diff --git a/implementation/routing/include/routing_manager.hpp b/implementation/routing/include/routing_manager.hpp
index ee18957..dcbdd5a 100644
--- a/implementation/routing/include/routing_manager.hpp
+++ b/implementation/routing/include/routing_manager.hpp
@@ -12,6 +12,7 @@
#include <boost/asio/io_service.hpp>
+#include <vsomeip/function_types.hpp>
#include <vsomeip/message.hpp>
#include <vsomeip/handler.hpp>
@@ -35,12 +36,13 @@ public:
virtual void start() = 0;
virtual void stop() = 0;
- virtual void offer_service(client_t _client, service_t _service,
+ virtual bool offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major,
minor_version_t _minor) = 0;
virtual void stop_offer_service(client_t _client, service_t _service,
- instance_t _instance, major_version_t _major, minor_version_t _minor) = 0;
+ 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,
@@ -61,7 +63,7 @@ public:
bool _flush) = 0;
virtual bool send(client_t _client, const byte_t *_data, uint32_t _size,
- instance_t _instance, bool _flush, bool _reliable, bool _initial) = 0;
+ instance_t _instance, bool _flush, bool _reliable) = 0;
virtual bool send_to(const std::shared_ptr<endpoint_definition> &_target,
std::shared_ptr<message>) = 0;
@@ -69,13 +71,16 @@ public:
virtual bool send_to(const std::shared_ptr<endpoint_definition> &_target,
const byte_t *_data, uint32_t _size) = 0;
- virtual void register_event(client_t _client, service_t _service, instance_t _instance,
- event_t _event, const std::set<eventgroup_t> &_eventgroups,
- bool _is_field, bool _is_provided, bool _is_shadow = false,
+ virtual void register_event(client_t _client, service_t _service,
+ instance_t _instance, event_t _event,
+ const std::set<eventgroup_t> &_eventgroups, bool _is_field,
+ std::chrono::milliseconds _cycle, bool _change_resets_cycle,
+ epsilon_change_func_t _epsilon_change_func,
+ bool _is_provided, bool _is_shadow = false,
bool _is_cache_placeholder = false) = 0;
- virtual void unregister_event(client_t _client, service_t _service, instance_t _instance,
- event_t _event, bool _is_provided) = 0;
+ virtual void unregister_event(client_t _client, service_t _service,
+ instance_t _instance, event_t _event, bool _is_provided) = 0;
virtual std::shared_ptr<event> get_event(service_t _service,
instance_t _instance, event_t _event) const = 0;
@@ -84,13 +89,15 @@ public:
instance_t _instance, eventgroup_t _eventgroup) const = 0;
virtual void notify(service_t _service, instance_t _instance,
- event_t _event, std::shared_ptr<payload> _payload) = 0;
+ event_t _event, std::shared_ptr<payload> _payload,
+ bool _force) = 0;
virtual void notify_one(service_t _service, instance_t _instance,
- event_t _event, std::shared_ptr<payload> _payload, client_t _client) = 0;
+ event_t _event, std::shared_ptr<payload> _payload,
+ client_t _client, bool _force) = 0;
- virtual void on_identify_response(client_t _client, service_t _service, instance_t _instance,
- bool _reliable) = 0;
+ virtual void on_identify_response(client_t _client, service_t _service,
+ instance_t _instance, bool _reliable) = 0;
};
} // namespace vsomeip
diff --git a/implementation/routing/include/routing_manager_base.hpp b/implementation/routing/include/routing_manager_base.hpp
index 1d69f6f..a7c127c 100644
--- a/implementation/routing/include/routing_manager_base.hpp
+++ b/implementation/routing/include/routing_manager_base.hpp
@@ -48,7 +48,7 @@ public:
virtual void init();
- virtual void offer_service(client_t _client, service_t _service,
+ virtual bool offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major,
minor_version_t _minor);
@@ -63,9 +63,10 @@ public:
instance_t _instance);
virtual void register_event(client_t _client, service_t _service, instance_t _instance,
- event_t _event, const std::set<eventgroup_t> &_eventgroups,
- bool _is_field, bool _is_provided, bool _is_shadow = false,
- bool _is_cache_placeholder = false);
+ event_t _event, const std::set<eventgroup_t> &_eventgroups, bool _is_field,
+ std::chrono::milliseconds _cycle, bool _change_resets_cycle,
+ epsilon_change_func_t _epsilon_change_func,
+ bool _is_provided, bool _is_shadow = false, bool _is_cache_placeholder = false);
virtual void unregister_event(client_t _client, service_t _service, instance_t _instance,
event_t _event, bool _is_provided);
@@ -84,19 +85,18 @@ public:
virtual void unsubscribe(client_t _client, service_t _service,
instance_t _instance, eventgroup_t _eventgroup);
- virtual void notify(service_t _service, instance_t _instance,
- event_t _event, std::shared_ptr<payload> _payload);
+ virtual void notify(service_t _service, instance_t _instance,
+ event_t _event, std::shared_ptr<payload> _payload, bool _force);
- virtual void notify_one(service_t _service, instance_t _instance,
- event_t _event, std::shared_ptr<payload> _payload, client_t _client);
+ virtual void notify_one(service_t _service, instance_t _instance,
+ event_t _event, std::shared_ptr<payload> _payload,
+ client_t _client, bool _force);
virtual bool send(client_t _client, std::shared_ptr<message> _message,
bool _flush);
virtual bool send(client_t _client, const byte_t *_data, uint32_t _size,
- instance_t _instance, bool _flush, bool _reliable, bool _initial) = 0;
-
- virtual bool queue_message(const byte_t *_data, uint32_t _size) const = 0;
+ instance_t _instance, bool _flush, bool _reliable) = 0;
// Endpoint host ~> will be implemented by routing_manager_impl/_proxy/
virtual void on_connect(std::shared_ptr<endpoint> _endpoint) = 0;
@@ -107,6 +107,8 @@ public:
virtual void on_error(const byte_t *_data, length_t _length,
endpoint *_receiver) = 0;
+ virtual void on_clientendpoint_error(client_t _client);
+
protected:
std::shared_ptr<serviceinfo> find_service(service_t _service, instance_t _instance) const;
std::shared_ptr<serviceinfo> create_service_info(service_t _service,
@@ -138,15 +140,14 @@ protected:
void remove_eventgroup_info(service_t _service, instance_t _instance,
eventgroup_t _eventgroup);
- void send_local_notification(client_t _client,
+ bool send_local_notification(client_t _client,
const byte_t *_data, uint32_t _size, instance_t _instance,
- bool _flush = true, bool _reliable = false, bool _inital = false);
+ bool _flush = true, bool _reliable = false);
bool send_local(
std::shared_ptr<endpoint> &_target, client_t _client,
const byte_t *_data, uint32_t _size, instance_t _instance,
- bool _flush, bool _reliable, uint8_t _command, bool _queue_message = false,
- bool _initial = false) const;
+ bool _flush, bool _reliable, uint8_t _command) const;
bool insert_subscription(service_t _service, instance_t _instance,
eventgroup_t _eventgroup, client_t _client);
diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp
index 13936a4..b08f2cd 100644
--- a/implementation/routing/include/routing_manager_impl.hpp
+++ b/implementation/routing/include/routing_manager_impl.hpp
@@ -58,7 +58,7 @@ public:
void start();
void stop();
- void offer_service(client_t _client, service_t _service,
+ bool offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major,
minor_version_t _minor);
@@ -82,7 +82,7 @@ public:
bool send(client_t _client, std::shared_ptr<message> _message, bool _flush);
bool send(client_t _client, const byte_t *_data, uint32_t _size,
- instance_t _instance, bool _flush, bool _reliable, bool _initial = false);
+ instance_t _instance, bool _flush, bool _reliable);
bool send_to(const std::shared_ptr<endpoint_definition> &_target,
std::shared_ptr<message> _message);
@@ -103,10 +103,11 @@ public:
bool _is_provided);
void notify(service_t _service, instance_t _instance, event_t _event,
- std::shared_ptr<payload> _payload);
+ std::shared_ptr<payload> _payload, bool _force);
void notify_one(service_t _service, instance_t _instance,
- event_t _event, std::shared_ptr<payload> _payload, client_t _client);
+ event_t _event, std::shared_ptr<payload> _payload,
+ client_t _client, bool _force);
void on_subscribe_nack(client_t _client, service_t _service,
instance_t _instance, eventgroup_t _eventgroup);
@@ -117,15 +118,15 @@ public:
void on_identify_response(client_t _client, service_t _service, instance_t _instance,
bool _reliable);
- bool queue_message(const byte_t *_data, uint32_t _size) const;
-
// interface to stub
std::shared_ptr<endpoint> find_local(client_t _client);
std::shared_ptr<endpoint> find_or_create_local(client_t _client);
void remove_local(client_t _client);
- void on_stop_offer_service(service_t _service, instance_t _instance,
+ void on_stop_offer_service(client_t _client, service_t _service, instance_t _instance,
major_version_t _major, minor_version_t _minor);
+ void on_pong(client_t _client);
+
// interface "endpoint_host"
std::shared_ptr<endpoint> find_or_create_remote_client(service_t _service,
instance_t _instance,
@@ -151,7 +152,7 @@ public:
std::shared_ptr<endpoint> create_service_discovery_endpoint(const std::string &_address,
uint16_t _port, bool _reliable);
void init_routing_info();
- void add_routing_info(service_t _service, instance_t _instance,
+ std::chrono::milliseconds add_routing_info(service_t _service, instance_t _instance,
major_version_t _major, minor_version_t _minor, ttl_t _ttl,
const boost::asio::ip::address &_reliable_address,
uint16_t _reliable_port,
@@ -165,11 +166,11 @@ public:
eventgroup_t _eventgroup,
std::shared_ptr<endpoint_definition> _subscriber,
std::shared_ptr<endpoint_definition> _target,
- const std::chrono::high_resolution_clock::time_point &_expiration);
+ const std::chrono::steady_clock::time_point &_expiration);
bool on_subscribe_accepted(service_t _service, instance_t _instance,
eventgroup_t _eventgroup,
std::shared_ptr<endpoint_definition> _target,
- const std::chrono::high_resolution_clock::time_point &_expiration);
+ const std::chrono::steady_clock::time_point &_expiration);
void on_unsubscribe(service_t _service, instance_t _instance,
eventgroup_t _eventgroup,
std::shared_ptr<endpoint_definition> _target);
@@ -179,11 +180,14 @@ public:
void expire_subscriptions(const boost::asio::ip::address &_address);
void expire_services(const boost::asio::ip::address &_address);
- std::chrono::high_resolution_clock::time_point expire_subscriptions();
+ std::chrono::steady_clock::time_point expire_subscriptions();
bool has_identified(client_t _client, service_t _service,
instance_t _instance, bool _reliable);
+ void on_clientendpoint_error(client_t _client);
+ void confirm_pending_offers(client_t _client);
+
private:
bool deliver_message(const byte_t *_data, length_t _length,
instance_t _instance, bool _reliable);
@@ -197,7 +201,7 @@ private:
std::shared_ptr<endpoint> create_client_endpoint(
const boost::asio::ip::address &_address,
- uint16_t _local_port, uint16_t _remote_port,
+ uint16_t _local_port, uint16_t _remote_port,
bool _reliable, client_t _client, bool _start);
std::shared_ptr<endpoint> create_server_endpoint(uint16_t _port,
@@ -223,6 +227,9 @@ private:
void stop_and_delete_client_endpoint(std::shared_ptr<endpoint> _endpoint);
void clear_multicast_endpoints(service_t _service, instance_t _instance);
+ bool is_identifying(client_t _client, service_t _service,
+ instance_t _instance, bool _reliable);
+
private:
return_code_e check_error(const byte_t *_data, length_t _size,
instance_t _instance);
@@ -244,6 +251,23 @@ private:
client_t _client,
const std::shared_ptr<endpoint_definition> &_target);
+ void log_version_timer_cbk(boost::system::error_code const & _error);
+
+ void clear_remote_service_info(service_t _service, instance_t _instance, bool _reliable);
+
+ bool handle_local_offer_service(client_t _client, service_t _service,
+ instance_t _instance, major_version_t _major,minor_version_t _minor);
+
+ void remove_specific_client_endpoint(client_t _client, service_t _service, instance_t _instance, bool _reliable);
+
+ void clear_identified_clients( service_t _service, instance_t _instance);
+
+ void clear_identifying_clients( service_t _service, instance_t _instance);
+
+ void remove_identified_client(service_t _service, instance_t _instance, client_t _client);
+
+ void remove_identifying_client(service_t _service, instance_t _instance, client_t _client);
+
std::shared_ptr<routing_manager_stub> stub_;
std::shared_ptr<sd::service_discovery> discovery_;
@@ -272,17 +296,36 @@ private:
std::mutex identified_clients_mutex_;
std::mutex requested_services_mutex_;
+ std::mutex remote_subscribers_mutex_;
std::map<service_t, std::map<instance_t, std::map<client_t,
std::set<std::shared_ptr<endpoint_definition>>>>> remote_subscribers_;
std::mutex specific_endpoint_clients_mutex_;
std::map<service_t, std::map<instance_t, std::unordered_set<client_t>>>specific_endpoint_clients_;
std::map<service_t, std::map<instance_t,
- std::map<bool, std::unordered_set<client_t> > > >identified_clients_;
+ std::map<bool, std::unordered_set<client_t> > > > identified_clients_;
+ std::map<service_t, std::map<instance_t,
+ std::map<bool, std::unordered_set<client_t> > > > identifying_clients_;
std::shared_ptr<serviceinfo> sd_info_;
std::map<bool, std::set<uint16_t>> used_client_ports_;
+
+ boost::asio::steady_timer version_log_timer_;
+
+#ifndef WITHOUT_SYSTEMD
+ boost::asio::steady_timer watchdog_timer_;
+ void watchdog_cbk(boost::system::error_code const &_error);
+#endif
+
+ std::mutex pending_offers_mutex_;
+ // map to store pending offers.
+ // 1st client id in tuple: client id of new offering application
+ // 2nd client id in tuple: client id of previously/stored offering application
+ std::map<service_t,
+ std::map<instance_t,
+ std::tuple<major_version_t, minor_version_t,
+ client_t, client_t>>> pending_offers_;
};
} // namespace vsomeip
diff --git a/implementation/routing/include/routing_manager_proxy.hpp b/implementation/routing/include/routing_manager_proxy.hpp
index d2f61d7..bea1c24 100644
--- a/implementation/routing/include/routing_manager_proxy.hpp
+++ b/implementation/routing/include/routing_manager_proxy.hpp
@@ -10,6 +10,7 @@
#include <mutex>
#include <boost/asio/io_service.hpp>
+#include <boost/asio/steady_timer.hpp>
#include "routing_manager_base.hpp"
#include <vsomeip/enumeration_types.hpp>
@@ -30,7 +31,7 @@ public:
void start();
void stop();
- void offer_service(client_t _client, service_t _service,
+ bool offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major,
minor_version_t _minor);
@@ -52,8 +53,7 @@ public:
eventgroup_t _eventgroup);
bool send(client_t _client, const byte_t *_data, uint32_t _size,
- instance_t _instance, bool _flush = true, bool _reliable = false,
- bool _initial = false);
+ instance_t _instance, bool _flush = true, bool _reliable = false);
bool send_to(const std::shared_ptr<endpoint_definition> &_target,
std::shared_ptr<message> _message);
@@ -63,15 +63,17 @@ public:
void register_event(client_t _client, service_t _service,
instance_t _instance, event_t _event,
- const std::set<eventgroup_t> &_eventgroups,
- bool _is_field, bool _is_provided, bool _is_shadow, bool _is_cache_placeholder);
+ const std::set<eventgroup_t> &_eventgroups, bool _is_field,
+ std::chrono::milliseconds _cycle, bool _change_resets_cycle,
+ epsilon_change_func_t _epsilon_change_func,
+ bool _is_provided, bool _is_shadow, bool _is_cache_placeholder);
void unregister_event(client_t _client, service_t _service,
instance_t _instance, event_t _event,
bool _is_provided);
void notify(service_t _service, instance_t _instance, event_t _event,
- std::shared_ptr<payload> _payload);
+ std::shared_ptr<payload> _payload, bool _force);
void on_connect(std::shared_ptr<endpoint> _endpoint);
void on_disconnect(std::shared_ptr<endpoint> _endpoint);
@@ -85,8 +87,6 @@ public:
void on_identify_response(client_t _client, service_t _service, instance_t _instance,
bool _reliable);
- bool queue_message(const byte_t *_data, uint32_t _size) const;
-
private:
void register_application();
void deregister_application();
@@ -131,10 +131,27 @@ private:
void on_stop_offer_service(service_t _service, instance_t _instance,
major_version_t _major, minor_version_t _minor);
+ void send_pending_commands();
+
+ void init_receiver();
+
+ void notify_remote_initally(service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup);
+
+ uint32_t get_remote_subscriber_count(service_t _service, instance_t _instance,
+ eventgroup_t _eventgroup, bool _increment);
+
+ void register_application_timeout_cbk(boost::system::error_code const &_error);
private:
+ enum class inner_state_type_e : std::uint8_t {
+ ST_REGISTERED = 0x0,
+ ST_DEREGISTERED = 0x1,
+ ST_REGISTERING = 0x2
+ };
+
bool is_connected_;
bool is_started_;
- state_type_e state_;
+ inner_state_type_e state_;
std::shared_ptr<endpoint> sender_; // --> stub
std::shared_ptr<endpoint> receiver_; // --> from everybody
@@ -202,7 +219,16 @@ private:
std::mutex send_mutex_;
std::mutex deserialize_mutex_;
- std::mutex pending_mutex_;
+
+ std::mutex state_mutex_;
+ std::condition_variable state_condition_;
+
+ std::map<service_t,
+ std::map<instance_t, std::map<eventgroup_t, uint32_t > > > remote_subscriber_count_;
+
+ mutable std::recursive_mutex sender_mutex_;
+
+ boost::asio::steady_timer register_application_timer_;
};
} // namespace vsomeip
diff --git a/implementation/routing/include/routing_manager_stub.hpp b/implementation/routing/include/routing_manager_stub.hpp
index 27b8ec5..6255cda 100644
--- a/implementation/routing/include/routing_manager_stub.hpp
+++ b/implementation/routing/include/routing_manager_stub.hpp
@@ -15,7 +15,7 @@
#include <thread>
#include <boost/asio/io_service.hpp>
-#include <boost/asio/system_timer.hpp>
+#include <boost/asio/steady_timer.hpp>
#include "../../endpoints/include/endpoint_host.hpp"
@@ -48,8 +48,6 @@ public:
void on_stop_offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major, minor_version_t _minor);
- bool queue_message(const byte_t *_data, uint32_t _size);
-
void send_subscribe(std::shared_ptr<vsomeip::endpoint> _target,
client_t _client, service_t _service,
instance_t _instance, eventgroup_t _eventgroup,
@@ -57,7 +55,8 @@ public:
void send_unsubscribe(std::shared_ptr<vsomeip::endpoint> _target,
client_t _client, service_t _service,
- instance_t _instance, eventgroup_t _eventgroup);
+ instance_t _instance, eventgroup_t _eventgroup,
+ bool _is_remote_subscriber);
void send_subscribe_nack(client_t _client, service_t _service,
instance_t _instance, eventgroup_t _eventgroup);
@@ -65,8 +64,15 @@ public:
void send_subscribe_ack(client_t _client, service_t _service,
instance_t _instance, eventgroup_t _eventgroup);
+ bool contained_in_routing_info(client_t _client, service_t _service,
+ instance_t _instance, major_version_t _major,
+ minor_version_t _minor) const;
+
+ void create_local_receiver();
+ bool send_ping(client_t _client);
+ void deregister_erroneous_client(client_t _client);
private:
- void broadcast(std::vector<byte_t> &_command) const;
+ void broadcast(const std::vector<byte_t> &_command) const;
void on_register_application(client_t _client);
void on_deregister_application(client_t _client);
@@ -81,11 +87,14 @@ private:
void send_application_lost(std::list<client_t> &_lost);
void client_registration_func(void);
+ void init_routing_endpoint();
+ void on_ping_timer_expired(boost::system::error_code const &_error);
+ void remove_from_pinged_clients(client_t _client);
private:
routing_manager_stub_host *host_;
boost::asio::io_service &io_;
- boost::asio::system_timer watchdog_timer_;
+ boost::asio::steady_timer watchdog_timer_;
std::string endpoint_path_;
std::string local_receiver_path_;
@@ -103,7 +112,18 @@ private:
std::shared_ptr<std::thread> client_registration_thread_;
std::mutex client_registration_mutex_;
std::condition_variable client_registration_condition_;
- std::map<client_t, std::vector<bool>> pending_client_registrations_;
+
+ enum class registration_type_e : std::uint8_t {
+ REGISTER = 0x1,
+ DEREGISTER = 0x2,
+ DEREGISTER_ERROR_CASE = 0x3
+ };
+ std::map<client_t, std::vector<registration_type_e>> pending_client_registrations_;
+ static const std::vector<byte_t> its_ping_;
+ const std::chrono::milliseconds configured_watchdog_timeout_;
+ boost::asio::steady_timer pinged_clients_timer_;
+ std::mutex pinged_clients_mutex_;
+ std::map<client_t, boost::asio::steady_timer::time_point> pinged_clients_;
};
} // namespace vsomeip
diff --git a/implementation/routing/include/routing_manager_stub_host.hpp b/implementation/routing/include/routing_manager_stub_host.hpp
index e216b5a..0d1decb 100644
--- a/implementation/routing/include/routing_manager_stub_host.hpp
+++ b/implementation/routing/include/routing_manager_stub_host.hpp
@@ -16,7 +16,7 @@ public:
virtual ~routing_manager_stub_host() {
}
- virtual void offer_service(client_t _client, service_t _service,
+ virtual bool offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major,
minor_version_t _minor) = 0;
@@ -59,7 +59,7 @@ public:
service_t _service, instance_t _instance,
const byte_t *_data, length_t _size, bool _notify_one = false) = 0;
- virtual void on_stop_offer_service(service_t _service,
+ virtual void on_stop_offer_service(client_t _client, service_t _service,
instance_t _instance, major_version_t _major,
minor_version_t _minor) = 0;
@@ -74,6 +74,10 @@ public:
virtual void on_identify_response(client_t _client, service_t _service, instance_t _instance,
bool _reliable) = 0;
+
+ virtual void on_pong(client_t _client) = 0;
+ virtual void on_clientendpoint_error(client_t _client) = 0;
+ virtual void confirm_pending_offers(client_t _client) = 0;
};
} // namespace vsomeip