4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * Copyright (c) 1982, 1986, 1990, 1993
36 * The Regents of the University of California. All rights reserved.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * @(#)in.h 8.3 (Berkeley) 1/3/94
67 * $FreeBSD: src/sys/netinet/in.h,v 1.82 2003/10/25 09:37:10 ume Exp $
89 uint8_t version_ihl; /**< version and header length */
90 uint8_t type_of_service; /**< type of service */
91 uint16_t total_length; /**< length of packet */
92 uint16_t packet_id; /**< packet ID */
93 uint16_t fragment_offset; /**< fragmentation offset */
94 uint8_t time_to_live; /**< time to live */
95 uint8_t next_proto_id; /**< protocol ID */
96 uint16_t hdr_checksum; /**< header checksum */
97 uint32_t src_addr; /**< source address */
98 uint32_t dst_addr; /**< destination address */
99 } __attribute__((__packed__));
101 /** Create IPv4 address */
102 #define IPv4(a,b,c,d) ((uint32_t)(((a) & 0xff) << 24) | \
103 (((b) & 0xff) << 16) | \
104 (((c) & 0xff) << 8) | \
107 /* Fragment Offset * Flags. */
108 #define IPV4_HDR_DF_SHIFT 14
109 #define IPV4_HDR_MF_SHIFT 13
110 #define IPV4_HDR_FO_SHIFT 3
112 #define IPV4_HDR_DF_FLAG (1 << IPV4_HDR_DF_SHIFT)
113 #define IPV4_HDR_MF_FLAG (1 << IPV4_HDR_MF_SHIFT)
115 #define IPV4_HDR_OFFSET_MASK ((1 << IPV4_HDR_MF_SHIFT) - 1)
117 #define IPV4_HDR_OFFSET_UNITS 8
120 #define IPPROTO_IP 0 /**< dummy for IP */
121 #define IPPROTO_HOPOPTS 0 /**< IP6 hop-by-hop options */
122 #define IPPROTO_ICMP 1 /**< control message protocol */
123 #define IPPROTO_IGMP 2 /**< group mgmt protocol */
124 #define IPPROTO_GGP 3 /**< gateway^2 (deprecated) */
125 #define IPPROTO_IPV4 4 /**< IPv4 encapsulation */
126 #define IPPROTO_TCP 6 /**< tcp */
127 #define IPPROTO_ST 7 /**< Stream protocol II */
128 #define IPPROTO_EGP 8 /**< exterior gateway protocol */
129 #define IPPROTO_PIGP 9 /**< private interior gateway */
130 #define IPPROTO_RCCMON 10 /**< BBN RCC Monitoring */
131 #define IPPROTO_NVPII 11 /**< network voice protocol*/
132 #define IPPROTO_PUP 12 /**< pup */
133 #define IPPROTO_ARGUS 13 /**< Argus */
134 #define IPPROTO_EMCON 14 /**< EMCON */
135 #define IPPROTO_XNET 15 /**< Cross Net Debugger */
136 #define IPPROTO_CHAOS 16 /**< Chaos*/
137 #define IPPROTO_UDP 17 /**< user datagram protocol */
138 #define IPPROTO_MUX 18 /**< Multiplexing */
139 #define IPPROTO_MEAS 19 /**< DCN Measurement Subsystems */
140 #define IPPROTO_HMP 20 /**< Host Monitoring */
141 #define IPPROTO_PRM 21 /**< Packet Radio Measurement */
142 #define IPPROTO_IDP 22 /**< xns idp */
143 #define IPPROTO_TRUNK1 23 /**< Trunk-1 */
144 #define IPPROTO_TRUNK2 24 /**< Trunk-2 */
145 #define IPPROTO_LEAF1 25 /**< Leaf-1 */
146 #define IPPROTO_LEAF2 26 /**< Leaf-2 */
147 #define IPPROTO_RDP 27 /**< Reliable Data */
148 #define IPPROTO_IRTP 28 /**< Reliable Transaction */
149 #define IPPROTO_TP 29 /**< tp-4 w/ class negotiation */
150 #define IPPROTO_BLT 30 /**< Bulk Data Transfer */
151 #define IPPROTO_NSP 31 /**< Network Services */
152 #define IPPROTO_INP 32 /**< Merit Internodal */
153 #define IPPROTO_SEP 33 /**< Sequential Exchange */
154 #define IPPROTO_3PC 34 /**< Third Party Connect */
155 #define IPPROTO_IDPR 35 /**< InterDomain Policy Routing */
156 #define IPPROTO_XTP 36 /**< XTP */
157 #define IPPROTO_DDP 37 /**< Datagram Delivery */
158 #define IPPROTO_CMTP 38 /**< Control Message Transport */
159 #define IPPROTO_TPXX 39 /**< TP++ Transport */
160 #define IPPROTO_IL 40 /**< IL transport protocol */
161 #define IPPROTO_IPV6 41 /**< IP6 header */
162 #define IPPROTO_SDRP 42 /**< Source Demand Routing */
163 #define IPPROTO_ROUTING 43 /**< IP6 routing header */
164 #define IPPROTO_FRAGMENT 44 /**< IP6 fragmentation header */
165 #define IPPROTO_IDRP 45 /**< InterDomain Routing*/
166 #define IPPROTO_RSVP 46 /**< resource reservation */
167 #define IPPROTO_GRE 47 /**< General Routing Encap. */
168 #define IPPROTO_MHRP 48 /**< Mobile Host Routing */
169 #define IPPROTO_BHA 49 /**< BHA */
170 #define IPPROTO_ESP 50 /**< IP6 Encap Sec. Payload */
171 #define IPPROTO_AH 51 /**< IP6 Auth Header */
172 #define IPPROTO_INLSP 52 /**< Integ. Net Layer Security */
173 #define IPPROTO_SWIPE 53 /**< IP with encryption */
174 #define IPPROTO_NHRP 54 /**< Next Hop Resolution */
175 /* 55-57: Unassigned */
176 #define IPPROTO_ICMPV6 58 /**< ICMP6 */
177 #define IPPROTO_NONE 59 /**< IP6 no next header */
178 #define IPPROTO_DSTOPTS 60 /**< IP6 destination option */
179 #define IPPROTO_AHIP 61 /**< any host internal protocol */
180 #define IPPROTO_CFTP 62 /**< CFTP */
181 #define IPPROTO_HELLO 63 /**< "hello" routing protocol */
182 #define IPPROTO_SATEXPAK 64 /**< SATNET/Backroom EXPAK */
183 #define IPPROTO_KRYPTOLAN 65 /**< Kryptolan */
184 #define IPPROTO_RVD 66 /**< Remote Virtual Disk */
185 #define IPPROTO_IPPC 67 /**< Pluribus Packet Core */
186 #define IPPROTO_ADFS 68 /**< Any distributed FS */
187 #define IPPROTO_SATMON 69 /**< Satnet Monitoring */
188 #define IPPROTO_VISA 70 /**< VISA Protocol */
189 #define IPPROTO_IPCV 71 /**< Packet Core Utility */
190 #define IPPROTO_CPNX 72 /**< Comp. Prot. Net. Executive */
191 #define IPPROTO_CPHB 73 /**< Comp. Prot. HeartBeat */
192 #define IPPROTO_WSN 74 /**< Wang Span Network */
193 #define IPPROTO_PVP 75 /**< Packet Video Protocol */
194 #define IPPROTO_BRSATMON 76 /**< BackRoom SATNET Monitoring */
195 #define IPPROTO_ND 77 /**< Sun net disk proto (temp.) */
196 #define IPPROTO_WBMON 78 /**< WIDEBAND Monitoring */
197 #define IPPROTO_WBEXPAK 79 /**< WIDEBAND EXPAK */
198 #define IPPROTO_EON 80 /**< ISO cnlp */
199 #define IPPROTO_VMTP 81 /**< VMTP */
200 #define IPPROTO_SVMTP 82 /**< Secure VMTP */
201 #define IPPROTO_VINES 83 /**< Banyon VINES */
202 #define IPPROTO_TTP 84 /**< TTP */
203 #define IPPROTO_IGP 85 /**< NSFNET-IGP */
204 #define IPPROTO_DGP 86 /**< dissimilar gateway prot. */
205 #define IPPROTO_TCF 87 /**< TCF */
206 #define IPPROTO_IGRP 88 /**< Cisco/GXS IGRP */
207 #define IPPROTO_OSPFIGP 89 /**< OSPFIGP */
208 #define IPPROTO_SRPC 90 /**< Strite RPC protocol */
209 #define IPPROTO_LARP 91 /**< Locus Address Resoloution */
210 #define IPPROTO_MTP 92 /**< Multicast Transport */
211 #define IPPROTO_AX25 93 /**< AX.25 Frames */
212 #define IPPROTO_IPEIP 94 /**< IP encapsulated in IP */
213 #define IPPROTO_MICP 95 /**< Mobile Int.ing control */
214 #define IPPROTO_SCCSP 96 /**< Semaphore Comm. security */
215 #define IPPROTO_ETHERIP 97 /**< Ethernet IP encapsulation */
216 #define IPPROTO_ENCAP 98 /**< encapsulation header */
217 #define IPPROTO_APES 99 /**< any private encr. scheme */
218 #define IPPROTO_GMTP 100 /**< GMTP */
219 #define IPPROTO_IPCOMP 108 /**< payload compression (IPComp) */
220 /* 101-254: Partly Unassigned */
221 #define IPPROTO_PIM 103 /**< Protocol Independent Mcast */
222 #define IPPROTO_PGM 113 /**< PGM */
223 #define IPPROTO_SCTP 132 /**< Stream Control Transport Protocol */
225 /* BSD Private, local use, namespace incursion */
226 #define IPPROTO_DIVERT 254 /**< divert pseudo-protocol */
227 #define IPPROTO_RAW 255 /**< raw IP packet */
228 #define IPPROTO_MAX 256 /**< maximum protocol number */
233 #define IPV4_ANY ((uint32_t)0x00000000) /**< 0.0.0.0 */
234 #define IPV4_LOOPBACK ((uint32_t)0x7f000001) /**< 127.0.0.1 */
235 #define IPV4_BROADCAST ((uint32_t)0xe0000000) /**< 224.0.0.0 */
236 #define IPV4_ALLHOSTS_GROUP ((uint32_t)0xe0000001) /**< 224.0.0.1 */
237 #define IPV4_ALLRTRS_GROUP ((uint32_t)0xe0000002) /**< 224.0.0.2 */
238 #define IPV4_MAX_LOCAL_GROUP ((uint32_t)0xe00000ff) /**< 224.0.0.255 */
241 * IPv4 Multicast-related macros
243 #define IPV4_MIN_MCAST IPv4(224, 0, 0, 0) /**< Minimal IPv4-multicast address */
244 #define IPV4_MAX_MCAST IPv4(239, 255, 255, 255) /**< Maximum IPv4 multicast address */
246 #define IS_IPV4_MCAST(x) \
247 ((x) >= IPV4_MIN_MCAST && (x) <= IPV4_MAX_MCAST) /**< check if IPv4 address is multicast */
253 uint32_t vtc_flow; /**< IP version, traffic class & flow label. */
254 uint16_t payload_len; /**< IP packet length - includes sizeof(ip_header). */
255 uint8_t proto; /**< Protocol, next header. */
256 uint8_t hop_limits; /**< Hop limits. */
257 uint8_t src_addr[16]; /**< IP address of source host. */
258 uint8_t dst_addr[16]; /**< IP address of destination host(s). */
259 } __attribute__((__packed__));
265 #endif /* _RTE_IP_H_ */