ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/slirp/slirp.h
Revision: 1.8
Committed: 2012-04-21T16:51:23Z (12 years, 6 months ago) by asvitkine
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +2 -2 lines
Log Message:
Apparently this change allows compilation with clang.
Patch by "Madd the Sane" (http://sourceforge.net/users/madd_the_sane)

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 gbeauche 1.6 typedef int socklen_t;
23     typedef unsigned long ioctlsockopt_t;
24 gbeauche 1.1
25     # include <windows.h>
26     # include <winsock2.h>
27     # include <sys/timeb.h>
28     # include <iphlpapi.h>
29    
30 gbeauche 1.6 # define USE_FIONBIO 1
31 gbeauche 1.1 # define EWOULDBLOCK WSAEWOULDBLOCK
32     # define EINPROGRESS WSAEINPROGRESS
33     # define ENOTCONN WSAENOTCONN
34     # define EHOSTUNREACH WSAEHOSTUNREACH
35     # define ENETUNREACH WSAENETUNREACH
36     # define ECONNREFUSED WSAECONNREFUSED
37 gbeauche 1.6
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
43 gbeauche 1.1 #else
44 gbeauche 1.6 typedef int ioctlsockopt_t;
45 gbeauche 1.1 # define ioctlsocket ioctl
46     # define closesocket(s) close(s)
47     # define O_BINARY 0
48     #endif
49    
50     #include <sys/types.h>
51     #ifdef HAVE_SYS_BITYPES_H
52     # include <sys/bitypes.h>
53     #endif
54 nigel 1.4 #ifdef HAVE_STDINT_H
55     # include <stdint.h>
56     #endif
57 gbeauche 1.1
58     #include <sys/time.h>
59    
60     #ifdef NEED_TYPEDEFS
61     typedef char int8_t;
62     typedef unsigned char u_int8_t;
63    
64     # if SIZEOF_SHORT == 2
65     typedef short int16_t;
66     typedef unsigned short u_int16_t;
67     # else
68     # if SIZEOF_INT == 2
69     typedef int int16_t;
70     typedef unsigned int u_int16_t;
71     # else
72     #error Cannot find a type with sizeof() == 2
73     # endif
74     # endif
75    
76     # if SIZEOF_SHORT == 4
77     typedef short int32_t;
78     typedef unsigned short u_int32_t;
79     # else
80     # if SIZEOF_INT == 4
81     typedef int int32_t;
82     typedef unsigned int u_int32_t;
83     # else
84     #error Cannot find a type with sizeof() == 4
85     # endif
86     # endif
87     #endif /* NEED_TYPEDEFS */
88    
89 gbeauche 1.7 /* Basilisk II types glue */
90     typedef u_int8_t uint8;
91     typedef u_int16_t uint16;
92     typedef u_int32_t uint32;
93    
94 gbeauche 1.1 #ifdef HAVE_UNISTD_H
95     # include <unistd.h>
96     #endif
97    
98     #ifdef HAVE_STDLIB_H
99     # include <stdlib.h>
100     #endif
101    
102     #include <stdio.h>
103     #include <errno.h>
104    
105     #ifndef HAVE_MEMMOVE
106     #define memmove(x, y, z) bcopy(y, x, z)
107     #endif
108    
109     #if TIME_WITH_SYS_TIME
110     # include <sys/time.h>
111     # include <time.h>
112     #else
113     # if HAVE_SYS_TIME_H
114     # include <sys/time.h>
115     # else
116     # include <time.h>
117     # endif
118     #endif
119    
120     #ifdef HAVE_STRING_H
121     # include <string.h>
122     #else
123     # include <strings.h>
124     #endif
125    
126     #ifndef _WIN32
127     #include <sys/uio.h>
128     #endif
129    
130     #ifndef _P
131     #ifndef NO_PROTOTYPES
132     # define _P(x) x
133     #else
134     # define _P(x) ()
135     #endif
136     #endif
137    
138     #ifndef _WIN32
139     #include <netinet/in.h>
140     #include <arpa/inet.h>
141     #endif
142    
143     #ifdef GETTIMEOFDAY_ONE_ARG
144     #define gettimeofday(x, y) gettimeofday(x)
145     #endif
146    
147     /* Systems lacking strdup() definition in <string.h>. */
148     #if defined(ultrix)
149     char *strdup _P((const char *));
150     #endif
151    
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));
156     #endif
157    
158     #ifndef HAVE_INET_ATON
159     int inet_aton _P((const char *cp, struct in_addr *ia));
160     #endif
161    
162     #include <fcntl.h>
163     #ifndef NO_UNIX_SOCKETS
164     #include <sys/un.h>
165     #endif
166     #include <signal.h>
167     #ifdef HAVE_SYS_SIGNAL_H
168     # include <sys/signal.h>
169     #endif
170     #ifndef _WIN32
171     #include <sys/socket.h>
172     #endif
173    
174     #if defined(HAVE_SYS_IOCTL_H)
175     # include <sys/ioctl.h>
176     #endif
177    
178     #ifdef HAVE_SYS_SELECT_H
179     # include <sys/select.h>
180     #endif
181    
182     #ifdef HAVE_SYS_WAIT_H
183     # include <sys/wait.h>
184     #endif
185    
186     #ifdef HAVE_SYS_FILIO_H
187     # include <sys/filio.h>
188     #endif
189    
190     #ifdef USE_PPP
191     #include <ppp/slirppp.h>
192     #endif
193    
194     #ifdef __STDC__
195     #include <stdarg.h>
196     #else
197     #include <varargs.h>
198     #endif
199    
200     #include <sys/stat.h>
201    
202     /* Avoid conflicting with the libc insque() and remque(), which
203     have different prototypes. */
204     #define insque slirp_insque
205     #define remque slirp_remque
206    
207     #ifdef HAVE_SYS_STROPTS_H
208     #include <sys/stropts.h>
209     #endif
210    
211     #include "debug.h"
212    
213 gbeauche 1.5 #if defined __GNUC__
214     #define PACKED__ __attribute__ ((packed))
215     #elif defined __sgi
216     #define PRAGMA_PACK_SUPPORTED 1
217     #define PACKED__
218     #else
219     #error "Packed attribute or pragma shall be supported"
220     #endif
221    
222 gbeauche 1.1 #include "ip.h"
223     #include "tcp.h"
224     #include "tcp_timer.h"
225     #include "tcp_var.h"
226     #include "tcpip.h"
227     #include "udp.h"
228     #include "icmp_var.h"
229     #include "mbuf.h"
230     #include "sbuf.h"
231     #include "socket.h"
232     #include "if.h"
233     #include "main.h"
234     #include "misc.h"
235     #include "ctl.h"
236     #ifdef USE_PPP
237     #include "ppp/pppd.h"
238     #include "ppp/ppp.h"
239     #endif
240    
241     #include "bootp.h"
242     #include "tftp.h"
243     #include "libslirp.h"
244    
245     extern struct ttys *ttys_unit[MAX_INTERFACES];
246    
247     #ifndef NULL
248     #define NULL (void *)0
249     #endif
250    
251     #ifndef FULL_BOLT
252     void if_start _P((void));
253     #else
254     void if_start _P((struct ttys *));
255     #endif
256    
257     #ifdef BAD_SPRINTF
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 *, ...));
262     #endif
263    
264     #ifdef DECLARE_SPRINTF
265     # ifndef BAD_SPRINTF
266     extern int vsprintf _P((char *, const char *, va_list));
267     # endif
268     extern int vfprintf _P((FILE *, const char *, va_list));
269     #endif
270    
271     #ifndef HAVE_STRERROR
272     extern char *strerror _P((int error));
273     #endif
274    
275     #ifndef HAVE_INDEX
276     char *index _P((const char *, int));
277     #endif
278    
279     #ifndef HAVE_GETHOSTID
280     long gethostid _P((void));
281     #endif
282    
283     void lprint _P((const char *, ...));
284    
285     extern int do_echo;
286    
287     #if SIZEOF_CHAR_P == 4
288     # define insque_32 insque
289     # define remque_32 remque
290     #else
291 asvitkine 1.8 extern inline void insque_32 _P((void *, void *));
292     extern inline void remque_32 _P((void *));
293 gbeauche 1.1 #endif
294    
295     #ifndef _WIN32
296     #include <netdb.h>
297     #endif
298    
299     #define DEFAULT_BAUD 115200
300    
301     /* cksum.c */
302     int cksum(struct mbuf *m, int len);
303    
304     /* if.c */
305     void if_init _P((void));
306     void if_output _P((struct socket *, struct mbuf *));
307    
308     /* ip_input.c */
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 *));
317    
318     /* ip_output.c */
319     int ip_output _P((struct socket *, struct mbuf *));
320    
321     /* tcp_input.c */
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));
327    
328     /* tcp_output.c */
329     int tcp_output _P((register struct tcpcb *));
330     void tcp_setpersist _P((register struct tcpcb *));
331    
332     /* tcp_subr.c */
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);
347    
348     #ifdef USE_PPP
349     #define MIN_MRU MINMRU
350     #define MAX_MRU MAXMRU
351     #else
352     #define MIN_MRU 128
353     #define MAX_MRU 16384
354     #endif
355    
356     #ifndef _WIN32
357     #define min(x,y) ((x) < (y) ? (x) : (y))
358     #define max(x,y) ((x) > (y) ? (x) : (y))
359     #endif
360    
361     #ifdef _WIN32
362     #undef errno
363     #define errno (WSAGetLastError())
364     #endif
365    
366     #endif