VirtualBox

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

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

Warnings

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

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