4 #include "config-host.h"
5 #include "slirp_config.h"
10 typedef uint8_t u_int8_t
;
11 typedef uint16_t u_int16_t
;
12 typedef uint32_t u_int32_t
;
13 typedef uint64_t u_int64_t
;
14 typedef char *caddr_t
;
17 # include <winsock2.h>
18 # include <ws2tcpip.h>
19 # include <sys/timeb.h>
20 # include <iphlpapi.h>
22 # define EWOULDBLOCK WSAEWOULDBLOCK
23 # define EINPROGRESS WSAEINPROGRESS
24 # define ENOTCONN WSAENOTCONN
25 # define EHOSTUNREACH WSAEHOSTUNREACH
26 # define ENETUNREACH WSAENETUNREACH
27 # define ECONNREFUSED WSAECONNREFUSED
29 # define ioctlsocket ioctl
30 # define closesocket(s) close(s)
34 #include <sys/types.h>
35 #ifdef HAVE_SYS_BITYPES_H
36 # include <sys/bitypes.h>
43 typedef unsigned char u_int8_t
;
45 # if SIZEOF_SHORT == 2
46 typedef short int16_t;
47 typedef unsigned short u_int16_t
;
51 typedef unsigned int u_int16_t
;
53 #error Cannot find a type with sizeof() == 2
57 # if SIZEOF_SHORT == 4
58 typedef short int32_t;
59 typedef unsigned short u_int32_t
;
63 typedef unsigned int u_int32_t
;
65 #error Cannot find a type with sizeof() == 4
68 #endif /* NEED_TYPEDEFS */
82 #define memmove(x, y, z) bcopy(y, x, z)
85 #if TIME_WITH_SYS_TIME
86 # include <sys/time.h>
89 # ifdef HAVE_SYS_TIME_H
90 # include <sys/time.h>
107 #ifndef NO_PROTOTYPES
114 #include <netinet/in.h>
115 #include <arpa/inet.h>
118 #ifdef GETTIMEOFDAY_ONE_ARG
119 #define gettimeofday(x, y) gettimeofday(x)
122 /* Systems lacking strdup() definition in <string.h>. */
124 char *strdup
_P((const char *));
127 /* Systems lacking malloc() definition in <stdlib.h>. */
128 #if defined(ultrix) || defined(hcx)
129 void *malloc
_P((size_t arg
));
130 void free
_P((void *ptr
));
133 #ifndef HAVE_INET_ATON
134 int inet_aton
_P((const char *cp
, struct in_addr
*ia
));
138 #ifndef NO_UNIX_SOCKETS
142 #ifdef HAVE_SYS_SIGNAL_H
143 # include <sys/signal.h>
146 #include <sys/socket.h>
149 #if defined(HAVE_SYS_IOCTL_H)
150 # include <sys/ioctl.h>
153 #ifdef HAVE_SYS_SELECT_H
154 # include <sys/select.h>
157 #ifdef HAVE_SYS_WAIT_H
158 # include <sys/wait.h>
161 #ifdef HAVE_SYS_FILIO_H
162 # include <sys/filio.h>
166 #include <ppp/slirppp.h>
175 #include <sys/stat.h>
177 /* Avoid conflicting with the libc insque() and remque(), which
178 have different prototypes. */
179 #define insque slirp_insque
180 #define remque slirp_remque
182 #ifdef HAVE_SYS_STROPTS_H
183 #include <sys/stropts.h>
188 #include "libslirp.h"
191 #include "tcp_timer.h"
202 #include "ppp/pppd.h"
210 /* virtual network configuration */
211 struct in_addr vnetwork_addr
;
212 struct in_addr vnetwork_mask
;
213 struct in_addr vhost_addr
;
214 struct in_addr vdhcp_startaddr
;
215 struct in_addr vnameserver_addr
;
217 /* ARP cache for the guest IP addresses (XXX: allow many entries) */
218 uint8_t client_ethaddr
[6];
220 struct in_addr client_ipaddr
;
221 char client_hostname
[33];
225 struct ex_list
*exec_list
;
228 struct mbuf m_freelist
, m_usedlist
;
232 int if_queued
; /* number of packets queued so far */
233 struct mbuf if_fastq
; /* fast queue (for interactive data) */
234 struct mbuf if_batchq
; /* queue for non-interactive data */
235 struct mbuf
*next_m
; /* pointer to next mbuf to output */
238 struct ipq ipq
; /* ip reass. queue */
239 u_int16_t ip_id
; /* ip packet ctr, for ids */
241 /* bootp/dhcp states */
242 BOOTPClient bootp_clients
[NB_BOOTP_CLIENTS
];
243 char *bootp_filename
;
247 struct socket
*tcp_last_so
;
248 tcp_seq tcp_iss
; /* tcp initial send seq # */
249 u_int32_t tcp_now
; /* for RFC 1323 timestamps */
253 struct socket
*udp_last_so
;
257 struct tftp_session tftp_sessions
[TFTP_SESSIONS_MAX
];
261 extern Slirp slirp_instance
;
264 #define NULL (void *)0
268 void if_start
_P((Slirp
*));
270 void if_start
_P((struct ttys
*));
274 # define vsprintf vsprintf_len
275 # define sprintf sprintf_len
276 extern int vsprintf_len
_P((char *, const char *, va_list));
277 extern int sprintf_len
_P((char *, const char *, ...));
280 #ifdef DECLARE_SPRINTF
282 extern int vsprintf
_P((char *, const char *, va_list));
284 extern int vfprintf
_P((FILE *, const char *, va_list));
287 #ifndef HAVE_STRERROR
288 extern char *strerror
_P((int error
));
292 char *index
_P((const char *, int));
295 #ifndef HAVE_GETHOSTID
296 long gethostid
_P((void));
299 void lprint
_P((const char *, ...));
305 #define DEFAULT_BAUD 115200
307 #define SO_OPTIONS DO_KEEPALIVE
308 #define TCP_MAXIDLE (TCPTV_KEEPCNT * TCPTV_KEEPINTVL)
311 int cksum(struct mbuf
*m
, int len
);
314 void if_init
_P((Slirp
*));
315 void if_output
_P((struct socket
*, struct mbuf
*));
318 void ip_init
_P((Slirp
*));
319 void ip_input
_P((struct mbuf
*));
320 void ip_slowtimo
_P((Slirp
*));
321 void ip_stripoptions
_P((register struct mbuf
*, struct mbuf
*));
324 int ip_output
_P((struct socket
*, struct mbuf
*));
327 void tcp_input
_P((register struct mbuf
*, int, struct socket
*));
328 int tcp_mss
_P((register struct tcpcb
*, u_int
));
331 int tcp_output
_P((register struct tcpcb
*));
332 void tcp_setpersist
_P((register struct tcpcb
*));
335 void tcp_init
_P((Slirp
*));
336 void tcp_template
_P((struct tcpcb
*));
337 void tcp_respond
_P((struct tcpcb
*, register struct tcpiphdr
*, register struct mbuf
*, tcp_seq
, tcp_seq
, int));
338 struct tcpcb
* tcp_newtcpcb
_P((struct socket
*));
339 struct tcpcb
* tcp_close
_P((register struct tcpcb
*));
340 void tcp_sockclosed
_P((struct tcpcb
*));
341 int tcp_fconnect
_P((struct socket
*));
342 void tcp_connect
_P((struct socket
*));
343 int tcp_attach
_P((struct socket
*));
344 u_int8_t tcp_tos
_P((struct socket
*));
345 int tcp_emu
_P((struct socket
*, struct mbuf
*));
346 int tcp_ctl
_P((struct socket
*));
347 struct tcpcb
*tcp_drop(struct tcpcb
*tp
, int err
);
350 #define MIN_MRU MINMRU
351 #define MAX_MRU MAXMRU
354 #define MAX_MRU 16384
358 #define min(x,y) ((x) < (y) ? (x) : (y))
359 #define max(x,y) ((x) > (y) ? (x) : (y))
364 #define errno (WSAGetLastError())