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