ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/slirp/slirp.h
Revision: 1.4
Committed: 2005-12-30T01:19:53Z (18 years, 5 months ago) by nigel
Content type: text/plain
Branch: MAIN
CVS Tags: nigel-build-17
Changes since 1.3: +3 -0 lines
Log Message:
Compiling on Mac OS X 10.2 doesn't define uint8_t using the standard headers.
Including stdint.h should be safe, but if it clashes, we could put an OS X
specific wrapper around it: #if (defined(__MACH__) && defined(__APPLE__))

File Contents

# Content
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
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
23 # include <windows.h>
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)
37 # define O_BINARY 0
38 #endif
39
40 #include <sys/types.h>
41 #ifdef HAVE_SYS_BITYPES_H
42 # include <sys/bitypes.h>
43 #endif
44 #ifdef HAVE_STDINT_H
45 # include <stdint.h>
46 #endif
47
48 #include <sys/time.h>
49
50 #ifdef NEED_TYPEDEFS
51 typedef char int8_t;
52 typedef unsigned char u_int8_t;
53
54 # if SIZEOF_SHORT == 2
55 typedef short int16_t;
56 typedef unsigned short u_int16_t;
57 # else
58 # if SIZEOF_INT == 2
59 typedef int int16_t;
60 typedef unsigned int u_int16_t;
61 # else
62 #error Cannot find a type with sizeof() == 2
63 # endif
64 # endif
65
66 # if SIZEOF_SHORT == 4
67 typedef short int32_t;
68 typedef unsigned short u_int32_t;
69 # else
70 # if SIZEOF_INT == 4
71 typedef int int32_t;
72 typedef unsigned int u_int32_t;
73 # else
74 #error Cannot find a type with sizeof() == 4
75 # endif
76 # endif
77 #endif /* NEED_TYPEDEFS */
78
79 #ifdef HAVE_UNISTD_H
80 # include <unistd.h>
81 #endif
82
83 #ifdef HAVE_STDLIB_H
84 # include <stdlib.h>
85 #endif
86
87 #include <stdio.h>
88 #include <errno.h>
89
90 #ifndef HAVE_MEMMOVE
91 #define memmove(x, y, z) bcopy(y, x, z)
92 #endif
93
94 #if TIME_WITH_SYS_TIME
95 # include <sys/time.h>
96 # include <time.h>
97 #else
98 # if HAVE_SYS_TIME_H
99 # include <sys/time.h>
100 # else
101 # include <time.h>
102 # endif
103 #endif
104
105 #ifdef HAVE_STRING_H
106 # include <string.h>
107 #else
108 # include <strings.h>
109 #endif
110
111 #ifndef _WIN32
112 #include <sys/uio.h>
113 #endif
114
115 #ifndef _P
116 #ifndef NO_PROTOTYPES
117 # define _P(x) x
118 #else
119 # define _P(x) ()
120 #endif
121 #endif
122
123 #ifndef _WIN32
124 #include <netinet/in.h>
125 #include <arpa/inet.h>
126 #endif
127
128 #ifdef GETTIMEOFDAY_ONE_ARG
129 #define gettimeofday(x, y) gettimeofday(x)
130 #endif
131
132 /* Systems lacking strdup() definition in <string.h>. */
133 #if defined(ultrix)
134 char *strdup _P((const char *));
135 #endif
136
137 /* Systems lacking malloc() definition in <stdlib.h>. */
138 #if defined(ultrix) || defined(hcx)
139 void *malloc _P((size_t arg));
140 void free _P((void *ptr));
141 #endif
142
143 #ifndef HAVE_INET_ATON
144 int inet_aton _P((const char *cp, struct in_addr *ia));
145 #endif
146
147 #include <fcntl.h>
148 #ifndef NO_UNIX_SOCKETS
149 #include <sys/un.h>
150 #endif
151 #include <signal.h>
152 #ifdef HAVE_SYS_SIGNAL_H
153 # include <sys/signal.h>
154 #endif
155 #ifndef _WIN32
156 #include <sys/socket.h>
157 #endif
158
159 #if defined(HAVE_SYS_IOCTL_H)
160 # include <sys/ioctl.h>
161 #endif
162
163 #ifdef HAVE_SYS_SELECT_H
164 # include <sys/select.h>
165 #endif
166
167 #ifdef HAVE_SYS_WAIT_H
168 # include <sys/wait.h>
169 #endif
170
171 #ifdef HAVE_SYS_FILIO_H
172 # include <sys/filio.h>
173 #endif
174
175 #ifdef USE_PPP
176 #include <ppp/slirppp.h>
177 #endif
178
179 #ifdef __STDC__
180 #include <stdarg.h>
181 #else
182 #include <varargs.h>
183 #endif
184
185 #include <sys/stat.h>
186
187 /* Avoid conflicting with the libc insque() and remque(), which
188 have different prototypes. */
189 #define insque slirp_insque
190 #define remque slirp_remque
191
192 #ifdef HAVE_SYS_STROPTS_H
193 #include <sys/stropts.h>
194 #endif
195
196 #include "debug.h"
197
198 #include "ip.h"
199 #include "tcp.h"
200 #include "tcp_timer.h"
201 #include "tcp_var.h"
202 #include "tcpip.h"
203 #include "udp.h"
204 #include "icmp_var.h"
205 #include "mbuf.h"
206 #include "sbuf.h"
207 #include "socket.h"
208 #include "if.h"
209 #include "main.h"
210 #include "misc.h"
211 #include "ctl.h"
212 #ifdef USE_PPP
213 #include "ppp/pppd.h"
214 #include "ppp/ppp.h"
215 #endif
216
217 #include "bootp.h"
218 #include "tftp.h"
219 #include "libslirp.h"
220
221 extern struct ttys *ttys_unit[MAX_INTERFACES];
222
223 #ifndef NULL
224 #define NULL (void *)0
225 #endif
226
227 #ifndef FULL_BOLT
228 void if_start _P((void));
229 #else
230 void if_start _P((struct ttys *));
231 #endif
232
233 #ifdef BAD_SPRINTF
234 # define vsprintf vsprintf_len
235 # define sprintf sprintf_len
236 extern int vsprintf_len _P((char *, const char *, va_list));
237 extern int sprintf_len _P((char *, const char *, ...));
238 #endif
239
240 #ifdef DECLARE_SPRINTF
241 # ifndef BAD_SPRINTF
242 extern int vsprintf _P((char *, const char *, va_list));
243 # endif
244 extern int vfprintf _P((FILE *, const char *, va_list));
245 #endif
246
247 #ifndef HAVE_STRERROR
248 extern char *strerror _P((int error));
249 #endif
250
251 #ifndef HAVE_INDEX
252 char *index _P((const char *, int));
253 #endif
254
255 #ifndef HAVE_GETHOSTID
256 long gethostid _P((void));
257 #endif
258
259 void lprint _P((const char *, ...));
260
261 extern int do_echo;
262
263 #if SIZEOF_CHAR_P == 4
264 # define insque_32 insque
265 # define remque_32 remque
266 #else
267 inline void insque_32 _P((void *, void *));
268 inline void remque_32 _P((void *));
269 #endif
270
271 #ifndef _WIN32
272 #include <netdb.h>
273 #endif
274
275 #define DEFAULT_BAUD 115200
276
277 /* cksum.c */
278 int cksum(struct mbuf *m, int len);
279
280 /* if.c */
281 void if_init _P((void));
282 void if_output _P((struct socket *, struct mbuf *));
283
284 /* ip_input.c */
285 void ip_init _P((void));
286 void ip_input _P((struct mbuf *));
287 struct ip * ip_reass _P((register struct ipasfrag *, register struct ipq *));
288 void ip_freef _P((struct ipq *));
289 void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
290 void ip_deq _P((register struct ipasfrag *));
291 void ip_slowtimo _P((void));
292 void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
293
294 /* ip_output.c */
295 int ip_output _P((struct socket *, struct mbuf *));
296
297 /* tcp_input.c */
298 int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
299 void tcp_input _P((register struct mbuf *, int, struct socket *));
300 void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
301 void tcp_xmit_timer _P((register struct tcpcb *, int));
302 int tcp_mss _P((register struct tcpcb *, u_int));
303
304 /* tcp_output.c */
305 int tcp_output _P((register struct tcpcb *));
306 void tcp_setpersist _P((register struct tcpcb *));
307
308 /* tcp_subr.c */
309 void tcp_init _P((void));
310 void tcp_template _P((struct tcpcb *));
311 void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
312 struct tcpcb * tcp_newtcpcb _P((struct socket *));
313 struct tcpcb * tcp_close _P((register struct tcpcb *));
314 void tcp_drain _P((void));
315 void tcp_sockclosed _P((struct tcpcb *));
316 int tcp_fconnect _P((struct socket *));
317 void tcp_connect _P((struct socket *));
318 int tcp_attach _P((struct socket *));
319 u_int8_t tcp_tos _P((struct socket *));
320 int tcp_emu _P((struct socket *, struct mbuf *));
321 int tcp_ctl _P((struct socket *));
322 struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
323
324 #ifdef USE_PPP
325 #define MIN_MRU MINMRU
326 #define MAX_MRU MAXMRU
327 #else
328 #define MIN_MRU 128
329 #define MAX_MRU 16384
330 #endif
331
332 #ifndef _WIN32
333 #define min(x,y) ((x) < (y) ? (x) : (y))
334 #define max(x,y) ((x) > (y) ? (x) : (y))
335 #endif
336
337 #ifdef _WIN32
338 #undef errno
339 #define errno (WSAGetLastError())
340 #endif
341
342 #endif