Fix typo in comment, by Andreas Faerber.
[qemu/dscho.git] / slirp / slirp.h
blob1ff68cb0b4969f68aeda9541e3d894ef40b4c5dd
1 #ifndef __COMMON_H__
2 #define __COMMON_H__
4 #define CONFIG_QEMU
6 #define DEBUG 1
8 #ifndef CONFIG_QEMU
9 #include "version.h"
10 #endif
11 #include "config.h"
12 #include "slirp_config.h"
14 #ifdef _WIN32
15 # include <inttypes.h>
17 typedef uint8_t u_int8_t;
18 typedef uint16_t u_int16_t;
19 typedef uint32_t u_int32_t;
20 typedef uint64_t u_int64_t;
21 typedef char *caddr_t;
23 # include <windows.h>
24 # include <winsock2.h>
25 # include <sys/timeb.h>
26 # include <iphlpapi.h>
28 # define EWOULDBLOCK WSAEWOULDBLOCK
29 # define EINPROGRESS WSAEINPROGRESS
30 # define ENOTCONN WSAENOTCONN
31 # define EHOSTUNREACH WSAEHOSTUNREACH
32 # define ENETUNREACH WSAENETUNREACH
33 # define ECONNREFUSED WSAECONNREFUSED
34 #else
35 # define ioctlsocket ioctl
36 # define closesocket(s) close(s)
37 # define O_BINARY 0
38 #endif
40 #include <sys/types.h>
41 #ifdef HAVE_SYS_BITYPES_H
42 # include <sys/bitypes.h>
43 #endif
45 #include <sys/time.h>
47 #ifdef NEED_TYPEDEFS
48 typedef char int8_t;
49 typedef unsigned char u_int8_t;
51 # if SIZEOF_SHORT == 2
52 typedef short int16_t;
53 typedef unsigned short u_int16_t;
54 # else
55 # if SIZEOF_INT == 2
56 typedef int int16_t;
57 typedef unsigned int u_int16_t;
58 # else
59 #error Cannot find a type with sizeof() == 2
60 # endif
61 # endif
63 # if SIZEOF_SHORT == 4
64 typedef short int32_t;
65 typedef unsigned short u_int32_t;
66 # else
67 # if SIZEOF_INT == 4
68 typedef int int32_t;
69 typedef unsigned int u_int32_t;
70 # else
71 #error Cannot find a type with sizeof() == 4
72 # endif
73 # endif
74 #endif /* NEED_TYPEDEFS */
76 #ifdef HAVE_UNISTD_H
77 # include <unistd.h>
78 #endif
80 #ifdef HAVE_STDLIB_H
81 # include <stdlib.h>
82 #endif
84 #include <stdio.h>
85 #include <errno.h>
87 #ifndef HAVE_MEMMOVE
88 #define memmove(x, y, z) bcopy(y, x, z)
89 #endif
91 #if TIME_WITH_SYS_TIME
92 # include <sys/time.h>
93 # include <time.h>
94 #else
95 # if HAVE_SYS_TIME_H
96 # include <sys/time.h>
97 # else
98 # include <time.h>
99 # endif
100 #endif
102 #ifdef HAVE_STRING_H
103 # include <string.h>
104 #else
105 # include <strings.h>
106 #endif
108 #ifndef _WIN32
109 #include <sys/uio.h>
110 #endif
112 #ifndef _P
113 #ifndef NO_PROTOTYPES
114 # define _P(x) x
115 #else
116 # define _P(x) ()
117 #endif
118 #endif
120 #ifndef _WIN32
121 #include <netinet/in.h>
122 #include <arpa/inet.h>
123 #endif
125 #ifdef GETTIMEOFDAY_ONE_ARG
126 #define gettimeofday(x, y) gettimeofday(x)
127 #endif
129 /* Systems lacking strdup() definition in <string.h>. */
130 #if defined(ultrix)
131 char *strdup _P((const char *));
132 #endif
134 /* Systems lacking malloc() definition in <stdlib.h>. */
135 #if defined(ultrix) || defined(hcx)
136 void *malloc _P((size_t arg));
137 void free _P((void *ptr));
138 #endif
140 #ifndef HAVE_INET_ATON
141 int inet_aton _P((const char *cp, struct in_addr *ia));
142 #endif
144 #include <fcntl.h>
145 #ifndef NO_UNIX_SOCKETS
146 #include <sys/un.h>
147 #endif
148 #include <signal.h>
149 #ifdef HAVE_SYS_SIGNAL_H
150 # include <sys/signal.h>
151 #endif
152 #ifndef _WIN32
153 #include <sys/socket.h>
154 #endif
156 #if defined(HAVE_SYS_IOCTL_H)
157 # include <sys/ioctl.h>
158 #endif
160 #ifdef HAVE_SYS_SELECT_H
161 # include <sys/select.h>
162 #endif
164 #ifdef HAVE_SYS_WAIT_H
165 # include <sys/wait.h>
166 #endif
168 #ifdef HAVE_SYS_FILIO_H
169 # include <sys/filio.h>
170 #endif
172 #ifdef USE_PPP
173 #include <ppp/slirppp.h>
174 #endif
176 #ifdef __STDC__
177 #include <stdarg.h>
178 #else
179 #include <varargs.h>
180 #endif
182 #include <sys/stat.h>
184 /* Avoid conflicting with the libc insque() and remque(), which
185 have different prototypes. */
186 #define insque slirp_insque
187 #define remque slirp_remque
189 #ifdef HAVE_SYS_STROPTS_H
190 #include <sys/stropts.h>
191 #endif
193 #include "debug.h"
195 #include "ip.h"
196 #include "tcp.h"
197 #include "tcp_timer.h"
198 #include "tcp_var.h"
199 #include "tcpip.h"
200 #include "udp.h"
201 #include "icmp_var.h"
202 #include "mbuf.h"
203 #include "sbuf.h"
204 #include "socket.h"
205 #include "if.h"
206 #include "main.h"
207 #include "misc.h"
208 #include "ctl.h"
209 #ifdef USE_PPP
210 #include "ppp/pppd.h"
211 #include "ppp/ppp.h"
212 #endif
214 #include "bootp.h"
215 #include "tftp.h"
216 #include "libslirp.h"
218 extern struct ttys *ttys_unit[MAX_INTERFACES];
220 #ifndef NULL
221 #define NULL (void *)0
222 #endif
224 #ifndef FULL_BOLT
225 void if_start _P((void));
226 #else
227 void if_start _P((struct ttys *));
228 #endif
230 #ifdef BAD_SPRINTF
231 # define vsprintf vsprintf_len
232 # define sprintf sprintf_len
233 extern int vsprintf_len _P((char *, const char *, va_list));
234 extern int sprintf_len _P((char *, const char *, ...));
235 #endif
237 #ifdef DECLARE_SPRINTF
238 # ifndef BAD_SPRINTF
239 extern int vsprintf _P((char *, const char *, va_list));
240 # endif
241 extern int vfprintf _P((FILE *, const char *, va_list));
242 #endif
244 #ifndef HAVE_STRERROR
245 extern char *strerror _P((int error));
246 #endif
248 #ifndef HAVE_INDEX
249 char *index _P((const char *, int));
250 #endif
252 #ifndef HAVE_GETHOSTID
253 long gethostid _P((void));
254 #endif
256 void lprint _P((const char *, ...));
258 extern int do_echo;
260 #if SIZEOF_CHAR_P == 4
261 # define insque_32 insque
262 # define remque_32 remque
263 #else
264 inline void insque_32 _P((void *, void *));
265 inline void remque_32 _P((void *));
266 #endif
268 #ifndef _WIN32
269 #include <netdb.h>
270 #endif
272 #define DEFAULT_BAUD 115200
274 /* cksum.c */
275 int cksum(struct mbuf *m, int len);
277 /* if.c */
278 void if_init _P((void));
279 void if_output _P((struct socket *, struct mbuf *));
281 /* ip_input.c */
282 void ip_init _P((void));
283 void ip_input _P((struct mbuf *));
284 struct ip * ip_reass _P((register struct ipasfrag *, register struct ipq *));
285 void ip_freef _P((struct ipq *));
286 void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
287 void ip_deq _P((register struct ipasfrag *));
288 void ip_slowtimo _P((void));
289 void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
291 /* ip_output.c */
292 int ip_output _P((struct socket *, struct mbuf *));
294 /* tcp_input.c */
295 int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
296 void tcp_input _P((register struct mbuf *, int, struct socket *));
297 void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
298 void tcp_xmit_timer _P((register struct tcpcb *, int));
299 int tcp_mss _P((register struct tcpcb *, u_int));
301 /* tcp_output.c */
302 int tcp_output _P((register struct tcpcb *));
303 void tcp_setpersist _P((register struct tcpcb *));
305 /* tcp_subr.c */
306 void tcp_init _P((void));
307 void tcp_template _P((struct tcpcb *));
308 void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
309 struct tcpcb * tcp_newtcpcb _P((struct socket *));
310 struct tcpcb * tcp_close _P((register struct tcpcb *));
311 void tcp_drain _P((void));
312 void tcp_sockclosed _P((struct tcpcb *));
313 int tcp_fconnect _P((struct socket *));
314 void tcp_connect _P((struct socket *));
315 int tcp_attach _P((struct socket *));
316 u_int8_t tcp_tos _P((struct socket *));
317 int tcp_emu _P((struct socket *, struct mbuf *));
318 int tcp_ctl _P((struct socket *));
319 struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
321 #ifdef USE_PPP
322 #define MIN_MRU MINMRU
323 #define MAX_MRU MAXMRU
324 #else
325 #define MIN_MRU 128
326 #define MAX_MRU 16384
327 #endif
329 #ifndef _WIN32
330 #define min(x,y) ((x) < (y) ? (x) : (y))
331 #define max(x,y) ((x) > (y) ? (x) : (y))
332 #endif
334 #ifdef _WIN32
335 #undef errno
336 #define errno (WSAGetLastError())
337 #endif
339 #endif