]>
Commit | Line | Data |
---|---|---|
f0cbd3ec FB |
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 | ||
379ff53d FB |
14 | #ifdef _WIN32 |
15 | # include <inttypes.h> | |
16 | ||
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 | ||
34444131 | 23 | # include <windows.h> |
379ff53d FB |
24 | # include <winsock2.h> |
25 | # include <sys/timeb.h> | |
26 | # include <iphlpapi.h> | |
27 | ||
28 | # define EWOULDBLOCK WSAEWOULDBLOCK | |
29 | # define EINPROGRESS WSAEINPROGRESS | |
30 | # define ENOTCONN WSAENOTCONN | |
31 | # define EHOSTUNREACH WSAEHOSTUNREACH | |
32 | # define ENETUNREACH WSAENETUNREACH | |
33 | # define ECONNREFUSED WSAECONNREFUSED | |
34 | #else | |
35 | # define ioctlsocket ioctl | |
36 | # define closesocket(s) close(s) | |
6d46bf8a | 37 | # define O_BINARY 0 |
379ff53d FB |
38 | #endif |
39 | ||
f0cbd3ec FB |
40 | #include <sys/types.h> |
41 | #ifdef HAVE_SYS_BITYPES_H | |
42 | # include <sys/bitypes.h> | |
43 | #endif | |
44 | ||
170c6f87 FB |
45 | #include <sys/time.h> |
46 | ||
f0cbd3ec FB |
47 | #ifdef NEED_TYPEDEFS |
48 | typedef char int8_t; | |
49 | typedef unsigned char u_int8_t; | |
50 | ||
51 | # if SIZEOF_SHORT == 2 | |
52 | typedef short int16_t; | |
53 | typedef unsigned short u_int16_t; | |
54 | # else | |
55 | # if SIZEOF_INT == 2 | |
56 | typedef int int16_t; | |
57 | typedef unsigned int u_int16_t; | |
58 | # else | |
59 | #error Cannot find a type with sizeof() == 2 | |
60 | # endif | |
61 | # endif | |
62 | ||
63 | # if SIZEOF_SHORT == 4 | |
64 | typedef short int32_t; | |
65 | typedef unsigned short u_int32_t; | |
66 | # else | |
67 | # if SIZEOF_INT == 4 | |
68 | typedef int int32_t; | |
69 | typedef unsigned int u_int32_t; | |
70 | # else | |
71 | #error Cannot find a type with sizeof() == 4 | |
72 | # endif | |
73 | # endif | |
74 | #endif /* NEED_TYPEDEFS */ | |
75 | ||
76 | #ifdef HAVE_UNISTD_H | |
77 | # include <unistd.h> | |
78 | #endif | |
79 | ||
80 | #ifdef HAVE_STDLIB_H | |
81 | # include <stdlib.h> | |
82 | #endif | |
83 | ||
84 | #include <stdio.h> | |
85 | #include <errno.h> | |
86 | ||
87 | #ifndef HAVE_MEMMOVE | |
88 | #define memmove(x, y, z) bcopy(y, x, z) | |
89 | #endif | |
90 | ||
91 | #if TIME_WITH_SYS_TIME | |
92 | # include <sys/time.h> | |
93 | # include <time.h> | |
94 | #else | |
95 | # if HAVE_SYS_TIME_H | |
96 | # include <sys/time.h> | |
97 | # else | |
98 | # include <time.h> | |
99 | # endif | |
100 | #endif | |
101 | ||
102 | #ifdef HAVE_STRING_H | |
103 | # include <string.h> | |
104 | #else | |
105 | # include <strings.h> | |
106 | #endif | |
107 | ||
379ff53d | 108 | #ifndef _WIN32 |
f0cbd3ec | 109 | #include <sys/uio.h> |
379ff53d | 110 | #endif |
f0cbd3ec FB |
111 | |
112 | #ifndef _P | |
113 | #ifndef NO_PROTOTYPES | |
114 | # define _P(x) x | |
115 | #else | |
116 | # define _P(x) () | |
117 | #endif | |
118 | #endif | |
119 | ||
379ff53d | 120 | #ifndef _WIN32 |
f0cbd3ec FB |
121 | #include <netinet/in.h> |
122 | #include <arpa/inet.h> | |
379ff53d | 123 | #endif |
f0cbd3ec FB |
124 | |
125 | #ifdef GETTIMEOFDAY_ONE_ARG | |
126 | #define gettimeofday(x, y) gettimeofday(x) | |
127 | #endif | |
128 | ||
129 | /* Systems lacking strdup() definition in <string.h>. */ | |
130 | #if defined(ultrix) | |
131 | char *strdup _P((const char *)); | |
132 | #endif | |
133 | ||
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)); | |
138 | #endif | |
139 | ||
140 | #ifndef HAVE_INET_ATON | |
141 | int inet_aton _P((const char *cp, struct in_addr *ia)); | |
142 | #endif | |
143 | ||
144 | #include <fcntl.h> | |
145 | #ifndef NO_UNIX_SOCKETS | |
146 | #include <sys/un.h> | |
147 | #endif | |
148 | #include <signal.h> | |
149 | #ifdef HAVE_SYS_SIGNAL_H | |
150 | # include <sys/signal.h> | |
151 | #endif | |
379ff53d | 152 | #ifndef _WIN32 |
f0cbd3ec | 153 | #include <sys/socket.h> |
379ff53d | 154 | #endif |
f0cbd3ec | 155 | |
ee2654ac | 156 | #if defined(HAVE_SYS_IOCTL_H) |
f0cbd3ec | 157 | # include <sys/ioctl.h> |
f0cbd3ec FB |
158 | #endif |
159 | ||
f0cbd3ec FB |
160 | #ifdef HAVE_SYS_SELECT_H |
161 | # include <sys/select.h> | |
162 | #endif | |
163 | ||
164 | #ifdef HAVE_SYS_WAIT_H | |
165 | # include <sys/wait.h> | |
166 | #endif | |
167 | ||
168 | #ifdef HAVE_SYS_FILIO_H | |
169 | # include <sys/filio.h> | |
170 | #endif | |
171 | ||
172 | #ifdef USE_PPP | |
173 | #include <ppp/slirppp.h> | |
174 | #endif | |
175 | ||
176 | #ifdef __STDC__ | |
177 | #include <stdarg.h> | |
178 | #else | |
179 | #include <varargs.h> | |
180 | #endif | |
181 | ||
182 | #include <sys/stat.h> | |
183 | ||
184 | /* Avoid conflicting with the libc insque() and remque(), which | |
185 | have different prototypes. */ | |
186 | #define insque slirp_insque | |
187 | #define remque slirp_remque | |
188 | ||
189 | #ifdef HAVE_SYS_STROPTS_H | |
190 | #include <sys/stropts.h> | |
191 | #endif | |
192 | ||
193 | #include "debug.h" | |
194 | ||
195 | #include "ip.h" | |
196 | #include "tcp.h" | |
197 | #include "tcp_timer.h" | |
198 | #include "tcp_var.h" | |
199 | #include "tcpip.h" | |
200 | #include "udp.h" | |
201 | #include "icmp_var.h" | |
202 | #include "mbuf.h" | |
203 | #include "sbuf.h" | |
204 | #include "socket.h" | |
205 | #include "if.h" | |
206 | #include "main.h" | |
207 | #include "misc.h" | |
208 | #include "ctl.h" | |
209 | #ifdef USE_PPP | |
210 | #include "ppp/pppd.h" | |
211 | #include "ppp/ppp.h" | |
212 | #endif | |
213 | ||
214 | #include "bootp.h" | |
c7f74643 | 215 | #include "tftp.h" |
f0cbd3ec FB |
216 | #include "libslirp.h" |
217 | ||
218 | extern struct ttys *ttys_unit[MAX_INTERFACES]; | |
219 | ||
220 | #ifndef NULL | |
221 | #define NULL (void *)0 | |
222 | #endif | |
223 | ||
224 | #ifndef FULL_BOLT | |
225 | void if_start _P((void)); | |
226 | #else | |
227 | void if_start _P((struct ttys *)); | |
228 | #endif | |
229 | ||
230 | #ifdef BAD_SPRINTF | |
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 *, ...)); | |
235 | #endif | |
236 | ||
237 | #ifdef DECLARE_SPRINTF | |
238 | # ifndef BAD_SPRINTF | |
239 | extern int vsprintf _P((char *, const char *, va_list)); | |
240 | # endif | |
241 | extern int vfprintf _P((FILE *, const char *, va_list)); | |
242 | #endif | |
243 | ||
244 | #ifndef HAVE_STRERROR | |
245 | extern char *strerror _P((int error)); | |
246 | #endif | |
247 | ||
248 | #ifndef HAVE_INDEX | |
249 | char *index _P((const char *, int)); | |
250 | #endif | |
251 | ||
252 | #ifndef HAVE_GETHOSTID | |
253 | long gethostid _P((void)); | |
254 | #endif | |
255 | ||
256 | void lprint _P((const char *, ...)); | |
257 | ||
258 | extern int do_echo; | |
259 | ||
260 | #if SIZEOF_CHAR_P == 4 | |
261 | # define insque_32 insque | |
262 | # define remque_32 remque | |
263 | #else | |
264 | inline void insque_32 _P((void *, void *)); | |
265 | inline void remque_32 _P((void *)); | |
266 | #endif | |
267 | ||
379ff53d | 268 | #ifndef _WIN32 |
f0cbd3ec | 269 | #include <netdb.h> |
379ff53d | 270 | #endif |
f0cbd3ec FB |
271 | |
272 | #define DEFAULT_BAUD 115200 | |
273 | ||
274 | /* cksum.c */ | |
275 | int cksum(struct mbuf *m, int len); | |
276 | ||
277 | /* if.c */ | |
278 | void if_init _P((void)); | |
279 | void if_output _P((struct socket *, struct mbuf *)); | |
280 | ||
281 | /* ip_input.c */ | |
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 *)); | |
290 | ||
291 | /* ip_output.c */ | |
292 | int ip_output _P((struct socket *, struct mbuf *)); | |
293 | ||
294 | /* tcp_input.c */ | |
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)); | |
300 | ||
301 | /* tcp_output.c */ | |
302 | int tcp_output _P((register struct tcpcb *)); | |
303 | void tcp_setpersist _P((register struct tcpcb *)); | |
304 | ||
305 | /* tcp_subr.c */ | |
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 *)); | |
9fafc9ea | 319 | struct tcpcb *tcp_drop(struct tcpcb *tp, int err); |
f0cbd3ec FB |
320 | |
321 | #ifdef USE_PPP | |
322 | #define MIN_MRU MINMRU | |
323 | #define MAX_MRU MAXMRU | |
324 | #else | |
325 | #define MIN_MRU 128 | |
326 | #define MAX_MRU 16384 | |
327 | #endif | |
328 | ||
379ff53d FB |
329 | #ifndef _WIN32 |
330 | #define min(x,y) ((x) < (y) ? (x) : (y)) | |
331 | #define max(x,y) ((x) > (y) ? (x) : (y)) | |
332 | #endif | |
333 | ||
02d2c54c | 334 | #ifdef _WIN32 |
ef6ff6b7 | 335 | #undef errno |
02d2c54c FB |
336 | #define errno (WSAGetLastError()) |
337 | #endif | |
338 | ||
f0cbd3ec | 339 | #endif |