Skip to content

Commit

Permalink
vsomeip 2.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent e9c35d3 commit 686cb94
Show file tree
Hide file tree
Showing 58 changed files with 3,323 additions and 284 deletions.
13 changes: 11 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
Changes
=======

v2.8.1
- Support negative filter in trace connector
v2.9.0
- Added get_offered_services_async method to application interface to
read the currently offered services
- Added set_watchdog_handler method to application interface which can
be used to register a handler invoked in a given interval.
- Optimize processing time of incoming service discovery messages
- Events are now sent based on their configuration in the json file
- If a remote service is offered reliable and unreliable subscriptions
are now done always with both endpoint options.
- Incoming subscriptions are now not acknowledged if not all events of
the eventgroup can be served with the given endpoint options.

v2.8.0
- Change behaviour of register_subscription_status_handler method of
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ cmake_minimum_required (VERSION 2.8.12)
project (vsomeip)

set (VSOMEIP_MAJOR_VERSION 2)
set (VSOMEIP_MINOR_VERSION 8)
set (VSOMEIP_PATCH_VERSION 1)
set (VSOMEIP_MINOR_VERSION 9)
set (VSOMEIP_PATCH_VERSION 0)
set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION})
set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentatin/doxygen.in
set (CMAKE_VERBOSE_MAKEFILE off)
Expand Down
2 changes: 2 additions & 0 deletions implementation/configuration/include/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class configuration {

virtual bool is_local_service(service_t _service, instance_t _instance) const = 0;

virtual bool is_event_reliable(service_t _service, instance_t _instance, event_t _event) const = 0;

// Service Discovery configuration
virtual bool is_sd_enabled() const = 0;

Expand Down
2 changes: 2 additions & 0 deletions implementation/configuration/include/configuration_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class configuration_impl:

VSOMEIP_EXPORT bool is_local_service(service_t _service, instance_t _instance) const;

VSOMEIP_EXPORT bool is_event_reliable(service_t _service, instance_t _instance, event_t _event) const;

// Service Discovery configuration
VSOMEIP_EXPORT bool is_sd_enabled() const;

Expand Down
7 changes: 5 additions & 2 deletions implementation/configuration/include/internal.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#define VSOMEIP_DEFAULT_CONFIGURATION_FILE "/etc/vsomeip.json"
#define VSOMEIP_LOCAL_CONFIGURATION_FILE "./vsomeip.json"
#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json,vsomeip_log.json"
#define VSOMEIP_MANDATORY_CONFIGURATION_FILES "vsomeip_std.json,vsomeip_app.json,vsomeip_plc.json"

#define VSOMEIP_DEFAULT_CONFIGURATION_FOLDER "/etc/vsomeip"
#define VSOMEIP_LOCAL_CONFIGURATION_FOLDER "./vsomeip"
Expand All @@ -39,7 +39,7 @@

#define VSOMEIP_ROUTING "@VSOMEIP_ROUTING@"
#define VSOMEIP_ROUTING_CLIENT 0
#define VSOMEIP_ROUTING_INFO_SIZE_INIT 256
#define VSOMEIP_ROUTING_INFO_SIZE_INIT 256

#ifdef _WIN32
#define VSOMEIP_INTERNAL_BASE_PORT 51234
Expand Down Expand Up @@ -98,6 +98,8 @@
#define VSOMEIP_UNREGISTER_EVENT 0x1C
#define VSOMEIP_ID_RESPONSE 0x1D
#define VSOMEIP_ID_REQUEST 0x1E
#define VSOMEIP_OFFERED_SERVICES_REQUEST 0x1F
#define VSOMEIP_OFFERED_SERVICES_RESPONSE 0x20

#define VSOMEIP_OFFER_SERVICE_COMMAND_SIZE 16
#define VSOMEIP_REQUEST_SERVICE_COMMAND_SIZE 17
Expand All @@ -111,6 +113,7 @@
#define VSOMEIP_UNREGISTER_EVENT_COMMAND_SIZE 14
#define VSOMEIP_ID_RESPONSE_COMMAND_SIZE 12
#define VSOMEIP_ID_REQUEST_COMMAND_SIZE 13
#define VSOMEIP_OFFERED_SERVICES_COMMAND_SIZE 8

#ifndef _WIN32
#include <pthread.h>
Expand Down
18 changes: 18 additions & 0 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,24 @@ std::shared_ptr<client> configuration_impl::find_client(service_t _service,
return its_client;
}

bool configuration_impl::is_event_reliable(service_t _service,
instance_t _instance, event_t _event) const {
bool is_reliable(false);
auto its_service = find_service(_service, _instance);
if (its_service) {
auto its_event = its_service->events_.find(_event);
if (its_event != its_service->events_.end()) {
return its_event->second->is_reliable_;
} else {
if (its_service->reliable_ != ILLEGAL_PORT &&
its_service->unreliable_ == ILLEGAL_PORT) {
is_reliable = true;
}
}
}
return is_reliable;
}

std::shared_ptr<service> configuration_impl::find_service(service_t _service,
instance_t _instance) const {
std::shared_ptr<service> its_service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <vsomeip/defines.hpp>

#include "server_endpoint_impl.hpp"
#include <atomic>

namespace vsomeip {

Expand Down Expand Up @@ -57,6 +58,7 @@ class udp_server_endpoint_impl: public udp_server_endpoint_base_impl {
private:
void set_broadcast();
bool is_joined(const std::string &_address) const;
bool is_joined(const std::string &_address, bool* _received) const;

private:
socket_type socket_;
Expand All @@ -65,7 +67,8 @@ class udp_server_endpoint_impl: public udp_server_endpoint_base_impl {
mutable std::mutex default_targets_mutex_;
std::map<service_t, endpoint_type> default_targets_;
mutable std::mutex joined_mutex_;
std::set<std::string> joined_;
std::map<std::string, bool> joined_;
std::atomic<bool> joined_group_;

message_buffer_t recv_buffer_;
std::mutex socket_mutex_;
Expand Down
2 changes: 1 addition & 1 deletion implementation/endpoints/src/udp_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void udp_client_endpoint_impl::connect() {
boost::system::error_code its_bind_error;
socket_->bind(local_, its_bind_error);
if(its_bind_error) {
VSOMEIP_WARNING << "tcp_client_endpoint::connect: "
VSOMEIP_WARNING << "udp_client_endpoint::connect: "
"Error binding socket: " << its_bind_error.message();
}
}
Expand Down
53 changes: 42 additions & 11 deletions implementation/endpoints/src/udp_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ udp_server_endpoint_impl::udp_server_endpoint_impl(
: server_endpoint_impl<ip::udp_ext>(
_host, _local, _io, VSOMEIP_MAX_UDP_MESSAGE_SIZE),
socket_(_io, _local.protocol()),
joined_group_(false),
recv_buffer_(VSOMEIP_MAX_UDP_MESSAGE_SIZE, 0),
local_port_(_local.port()) {
boost::system::error_code ec;
Expand Down Expand Up @@ -151,10 +152,23 @@ bool udp_server_endpoint_impl::is_joined(const std::string &_address) const {
return (joined_.find(_address) != joined_.end());
}

bool udp_server_endpoint_impl::is_joined(
const std::string &_address, bool* _received) const {
*_received = false;
std::lock_guard<std::mutex> its_lock(joined_mutex_);
const auto found_address = joined_.find(_address);
if (found_address != joined_.end()) {
*_received = found_address->second;
}
return (found_address != joined_.end());
}

void udp_server_endpoint_impl::join(const std::string &_address) {
bool has_received(false);

try {
if (!is_joined(_address)) {
std::function<void(const std::string &)> join_func =
[this](const std::string &_address) {
try {
bool is_v4(false);
bool is_v6(false);
{
Expand Down Expand Up @@ -191,15 +205,20 @@ void udp_server_endpoint_impl::join(const std::string &_address) {
}
{
std::lock_guard<std::mutex> its_lock(joined_mutex_);
joined_.insert(_address);
joined_[_address] = false;
}
} else {
VSOMEIP_INFO << "udp_server_endpoint_impl::join: "
"Trying to join already joined address: " << _address;
joined_group_ = true;
} catch (const std::exception &e) {
VSOMEIP_ERROR << "udp_server_endpoint_impl::join" << ":" << e.what();
}
}
catch (const std::exception &e) {
VSOMEIP_ERROR << __func__ << ":" << e.what();
};

if (!is_joined(_address, &has_received)) {
join_func(_address);
} else if (!has_received) {
// joined the multicast group but didn't receive a event yet -> rejoin
leave(_address);
join_func(_address);
}
}

Expand All @@ -225,6 +244,9 @@ void udp_server_endpoint_impl::leave(const std::string &_address) {
{
std::lock_guard<std::mutex> its_lock(joined_mutex_);
joined_.erase(_address);
if (!joined_.size()) {
joined_group_ = false;
}
}
}
}
Expand Down Expand Up @@ -297,6 +319,8 @@ void udp_server_endpoint_impl::receive_cbk(
return;
}
remaining_bytes -= current_message_size;
service_t its_service = VSOMEIP_BYTES_TO_WORD(recv_buffer_[i + VSOMEIP_SERVICE_POS_MIN],
recv_buffer_[i + VSOMEIP_SERVICE_POS_MAX]);
if (utility::is_request(
recv_buffer_[i + VSOMEIP_MESSAGE_TYPE_POS])) {
client_t its_client;
Expand All @@ -311,9 +335,16 @@ void udp_server_endpoint_impl::receive_cbk(
clients_[its_client][its_session] = remote_;
clients_to_endpoint_[its_client] = remote_;
clients_mutex_.unlock();
} else if (its_service != VSOMEIP_SD_SERVICE
&& utility::is_notification(recv_buffer_[i + VSOMEIP_MESSAGE_TYPE_POS])
&& joined_group_) {
std::lock_guard<std::mutex> its_lock(joined_mutex_);
boost::system::error_code ec;
const auto found_address = joined_.find(_destination.to_string(ec));
if (found_address != joined_.end()) {
found_address->second = true;
}
}
service_t its_service = VSOMEIP_BYTES_TO_WORD(recv_buffer_[i + VSOMEIP_SERVICE_POS_MIN],
recv_buffer_[i + VSOMEIP_SERVICE_POS_MAX]);
if (its_service != VSOMEIP_SD_SERVICE ||
(current_message_size > VSOMEIP_SOMEIP_HEADER_SIZE &&
current_message_size >= remaining_bytes)) {
Expand Down
5 changes: 5 additions & 0 deletions implementation/routing/include/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class event: public std::enable_shared_from_this<event> {

bool is_subscribed(client_t _client);

bool is_reliable() const;
void set_reliable(bool _is_reliable);

private:
void update_cbk(boost::system::error_code const &_error);
void notify(bool _flush);
Expand Down Expand Up @@ -146,6 +149,8 @@ class event: public std::enable_shared_from_this<event> {
std::atomic<bool> is_cache_placeholder_;

epsilon_change_func_t epsilon_change_func_;

std::atomic<bool> is_reliable_;
};

} // namespace vsomeip
Expand Down
4 changes: 4 additions & 0 deletions implementation/routing/include/eventgroupinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class eventgroupinfo {
VSOMEIP_EXPORT const std::set<std::shared_ptr<event> > get_events() const;
VSOMEIP_EXPORT void add_event(std::shared_ptr<event> _event);
VSOMEIP_EXPORT void remove_event(std::shared_ptr<event> _event);
VSOMEIP_EXPORT void get_reliability(bool& _has_reliable, bool& _has_unreliable) const;

VSOMEIP_EXPORT const std::list<target_t> get_targets() const;
VSOMEIP_EXPORT uint32_t get_unreliable_target_count() const;
Expand Down Expand Up @@ -93,6 +94,9 @@ class eventgroupinfo {

std::atomic<uint8_t> threshold_;
std::mutex subscription_mutex_;

std::atomic<bool> has_reliable_;
std::atomic<bool> has_unreliable_;
};

} // namespace vsomeip
Expand Down
2 changes: 1 addition & 1 deletion implementation/routing/include/routing_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class routing_manager {

virtual void set_routing_state(routing_state_e _routing_state) = 0;


virtual void send_get_offered_services_info(client_t _client, offer_type_e _offer_type) = 0;
};

} // namespace vsomeip
Expand Down
5 changes: 5 additions & 0 deletions implementation/routing/include/routing_manager_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class routing_manager_base : public routing_manager,
virtual void register_client_error_handler(client_t _client,
const std::shared_ptr<endpoint> &_endpoint) = 0;

virtual void send_get_offered_services_info(client_t _client, offer_type_e _offer_type) = 0;

protected:
std::shared_ptr<serviceinfo> find_service(service_t _service, instance_t _instance) const;
std::shared_ptr<serviceinfo> create_service_info(service_t _service,
Expand Down Expand Up @@ -254,6 +256,9 @@ class routing_manager_base : public routing_manager,
};
std::set<subscription_data_t> pending_subscriptions_;

services_t services_remote_;
std::mutex services_remote_mutex_;

private:
services_t services_;
mutable std::mutex services_mutex_;
Expand Down
1 change: 1 addition & 0 deletions implementation/routing/include/routing_manager_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class routing_manager_host {
virtual void on_subscription_status(service_t _service, instance_t _instance,
eventgroup_t _eventgroup, event_t _event, uint16_t _error) = 0;
virtual void send(std::shared_ptr<message> _message, bool _flush) = 0;
virtual void on_offered_services_info(std::vector<std::pair<service_t, instance_t>> &_services) = 0;
};

} // namespace vsomeip
Expand Down
12 changes: 11 additions & 1 deletion implementation/routing/include/routing_manager_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ class routing_manager_impl: public routing_manager_base,
std::shared_ptr<eventgroupinfo> find_eventgroup(service_t _service,
instance_t _instance, eventgroup_t _eventgroup) const;
services_t get_offered_services() const;
std::shared_ptr<serviceinfo> get_offered_service(
service_t _service, instance_t _instance) const;
std::map<instance_t, std::shared_ptr<serviceinfo>> get_offered_service_instances(
service_t _service) const;

std::shared_ptr<endpoint> create_service_discovery_endpoint(const std::string &_address,
uint16_t _port, bool _reliable);
void init_routing_info();
Expand Down Expand Up @@ -212,6 +217,11 @@ class routing_manager_impl: public routing_manager_base,

void set_routing_state(routing_state_e _routing_state);

void send_get_offered_services_info(client_t _client, offer_type_e _offer_type) {
(void) _client;
(void) _offer_type;
}

private:
bool deliver_message(const byte_t *_data, length_t _length,
instance_t _instance, bool _reliable, bool _is_valid_crc = true);
Expand Down Expand Up @@ -320,7 +330,7 @@ class routing_manager_impl: public routing_manager_base,
void requested_service_remove(client_t _client, service_t _service,
instance_t _instance);

void call_sd_reliable_endpoint_connected(const boost::system::error_code& _error,
void call_sd_endpoint_connected(const boost::system::error_code& _error,
service_t _service, instance_t _instance,
std::shared_ptr<endpoint> _endpoint,
std::shared_ptr<boost::asio::steady_timer> _timer);
Expand Down
4 changes: 4 additions & 0 deletions implementation/routing/include/routing_manager_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class routing_manager_proxy: public routing_manager_base {
const std::shared_ptr<endpoint> &_endpoint);
void handle_client_error(client_t _client);

void on_offered_services_info(const byte_t *_data, uint32_t _size);

void send_get_offered_services_info(client_t _client, offer_type_e _offer_type);

private:
void register_application();
void deregister_application();
Expand Down
10 changes: 10 additions & 0 deletions implementation/routing/include/routing_manager_stub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ class routing_manager_stub: public endpoint_host,
minor_version_t _minor = ANY_MINOR);
void send_client_routing_info(const client_t _target);

void create_offered_services_info(const client_t _target);
void insert_offered_services_info(client_t _target,
routing_info_entry_e _entry,
service_t _service,
instance_t _instance,
major_version_t _major,
minor_version_t _minor);
void send_offered_services_info(const client_t _target);

void on_client_id_timer_expired(boost::system::error_code const &_error);

private:
Expand Down Expand Up @@ -170,6 +179,7 @@ class routing_manager_stub: public endpoint_host,
std::map<client_t, std::set<client_t>> connection_matrix_;

std::map<client_t, std::vector<byte_t>> client_routing_info_;
std::map<client_t, std::vector<byte_t>> offered_services_info_;
};

} // namespace vsomeip
Expand Down
8 changes: 8 additions & 0 deletions implementation/routing/src/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,12 @@ bool event::is_subscribed(client_t _client) {
return false;
}

bool event::is_reliable() const {
return is_reliable_;
}

void event::set_reliable(bool _is_reliable) {
is_reliable_ = _is_reliable;
}

} // namespace vsomeip
Loading

0 comments on commit 686cb94

Please sign in to comment.