]> Git Repo - qemu.git/blame - slirp/slirp.h
Prevent cpsr_write/_read be put out of line in op.o (fixes a segfault on some platforms).
[qemu.git] / slirp / slirp.h
CommitLineData
f0cbd3ec
FB
1#ifndef __COMMON_H__
2#define __COMMON_H__
3
4#define CONFIG_QEMU
5
31a60e22
BS
6//#define DEBUG 1
7
8// Uncomment the following line to enable SLIRP statistics printing in Qemu
9//#define LOG_ENABLED
10
11#ifdef LOG_ENABLED
12#define STAT(expr) expr
13#else
14#define STAT(expr) do { } while(0)
15#endif
f0cbd3ec
FB
16
17#ifndef CONFIG_QEMU
18#include "version.h"
19#endif
5fa0ab8f 20#include "config-host.h"
f0cbd3ec
FB
21#include "slirp_config.h"
22
379ff53d
FB
23#ifdef _WIN32
24# include <inttypes.h>
25
26typedef uint8_t u_int8_t;
27typedef uint16_t u_int16_t;
28typedef uint32_t u_int32_t;
29typedef uint64_t u_int64_t;
30typedef char *caddr_t;
31
34444131 32# include <windows.h>
379ff53d
FB
33# include <winsock2.h>
34# include <sys/timeb.h>
35# include <iphlpapi.h>
36
37# define EWOULDBLOCK WSAEWOULDBLOCK
38# define EINPROGRESS WSAEINPROGRESS
39# define ENOTCONN WSAENOTCONN
40# define EHOSTUNREACH WSAEHOSTUNREACH
41# define ENETUNREACH WSAENETUNREACH
42# define ECONNREFUSED WSAECONNREFUSED
43#else
44# define ioctlsocket ioctl
45# define closesocket(s) close(s)
6d46bf8a 46# define O_BINARY 0
379ff53d
FB
47#endif
48
f0cbd3ec
FB
49#include <sys/types.h>
50#ifdef HAVE_SYS_BITYPES_H
51# include <sys/bitypes.h>
52#endif
53
170c6f87
FB
54#include <sys/time.h>
55
f0cbd3ec
FB
56#ifdef NEED_TYPEDEFS
57typedef char int8_t;
58typedef unsigned char u_int8_t;
59
60# if SIZEOF_SHORT == 2
61 typedef short int16_t;
62 typedef unsigned short u_int16_t;
63# else
64# if SIZEOF_INT == 2
65 typedef int int16_t;
66 typedef unsigned int u_int16_t;
67# else
68 #error Cannot find a type with sizeof() == 2
69# endif
70# endif
71
72# if SIZEOF_SHORT == 4
73 typedef short int32_t;
74 typedef unsigned short u_int32_t;
75# else
76# if SIZEOF_INT == 4
77 typedef int int32_t;
78 typedef unsigned int u_int32_t;
79# else
80 #error Cannot find a type with sizeof() == 4
81# endif
82# endif
83#endif /* NEED_TYPEDEFS */
84
85#ifdef HAVE_UNISTD_H
86# include <unistd.h>
87#endif
88
89#ifdef HAVE_STDLIB_H
90# include <stdlib.h>
91#endif
92
93#include <stdio.h>
94#include <errno.h>
95
96#ifndef HAVE_MEMMOVE
97#define memmove(x, y, z) bcopy(y, x, z)
98#endif
99
100#if TIME_WITH_SYS_TIME
101# include <sys/time.h>
102# include <time.h>
103#else
104# if HAVE_SYS_TIME_H
105# include <sys/time.h>
106# else
107# include <time.h>
108# endif
109#endif
110
111#ifdef HAVE_STRING_H
112# include <string.h>
113#else
114# include <strings.h>
115#endif
116
379ff53d 117#ifndef _WIN32
f0cbd3ec 118#include <sys/uio.h>
379ff53d 119#endif
f0cbd3ec
FB
120
121#ifndef _P
122#ifndef NO_PROTOTYPES
123# define _P(x) x
124#else
125# define _P(x) ()
126#endif
127#endif
128
379ff53d 129#ifndef _WIN32
f0cbd3ec
FB
130#include <netinet/in.h>
131#include <arpa/inet.h>
379ff53d 132#endif
f0cbd3ec
FB
133
134#ifdef GETTIMEOFDAY_ONE_ARG
135#define gettimeofday(x, y) gettimeofday(x)
136#endif
137
138/* Systems lacking strdup() definition in <string.h>. */
139#if defined(ultrix)
140char *strdup _P((const char *));
141#endif
142
143/* Systems lacking malloc() definition in <stdlib.h>. */
144#if defined(ultrix) || defined(hcx)
145void *malloc _P((size_t arg));
146void free _P((void *ptr));
147#endif
148
149#ifndef HAVE_INET_ATON
150int inet_aton _P((const char *cp, struct in_addr *ia));
151#endif
152
153#include <fcntl.h>
154#ifndef NO_UNIX_SOCKETS
155#include <sys/un.h>
156#endif
157#include <signal.h>
158#ifdef HAVE_SYS_SIGNAL_H
159# include <sys/signal.h>
160#endif
379ff53d 161#ifndef _WIN32
f0cbd3ec 162#include <sys/socket.h>
379ff53d 163#endif
f0cbd3ec 164
ee2654ac 165#if defined(HAVE_SYS_IOCTL_H)
f0cbd3ec 166# include <sys/ioctl.h>
f0cbd3ec
FB
167#endif
168
f0cbd3ec
FB
169#ifdef HAVE_SYS_SELECT_H
170# include <sys/select.h>
171#endif
172
173#ifdef HAVE_SYS_WAIT_H
174# include <sys/wait.h>
175#endif
176
177#ifdef HAVE_SYS_FILIO_H
178# include <sys/filio.h>
179#endif
180
181#ifdef USE_PPP
182#include <ppp/slirppp.h>
183#endif
184
185#ifdef __STDC__
186#include <stdarg.h>
187#else
188#include <varargs.h>
189#endif
190
191#include <sys/stat.h>
192
193/* Avoid conflicting with the libc insque() and remque(), which
194 have different prototypes. */
195#define insque slirp_insque
196#define remque slirp_remque
197
198#ifdef HAVE_SYS_STROPTS_H
199#include <sys/stropts.h>
200#endif
201
202#include "debug.h"
203
204#include "ip.h"
205#include "tcp.h"
206#include "tcp_timer.h"
207#include "tcp_var.h"
208#include "tcpip.h"
209#include "udp.h"
210#include "icmp_var.h"
211#include "mbuf.h"
212#include "sbuf.h"
213#include "socket.h"
214#include "if.h"
215#include "main.h"
216#include "misc.h"
217#include "ctl.h"
218#ifdef USE_PPP
219#include "ppp/pppd.h"
220#include "ppp/ppp.h"
221#endif
222
223#include "bootp.h"
c7f74643 224#include "tftp.h"
f0cbd3ec
FB
225#include "libslirp.h"
226
227extern struct ttys *ttys_unit[MAX_INTERFACES];
228
229#ifndef NULL
230#define NULL (void *)0
231#endif
232
233#ifndef FULL_BOLT
234void if_start _P((void));
235#else
236void if_start _P((struct ttys *));
237#endif
238
239#ifdef BAD_SPRINTF
240# define vsprintf vsprintf_len
241# define sprintf sprintf_len
242 extern int vsprintf_len _P((char *, const char *, va_list));
243 extern int sprintf_len _P((char *, const char *, ...));
244#endif
245
246#ifdef DECLARE_SPRINTF
247# ifndef BAD_SPRINTF
248 extern int vsprintf _P((char *, const char *, va_list));
249# endif
250 extern int vfprintf _P((FILE *, const char *, va_list));
251#endif
252
253#ifndef HAVE_STRERROR
254 extern char *strerror _P((int error));
255#endif
256
257#ifndef HAVE_INDEX
258 char *index _P((const char *, int));
259#endif
260
261#ifndef HAVE_GETHOSTID
262 long gethostid _P((void));
263#endif
264
265void lprint _P((const char *, ...));
266
f0cbd3ec
FB
267#if SIZEOF_CHAR_P == 4
268# define insque_32 insque
269# define remque_32 remque
270#else
271 inline void insque_32 _P((void *, void *));
272 inline void remque_32 _P((void *));
273#endif
274
379ff53d 275#ifndef _WIN32
f0cbd3ec 276#include <netdb.h>
379ff53d 277#endif
f0cbd3ec
FB
278
279#define DEFAULT_BAUD 115200
280
9634d903
BS
281#define SO_OPTIONS DO_KEEPALIVE
282#define TCP_MAXIDLE (TCPTV_KEEPCNT * TCPTV_KEEPINTVL)
283
f0cbd3ec
FB
284/* cksum.c */
285int cksum(struct mbuf *m, int len);
286
287/* if.c */
288void if_init _P((void));
289void if_output _P((struct socket *, struct mbuf *));
290
291/* ip_input.c */
292void ip_init _P((void));
293void ip_input _P((struct mbuf *));
f0cbd3ec
FB
294void ip_slowtimo _P((void));
295void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
296
297/* ip_output.c */
298int ip_output _P((struct socket *, struct mbuf *));
299
300/* tcp_input.c */
f0cbd3ec 301void tcp_input _P((register struct mbuf *, int, struct socket *));
f0cbd3ec
FB
302int tcp_mss _P((register struct tcpcb *, u_int));
303
304/* tcp_output.c */
305int tcp_output _P((register struct tcpcb *));
306void tcp_setpersist _P((register struct tcpcb *));
307
308/* tcp_subr.c */
309void tcp_init _P((void));
310void tcp_template _P((struct tcpcb *));
311void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
312struct tcpcb * tcp_newtcpcb _P((struct socket *));
313struct tcpcb * tcp_close _P((register struct tcpcb *));
f0cbd3ec
FB
314void tcp_sockclosed _P((struct tcpcb *));
315int tcp_fconnect _P((struct socket *));
316void tcp_connect _P((struct socket *));
317int tcp_attach _P((struct socket *));
318u_int8_t tcp_tos _P((struct socket *));
319int tcp_emu _P((struct socket *, struct mbuf *));
320int tcp_ctl _P((struct socket *));
9fafc9ea 321struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
f0cbd3ec
FB
322
323#ifdef USE_PPP
324#define MIN_MRU MINMRU
325#define MAX_MRU MAXMRU
326#else
327#define MIN_MRU 128
328#define MAX_MRU 16384
329#endif
330
379ff53d
FB
331#ifndef _WIN32
332#define min(x,y) ((x) < (y) ? (x) : (y))
333#define max(x,y) ((x) > (y) ? (x) : (y))
334#endif
335
02d2c54c 336#ifdef _WIN32
ef6ff6b7 337#undef errno
02d2c54c
FB
338#define errno (WSAGetLastError())
339#endif
340
f0cbd3ec 341#endif
This page took 0.180419 seconds and 4 git commands to generate.