adjust makefile to make crt/ and ldso/ sources arch-replaceable
[musl.git] / include / netinet / ip.h
blobd7fa8d5e4e9b228d0542c3607c29a43589566f6b
1 #ifndef _NETINET_IP_H
2 #define _NETINET_IP_H
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
8 #include <stdint.h>
9 #include <netinet/in.h>
10 #include <endian.h>
12 struct timestamp {
13 uint8_t len;
14 uint8_t ptr;
15 #if __BYTE_ORDER == __LITTLE_ENDIAN
16 unsigned int flags:4;
17 unsigned int overflow:4;
18 #else
19 unsigned int overflow:4;
20 unsigned int flags:4;
21 #endif
22 uint32_t data[9];
25 struct iphdr {
26 #if __BYTE_ORDER == __LITTLE_ENDIAN
27 unsigned int ihl:4;
28 unsigned int version:4;
29 #else
30 unsigned int version:4;
31 unsigned int ihl:4;
32 #endif
33 uint8_t tos;
34 uint16_t tot_len;
35 uint16_t id;
36 uint16_t frag_off;
37 uint8_t ttl;
38 uint8_t protocol;
39 uint16_t check;
40 uint32_t saddr;
41 uint32_t daddr;
44 struct ip {
45 #if __BYTE_ORDER == __LITTLE_ENDIAN
46 unsigned int ip_hl:4;
47 unsigned int ip_v:4;
48 #else
49 unsigned int ip_v:4;
50 unsigned int ip_hl:4;
51 #endif
52 uint8_t ip_tos;
53 uint16_t ip_len;
54 uint16_t ip_id;
55 uint16_t ip_off;
56 uint8_t ip_ttl;
57 uint8_t ip_p;
58 uint16_t ip_sum;
59 struct in_addr ip_src, ip_dst;
62 #define IP_RF 0x8000
63 #define IP_DF 0x4000
64 #define IP_MF 0x2000
65 #define IP_OFFMASK 0x1fff
67 struct ip_timestamp {
68 uint8_t ipt_code;
69 uint8_t ipt_len;
70 uint8_t ipt_ptr;
71 #if __BYTE_ORDER == __LITTLE_ENDIAN
72 unsigned int ipt_flg:4;
73 unsigned int ipt_oflw:4;
74 #else
75 unsigned int ipt_oflw:4;
76 unsigned int ipt_flg:4;
77 #endif
78 uint32_t data[9];
81 #define IPVERSION 4
82 #define IP_MAXPACKET 65535
84 #define IPTOS_ECN_MASK 0x03
85 #define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
86 #define IPTOS_ECN_NOT_ECT 0x00
87 #define IPTOS_ECN_ECT1 0x01
88 #define IPTOS_ECN_ECT0 0x02
89 #define IPTOS_ECN_CE 0x03
91 #define IPTOS_DSCP_MASK 0xfc
92 #define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
93 #define IPTOS_DSCP_AF11 0x28
94 #define IPTOS_DSCP_AF12 0x30
95 #define IPTOS_DSCP_AF13 0x38
96 #define IPTOS_DSCP_AF21 0x48
97 #define IPTOS_DSCP_AF22 0x50
98 #define IPTOS_DSCP_AF23 0x58
99 #define IPTOS_DSCP_AF31 0x68
100 #define IPTOS_DSCP_AF32 0x70
101 #define IPTOS_DSCP_AF33 0x78
102 #define IPTOS_DSCP_AF41 0x88
103 #define IPTOS_DSCP_AF42 0x90
104 #define IPTOS_DSCP_AF43 0x98
105 #define IPTOS_DSCP_EF 0xb8
107 #define IPTOS_CLASS_MASK 0xe0
108 #define IPTOS_CLASS(x) ((x) & IPTOS_CLASS_MASK)
109 #define IPTOS_CLASS_CS0 0x00
110 #define IPTOS_CLASS_CS1 0x20
111 #define IPTOS_CLASS_CS2 0x40
112 #define IPTOS_CLASS_CS3 0x60
113 #define IPTOS_CLASS_CS4 0x80
114 #define IPTOS_CLASS_CS5 0xa0
115 #define IPTOS_CLASS_CS6 0xc0
116 #define IPTOS_CLASS_CS7 0xe0
117 #define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0
119 #define IPTOS_TOS_MASK 0x1E
120 #define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
121 #define IPTOS_LOWDELAY 0x10
122 #define IPTOS_THROUGHPUT 0x08
123 #define IPTOS_RELIABILITY 0x04
124 #define IPTOS_LOWCOST 0x02
125 #define IPTOS_MINCOST IPTOS_LOWCOST
127 #define IPTOS_PREC_MASK 0xe0
128 #define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
129 #define IPTOS_PREC_NETCONTROL 0xe0
130 #define IPTOS_PREC_INTERNETCONTROL 0xc0
131 #define IPTOS_PREC_CRITIC_ECP 0xa0
132 #define IPTOS_PREC_FLASHOVERRIDE 0x80
133 #define IPTOS_PREC_FLASH 0x60
134 #define IPTOS_PREC_IMMEDIATE 0x40
135 #define IPTOS_PREC_PRIORITY 0x20
136 #define IPTOS_PREC_ROUTINE 0x00
138 #define IPOPT_COPY 0x80
139 #define IPOPT_CLASS_MASK 0x60
140 #define IPOPT_NUMBER_MASK 0x1f
142 #define IPOPT_COPIED(o) ((o) & IPOPT_COPY)
143 #define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK)
144 #define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK)
146 #define IPOPT_CONTROL 0x00
147 #define IPOPT_RESERVED1 0x20
148 #define IPOPT_DEBMEAS 0x40
149 #define IPOPT_MEASUREMENT IPOPT_DEBMEAS
150 #define IPOPT_RESERVED2 0x60
152 #define IPOPT_EOL 0
153 #define IPOPT_END IPOPT_EOL
154 #define IPOPT_NOP 1
155 #define IPOPT_NOOP IPOPT_NOP
157 #define IPOPT_RR 7
158 #define IPOPT_TS 68
159 #define IPOPT_TIMESTAMP IPOPT_TS
160 #define IPOPT_SECURITY 130
161 #define IPOPT_SEC IPOPT_SECURITY
162 #define IPOPT_LSRR 131
163 #define IPOPT_SATID 136
164 #define IPOPT_SID IPOPT_SATID
165 #define IPOPT_SSRR 137
166 #define IPOPT_RA 148
168 #define IPOPT_OPTVAL 0
169 #define IPOPT_OLEN 1
170 #define IPOPT_OFFSET 2
171 #define IPOPT_MINOFF 4
173 #define MAX_IPOPTLEN 40
175 #define IPOPT_TS_TSONLY 0
176 #define IPOPT_TS_TSANDADDR 1
177 #define IPOPT_TS_PRESPEC 3
179 #define IPOPT_SECUR_UNCLASS 0x0000
180 #define IPOPT_SECUR_CONFID 0xf135
181 #define IPOPT_SECUR_EFTO 0x789a
182 #define IPOPT_SECUR_MMMM 0xbc4d
183 #define IPOPT_SECUR_RESTR 0xaf13
184 #define IPOPT_SECUR_SECRET 0xd788
185 #define IPOPT_SECUR_TOPSECRET 0x6bc5
187 #define MAXTTL 255
188 #define IPDEFTTL 64
189 #define IPFRAGTTL 60
190 #define IPTTLDEC 1
192 #define IP_MSS 576
194 #ifdef __cplusplus
196 #endif
198 #endif