Rev 4710 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 4710 | mejdrech | 1 | /* |
| 2 | * Copyright (c) 2009 Lukas Mejdrech |
||
| 3 | * All rights reserved. |
||
| 4 | * |
||
| 5 | * Redistribution and use in source and binary forms, with or without |
||
| 6 | * modification, are permitted provided that the following conditions |
||
| 7 | * are met: |
||
| 8 | * |
||
| 9 | * - Redistributions of source code must retain the above copyright |
||
| 10 | * notice, this list of conditions and the following disclaimer. |
||
| 11 | * - Redistributions in binary form must reproduce the above copyright |
||
| 12 | * notice, this list of conditions and the following disclaimer in the |
||
| 13 | * documentation and/or other materials provided with the distribution. |
||
| 14 | * - The name of the author may not be used to endorse or promote products |
||
| 15 | * derived from this software without specific prior written permission. |
||
| 16 | * |
||
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
||
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
| 27 | */ |
||
| 28 | |||
| 29 | /** @addtogroup ip |
||
| 30 | * @{ |
||
| 31 | */ |
||
| 32 | |||
| 33 | /** @file |
||
| 4756 | mejdrech | 34 | * IP codes and definitions. |
| 4710 | mejdrech | 35 | */ |
| 36 | |||
| 37 | #ifndef __NET_IP_CODES_H__ |
||
| 38 | #define __NET_IP_CODES_H__ |
||
| 39 | |||
| 40 | #include <sys/types.h> |
||
| 41 | |||
| 4756 | mejdrech | 42 | /** IP time to live counter type definition. |
| 43 | */ |
||
| 4710 | mejdrech | 44 | typedef uint8_t ip_ttl_t; |
| 4756 | mejdrech | 45 | |
| 46 | /** IP type of service type definition. |
||
| 47 | */ |
||
| 4710 | mejdrech | 48 | typedef uint8_t ip_tos_t; |
| 4756 | mejdrech | 49 | |
| 50 | /** IP transport protocol type definition. |
||
| 51 | */ |
||
| 4710 | mejdrech | 52 | typedef uint8_t ip_protocol_t; |
| 53 | |||
| 4756 | mejdrech | 54 | /** Default IPVERSION. |
| 55 | */ |
||
| 4710 | mejdrech | 56 | #define IPVERSION 4 |
| 4756 | mejdrech | 57 | |
| 58 | /** Maximum time to live counter. |
||
| 59 | */ |
||
| 4710 | mejdrech | 60 | #define MAXTTL 255 |
| 4756 | mejdrech | 61 | |
| 62 | /** Default time to live counter. |
||
| 63 | */ |
||
| 4710 | mejdrech | 64 | #define IPDEFTTL 64 |
| 65 | |||
| 4756 | mejdrech | 66 | /** @name IP type of service definitions |
| 67 | */ |
||
| 68 | /*@{*/ |
||
| 69 | |||
| 70 | /** IP TOS mask. |
||
| 71 | */ |
||
| 4710 | mejdrech | 72 | #define IPTOS_TOS_MASK 0x1E |
| 4756 | mejdrech | 73 | |
| 74 | /** Precedence shift. |
||
| 75 | */ |
||
| 4710 | mejdrech | 76 | #define IPTOS_PRECEDENCE_SHIFT 5 |
| 4756 | mejdrech | 77 | |
| 78 | /** Delay shift. |
||
| 79 | */ |
||
| 4710 | mejdrech | 80 | #define IPTOS_DELAY_SHIFT 4 |
| 4756 | mejdrech | 81 | |
| 82 | /** Throughput shift. |
||
| 83 | */ |
||
| 4710 | mejdrech | 84 | #define IPTOS_THROUGHPUT_SHIFT 3 |
| 4756 | mejdrech | 85 | |
| 86 | /** Reliability shift. |
||
| 87 | */ |
||
| 4710 | mejdrech | 88 | #define IPTOS_RELIABILITY_SHIFT 2 |
| 4756 | mejdrech | 89 | |
| 90 | /** Cost shift. |
||
| 91 | */ |
||
| 4710 | mejdrech | 92 | #define IPTOS_COST_SHIFT 1 |
| 93 | |||
| 4756 | mejdrech | 94 | /** Normal delay. |
| 95 | */ |
||
| 4710 | mejdrech | 96 | #define IPTOS_NORMALDELAY ( 0x0 << IPTOS_DELAY_SHIFT ) |
| 4756 | mejdrech | 97 | |
| 98 | /** Low delay. |
||
| 99 | */ |
||
| 4710 | mejdrech | 100 | #define IPTOS_LOWDELAY ( 0x1 << IPTOS_DELAY_SHIFT ) |
| 101 | |||
| 4756 | mejdrech | 102 | /** Normal throughput. |
| 103 | */ |
||
| 4710 | mejdrech | 104 | #define IPTOS_NORMALTHROUGHPUT ( 0x0 << IPTOS_THROUGHPUT_SHIFT ) |
| 4756 | mejdrech | 105 | |
| 106 | /** Throughput. |
||
| 107 | */ |
||
| 4710 | mejdrech | 108 | #define IPTOS_THROUGHPUT ( 0x1 << IPTOS_THROUGHPUT_SHIFT ) |
| 109 | |||
| 4756 | mejdrech | 110 | /** Normal reliability. |
| 111 | */ |
||
| 4710 | mejdrech | 112 | #define IPTOS_NORMALRELIABILITY ( 0x0 << IPTOS_RELIABILITY_SHIFT ) |
| 4756 | mejdrech | 113 | |
| 114 | /** Reliability. |
||
| 115 | */ |
||
| 4710 | mejdrech | 116 | #define IPTOS_RELIABILITY ( 0x1 << IPTOS_RELIABILITY_SHIFT ) |
| 117 | |||
| 4756 | mejdrech | 118 | /** Normal cost. |
| 119 | */ |
||
| 4710 | mejdrech | 120 | #define IPTOS_NORMALCOST ( 0x0 << IPTOS_COST_SHIFT ) |
| 4756 | mejdrech | 121 | |
| 122 | /** Minimum cost. |
||
| 123 | */ |
||
| 4710 | mejdrech | 124 | #define IPTOS_MICNCOST ( 0x1 << IPTOS_COST_SHIFT ) |
| 125 | |||
| 4756 | mejdrech | 126 | /*@}*/ |
| 127 | |||
| 128 | /** @name IP TOS precedence definitions |
||
| 129 | */ |
||
| 130 | /*@{*/ |
||
| 131 | |||
| 132 | |||
| 133 | /** Precedence mask. |
||
| 134 | */ |
||
| 4710 | mejdrech | 135 | #define IPTOS_PREC_MASK 0xE0 |
| 4756 | mejdrech | 136 | |
| 137 | /** Routine precedence. |
||
| 138 | */ |
||
| 4710 | mejdrech | 139 | #define IPTOS_PREC_ROUTINE ( 0x0 << IPTOS_PRECEDENCE_SHIFT ) |
| 4756 | mejdrech | 140 | |
| 141 | /** Priority precedence. |
||
| 142 | */ |
||
| 4710 | mejdrech | 143 | #define IPTOS_PREC_PRIORITY ( 0x1 << IPTOS_PRECEDENCE_SHIFT ) |
| 4756 | mejdrech | 144 | |
| 145 | /** Immediate precedence. |
||
| 146 | */ |
||
| 4710 | mejdrech | 147 | #define IPTOS_PREC_IMMEDIATE ( 0x2 << IPTOS_PRECEDENCE_SHIFT ) |
| 4756 | mejdrech | 148 | |
| 149 | /** Flash precedence. |
||
| 150 | */ |
||
| 4710 | mejdrech | 151 | #define IPTOS_PREC_FLASH ( 0x3 << IPTOS_PRECEDENCE_SHIFT ) |
| 4756 | mejdrech | 152 | |
| 153 | /** Flash override precedence. |
||
| 154 | */ |
||
| 4710 | mejdrech | 155 | #define IPTOS_PREC_FLASHOVERRIDE ( 0x4 << IPTOS_PRECEDENCE_SHIFT ) |
| 4756 | mejdrech | 156 | |
| 157 | /** Critical precedence. |
||
| 158 | */ |
||
| 4710 | mejdrech | 159 | #define IPTOS_PREC_CRITIC_ECP ( 0x5 << IPTOS_PRECEDENCE_SHIFT ) |
| 4756 | mejdrech | 160 | |
| 161 | /** Inter-network control precedence. |
||
| 162 | */ |
||
| 4710 | mejdrech | 163 | #define IPTOS_PREC_INTERNETCONTROL ( 0x6 << IPTOS_PRECEDENCE_SHIFT ) |
| 4756 | mejdrech | 164 | |
| 165 | /** Network control precedence. |
||
| 166 | */ |
||
| 4710 | mejdrech | 167 | #define IPTOS_PREC_NETCONTROL ( 0x7 << IPTOS_PRECEDENCE_SHIFT ) |
| 168 | |||
| 4756 | mejdrech | 169 | /*@}*/ |
| 170 | |||
| 171 | /** @name IP options definitions |
||
| 172 | */ |
||
| 173 | /*@{*/ |
||
| 174 | |||
| 175 | /** Copy shift. |
||
| 176 | */ |
||
| 4710 | mejdrech | 177 | #define IPOPT_COPY_SHIFT 7 |
| 4756 | mejdrech | 178 | |
| 179 | /** Class shift. |
||
| 180 | */ |
||
| 4710 | mejdrech | 181 | #define IPOPT_CLASS_SHIFT 5 |
| 4756 | mejdrech | 182 | |
| 183 | /** Number shift. |
||
| 184 | */ |
||
| 4710 | mejdrech | 185 | #define IPOPT_NUMBER_SHIFT 0 |
| 4756 | mejdrech | 186 | |
| 187 | /** Class mask. |
||
| 188 | */ |
||
| 4710 | mejdrech | 189 | #define IPOPT_CLASS_MASK 0x60 |
| 4756 | mejdrech | 190 | |
| 191 | /** Number mask. |
||
| 192 | */ |
||
| 4710 | mejdrech | 193 | #define IPOPT_NUMBER_MASK 0x1F |
| 194 | |||
| 4756 | mejdrech | 195 | /** Copy flag. |
| 196 | */ |
||
| 4710 | mejdrech | 197 | #define IPOPT_COPY ( 1 << IPOPT_COPY_SHIFT ) |
| 198 | |||
| 4756 | mejdrech | 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 | */ |
||
| 4710 | mejdrech | 204 | #define IPOPT_TYPE( copy, class, number ) ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK )) |
| 205 | |||
| 4756 | mejdrech | 206 | /** Returns a value indicating whether the IP option should be copied. |
| 207 | * @param[in] o The IP option. |
||
| 208 | */ |
||
| 4710 | mejdrech | 209 | #define IPOPT_COPIED( o ) (( o ) & IPOPT_COPY ) |
| 4756 | mejdrech | 210 | |
| 211 | /** Returns an IP option class. |
||
| 212 | * @param[in] o The IP option. |
||
| 213 | */ |
||
| 4710 | mejdrech | 214 | #define IPOPT_CLASS( o ) (( o ) & IPOPT_CLASS_MASK ) |
| 4756 | mejdrech | 215 | |
| 216 | /** Returns an IP option number. |
||
| 217 | * @param[in] o The IP option. |
||
| 218 | */ |
||
| 4710 | mejdrech | 219 | #define IPOPT_NUMBER( o ) (( o ) & IPOPT_NUMBER_MASK ) |
| 220 | |||
| 4756 | mejdrech | 221 | /*@}*/ |
| 222 | |||
| 223 | /** @name IP option class definitions |
||
| 224 | */ |
||
| 225 | /*@{*/ |
||
| 226 | |||
| 227 | /** Control class. |
||
| 228 | */ |
||
| 4710 | mejdrech | 229 | #define IPOPT_CONTROL ( 0 << IPOPT_CLASS_SHIFT ) |
| 4756 | mejdrech | 230 | |
| 231 | /** Reserved class 1. |
||
| 232 | */ |
||
| 4710 | mejdrech | 233 | #define IPOPT_RESERVED1 ( 1 << IPOPT_CLASS_SHIFT ) |
| 4756 | mejdrech | 234 | |
| 235 | /** Measurement class. |
||
| 236 | */ |
||
| 4710 | mejdrech | 237 | #define IPOPT_MEASUREMENT ( 2 << IPOPT_CLASS_SHIFT ) |
| 4756 | mejdrech | 238 | |
| 239 | /** Reserved class 2. |
||
| 240 | */ |
||
| 4710 | mejdrech | 241 | #define IPOPT_RESERVED2 ( 3 << IPOPT_CLASS_SHIFT ) |
| 242 | |||
| 4756 | mejdrech | 243 | /*@}*/ |
| 244 | |||
| 245 | /** @name IP option type definitions |
||
| 246 | */ |
||
| 247 | /*@{*/ |
||
| 248 | |||
| 249 | /** End of list. |
||
| 250 | */ |
||
| 251 | //#define IPOPT_END_OF_LIST 0x0 |
||
| 4710 | mejdrech | 252 | #define IPOPT_END IPOPT_TYPE( 0, IPOPT_CONTROL, 0 ) |
| 4756 | mejdrech | 253 | |
| 254 | /** No operation. |
||
| 255 | */ |
||
| 4710 | mejdrech | 256 | //#define IPOPT_NO_OPERATION 0x1 |
| 257 | #define IPOPT_NOOP IPOPT_TYPE( 0, IPOPT_CONTROL, 1 ) |
||
| 4756 | mejdrech | 258 | |
| 259 | /** Security. |
||
| 260 | */ |
||
| 4710 | mejdrech | 261 | //#define IPOPT_SECURITY 0x82 |
| 262 | #define IPOPT_SEC IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 ) |
||
| 4756 | mejdrech | 263 | |
| 264 | /** Loose source. |
||
| 265 | */ |
||
| 4710 | mejdrech | 266 | //#define IPOPT_LOOSE_SOURCE 0x83 |
| 267 | #define IPOPT_LSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 ) |
||
| 4756 | mejdrech | 268 | |
| 269 | /** Strict route. |
||
| 270 | */ |
||
| 4710 | mejdrech | 271 | //#define IPOPT_STRICT_SOURCE 0x89 |
| 272 | #define IPOPT_SSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 ) |
||
| 4756 | mejdrech | 273 | |
| 274 | /** Record route. |
||
| 275 | */ |
||
| 4710 | mejdrech | 276 | //#define IPOPT_RECORD_ROUTE 0x07 |
| 277 | #define IPOPT_RR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 ) |
||
| 4756 | mejdrech | 278 | |
| 279 | /** Stream identifier. |
||
| 280 | */ |
||
| 4710 | mejdrech | 281 | //#define IPOPT_STREAM_IDENTIFIER 0x88 |
| 282 | #define IPOPT_SID IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 ) |
||
| 4756 | mejdrech | 283 | |
| 284 | /** Stream identifier length. |
||
| 285 | */ |
||
| 4710 | mejdrech | 286 | #define IPOPT_SID_LENGTH 4 |
| 4756 | mejdrech | 287 | |
| 288 | /** Internet timestamp. |
||
| 289 | */ |
||
| 4710 | mejdrech | 290 | //#define IPOPT_INTERNET_TIMESTAMP 0x44 |
| 291 | #define IPOPT_TIMESTAMP IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 ) |
||
| 4756 | mejdrech | 292 | |
| 293 | /** Commercial IP security option. |
||
| 294 | */ |
||
| 4710 | mejdrech | 295 | #define IPOPT_CIPSO IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 ) |
| 296 | |||
| 4756 | mejdrech | 297 | /** No operation variant. |
| 298 | */ |
||
| 4710 | mejdrech | 299 | #define IPOPT_NOP IPOPT_NOOP |
| 4756 | mejdrech | 300 | |
| 301 | /** End of list variant. |
||
| 302 | */ |
||
| 4710 | mejdrech | 303 | #define IPOPT_EOL IPOPT_END |
| 4756 | mejdrech | 304 | |
| 305 | /** Timestamp variant. |
||
| 306 | */ |
||
| 4710 | mejdrech | 307 | #define IPOPT_TS IPOPT_TIMESTAMP |
| 308 | |||
| 4756 | mejdrech | 309 | /*@}*/ |
| 4710 | mejdrech | 310 | |
| 4756 | mejdrech | 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 | */ |
||
| 359 | #define IPOPT_TS_TSONLY 0 |
||
| 360 | |||
| 361 | /** Timestamps and addresses. |
||
| 362 | */ |
||
| 363 | #define IPOPT_TS_TSANDADDR 1 |
||
| 364 | |||
| 365 | /** Specified modules only. |
||
| 366 | */ |
||
| 367 | #define IPOPT_TS_PRESPEC 3 |
||
| 368 | |||
| 369 | /*@}*/ |
||
| 370 | |||
| 4710 | mejdrech | 371 | #endif |
| 372 | |||
| 373 | /** @} |
||
| 374 | */ |