Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vSomeIP 3.5.3 #802

Merged
merged 23 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
Changes
=======

v3.5.3
- Revert fix compile issue with pthreads in android commit
- Revert Force abort hanging detached threads commit
- Remove dead code path
- Add timeout for detached threads
- Update wireshark dissector
- fix race condition on boost async operations
- Enabled initial event tests
- Add vsomeip config parsing
- Whitelist initial events tests
- Adds on_register_application_ack
- Suspend resume tests fix
- add service and method ids to the clients_ array
- Fix capturing references to stack variables
- Protects receiver_ and lock to routing stop function
- Add include unordered map
- Add remove local in deregistration(rmi)
- protect deserialization from malicious input
- Ignore send_cbk if the socket is not connected
- Move suspend/resume of endpoints
- Change handling of availabilities for wildcasts
- Allow to configure the initial routing state
- Enable subscription expiration

v3.5.1
- Restructure Network Tests CMakeLists
- policy.cpp unit test
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set (VSOMEIP_COMPAT_NAME vsomeip)

set (VSOMEIP_MAJOR_VERSION 3)
set (VSOMEIP_MINOR_VERSION 5)
set (VSOMEIP_PATCH_VERSION 1)
set (VSOMEIP_PATCH_VERSION 3)
set (VSOMEIP_HOTFIX_VERSION 0)

set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION})
Expand Down
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"cacheVariables": {
"CMAKE_CXX_FLAGS_INIT": {
"type": "STRING",
"value": "--coverage -Wno-error=tsan"
"value": "--coverage -Wno-error=tsan -fprofile-update=atomic"
},
"TEST_IP_SLAVE_SECOND": {
"type": "STRING",
Expand Down
8 changes: 5 additions & 3 deletions documentation/vsomeipProtocol.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# vSomeIP command documentation

Vsomeip protocol payload will contain a start and end tag with the following value: 0x67376d07 (the end tag is reversed).

## VSOMEIP_ASSIGN_CLIENT (0x00)

Command 00
Expand Down Expand Up @@ -47,14 +49,14 @@
Size xx xx xx xx
Client xx xx
[Address] xx .. xx ; Size - sizeof(Client) - sizeof(Port)
[Port] xx
[Port] xx xx

SubCommand xx ; RIE_ADD_SERVICE_INSTANCE (0x2) or RIE_DEL_SERVICE_INSTANCE (0x3)
SubCommand xx ; RIE_ADD_SERVICE_INSTANCE (0x2) or RIE_DEL_SERVICE_INSTANCE (0x4)
Size xx xx xx xx ; Command size
Size xx xx xx xx ; Client info size
Client xx xx
[Address] xx .. xx ; Client info size - sizeof(Client) - sizeof(Port)
[Port] xx
[Port] xx xx
Size xx xx xx xx ; Services size
Service xx xx
Instance xx xx
Expand Down
5 changes: 5 additions & 0 deletions documentation/vsomeipUserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,11 @@ Configuration file element explanation:
Specifies whether the Service Discovery is enabled (valid values: _true_,
_false_). The default value is _true_.

* `initial_state`

Specifies the initial Service Discovery state after startup
(valid values: _unknown_, _suspended_, _resumed_). The default value is _unknown_.

* `multicast`

The multicast address which the messages of the Service Discovery will be sent
Expand Down
1 change: 1 addition & 0 deletions implementation/configuration/include/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class configuration {
uid_t _uid, gid_t _gid) const = 0;

virtual bool is_local_routing() const = 0;
virtual routing_state_e get_initial_routing_state() const = 0;

virtual std::string get_unicast_address(service_t _service,
instance_t _instance) const = 0;
Expand Down
6 changes: 5 additions & 1 deletion implementation/configuration/include/configuration_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class configuration_impl:

VSOMEIP_EXPORT bool is_routing_enabled() const;
VSOMEIP_EXPORT bool is_local_routing() const;
VSOMEIP_EXPORT routing_state_e get_initial_routing_state() const;

VSOMEIP_EXPORT const std::string &get_routing_host_name() const;
VSOMEIP_EXPORT const boost::asio::ip::address &get_routing_host_address() const;
Expand Down Expand Up @@ -606,7 +607,8 @@ class configuration_impl:
ET_PARTITIONS,
ET_SECURITY_AUDIT_MODE,
ET_SECURITY_REMOTE_ACCESS,
ET_MAX = 46
ET_INITIAL_ROUTING_STATE,
ET_MAX = 47
};

bool is_configured_[ET_MAX];
Expand Down Expand Up @@ -683,6 +685,8 @@ class configuration_impl:
std::atomic_bool is_security_external_;
std::atomic_bool is_security_audit_;
std::atomic_bool is_remote_access_allowed_;

routing_state_e initial_routing_state_;
};

} // namespace cfg
Expand Down
8 changes: 7 additions & 1 deletion implementation/configuration/include/internal.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
#define VSOMEIP_MAX_DISPATCHERS 10
#define VSOMEIP_MAX_DISPATCH_TIME 100

