Cirrus VGA emulation
[qemu.git] / slirp / slirp.h
blob5b9cfdec80363a5975703ae2d4754ef99ea4670e
1 #ifndef __COMMON_H__
2 #define __COMMON_H__
4 #define CONFIG_QEMU
6 #define DEBUG 1
8 #ifndef CONFIG_QEMU
9 #include "version.h"
10 #endif
11 #include "config.h"
12 #include "slirp_config.h"
14 #include <sys/types.h>
15 #ifdef HAVE_SYS_BITYPES_H
16 # include <sys/bitypes.h>
17 #endif
19 #include <sys/time.h>
21 #ifdef NEED_TYPEDEFS
22 typedef char int8_t;
23 typedef unsigned char u_int8_t;
25 # if SIZEOF_SHORT == 2
26 typedef short int16_t;
27 typedef unsigned short u_int16_t;
28 # else
29 # if SIZEOF_INT == 2
30 typedef int int16_t;
31 typedef unsigned int u_int16_t;
32 # else
33 #error Cannot find a type with sizeof() == 2
34 # endif
35 # endif
37 # if SIZEOF_SHORT == 4
38 typedef short int32_t;
39 typedef unsigned short u_int32_t;
40 # else
41 # if SIZEOF_INT == 4
42 typedef int int32_t;
43 typedef unsigned int u_int32_t;
44 # else
45 #error Cannot find a type with sizeof() == 4
46 # endif
47 # endif
48 #endif /* NEED_TYPEDEFS */
50 #ifdef HAVE_UNISTD_H
51 # include <unistd.h>
52 #endif
54 #ifdef HAVE_STDLIB_H
55 # include <stdlib.h>
56 #endif
58 #include <stdio.h>
59 #include <errno.h>
61 #ifndef HAVE_MEMMOVE
62 #define memmove(x, y, z) bcopy(y, x, z)
63 #endif
65 #if TIME_WITH_SYS_TIME
66 # include <sys/time.h>
67 # include <time.h>
68 #else
69 # if HAVE_SYS_TIME_H
70 # include <sys/time.h>
71 # else
72 # include <time.h>
73 # endif
74 #endif
76 #ifdef HAVE_STRING_H
77 # include <string.h>
78 #else
79 # include <strings.h>
80 #endif
82 #include <sys/uio.h>
84 #ifndef _P
85 #ifndef NO_PROTOTYPES
86 # define _P(x) x
87 #else
88 # define _P(x) ()
89 #endif
90 #endif
92 #include <netinet/in.h>
93 #include <arpa/inet.h>
95 #ifdef GETTIMEOFDAY_ONE_ARG
96 #define gettimeofday(x, y) gettimeofday(x)
97 #endif
99 /* Systems lacking strdup() definition in <string.h>. */
100 #if defined(ultrix)
101 char *strdup _P((const char *));
102 #endif
104 /* Systems lacking malloc() definition in <stdlib.h>. */
105 #if defined(ultrix) || defined(hcx)
106 void *malloc _P((size_t arg));
107 void free _P((void *ptr));
108 #endif
110 #ifndef HAVE_INET_ATON
111 int inet_aton _P((const char *cp, struct in_addr *ia));
112 #endif
114 #include <fcntl.h>
115 #ifndef NO_UNIX_SOCKETS
116 #include <sys/un.h>
117 #endif
118 #include <signal.h>
119 #ifdef HAVE_SYS_SIGNAL_H
120 # include <sys/signal.h>
121 #endif
122 #include <sys/socket.h>
124 #if defined(WANT_SYS_IOCTL_H) && defined(HAVE_SYS_IOCTL_H)
125 # include <sys/ioctl.h>
126 #else
127 # define WANT_SYS_TERMIOS_H
128 #endif
130 #ifdef WANT_SYS_TERMIOS_H
131 # ifndef INCLUDED_TERMIOS_H
132 # ifdef HAVE_TERMIOS_H
133 # include <termios.h>
134 # else
135 # include <termio.h>
136 # endif
137 # define INCLUDED_TERMIOS_H
138 # endif
139 #endif
143 #ifdef HAVE_SYS_SELECT_H
144 # include <sys/select.h>
145 #endif
147 #ifdef HAVE_SYS_WAIT_H
148 # include <sys/wait.h>
149 #endif
151 #ifdef HAVE_SYS_FILIO_H
152 # include <sys/filio.h>
153 #endif
155 #ifdef USE_PPP
156 #include <ppp/slirppp.h>
157 #endif
159 #ifdef __STDC__
160 #include <stdarg.h>
161 #else
162 #include <varargs.h>
163 #endif
165 #include <sys/stat.h>
167 /* Avoid conflicting with the libc insque() and remque(), which
168 have different prototypes. */
169 #define insque slirp_insque
170 #define remque slirp_remque
172 #ifdef HAVE_SYS_STROPTS_H
173 #include <sys/stropts.h>
174 #endif
176 #include "debug.h"
178 #include "ip.h"
179 #include "tcp.h"
180 #include "tcp_timer.h"
181 #include "tcp_var.h"
182 #include "tcpip.h"
183 #include "udp.h"
184 #include "icmp_var.h"
185 #include "mbuf.h"
186 #include "sbuf.h"
187 #include "socket.h"
188 #include "if.h"
189 #include "main.h"
190 #include "misc.h"
191 #include "ctl.h"
192 #ifdef USE_PPP
193 #include "ppp/pppd.h"
194 #include "ppp/ppp.h"
195 #endif
197 #include "bootp.h"
198 #include "libslirp.h"
200 extern struct ttys *ttys_unit[MAX_INTERFACES];
202 #ifndef NULL
203 #define NULL (void *)0
204 #endif
206 #ifndef FULL_BOLT
207 void if_start _P((void));
208 #else
209 void if_start _P((struct ttys *));
210 #endif
212 #ifdef BAD_SPRINTF
213 # define vsprintf vsprintf_len
214 # define sprintf sprintf_len
215 extern int vsprintf_len _P((char *, const char *, va_list));
216 extern int sprintf_len _P((char *, const char *, ...));
217 #endif
219 #ifdef DECLARE_SPRINTF
220 # ifndef BAD_SPRINTF
221 extern int vsprintf _P((char *, const char *, va_list));
222 # endif
223 extern int vfprintf _P((FILE *, const char *, va_list));
224 #endif
226 #ifndef HAVE_STRERROR
227 extern char *strerror _P((int error));
228 #endif
230 #ifndef HAVE_INDEX
231 char *index _P((const char *, int));
232 #endif
234 #ifndef HAVE_GETHOSTID
235 long gethostid _P((void));
236 #endif
238 void lprint _P((const char *, ...));
240 extern int do_echo;
242 #if SIZEOF_CHAR_P == 4
243 # define insque_32 insque
244 # define remque_32 remque
245 #else
246 inline void insque_32 _P((void *, void *));
247 inline void remque_32 _P((void *));
248 #endif
250 #include <pwd.h>
251 #include <netdb.h>
253 #define DEFAULT_BAUD 115200
255 /* cksum.c */
256 int cksum(struct mbuf *m, int len);
258 /* if.c */
259 void if_init _P((void));
260 void if_output _P((struct socket *, struct mbuf *));
262 /* ip_input.c */
263 void ip_init _P((void));
264 void ip_input _P((struct mbuf *));
265 struct ip * ip_reass _P((register struct ipasfrag *, register struct ipq *));
266 void ip_freef _P((struct ipq *));
267 void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
268 void ip_deq _P((register struct ipasfrag *));
269 void ip_slowtimo _P((void));
270 void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
272 /* ip_output.c */
273 int ip_output _P((struct socket *, struct mbuf *));
275 /* tcp_input.c */
276 int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
277 void tcp_input _P((register struct mbuf *, int, struct socket *));
278 void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
279 void tcp_xmit_timer _P((register struct tcpcb *, int));
280 int tcp_mss _P((register struct tcpcb *, u_int));
282 /* tcp_output.c */
283 int tcp_output _P((register struct tcpcb *));
284 void tcp_setpersist _P((register struct tcpcb *));
286 /* tcp_subr.c */
287 void tcp_init _P((void));
288 void tcp_template _P((struct tcpcb *));
289 void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
290 struct tcpcb * tcp_newtcpcb _P((struct socket *));
291 struct tcpcb * tcp_close _P((register struct tcpcb *));
292 void tcp_drain _P((void));
293 void tcp_sockclosed _P((struct tcpcb *));
294 int tcp_fconnect _P((struct socket *));
295 void tcp_connect _P((struct socket *));
296 int tcp_attach _P((struct socket *));
297 u_int8_t tcp_tos _P((struct socket *));
298 int tcp_emu _P((struct socket *, struct mbuf *));
299 int tcp_ctl _P((struct socket *));
300 struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
302 #ifdef USE_PPP
303 #define MIN_MRU MINMRU
304 #define MAX_MRU MAXMRU
305 #else
306 #define MIN_MRU 128
307 #define MAX_MRU 16384
308 #endif
310 #endif