ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/slirp/slirp.h
Revision: 1.2
Committed: 2005-05-14T17:37:07Z (19 years, 4 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
Changes since 1.1: +4 -0 lines
Log Message:
Remove bootp debug code as it uses varargs macros that are not supported in
all foreign compilers (including preprocessor shipped with MacOS X!). Also
fix build on platforms not including <stdint.h> by default.

File Contents

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