initial version, corresponding to ipfw3-2012
[ipfw-google.git] / sys / netinet / ip.h
1 #ifndef _NETINET_IP_H_
2 #define _NETINET_IP_H_
3
4 #define LITTLE_ENDIAN   1234
5 #define BIG_ENDIAN      4321
6 #if defined(__BIG_ENDIAN)
7 #define BYTE_ORDER      BIG_ENDIAN
8 //#warning we are in bigendian
9 #elif defined(__LITTLE_ENDIAN)
10 //#warning we are in littleendian
11 #define BYTE_ORDER      LITTLE_ENDIAN
12 #else
13 #error no platform
14 #endif
15
16 /* XXX endiannes doesn't belong here */
17 // #define LITTLE_ENDIAN   1234
18 // #define BIG_ENDIAN      4321
19 // #define BYTE_ORDER      LITTLE_ENDIAN
20
21 /*
22  * Structure of an internet header, naked of options.
23  */
24 struct ip {
25 #if BYTE_ORDER == LITTLE_ENDIAN
26         u_char  ip_hl:4,                /* header length */
27                 ip_v:4;                 /* version */
28 #endif
29 #if BYTE_ORDER == BIG_ENDIAN
30         u_char  ip_v:4,                 /* version */
31                 ip_hl:4;                /* header length */
32 #endif
33         u_char  ip_tos;                 /* type of service */
34         u_short ip_len;                 /* total length */
35         u_short ip_id;                  /* identification */
36         u_short ip_off;                 /* fragment offset field */
37 #define IP_RF 0x8000                    /* reserved fragment flag */
38 #define IP_DF 0x4000                    /* dont fragment flag */
39 #define IP_MF 0x2000                    /* more fragments flag */
40 #define IP_OFFMASK 0x1fff               /* mask for fragmenting bits */
41         u_char  ip_ttl;                 /* time to live */
42         u_char  ip_p;                   /* protocol */
43         u_short ip_sum;                 /* checksum */
44         struct  in_addr ip_src,ip_dst;  /* source and dest address */
45 } __packed __aligned(4);
46
47 #define IPTOS_LOWDELAY          0x10
48
49 #endif /* _NETINET_IP_H_ */