|
|
1.1 ! root 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: #ifdef _WIN32 ! 15: #undef _WIN32_WINNT ! 16: #define _WIN32_WINNT 0x0501 ! 17: # include <inttypes.h> ! 18: # include <WinError.h> ! 19: ! 20: typedef uint8_t u_int8_t; ! 21: typedef uint16_t u_int16_t; ! 22: typedef uint32_t u_int32_t; ! 23: typedef uint64_t u_int64_t; ! 24: typedef char *caddr_t; ! 25: typedef int socklen_t; ! 26: typedef unsigned long ioctlsockopt_t; ! 27: ! 28: # include <winsock2.h> ! 29: # include <WS2tcpip.h> ! 30: # include <sys/timeb.h> ! 31: # include <iphlpapi.h> ! 32: ! 33: # define USE_FIONBIO 1 ! 34: ! 35: /* Basilisk II Router defines those */ ! 36: # define udp_read_completion slirp_udp_read_completion ! 37: # define write_udp slirp_write_udp ! 38: # define init_udp slirp_init_udp ! 39: # define final_udp slirp_final_udp ! 40: #else ! 41: # define WSAGetLastError() (int)(errno) ! 42: # define WSASetLastError(e) (void)(errno = (e)) ! 43: # define WSAEWOULDBLOCK EWOULDBLOCK ! 44: # define WSAEINPROGRESS EINPROGRESS ! 45: # define WSAENOTCONN ENOTCONN ! 46: # define WSAEHOSTUNREACH EHOSTUNREACH ! 47: # define WSAENETUNREACH ENETUNREACH ! 48: # define WSAECONNREFUSED ECONNREFUSED ! 49: typedef int ioctlsockopt_t; ! 50: # define ioctlsocket ioctl ! 51: # define closesocket(s) close(s) ! 52: # define O_BINARY 0 ! 53: #endif ! 54: ! 55: #include <sys/types.h> ! 56: #ifdef HAVE_SYS_BITYPES_H ! 57: # include <sys/bitypes.h> ! 58: #endif ! 59: #ifdef HAVE_STDINT_H ! 60: # include <stdint.h> ! 61: #endif ! 62: ! 63: #ifndef _WIN32 ! 64: #include <sys/time.h> ! 65: #endif ! 66: ! 67: #ifdef NEED_TYPEDEFS ! 68: typedef char int8_t; ! 69: typedef unsigned char u_int8_t; ! 70: ! 71: # if SIZEOF_SHORT == 2 ! 72: typedef short int16_t; ! 73: typedef unsigned short u_int16_t; ! 74: # else ! 75: # if SIZEOF_INT == 2 ! 76: typedef int int16_t; ! 77: typedef unsigned int u_int16_t; ! 78: # else ! 79: #error Cannot find a type with sizeof() == 2 ! 80: # endif ! 81: # endif ! 82: ! 83: # if SIZEOF_SHORT == 4 ! 84: typedef short int32_t; ! 85: typedef unsigned short u_int32_t; ! 86: # else ! 87: # if SIZEOF_INT == 4 ! 88: typedef int int32_t; ! 89: typedef unsigned int u_int32_t; ! 90: # else ! 91: #error Cannot find a type with sizeof() == 4 ! 92: # endif ! 93: # endif ! 94: #endif /* NEED_TYPEDEFS */ ! 95: ! 96: #ifdef __HAIKU__ ! 97: #include <SupportDefs.h> ! 98: #else ! 99: /* Basilisk II types glue */ ! 100: typedef u_int8_t uint8; ! 101: typedef u_int16_t uint16; ! 102: typedef u_int32_t uint32; ! 103: #endif ! 104: ! 105: #ifdef HAVE_UNISTD_H ! 106: # include <unistd.h> ! 107: #endif ! 108: ! 109: #ifdef HAVE_STDLIB_H ! 110: # include <stdlib.h> ! 111: #endif ! 112: ! 113: #include <stdio.h> ! 114: #include <errno.h> ! 115: ! 116: #ifndef SLIRP_HAVE_MEMMOVE ! 117: #define memmove(x, y, z) bcopy(y, x, z) ! 118: #endif ! 119: ! 120: #if TIME_WITH_SYS_TIME ! 121: # include <sys/time.h> ! 122: # include <time.h> ! 123: #else ! 124: # if HAVE_SYS_TIME_H ! 125: # include <sys/time.h> ! 126: # else ! 127: # include <time.h> ! 128: # endif ! 129: #endif ! 130: ! 131: #ifdef HAVE_STRING_H ! 132: # include <string.h> ! 133: #else ! 134: # include <strings.h> ! 135: #endif ! 136: ! 137: #ifndef _WIN32 ! 138: #include <sys/uio.h> ! 139: #include <netinet/in.h> ! 140: #include <arpa/inet.h> ! 141: #endif ! 142: ! 143: #ifdef GETTIMEOFDAY_ONE_ARG ! 144: #define gettimeofday(x, y) gettimeofday(x) ! 145: #endif ! 146: ! 147: /* Systems lacking strdup() definition in <string.h>. */ ! 148: #if defined(ultrix) ! 149: char *strdup(const char *); ! 150: #endif ! 151: ! 152: /* Systems lacking malloc() definition in <stdlib.h>. */ ! 153: #if defined(ultrix) || defined(hcx) ! 154: void *malloc(size_t arg); ! 155: void free(void *ptr); ! 156: #endif ! 157: ! 158: #ifndef HAVE_INET_ATON ! 159: int inet_aton(const char *cp, struct in_addr *ia); ! 160: #endif ! 161: ! 162: #include <fcntl.h> ! 163: #ifdef _WIN32 ! 164: #include <io.h> ! 165: const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); ! 166: #endif ! 167: #ifndef NO_UNIX_SOCKETS ! 168: #include <sys/un.h> ! 169: #endif ! 170: #include <signal.h> ! 171: #ifdef HAVE_SYS_SIGNAL_H ! 172: # include <sys/signal.h> ! 173: #endif ! 174: #ifndef _WIN32 ! 175: #include <sys/socket.h> ! 176: #endif ! 177: ! 178: #if defined(HAVE_SYS_IOCTL_H) ! 179: # include <sys/ioctl.h> ! 180: #endif ! 181: ! 182: #ifdef HAVE_SYS_SELECT_H ! 183: # include <sys/select.h> ! 184: #endif ! 185: ! 186: #ifdef HAVE_SYS_WAIT_H ! 187: # include <sys/wait.h> ! 188: #endif ! 189: ! 190: #ifdef HAVE_SYS_FILIO_H ! 191: # include <sys/filio.h> ! 192: #endif ! 193: ! 194: #ifdef USE_PPP ! 195: #include <ppp/slirppp.h> ! 196: #endif ! 197: ! 198: #include <stdarg.h> ! 199: ! 200: #include <sys/stat.h> ! 201: ! 202: /* Avoid conflicting with the libc insque() and remque(), which ! 203: have different prototypes. */ ! 204: #define insque slirp_insque ! 205: #define remque slirp_remque ! 206: ! 207: #ifdef HAVE_SYS_STROPTS_H ! 208: #include <sys/stropts.h> ! 209: #endif ! 210: ! 211: #include "slirpdebug.h" ! 212: ! 213: #if defined __GNUC__ ! 214: #define PACKED__ __attribute__ ((packed)) ! 215: #elif defined _MSC_VER ! 216: #define PRAGMA_PACK_SUPPORTED 1 ! 217: #define PACK_RESET ! 218: #define PACKED__ ! 219: #elif defined __sgi ! 220: #define PRAGMA_PACK_SUPPORTED 1 ! 221: #define PACK_RESET 0 ! 222: #define PACKED__ ! 223: #else ! 224: #error "Packed attribute or pragma shall be supported" ! 225: #endif ! 226: ! 227: #include "ip.h" ! 228: #include "tcp.h" ! 229: #include "tcp_timer.h" ! 230: #include "tcp_var.h" ! 231: #include "tcpip.h" ! 232: #include "udp.h" ! 233: #include "icmp_var.h" ! 234: #include "mbuf.h" ! 235: #include "sbuf.h" ! 236: #include "socket.h" ! 237: #include "if.h" ! 238: #include "slirpmain.h" ! 239: #include "misc.h" ! 240: #include "ctl.h" ! 241: #ifdef USE_PPP ! 242: #include "ppp/pppd.h" ! 243: #include "ppp/ppp.h" ! 244: #endif ! 245: ! 246: #include "bootp.h" ! 247: #include "tftp.h" ! 248: #include "libslirp.h" ! 249: ! 250: extern struct ttys *ttys_unit[MAX_INTERFACES]; ! 251: ! 252: #ifndef NULL ! 253: #define NULL (void *)0 ! 254: #endif ! 255: ! 256: #ifndef FULL_BOLT ! 257: void if_start(void); ! 258: #else ! 259: void if_start(struct ttys *); ! 260: #endif ! 261: ! 262: #ifdef BAD_SPRINTF ! 263: # define vsprintf vsprintf_len ! 264: # define sprintf sprintf_len ! 265: extern int vsprintf_len(char *, const char *, va_list); ! 266: extern int sprintf_len(char *, const char *, ...); ! 267: #endif ! 268: ! 269: #ifdef DECLARE_SPRINTF ! 270: # ifndef BAD_SPRINTF ! 271: extern int vsprintf(char *, const char *, va_list); ! 272: # endif ! 273: extern int vfprintf(FILE *, const char *, va_list); ! 274: #endif ! 275: ! 276: #ifndef HAVE_STRERROR ! 277: extern char *strerror(int error); ! 278: #endif ! 279: ! 280: #ifndef HAVE_INDEX ! 281: char *index(const char *, int); ! 282: #endif ! 283: ! 284: #ifndef HAVE_GETHOSTID ! 285: long gethostid(void); ! 286: #endif ! 287: ! 288: void lprint(const char *, ...); ! 289: ! 290: extern int do_echo; ! 291: ! 292: #ifndef _WIN32 ! 293: #include <netdb.h> ! 294: #endif ! 295: ! 296: #define DEFAULT_BAUD 115200 ! 297: ! 298: /* cksum.c */ ! 299: int cksum(struct mbuf *m, int len); ! 300: ! 301: /* if.c */ ! 302: void if_init(void); ! 303: void if_output(struct socket *, struct mbuf *); ! 304: ! 305: /* ip_input.c */ ! 306: void ip_init(void); ! 307: void ip_input(struct mbuf *); ! 308: struct ip * ip_reass(register struct ip *ip, register struct ipq *); ! 309: void ip_freef(struct ipq *); ! 310: void ip_enq(register struct ipasfrag *, register struct ipasfrag *); ! 311: void ip_deq(register struct ipasfrag *); ! 312: void ip_slowtimo(void); ! 313: void ip_stripoptions(register struct mbuf *, struct mbuf *); ! 314: ! 315: /* ip_output.c */ ! 316: int ip_output(struct socket *, struct mbuf *); ! 317: ! 318: /* tcp_input.c */ ! 319: int tcp_reass(register struct tcpcb *, register struct tcpiphdr *, struct mbuf *); ! 320: void tcp_input(register struct mbuf *, int, struct socket *); ! 321: void tcp_dooptions(struct tcpcb *, u_char *, int, struct tcpiphdr *); ! 322: void tcp_xmit_timer(register struct tcpcb *, int); ! 323: u_int tcp_mss(register struct tcpcb *, u_int); ! 324: ! 325: /* tcp_output.c */ ! 326: int tcp_output(register struct tcpcb *); ! 327: void tcp_setpersist(register struct tcpcb *); ! 328: ! 329: /* tcp_subr.c */ ! 330: void tcp_init(void); ! 331: void tcp_template(struct tcpcb *); ! 332: void tcp_respond(struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int); ! 333: struct tcpcb * tcp_newtcpcb(struct socket *); ! 334: struct tcpcb * tcp_close(register struct tcpcb *); ! 335: void tcp_drain(void); ! 336: void tcp_sockclosed(struct tcpcb *); ! 337: int tcp_fconnect(struct socket *); ! 338: void tcp_connect(struct socket *); ! 339: int tcp_attach(struct socket *); ! 340: u_int8_t tcp_tos(struct socket *); ! 341: int tcp_emu(struct socket *, struct mbuf *); ! 342: int tcp_ctl(struct socket *); ! 343: struct tcpcb *tcp_drop(struct tcpcb *tp, int err); ! 344: ! 345: #ifdef USE_PPP ! 346: #define MIN_MRU MINMRU ! 347: #define MAX_MRU MAXMRU ! 348: #else ! 349: #define MIN_MRU 128 ! 350: #define MAX_MRU 16384 ! 351: #endif ! 352: ! 353: #ifndef _WIN32 ! 354: #define min(x,y) ((x) < (y) ? (x) : (y)) ! 355: #define max(x,y) ((x) > (y) ? (x) : (y)) ! 356: #endif ! 357: ! 358: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.