VirtualBox

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

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

NAT: introduced (port) service slection for correct bind operation.
some services require special value for source port.

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