eecef59165103d19199325137a49908aa05acdb3
[qemu] / slirp / slirp.h
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 #include <sys/types.h>
15 #ifdef HAVE_SYS_BITYPES_H
16 # include <sys/bitypes.h>
17 #endif
18
19 #include <sys/time.h>
20
21 #ifdef NEED_TYPEDEFS
22 typedef char int8_t;
23 typedef unsigned char u_int8_t;
24
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
36
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 */
49
50 #ifdef HAVE_UNISTD_H
51 # include <unistd.h>
52 #endif
53
54 #ifdef HAVE_STDLIB_H
55 # include <stdlib.h>
56 #endif
57
58 #include <stdio.h>
59 #include <errno.h>
60
61 #ifndef HAVE_MEMMOVE
62 #define memmove(x, y, z) bcopy(y, x, z)
63 #endif
64
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
75
76 #ifdef HAVE_STRING_H
77 # include <string.h>
78 #else
79 # include <strings.h>
80 #endif
81
82 #include <sys/uio.h>
83
84 #ifndef _P
85 #ifndef NO_PROTOTYPES
86 #  define   _P(x)   x
87 #else
88 #  define   _P(x)   ()
89 #endif
90 #endif
91
92 #include <netinet/in.h>
93 #include <arpa/inet.h>
94
95 #ifdef GETTIMEOFDAY_ONE_ARG
96 #define gettimeofday(x, y) gettimeofday(x)
97 #endif
98
99 /* Systems lacking strdup() definition in <string.h>. */
100 #if defined(ultrix)
101 char *strdup _P((const char *));
102 #endif
103
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
109
110 #ifndef HAVE_INET_ATON
111 int inet_aton _P((const char *cp, struct in_addr *ia));
112 #endif
113
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>
123
124 #if defined(HAVE_SYS_IOCTL_H)
125 # include <sys/ioctl.h>
126 #endif
127
128 #ifdef HAVE_SYS_SELECT_H
129 # include <sys/select.h>
130 #endif
131
132 #ifdef HAVE_SYS_WAIT_H
133 # include <sys/wait.h>
134 #endif
135
136 #ifdef HAVE_SYS_FILIO_H
137 # include <sys/filio.h>
138 #endif
139
140 #ifdef USE_PPP
141 #include <ppp/slirppp.h>
142 #endif
143
144 #ifdef __STDC__
145 #include <stdarg.h>
146 #else
147 #include <varargs.h>
148 #endif
149
150 #include <sys/stat.h>
151
152 /* Avoid conflicting with the libc insque() and remque(), which
153    have different prototypes. */
154 #define insque slirp_insque
155 #define remque slirp_remque
156
157 #ifdef HAVE_SYS_STROPTS_H
158 #include <sys/stropts.h>
159 #endif
160
161 #include "debug.h"
162
163 #include "ip.h"
164 #include "tcp.h"
165 #include "tcp_timer.h"
166 #include "tcp_var.h"
167 #include "tcpip.h"
168 #include "udp.h"
169 #include "icmp_var.h"
170 #include "mbuf.h"
171 #include "sbuf.h"
172 #include "socket.h"
173 #include "if.h"
174 #include "main.h"
175 #include "misc.h"
176 #include "ctl.h"
177 #ifdef USE_PPP
178 #include "ppp/pppd.h"
179 #include "ppp/ppp.h"
180 #endif
181
182 #include "bootp.h"
183 #include "libslirp.h"
184
185 extern struct ttys *ttys_unit[MAX_INTERFACES];
186
187 #ifndef NULL
188 #define NULL (void *)0
189 #endif
190
191 #ifndef FULL_BOLT
192 void if_start _P((void));
193 #else
194 void if_start _P((struct ttys *));
195 #endif
196
197 #ifdef BAD_SPRINTF
198 # define vsprintf vsprintf_len
199 # define sprintf sprintf_len
200  extern int vsprintf_len _P((char *, const char *, va_list));
201  extern int sprintf_len _P((char *, const char *, ...));
202 #endif
203
204 #ifdef DECLARE_SPRINTF
205 # ifndef BAD_SPRINTF
206  extern int vsprintf _P((char *, const char *, va_list));
207 # endif
208  extern int vfprintf _P((FILE *, const char *, va_list));
209 #endif
210
211 #ifndef HAVE_STRERROR
212  extern char *strerror _P((int error));
213 #endif
214
215 #ifndef HAVE_INDEX
216  char *index _P((const char *, int));
217 #endif
218
219 #ifndef HAVE_GETHOSTID
220  long gethostid _P((void));
221 #endif
222
223 void lprint _P((const char *, ...));
224
225 extern int do_echo;
226
227 #if SIZEOF_CHAR_P == 4
228 # define insque_32 insque
229 # define remque_32 remque
230 #else
231  inline void insque_32 _P((void *, void *));
232  inline void remque_32 _P((void *));
233 #endif
234
235 #include <pwd.h>
236 #include <netdb.h>
237
238 #define DEFAULT_BAUD 115200
239
240 /* cksum.c */
241 int cksum(struct mbuf *m, int len);
242
243 /* if.c */
244 void if_init _P((void));
245 void if_output _P((struct socket *, struct mbuf *));
246
247 /* ip_input.c */
248 void ip_init _P((void));
249 void ip_input _P((struct mbuf *));
250 struct ip * ip_reass _P((register struct ipasfrag *, register struct ipq *));
251 void ip_freef _P((struct ipq *));
252 void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
253 void ip_deq _P((register struct ipasfrag *));
254 void ip_slowtimo _P((void));
255 void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
256
257 /* ip_output.c */
258 int ip_output _P((struct socket *, struct mbuf *));
259
260 /* tcp_input.c */
261 int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
262 void tcp_input _P((register struct mbuf *, int, struct socket *));
263 void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
264 void tcp_xmit_timer _P((register struct tcpcb *, int));
265 int tcp_mss _P((register struct tcpcb *, u_int));
266
267 /* tcp_output.c */
268 int tcp_output _P((register struct tcpcb *));
269 void tcp_setpersist _P((register struct tcpcb *));
270
271 /* tcp_subr.c */
272 void tcp_init _P((void));
273 void tcp_template _P((struct tcpcb *));
274 void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
275 struct tcpcb * tcp_newtcpcb _P((struct socket *));
276 struct tcpcb * tcp_close _P((register struct tcpcb *));
277 void tcp_drain _P((void));
278 void tcp_sockclosed _P((struct tcpcb *));
279 int tcp_fconnect _P((struct socket *));
280 void tcp_connect _P((struct socket *));
281 int tcp_attach _P((struct socket *));
282 u_int8_t tcp_tos _P((struct socket *));
283 int tcp_emu _P((struct socket *, struct mbuf *));
284 int tcp_ctl _P((struct socket *));
285 struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
286
287 #ifdef USE_PPP
288 #define MIN_MRU MINMRU
289 #define MAX_MRU MAXMRU
290 #else
291 #define MIN_MRU 128
292 #define MAX_MRU 16384
293 #endif
294
295 #endif