ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/slirp/slirp.h
Revision: 1.5
Committed: 2006-01-17T21:19:12Z (18 years, 9 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
Changes since 1.4: +9 -0 lines
Log Message:
Packet headers can be examined through unaligned addresses. This patch
fixes this, especially for MIPS & SPARC platforms. [Initial patch from
Brian J. Johnson]

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     #include <sys/types.h>
41     #ifdef HAVE_SYS_BITYPES_H
42     # include <sys/bitypes.h>
43     #endif
44 nigel 1.4 #ifdef HAVE_STDINT_H
45     # include <stdint.h>
46     #endif
47 gbeauche 1.1
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 gbeauche 1.5 #if defined __GNUC__
199     #define PACKED__ __attribute__ ((packed))
200     #elif defined __sgi
201     #define PRAGMA_PACK_SUPPORTED 1
202     #define PACKED__
203     #else
204     #error "Packed attribute or pragma shall be supported"
205     #endif
206    
207 gbeauche 1.1 #include "ip.h"
208     #include "tcp.h"
209     #include "tcp_timer.h"
210     #include "tcp_var.h"
211     #include "tcpip.h"
212     #include "udp.h"
213     #include "icmp_var.h"
214     #include "mbuf.h"
215     #include "sbuf.h"
216     #include "socket.h"
217     #include "if.h"
218     #include "main.h"
219     #include "misc.h"
220     #include "ctl.h"
221     #ifdef USE_PPP
222     #include "ppp/pppd.h"
223     #include "ppp/ppp.h"
224     #endif
225    
226     #include "bootp.h"
227     #include "tftp.h"
228     #include "libslirp.h"
229    
230     extern struct ttys *ttys_unit[MAX_INTERFACES];
231    
232     #ifndef NULL
233     #define NULL (void *)0
234     #endif
235    
236     #ifndef FULL_BOLT
237     void if_start _P((void));
238     #else
239     void if_start _P((struct ttys *));
240     #endif
241    
242     #ifdef BAD_SPRINTF
243     # define vsprintf vsprintf_len
244     # define sprintf sprintf_len
245     extern int vsprintf_len _P((char *, const char *, va_list));
246     extern int sprintf_len _P((char *, const char *, ...));
247     #endif
248    
249     #ifdef DECLARE_SPRINTF
250     # ifndef BAD_SPRINTF
251     extern int vsprintf _P((char *, const char *, va_list));
252     # endif
253     extern int vfprintf _P((FILE *, const char *, va_list));
254     #endif
255    
256     #ifndef HAVE_STRERROR
257     extern char *strerror _P((int error));
258     #endif
259    
260     #ifndef HAVE_INDEX
261     char *index _P((const char *, int));
262     #endif
263    
264     #ifndef HAVE_GETHOSTID
265     long gethostid _P((void));
266     #endif
267    
268     void lprint _P((const char *, ...));
269    
270     extern int do_echo;
271    
272     #if SIZEOF_CHAR_P == 4
273     # define insque_32 insque
274     # define remque_32 remque
275     #else
276     inline void insque_32 _P((void *, void *));
277     inline void remque_32 _P((void *));
278     #endif
279    
280     #ifndef _WIN32
281     #include <netdb.h>
282     #endif
283    
284     #define DEFAULT_BAUD 115200
285    
286     /* cksum.c */
287     int cksum(struct mbuf *m, int len);
288    
289     /* if.c */
290     void if_init _P((void));
291     void if_output _P((struct socket *, struct mbuf *));
292    
293     /* ip_input.c */
294     void ip_init _P((void));
295     void ip_input _P((struct mbuf *));
296     struct ip * ip_reass _P((register struct ipasfrag *, register struct ipq *));
297     void ip_freef _P((struct ipq *));
298     void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
299     void ip_deq _P((register struct ipasfrag *));
300     void ip_slowtimo _P((void));
301     void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
302    
303     /* ip_output.c */
304     int ip_output _P((struct socket *, struct mbuf *));
305    
306     /* tcp_input.c */
307     int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
308     void tcp_input _P((register struct mbuf *, int, struct socket *));
309     void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
310     void tcp_xmit_timer _P((register struct tcpcb *, int));
311     int tcp_mss _P((register struct tcpcb *, u_int));
312    
313     /* tcp_output.c */
314     int tcp_output _P((register struct tcpcb *));
315     void tcp_setpersist _P((register struct tcpcb *));
316    
317     /* tcp_subr.c */
318     void tcp_init _P((void));
319     void tcp_template _P((struct tcpcb *));
320     void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
321     struct tcpcb * tcp_newtcpcb _P((struct socket *));
322     struct tcpcb * tcp_close _P((register struct tcpcb *));
323     void tcp_drain _P((void));
324     void tcp_sockclosed _P((struct tcpcb *));
325     int tcp_fconnect _P((struct socket *));
326     void tcp_connect _P((struct socket *));
327     int tcp_attach _P((struct socket *));
328     u_int8_t tcp_tos _P((struct socket *));
329     int tcp_emu _P((struct socket *, struct mbuf *));
330     int tcp_ctl _P((struct socket *));
331     struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
332    
333     #ifdef USE_PPP
334     #define MIN_MRU MINMRU
335     #define MAX_MRU MAXMRU
336     #else
337     #define MIN_MRU 128
338     #define MAX_MRU 16384
339     #endif
340    
341     #ifndef _WIN32
342     #define min(x,y) ((x) < (y) ? (x) : (y))
343     #define max(x,y) ((x) > (y) ? (x) : (y))
344     #endif
345    
346     #ifdef _WIN32
347     #undef errno
348     #define errno (WSAGetLastError())
349     #endif
350    
351     #endif