Skip to content

Commit

Permalink
vsomeip 3.1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzbichler committed Dec 4, 2020
1 parent 710a861 commit 0f51130
Show file tree
Hide file tree
Showing 18 changed files with 273 additions and 169 deletions.
11 changes: 11 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Changes
=======

v3.1.20.2
- Removed special way of detecting boost within NDK (PR #187)
- Allow events/eventgroups to be specified in arbitrary order (Issue #68)
- Allow port 65536 to be used (Issue #80)
- Support IPv6 (Issue #162, PR #179)
- Fix handling of local service history (Issue #163)
- Fix referencing of placeholder events (Issue #175)
- Corrected handling of debounced requests when releasing (Issue #181)
- Fixed possible race when disconnecting (Issue #182)
- Align order of acknowledgement and value sending (Issue #183)

v3.1.20.1
- CMakeLists.txt fixes
(by Martin Haase)
Expand Down
10 changes: 2 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set (VSOMEIP_COMPAT_NAME vsomeip)
set (VSOMEIP_MAJOR_VERSION 3)
set (VSOMEIP_MINOR_VERSION 1)
set (VSOMEIP_PATCH_VERSION 20)
set (VSOMEIP_HOTFIX_VERSION 1)
set (VSOMEIP_HOTFIX_VERSION 2)

set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP_PATCH_VERSION})
set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentation/doxygen.in
Expand Down Expand Up @@ -140,13 +140,7 @@ endif ()
find_package(Threads REQUIRED)

# Boost
if (${CMAKE_SYSTEM_NAME} MATCHES "Android")
# Please implement your macro workaround to set Boost_ variables, because NDK does not have Boost libs package
# Example of macro implementation you can find in test project that mentioned in examples/hello_world/readme_android
ndk_find_package_boost(system thread filesystem)
else()
find_package( Boost 1.55 COMPONENTS system thread filesystem REQUIRED )
endif()
find_package( Boost 1.55 COMPONENTS system thread filesystem REQUIRED )
include_directories( ${Boost_INCLUDE_DIR} )

if(Boost_FOUND)
Expand Down
8 changes: 5 additions & 3 deletions implementation/configuration/include/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ namespace cfg {
struct eventgroup;

struct event {
event(event_t _id, bool _is_field, reliability_type_e _reliability)
event(event_t _id)
: id_(_id),
is_field_(_is_field),
reliability_(_reliability) {
is_placeholder_(true),
is_field_(false),
reliability_(reliability_type_e::RT_UNRELIABLE) {
}

event_t id_;
bool is_placeholder_;
bool is_field_;
reliability_type_e reliability_;
std::vector<std::weak_ptr<eventgroup> > groups_;
Expand Down
28 changes: 19 additions & 9 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,13 +1627,24 @@ void configuration_impl::load_event(
}

if (its_event_id > 0) {
std::shared_ptr<event> its_event;

auto found_event = _service->events_.find(its_event_id);
if (found_event != _service->events_.end()) {
VSOMEIP_ERROR << "Multiple configurations for event ["
<< std::hex << _service->service_ << "."
<< _service->instance_ << "."
<< its_event_id << "]";
if (found_event->second->is_placeholder_) {
its_event = found_event->second;
} else {
VSOMEIP_ERROR << "Multiple configurations for event ["
<< std::hex << _service->service_ << "."
<< _service->instance_ << "."
<< its_event_id << "]";
}
} else {
its_event = std::make_shared<event>(its_event_id);
_service->events_[its_event_id] = its_event;
}

if (its_event) {
// If event reliability type was not configured,
if (its_reliability == reliability_type_e::RT_UNKNOWN) {
if (_service->unreliable_ != ILLEGAL_PORT) {
Expand All @@ -1649,9 +1660,9 @@ void configuration_impl::load_event(
? "RT_RELIABLE" : "RT_UNRELIABLE");
}

std::shared_ptr<event> its_event = std::make_shared<event>(
its_event_id, its_is_field, its_reliability);
_service->events_[its_event_id] = its_event;
its_event->is_placeholder_ = false;
its_event->reliability_ = its_reliability;
its_event->is_field_ = its_is_field;
}
}
}
Expand Down Expand Up @@ -1715,8 +1726,7 @@ void configuration_impl::load_eventgroup(
if (find_event != _service->events_.end()) {
its_event = find_event->second;
} else {
its_event = std::make_shared<event>(its_event_id,
false, reliability_type_e::RT_UNRELIABLE);
its_event = std::make_shared<event>(its_event_id);
}
if (its_event) {
its_event->groups_.push_back(its_eventgroup);
Expand Down
4 changes: 3 additions & 1 deletion implementation/endpoints/src/endpoint_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ std::shared_ptr<endpoint> endpoint_manager_impl::create_server_endpoint(
<< " Server endpoint creation failed."
<< " Reason: "<< e.what()
<< " Port: " << _port
<< " (" << _reliable << ")";
<< " (reliable="
<< (_reliable ? "reliable" : "unreliable")
<< ")";
}

return (its_endpoint);
Expand Down
34 changes: 16 additions & 18 deletions implementation/endpoints/src/tcp_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,24 @@ void tcp_client_endpoint_impl::connect() {
}
#endif

// In case a client endpoint port was configured,
// bind to it before connecting
if (local_.port() != ILLEGAL_PORT) {
boost::system::error_code its_bind_error;
socket_->bind(local_, its_bind_error);
if(its_bind_error) {
VSOMEIP_WARNING << "tcp_client_endpoint::connect: "
"Error binding socket: " << its_bind_error.message()
<< " remote:" << get_address_port_remote();
try {
// don't connect on bind error to avoid using a random port
strand_.post(std::bind(&client_endpoint_impl::connect_cbk,
shared_from_this(), its_bind_error));
} catch (const std::exception &e) {
VSOMEIP_ERROR << "tcp_client_endpoint_impl::connect: "
<< e.what() << " remote:" << get_address_port_remote();
}
return;
// Bind address and, optionally, port.
boost::system::error_code its_bind_error;
socket_->bind(local_, its_bind_error);
if(its_bind_error) {
VSOMEIP_WARNING << "tcp_client_endpoint::connect: "
"Error binding socket: " << its_bind_error.message()
<< " remote:" << get_address_port_remote();
try {
// don't connect on bind error to avoid using a random port
strand_.post(std::bind(&client_endpoint_impl::connect_cbk,
shared_from_this(), its_bind_error));
} catch (const std::exception &e) {
VSOMEIP_ERROR << "tcp_client_endpoint_impl::connect: "
<< e.what() << " remote:" << get_address_port_remote();
}
return;
}

state_ = cei_state_e::CONNECTING;
connect_timepoint_ = std::chrono::steady_clock::now();
aborted_restart_count_ = 0;
Expand Down
38 changes: 15 additions & 23 deletions implementation/endpoints/src/udp_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ void udp_client_endpoint_impl::connect() {
}
}

if (local_.port() == ILLEGAL_PORT) {
// Let the OS assign the port
local_.port(0);
}

#ifndef _WIN32
// If specified, bind to device
std::string its_device(configuration_->get_device());
Expand All @@ -100,25 +95,22 @@ void udp_client_endpoint_impl::connect() {
}
#endif

// In case a client endpoint port was configured,
// bind to it before connecting
if (local_.port() != ILLEGAL_PORT) {
boost::system::error_code its_bind_error;
socket_->bind(local_, its_bind_error);
if(its_bind_error) {
VSOMEIP_WARNING << "udp_client_endpoint::connect: "
"Error binding socket: " << its_bind_error.message()
<< " remote:" << get_address_port_remote();
try {
// don't connect on bind error to avoid using a random port
strand_.post(std::bind(&client_endpoint_impl::connect_cbk,
shared_from_this(), its_bind_error));
} catch (const std::exception &e) {
VSOMEIP_ERROR << "udp_client_endpoint_impl::connect: "
<< e.what() << " remote:" << get_address_port_remote();
}
return;
// Bind address and, optionally, port.
boost::system::error_code its_bind_error;
socket_->bind(local_, its_bind_error);
if(its_bind_error) {
VSOMEIP_WARNING << "udp_client_endpoint::connect: "
"Error binding socket: " << its_bind_error.message()
<< " remote:" << get_address_port_remote();
try {
// don't connect on bind error to avoid using a random port
strand_.post(std::bind(&client_endpoint_impl::connect_cbk,
shared_from_this(), its_bind_error));
} catch (const std::exception &e) {
VSOMEIP_ERROR << "udp_client_endpoint_impl::connect: "
<< e.what() << " remote:" << get_address_port_remote();
}
return;
}

state_ = cei_state_e::CONNECTING;
Expand Down
18 changes: 14 additions & 4 deletions implementation/endpoints/src/udp_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,22 @@ void udp_server_endpoint_impl::join_unlocked(const std::string &_address) {

#ifdef _WIN32
const char* optval("0001");
::setsockopt(multicast_socket_->native_handle(), IPPROTO_IP, IP_PKTINFO,
optval, sizeof(optval));
if (is_v4) {
::setsockopt(multicast_socket_->native_handle(), IPPROTO_IP, IP_PKTINFO,
optval, sizeof(optval));
} else if (is_v6) {
::setsockopt(multicast_socket_->native_handle(), IPPROTO_IPV6, IPV6_PKTINFO,
optval, sizeof(optval));
}
#else
int optval(1);
::setsockopt(multicast_socket_->native_handle(), IPPROTO_IP, IP_PKTINFO,
&optval, sizeof(optval));
if (is_v4) {
::setsockopt(multicast_socket_->native_handle(), IPPROTO_IP, IP_PKTINFO,
&optval, sizeof(optval));
} else {
::setsockopt(multicast_socket_->native_handle(), IPPROTO_IPV6, IPV6_RECVPKTINFO,
&optval, sizeof(optval));
}
#endif
multicast_id_++;
receive_multicast(multicast_id_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,30 @@ signed_size_type recvfrom(socket_type s, buf* bufs, size_t count,
if (result >= 0) {
ec = boost::system::error_code();

// Find destination address
for (LPWSACMSGHDR cmsg = WSA_CMSG_FIRSTHDR(&msg);
cmsg != NULL;
cmsg = WSA_CMSG_NXTHDR(&msg, cmsg))
{
if (cmsg->cmsg_level != IPPROTO_IP || cmsg->cmsg_type != IP_PKTINFO)
continue;

struct in_pktinfo *pi = (struct in_pktinfo *) WSA_CMSG_DATA(cmsg);
if (pi)
{
da = boost::asio::ip::address_v4(ntohl(pi->ipi_addr.s_addr));
}
}
// Find destination address
for (LPWSACMSGHDR cmsg = WSA_CMSG_FIRSTHDR(&msg);
cmsg != NULL;
cmsg = WSA_CMSG_NXTHDR(&msg, cmsg))
{
if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO)
{
struct in_pktinfo *pi = (struct in_pktinfo *) WSA_CMSG_DATA(cmsg);
if (pi)
{
da = boost::asio::ip::address_v4(ntohl(pi->ipi_addr.s_addr));
}
} else
if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO)
{
struct in6_pktinfo *pi = (struct in6_pktinfo *) WSA_CMSG_DATA(cmsg);
if (pi)
{
boost::asio::ip::address_v6::bytes_type b;
memcpy(b.data(), pi->ipi6_addr.s6_addr, sizeof(pi->ipi6_addr.s6_addr));
da = boost::asio::ip::address_v6(b);
}
}
}
} else {
dwNumberOfBytesRecvd = -1;
}
Expand All @@ -91,20 +101,30 @@ signed_size_type recvfrom(socket_type s, buf* bufs, size_t count,
if (result >= 0) {
ec = boost::system::error_code();

// Find destination address
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
cmsg != NULL;
cmsg = CMSG_NXTHDR(&msg, cmsg))
{
if (cmsg->cmsg_level != IPPROTO_IP || cmsg->cmsg_type != IP_PKTINFO)
continue;

struct in_pktinfo *pi = (struct in_pktinfo *) CMSG_DATA(cmsg);
if (pi)
{
da = boost::asio::ip::address_v4(ntohl(pi->ipi_addr.s_addr));
}
}
// Find destination address
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
cmsg != NULL;
cmsg = CMSG_NXTHDR(&msg, cmsg))
{
if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO)
{
struct in_pktinfo *pi = (struct in_pktinfo *) CMSG_DATA(cmsg);
if (pi)
{
da = boost::asio::ip::address_v4(ntohl(pi->ipi_addr.s_addr));
}
} else
if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO)
{
struct in6_pktinfo *pi = (struct in6_pktinfo *) CMSG_DATA(cmsg);
if (pi)
{
boost::asio::ip::address_v6::bytes_type b;
memcpy(b.data(), pi->ipi6_addr.s6_addr, sizeof(pi->ipi6_addr.s6_addr));
da = boost::asio::ip::address_v6(b);
}
}
}
}
return result;
#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
Expand Down
Loading

0 comments on commit 0f51130

Please sign in to comment.