Rev 4710 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4710 | Rev 4756 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | /** @addtogroup ip |
29 | /** @addtogroup ip |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** @file |
33 | /** @file |
34 | * \todo |
34 | * IP codes and definitions. |
35 | */ |
35 | */ |
36 | 36 | ||
37 | #ifndef __NET_IP_CODES_H__ |
37 | #ifndef __NET_IP_CODES_H__ |
38 | #define __NET_IP_CODES_H__ |
38 | #define __NET_IP_CODES_H__ |
39 | 39 | ||
40 | #include <sys/types.h> |
40 | #include <sys/types.h> |
41 | 41 | ||
- | 42 | /** IP time to live counter type definition. |
|
- | 43 | */ |
|
42 | typedef uint8_t ip_ttl_t; |
44 | typedef uint8_t ip_ttl_t; |
- | 45 | ||
- | 46 | /** IP type of service type definition. |
|
- | 47 | */ |
|
43 | typedef uint8_t ip_tos_t; |
48 | typedef uint8_t ip_tos_t; |
- | 49 | ||
- | 50 | /** IP transport protocol type definition. |
|
- | 51 | */ |
|
44 | typedef uint8_t ip_protocol_t; |
52 | typedef uint8_t ip_protocol_t; |
45 | 53 | ||
- | 54 | /** Default IPVERSION. |
|
- | 55 | */ |
|
46 | #define IPVERSION 4 |
56 | #define IPVERSION 4 |
- | 57 | ||
- | 58 | /** Maximum time to live counter. |
|
- | 59 | */ |
|
47 | #define MAXTTL 255 |
60 | #define MAXTTL 255 |
- | 61 | ||
- | 62 | /** Default time to live counter. |
|
- | 63 | */ |
|
48 | #define IPDEFTTL 64 |
64 | #define IPDEFTTL 64 |
49 | 65 | ||
- | 66 | /** @name IP type of service definitions |
|
- | 67 | */ |
|
- | 68 | /*@{*/ |
|
- | 69 | ||
- | 70 | /** IP TOS mask. |
|
- | 71 | */ |
|
50 | #define IPTOS_TOS_MASK 0x1E |
72 | #define IPTOS_TOS_MASK 0x1E |
- | 73 | ||
- | 74 | /** Precedence shift. |
|
- | 75 | */ |
|
51 | #define IPTOS_PRECEDENCE_SHIFT 5 |
76 | #define IPTOS_PRECEDENCE_SHIFT 5 |
- | 77 | ||
- | 78 | /** Delay shift. |
|
- | 79 | */ |
|
52 | #define IPTOS_DELAY_SHIFT 4 |
80 | #define IPTOS_DELAY_SHIFT 4 |
- | 81 | ||
- | 82 | /** Throughput shift. |
|
- | 83 | */ |
|
53 | #define IPTOS_THROUGHPUT_SHIFT 3 |
84 | #define IPTOS_THROUGHPUT_SHIFT 3 |
- | 85 | ||
- | 86 | /** Reliability shift. |
|
- | 87 | */ |
|
54 | #define IPTOS_RELIABILITY_SHIFT 2 |
88 | #define IPTOS_RELIABILITY_SHIFT 2 |
- | 89 | ||
- | 90 | /** Cost shift. |
|
- | 91 | */ |
|
55 | #define IPTOS_COST_SHIFT 1 |
92 | #define IPTOS_COST_SHIFT 1 |
56 | 93 | ||
- | 94 | /** Normal delay. |
|
- | 95 | */ |
|
57 | #define IPTOS_NORMALDELAY ( 0x0 << IPTOS_DELAY_SHIFT ) |
96 | #define IPTOS_NORMALDELAY ( 0x0 << IPTOS_DELAY_SHIFT ) |
- | 97 | ||
- | 98 | /** Low delay. |
|
- | 99 | */ |
|
58 | #define IPTOS_LOWDELAY ( 0x1 << IPTOS_DELAY_SHIFT ) |
100 | #define IPTOS_LOWDELAY ( 0x1 << IPTOS_DELAY_SHIFT ) |
59 | 101 | ||
- | 102 | /** Normal throughput. |
|
- | 103 | */ |
|
60 | #define IPTOS_NORMALTHROUGHPUT ( 0x0 << IPTOS_THROUGHPUT_SHIFT ) |
104 | #define IPTOS_NORMALTHROUGHPUT ( 0x0 << IPTOS_THROUGHPUT_SHIFT ) |
- | 105 | ||
- | 106 | /** Throughput. |
|
- | 107 | */ |
|
61 | #define IPTOS_THROUGHPUT ( 0x1 << IPTOS_THROUGHPUT_SHIFT ) |
108 | #define IPTOS_THROUGHPUT ( 0x1 << IPTOS_THROUGHPUT_SHIFT ) |
62 | 109 | ||
- | 110 | /** Normal reliability. |
|
- | 111 | */ |
|
63 | #define IPTOS_NORMALRELIABILITY ( 0x0 << IPTOS_RELIABILITY_SHIFT ) |
112 | #define IPTOS_NORMALRELIABILITY ( 0x0 << IPTOS_RELIABILITY_SHIFT ) |
- | 113 | ||
- | 114 | /** Reliability. |
|
- | 115 | */ |
|
64 | #define IPTOS_RELIABILITY ( 0x1 << IPTOS_RELIABILITY_SHIFT ) |
116 | #define IPTOS_RELIABILITY ( 0x1 << IPTOS_RELIABILITY_SHIFT ) |
65 | 117 | ||
- | 118 | /** Normal cost. |
|
- | 119 | */ |
|
66 | #define IPTOS_NORMALCOST ( 0x0 << IPTOS_COST_SHIFT ) |
120 | #define IPTOS_NORMALCOST ( 0x0 << IPTOS_COST_SHIFT ) |
- | 121 | ||
- | 122 | /** Minimum cost. |
|
- | 123 | */ |
|
67 | #define IPTOS_MICNCOST ( 0x1 << IPTOS_COST_SHIFT ) |
124 | #define IPTOS_MICNCOST ( 0x1 << IPTOS_COST_SHIFT ) |
68 | 125 | ||
- | 126 | /*@}*/ |
|
- | 127 | ||
- | 128 | /** @name IP TOS precedence definitions |
|
- | 129 | */ |
|
- | 130 | /*@{*/ |
|
- | 131 | ||
- | 132 | ||
- | 133 | /** Precedence mask. |
|
- | 134 | */ |
|
69 | #define IPTOS_PREC_MASK 0xE0 |
135 | #define IPTOS_PREC_MASK 0xE0 |
- | 136 | ||
- | 137 | /** Routine precedence. |
|
- | 138 | */ |
|
70 | #define IPTOS_PREC_ROUTINE ( 0x0 << IPTOS_PRECEDENCE_SHIFT ) |
139 | #define IPTOS_PREC_ROUTINE ( 0x0 << IPTOS_PRECEDENCE_SHIFT ) |
- | 140 | ||
- | 141 | /** Priority precedence. |
|
- | 142 | */ |
|
71 | #define IPTOS_PREC_PRIORITY ( 0x1 << IPTOS_PRECEDENCE_SHIFT ) |
143 | #define IPTOS_PREC_PRIORITY ( 0x1 << IPTOS_PRECEDENCE_SHIFT ) |
- | 144 | ||
- | 145 | /** Immediate precedence. |
|
- | 146 | */ |
|
72 | #define IPTOS_PREC_IMMEDIATE ( 0x2 << IPTOS_PRECEDENCE_SHIFT ) |
147 | #define IPTOS_PREC_IMMEDIATE ( 0x2 << IPTOS_PRECEDENCE_SHIFT ) |
- | 148 | ||
- | 149 | /** Flash precedence. |
|
- | 150 | */ |
|
73 | #define IPTOS_PREC_FLASH ( 0x3 << IPTOS_PRECEDENCE_SHIFT ) |
151 | #define IPTOS_PREC_FLASH ( 0x3 << IPTOS_PRECEDENCE_SHIFT ) |
- | 152 | ||
- | 153 | /** Flash override precedence. |
|
- | 154 | */ |
|
74 | #define IPTOS_PREC_FLASHOVERRIDE ( 0x4 << IPTOS_PRECEDENCE_SHIFT ) |
155 | #define IPTOS_PREC_FLASHOVERRIDE ( 0x4 << IPTOS_PRECEDENCE_SHIFT ) |
- | 156 | ||
- | 157 | /** Critical precedence. |
|
- | 158 | */ |
|
75 | #define IPTOS_PREC_CRITIC_ECP ( 0x5 << IPTOS_PRECEDENCE_SHIFT ) |
159 | #define IPTOS_PREC_CRITIC_ECP ( 0x5 << IPTOS_PRECEDENCE_SHIFT ) |
- | 160 | ||
- | 161 | /** Inter-network control precedence. |
|
- | 162 | */ |
|
76 | #define IPTOS_PREC_INTERNETCONTROL ( 0x6 << IPTOS_PRECEDENCE_SHIFT ) |
163 | #define IPTOS_PREC_INTERNETCONTROL ( 0x6 << IPTOS_PRECEDENCE_SHIFT ) |
- | 164 | ||
- | 165 | /** Network control precedence. |
|
- | 166 | */ |
|
77 | #define IPTOS_PREC_NETCONTROL ( 0x7 << IPTOS_PRECEDENCE_SHIFT ) |
167 | #define IPTOS_PREC_NETCONTROL ( 0x7 << IPTOS_PRECEDENCE_SHIFT ) |
78 | 168 | ||
- | 169 | /*@}*/ |
|
- | 170 | ||
- | 171 | /** @name IP options definitions |
|
- | 172 | */ |
|
- | 173 | /*@{*/ |
|
- | 174 | ||
- | 175 | /** Copy shift. |
|
- | 176 | */ |
|
79 | #define IPOPT_COPY_SHIFT 7 |
177 | #define IPOPT_COPY_SHIFT 7 |
- | 178 | ||
- | 179 | /** Class shift. |
|
- | 180 | */ |
|
80 | #define IPOPT_CLASS_SHIFT 5 |
181 | #define IPOPT_CLASS_SHIFT 5 |
- | 182 | ||
- | 183 | /** Number shift. |
|
- | 184 | */ |
|
81 | #define IPOPT_NUMBER_SHIFT 0 |
185 | #define IPOPT_NUMBER_SHIFT 0 |
- | 186 | ||
- | 187 | /** Class mask. |
|
- | 188 | */ |
|
82 | #define IPOPT_CLASS_MASK 0x60 |
189 | #define IPOPT_CLASS_MASK 0x60 |
- | 190 | ||
- | 191 | /** Number mask. |
|
- | 192 | */ |
|
83 | #define IPOPT_NUMBER_MASK 0x1F |
193 | #define IPOPT_NUMBER_MASK 0x1F |
84 | 194 | ||
- | 195 | /** Copy flag. |
|
- | 196 | */ |
|
85 | #define IPOPT_COPY ( 1 << IPOPT_COPY_SHIFT ) |
197 | #define IPOPT_COPY ( 1 << IPOPT_COPY_SHIFT ) |
86 | 198 | ||
- | 199 | /** Returns IP option type. |
|
- | 200 | * @param[in] copy The value indication whether the IP option should be copied. |
|
- | 201 | * @param[in] class The IP option class. |
|
- | 202 | * @param[in] number The IP option number. |
|
- | 203 | */ |
|
87 | #define IPOPT_TYPE( copy, class, number ) ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK )) |
204 | #define IPOPT_TYPE( copy, class, number ) ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK )) |
88 | 205 | ||
- | 206 | /** Returns a value indicating whether the IP option should be copied. |
|
- | 207 | * @param[in] o The IP option. |
|
- | 208 | */ |
|
89 | #define IPOPT_COPIED( o ) (( o ) & IPOPT_COPY ) |
209 | #define IPOPT_COPIED( o ) (( o ) & IPOPT_COPY ) |
- | 210 | ||
- | 211 | /** Returns an IP option class. |
|
- | 212 | * @param[in] o The IP option. |
|
- | 213 | */ |
|
90 | #define IPOPT_CLASS( o ) (( o ) & IPOPT_CLASS_MASK ) |
214 | #define IPOPT_CLASS( o ) (( o ) & IPOPT_CLASS_MASK ) |
- | 215 | ||
- | 216 | /** Returns an IP option number. |
|
- | 217 | * @param[in] o The IP option. |
|
- | 218 | */ |
|
91 | #define IPOPT_NUMBER( o ) (( o ) & IPOPT_NUMBER_MASK ) |
219 | #define IPOPT_NUMBER( o ) (( o ) & IPOPT_NUMBER_MASK ) |
92 | 220 | ||
- | 221 | /*@}*/ |
|
- | 222 | ||
- | 223 | /** @name IP option class definitions |
|
- | 224 | */ |
|
- | 225 | /*@{*/ |
|
- | 226 | ||
- | 227 | /** Control class. |
|
- | 228 | */ |
|
93 | #define IPOPT_CONTROL ( 0 << IPOPT_CLASS_SHIFT ) |
229 | #define IPOPT_CONTROL ( 0 << IPOPT_CLASS_SHIFT ) |
- | 230 | ||
- | 231 | /** Reserved class 1. |
|
- | 232 | */ |
|
94 | #define IPOPT_RESERVED1 ( 1 << IPOPT_CLASS_SHIFT ) |
233 | #define IPOPT_RESERVED1 ( 1 << IPOPT_CLASS_SHIFT ) |
- | 234 | ||
- | 235 | /** Measurement class. |
|
- | 236 | */ |
|
95 | #define IPOPT_MEASUREMENT ( 2 << IPOPT_CLASS_SHIFT ) |
237 | #define IPOPT_MEASUREMENT ( 2 << IPOPT_CLASS_SHIFT ) |
- | 238 | ||
- | 239 | /** Reserved class 2. |
|
- | 240 | */ |
|
96 | #define IPOPT_RESERVED2 ( 3 << IPOPT_CLASS_SHIFT ) |
241 | #define IPOPT_RESERVED2 ( 3 << IPOPT_CLASS_SHIFT ) |
97 | 242 | ||
- | 243 | /*@}*/ |
|
- | 244 | ||
- | 245 | /** @name IP option type definitions |
|
- | 246 | */ |
|
- | 247 | /*@{*/ |
|
- | 248 | ||
- | 249 | /** End of list. |
|
- | 250 | */ |
|
98 | //#define IPOPT_END_OF_LIST 0x0 |
251 | //#define IPOPT_END_OF_LIST 0x0 |
99 | #define IPOPT_END IPOPT_TYPE( 0, IPOPT_CONTROL, 0 ) |
252 | #define IPOPT_END IPOPT_TYPE( 0, IPOPT_CONTROL, 0 ) |
- | 253 | ||
- | 254 | /** No operation. |
|
- | 255 | */ |
|
100 | //#define IPOPT_NO_OPERATION 0x1 |
256 | //#define IPOPT_NO_OPERATION 0x1 |
101 | #define IPOPT_NOOP IPOPT_TYPE( 0, IPOPT_CONTROL, 1 ) |
257 | #define IPOPT_NOOP IPOPT_TYPE( 0, IPOPT_CONTROL, 1 ) |
- | 258 | ||
- | 259 | /** Security. |
|
- | 260 | */ |
|
102 | //#define IPOPT_SECURITY 0x82 |
261 | //#define IPOPT_SECURITY 0x82 |
103 | #define IPOPT_SEC IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 ) |
262 | #define IPOPT_SEC IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 ) |
- | 263 | ||
104 | #define IPOPT_SEC_LENGTH 11 |
264 | /** Loose source. |
105 | #define IPOPT_SEC_UNCLASIFIED 0x0 |
- | |
106 | #define IPOPT_SEC_CONFIDENTIAL 0xF035 |
- | |
107 | #define IPOPT_SEC_EFTO 0x789A |
- | |
108 | #define IPOPT_SEC_MMMM 0xBC4D |
265 | */ |
109 | #define IPOPT_SEC_PROG 0x5E26 |
- | |
110 | #define IPOPT_SEC_RESTRICTED 0xAF13 |
- | |
111 | #define IPOPT_SEC_SECRET 0xD788 |
- | |
112 | #define IPOPT_SEC_TOP_SECRET 0x6BC5 |
- | |
113 | //#define IPOPT_LOOSE_SOURCE 0x83 |
266 | //#define IPOPT_LOOSE_SOURCE 0x83 |
114 | #define IPOPT_LSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 ) |
267 | #define IPOPT_LSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 ) |
- | 268 | ||
- | 269 | /** Strict route. |
|
- | 270 | */ |
|
115 | //#define IPOPT_STRICT_SOURCE 0x89 |
271 | //#define IPOPT_STRICT_SOURCE 0x89 |
116 | #define IPOPT_SSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 ) |
272 | #define IPOPT_SSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 ) |
- | 273 | ||
- | 274 | /** Record route. |
|
- | 275 | */ |
|
117 | //#define IPOPT_RECORD_ROUTE 0x07 |
276 | //#define IPOPT_RECORD_ROUTE 0x07 |
118 | #define IPOPT_RR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 ) |
277 | #define IPOPT_RR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 ) |
- | 278 | ||
- | 279 | /** Stream identifier. |
|
- | 280 | */ |
|
119 | //#define IPOPT_STREAM_IDENTIFIER 0x88 |
281 | //#define IPOPT_STREAM_IDENTIFIER 0x88 |
120 | #define IPOPT_SID IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 ) |
282 | #define IPOPT_SID IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 ) |
- | 283 | ||
- | 284 | /** Stream identifier length. |
|
- | 285 | */ |
|
121 | #define IPOPT_SID_LENGTH 4 |
286 | #define IPOPT_SID_LENGTH 4 |
- | 287 | ||
- | 288 | /** Internet timestamp. |
|
- | 289 | */ |
|
122 | //#define IPOPT_INTERNET_TIMESTAMP 0x44 |
290 | //#define IPOPT_INTERNET_TIMESTAMP 0x44 |
123 | #define IPOPT_TIMESTAMP IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 ) |
291 | #define IPOPT_TIMESTAMP IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 ) |
- | 292 | ||
- | 293 | /** Commercial IP security option. |
|
- | 294 | */ |
|
124 | #define IPOPT_CIPSO IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 ) |
295 | #define IPOPT_CIPSO IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 ) |
125 | 296 | ||
- | 297 | /** No operation variant. |
|
- | 298 | */ |
|
126 | #define IPOPT_NOP IPOPT_NOOP |
299 | #define IPOPT_NOP IPOPT_NOOP |
- | 300 | ||
- | 301 | /** End of list variant. |
|
- | 302 | */ |
|
127 | #define IPOPT_EOL IPOPT_END |
303 | #define IPOPT_EOL IPOPT_END |
- | 304 | ||
- | 305 | /** Timestamp variant. |
|
- | 306 | */ |
|
128 | #define IPOPT_TS IPOPT_TIMESTAMP |
307 | #define IPOPT_TS IPOPT_TIMESTAMP |
129 | 308 | ||
- | 309 | /*@}*/ |
|
- | 310 | ||
- | 311 | /** @name IP security option definitions |
|
- | 312 | */ |
|
- | 313 | /*@{*/ |
|
- | 314 | ||
- | 315 | /** Security length. |
|
- | 316 | */ |
|
- | 317 | #define IPOPT_SEC_LENGTH 11 |
|
- | 318 | ||
- | 319 | /** Unclasified. |
|
- | 320 | */ |
|
- | 321 | #define IPOPT_SEC_UNCLASIFIED 0x0 |
|
- | 322 | ||
- | 323 | /** Confidential. |
|
- | 324 | */ |
|
- | 325 | #define IPOPT_SEC_CONFIDENTIAL 0xF035 |
|
- | 326 | ||
- | 327 | /** EFTO. |
|
- | 328 | */ |
|
- | 329 | #define IPOPT_SEC_EFTO 0x789A |
|
- | 330 | ||
- | 331 | /** MMMM. |
|
- | 332 | */ |
|
- | 333 | #define IPOPT_SEC_MMMM 0xBC4D |
|
- | 334 | ||
- | 335 | /** PROG. |
|
- | 336 | */ |
|
- | 337 | #define IPOPT_SEC_PROG 0x5E26 |
|
- | 338 | ||
- | 339 | /** Restricted. |
|
- | 340 | */ |
|
- | 341 | #define IPOPT_SEC_RESTRICTED 0xAF13 |
|
- | 342 | ||
- | 343 | /** Secret. |
|
- | 344 | */ |
|
- | 345 | #define IPOPT_SEC_SECRET 0xD788 |
|
- | 346 | ||
- | 347 | /** Top secret. |
|
- | 348 | */ |
|
- | 349 | #define IPOPT_SEC_TOP_SECRET 0x6BC5 |
|
- | 350 | ||
- | 351 | /*@}*/ |
|
- | 352 | ||
- | 353 | /** @name IP timestamp option definitions |
|
- | 354 | */ |
|
- | 355 | /*@{*/ |
|
- | 356 | ||
- | 357 | /** Tiemstamp only. |
|
- | 358 | */ |
|
130 | #define IPOPT_TS_TSONLY 0 /* timestamps only */ |
359 | #define IPOPT_TS_TSONLY 0 |
- | 360 | ||
- | 361 | /** Timestamps and addresses. |
|
- | 362 | */ |
|
131 | #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ |
363 | #define IPOPT_TS_TSANDADDR 1 |
- | 364 | ||
- | 365 | /** Specified modules only. |
|
- | 366 | */ |
|
132 | #define IPOPT_TS_PRESPEC 3 /* specified modules only */ |
367 | #define IPOPT_TS_PRESPEC 3 |
- | 368 | ||
- | 369 | /*@}*/ |
|
133 | 370 | ||
134 | #endif |
371 | #endif |
135 | 372 | ||
136 | /** @} |
373 | /** @} |
137 | */ |
374 | */ |