Skip to content

Commit

Permalink
vsomeip 2.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent 005f77c commit ca8af4e
Show file tree
Hide file tree
Showing 18 changed files with 582 additions and 146 deletions.
9 changes: 9 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changes
=======

v2.10.4
- Extended diagnosis plugin to handle requests for
"disableRxAndEnableTx" and "disableRxAndTx".
- Catch unhandled user code exceptions thrown from called handlers.
- Don't send SubscribeEventGroupNACK for pending subscriptions on next
offer to reduce the amount of StopSubscribe/Subscribe messages.
- Added possibility to apply filter for client side logging
using VSOMEIP_CLIENTSIDELOGGING environment variable.

v2.10.3
- Interpret all incoming TTLs five times longer in service discovery
to prevent inadvertent expiration of remote offers during high load
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project (vsomeip)

set (VSOMEIP_MAJOR_VERSION 2)
set (VSOMEIP_MINOR_VERSION 10)
set (VSOMEIP_PATCH_VERSION 3)
set (VSOMEIP_PATCH_VERSION 4)
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
41 changes: 36 additions & 5 deletions documentation/vsomeipUserGuide
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,14 @@ On startup the following environment variables are read out:
applications, all other configuration files are only read by the application that is
responsible for connections to external devices. If this configuration variable is not set,
the default mandatory files vsomeip_std.json, vsomeip_app.json and vsomeip_plc.json are used.
* `VSOMEIP_CLIENTSIDELOGGING`: Set this variable to an empty string or an arbitrary
value to enable logging of received messages to DLT in all applications
acting as routing manager proxies. For example add the following line to the
application's systemd service file:
* `VSOMEIP_CLIENTSIDELOGGING`: Set this variable to an empty string to enable logging of
any received messages to DLT in all applications acting as routing manager proxies. For
example add the following line to the application's systemd service file:
`Environment=VSOMEIP_CLIENTSIDELOGGING=""`
To enable service-specific logs, provide a space- or colon-separated list of ServiceIDs (using
4-digit hexadecimal notation, optionally followed by dot-separted InstanceID). For example:
`Environment=VSOMEIP_CLIENTSIDELOGGING="b003.0001 f013.000a 1001 1002"`
`Environment=VSOMEIP_CLIENTSIDELOGGING="b003.0001:f013.000a:1001:1002"`

NOTE: If the file/folder that is configured by `VSOMEIP_CONFIGURATION` does _not_ exist,
the default configuration locations will be used.
Expand Down Expand Up @@ -907,9 +910,37 @@ Specifies a service for the _offers_.
+
Specifies a instance for the _offers_

In the config/ folder are some vSomeIP configuration files to run the vSomeIP examples with activated security checks.
In the `config/` folder are some vSomeIP configuration files to run the vSomeIP
examples with activated security checks.
Additionally there's a security test in the `test/` subfolder which can be used
for further reference. +
They give a basic overview how to use the security related configuration tags described in this chapter to run a simple request/response or subscribe/notify example locally or over remote.

Audit Mode
~~~~~~~~~~
vSomeIP's security implementation can be put in a so called 'Audit Mode' where
all security violations will be logged but allowed. This mode can be used to
build a security configuration.

To activate the 'Audit Mode' the 'security' object has to be included in the
json file but the 'check_credentials' switch has to be set to false. For
example:

[source, json]
----
[...]
"services" :
[
[...]
],
"security" :
{
"check_credentials" : "false"
},
"routing" : "service-sample",
[...]
----

Autoconfiguration
-----------------
vsomeip supports the automatic configuration of client identifiers and the routing.
Expand Down
4 changes: 0 additions & 4 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,6 @@ bool configuration_impl::load_data(const std::vector<element> &_elements,
}
}

for (auto its_service : services_) {
VSOMEIP_INFO << "service: " << its_service.first;
}

return is_logging_loaded_ && has_routing && has_applications;
}

