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
;
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
35 # define ioctlsocket ioctl
36 # define closesocket(s) close(s)
40 #include <sys/types.h>
41 #ifdef HAVE_SYS_BITYPES_H
42 # include <sys/bitypes.h>
49 typedef unsigned char u_int8_t
;
51 # if SIZEOF_SHORT == 2
52 typedef short int16_t;
53 typedef unsigned short u_int16_t
;
57 typedef unsigned int u_int16_t
;
59 #error Cannot find a type with sizeof() == 2
63 # if SIZEOF_SHORT == 4
64 typedef short int32_t;
65 typedef unsigned short u_int32_t
;
69 typedef unsigned int u_int32_t
;
71 #error Cannot find a type with sizeof() == 4
74 #endif /* NEED_TYPEDEFS */
88 #define memmove(x, y, z) bcopy(y, x, z)
91 #if TIME_WITH_SYS_TIME
92 # include <sys/time.h>
96 # include <sys/time.h>
105 # include <strings.h>
113 #ifndef NO_PROTOTYPES
121 #include <netinet/in.h>
122 #include <arpa/inet.h>
125 #ifdef GETTIMEOFDAY_ONE_ARG
126 #define gettimeofday(x, y) gettimeofday(x)
129 /* Systems lacking strdup() definition in <string.h>. */
131 char *strdup
_P((const char *));
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
));
140 #ifndef HAVE_INET_ATON
141 int inet_aton
_P((const char *cp
, struct in_addr
*ia
));
145 #ifndef NO_UNIX_SOCKETS
149 #ifdef HAVE_SYS_SIGNAL_H
150 # include <sys/signal.h>
153 #include <sys/socket.h>
156 #if defined(HAVE_SYS_IOCTL_H)
157 # include <sys/ioctl.h>
160 #ifdef HAVE_SYS_SELECT_H
161 # include <sys/select.h>
164 #ifdef HAVE_SYS_WAIT_H
165 # include <sys/wait.h>
168 #ifdef HAVE_SYS_FILIO_H
169 # include <sys/filio.h>
173 #include <ppp/slirppp.h>
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>
197 #include "tcp_timer.h"
201 #include "icmp_var.h"
210 #include "ppp/pppd.h"
216 #include "libslirp.h"
218 extern struct ttys
*ttys_unit
[MAX_INTERFACES
];
221 #define NULL (void *)0
225 void if_start
_P((void));
227 void if_start
_P((struct ttys
*));
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 *, ...));
237 #ifdef DECLARE_SPRINTF
239 extern int vsprintf
_P((char *, const char *, va_list));
241 extern int vfprintf
_P((FILE *, const char *, va_list));
244 #ifndef HAVE_STRERROR
245 extern char *strerror
_P((int error
));
249 char *index
_P((const char *, int));
252 #ifndef HAVE_GETHOSTID
253 long gethostid
_P((void));
256 void lprint
_P((const char *, ...));
260 #if SIZEOF_CHAR_P == 4
261 # define insque_32 insque
262 # define remque_32 remque
264 inline void insque_32
_P((void *, void *));
265 inline void remque_32
_P((void *));
272 #define DEFAULT_BAUD 115200
275 int cksum(struct mbuf
*m
, int len
);
278 void if_init
_P((void));
279 void if_output
_P((struct socket
*, struct mbuf
*));
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
*));
292 int ip_output
_P((struct socket
*, struct mbuf
*));
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
));
302 int tcp_output
_P((register struct tcpcb
*));
303 void tcp_setpersist
_P((register struct tcpcb
*));
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
);
322 #define MIN_MRU MINMRU
323 #define MAX_MRU MAXMRU
326 #define MAX_MRU 16384
330 #define min(x,y) ((x) < (y) ? (x) : (y))
331 #define max(x,y) ((x) > (y) ? (x) : (y))
336 #define errno (WSAGetLastError())