|
|
|
@ -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
|
|
|
|
|
{
|
|
|
|
|