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