Expand Down
10 changes: 9 additions & 1 deletion implementation/endpoints/include/tcp_client_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl {
endpoint_type _remote,
boost::asio::io_service &_io,
std::uint32_t _max_message_size,
std::uint32_t buffer_shrink_threshold);
std::uint32_t buffer_shrink_threshold,
std::chrono::milliseconds _send_timeout);
virtual ~tcp_client_endpoint_impl();

void start();
Expand All @@ -52,6 +53,11 @@ class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl {
const std::string get_address_port_local() const;
void handle_recv_buffer_exception(const std::exception &_e);
void set_local_port();
std::size_t write_completion_condition(
const boost::system::error_code& _error,
std::size_t _bytes_transferred, std::size_t _bytes_to_send,
service_t _service, method_t _method, client_t _client, session_t _session,
std::chrono::steady_clock::time_point _start);


const std::uint32_t recv_buffer_size_initial_;
Expand All @@ -64,6 +70,8 @@ class tcp_client_endpoint_impl: public tcp_client_endpoint_base_impl {
const boost::asio::ip::address remote_address_;
const std::uint16_t remote_port_;
std::chrono::steady_clock::time_point last_cookie_sent_;
const std::chrono::milliseconds send_timeout_;
const std::chrono::milliseconds send_timeout_warning_;
};

} // namespace vsomeip
Expand Down
19 changes: 15 additions & 4 deletions implementation/endpoints/include/tcp_server_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class tcp_server_endpoint_impl: public tcp_server_endpoint_base_impl {
endpoint_type _local,
boost::asio::io_service &_io,
std::uint32_t _max_message_size,
std::uint32_t _buffer_shrink_threshold);
std::uint32_t _buffer_shrink_threshold,
std::chrono::milliseconds _send_timeout);
virtual ~tcp_server_endpoint_impl();

void start();
Expand Down Expand Up @@ -64,7 +65,8 @@ class tcp_server_endpoint_impl: public tcp_server_endpoint_base_impl {
std::uint32_t _max_message_size,
std::uint32_t _buffer_shrink_threshold,
bool _magic_cookies_enabled,
boost::asio::io_service & _io_service);
boost::asio::io_service & _io_service,
std::chrono::milliseconds _send_timeout);
socket_type & get_socket();
std::unique_lock<std::mutex> get_socket_lock();

Expand All @@ -84,15 +86,21 @@ class tcp_server_endpoint_impl: public tcp_server_endpoint_base_impl {
std::uint32_t _recv_buffer_size_initial,
std::uint32_t _buffer_shrink_threshold,
bool _magic_cookies_enabled,
boost::asio::io_service & _io_service);
boost::asio::io_service & _io_service,
std::chrono::milliseconds _send_timeout);
void send_magic_cookie(message_buffer_ptr_t &_buffer);
bool is_magic_cookie(size_t _offset) const;
void receive_cbk(boost::system::error_code const &_error,
std::size_t _bytes);
void calculate_shrink_count();
const std::string get_address_port_local() const;
void handle_recv_buffer_exception(const std::exception &_e);

std::size_t write_completion_condition(
const boost::system::error_code& _error,
std::size_t _bytes_transferred, std::size_t _bytes_to_send,
service_t _service, method_t _method, client_t _client, session_t _session,
std::chrono::steady_clock::time_point _start);
void stop_and_remove_connection();

std::mutex socket_mutex_;
tcp_server_endpoint_impl::socket_type socket_;
Expand All @@ -112,6 +120,8 @@ class tcp_server_endpoint_impl: public tcp_server_endpoint_base_impl {
std::uint16_t remote_port_;
std::atomic<bool> magic_cookies_enabled_;
std::chrono::steady_clock::time_point last_cookie_sent_;
const std::chrono::milliseconds send_timeout_;
const std::chrono::milliseconds send_timeout_warning_;
};

