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