ok fix ip header struct

which was broken for a while apparently
pull/179/head
Rick 5 years ago
parent 6040ab8c63
commit c6a3fc255a
No known key found for this signature in database
GPG Key ID: C0EDC8723FDC3465

@ -280,6 +280,7 @@ tun_ev_loop(void* unused)
if(ev->t->recvpkt)
ev->t->recvpkt(ev->t, llarp::InitBuffer(pkt->buf, size));
ev->flush_write();
ev->read(ev->readbuf, sizeof(ev->readbuf));
}
else
{
@ -364,7 +365,7 @@ namespace llarp
{
socklen_t slen = sizeof(sockaddr_in);
if(_addr.ss_family == AF_UNIX)
slen = 115;
slen = sizeof(sockaddr_un);
else if(_addr.ss_family == AF_INET6)
slen = sizeof(sockaddr_in6);
int result = ::connect(fd, (const sockaddr*)&_addr, slen);

@ -11,6 +11,32 @@
#include <sys/types.h> // FreeBSD needs this for uchar for ip.h
#include <netinet/in.h>
#include <netinet/ip.h>
// anything not win32
struct ip_header
{
#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
#if defined(__linux__)
#define ip_version version
#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;
};
#else
// windows nt
#include <winsock2.h>
@ -19,7 +45,7 @@ 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 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
@ -38,42 +64,17 @@ typedef struct ip_hdr
unsigned int ip_srcaddr; // Source address
unsigned int ip_destaddr; // Source address
} IPV4_HDR;
#define iphdr IPV4_HDR
#define ip_header IPV4_HDR
#define saddr ip_srcaddr
#define daddr ip_destaddr
#define check ip_checksum
#define ihl ip_header_len
#define ip_version version
#endif
#define protocol ip_protocol
#define frag_off ip_frag_offset
#include <memory>
// anything not win32
struct ip_header
{
#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
#if defined(__linux__)
#define ip_version version
#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;
};
#include <memory>
namespace llarp
{

Loading…
Cancel
Save