Rev 4350 | Rev 4704 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4350 | Rev 4505 | ||
---|---|---|---|
Line 37... | Line 37... | ||
37 | 37 | ||
38 | #ifndef __NET_IP_HEADER_H__ |
38 | #ifndef __NET_IP_HEADER_H__ |
39 | #define __NET_IP_HEADER_H__ |
39 | #define __NET_IP_HEADER_H__ |
40 | 40 | ||
41 | #include <byteorder.h> |
41 | #include <byteorder.h> |
42 | #include <types.h> |
42 | #include <sys/types.h> |
43 | 43 | ||
44 | /** Type definition of the internet header. |
44 | /** Type definition of the internet header. |
45 | * @see ip_header |
45 | * @see ip_header |
46 | */ |
46 | */ |
47 | typedef struct ip_header ip_header_t; |
47 | typedef struct ip_header ip_header_t; |
Line 56... | Line 56... | ||
56 | */ |
56 | */ |
57 | struct ip_header{ |
57 | struct ip_header{ |
58 | #ifdef ARCH_IS_BIG_ENDIAN |
58 | #ifdef ARCH_IS_BIG_ENDIAN |
59 | /** The Version field indicates the format of the internet header. |
59 | /** The Version field indicates the format of the internet header. |
60 | */ |
60 | */ |
61 | uint8_t:4 version; |
61 | uint8_t version:4; |
62 | /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data. |
62 | /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data. |
63 | * Note that the minimum value for a~correct header is~5. |
63 | * Note that the minimum value for a~correct header is~5. |
64 | */ |
64 | */ |
65 | uint8_t:4 ihl; |
65 | uint8_t ihl:4; |
66 | #else |
66 | #else |
67 | /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data. |
67 | /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data. |
68 | * Note that the minimum value for a~correct header is~5. |
68 | * Note that the minimum value for a~correct header is~5. |
69 | */ |
69 | */ |
70 | uint8_t:4 ihl; |
70 | uint8_t ihl:4; |
71 | /** The Version field indicates the format of the internet header. |
71 | /** The Version field indicates the format of the internet header. |
72 | */ |
72 | */ |
73 | uint8_t:4 version; |
73 | uint8_t version:4; |
74 | #endif |
74 | #endif |
75 | /** The Type of Service provides an indication of the abstract parameters of the quality of service desired. |
75 | /** The Type of Service provides an indication of the abstract parameters of the quality of service desired. |
76 | * These parameters are to be used to guide the selection of the actual service parameters when transmitting a~datagram through a~particular network. |
76 | * These parameters are to be used to guide the selection of the actual service parameters when transmitting a~datagram through a~particular network. |
77 | * Several networks offer service precedence, which somehow treats high precedence traffic as more important than other traffic (generally by accepting only traffic above a~certain precedence at time of high load). |
77 | * Several networks offer service precedence, which somehow treats high precedence traffic as more important than other traffic (generally by accepting only traffic above a~certain precedence at time of high load). |
78 | * The major choice is a~three way tradeoff between low-delay, high-reliability, and high-throughput. |
78 | * The major choice is a~three way tradeoff between low-delay, high-reliability, and high-throughput. |
Line 82... | Line 82... | ||
82 | * This field allows the length of a~datagram to be up to 65,535~octets. |
82 | * This field allows the length of a~datagram to be up to 65,535~octets. |
83 | */ |
83 | */ |
84 | uint16_t total_length; |
84 | uint16_t total_length; |
85 | /** An identifying value assigned by the sender to aid in assembling the fragments of a~datagram. |
85 | /** An identifying value assigned by the sender to aid in assembling the fragments of a~datagram. |
86 | */ |
86 | */ |
87 | unit16_t identification; |
87 | uint16_t identification; |
88 | #ifdef ARCH_IS_BIG_ENDIAN |
88 | #ifdef ARCH_IS_BIG_ENDIAN |
89 | /** Various control flags. |
89 | /** Various control flags. |
90 | */ |
90 | */ |
91 | uint_16:3 flags; |
91 | uint16_t flags:3; |
92 | /** This field indicates where in the datagram this fragment belongs. |
92 | /** This field indicates where in the datagram this fragment belongs. |
93 | */ |
93 | */ |
94 | uint_16:13 fragment_offset; |
94 | uint16_t fragment_offset:3; |
95 | #else |
95 | #else |
96 | /** This field indicates where in the datagram this fragment belongs. |
96 | /** This field indicates where in the datagram this fragment belongs. |
97 | */ |
97 | */ |
98 | uint_16:13 fragment_offset; |
98 | uint16_t fragment_offset:13; |
99 | /** Various control flags. |
99 | /** Various control flags. |
100 | */ |
100 | */ |
101 | uint_16:3 flags; |
101 | uint16_t flags:3; |
102 | #endif |
102 | #endif |
103 | /** This field indicates the maximum time the datagram is allowed to remain in the internet system. |
103 | /** This field indicates the maximum time the datagram is allowed to remain in the internet system. |
104 | * If this field contains the value zero, then the datagram must be destroyed. |
104 | * If this field contains the value zero, then the datagram must be destroyed. |
105 | * This field is modified in internet header processing. |
105 | * This field is modified in internet header processing. |
106 | * The time is measured in units of seconds, but since every module that processes a~datagram must decrease the TTL by at least one even if it process the datagram in less than a~second, the TTL must be thought of only as an upper bound on the time a~datagram may exist. |
106 | * The time is measured in units of seconds, but since every module that processes a~datagram must decrease the TTL by at least one even if it process the datagram in less than a~second, the TTL must be thought of only as an upper bound on the time a~datagram may exist. |
Line 130... | Line 130... | ||
130 | typedef struct ip_option ip_option_t; |
130 | typedef struct ip_option ip_option_t; |
131 | 131 | ||
132 | /** Type definition of the internet option header pointer. |
132 | /** Type definition of the internet option header pointer. |
133 | * @see ip_header |
133 | * @see ip_header |
134 | */ |
134 | */ |
135 | typedef ip_option * ip_option_ref; |
135 | typedef ip_option_t * ip_option_ref; |
136 | 136 | ||
137 | /** Internet option header. |
137 | /** Internet option header. |
138 | * Only type field is always valid. |
138 | * Only type field is always valid. |
139 | * Other fields' validity depends on the option type. |
139 | * Other fields' validity depends on the option type. |
140 | */ |
140 | */ |
Line 149... | Line 149... | ||
149 | */ |
149 | */ |
150 | uint8_t pointer; |
150 | uint8_t pointer; |
151 | #ifdef ARCH_IS_BIG_ENDIAN |
151 | #ifdef ARCH_IS_BIG_ENDIAN |
152 | /** The number of IP modules that cannot register timestamps due to lack of space. |
152 | /** The number of IP modules that cannot register timestamps due to lack of space. |
153 | */ |
153 | */ |
154 | uint8_t:4 overflow; |
154 | uint8_t overflow:4; |
155 | /** Various internet timestamp control flags. |
155 | /** Various internet timestamp control flags. |
156 | */ |
156 | */ |
157 | uint8_t:4 flags; |
157 | uint8_t flags:4; |
158 | #else |
158 | #else |
159 | /** Various internet timestamp control flags. |
159 | /** Various internet timestamp control flags. |
160 | */ |
160 | */ |
161 | uint8_t:4 flags; |
161 | uint8_t flags:4; |
162 | /** The number of IP modules that cannot register timestamps due to lack of space. |
162 | /** The number of IP modules that cannot register timestamps due to lack of space. |
163 | */ |
163 | */ |
164 | uint8_t:4 overflow; |
164 | uint8_t overflow:4; |
165 | #endif |
165 | #endif |
166 | } __attribute__ ((packed)); |
166 | } __attribute__ ((packed)); |
167 | 167 | ||
168 | #define IPTOS_TOS_MASK 0x1E |
- | |
169 | #define IPTOS_PRECEDENCE_SHIFT 5 |
- | |
170 | #define IPTOS_DELAY_SHIFT 4 |
- | |
171 | #define IPTOS_THROUGHPUT_SHIFT 3 |
- | |
172 | #define IPTOS_RELIABILITY_SHIFT 2 |
- | |
173 | #define IPTOS_COST_SHIFT 1 |
- | |
174 | - | ||
175 | #define IPTOS_NORMALDELAY ( 0x0 << IPTOS_DELAY_SHIFT ) |
- | |
176 | #define IPTOS_LOWDELAY ( 0x1 << IPTOS_DELAY_SHIFT ) |
- | |
177 | - | ||
178 | #define IPTOS_NORMALTHROUGHPUT ( 0x0 << IPTOS_THROUGHPUT_SHIFT ) |
- | |
179 | #define IPTOS_THROUGHPUT ( 0x1 << IPTOS_THROUGHPUT_SHIFT ) |
- | |
180 | - | ||
181 | #define IPTOS_NORMALRELIABILITY ( 0x0 << IPTOS_RELIABILITY_SHIFT ) |
- | |
182 | #define IPTOS_RELIABILITY ( 0x1 << IPTOS_RELIABILITY_SHIFT ) |
- | |
183 | - | ||
184 | #define IPTOS_NORMALCOST ( 0x0 << IPTOS_COST_SHIFT ) |
- | |
185 | #define IPTOS_MICNCOST ( 0x1 << IPTOS_COST_SHIFT ) |
- | |
186 | - | ||
187 | #define IPTOS_PREC_MASK 0xE0 |
- | |
188 | #define IPTOS_PREC_ROUTINE ( 0x0 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
189 | #define IPTOS_PREC_PRIORITY ( 0x1 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
190 | #define IPTOS_PREC_IMMEDIATE ( 0x2 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
191 | #define IPTOS_PREC_FLASH ( 0x3 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
192 | #define IPTOS_PREC_FLASHOVERRIDE ( 0x4 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
193 | #define IPTOS_PREC_CRITIC_ECP ( 0x5 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
194 | #define IPTOS_PREC_INTERNETCONTROL ( 0x6 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
195 | #define IPTOS_PREC_NETCONTROL ( 0x7 << IPTOS_PRECEDENCE_SHIFT ) |
- | |
196 | - | ||
197 | #define IPFLAG_FRAGMENT_SHIFT 1 |
168 | #define IPFLAG_FRAGMENT_SHIFT 1 |
198 | #define IPFLAG_FRAGMENTED_SHIFT 0 |
169 | #define IPFLAG_FRAGMENTED_SHIFT 0 |
199 | 170 | ||
200 | #define IPFLAG_MAY_FRAGMENT ( 0x0 << IPFLAG_FRAGMENT_SHIFT ) |
171 | #define IPFLAG_MAY_FRAGMENT ( 0x0 << IPFLAG_FRAGMENT_SHIFT ) |
201 | #define IPFLAG_DONT_FRAGMENT ( 0x1 << IPFLAG_FRAGMENT_SHIFT ) |
172 | #define IPFLAG_DONT_FRAGMENT ( 0x1 << IPFLAG_FRAGMENT_SHIFT ) |
202 | 173 | ||
203 | #define IPFLAG_LAST_FRAGMENT ( 0x0 << IPFLAG_FRAGMENTED_SHIFT ) |
174 | #define IPFLAG_LAST_FRAGMENT ( 0x0 << IPFLAG_FRAGMENTED_SHIFT ) |
204 | #define IPFLAG_MORE_FRAGMENTS ( 0x1 << IPFLAG_FRAGMENTED_SHIFT ) |
175 | #define IPFLAG_MORE_FRAGMENTS ( 0x1 << IPFLAG_FRAGMENTED_SHIFT ) |
205 | 176 | ||
206 | #define IPOPT_COPY_SHIFT 7 |
- | |
207 | #define IPOPT_CLASS_SHIFT 5 |
- | |
208 | #define IPOPT_NUMBER_SHIFT 0 |
- | |
209 | #define IPOPT_CLASS_MASK 0x60 |
- | |
210 | #define IPOPT_NUMBER_MASK 0x1F |
- | |
211 | - | ||
212 | #define IPOPT_COPY ( 1 << IPOPT_COPY_SHIFT ) |
- | |
213 | - | ||
214 | #define IPOPT_TYPE( copy, class, number ) ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK )) |
- | |
215 | - | ||
216 | #define IPOPT_COPIED( o ) (( o ) & IPOPT_COPY ) |
- | |
217 | #define IPOPT_CLASS( o ) (( o ) & IPOPT_CLASS_MASK ) |
- | |
218 | #define IPOPT_NUMBER( o ) (( o ) & IPOPT_NUMBER_MASK ) |
- | |
219 | - | ||
220 | #define IPOPT_CONTROL ( 1 << IPOPT_CLASS_SHIFT ) |
- | |
221 | #define IPOPT_RESERVED1 ( 2 << IPOPT_CLASS_SHIFT ) |
- | |
222 | #define IPOPT_MEASUREMENT ( 3 << IPOPT_CLASS_SHIFT ) |
- | |
223 | #define IPOPT_RESERVED2 ( 4 << IPOPT_CLASS_SHIFT ) |
- | |
224 | - | ||
225 | //#define IPOPT_END_OF_LIST 0x0 |
- | |
226 | #define IPOPT_END IPOPT_TYPE( 0, IPOPT_CONTROL, 0 ) |
- | |
227 | //#define IPOPT_NO_OPERATION 0x1 |
- | |
228 | #define IPOPT_NOOP IPOPT_TYPE( 0, IPOPT_CONTROL, 1 ) |
- | |
229 | //#define IPOPT_SECURITY 0x82 |
- | |
230 | #define IPOPT_SEC IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 ) |
- | |
231 | #define IPOPT_SEC_LENGTH 11 |
- | |
232 | #define IPOPT_SEC_UNCLASIFIED 0x0 |
- | |
233 | #define IPOPT_SEC_CONFIDENTIAL 0xF035 |
- | |
234 | #define IPOPT_SEC_EFTO 0x789A |
- | |
235 | #define IPOPT_SEC_MMMM 0xBC4D |
- | |
236 | #define IPOPT_SEC_PROG 0x5E26 |
- | |
237 | #define IPOPT_SEC_RESTRICTED 0xAF13 |
- | |
238 | #define IPOPT_SEC_SECRET 0xD788 |
- | |
239 | #define IPOPT_SEC_TOP_SECRET 0x6BC5 |
- | |
240 | //#define IPOPT_LOOSE_SOURCE 0x83 |
- | |
241 | #define IPOPT_LSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 ) |
- | |
242 | //#define IPOPT_STRICT_SOURCE 0x89 |
- | |
243 | #define IPOPT_SSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 ) |
- | |
244 | //#define IPOPT_RECORD_ROUTE 0x07 |
- | |
245 | #define IPOPT_RR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 ) |
- | |
246 | //#define IPOPT_STREAM_IDENTIFIER 0x88 |
- | |
247 | #define IPOPT_SID IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 ) |
- | |
248 | #define IPOPT_SID_LENGTH 4 |
- | |
249 | //#define IPOPT_INTERNET_TIMESTAMP 0x44 |
- | |
250 | #define IPOPT_TIMESTAMP IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 ) |
- | |
251 | #define IPOPT_CIPSO IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 ) |
- | |
252 | - | ||
253 | #define IPVERSION 4 |
- | |
254 | #define MAXTTL 255 |
- | |
255 | #define IPDEFTTL 64 |
- | |
256 | 177 | /* |
|
257 | #define IPOPT_OPTVAL 0 |
178 | #define IPOPT_OPTVAL 0 |
258 | #define IPOPT_OLEN 1 |
179 | #define IPOPT_OLEN 1 |
259 | #define IPOPT_OFFSET 2 |
180 | #define IPOPT_OFFSET 2 |
260 | #define IPOPT_MINOFF 4 |
181 | #define IPOPT_MINOFF 4 |
261 | #define MAX_IPOPTLEN 40 |
182 | #define MAX_IPOPTLEN 40 |
262 | #define IPOPT_NOP IPOPT_NOOP |
- | |
263 | #define IPOPT_EOL IPOPT_END |
- | |
264 | #define IPOPT_TS IPOPT_TIMESTAMP |
- | |
265 | 183 | */ |
|
266 | #define IPOPT_TS_TSONLY 0 /* timestamps only */ |
- | |
267 | #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ |
- | |
268 | #define IPOPT_TS_PRESPEC 3 /* specified modules only */ |
- | |
269 | 184 | ||
270 | #endif |
185 | #endif |
271 | 186 | ||
272 | /** @} |
187 | /** @} |
273 | */ |
188 | */ |