VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/slirp/ip.h@ 15450

Last change on this file since 15450 was 15450, checked in by vboxsync, 16 years ago

slirp: style, dead code

  • Property svn:eol-style set to native
File size: 10.8 KB
Line 
1/*
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. 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 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)ip.h 8.1 (Berkeley) 6/10/93
34 * ip.h,v 1.3 1994/08/21 05:27:30 paul Exp
35 */
36
37#ifndef _IP_H_
38#define _IP_H_
39
40#ifdef VBOX_WITH_BSD_REASS
41# include "queue.h"
42#endif
43
44#ifdef WORDS_BIGENDIAN
45# ifndef NTOHL
46# define NTOHL(d)
47# endif
48# ifndef NTOHS
49# define NTOHS(d)
50# endif
51# ifndef HTONL
52# define HTONL(d)
53# endif
54# ifndef HTONS
55# define HTONS(d)
56# endif
57#else
58# ifndef NTOHL
59# define NTOHL(d) ((d) = ntohl((d)))
60# endif
61# ifndef NTOHS
62# define NTOHS(d) ((d) = ntohs((u_int16_t)(d)))
63# endif
64# ifndef HTONL
65# define HTONL(d) ((d) = htonl((d)))
66# endif
67# ifndef HTONS
68# define HTONS(d) ((d) = htons((u_int16_t)(d)))
69# endif
70#endif
71
72/*
73 * Definitions for internet protocol version 4.
74 * Per RFC 791, September 1981.
75 */
76#define IPVERSION 4
77
78/*
79 * Structure of an internet header, naked of options.
80 */
81struct ip
82{
83#ifdef WORDS_BIGENDIAN
84# ifdef _MSC_VER
85 uint8_t ip_v:4; /* version */
86 uint8_t ip_hl:4; /* header length */
87# else
88 unsigned ip_v:4; /* version */
89 unsigned ip_hl:4; /* header length */
90# endif
91#else
92# ifdef _MSC_VER
93 uint8_t ip_hl:4; /* header length */
94 uint8_t ip_v:4; /* version */
95# else
96 unsigned ip_hl:4; /* header length */
97 unsigned ip_v:4; /* version */
98# endif
99#endif
100 uint8_t ip_tos; /* type of service */
101 uint16_t ip_len; /* total length */
102 uint16_t ip_id; /* identification */
103 uint16_t ip_off; /* fragment offset field */
104#define IP_DF 0x4000 /* don't fragment flag */
105#define IP_MF 0x2000 /* more fragments flag */
106#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
107 uint8_t ip_ttl; /* time to live */
108 uint8_t ip_p; /* protocol */
109 uint16_t ip_sum; /* checksum */
110 struct in_addr ip_src; /* source address */
111 struct in_addr ip_dst; /* destination address */
112};
113AssertCompileSize(struct ip, 20);
114
115#define IP_MAXPACKET 65535 /* maximum packet size */
116
117/*
118 * Definitions for IP type of service (ip_tos)
119 */
120#define IPTOS_LOWDELAY 0x10
121#define IPTOS_THROUGHPUT 0x08
122#define IPTOS_RELIABILITY 0x04
123
124
125/*
126 * Time stamp option structure.
127 */
128struct ip_timestamp
129{
130 uint8_t ipt_code; /* IPOPT_TS */
131 uint8_t ipt_len; /* size of structure (variable) */
132 uint8_t ipt_ptr; /* index of current entry */
133#ifdef WORDS_BIGENDIAN
134# ifdef _MSC_VER
135 uint8_t ipt_oflw:4; /* overflow counter */
136 uint8_t ipt_flg:4; /* flags, see below */
137# else
138 unsigned ipt_oflw:4; /* overflow counter */
139 unsigned ipt_flg:4; /* flags, see below */
140# endif
141#else
142# ifdef _MSC_VER
143 uint8_t ipt_flg:4; /* flags, see below */
144 uint8_t ipt_oflw:4; /* overflow counter */
145# else
146 unsigned ipt_flg:4; /* flags, see below */
147 unsigned ipt_oflw:4; /* overflow counter */
148# endif
149#endif
150 union ipt_timestamp
151 {
152 uint32_t ipt_time[1];
153 struct ipt_ta
154 {
155 struct in_addr ipt_addr;
156 uint32_t ipt_time;
157 } ipt_ta[1];
158 } ipt_timestamp;
159};
160AssertCompileSize(struct ip_timestamp, 12);
161
162/*
163 * Internet implementation parameters.
164 */
165#define MAXTTL 255 /* maximum time to live (seconds) */
166#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
167#define IPFRAGTTL 60 /* time to live for frags, slowhz */
168#define IPTTLDEC 1 /* subtracted when forwarding */
169
170#define IP_MSS 576 /* default maximum segment size */
171
172#ifdef HAVE_SYS_TYPES32_H /* Overcome some Solaris 2.x junk */
173# include <sys/types32.h>
174#else
175# if SIZEOF_CHAR_P == 4
176typedef caddr_t caddr32_t;
177# else
178# if !defined(VBOX_WITH_BSD_REASS)
179typedef u_int32_t caddr32_t;
180# else /* VBOX_WITH_BSD_REASS */
181typedef caddr_t caddr32_t;
182# endif /* VBOX_WITH_BSD_REASS */
183# endif
184#endif
185
186#if SIZEOF_CHAR_P == 4
187typedef struct ipq_t *ipqp_32;
188typedef struct ipasfrag *ipasfragp_32;
189#else
190typedef caddr32_t ipqp_32;
191typedef caddr32_t ipasfragp_32;
192#endif
193
194/*
195 * Overlay for ip header used by other protocols (tcp, udp).
196 */
197struct ipovly
198{
199#if !defined(VBOX_WITH_BSD_REASS)
200 caddr32_t ih_next;
201 caddr32_t ih_prev; /* for protocol sequence q's */
202 u_int8_t ih_x1; /* (unused) */
203#else /* VBOX_WITH_BSD_REASS */
204 u_int8_t ih_x1[9]; /* (unused) */
205#endif /* VBOX_WITH_BSD_REASS */
206 u_int8_t ih_pr; /* protocol */
207 u_int16_t ih_len; /* protocol length */
208 struct in_addr ih_src; /* source internet address */
209 struct in_addr ih_dst; /* destination internet address */
210};
211AssertCompileSize(struct ipovly, 20);
212
213/*
214 * Ip reassembly queue structure. Each fragment being reassembled is
215 * attached to one of these structures. They are timed out after ipq_ttl
216 * drops to 0, and may also be reclaimed if memory becomes tight.
217 * size 28 bytes
218 */
219struct ipq_t
220{
221#ifndef VBOX_WITH_BSD_REASS
222 ipqp_32 next;
223 ipqp_32 prev; /* to other reass headers */
224#else /* VBOX_WITH_BSD_REASS */
225 TAILQ_ENTRY(ipq_t) ipq_list;
226#endif /* VBOX_WITH_BSD_REASS */
227 u_int8_t ipq_ttl; /* time for reass q to live */
228 u_int8_t ipq_p; /* protocol of this fragment */
229 u_int16_t ipq_id; /* sequence id for reassembly */
230#ifndef VBOX_WITH_BSD_REASS
231 ipasfragp_32 ipq_next;
232 ipasfragp_32 ipq_prev; /* to ip headers of fragments */
233#else /* VBOX_WITH_BSD_REASS */
234 struct mbuf *ipq_frags; /* to ip headers of fragments */
235 uint8_t ipq_nfrags; /* # of fragments in this packet */
236#endif /* VBOX_WITH_BSD_REASS */
237 struct in_addr ipq_src;
238 struct in_addr ipq_dst;
239};
240
241#ifdef VBOX_WITH_BSD_REASS
242
243/*
244* IP datagram reassembly.
245*/
246#define IPREASS_NHASH_LOG2 6
247#define IPREASS_NHASH (1 << IPREASS_NHASH_LOG2)
248#define IPREASS_HMASK (IPREASS_NHASH - 1)
249#define IPREASS_HASH(x,y) \
250(((((x) & 0xF) | ((((x) >> 8) & 0xF) << 4)) ^ (y)) & IPREASS_HMASK)
251TAILQ_HEAD(ipqhead,ipq_t);
252
253#else /* !VBOX_WITH_BSD_REASS */
254
255/*
256 * Ip header, when holding a fragment.
257 *
258 * Note: ipf_next must be at same offset as ipq_next above
259 */
260struct ipasfrag
261{
262#ifdef WORDS_BIGENDIAN
263# ifdef _MSC_VER
264 uint8_t ip_v:4;
265 uint8_t ip_hl:4;
266# else
267 unsigned ip_v:4;
268 unsigned ip_hl:4;
269# endif
270#else
271# ifdef _MSC_VER
272 uint8_t ip_hl:4;
273 uint8_t ip_v:4;
274# else
275 unsigned ip_hl:4;
276 unsigned ip_v:4;
277# endif
278#endif
279 u_int8_t ipf_mff; /* XXX overlays ip_tos: use low bit
280 * to avoid destroying tos (PPPDTRuu);
281 * copied from (ip_off & IP_MF) */
282 u_int16_t ip_len;
283 u_int16_t ip_id;
284 u_int16_t ip_off;
285 u_int8_t ip_ttl;
286 u_int8_t ip_p;
287 u_int16_t ip_sum;
288 ipasfragp_32 ipf_next; /* next fragment */
289 ipasfragp_32 ipf_prev; /* previous fragment */
290};
291AssertCompileSize(struct ipasfrag, 20);
292
293#endif /* !VBOX_WITH_BSD_REASS */
294
295/*
296 * Structure attached to inpcb.ip_moptions and
297 * passed to ip_output when IP multicast options are in use.
298 */
299
300struct ipstat_t
301{
302 u_long ips_total; /* total packets received */
303 u_long ips_badsum; /* checksum bad */
304 u_long ips_tooshort; /* packet too short */
305 u_long ips_toosmall; /* not enough data */
306 u_long ips_badhlen; /* ip header length < data size */
307 u_long ips_badlen; /* ip length < ip header length */
308 u_long ips_fragments; /* fragments received */
309 u_long ips_fragdropped; /* frags dropped (dups, out of space) */
310 u_long ips_fragtimeout; /* fragments timed out */
311 u_long ips_forward; /* packets forwarded */
312 u_long ips_cantforward; /* packets rcvd for unreachable dest */
313 u_long ips_redirectsent; /* packets forwarded on same net */
314 u_long ips_noproto; /* unknown or unsupported protocol */
315 u_long ips_delivered; /* datagrams delivered to upper level*/
316 u_long ips_localout; /* total ip packets generated here */
317 u_long ips_odropped; /* lost packets due to nobufs, etc. */
318 u_long ips_reassembled; /* total packets reassembled ok */
319 u_long ips_fragmented; /* datagrams successfully fragmented */
320 u_long ips_ofragments; /* output fragments created */
321 u_long ips_cantfrag; /* don't fragment flag was set, etc. */
322 u_long ips_badoptions; /* error in option processing */
323 u_long ips_noroute; /* packets discarded due to no route */
324 u_long ips_badvers; /* ip version != 4 */
325 u_long ips_rawout; /* total raw ip packets generated */
326 u_long ips_unaligned; /* times the ip packet was not aligned */
327};
328
329#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette