VirtualBox

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

Last change on this file since 3021 was 1824, checked in by vboxsync, 18 years ago

Disable NAT UDP broadcast resend to local address. Removed the inline declarations and the useless _MSC_VER checks. And eliminated a few compiler warnings.

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