kvm: qemu: fix pci_enable_capabilities to set the CAP feature in pci::status
[kvm-userspace.git] / qemu / slirp / slirp.h
blob8309fe051c01f9ef63209f275d8f8bfc812f556f
1 #ifndef __COMMON_H__
2 #define __COMMON_H__
4 #define CONFIG_QEMU
6 //#define DEBUG 1
8 // Uncomment the following line to enable SLIRP statistics printing in Qemu
9 //#define LOG_ENABLED
11 #ifdef LOG_ENABLED
12 #define STAT(expr) expr
13 #else
14 #define STAT(expr) do { } while(0)
15 #endif
17 #ifndef CONFIG_QEMU
18 #include "version.h"
19 #endif
20 #include "config-host.h"
21 #include "slirp_config.h"
23 #ifdef _WIN32
24 # include <inttypes.h>
26 typedef uint8_t u_int8_t;
27 typedef uint16_t u_int16_t;
28 typedef uint32_t u_int32_t;
29 typedef uint64_t u_int64_t;
30 typedef char *caddr_t;
32 # include <windows.h>
33 # include <winsock2.h>
34 # include <ws2tcpip.h>
35 # include <sys/timeb.h>
36 # include <iphlpapi.h>
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)
47 # define O_BINARY 0
48 #endif
50 #include <sys/types.h>
51 #ifdef HAVE_SYS_BITYPES_H
52 # include <sys/bitypes.h>
53 #endif
55 #include <sys/time.h>
57 #ifdef NEED_TYPEDEFS
58 typedef char int8_t;
59 typedef unsigned char u_int8_t;
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
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 */
86 #ifdef HAVE_UNISTD_H
87 # include <unistd.h>
88 #endif
90 #ifdef HAVE_STDLIB_H
91 # include <stdlib.h>
92 #endif
94 #include <stdio.h>
95 #include <errno.h>
97 #ifndef HAVE_MEMMOVE
98 #define memmove(x, y, z) bcopy(y, x, z)
99 #endif
101 #if TIME_WITH_SYS_TIME
102 # include <sys/time.h>
103 # include <time.h>
104 #else
105 # ifdef HAVE_SYS_TIME_H
106 # include <sys/time.h>
107 # else
108 # include <time.h>
109 # endif
110 #endif
112 #ifdef HAVE_STRING_H
113 # include <string.h>
114 #else
115 # include <strings.h>
116 #endif
118 #ifndef _WIN32
119 #include <sys/uio.h>
120 #endif
122 #undef _P
123 #ifndef NO_PROTOTYPES
124 # define _P(x) x
125 #else
126 # define _P(x) ()
127 #endif
129 #ifndef _WIN32
130 #include <netinet/in.h>
131 #include <arpa/inet.h>
132 #endif
134 #ifdef GETTIMEOFDAY_ONE_ARG
135 #define gettimeofday(x, y) gettimeofday(x)
136 #endif
138 /* Systems lacking strdup() definition in <string.h>. */
139 #if defined(ultrix)
140 char *strdup _P((const char *));
141 #endif
143 /* Systems lacking malloc() definition in <stdlib.h>. */
144 #if defined(ultrix) || defined(hcx)
145 void *malloc _P((size_t arg));
146 void free _P((void *ptr));
147 #endif
149 #ifndef HAVE_INET_ATON
150 int inet_aton _P((const char *cp, struct in_addr *ia));
151 #endif
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
161 #ifndef _WIN32
162 #include <sys/socket.h>
163 #endif
165 #if defined(HAVE_SYS_IOCTL_H)
166 # include <sys/ioctl.h>
167 #endif
169 #ifdef HAVE_SYS_SELECT_H
170 # include <sys/select.h>
171 #endif
173 #ifdef HAVE_SYS_WAIT_H
174 # include <sys/wait.h>
175 #endif
177 #ifdef HAVE_SYS_FILIO_H
178 # include <sys/filio.h>
179 #endif
181 #ifdef USE_PPP
182 #include <ppp/slirppp.h>
183 #endif
185 #ifdef __STDC__
186 #include <stdarg.h>
187 #else
188 #include <varargs.h>
189 #endif
191 #include <sys/stat.h>
193 /* Avoid conflicting with the libc insque() and remque(), which
194 have different prototypes. */
195 #define insque slirp_insque
196 #define remque slirp_remque
198 #ifdef HAVE_SYS_STROPTS_H
199 #include <sys/stropts.h>
200 #endif
202 #include "debug.h"
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
223 #include "bootp.h"
224 #include "tftp.h"
225 #include "libslirp.h"
227 extern struct ttys *ttys_unit[MAX_INTERFACES];
229 #ifndef NULL
230 #define NULL (void *)0
231 #endif
233 #ifndef FULL_BOLT
234 void if_start _P((void));
235 #else
236 void if_start _P((struct ttys *));
237 #endif
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
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
253 #ifndef HAVE_STRERROR
254 extern char *strerror _P((int error));
255 #endif
257 #ifndef HAVE_INDEX
258 char *index _P((const char *, int));
259 #endif
261 #ifndef HAVE_GETHOSTID
262 long gethostid _P((void));
263 #endif
265 void lprint _P((const char *, ...));
267 #ifndef _WIN32
268 #include <netdb.h>
269 #endif
271 #define DEFAULT_BAUD 115200
273 #define SO_OPTIONS DO_KEEPALIVE
274 #define TCP_MAXIDLE (TCPTV_KEEPCNT * TCPTV_KEEPINTVL)
276 /* cksum.c */
277 int cksum(struct mbuf *m, int len);
279 /* if.c */
280 void if_init _P((void));
281 void if_output _P((struct socket *, struct mbuf *));
283 /* ip_input.c */
284 void ip_init _P((void));
285 void ip_input _P((struct mbuf *));
286 void ip_slowtimo _P((void));
287 void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
289 /* ip_output.c */
290 int ip_output _P((struct socket *, struct mbuf *));
292 /* tcp_input.c */
293 void tcp_input _P((register struct mbuf *, int, struct socket *));
294 int tcp_mss _P((register struct tcpcb *, u_int));
296 /* tcp_output.c */
297 int tcp_output _P((register struct tcpcb *));
298 void tcp_setpersist _P((register struct tcpcb *));
300 /* tcp_subr.c */
301 void tcp_init _P((void));
302 void tcp_template _P((struct tcpcb *));
303 void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
304 struct tcpcb * tcp_newtcpcb _P((struct socket *));
305 struct tcpcb * tcp_close _P((register struct tcpcb *));
306 void tcp_sockclosed _P((struct tcpcb *));
307 int tcp_fconnect _P((struct socket *));
308 void tcp_connect _P((struct socket *));
309 int tcp_attach _P((struct socket *));
310 u_int8_t tcp_tos _P((struct socket *));
311 int tcp_emu _P((struct socket *, struct mbuf *));
312 int tcp_ctl _P((struct socket *));
313 struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
315 #ifdef USE_PPP
316 #define MIN_MRU MINMRU
317 #define MAX_MRU MAXMRU
318 #else
319 #define MIN_MRU 128
320 #define MAX_MRU 16384
321 #endif
323 #ifndef _WIN32
324 #define min(x,y) ((x) < (y) ? (x) : (y))
325 #define max(x,y) ((x) > (y) ? (x) : (y))
326 #endif
328 #ifdef _WIN32
329 #undef errno
330 #define errno (WSAGetLastError())
331 #endif
333 #endif