12 #include "slirp_config.h"
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 <winsock2.h>
24 # include <sys/timeb.h>
25 # include <iphlpapi.h>
27 # define EWOULDBLOCK WSAEWOULDBLOCK
28 # define EINPROGRESS WSAEINPROGRESS
29 # define ENOTCONN WSAENOTCONN
30 # define EHOSTUNREACH WSAEHOSTUNREACH
31 # define ENETUNREACH WSAENETUNREACH
32 # define ECONNREFUSED WSAECONNREFUSED
34 # define ioctlsocket ioctl
35 # define closesocket(s) close(s)
38 #include <sys/types.h>
39 #ifdef HAVE_SYS_BITYPES_H
40 # include <sys/bitypes.h>
47 typedef unsigned char u_int8_t;
49 # if SIZEOF_SHORT == 2
50 typedef short int16_t;
51 typedef unsigned short u_int16_t;
55 typedef unsigned int u_int16_t;
57 #error Cannot find a type with sizeof() == 2
61 # if SIZEOF_SHORT == 4
62 typedef short int32_t;
63 typedef unsigned short u_int32_t;
67 typedef unsigned int u_int32_t;
69 #error Cannot find a type with sizeof() == 4
72 #endif /* NEED_TYPEDEFS */
86 #define memmove(x, y, z) bcopy(y, x, z)
89 #if TIME_WITH_SYS_TIME
90 # include <sys/time.h>
94 # include <sys/time.h>
103 # include <strings.h>
111 #ifndef NO_PROTOTYPES
119 #include <netinet/in.h>
120 #include <arpa/inet.h>
123 #ifdef GETTIMEOFDAY_ONE_ARG
124 #define gettimeofday(x, y) gettimeofday(x)
127 /* Systems lacking strdup() definition in <string.h>. */
129 char *strdup _P((const char *));
132 /* Systems lacking malloc() definition in <stdlib.h>. */
133 #if defined(ultrix) || defined(hcx)
134 void *malloc _P((size_t arg));
135 void free _P((void *ptr));
138 #ifndef HAVE_INET_ATON
139 int inet_aton _P((const char *cp, struct in_addr *ia));
143 #ifndef NO_UNIX_SOCKETS
147 #ifdef HAVE_SYS_SIGNAL_H
148 # include <sys/signal.h>
151 #include <sys/socket.h>
154 #if defined(HAVE_SYS_IOCTL_H)
155 # include <sys/ioctl.h>
158 #ifdef HAVE_SYS_SELECT_H
159 # include <sys/select.h>
162 #ifdef HAVE_SYS_WAIT_H
163 # include <sys/wait.h>
166 #ifdef HAVE_SYS_FILIO_H
167 # include <sys/filio.h>
171 #include <ppp/slirppp.h>
180 #include <sys/stat.h>
182 /* Avoid conflicting with the libc insque() and remque(), which
183 have different prototypes. */
184 #define insque slirp_insque
185 #define remque slirp_remque
187 #ifdef HAVE_SYS_STROPTS_H
188 #include <sys/stropts.h>
195 #include "tcp_timer.h"
199 #include "icmp_var.h"
208 #include "ppp/pppd.h"
213 #include "libslirp.h"
215 extern struct ttys *ttys_unit[MAX_INTERFACES];
218 #define NULL (void *)0
222 void if_start _P((void));
224 void if_start _P((struct ttys *));
228 # define vsprintf vsprintf_len
229 # define sprintf sprintf_len
230 extern int vsprintf_len _P((char *, const char *, va_list));
231 extern int sprintf_len _P((char *, const char *, ...));
234 #ifdef DECLARE_SPRINTF
236 extern int vsprintf _P((char *, const char *, va_list));
238 extern int vfprintf _P((FILE *, const char *, va_list));
241 #ifndef HAVE_STRERROR
242 extern char *strerror _P((int error));
246 char *index _P((const char *, int));
249 #ifndef HAVE_GETHOSTID
250 long gethostid _P((void));
253 void lprint _P((const char *, ...));
257 #if SIZEOF_CHAR_P == 4
258 # define insque_32 insque
259 # define remque_32 remque
261 inline void insque_32 _P((void *, void *));
262 inline void remque_32 _P((void *));
269 #define DEFAULT_BAUD 115200
272 int cksum(struct mbuf *m, int len);
275 void if_init _P((void));
276 void if_output _P((struct socket *, struct mbuf *));
279 void ip_init _P((void));
280 void ip_input _P((struct mbuf *));
281 struct ip * ip_reass _P((register struct ipasfrag *, register struct ipq *));
282 void ip_freef _P((struct ipq *));
283 void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
284 void ip_deq _P((register struct ipasfrag *));
285 void ip_slowtimo _P((void));
286 void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
289 int ip_output _P((struct socket *, struct mbuf *));
292 int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
293 void tcp_input _P((register struct mbuf *, int, struct socket *));
294 void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
295 void tcp_xmit_timer _P((register struct tcpcb *, int));
296 int tcp_mss _P((register struct tcpcb *, u_int));
299 int tcp_output _P((register struct tcpcb *));
300 void tcp_setpersist _P((register struct tcpcb *));
303 void tcp_init _P((void));
304 void tcp_template _P((struct tcpcb *));
305 void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
306 struct tcpcb * tcp_newtcpcb _P((struct socket *));
307 struct tcpcb * tcp_close _P((register struct tcpcb *));
308 void tcp_drain _P((void));
309 void tcp_sockclosed _P((struct tcpcb *));
310 int tcp_fconnect _P((struct socket *));
311 void tcp_connect _P((struct socket *));
312 int tcp_attach _P((struct socket *));
313 u_int8_t tcp_tos _P((struct socket *));
314 int tcp_emu _P((struct socket *, struct mbuf *));
315 int tcp_ctl _P((struct socket *));
316 struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
319 #define MIN_MRU MINMRU
320 #define MAX_MRU MAXMRU
323 #define MAX_MRU 16384
327 #define min(x,y) ((x) < (y) ? (x) : (y))
328 #define max(x,y) ((x) > (y) ? (x) : (y))