std::mutex acceptor_mutex_;
Expand All @@ -121,6 +131,7 @@ class tcp_server_endpoint_impl: public tcp_server_endpoint_base_impl {
connections_t connections_;
const std::uint32_t buffer_shrink_threshold_;
const std::uint16_t local_port_;
const std::chrono::milliseconds send_timeout_;

private:
void remove_connection(connection *_connection);
Expand Down
98 changes: 96 additions & 2 deletions implementation/endpoints/src/tcp_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
#include "../include/tcp_client_endpoint_impl.hpp"
#include "../../logging/include/logger.hpp"
#include "../../utility/include/utility.hpp"
#include "../../utility/include/byteorder.hpp"
#include "../../configuration/include/internal.hpp"


namespace ip = boost::asio::ip;

namespace vsomeip {
Expand All @@ -26,7 +28,8 @@ tcp_client_endpoint_impl::tcp_client_endpoint_impl(
endpoint_type _remote,
boost::asio::io_service &_io,
std::uint32_t _max_message_size,
std::uint32_t _buffer_shrink_threshold)
std::uint32_t _buffer_shrink_threshold,
std::chrono::milliseconds _send_timeout)
: tcp_client_endpoint_base_impl(_host, _local, _remote, _io, _max_message_size),
recv_buffer_size_initial_(VSOMEIP_SOMEIP_HEADER_SIZE),
recv_buffer_(recv_buffer_size_initial_, 0),
Expand All @@ -36,7 +39,9 @@ tcp_client_endpoint_impl::tcp_client_endpoint_impl(
buffer_shrink_threshold_(_buffer_shrink_threshold),
remote_address_(_remote.address()),
remote_port_(_remote.port()),
last_cookie_sent_(std::chrono::steady_clock::now() - std::chrono::seconds(11)) {
last_cookie_sent_(std::chrono::steady_clock::now() - std::chrono::seconds(11)),
send_timeout_(_send_timeout),
send_timeout_warning_(_send_timeout / 2) {
is_supporting_magic_cookies_ = true;
}

Expand Down Expand Up @@ -67,6 +72,27 @@ void tcp_client_endpoint_impl::restart() {
}
{
std::lock_guard<std::mutex> its_lock(mutex_);
for (const auto&m : queue_) {
const service_t its_service = VSOMEIP_BYTES_TO_WORD(
(*m)[VSOMEIP_SERVICE_POS_MIN],
(*m)[VSOMEIP_SERVICE_POS_MAX]);
const method_t its_method = VSOMEIP_BYTES_TO_WORD(
(*m)[VSOMEIP_METHOD_POS_MIN],
(*m)[VSOMEIP_METHOD_POS_MAX]);
const client_t its_client = VSOMEIP_BYTES_TO_WORD(
(*m)[VSOMEIP_CLIENT_POS_MIN],
(*m)[VSOMEIP_CLIENT_POS_MAX]);
const session_t its_session = VSOMEIP_BYTES_TO_WORD(
(*m)[VSOMEIP_SESSION_POS_MIN],
(*m)[VSOMEIP_SESSION_POS_MAX]);
VSOMEIP_WARNING << "tce::restart: dropping message: "
<< "remote:" << get_address_port_remote() << " ("
<< std::hex << std::setw(4) << std::setfill('0') << its_client <<"): ["
<< std::hex << std::setw(4) << std::setfill('0') << its_service << "."
<< std::hex << std::setw(4) << std::setfill('0') << its_method << "."
<< std::hex << std::setw(4) << std::setfill('0') << its_session << "]"
<< " size: " << std::dec << m->size();
}
queue_.clear();
}
start_connect_timer();
Expand Down Expand Up @@ -174,6 +200,18 @@ void tcp_client_endpoint_impl::send_queued() {
} else {
return;
}
const service_t its_service = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_SERVICE_POS_MIN],
(*its_buffer)[VSOMEIP_SERVICE_POS_MAX]);
const method_t its_method = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_METHOD_POS_MIN],
(*its_buffer)[VSOMEIP_METHOD_POS_MAX]);
const client_t its_client = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_CLIENT_POS_MIN],
(*its_buffer)[VSOMEIP_CLIENT_POS_MAX]);
const session_t its_session = VSOMEIP_BYTES_TO_WORD(
(*its_buffer)[VSOMEIP_SESSION_POS_MIN],
(*its_buffer)[VSOMEIP_SESSION_POS_MAX]);