#define VSOMEIP_MAX_WAIT_TIME_DETACHED_THREADS 5
#define VSOMEIP_MAX_WAIT_TIME_DETACHED_THREADS 3

#define VSOMEIP_REQUEST_DEBOUNCE_TIME 10
#define VSOMEIP_DEFAULT_STATISTICS_MAX_MSG 50
Expand All @@ -121,6 +121,10 @@
#define LOCAL_TCP_PORT_WAIT_TIME @VSOMEIP_LOCAL_TCP_PORT_WAIT_TIME@
#define LOCAL_TCP_PORT_MAX_WAIT_TIME @VSOMEIP_LOCAL_TCP_PORT_MAX_WAIT_TIME@

#define MIN_ENDPOINT_WAIT_INTERVAL 10
#define MAX_ENDPOINT_WAIT_INTERVAL 160
#define SUM_ENDPOINT_WAIT_INTERVAL 500

#if defined(__linux__) || defined(ANDROID) || defined(__QNX__)
#include <pthread.h>
#endif
Expand Down Expand Up @@ -153,6 +157,8 @@ inline constexpr std::uint32_t QUEUE_SIZE_UNLIMITED = (std::numeric_limits<std::
#define VSOMEIP_DEFAULT_NPDU_MAXIMUM_RETENTION_NANO 5 * 1000 * 1000

inline constexpr std::uint32_t MAX_RECONNECTS_UNLIMITED = (std::numeric_limits<std::uint32_t>::max)();
inline constexpr std::uint32_t MAX_RECONNECTS_LOCAL_UDS = 13;
inline constexpr std::uint32_t MAX_RECONNECTS_LOCAL_TCP = 5;

const uid_t ANY_UID = 0xFFFFFFFF;
const gid_t ANY_GID = 0xFFFFFFFF;
Expand Down
8 changes: 7 additions & 1 deletion implementation/configuration/include/internal_android.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#define VSOMEIP_MAX_DISPATCHERS 10
#define VSOMEIP_MAX_DISPATCH_TIME 100

#define VSOMEIP_MAX_WAIT_TIME_DETACHED_THREADS 5
#define VSOMEIP_MAX_WAIT_TIME_DETACHED_THREADS 3

#define VSOMEIP_REQUEST_DEBOUNCE_TIME 10
#define VSOMEIP_DEFAULT_STATISTICS_MAX_MSG 50
Expand All @@ -106,6 +106,10 @@
#define LOCAL_TCP_PORT_WAIT_TIME 100
#define LOCAL_TCP_PORT_MAX_WAIT_TIME 10000

#define MIN_ENDPOINT_WAIT_INTERVAL 10
#define MAX_ENDPOINT_WAIT_INTERVAL 160
#define SUM_ENDPOINT_WAIT_INTERVAL 500

#include <pthread.h>

#define VSOMEIP_DATA_ID 0x677D
Expand Down Expand Up @@ -143,6 +147,8 @@ inline constexpr std::uint32_t QUEUE_SIZE_UNLIMITED = std::numeric_limits<std::u
#define VSOMEIP_DEFAULT_NPDU_MAXIMUM_RETENTION_NANO 5 * 1000 * 1000

inline constexpr std::uint32_t MAX_RECONNECTS_UNLIMITED = std::numeric_limits<std::uint32_t>::max();
inline constexpr std::uint32_t MAX_RECONNECTS_LOCAL_UDS = 13;
inline constexpr std::uint32_t MAX_RECONNECTS_LOCAL_TCP = 5;

inline constexpr std::uint32_t ANY_UID = 0xFFFFFFFF;
inline constexpr std::uint32_t ANY_GID = 0xFFFFFFFF;
Expand Down
167 changes: 78 additions & 89 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,69 +44,45 @@
namespace vsomeip_v3 {
namespace cfg {

configuration_impl::configuration_impl(const std::string &_path)
: default_unicast_("local"),
is_loaded_(false),
is_logging_loaded_(false),
prefix_(VSOMEIP_PREFIX),
diagnosis_(VSOMEIP_DIAGNOSIS_ADDRESS),
diagnosis_mask_(0xFF00),
has_console_log_(true),
has_file_log_(false),
has_dlt_log_(false),
logfile_("/tmp/vsomeip.log"),
loglevel_(vsomeip_v3::logger::level_e::LL_INFO),
is_sd_enabled_(VSOMEIP_SD_DEFAULT_ENABLED),
sd_protocol_(VSOMEIP_SD_DEFAULT_PROTOCOL),
sd_multicast_(VSOMEIP_SD_DEFAULT_MULTICAST),
sd_port_(VSOMEIP_SD_DEFAULT_PORT),
sd_initial_delay_min_(VSOMEIP_SD_DEFAULT_INITIAL_DELAY_MIN),
sd_initial_delay_max_(VSOMEIP_SD_DEFAULT_INITIAL_DELAY_MAX),
sd_repetitions_base_delay_(VSOMEIP_SD_DEFAULT_REPETITIONS_BASE_DELAY),
sd_repetitions_max_(VSOMEIP_SD_DEFAULT_REPETITIONS_MAX),
sd_ttl_(VSOMEIP_SD_DEFAULT_TTL),
sd_cyclic_offer_delay_(VSOMEIP_SD_DEFAULT_CYCLIC_OFFER_DELAY),
sd_request_response_delay_(VSOMEIP_SD_DEFAULT_REQUEST_RESPONSE_DELAY),
sd_offer_debounce_time_(VSOMEIP_SD_DEFAULT_OFFER_DEBOUNCE_TIME),
sd_find_debounce_time_(VSOMEIP_SD_DEFAULT_FIND_DEBOUNCE_TIME),
max_configured_message_size_(0),
max_local_message_size_(0),
max_reliable_message_size_(0),
max_unreliable_message_size_(0),
buffer_shrink_threshold_(VSOMEIP_DEFAULT_BUFFER_SHRINK_THRESHOLD),
trace_(std::make_shared<trace>()),
watchdog_(std::make_shared<watchdog>()),
log_version_(true),
log_version_interval_(10),
permissions_uds_(VSOMEIP_DEFAULT_UDS_PERMISSIONS),
network_("vsomeip"),
e2e_enabled_(false),
log_memory_(false),
log_memory_interval_(0),
log_status_(false),
log_status_interval_(0),
endpoint_queue_limit_external_(QUEUE_SIZE_UNLIMITED),
endpoint_queue_limit_local_(QUEUE_SIZE_UNLIMITED),
tcp_restart_aborts_max_(VSOMEIP_MAX_TCP_RESTART_ABORTS),
tcp_connect_time_max_(VSOMEIP_MAX_TCP_CONNECT_TIME),
has_issued_methods_warning_(false),
has_issued_clients_warning_(false),
udp_receive_buffer_size_(VSOMEIP_DEFAULT_UDP_RCV_BUFFER_SIZE),
npdu_default_debounce_requ_(VSOMEIP_DEFAULT_NPDU_DEBOUNCING_NANO),
npdu_default_debounce_resp_(VSOMEIP_DEFAULT_NPDU_DEBOUNCING_NANO),
npdu_default_max_retention_requ_(VSOMEIP_DEFAULT_NPDU_MAXIMUM_RETENTION_NANO),
npdu_default_max_retention_resp_(VSOMEIP_DEFAULT_NPDU_MAXIMUM_RETENTION_NANO),
shutdown_timeout_(VSOMEIP_DEFAULT_SHUTDOWN_TIMEOUT),
log_statistics_(true),
statistics_interval_(VSOMEIP_DEFAULT_STATISTICS_INTERVAL),
statistics_min_freq_(VSOMEIP_DEFAULT_STATISTICS_MIN_FREQ),
statistics_max_messages_(VSOMEIP_DEFAULT_STATISTICS_MAX_MSG),
max_remote_subscribers_(VSOMEIP_DEFAULT_MAX_REMOTE_SUBSCRIBERS),
path_(_path),
is_security_enabled_(false),
is_security_external_(false),
is_security_audit_(false),
is_remote_access_allowed_(true) {
configuration_impl::configuration_impl(const std::string& _path) :
default_unicast_ {"local"}, is_loaded_ {false}, is_logging_loaded_ {false},
prefix_ {VSOMEIP_PREFIX}, diagnosis_ {VSOMEIP_DIAGNOSIS_ADDRESS}, diagnosis_mask_ {0xFF00},
has_console_log_ {true}, has_file_log_ {false}, has_dlt_log_ {false},
logfile_ {"/tmp/vsomeip.log"}, loglevel_ {vsomeip_v3::logger::level_e::LL_INFO},
is_sd_enabled_ {VSOMEIP_SD_DEFAULT_ENABLED}, sd_protocol_ {VSOMEIP_SD_DEFAULT_PROTOCOL},
sd_multicast_ {VSOMEIP_SD_DEFAULT_MULTICAST}, sd_port_ {VSOMEIP_SD_DEFAULT_PORT},
sd_initial_delay_min_ {VSOMEIP_SD_DEFAULT_INITIAL_DELAY_MIN},
sd_initial_delay_max_ {VSOMEIP_SD_DEFAULT_INITIAL_DELAY_MAX},
sd_repetitions_base_delay_ {VSOMEIP_SD_DEFAULT_REPETITIONS_BASE_DELAY},
sd_repetitions_max_ {VSOMEIP_SD_DEFAULT_REPETITIONS_MAX}, sd_ttl_ {VSOMEIP_SD_DEFAULT_TTL},
sd_cyclic_offer_delay_ {VSOMEIP_SD_DEFAULT_CYCLIC_OFFER_DELAY},
sd_request_response_delay_ {VSOMEIP_SD_DEFAULT_REQUEST_RESPONSE_DELAY},
sd_offer_debounce_time_ {VSOMEIP_SD_DEFAULT_OFFER_DEBOUNCE_TIME},
sd_find_debounce_time_ {VSOMEIP_SD_DEFAULT_FIND_DEBOUNCE_TIME},
max_configured_message_size_ {0}, max_local_message_size_ {0}, max_reliable_message_size_ {0},
max_unreliable_message_size_ {0},
buffer_shrink_threshold_ {VSOMEIP_DEFAULT_BUFFER_SHRINK_THRESHOLD},
trace_ {std::make_shared<trace>()}, watchdog_ {std::make_shared<watchdog>()},
log_version_ {true}, log_version_interval_ {10},
permissions_uds_ {VSOMEIP_DEFAULT_UDS_PERMISSIONS}, network_ {"vsomeip"}, e2e_enabled_ {false},
log_memory_ {false}, log_memory_interval_ {0}, log_status_ {false}, log_status_interval_ {0},
endpoint_queue_limit_external_ {QUEUE_SIZE_UNLIMITED},
endpoint_queue_limit_local_ {QUEUE_SIZE_UNLIMITED},
tcp_restart_aborts_max_ {VSOMEIP_MAX_TCP_RESTART_ABORTS},
tcp_connect_time_max_ {VSOMEIP_MAX_TCP_CONNECT_TIME}, has_issued_methods_warning_ {false},
has_issued_clients_warning_ {false},
udp_receive_buffer_size_ {VSOMEIP_DEFAULT_UDP_RCV_BUFFER_SIZE},
npdu_default_debounce_requ_ {VSOMEIP_DEFAULT_NPDU_DEBOUNCING_NANO},
npdu_default_debounce_resp_ {VSOMEIP_DEFAULT_NPDU_DEBOUNCING_NANO},
npdu_default_max_retention_requ_ {VSOMEIP_DEFAULT_NPDU_MAXIMUM_RETENTION_NANO},
npdu_default_max_retention_resp_ {VSOMEIP_DEFAULT_NPDU_MAXIMUM_RETENTION_NANO},
shutdown_timeout_ {VSOMEIP_DEFAULT_SHUTDOWN_TIMEOUT}, log_statistics_ {true},
statistics_interval_ {VSOMEIP_DEFAULT_STATISTICS_INTERVAL},
statistics_min_freq_ {VSOMEIP_DEFAULT_STATISTICS_MIN_FREQ},
statistics_max_messages_ {VSOMEIP_DEFAULT_STATISTICS_MAX_MSG},
max_remote_subscribers_ {VSOMEIP_DEFAULT_MAX_REMOTE_SUBSCRIBERS}, path_ {_path},
is_security_enabled_ {false}, is_security_external_ {false}, is_security_audit_ {false},
is_remote_access_allowed_ {true}, initial_routing_state_ {routing_state_e::RS_UNKNOWN} {

policy_manager_ = std::make_shared<policy_manager_impl>();
security_ = std::make_shared<security>(policy_manager_);
Expand All @@ -123,32 +99,29 @@ configuration_impl::configuration_impl(const std::string &_path)
#endif
}

configuration_impl::configuration_impl(const configuration_impl &_other)
: std::enable_shared_from_this<configuration_impl>(_other),
default_unicast_(_other.default_unicast_),
is_loaded_(_other.is_loaded_),
is_logging_loaded_(_other.is_logging_loaded_),
mandatory_(_other.mandatory_),
has_console_log_(_other.has_console_log_.load()),
has_file_log_(_other.has_file_log_.load()),
has_dlt_log_(_other.has_dlt_log_.load()),
max_configured_message_size_(_other.max_configured_message_size_),
max_local_message_size_(_other.max_local_message_size_),
max_reliable_message_size_(_other.max_reliable_message_size_),
max_unreliable_message_size_(_other.max_unreliable_message_size_),
buffer_shrink_threshold_(_other.buffer_shrink_threshold_),
permissions_uds_(VSOMEIP_DEFAULT_UDS_PERMISSIONS),
endpoint_queue_limit_external_(_other.endpoint_queue_limit_external_),
endpoint_queue_limit_local_(_other.endpoint_queue_limit_local_),
tcp_restart_aborts_max_(_other.tcp_restart_aborts_max_),
tcp_connect_time_max_(_other.tcp_connect_time_max_),
udp_receive_buffer_size_(_other.udp_receive_buffer_size_),
npdu_default_debounce_requ_(_other.npdu_default_debounce_requ_),
npdu_default_debounce_resp_(_other.npdu_default_debounce_resp_),
npdu_default_max_retention_requ_(_other.npdu_default_max_retention_requ_),
npdu_default_max_retention_resp_(_other.npdu_default_max_retention_resp_),
shutdown_timeout_(_other.shutdown_timeout_),
path_(_other.path_) {
configuration_impl::configuration_impl(const configuration_impl& _other) :
std::enable_shared_from_this<configuration_impl>(_other),
default_unicast_ {_other.default_unicast_}, is_loaded_ {_other.is_loaded_},
is_logging_loaded_ {_other.is_logging_loaded_}, mandatory_ {_other.mandatory_},
has_console_log_ {_other.has_console_log_.load()}, has_file_log_ {_other.has_file_log_.load()},
has_dlt_log_ {_other.has_dlt_log_.load()},
max_configured_message_size_ {_other.max_configured_message_size_},
max_local_message_size_ {_other.max_local_message_size_},
max_reliable_message_size_ {_other.max_reliable_message_size_},
max_unreliable_message_size_ {_other.max_unreliable_message_size_},
buffer_shrink_threshold_ {_other.buffer_shrink_threshold_},
permissions_uds_ {VSOMEIP_DEFAULT_UDS_PERMISSIONS},
endpoint_queue_limit_external_ {_other.endpoint_queue_limit_external_},
endpoint_queue_limit_local_ {_other.endpoint_queue_limit_local_},
tcp_restart_aborts_max_ {_other.tcp_restart_aborts_max_},
tcp_connect_time_max_ {_other.tcp_connect_time_max_},
udp_receive_buffer_size_ {_other.udp_receive_buffer_size_},
npdu_default_debounce_requ_ {_other.npdu_default_debounce_requ_},
npdu_default_debounce_resp_ {_other.npdu_default_debounce_resp_},
npdu_default_max_retention_requ_ {_other.npdu_default_max_retention_requ_},
npdu_default_max_retention_resp_ {_other.npdu_default_max_retention_resp_},
shutdown_timeout_ {_other.shutdown_timeout_}, path_ {_other.path_},
initial_routing_state_ {_other.initial_routing_state_} {

applications_.insert(_other.applications_.begin(), _other.applications_.end());
client_identifiers_ = _other.client_identifiers_;
Expand Down Expand Up @@ -1877,6 +1850,18 @@ void configuration_impl::load_service_discovery(
}
is_configured_[ET_MAX_REMOTE_SUBSCRIBERS] = true;
}
} else if (its_key == "initial_state") {
if (is_configured_[ET_INITIAL_ROUTING_STATE]) {
VSOMEIP_WARNING << "Multiple definitions for service_discovery.initial_state."
" Ignoring definition from "
<< _element.name_;
} else {
if (its_value == "suspended") {
initial_routing_state_ = routing_state_e::RS_SUSPENDED;
} else if (its_value == "resumed") {
initial_routing_state_ = routing_state_e::RS_RESUMED;
}
}
}
}
} catch (...) {
Expand Down Expand Up @@ -5065,5 +5050,9 @@ std::shared_ptr<security> configuration_impl::get_security() const {
return security_;
}

routing_state_e configuration_impl::get_initial_routing_state() const {
return initial_routing_state_;
}

} // namespace cfg
} // namespace vsomeip_v3
1 change: 1 addition & 0 deletions implementation/endpoints/include/client_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class client_endpoint_impl: public endpoint_impl<Protocol>, public client_endpoi

bool is_established() const;
bool is_established_or_connected() const;
bool is_closed() const;
void set_established(bool _established);
void set_connected(bool _connected);
virtual bool get_remote_address(boost::asio::ip::address &_address) const;
Expand Down
1 change: 1 addition & 0 deletions implementation/endpoints/include/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class endpoint {

virtual bool is_established() const = 0;
virtual bool is_established_or_connected() const = 0;
virtual bool is_closed() const = 0;

virtual bool send(const byte_t *_data, uint32_t _size) = 0;
virtual bool send_to(const std::shared_ptr<endpoint_definition> _target,
Expand Down
Loading
Loading