6 #include "config-host.h"
7 #include "slirp_config.h"
10 # include <inttypes.h>
12 typedef uint8_t u_int8_t;
13 typedef uint16_t u_int16_t;
14 typedef uint32_t u_int32_t;
15 typedef uint64_t u_int64_t;
16 typedef char *caddr_t;
19 # include <winsock2.h>
20 # include <ws2tcpip.h>
21 # include <sys/timeb.h>
22 # include <iphlpapi.h>
24 # define EWOULDBLOCK WSAEWOULDBLOCK
25 # define EINPROGRESS WSAEINPROGRESS
26 # define ENOTCONN WSAENOTCONN
27 # define EHOSTUNREACH WSAEHOSTUNREACH
28 # define ENETUNREACH WSAENETUNREACH
29 # define ECONNREFUSED WSAECONNREFUSED
31 # define ioctlsocket ioctl
32 # define closesocket(s) close(s)
36 #include <sys/types.h>
37 #ifdef HAVE_SYS_BITYPES_H
38 # include <sys/bitypes.h>
45 typedef unsigned char u_int8_t;
47 # if SIZEOF_SHORT == 2
48 typedef short int16_t;
49 typedef unsigned short u_int16_t;
53 typedef unsigned int u_int16_t;
55 #error Cannot find a type with sizeof() == 2
59 # if SIZEOF_SHORT == 4
60 typedef short int32_t;
61 typedef unsigned short u_int32_t;
65 typedef unsigned int u_int32_t;
67 #error Cannot find a type with sizeof() == 4
70 #endif /* NEED_TYPEDEFS */
84 #define memmove(x, y, z) bcopy(y, x, z)
87 #if TIME_WITH_SYS_TIME
88 # include <sys/time.h>
91 # ifdef HAVE_SYS_TIME_H
92 # include <sys/time.h>
101 # include <strings.h>
109 #ifndef NO_PROTOTYPES
116 #include <netinet/in.h>
117 #include <arpa/inet.h>
120 #ifdef GETTIMEOFDAY_ONE_ARG
121 #define gettimeofday(x, y) gettimeofday(x)
124 /* Systems lacking strdup() definition in <string.h>. */
126 char *strdup _P((const char *));
129 /* Systems lacking malloc() definition in <stdlib.h>. */
130 #if defined(ultrix) || defined(hcx)
131 void *malloc _P((size_t arg));
132 void free _P((void *ptr));
135 #ifndef HAVE_INET_ATON
136 int inet_aton _P((const char *cp, struct in_addr *ia));
140 #ifndef NO_UNIX_SOCKETS
144 #ifdef HAVE_SYS_SIGNAL_H
145 # include <sys/signal.h>
148 #include <sys/socket.h>
151 #if defined(HAVE_SYS_IOCTL_H)
152 # include <sys/ioctl.h>
155 #ifdef HAVE_SYS_SELECT_H
156 # include <sys/select.h>
159 #ifdef HAVE_SYS_WAIT_H
160 # include <sys/wait.h>
163 #ifdef HAVE_SYS_FILIO_H
164 # include <sys/filio.h>
168 #include <ppp/slirppp.h>
177 #include <sys/stat.h>
179 /* Avoid conflicting with the libc insque() and remque(), which
180 have different prototypes. */
181 #define insque slirp_insque
182 #define remque slirp_remque
184 #ifdef HAVE_SYS_STROPTS_H
185 #include <sys/stropts.h>
192 #include "tcp_timer.h"
196 #include "icmp_var.h"
204 #include "ppp/pppd.h"
210 #include "libslirp.h"
213 #define NULL (void *)0
217 void if_start _P((void));
219 void if_start _P((struct ttys *));
223 # define vsprintf vsprintf_len
224 # define sprintf sprintf_len
225 extern int vsprintf_len _P((char *, const char *, va_list));
226 extern int sprintf_len _P((char *, const char *, ...));
229 #ifdef DECLARE_SPRINTF
231 extern int vsprintf _P((char *, const char *, va_list));
233 extern int vfprintf _P((FILE *, const char *, va_list));
236 #ifndef HAVE_STRERROR
237 extern char *strerror _P((int error));
241 char *index _P((const char *, int));
244 #ifndef HAVE_GETHOSTID
245 long gethostid _P((void));
248 void lprint _P((const char *, ...));
254 #define DEFAULT_BAUD 115200
256 #define SO_OPTIONS DO_KEEPALIVE
257 #define TCP_MAXIDLE (TCPTV_KEEPCNT * TCPTV_KEEPINTVL)
260 int cksum(struct mbuf *m, int len);
263 void if_init _P((void));
264 void if_output _P((struct socket *, struct mbuf *));
267 void ip_init _P((void));
268 void ip_input _P((struct mbuf *));
269 void ip_slowtimo _P((void));
270 void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
273 int ip_output _P((struct socket *, struct mbuf *));
276 void tcp_input _P((register struct mbuf *, int, struct socket *));
277 int tcp_mss _P((register struct tcpcb *, u_int));
280 int tcp_output _P((register struct tcpcb *));
281 void tcp_setpersist _P((register struct tcpcb *));
284 void tcp_init _P((void));
285 void tcp_template _P((struct tcpcb *));
286 void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
287 struct tcpcb * tcp_newtcpcb _P((struct socket *));
288 struct tcpcb * tcp_close _P((register struct tcpcb *));
289 void tcp_sockclosed _P((struct tcpcb *));
290 int tcp_fconnect _P((struct socket *));
291 void tcp_connect _P((struct socket *));
292 int tcp_attach _P((struct socket *));
293 u_int8_t tcp_tos _P((struct socket *));
294 int tcp_emu _P((struct socket *, struct mbuf *));
295 int tcp_ctl _P((struct socket *));
296 struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
299 #define MIN_MRU MINMRU
300 #define MAX_MRU MAXMRU
303 #define MAX_MRU 16384
307 #define min(x,y) ((x) < (y) ? (x) : (y))
308 #define max(x,y) ((x) > (y) ? (x) : (y))
313 #define errno (WSAGetLastError())