Statistics
| Branch: | Revision:

root / slirp / slirp.h @ dc5d0b3d

History | View | Annotate | Download (6.1 kB)

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