Skip to content

Commit

Permalink
Fix Linux build.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisstaite committed Sep 7, 2020
1 parent ea3ee36 commit 6570281
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/client_forwarders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <arpa/inet.h>
#include <functional>
#include <cstring>

namespace dote {

Expand Down
10 changes: 3 additions & 7 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace dote {

namespace {

void getDestinationAddress(const msghdr& message, sockaddr_storage& dstAddr, int& ifIndex)
void getDestinationAddress(msghdr& message, sockaddr_storage& dstAddr, int& ifIndex)
{
// Process ancillary data received in msgheader - cmsg(3)
for (auto controlMsg = CMSG_FIRSTHDR(&message);
Expand All @@ -37,7 +37,6 @@ void getDestinationAddress(const msghdr& message, sockaddr_storage& dstAddr, int
auto i = reinterpret_cast<in_pktinfo*>(CMSG_DATA(controlMsg));
reinterpret_cast<sockaddr_in*>(&dstAddr)->sin_addr = i->ipi_addr;
dstAddr.ss_family = AF_INET;
dstAddr.ss_len = sizeof(sockaddr_in);
ifIndex = i->ipi_ifindex;
}
#endif
Expand All @@ -49,7 +48,6 @@ void getDestinationAddress(const msghdr& message, sockaddr_storage& dstAddr, int
auto i = reinterpret_cast<in_addr*>(CMSG_DATA(controlMsg));
reinterpret_cast<sockaddr_in*>(&dstAddr)->sin_addr = *i;
dstAddr.ss_family = AF_INET;
dstAddr.ss_len = sizeof(sockaddr_in);
}
#endif

Expand All @@ -65,7 +63,6 @@ void getDestinationAddress(const msghdr& message, sockaddr_storage& dstAddr, int
auto i = reinterpret_cast<in6_pktinfo*>(CMSG_DATA(controlMsg));
reinterpret_cast<sockaddr_in6*>(&dstAddr)->sin6_addr = i->ipi6_addr;
dstAddr.ss_family = AF_INET6;
dstAddr.ss_len = sizeof(sockaddr_in6);
ifIndex = i->ipi6_ifindex;
}
#endif
Expand Down Expand Up @@ -158,9 +155,8 @@ void Server::handleDnsRequest(int handle)
tcpBuffer.resize(count + SIZE_LENGTH);
*reinterpret_cast<unsigned short*>(tcpBuffer.data()) = htons(count);

sockaddr_storage dstAddr = {
0, AF_UNSPEC
};
sockaddr_storage dstAddr;
dstAddr.ss_family = AF_UNSPEC;
int ifIndex = -1;
getDestinationAddress(message, dstAddr, ifIndex);

Expand Down

0 comments on commit 6570281

Please sign in to comment.