VirtualBox

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

最後變更 在這個檔案從15472是 15453,由 vboxsync 提交於 16 年 前

slirp: removed the old 64-bit incompatible reassemble code

  • 屬性 svn:eol-style 設為 native
檔案大小: 7.2 KB
 
1#ifndef __COMMON_H__
2#define __COMMON_H__
3
4#include <VBox/stam.h>
5
6#ifdef RT_OS_WINDOWS
7# include <winsock2.h>
8# include <ws2tcpip.h>
9typedef int socklen_t;
10#endif
11#ifdef RT_OS_OS2 /* temporary workaround, see ticket #127 */
12# define mbstat mbstat_os2
13# include <sys/socket.h>
14# undef mbstat
15typedef int socklen_t;
16#endif
17
18#define CONFIG_QEMU
19
20#ifdef DEBUG
21# undef DEBUG
22# define DEBUG 1
23#endif
24
25#ifndef CONFIG_QEMU
26# include "version.h"
27#endif
28#define LOG_GROUP LOG_GROUP_DRV_NAT
29#include <VBox/log.h>
30#ifdef VBOX_WITH_SLIRP_MEMORY_CHECK
31# define RTMEM_WRAP_TO_EF_APIS
32#endif /* VBOX_WITH_SLIRP_MEMORY_CHECK */
33#include <iprt/mem.h>
34#ifdef RT_OS_WINDOWS
35# include <windows.h>
36# include <io.h>
37#endif
38#include <iprt/assert.h>
39#include <iprt/string.h>
40#include <iprt/dir.h>
41#include <VBox/types.h>
42
43#define malloc(a) RTMemAlloc(a)
44#define free(a) RTMemFree(a)
45#define realloc(a,b) RTMemRealloc(a, b)
46
47#include "slirp_config.h"
48
49#ifdef RT_OS_WINDOWS
50
51# ifndef _MSC_VER
52# include <inttypes.h>
53# endif
54
55typedef uint8_t u_int8_t;
56typedef uint16_t u_int16_t;
57typedef uint32_t u_int32_t;
58typedef uint64_t u_int64_t;
59typedef char *caddr_t;
60
61# include <sys/timeb.h>
62# include <iphlpapi.h>
63
64# define EWOULDBLOCK WSAEWOULDBLOCK
65# define EINPROGRESS WSAEINPROGRESS
66# define ENOTCONN WSAENOTCONN
67# define EHOSTUNREACH WSAEHOSTUNREACH
68# define ENETUNREACH WSAENETUNREACH
69# define ECONNREFUSED WSAECONNREFUSED
70
71#else /* !RT_OS_WINDOWS */
72
73# define ioctlsocket ioctl
74# define closesocket(s) close(s)
75# define O_BINARY 0
76
77#endif /* !RT_OS_WINDOWS */
78
79#include <sys/types.h>
80#ifdef HAVE_SYS_BITYPES_H
81# include <sys/bitypes.h>
82#endif
83
84#ifdef _MSC_VER
85# include <time.h>
86#else /* !_MSC_VER */
87# include <sys/time.h>
88#endif /* !_MSC_VER */
89
90#ifdef NEED_TYPEDEFS
91typedef char int8_t;
92typedef unsigned char u_int8_t;
93
94# if SIZEOF_SHORT == 2
95 typedef short int16_t;
96 typedef unsigned short u_int16_t;
97# else
98# if SIZEOF_INT == 2
99 typedef int int16_t;
100 typedef unsigned int u_int16_t;
101# else
102 #error Cannot find a type with sizeof() == 2
103# endif
104# endif
105
106# if SIZEOF_SHORT == 4
107 typedef short int32_t;
108 typedef unsigned short u_int32_t;
109# else
110# if SIZEOF_INT == 4
111 typedef int int32_t;
112 typedef unsigned int u_int32_t;
113# else
114 #error Cannot find a type with sizeof() == 4
115# endif
116# endif
117#endif /* NEED_TYPEDEFS */
118
119#ifdef HAVE_UNISTD_H
120# include <unistd.h>
121#endif
122
123#ifdef HAVE_STDLIB_H
124# include <stdlib.h>
125#endif
126
127#include <stdio.h>
128#include <errno.h>
129
130#ifndef HAVE_MEMMOVE
131# define memmove(x, y, z) bcopy(y, x, z)
132#endif
133
134#if TIME_WITH_SYS_TIME
135# include <sys/time.h>
136# include <time.h>
137#else
138# if HAVE_SYS_TIME_H
139# include <sys/time.h>
140# else
141# include <time.h>
142# endif
143#endif
144
145#ifdef HAVE_STRING_H
146# include <string.h>
147#else
148# include <strings.h>
149#endif
150
151#ifndef RT_OS_WINDOWS
152# include <sys/uio.h>
153#endif
154
155#ifndef _P
156#ifndef NO_PROTOTYPES
157# define _P(x) x
158#else
159# define _P(x) ()
160#endif
161#endif
162
163#ifndef RT_OS_WINDOWS
164# include <netinet/in.h>
165# include <arpa/inet.h>
166#endif
167
168#ifdef GETTIMEOFDAY_ONE_ARG
169# define gettimeofday(x, y) gettimeofday(x)
170#endif
171
172/* Systems lacking strdup() definition in <string.h>. */
173#if defined(ultrix)
174char *strdup _P((const char *));
175#endif
176
177/* Systems lacking malloc() definition in <stdlib.h>. */
178#if defined(ultrix) || defined(hcx)
179void *malloc _P((size_t arg));
180void free _P((void *ptr));
181#endif
182
183#ifndef HAVE_INET_ATON
184int inet_aton _P((const char *cp, struct in_addr *ia));
185#endif
186
187#include <fcntl.h>
188#ifndef NO_UNIX_SOCKETS
189# include <sys/un.h>
190#endif
191#include <signal.h>
192#ifdef HAVE_SYS_SIGNAL_H
193# include <sys/signal.h>
194#endif
195#ifndef RT_OS_WINDOWS
196# include <sys/socket.h>
197#endif
198
199#if defined(HAVE_SYS_IOCTL_H)
200# include <sys/ioctl.h>
201#endif
202
203#ifdef HAVE_SYS_SELECT_H
204# include <sys/select.h>
205#endif
206
207#ifdef HAVE_SYS_WAIT_H
208# include <sys/wait.h>
209#endif
210
211#ifdef HAVE_SYS_FILIO_H
212# include <sys/filio.h>
213#endif
214
215#if defined(__STDC__) || defined(_MSC_VER)
216# include <stdarg.h>
217#else
218# include <varargs.h>
219#endif
220
221#include <sys/stat.h>
222
223/* Avoid conflicting with the libc insque() and remque(), which
224 * have different prototypes. */
225#define insque slirp_insque
226#define remque slirp_remque
227
228#ifdef HAVE_SYS_STROPTS_H
229# include <sys/stropts.h>
230#endif
231
232#include "libslirp.h"
233
234#include "debug.h"
235
236#include "ip.h"
237#include "tcp.h"
238#include "tcp_timer.h"
239#include "tcp_var.h"
240#include "tcpip.h"
241#include "udp.h"
242#include "icmp_var.h"
243#include "mbuf.h"
244#include "sbuf.h"
245#include "socket.h"
246#include "if.h"
247#include "main.h"
248#include "misc.h"
249#include "ctl.h"
250#include "bootp.h"
251#include "tftp.h"
252
253#include "slirp_state.h"
254
255#undef PVM /* XXX Mac OS X hack */
256
257#ifndef NULL
258# define NULL (void *)0
259#endif
260
261void if_start _P((PNATState));
262
263#ifndef HAVE_INDEX
264 char *index _P((const char *, int));
265#endif
266
267#ifndef HAVE_GETHOSTID
268 long gethostid _P((void));
269#endif
270
271#if SIZEOF_CHAR_P == 4
272# define insque_32 insque
273# define remque_32 remque
274#else
275extern void insque_32 _P((PNATState, void *, void *));
276extern void remque_32 _P((PNATState, void *));
277#endif
278
279#ifndef RT_OS_WINDOWS
280#include <netdb.h>
281#endif
282
283#define DEFAULT_BAUD 115200
284
285int get_dns_addr(PNATState pData, struct in_addr *pdns_addr);
286
287/* cksum.c */
288int cksum(struct mbuf *m, int len);
289
290/* if.c */
291void if_init _P((PNATState));
292void if_output _P((PNATState, struct socket *, struct mbuf *));
293
294/* ip_input.c */
295void ip_init _P((PNATState));
296void ip_input _P((PNATState, struct mbuf *));
297struct mbuf * ip_reass _P((PNATState, register struct mbuf *));
298void ip_freef _P((PNATState, struct ipqhead *, struct ipq_t *));
299void ip_slowtimo _P((PNATState));
300void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
301
302/* ip_output.c */
303int ip_output _P((PNATState, struct socket *, struct mbuf *));
304
305/* tcp_input.c */
306int tcp_reass _P((PNATState, struct tcpcb *, struct tcphdr *, int *, struct mbuf *));
307void tcp_input _P((PNATState, register struct mbuf *, int, struct socket *));
308void tcp_dooptions _P((PNATState, struct tcpcb *, u_char *, int, struct tcpiphdr *));
309void tcp_xmit_timer _P((PNATState, register struct tcpcb *, int));
310int tcp_mss _P((PNATState, register struct tcpcb *, u_int));
311
312/* tcp_output.c */
313int tcp_output _P((PNATState, register struct tcpcb *));
314void tcp_setpersist _P((register struct tcpcb *));
315
316/* tcp_subr.c */
317void tcp_init _P((PNATState));
318void tcp_template _P((struct tcpcb *));
319void tcp_respond _P((PNATState, struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
320struct tcpcb * tcp_newtcpcb _P((PNATState, struct socket *));
321struct tcpcb * tcp_close _P((PNATState, register struct tcpcb *));
322void tcp_drain _P((void));
323void tcp_sockclosed _P((PNATState, struct tcpcb *));
324int tcp_fconnect _P((PNATState, struct socket *));
325void tcp_connect _P((PNATState, struct socket *));
326int tcp_attach _P((PNATState, struct socket *));
327u_int8_t tcp_tos _P((struct socket *));
328int tcp_emu _P((PNATState, struct socket *, struct mbuf *));
329int tcp_ctl _P((PNATState, struct socket *));
330struct tcpcb *tcp_drop(PNATState, struct tcpcb *tp, int err);
331
332#define MIN_MRU 128
333#define MAX_MRU 16384
334
335#ifndef RT_OS_WINDOWS
336# define min(x,y) ((x) < (y) ? (x) : (y))
337# define max(x,y) ((x) > (y) ? (x) : (y))
338#endif
339
340#ifdef RT_OS_WINDOWS
341# undef errno
342# if 0 /* debugging */
343int errno_func(const char *file, int line);
344# define errno (errno_func(__FILE__, __LINE__))
345# else
346# define errno (WSAGetLastError())
347# endif
348#endif
349
350#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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