1 | /*
|
---|
2 | * Copyright (c) 2012 Jiri Svoboda
|
---|
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 inet
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /**
|
---|
33 | * @file IP header definitions
|
---|
34 | *
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef INET_STD_H_
|
---|
38 | #define INET_STD_H_
|
---|
39 |
|
---|
40 | #include <sys/types.h>
|
---|
41 |
|
---|
42 | /** Internet Datagram header (fixed part) */
|
---|
43 | typedef struct {
|
---|
44 | /** Version, Internet Header Length */
|
---|
45 | uint8_t ver_ihl;
|
---|
46 | /* Type of Service */
|
---|
47 | uint8_t tos;
|
---|
48 | /** Total Length */
|
---|
49 | uint16_t tot_len;
|
---|
50 | /** Identification */
|
---|
51 | uint16_t id;
|
---|
52 | /** Flags, Fragment Offset */
|
---|
53 | uint16_t flags_foff;
|
---|
54 | /** Time to Live */
|
---|
55 | uint8_t ttl;
|
---|
56 | /** Protocol */
|
---|
57 | uint8_t proto;
|
---|
58 | /** Header Checksum */
|
---|
59 | uint16_t chksum;
|
---|
60 | /** Source Address */
|
---|
61 | uint32_t src_addr;
|
---|
62 | /** Destination Address */
|
---|
63 | uint32_t dest_addr;
|
---|
64 | } ip_header_t;
|
---|
65 |
|
---|
66 | /** Bits in ip_header_t.ver_ihl */
|
---|
67 | enum ver_ihl_bits {
|
---|
68 | /** Version, highest bit */
|
---|
69 | VI_VERSION_h = 7,
|
---|
70 | /** Version, lowest bit */
|
---|
71 | VI_VERSION_l = 4,
|
---|
72 | /** Internet Header Length, highest bit */
|
---|
73 | VI_IHL_h = 3,
|
---|
74 | /** Internet Header Length, lowest bit */
|
---|
75 | VI_IHL_l = 0
|
---|
76 | };
|
---|
77 |
|
---|
78 | /** Bits in ip_header_t.flags_foff */
|
---|
79 | enum flags_foff_bits {
|
---|
80 | /** Reserved, must be zero */
|
---|
81 | FF_FLAG_RSVD = 15,
|
---|
82 | /** Don't Fragment */
|
---|
83 | FF_FLAG_DF = 14,
|
---|
84 | /** More Fragments */
|
---|
85 | FF_FLAG_MF = 13,
|
---|
86 | /** Fragment Offset, highest bit */
|
---|
87 | FF_FRAGOFF_h = 12,
|
---|
88 | /** Fragment Offset, lowest bit */
|
---|
89 | FF_FRAGOFF_l = 0
|
---|
90 | };
|
---|
91 |
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | /** @}
|
---|
95 | */
|
---|