fix osx build

pull/15/head
Jeff 6 years ago
parent 47a24ff692
commit 689668d892

@ -3,55 +3,30 @@
#include <llarp/buffer.h>
#include <llarp/time.h>
#include <llarp/net.hpp>
#ifndef _WIN32
#include <netinet/in.h>
#include <netinet/ip.h>
#else
#ifdef _WIN32
#include <winsock2.h>
// Apparently this does not seem to be located _anywhere_ in the windows sdk???
// -despair86
typedef struct ip_hdr
{
unsigned char
ip_header_len : 4; // 4-bit header length (in 32-bit words) normally=5
// (Means 20 Bytes may be 24 also)
unsigned char ip_version : 4; // 4-bit IPv4 version
unsigned char ip_tos; // IP type of service
unsigned short ip_total_length; // Total length
unsigned short ip_id; // Unique identifier
unsigned char ip_frag_offset : 5; // Fragment offset field
unsigned char ip_more_fragment : 1;
unsigned char ip_dont_fragment : 1;
unsigned char ip_reserved_zero : 1;
unsigned char ip_frag_offset1; // fragment offset
unsigned char ip_ttl; // Time to live
unsigned char ip_protocol; // Protocol(TCP,UDP etc)
unsigned short ip_checksum; // IP checksum
unsigned int ip_srcaddr; // Source address
unsigned int ip_destaddr; // Source address
} IPV4_HDR;
#define iphdr IPV4_HDR
#define saddr ip_srcaddr
#define daddr ip_destaddr
#define check ip_checksum
#define ihl ip_header_len
#endif
#include <memory>
#if !defined(__linux__) && !defined(_WIN32)
#define iphdr ip
#define saddr ip_src.s_addr
#define daddr ip_dst.s_addr
#define ip_version ip_v
#define check ip_sum
#define ihl ip_hl
#endif
#if defined(__linux__)
#define ip_version version
struct iphdr
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int ihl:4;
unsigned int version:4;
#elif __BYTE_ORDER == __BIG_ENDIAN
unsigned int version:4;
unsigned int ihl:4;
#else
# error "Please fix <bits/endian.h>"
#endif
uint8_t tos;
uint16_t tot_len;
uint16_t id;
uint16_t frag_off;
uint8_t ttl;
uint8_t protocol;
uint16_t check;
uint32_t saddr;
uint32_t daddr;
};
namespace llarp
{

@ -343,9 +343,9 @@ namespace llarp
if(!self->m_UserToNetworkPktQueue.EmplaceIf(
[self, buf, sz](net::IPv4Packet &pkt) -> bool {
return pkt.Load(llarp::InitBuffer(buf, sz))
&& pkt.Header()->ip_version == 4;
&& pkt.Header()->version == 4;
}))
llarp::LogError("Failed to parse ipv4 packet");
llarp::LogDebug("Failed to parse ipv4 packet");
}
TunEndpoint::~TunEndpoint()

@ -61,8 +61,8 @@ namespace llarp
hdr->check = 0;
auto len = hdr->ihl * 4;
hdr->check = ipchksum(buf, len);
auto itr = protoChecksumOffsets.find(hdr->protocol);
auto proto = hdr->protocol;
auto itr = protoChecksumOffsets.find(proto);
if(itr != protoChecksumOffsets.end())
{
auto offset = itr->second.second;

Loading…
Cancel
Save