diff --git a/implementation/endpoints/include/server_endpoint_impl.hpp b/implementation/endpoints/include/server_endpoint_impl.hpp index 1037401e7..aa9e500d7 100644 --- a/implementation/endpoints/include/server_endpoint_impl.hpp +++ b/implementation/endpoints/include/server_endpoint_impl.hpp @@ -18,9 +18,6 @@ #include "buffer.hpp" #include "endpoint_impl.hpp" #include "tp.hpp" -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif namespace vsomeip_v3 { diff --git a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp index 9820004cd..918c8a764 100644 --- a/implementation/endpoints/include/tcp_client_endpoint_impl.hpp +++ b/implementation/endpoints/include/tcp_client_endpoint_impl.hpp @@ -13,9 +13,6 @@ #include #include "client_endpoint_impl.hpp" -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif namespace vsomeip_v3 { diff --git a/implementation/endpoints/include/tcp_server_endpoint_impl.hpp b/implementation/endpoints/include/tcp_server_endpoint_impl.hpp index dd7b9554c..e26eb781a 100644 --- a/implementation/endpoints/include/tcp_server_endpoint_impl.hpp +++ b/implementation/endpoints/include/tcp_server_endpoint_impl.hpp @@ -17,10 +17,6 @@ #include -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif - namespace vsomeip_v3 { typedef server_endpoint_impl< diff --git a/implementation/endpoints/include/tp_message.hpp b/implementation/endpoints/include/tp_message.hpp index 0f943b403..13aef2d0f 100644 --- a/implementation/endpoints/include/tp_message.hpp +++ b/implementation/endpoints/include/tp_message.hpp @@ -14,9 +14,6 @@ #include "buffer.hpp" -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif namespace vsomeip_v3 { namespace tp { diff --git a/implementation/endpoints/include/tp_reassembler.hpp b/implementation/endpoints/include/tp_reassembler.hpp index 5c8936ae1..f64080cfa 100644 --- a/implementation/endpoints/include/tp_reassembler.hpp +++ b/implementation/endpoints/include/tp_reassembler.hpp @@ -19,10 +19,6 @@ #include "tp_message.hpp" -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif - namespace vsomeip_v3 { namespace tp { diff --git a/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp b/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp index 5823dcf59..059dc3cf0 100644 --- a/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp +++ b/implementation/endpoints/include/udp_server_endpoint_impl_receive_op.hpp @@ -20,7 +20,6 @@ #if defined(__QNX__) #include #include -#include "../../utility/include/qnx_helper.hpp" #endif namespace vsomeip_v3 { @@ -306,11 +305,12 @@ receive_cb (std::shared_ptr _data) { _data->sender_ = endpoint_type_t(its_sender_address, its_sender_port); // destination - struct in_pktinfo *its_pktinfo_v4; for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&its_header); cmsg != NULL; cmsg = CMSG_NXTHDR(&its_header, cmsg)) { +#if defined(IP_PKTINFO) # Linux, QNX io-pkt + struct in_pktinfo *its_pktinfo_v4; if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO && cmsg->cmsg_len == CMSG_LEN(sizeof(*its_pktinfo_v4))) { @@ -322,6 +322,22 @@ receive_cb (std::shared_ptr _data) { break; } } +#elif defined(IP_RECVDSTADDR) # FreeBSD, QNX io-sock + struct in_addr *its_pktinfo_v4; + if (cmsg->cmsg_level == IPPROTO_IP + && cmsg->cmsg_type == IP_RECVDSTADDR + && cmsg->cmsg_len == CMSG_LEN(sizeof(*its_pktinfo_v4))) { + + its_pktinfo_v4 = (struct in_addr*) CMSG_DATA(cmsg); + if (its_pktinfo_v4) { + _data->destination_ = boost::asio::ip::address_v4( + ntohl(its_pktinfo_v4->s_addr)); + break; + } + } +#else + #error "Platform not supported. Neither IP_PKTINFO nor IP_RECVDSTADDR is defined."; +#endif } } else { boost::asio::ip::address_v6::bytes_type its_bytes; diff --git a/implementation/endpoints/src/udp_server_endpoint_impl.cpp b/implementation/endpoints/src/udp_server_endpoint_impl.cpp index 23675b4aa..cf6a60616 100644 --- a/implementation/endpoints/src/udp_server_endpoint_impl.cpp +++ b/implementation/endpoints/src/udp_server_endpoint_impl.cpp @@ -801,7 +801,13 @@ udp_server_endpoint_impl::set_multicast_option(const boost::asio::ip::address& _ int its_pktinfo_option(1); ::setsockopt(multicast_socket_->native_handle(), (is_v4_ ? IPPROTO_IP : IPPROTO_IPV6), +#if defined(IP_PKTINFO) # Linux, QNX io-pkt (is_v4_ ? IP_PKTINFO : IPV6_RECVPKTINFO), +#elif defined(IP_RECVDSTADDR) # FreeBSD, QNX io-sock + (is_v4_ ? IP_RECVDSTADDR : IPV6_RECVPKTINFO), +#else + #error "Platform not supported. Neither IP_PKTINFO nor IP_RECVDSTADDR is defined."; +#endif &its_pktinfo_option, sizeof(its_pktinfo_option)); #endif if (multicast_recv_buffer_.empty()) diff --git a/implementation/message/include/deserializer.hpp b/implementation/message/include/deserializer.hpp index 3ebb8231d..098698d04 100644 --- a/implementation/message/include/deserializer.hpp +++ b/implementation/message/include/deserializer.hpp @@ -11,10 +11,6 @@ #include #include -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif - namespace vsomeip_v3 { class message_impl; diff --git a/implementation/message/include/payload_impl.hpp b/implementation/message/include/payload_impl.hpp index e63dbc393..85f1d7c97 100644 --- a/implementation/message/include/payload_impl.hpp +++ b/implementation/message/include/payload_impl.hpp @@ -9,10 +9,6 @@ #include #include -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif - namespace vsomeip_v3 { class serializer; diff --git a/implementation/protocol/include/expire_command.hpp b/implementation/protocol/include/expire_command.hpp index 3f9fdfa40..4c47aa98a 100644 --- a/implementation/protocol/include/expire_command.hpp +++ b/implementation/protocol/include/expire_command.hpp @@ -12,10 +12,6 @@ #include "subscribe_command_base.hpp" -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif - namespace vsomeip_v3 { namespace protocol { diff --git a/implementation/protocol/include/security_policy_response_command_base.hpp b/implementation/protocol/include/security_policy_response_command_base.hpp index 2bb4ba6d0..799f70391 100644 --- a/implementation/protocol/include/security_policy_response_command_base.hpp +++ b/implementation/protocol/include/security_policy_response_command_base.hpp @@ -10,10 +10,6 @@ #include "command.hpp" -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif - namespace vsomeip_v3 { struct policy; diff --git a/implementation/protocol/include/unregister_event_command.hpp b/implementation/protocol/include/unregister_event_command.hpp index 287eac799..9779946e2 100644 --- a/implementation/protocol/include/unregister_event_command.hpp +++ b/implementation/protocol/include/unregister_event_command.hpp @@ -12,10 +12,6 @@ #include "command.hpp" -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif - namespace vsomeip_v3 { namespace protocol { diff --git a/implementation/routing/include/eventgroupinfo.hpp b/implementation/routing/include/eventgroupinfo.hpp index 2dc8279fc..1a5a1b976 100644 --- a/implementation/routing/include/eventgroupinfo.hpp +++ b/implementation/routing/include/eventgroupinfo.hpp @@ -22,10 +22,6 @@ #include "remote_subscription.hpp" #include "types.hpp" -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif - namespace vsomeip_v3 { class endpoint_definition; diff --git a/implementation/routing/include/remote_subscription.hpp b/implementation/routing/include/remote_subscription.hpp index a770a56f7..f105ab856 100644 --- a/implementation/routing/include/remote_subscription.hpp +++ b/implementation/routing/include/remote_subscription.hpp @@ -17,10 +17,6 @@ #include "types.hpp" #include -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif - namespace vsomeip_v3 { class eventgroupinfo; diff --git a/implementation/routing/include/routing_manager_base.hpp b/implementation/routing/include/routing_manager_base.hpp index 51262e5ff..75aad9deb 100644 --- a/implementation/routing/include/routing_manager_base.hpp +++ b/implementation/routing/include/routing_manager_base.hpp @@ -28,10 +28,6 @@ #include "../../configuration/include/configuration.hpp" #include "../../endpoints/include/endpoint_manager_base.hpp" -#if defined(__QNX__) -#include "../../utility/include/qnx_helper.hpp" -#endif - namespace vsomeip_v3 { #ifdef USE_DLT diff --git a/implementation/utility/include/qnx_helper.hpp b/implementation/utility/include/qnx_helper.hpp deleted file mode 100644 index 2d390b6fc..000000000 --- a/implementation/utility/include/qnx_helper.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2020-2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifdef __QNX__ -#ifndef VSOMEIP_V3_QNX_HELPER_HPP_ -#define VSOMEIP_V3_QNX_HELPER_HPP_ -#include -#include - - #define SO_BINDTODEVICE 0x0800 /* restrict traffic to an interface */ - #define IP_PKTINFO 25 /* int; send interface and src addr */ - -/* Structure used for IP_PKTINFO. */ -#ifndef _STRUCT_IN_PKTINFO -struct in_pktinfo - { - int ipi_ifindex; /* Interface index */ - struct in_addr ipi_spec_dst; /* Routing destination address */ - struct in_addr ipi_addr; /* Header destination address */ - }; -#define _STRUCT_IN_PKTINFO -#endif - - #endif // VSOMEIP_V3_QNX_HELPER_HPP_ - -#endif