summaryrefslogtreecommitdiff
path: root/implementation/endpoints/src
diff options
context:
space:
mode:
authorLutz Bichler <Lutz.Bichler@bmw.de>2020-12-04 11:52:58 +0100
committerLutz Bichler <Lutz.Bichler@bmw.de>2020-12-04 11:52:58 +0100
commit0f51130b96b5400b87924d8705d0e4a77930cb61 (patch)
tree0dade462d83a9b4d1de6eb82ab0827d5ec7e93cf /implementation/endpoints/src
parent710a8613ee5bd9eb490addecd7f2ee8049c4fd0c (diff)
downloadvSomeIP-3.1.20.2.tar.gz
vsomeip 3.1.20.23.1.20.2
Diffstat (limited to 'implementation/endpoints/src')
-rw-r--r--implementation/endpoints/src/endpoint_manager_impl.cpp4
-rw-r--r--implementation/endpoints/src/tcp_client_endpoint_impl.cpp34
-rw-r--r--implementation/endpoints/src/udp_client_endpoint_impl.cpp38
-rw-r--r--implementation/endpoints/src/udp_server_endpoint_impl.cpp18
4 files changed, 48 insertions, 46 deletions
diff --git a/implementation/endpoints/src/endpoint_manager_impl.cpp b/implementation/endpoints/src/endpoint_manager_impl.cpp
index 32ba31d..38dabf7 100644
--- a/implementation/endpoints/src/endpoint_manager_impl.cpp
+++ b/implementation/endpoints/src/endpoint_manager_impl.cpp
@@ -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);
diff --git a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
index c490f53..3debcc7 100644
--- a/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
+++ b/implementation/endpoints/src/tcp_client_endpoint_impl.cpp
@@ -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;
diff --git a/implementation/endpoints/src/udp_client_endpoint_impl.cpp b/implementation/endpoints/src/udp_client_endpoint_impl.cpp
index ff24173..dc7a7bf 100644
--- a/implementation/endpoints/src/udp_client_endpoint_impl.cpp
+++ b/implementation/endpoints/src/udp_client_endpoint_impl.cpp
@@ -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());
@@ -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;
diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp
index add828c..bd6fc62 100644
--- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp
+++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp
@@ -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_);