if (has_enabled_magic_cookies_) {
const std::chrono::steady_clock::time_point now =
Expand All @@ -200,6 +238,13 @@ void tcp_client_endpoint_impl::send_queued() {
boost::asio::async_write(
*socket_,
boost::asio::buffer(*its_buffer),
std::bind(&tcp_client_endpoint_impl::write_completion_condition,
std::static_pointer_cast<tcp_client_endpoint_impl>(shared_from_this()),
std::placeholders::_1,
std::placeholders::_2,
its_buffer->size(),
its_service, its_method, its_client, its_session,
std::chrono::steady_clock::now()),
std::bind(
&tcp_client_endpoint_base_impl::send_cbk,
shared_from_this(),
Expand Down Expand Up @@ -233,6 +278,55 @@ void tcp_client_endpoint_impl::set_local_port() {
}
}

std::size_t tcp_client_endpoint_impl::write_completion_condition(
const boost::system::error_code& _error, std::size_t _bytes_transferred,
std::size_t _bytes_to_send, service_t _service, method_t _method,
client_t _client, session_t _session,
std::chrono::steady_clock::time_point _start) {

if (_error) {
VSOMEIP_ERROR << "tce::write_completion_condition: "
<< _error.message() << "(" << std::dec << _error.value()
<< ") bytes transferred: " << std::dec << _bytes_transferred
<< " bytes to sent: " << std::dec << _bytes_to_send << " "
<< "remote:" << get_address_port_remote() << " ("
<< std::hex << std::setw(4) << std::setfill('0') << _client <<"): ["
<< std::hex << std::setw(4) << std::setfill('0') << _service << "."
<< std::hex << std::setw(4) << std::setfill('0') << _method << "."
<< std::hex << std::setw(4) << std::setfill('0') << _session << "]";
return 0;
}

std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
std::chrono::milliseconds passed = std::chrono::duration_cast<std::chrono::milliseconds>(now - _start);
if (passed > send_timeout_warning_) {
if (passed > send_timeout_) {
VSOMEIP_ERROR << "tce::write_completion_condition: "
<< _error.message() << "(" << std::dec << _error.value()
<< ") took longer than " << std::dec << send_timeout_.count()
<< "ms bytes transferred: " << std::dec << _bytes_transferred
<< " bytes to sent: " << std::dec << _bytes_to_send << " "
<< "remote:" << get_address_port_remote() << " ("
<< std::hex << std::setw(4) << std::setfill('0') << _client <<"): ["
<< std::hex << std::setw(4) << std::setfill('0') << _service << "."
<< std::hex << std::setw(4) << std::setfill('0') << _method << "."
<< std::hex << std::setw(4) << std::setfill('0') << _session << "]";
} else {
VSOMEIP_WARNING << "tce::write_completion_condition: "
<< _error.message() << "(" << std::dec << _error.value()
<< ") took longer than " << std::dec << send_timeout_warning_.count()
<< "ms bytes transferred: " << std::dec << _bytes_transferred
<< " bytes to sent: " << std::dec << _bytes_to_send << " "
<< "remote:" << get_address_port_remote() << " ("
<< std::hex << std::setw(4) << std::setfill('0') << _client <<"): ["
<< std::hex << std::setw(4) << std::setfill('0') << _service << "."
<< std::hex << std::setw(4) << std::setfill('0') << _method << "."
<< std::hex << std::setw(4) << std::setfill('0') << _session << "]";
}
}
return _bytes_to_send - _bytes_transferred;
}

std::uint16_t tcp_client_endpoint_impl::get_remote_port() const {
return remote_port_;
}
Expand Down
Loading

0 comments on commit ca8af4e

Please sign in to comment.