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

Use IP_RECVDSTADDR in absence of IP_PKTINFO #772

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 0 additions & 3 deletions implementation/endpoints/include/server_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
3 changes: 0 additions & 3 deletions implementation/endpoints/include/tcp_client_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

#include <vsomeip/defines.hpp>
#include "client_endpoint_impl.hpp"
#if defined(__QNX__)
#include "../../utility/include/qnx_helper.hpp"
#endif

namespace vsomeip_v3 {

Expand Down
4 changes: 0 additions & 4 deletions implementation/endpoints/include/tcp_server_endpoint_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

#include <chrono>

#if defined(__QNX__)
#include "../../utility/include/qnx_helper.hpp"
#endif

namespace vsomeip_v3 {

typedef server_endpoint_impl<
Expand Down
3 changes: 0 additions & 3 deletions implementation/endpoints/include/tp_message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

#include "buffer.hpp"

#if defined(__QNX__)
#include "../../utility/include/qnx_helper.hpp"
#endif
namespace vsomeip_v3 {
namespace tp {

Expand Down
4 changes: 0 additions & 4 deletions implementation/endpoints/include/tp_reassembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@

#include "tp_message.hpp"

#if defined(__QNX__)
#include "../../utility/include/qnx_helper.hpp"
#endif

namespace vsomeip_v3 {
namespace tp {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#if defined(__QNX__)
#include <netinet/in.h>
#include <sys/socket.h>
#include "../../utility/include/qnx_helper.hpp"
#endif

namespace vsomeip_v3 {
Expand Down Expand Up @@ -306,11 +305,12 @@ receive_cb (std::shared_ptr<storage> _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))) {
Expand All @@ -322,6 +322,22 @@ receive_cb (std::shared_ptr<storage> _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;
Expand Down
6 changes: 6 additions & 0 deletions implementation/endpoints/src/udp_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 0 additions & 4 deletions implementation/message/include/deserializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#include <vsomeip/export.hpp>
#include <vsomeip/primitive_types.hpp>

#if defined(__QNX__)
#include "../../utility/include/qnx_helper.hpp"
#endif

namespace vsomeip_v3 {

class message_impl;
Expand Down
4 changes: 0 additions & 4 deletions implementation/message/include/payload_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
#include <vsomeip/export.hpp>
#include <vsomeip/payload.hpp>

#if defined(__QNX__)
#include "../../utility/include/qnx_helper.hpp"
#endif

namespace vsomeip_v3 {

class serializer;
Expand Down
4 changes: 0 additions & 4 deletions implementation/protocol/include/expire_command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@

#include "subscribe_command_base.hpp"

#if defined(__QNX__)
#include "../../utility/include/qnx_helper.hpp"
#endif

namespace vsomeip_v3 {
namespace protocol {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

#include "command.hpp"

#if defined(__QNX__)
#include "../../utility/include/qnx_helper.hpp"
#endif

namespace vsomeip_v3 {

struct policy;
Expand Down
4 changes: 0 additions & 4 deletions implementation/protocol/include/unregister_event_command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@

#include "command.hpp"

#if defined(__QNX__)
#include "../../utility/include/qnx_helper.hpp"
#endif

namespace vsomeip_v3 {
namespace protocol {

Expand Down
4 changes: 0 additions & 4 deletions implementation/routing/include/eventgroupinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions implementation/routing/include/remote_subscription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
#include "types.hpp"
#include <vsomeip/export.hpp>

#if defined(__QNX__)
#include "../../utility/include/qnx_helper.hpp"
#endif

namespace vsomeip_v3 {

class eventgroupinfo;
Expand Down
4 changes: 0 additions & 4 deletions implementation/routing/include/routing_manager_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 0 additions & 28 deletions implementation/utility/include/qnx_helper.hpp

This file was deleted.

Loading