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;
22
typedef int socklen_t;
23
typedef unsigned long ioctlsockopt_t;
26
# include <winsock2.h>
27
# include <sys/timeb.h>
28
# include <iphlpapi.h>
30
# define USE_FIONBIO 1
31
# define EWOULDBLOCK WSAEWOULDBLOCK
32
# define EINPROGRESS WSAEINPROGRESS
33
# define ENOTCONN WSAENOTCONN
34
# define EHOSTUNREACH WSAEHOSTUNREACH
35
# define ENETUNREACH WSAENETUNREACH
36
# define ECONNREFUSED WSAECONNREFUSED
38
/* Basilisk II Router defines those */
39
# define udp_read_completion slirp_udp_read_completion
40
# define write_udp slirp_write_udp
41
# define init_udp slirp_init_udp
42
# define final_udp slirp_final_udp
44
typedef int ioctlsockopt_t;
45
# define ioctlsocket ioctl
46
# define closesocket(s) close(s)
50
#include <sys/types.h>
51
#ifdef HAVE_SYS_BITYPES_H
52
# include <sys/bitypes.h>
62
typedef unsigned char u_int8_t;
64
# if SIZEOF_SHORT == 2
65
typedef short int16_t;
66
typedef unsigned short u_int16_t;
70
typedef unsigned int u_int16_t;
72
#error Cannot find a type with sizeof() == 2
76
# if SIZEOF_SHORT == 4
77
typedef short int32_t;
78
typedef unsigned short u_int32_t;
82
typedef unsigned int u_int32_t;
84
#error Cannot find a type with sizeof() == 4
87
#endif /* NEED_TYPEDEFS */
89
/* Basilisk II types glue */
90
typedef u_int8_t uint8;
91
typedef u_int16_t uint16;
92
typedef u_int32_t uint32;
106
#define memmove(x, y, z) bcopy(y, x, z)
109
#if TIME_WITH_SYS_TIME
110
# include <sys/time.h>
114
# include <sys/time.h>
123
# include <strings.h>
131
#ifndef NO_PROTOTYPES
139
#include <netinet/in.h>
140
#include <arpa/inet.h>
143
#ifdef GETTIMEOFDAY_ONE_ARG
144
#define gettimeofday(x, y) gettimeofday(x)
147
/* Systems lacking strdup() definition in <string.h>. */
149
char *strdup _P((const char *));
152
/* Systems lacking malloc() definition in <stdlib.h>. */
153
#if defined(ultrix) || defined(hcx)
154
void *malloc _P((size_t arg));
155
void free _P((void *ptr));
158
#ifndef HAVE_INET_ATON
159
int inet_aton _P((const char *cp, struct in_addr *ia));
163
#ifndef NO_UNIX_SOCKETS
167
#ifdef HAVE_SYS_SIGNAL_H
168
# include <sys/signal.h>
171
#include <sys/socket.h>
174
#if defined(HAVE_SYS_IOCTL_H)
175
# include <sys/ioctl.h>
178
#ifdef HAVE_SYS_SELECT_H
179
# include <sys/select.h>
182
#ifdef HAVE_SYS_WAIT_H
183
# include <sys/wait.h>
186
#ifdef HAVE_SYS_FILIO_H
187
# include <sys/filio.h>
191
#include <ppp/slirppp.h>
200
#include <sys/stat.h>
202
/* Avoid conflicting with the libc insque() and remque(), which
203
have different prototypes. */
204
#define insque slirp_insque
205
#define remque slirp_remque
207
#ifdef HAVE_SYS_STROPTS_H
208
#include <sys/stropts.h>
214
#define PACKED__ __attribute__ ((packed))
216
#define PRAGMA_PACK_SUPPORTED 1
219
#error "Packed attribute or pragma shall be supported"
224
#include "tcp_timer.h"
228
#include "icmp_var.h"
237
#include "ppp/pppd.h"
243
#include "libslirp.h"
245
extern struct ttys *ttys_unit[MAX_INTERFACES];
248
#define NULL (void *)0
252
void if_start _P((void));
254
void if_start _P((struct ttys *));
258
# define vsprintf vsprintf_len
259
# define sprintf sprintf_len
260
extern int vsprintf_len _P((char *, const char *, va_list));
261
extern int sprintf_len _P((char *, const char *, ...));
264
#ifdef DECLARE_SPRINTF
266
extern int vsprintf _P((char *, const char *, va_list));
268
extern int vfprintf _P((FILE *, const char *, va_list));
271
#ifndef HAVE_STRERROR
272
extern char *strerror _P((int error));
276
char *index _P((const char *, int));
279
#ifndef HAVE_GETHOSTID
280
long gethostid _P((void));
283
void lprint _P((const char *, ...));
287
#if SIZEOF_CHAR_P == 4
288
# define insque_32 insque
289
# define remque_32 remque
291
inline void insque_32 _P((void *, void *));
292
inline void remque_32 _P((void *));
299
#define DEFAULT_BAUD 115200
302
int cksum(struct mbuf *m, int len);
305
void if_init _P((void));
306
void if_output _P((struct socket *, struct mbuf *));
309
void ip_init _P((void));
310
void ip_input _P((struct mbuf *));
311
struct ip * ip_reass _P((register struct ipasfrag *, register struct ipq *));
312
void ip_freef _P((struct ipq *));
313
void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
314
void ip_deq _P((register struct ipasfrag *));
315
void ip_slowtimo _P((void));
316
void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
319
int ip_output _P((struct socket *, struct mbuf *));
322
int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
323
void tcp_input _P((register struct mbuf *, int, struct socket *));
324
void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
325
void tcp_xmit_timer _P((register struct tcpcb *, int));
326
int tcp_mss _P((register struct tcpcb *, u_int));
329
int tcp_output _P((register struct tcpcb *));
330
void tcp_setpersist _P((register struct tcpcb *));
333
void tcp_init _P((void));
334
void tcp_template _P((struct tcpcb *));
335
void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
336
struct tcpcb * tcp_newtcpcb _P((struct socket *));
337
struct tcpcb * tcp_close _P((register struct tcpcb *));
338
void tcp_drain _P((void));
339
void tcp_sockclosed _P((struct tcpcb *));
340
int tcp_fconnect _P((struct socket *));
341
void tcp_connect _P((struct socket *));
342
int tcp_attach _P((struct socket *));
343
u_int8_t tcp_tos _P((struct socket *));
344
int tcp_emu _P((struct socket *, struct mbuf *));
345
int tcp_ctl _P((struct socket *));
346
struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
349
#define MIN_MRU MINMRU
350
#define MAX_MRU MAXMRU
353
#define MAX_MRU 16384
357
#define min(x,y) ((x) < (y) ? (x) : (y))
358
#define max(x,y) ((x) > (y) ? (x) : (y))
363
#define errno (WSAGetLastError())