[21580dd] | 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
|
---|
| 34 | * IP codes and definitions.
|
---|
| 35 | */
|
---|
| 36 |
|
---|
| 37 | #ifndef __NET_IP_CODES_H__
|
---|
| 38 | #define __NET_IP_CODES_H__
|
---|
| 39 |
|
---|
| 40 | #include <sys/types.h>
|
---|
| 41 |
|
---|
| 42 | /** IP time to live counter type definition.
|
---|
| 43 | */
|
---|
| 44 | typedef uint8_t ip_ttl_t;
|
---|
| 45 |
|
---|
| 46 | /** IP type of service type definition.
|
---|
| 47 | */
|
---|
| 48 | typedef uint8_t ip_tos_t;
|
---|
| 49 |
|
---|
| 50 | /** IP transport protocol type definition.
|
---|
| 51 | */
|
---|
| 52 | typedef uint8_t ip_protocol_t;
|
---|
| 53 |
|
---|
| 54 | /** Default IPVERSION.
|
---|
| 55 | */
|
---|
| 56 | #define IPVERSION 4
|
---|
| 57 |
|
---|
| 58 | /** Maximum time to live counter.
|
---|
| 59 | */
|
---|
| 60 | #define MAXTTL 255
|
---|
| 61 |
|
---|
| 62 | /** Default time to live counter.
|
---|
| 63 | */
|
---|
| 64 | #define IPDEFTTL 64
|
---|
| 65 |
|
---|
| 66 | /** @name IP type of service definitions
|
---|
| 67 | */
|
---|
| 68 | /*@{*/
|
---|
| 69 |
|
---|
| 70 | /** IP TOS mask.
|
---|
| 71 | */
|
---|
| 72 | #define IPTOS_TOS_MASK 0x1E
|
---|
| 73 |
|
---|
| 74 | /** Precedence shift.
|
---|
| 75 | */
|
---|
| 76 | #define IPTOS_PRECEDENCE_SHIFT 5
|
---|
| 77 |
|
---|
| 78 | /** Delay shift.
|
---|
| 79 | */
|
---|
| 80 | #define IPTOS_DELAY_SHIFT 4
|
---|
| 81 |
|
---|
| 82 | /** Throughput shift.
|
---|
| 83 | */
|
---|
| 84 | #define IPTOS_THROUGHPUT_SHIFT 3
|
---|
| 85 |
|
---|
| 86 | /** Reliability shift.
|
---|
| 87 | */
|
---|
| 88 | #define IPTOS_RELIABILITY_SHIFT 2
|
---|
| 89 |
|
---|
| 90 | /** Cost shift.
|
---|
| 91 | */
|
---|
| 92 | #define IPTOS_COST_SHIFT 1
|
---|
| 93 |
|
---|
| 94 | /** Normal delay.
|
---|
| 95 | */
|
---|
[aadf01e] | 96 | #define IPTOS_NORMALDELAY (0x0 << IPTOS_DELAY_SHIFT)
|
---|
[21580dd] | 97 |
|
---|
| 98 | /** Low delay.
|
---|
| 99 | */
|
---|
[aadf01e] | 100 | #define IPTOS_LOWDELAY (0x1 << IPTOS_DELAY_SHIFT)
|
---|
[21580dd] | 101 |
|
---|
| 102 | /** Normal throughput.
|
---|
| 103 | */
|
---|
[aadf01e] | 104 | #define IPTOS_NORMALTHROUGHPUT (0x0 << IPTOS_THROUGHPUT_SHIFT)
|
---|
[21580dd] | 105 |
|
---|
| 106 | /** Throughput.
|
---|
| 107 | */
|
---|
[aadf01e] | 108 | #define IPTOS_THROUGHPUT (0x1 << IPTOS_THROUGHPUT_SHIFT)
|
---|
[21580dd] | 109 |
|
---|
| 110 | /** Normal reliability.
|
---|
| 111 | */
|
---|
[aadf01e] | 112 | #define IPTOS_NORMALRELIABILITY (0x0 << IPTOS_RELIABILITY_SHIFT)
|
---|
[21580dd] | 113 |
|
---|
| 114 | /** Reliability.
|
---|
| 115 | */
|
---|
[aadf01e] | 116 | #define IPTOS_RELIABILITY (0x1 << IPTOS_RELIABILITY_SHIFT)
|
---|
[21580dd] | 117 |
|
---|
| 118 | /** Normal cost.
|
---|
| 119 | */
|
---|
[aadf01e] | 120 | #define IPTOS_NORMALCOST (0x0 << IPTOS_COST_SHIFT)
|
---|
[21580dd] | 121 |
|
---|
| 122 | /** Minimum cost.
|
---|
| 123 | */
|
---|
[aadf01e] | 124 | #define IPTOS_MICNCOST (0x1 << IPTOS_COST_SHIFT)
|
---|
[21580dd] | 125 |
|
---|
| 126 | /*@}*/
|
---|
| 127 |
|
---|
| 128 | /** @name IP TOS precedence definitions
|
---|
| 129 | */
|
---|
| 130 | /*@{*/
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | /** Precedence mask.
|
---|
| 134 | */
|
---|
| 135 | #define IPTOS_PREC_MASK 0xE0
|
---|
| 136 |
|
---|
| 137 | /** Routine precedence.
|
---|
| 138 | */
|
---|
[aadf01e] | 139 | #define IPTOS_PREC_ROUTINE (0x0 << IPTOS_PRECEDENCE_SHIFT)
|
---|
[21580dd] | 140 |
|
---|
| 141 | /** Priority precedence.
|
---|
| 142 | */
|
---|
[aadf01e] | 143 | #define IPTOS_PREC_PRIORITY (0x1 << IPTOS_PRECEDENCE_SHIFT)
|
---|
[21580dd] | 144 |
|
---|
| 145 | /** Immediate precedence.
|
---|
| 146 | */
|
---|
[aadf01e] | 147 | #define IPTOS_PREC_IMMEDIATE (0x2 << IPTOS_PRECEDENCE_SHIFT)
|
---|
[21580dd] | 148 |
|
---|
| 149 | /** Flash precedence.
|
---|
| 150 | */
|
---|
[aadf01e] | 151 | #define IPTOS_PREC_FLASH (0x3 << IPTOS_PRECEDENCE_SHIFT)
|
---|
[21580dd] | 152 |
|
---|
| 153 | /** Flash override precedence.
|
---|
| 154 | */
|
---|
[aadf01e] | 155 | #define IPTOS_PREC_FLASHOVERRIDE (0x4 << IPTOS_PRECEDENCE_SHIFT)
|
---|
[21580dd] | 156 |
|
---|
| 157 | /** Critical precedence.
|
---|
| 158 | */
|
---|
[aadf01e] | 159 | #define IPTOS_PREC_CRITIC_ECP (0x5 << IPTOS_PRECEDENCE_SHIFT)
|
---|
[21580dd] | 160 |
|
---|
| 161 | /** Inter-network control precedence.
|
---|
| 162 | */
|
---|
[aadf01e] | 163 | #define IPTOS_PREC_INTERNETCONTROL (0x6 << IPTOS_PRECEDENCE_SHIFT)
|
---|
[21580dd] | 164 |
|
---|
| 165 | /** Network control precedence.
|
---|
| 166 | */
|
---|
[aadf01e] | 167 | #define IPTOS_PREC_NETCONTROL (0x7 << IPTOS_PRECEDENCE_SHIFT)
|
---|
[21580dd] | 168 |
|
---|
| 169 | /*@}*/
|
---|
| 170 |
|
---|
| 171 | /** @name IP options definitions
|
---|
| 172 | */
|
---|
| 173 | /*@{*/
|
---|
| 174 |
|
---|
| 175 | /** Copy shift.
|
---|
| 176 | */
|
---|
| 177 | #define IPOPT_COPY_SHIFT 7
|
---|
| 178 |
|
---|
| 179 | /** Class shift.
|
---|
| 180 | */
|
---|
| 181 | #define IPOPT_CLASS_SHIFT 5
|
---|
| 182 |
|
---|
| 183 | /** Number shift.
|
---|
| 184 | */
|
---|
| 185 | #define IPOPT_NUMBER_SHIFT 0
|
---|
| 186 |
|
---|
| 187 | /** Class mask.
|
---|
| 188 | */
|
---|
| 189 | #define IPOPT_CLASS_MASK 0x60
|
---|
| 190 |
|
---|
| 191 | /** Number mask.
|
---|
| 192 | */
|
---|
| 193 | #define IPOPT_NUMBER_MASK 0x1F
|
---|
| 194 |
|
---|
| 195 | /** Copy flag.
|
---|
| 196 | */
|
---|
[aadf01e] | 197 | #define IPOPT_COPY (1 << IPOPT_COPY_SHIFT)
|
---|
[21580dd] | 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 | */
|
---|
[aadf01e] | 204 | #define IPOPT_TYPE(copy, class, number) (((copy) &IPOPT_COPY) | ((class) &IPOPT_CLASS_MASK) | ((number << IPOPT_NUMBER_SHIFT) &IPOPT_NUMBER_MASK))
|
---|
[21580dd] | 205 |
|
---|
| 206 | /** Returns a value indicating whether the IP option should be copied.
|
---|
| 207 | * @param[in] o The IP option.
|
---|
| 208 | */
|
---|
[aadf01e] | 209 | #define IPOPT_COPIED(o) ((o) &IPOPT_COPY)
|
---|
[21580dd] | 210 |
|
---|
| 211 | /** Returns an IP option class.
|
---|
| 212 | * @param[in] o The IP option.
|
---|
| 213 | */
|
---|
[aadf01e] | 214 | #define IPOPT_CLASS(o) ((o) &IPOPT_CLASS_MASK)
|
---|
[21580dd] | 215 |
|
---|
| 216 | /** Returns an IP option number.
|
---|
| 217 | * @param[in] o The IP option.
|
---|
| 218 | */
|
---|
[aadf01e] | 219 | #define IPOPT_NUMBER(o) ((o) &IPOPT_NUMBER_MASK)
|
---|
[21580dd] | 220 |
|
---|
| 221 | /*@}*/
|
---|
| 222 |
|
---|
| 223 | /** @name IP option class definitions
|
---|
| 224 | */
|
---|
| 225 | /*@{*/
|
---|
| 226 |
|
---|
| 227 | /** Control class.
|
---|
| 228 | */
|
---|
[aadf01e] | 229 | #define IPOPT_CONTROL (0 << IPOPT_CLASS_SHIFT)
|
---|
[21580dd] | 230 |
|
---|
| 231 | /** Reserved class 1.
|
---|
| 232 | */
|
---|
[aadf01e] | 233 | #define IPOPT_RESERVED1 (1 << IPOPT_CLASS_SHIFT)
|
---|
[21580dd] | 234 |
|
---|
| 235 | /** Measurement class.
|
---|
| 236 | */
|
---|
[aadf01e] | 237 | #define IPOPT_MEASUREMENT (2 << IPOPT_CLASS_SHIFT)
|
---|
[21580dd] | 238 |
|
---|
| 239 | /** Reserved class 2.
|
---|
| 240 | */
|
---|
[aadf01e] | 241 | #define IPOPT_RESERVED2 (3 << IPOPT_CLASS_SHIFT)
|
---|
[21580dd] | 242 |
|
---|
| 243 | /*@}*/
|
---|
| 244 |
|
---|
| 245 | /** @name IP option type definitions
|
---|
| 246 | */
|
---|
| 247 | /*@{*/
|
---|
| 248 |
|
---|
| 249 | /** End of list.
|
---|
| 250 | */
|
---|
| 251 | //#define IPOPT_END_OF_LIST 0x0
|
---|
[aadf01e] | 252 | #define IPOPT_END IPOPT_TYPE(0, IPOPT_CONTROL, 0)
|
---|
[21580dd] | 253 |
|
---|
| 254 | /** No operation.
|
---|
| 255 | */
|
---|
| 256 | //#define IPOPT_NO_OPERATION 0x1
|
---|
[aadf01e] | 257 | #define IPOPT_NOOP IPOPT_TYPE(0, IPOPT_CONTROL, 1)
|
---|
[21580dd] | 258 |
|
---|
| 259 | /** Security.
|
---|
| 260 | */
|
---|
| 261 | //#define IPOPT_SECURITY 0x82
|
---|
[aadf01e] | 262 | #define IPOPT_SEC IPOPT_TYPE(IPOPT_COPY, IPOPT_CONTROL, 2)
|
---|
[21580dd] | 263 |
|
---|
| 264 | /** Loose source.
|
---|
| 265 | */
|
---|
| 266 | //#define IPOPT_LOOSE_SOURCE 0x83
|
---|
[aadf01e] | 267 | #define IPOPT_LSRR IPOPT_TYPE(IPOPT_COPY, IPOPT_CONTROL, 3)
|
---|
[21580dd] | 268 |
|
---|
| 269 | /** Strict route.
|
---|
| 270 | */
|
---|
| 271 | //#define IPOPT_STRICT_SOURCE 0x89
|
---|
[aadf01e] | 272 | #define IPOPT_SSRR IPOPT_TYPE(IPOPT_COPY, IPOPT_CONTROL, 9)
|
---|
[21580dd] | 273 |
|
---|
| 274 | /** Record route.
|
---|
| 275 | */
|
---|
| 276 | //#define IPOPT_RECORD_ROUTE 0x07
|
---|
[aadf01e] | 277 | #define IPOPT_RR IPOPT_TYPE(IPOPT_COPY, IPOPT_CONTROL, 7)
|
---|
[21580dd] | 278 |
|
---|
| 279 | /** Stream identifier.
|
---|
| 280 | */
|
---|
| 281 | //#define IPOPT_STREAM_IDENTIFIER 0x88
|
---|
[aadf01e] | 282 | #define IPOPT_SID IPOPT_TYPE(IPOPT_COPY, IPOPT_CONTROL, 8)
|
---|
[21580dd] | 283 |
|
---|
| 284 | /** Stream identifier length.
|
---|
| 285 | */
|
---|
| 286 | #define IPOPT_SID_LENGTH 4
|
---|
| 287 |
|
---|
| 288 | /** Internet timestamp.
|
---|
| 289 | */
|
---|
| 290 | //#define IPOPT_INTERNET_TIMESTAMP 0x44
|
---|
[aadf01e] | 291 | #define IPOPT_TIMESTAMP IPOPT_TYPE(IPOPT_COPY, IPOPT_MEASUREMENT, 4)
|
---|
[21580dd] | 292 |
|
---|
| 293 | /** Commercial IP security option.
|
---|
| 294 | */
|
---|
[aadf01e] | 295 | #define IPOPT_CIPSO IPOPT_TYPE(IPOPT_COPY, IPOPT_CONTROL, 5)
|
---|
[21580dd] | 296 |
|
---|
| 297 | /** No operation variant.
|
---|
| 298 | */
|
---|
| 299 | #define IPOPT_NOP IPOPT_NOOP
|
---|
| 300 |
|
---|
| 301 | /** End of list variant.
|
---|
| 302 | */
|
---|
| 303 | #define IPOPT_EOL IPOPT_END
|
---|
| 304 |
|
---|
| 305 | /** Timestamp variant.
|
---|
| 306 | */
|
---|
| 307 | #define IPOPT_TS IPOPT_TIMESTAMP
|
---|
| 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 | */
|
---|
| 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 |
|
---|
| 371 | #endif
|
---|
| 372 |
|
---|
| 373 | /** @}
|
---|
| 374 | */
|
---|