|
|
1.1 root 1: #ifndef __COMMON_H__
2: #define __COMMON_H__
3:
4: #define CONFIG_QEMU
5:
6: #define DEBUG 1
7:
8: #ifndef CONFIG_QEMU
9: #include "version.h"
10: #endif
11: #include "config.h"
12: #include "slirp_config.h"
13:
14: #ifdef _WIN32
1.1.1.2 ! root 15: #undef _WIN32_WINNT
! 16: #define _WIN32_WINNT 0x0501
1.1 root 17: # include <inttypes.h>
18:
19: typedef uint8_t u_int8_t;
20: typedef uint16_t u_int16_t;
21: typedef uint32_t u_int32_t;
22: typedef uint64_t u_int64_t;
23: typedef char *caddr_t;
24: typedef int socklen_t;
25: typedef unsigned long ioctlsockopt_t;
26:
27: # include <winsock2.h>
1.1.1.2 ! root 28: # include <WS2tcpip.h>
1.1 root 29: # include <sys/timeb.h>
30: # include <iphlpapi.h>
31:
32: # define USE_FIONBIO 1
33:
34: /* Basilisk II Router defines those */
35: # define udp_read_completion slirp_udp_read_completion
36: # define write_udp slirp_write_udp
37: # define init_udp slirp_init_udp
38: # define final_udp slirp_final_udp
39: #else
1.1.1.2 ! root 40: # define WSAGetLastError() (int)(errno)
! 41: # define WSASetLastError(e) (void)(errno = (e))
! 42: # define WSAEWOULDBLOCK EWOULDBLOCK
! 43: # define WSAEINPROGRESS EINPROGRESS
! 44: # define WSAENOTCONN ENOTCONN
! 45: # define WSAEHOSTUNREACH EHOSTUNREACH
! 46: # define WSAENETUNREACH ENETUNREACH
! 47: # define WSAECONNREFUSED ECONNREFUSED
1.1 root 48: typedef int ioctlsockopt_t;
49: # define ioctlsocket ioctl
50: # define closesocket(s) close(s)
51: # define O_BINARY 0
52: #endif
53:
54: #include <sys/types.h>
55: #ifdef HAVE_SYS_BITYPES_H
56: # include <sys/bitypes.h>
57: #endif
58: #ifdef HAVE_STDINT_H
59: # include <stdint.h>
60: #endif
61:
1.1.1.2 ! root 62: #ifndef _WIN32
1.1 root 63: #include <sys/time.h>
1.1.1.2 ! root 64: #endif
1.1 root 65:
66: #ifdef NEED_TYPEDEFS
67: typedef char int8_t;
68: typedef unsigned char u_int8_t;
69:
70: # if SIZEOF_SHORT == 2
71: typedef short int16_t;
72: typedef unsigned short u_int16_t;
73: # else
74: # if SIZEOF_INT == 2
75: typedef int int16_t;
76: typedef unsigned int u_int16_t;
77: # else
78: #error Cannot find a type with sizeof() == 2
79: # endif
80: # endif
81:
82: # if SIZEOF_SHORT == 4
83: typedef short int32_t;
84: typedef unsigned short u_int32_t;
85: # else
86: # if SIZEOF_INT == 4
87: typedef int int32_t;
88: typedef unsigned int u_int32_t;
89: # else
90: #error Cannot find a type with sizeof() == 4
91: # endif
92: # endif
93: #endif /* NEED_TYPEDEFS */
94:
95: /* Basilisk II types glue */
96: typedef u_int8_t uint8;
97: typedef u_int16_t uint16;
98: typedef u_int32_t uint32;
99:
100: #ifdef HAVE_UNISTD_H
101: # include <unistd.h>
102: #endif
103:
104: #ifdef HAVE_STDLIB_H
105: # include <stdlib.h>
106: #endif
107:
108: #include <stdio.h>
109: #include <errno.h>
110:
1.1.1.2 ! root 111: #ifndef SLIRP_HAVE_MEMMOVE
1.1 root 112: #define memmove(x, y, z) bcopy(y, x, z)
113: #endif
114:
115: #if TIME_WITH_SYS_TIME
116: # include <sys/time.h>
117: # include <time.h>
118: #else
119: # if HAVE_SYS_TIME_H
120: # include <sys/time.h>
121: # else
122: # include <time.h>
123: # endif
124: #endif
125:
126: #ifdef HAVE_STRING_H
127: # include <string.h>
128: #else
129: # include <strings.h>
130: #endif
131:
132: #ifndef _WIN32
133: #include <sys/uio.h>
134: #include <netinet/in.h>
135: #include <arpa/inet.h>
136: #endif
137:
138: #ifdef GETTIMEOFDAY_ONE_ARG
139: #define gettimeofday(x, y) gettimeofday(x)
140: #endif
141:
142: /* Systems lacking strdup() definition in <string.h>. */
143: #if defined(ultrix)
1.1.1.2 ! root 144: char *strdup(const char *);
1.1 root 145: #endif
146:
147: /* Systems lacking malloc() definition in <stdlib.h>. */
148: #if defined(ultrix) || defined(hcx)
1.1.1.2 ! root 149: void *malloc(size_t arg);
! 150: void free(void *ptr);
1.1 root 151: #endif
152:
153: #ifndef HAVE_INET_ATON
1.1.1.2 ! root 154: int inet_aton(const char *cp, struct in_addr *ia);
1.1 root 155: #endif
156:
157: #include <fcntl.h>
1.1.1.2 ! root 158: #ifdef _WIN32
! 159: #include <io.h>
! 160: #endif
1.1 root 161: #ifndef NO_UNIX_SOCKETS
162: #include <sys/un.h>
163: #endif
164: #include <signal.h>
165: #ifdef HAVE_SYS_SIGNAL_H
166: # include <sys/signal.h>
167: #endif
168: #ifndef _WIN32
169: #include <sys/socket.h>
170: #endif
171:
172: #if defined(HAVE_SYS_IOCTL_H)
173: # include <sys/ioctl.h>
174: #endif
175:
176: #ifdef HAVE_SYS_SELECT_H
177: # include <sys/select.h>
178: #endif
179:
180: #ifdef HAVE_SYS_WAIT_H
181: # include <sys/wait.h>
182: #endif
183:
184: #ifdef HAVE_SYS_FILIO_H
185: # include <sys/filio.h>
186: #endif
187:
188: #ifdef USE_PPP
189: #include <ppp/slirppp.h>
190: #endif
191:
192: #include <stdarg.h>
193:
194: #include <sys/stat.h>
195:
196: /* Avoid conflicting with the libc insque() and remque(), which
197: have different prototypes. */
198: #define insque slirp_insque
199: #define remque slirp_remque
200:
201: #ifdef HAVE_SYS_STROPTS_H
202: #include <sys/stropts.h>
203: #endif
204:
205: #include "slirpdebug.h"
206:
207: #if defined __GNUC__
208: #define PACKED__ __attribute__ ((packed))
1.1.1.2 ! root 209: #elif defined _MSC_VER
! 210: #define PRAGMA_PACK_SUPPORTED 1
! 211: #define PACK_RESET
! 212: #define PACKED__
1.1 root 213: #elif defined __sgi
214: #define PRAGMA_PACK_SUPPORTED 1
1.1.1.2 ! root 215: #define PACK_RESET 0
1.1 root 216: #define PACKED__
217: #else
218: #error "Packed attribute or pragma shall be supported"
219: #endif
220:
221: #include "ip.h"
222: #include "tcp.h"
223: #include "tcp_timer.h"
224: #include "tcp_var.h"
225: #include "tcpip.h"
226: #include "udp.h"
227: #include "icmp_var.h"
228: #include "mbuf.h"
229: #include "sbuf.h"
230: #include "socket.h"
231: #include "if.h"
232: #include "slirpmain.h"
233: #include "misc.h"
234: #include "ctl.h"
235: #ifdef USE_PPP
236: #include "ppp/pppd.h"
237: #include "ppp/ppp.h"
238: #endif
239:
240: #include "bootp.h"
241: #include "tftp.h"
242: #include "libslirp.h"
243:
244: extern struct ttys *ttys_unit[MAX_INTERFACES];
245:
246: #ifndef NULL
247: #define NULL (void *)0
248: #endif
249:
250: #ifndef FULL_BOLT
1.1.1.2 ! root 251: void if_start(void);
1.1 root 252: #else
1.1.1.2 ! root 253: void if_start(struct ttys *);
1.1 root 254: #endif
255:
256: #ifdef BAD_SPRINTF
257: # define vsprintf vsprintf_len
258: # define sprintf sprintf_len
1.1.1.2 ! root 259: extern int vsprintf_len(char *, const char *, va_list);
! 260: extern int sprintf_len(char *, const char *, ...);
1.1 root 261: #endif
262:
263: #ifdef DECLARE_SPRINTF
264: # ifndef BAD_SPRINTF
1.1.1.2 ! root 265: extern int vsprintf(char *, const char *, va_list);
1.1 root 266: # endif
1.1.1.2 ! root 267: extern int vfprintf(FILE *, const char *, va_list);
1.1 root 268: #endif
269:
270: #ifndef HAVE_STRERROR
1.1.1.2 ! root 271: extern char *strerror(int error);
1.1 root 272: #endif
273:
274: #ifndef HAVE_INDEX
1.1.1.2 ! root 275: char *index(const char *, int);
1.1 root 276: #endif
277:
278: #ifndef HAVE_GETHOSTID
1.1.1.2 ! root 279: long gethostid(void);
1.1 root 280: #endif
281:
1.1.1.2 ! root 282: void lprint(const char *, ...);
1.1 root 283:
284: extern int do_echo;
285:
286: #ifndef _WIN32
287: #include <netdb.h>
288: #endif
289:
290: #define DEFAULT_BAUD 115200
291:
292: /* cksum.c */
293: int cksum(struct mbuf *m, int len);
294:
295: /* if.c */
1.1.1.2 ! root 296: void if_init(void);
! 297: void if_output(struct socket *, struct mbuf *);
1.1 root 298:
299: /* ip_input.c */
1.1.1.2 ! root 300: void ip_init(void);
! 301: void ip_input(struct mbuf *);
! 302: struct ip * ip_reass(register struct ip *ip, register struct ipq *);
! 303: void ip_freef(struct ipq *);
! 304: void ip_enq(register struct ipasfrag *, register struct ipasfrag *);
! 305: void ip_deq(register struct ipasfrag *);
! 306: void ip_slowtimo(void);
! 307: void ip_stripoptions(register struct mbuf *, struct mbuf *);
1.1 root 308:
309: /* ip_output.c */
1.1.1.2 ! root 310: int ip_output(struct socket *, struct mbuf *);
1.1 root 311:
312: /* tcp_input.c */
1.1.1.2 ! root 313: int tcp_reass(register struct tcpcb *, register struct tcpiphdr *, struct mbuf *);
! 314: void tcp_input(register struct mbuf *, int, struct socket *);
! 315: void tcp_dooptions(struct tcpcb *, u_char *, int, struct tcpiphdr *);
! 316: void tcp_xmit_timer(register struct tcpcb *, int);
! 317: u_int tcp_mss(register struct tcpcb *, u_int);
1.1 root 318:
319: /* tcp_output.c */
1.1.1.2 ! root 320: int tcp_output(register struct tcpcb *);
! 321: void tcp_setpersist(register struct tcpcb *);
1.1 root 322:
323: /* tcp_subr.c */
1.1.1.2 ! root 324: void tcp_init(void);
! 325: void tcp_template(struct tcpcb *);
! 326: void tcp_respond(struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int);
! 327: struct tcpcb * tcp_newtcpcb(struct socket *);
! 328: struct tcpcb * tcp_close(register struct tcpcb *);
! 329: void tcp_drain(void);
! 330: void tcp_sockclosed(struct tcpcb *);
! 331: int tcp_fconnect(struct socket *);
! 332: void tcp_connect(struct socket *);
! 333: int tcp_attach(struct socket *);
! 334: u_int8_t tcp_tos(struct socket *);
! 335: int tcp_emu(struct socket *, struct mbuf *);
! 336: int tcp_ctl(struct socket *);
1.1 root 337: struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
338:
339: #ifdef USE_PPP
340: #define MIN_MRU MINMRU
341: #define MAX_MRU MAXMRU
342: #else
343: #define MIN_MRU 128
344: #define MAX_MRU 16384
345: #endif
346:
347: #ifndef _WIN32
348: #define min(x,y) ((x) < (y) ? (x) : (y))
349: #define max(x,y) ((x) > (y) ? (x) : (y))
350: #endif
351:
352: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.