Commit 379ff53dc964ee1dc9442dac230c87a595e06a12
1 parent
ce93da6f
win32 compile
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1016 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
13 changed files
with
142 additions
and
26 deletions
slirp/libslirp.h
slirp/main.h
slirp/misc.c
| @@ -326,7 +326,7 @@ fork_exec(so, ex, do_pty) | @@ -326,7 +326,7 @@ fork_exec(so, ex, do_pty) | ||
| 326 | bind(s, (struct sockaddr *)&addr, addrlen) < 0 || | 326 | bind(s, (struct sockaddr *)&addr, addrlen) < 0 || |
| 327 | listen(s, 1) < 0) { | 327 | listen(s, 1) < 0) { |
| 328 | lprint("Error: inet socket: %s\n", strerror(errno)); | 328 | lprint("Error: inet socket: %s\n", strerror(errno)); |
| 329 | - close(s); | 329 | + closesocket(s); |
| 330 | 330 | ||
| 331 | return 0; | 331 | return 0; |
| 332 | } | 332 | } |
| @@ -421,7 +421,7 @@ fork_exec(so, ex, do_pty) | @@ -421,7 +421,7 @@ fork_exec(so, ex, do_pty) | ||
| 421 | * of connect() fail in the child process | 421 | * of connect() fail in the child process |
| 422 | */ | 422 | */ |
| 423 | so->s = accept(s, (struct sockaddr *)&addr, &addrlen); | 423 | so->s = accept(s, (struct sockaddr *)&addr, &addrlen); |
| 424 | - close(s); | 424 | + closesocket(s); |
| 425 | opt = 1; | 425 | opt = 1; |
| 426 | setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); | 426 | setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); |
| 427 | opt = 1; | 427 | opt = 1; |
| @@ -804,7 +804,7 @@ fd_nonblock(fd) | @@ -804,7 +804,7 @@ fd_nonblock(fd) | ||
| 804 | #ifdef FIONBIO | 804 | #ifdef FIONBIO |
| 805 | int opt = 1; | 805 | int opt = 1; |
| 806 | 806 | ||
| 807 | - ioctl(fd, FIONBIO, &opt); | 807 | + ioctlsocket(fd, FIONBIO, &opt); |
| 808 | #else | 808 | #else |
| 809 | int opt; | 809 | int opt; |
| 810 | 810 | ||
| @@ -821,7 +821,7 @@ fd_block(fd) | @@ -821,7 +821,7 @@ fd_block(fd) | ||
| 821 | #ifdef FIONBIO | 821 | #ifdef FIONBIO |
| 822 | int opt = 0; | 822 | int opt = 0; |
| 823 | 823 | ||
| 824 | - ioctl(fd, FIONBIO, &opt); | 824 | + ioctlsocket(fd, FIONBIO, &opt); |
| 825 | #else | 825 | #else |
| 826 | int opt; | 826 | int opt; |
| 827 | 827 |
slirp/sbuf.c
| @@ -106,7 +106,7 @@ sbappend(so, m) | @@ -106,7 +106,7 @@ sbappend(so, m) | ||
| 106 | * ottherwise it'll arrive out of order, and hence corrupt | 106 | * ottherwise it'll arrive out of order, and hence corrupt |
| 107 | */ | 107 | */ |
| 108 | if (!so->so_rcv.sb_cc) | 108 | if (!so->so_rcv.sb_cc) |
| 109 | - ret = write(so->s, m->m_data, m->m_len); | 109 | + ret = send(so->s, m->m_data, m->m_len, 0); |
| 110 | 110 | ||
| 111 | if (ret <= 0) { | 111 | if (ret <= 0) { |
| 112 | /* | 112 | /* |
slirp/slirp.c
| @@ -28,8 +28,50 @@ fd_set *global_readfds, *global_writefds, *global_xfds; | @@ -28,8 +28,50 @@ fd_set *global_readfds, *global_writefds, *global_xfds; | ||
| 28 | 28 | ||
| 29 | static int get_dns_addr(struct in_addr *pdns_addr) | 29 | static int get_dns_addr(struct in_addr *pdns_addr) |
| 30 | { | 30 | { |
| 31 | - /* XXX: add it */ | ||
| 32 | - return -1; | 31 | + FIXED_INFO *FixedInfo=NULL; |
| 32 | + ULONG BufLen; | ||
| 33 | + DWORD ret; | ||
| 34 | + IP_ADDR_STRING *pIPAddr; | ||
| 35 | + struct in_addr tmp_addr; | ||
| 36 | + | ||
| 37 | + FixedInfo = (FIXED_INFO *)GlobalAlloc(GPTR, sizeof(FIXED_INFO)); | ||
| 38 | + BufLen = sizeof(FIXED_INFO); | ||
| 39 | + | ||
| 40 | + if (ERROR_BUFFER_OVERFLOW == GetNetworkParams(FixedInfo, &BufLen)) { | ||
| 41 | + if (FixedInfo) { | ||
| 42 | + GlobalFree(FixedInfo); | ||
| 43 | + FixedInfo = NULL; | ||
| 44 | + } | ||
| 45 | + FixedInfo = GlobalAlloc(GPTR, BufLen); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + if ((ret = GetNetworkParams(FixedInfo, &BufLen)) != ERROR_SUCCESS) { | ||
| 49 | + printf("GetNetworkParams failed. ret = %08x\n", (u_int)ret ); | ||
| 50 | + if (FixedInfo) { | ||
| 51 | + GlobalFree(FixedInfo); | ||
| 52 | + FixedInfo = NULL; | ||
| 53 | + } | ||
| 54 | + return -1; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + pIPAddr = &(FixedInfo->DnsServerList); | ||
| 58 | + inet_aton(pIPAddr->IpAddress.String, &tmp_addr); | ||
| 59 | + *pdns_addr = tmp_addr; | ||
| 60 | +#if 0 | ||
| 61 | + printf( "DNS Servers:\n" ); | ||
| 62 | + printf( "DNS Addr:%s\n", pIPAddr->IpAddress.String ); | ||
| 63 | + | ||
| 64 | + pIPAddr = FixedInfo -> DnsServerList.Next; | ||
| 65 | + while ( pIPAddr ) { | ||
| 66 | + printf( "DNS Addr:%s\n", pIPAddr ->IpAddress.String ); | ||
| 67 | + pIPAddr = pIPAddr ->Next; | ||
| 68 | + } | ||
| 69 | +#endif | ||
| 70 | + if (FixedInfo) { | ||
| 71 | + GlobalFree(FixedInfo); | ||
| 72 | + FixedInfo = NULL; | ||
| 73 | + } | ||
| 74 | + return 0; | ||
| 33 | } | 75 | } |
| 34 | 76 | ||
| 35 | #else | 77 | #else |
| @@ -73,10 +115,25 @@ static int get_dns_addr(struct in_addr *pdns_addr) | @@ -73,10 +115,25 @@ static int get_dns_addr(struct in_addr *pdns_addr) | ||
| 73 | 115 | ||
| 74 | #endif | 116 | #endif |
| 75 | 117 | ||
| 118 | +#ifdef _WIN32 | ||
| 119 | +void slirp_cleanup(void) | ||
| 120 | +{ | ||
| 121 | + WSACleanup(); | ||
| 122 | +} | ||
| 123 | +#endif | ||
| 124 | + | ||
| 76 | void slirp_init(void) | 125 | void slirp_init(void) |
| 77 | { | 126 | { |
| 78 | // debug_init("/tmp/slirp.log", DEBUG_DEFAULT); | 127 | // debug_init("/tmp/slirp.log", DEBUG_DEFAULT); |
| 79 | 128 | ||
| 129 | +#ifdef _WIN32 | ||
| 130 | + { | ||
| 131 | + WSADATA Data; | ||
| 132 | + WSAStartup(MAKEWORD(2,0), &Data); | ||
| 133 | + atexit(slirp_cleanup); | ||
| 134 | + } | ||
| 135 | +#endif | ||
| 136 | + | ||
| 80 | link_up = 1; | 137 | link_up = 1; |
| 81 | 138 | ||
| 82 | if_init(); | 139 | if_init(); |
| @@ -104,6 +161,16 @@ void slirp_init(void) | @@ -104,6 +161,16 @@ void slirp_init(void) | ||
| 104 | /* | 161 | /* |
| 105 | * curtime kept to an accuracy of 1ms | 162 | * curtime kept to an accuracy of 1ms |
| 106 | */ | 163 | */ |
| 164 | +#ifdef _WIN32 | ||
| 165 | +static void updtime(void) | ||
| 166 | +{ | ||
| 167 | + struct _timeb tb; | ||
| 168 | + | ||
| 169 | + _ftime(&tb); | ||
| 170 | + curtime = (u_int)tb.time * (u_int)1000; | ||
| 171 | + curtime += (u_int)tb.millitm; | ||
| 172 | +} | ||
| 173 | +#else | ||
| 107 | static void updtime(void) | 174 | static void updtime(void) |
| 108 | { | 175 | { |
| 109 | gettimeofday(&tt, 0); | 176 | gettimeofday(&tt, 0); |
| @@ -114,6 +181,7 @@ static void updtime(void) | @@ -114,6 +181,7 @@ static void updtime(void) | ||
| 114 | if ((tt.tv_usec % 1000) >= 500) | 181 | if ((tt.tv_usec % 1000) >= 500) |
| 115 | curtime++; | 182 | curtime++; |
| 116 | } | 183 | } |
| 184 | +#endif | ||
| 117 | 185 | ||
| 118 | void slirp_select_fill(int *pnfds, | 186 | void slirp_select_fill(int *pnfds, |
| 119 | fd_set *readfds, fd_set *writefds, fd_set *xfds) | 187 | fd_set *readfds, fd_set *writefds, fd_set *xfds) |
slirp/slirp.h
| @@ -11,6 +11,30 @@ | @@ -11,6 +11,30 @@ | ||
| 11 | #include "config.h" | 11 | #include "config.h" |
| 12 | #include "slirp_config.h" | 12 | #include "slirp_config.h" |
| 13 | 13 | ||
| 14 | +#ifdef _WIN32 | ||
| 15 | +# include <inttypes.h> | ||
| 16 | + | ||
| 17 | +typedef uint8_t u_int8_t; | ||
| 18 | +typedef uint16_t u_int16_t; | ||
| 19 | +typedef uint32_t u_int32_t; | ||
| 20 | +typedef uint64_t u_int64_t; | ||
| 21 | +typedef char *caddr_t; | ||
| 22 | + | ||
| 23 | +# include <winsock2.h> | ||
| 24 | +# include <sys/timeb.h> | ||
| 25 | +# include <iphlpapi.h> | ||
| 26 | + | ||
| 27 | +# define EWOULDBLOCK WSAEWOULDBLOCK | ||
| 28 | +# define EINPROGRESS WSAEINPROGRESS | ||
| 29 | +# define ENOTCONN WSAENOTCONN | ||
| 30 | +# define EHOSTUNREACH WSAEHOSTUNREACH | ||
| 31 | +# define ENETUNREACH WSAENETUNREACH | ||
| 32 | +# define ECONNREFUSED WSAECONNREFUSED | ||
| 33 | +#else | ||
| 34 | +# define ioctlsocket ioctl | ||
| 35 | +# define closesocket(s) close(s) | ||
| 36 | +#endif | ||
| 37 | + | ||
| 14 | #include <sys/types.h> | 38 | #include <sys/types.h> |
| 15 | #ifdef HAVE_SYS_BITYPES_H | 39 | #ifdef HAVE_SYS_BITYPES_H |
| 16 | # include <sys/bitypes.h> | 40 | # include <sys/bitypes.h> |
| @@ -79,7 +103,9 @@ typedef unsigned char u_int8_t; | @@ -79,7 +103,9 @@ typedef unsigned char u_int8_t; | ||
| 79 | # include <strings.h> | 103 | # include <strings.h> |
| 80 | #endif | 104 | #endif |
| 81 | 105 | ||
| 106 | +#ifndef _WIN32 | ||
| 82 | #include <sys/uio.h> | 107 | #include <sys/uio.h> |
| 108 | +#endif | ||
| 83 | 109 | ||
| 84 | #ifndef _P | 110 | #ifndef _P |
| 85 | #ifndef NO_PROTOTYPES | 111 | #ifndef NO_PROTOTYPES |
| @@ -89,8 +115,10 @@ typedef unsigned char u_int8_t; | @@ -89,8 +115,10 @@ typedef unsigned char u_int8_t; | ||
| 89 | #endif | 115 | #endif |
| 90 | #endif | 116 | #endif |
| 91 | 117 | ||
| 118 | +#ifndef _WIN32 | ||
| 92 | #include <netinet/in.h> | 119 | #include <netinet/in.h> |
| 93 | #include <arpa/inet.h> | 120 | #include <arpa/inet.h> |
| 121 | +#endif | ||
| 94 | 122 | ||
| 95 | #ifdef GETTIMEOFDAY_ONE_ARG | 123 | #ifdef GETTIMEOFDAY_ONE_ARG |
| 96 | #define gettimeofday(x, y) gettimeofday(x) | 124 | #define gettimeofday(x, y) gettimeofday(x) |
| @@ -119,7 +147,9 @@ int inet_aton _P((const char *cp, struct in_addr *ia)); | @@ -119,7 +147,9 @@ int inet_aton _P((const char *cp, struct in_addr *ia)); | ||
| 119 | #ifdef HAVE_SYS_SIGNAL_H | 147 | #ifdef HAVE_SYS_SIGNAL_H |
| 120 | # include <sys/signal.h> | 148 | # include <sys/signal.h> |
| 121 | #endif | 149 | #endif |
| 150 | +#ifndef _WIN32 | ||
| 122 | #include <sys/socket.h> | 151 | #include <sys/socket.h> |
| 152 | +#endif | ||
| 123 | 153 | ||
| 124 | #if defined(HAVE_SYS_IOCTL_H) | 154 | #if defined(HAVE_SYS_IOCTL_H) |
| 125 | # include <sys/ioctl.h> | 155 | # include <sys/ioctl.h> |
| @@ -232,8 +262,9 @@ extern int do_echo; | @@ -232,8 +262,9 @@ extern int do_echo; | ||
| 232 | inline void remque_32 _P((void *)); | 262 | inline void remque_32 _P((void *)); |
| 233 | #endif | 263 | #endif |
| 234 | 264 | ||
| 235 | -#include <pwd.h> | 265 | +#ifndef _WIN32 |
| 236 | #include <netdb.h> | 266 | #include <netdb.h> |
| 267 | +#endif | ||
| 237 | 268 | ||
| 238 | #define DEFAULT_BAUD 115200 | 269 | #define DEFAULT_BAUD 115200 |
| 239 | 270 | ||
| @@ -292,4 +323,9 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err); | @@ -292,4 +323,9 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err); | ||
| 292 | #define MAX_MRU 16384 | 323 | #define MAX_MRU 16384 |
| 293 | #endif | 324 | #endif |
| 294 | 325 | ||
| 326 | +#ifndef _WIN32 | ||
| 327 | +#define min(x,y) ((x) < (y) ? (x) : (y)) | ||
| 328 | +#define max(x,y) ((x) > (y) ? (x) : (y)) | ||
| 329 | +#endif | ||
| 330 | + | ||
| 295 | #endif | 331 | #endif |
slirp/slirp_config.h
| @@ -61,7 +61,10 @@ | @@ -61,7 +61,10 @@ | ||
| 61 | #define HAVE_STDLIB_H | 61 | #define HAVE_STDLIB_H |
| 62 | 62 | ||
| 63 | /* Define if you have sys/ioctl.h */ | 63 | /* Define if you have sys/ioctl.h */ |
| 64 | +#undef HAVE_SYS_IOCTL_H | ||
| 65 | +#ifndef _WIN32 | ||
| 64 | #define HAVE_SYS_IOCTL_H | 66 | #define HAVE_SYS_IOCTL_H |
| 67 | +#endif | ||
| 65 | 68 | ||
| 66 | /* Define if you have sys/filio.h */ | 69 | /* Define if you have sys/filio.h */ |
| 67 | #undef HAVE_SYS_FILIO_H | 70 | #undef HAVE_SYS_FILIO_H |
| @@ -93,6 +96,9 @@ | @@ -93,6 +96,9 @@ | ||
| 93 | 96 | ||
| 94 | /* Define if iovec needs to be declared */ | 97 | /* Define if iovec needs to be declared */ |
| 95 | #undef DECLARE_IOVEC | 98 | #undef DECLARE_IOVEC |
| 99 | +#ifdef _WIN32 | ||
| 100 | +#define DECLARE_IOVEC | ||
| 101 | +#endif | ||
| 96 | 102 | ||
| 97 | /* Define if a declaration of sprintf/fprintf is needed */ | 103 | /* Define if a declaration of sprintf/fprintf is needed */ |
| 98 | #undef DECLARE_SPRINTF | 104 | #undef DECLARE_SPRINTF |
| @@ -101,13 +107,19 @@ | @@ -101,13 +107,19 @@ | ||
| 101 | #undef HAVE_SYS_WAIT_H | 107 | #undef HAVE_SYS_WAIT_H |
| 102 | 108 | ||
| 103 | /* Define if you have sys/select.h */ | 109 | /* Define if you have sys/select.h */ |
| 110 | +#undef HAVE_SYS_SELECT_H | ||
| 111 | +#ifndef _WIN32 | ||
| 104 | #define HAVE_SYS_SELECT_H | 112 | #define HAVE_SYS_SELECT_H |
| 113 | +#endif | ||
| 105 | 114 | ||
| 106 | /* Define if you have strings.h */ | 115 | /* Define if you have strings.h */ |
| 107 | #define HAVE_STRING_H | 116 | #define HAVE_STRING_H |
| 108 | 117 | ||
| 109 | /* Define if you have arpa/inet.h */ | 118 | /* Define if you have arpa/inet.h */ |
| 119 | +#undef HAVE_ARPA_INET_H | ||
| 120 | +#ifndef _WIN32 | ||
| 110 | #define HAVE_ARPA_INET_H | 121 | #define HAVE_ARPA_INET_H |
| 122 | +#endif | ||
| 111 | 123 | ||
| 112 | /* Define if you have sys/signal.h */ | 124 | /* Define if you have sys/signal.h */ |
| 113 | #undef HAVE_SYS_SIGNAL_H | 125 | #undef HAVE_SYS_SIGNAL_H |
| @@ -147,7 +159,10 @@ | @@ -147,7 +159,10 @@ | ||
| 147 | #undef HAVE_SRANDOM | 159 | #undef HAVE_SRANDOM |
| 148 | 160 | ||
| 149 | /* Define if you have inet_aton */ | 161 | /* Define if you have inet_aton */ |
| 162 | +#undef HAVE_INET_ATON | ||
| 163 | +#ifndef _WIN32 | ||
| 150 | #define HAVE_INET_ATON | 164 | #define HAVE_INET_ATON |
| 165 | +#endif | ||
| 151 | 166 | ||
| 152 | /* Define if you have setenv */ | 167 | /* Define if you have setenv */ |
| 153 | #undef HAVE_SETENV | 168 | #undef HAVE_SETENV |
| @@ -169,6 +184,9 @@ | @@ -169,6 +184,9 @@ | ||
| 169 | 184 | ||
| 170 | /* Define if you DON'T have unix-domain sockets */ | 185 | /* Define if you DON'T have unix-domain sockets */ |
| 171 | #undef NO_UNIX_SOCKETS | 186 | #undef NO_UNIX_SOCKETS |
| 187 | +#ifdef _WIN32 | ||
| 188 | +#define NO_UNIX_SOCKETS | ||
| 189 | +#endif | ||
| 172 | 190 | ||
| 173 | /* Define if gettimeofday only takes one argument */ | 191 | /* Define if gettimeofday only takes one argument */ |
| 174 | #undef GETTIMEOFDAY_ONE_ARG | 192 | #undef GETTIMEOFDAY_ONE_ARG |
slirp/socket.c
| @@ -418,7 +418,7 @@ sorecvfrom(so) | @@ -418,7 +418,7 @@ sorecvfrom(so) | ||
| 418 | */ | 418 | */ |
| 419 | len = M_FREEROOM(m); | 419 | len = M_FREEROOM(m); |
| 420 | /* if (so->so_fport != htons(53)) { */ | 420 | /* if (so->so_fport != htons(53)) { */ |
| 421 | - ioctl(so->s, FIONREAD, &n); | 421 | + ioctlsocket(so->s, FIONREAD, &n); |
| 422 | 422 | ||
| 423 | if (n > len) { | 423 | if (n > len) { |
| 424 | n = (m->m_data - m->m_dat) + m->m_len + n + 1; | 424 | n = (m->m_data - m->m_dat) + m->m_len + n + 1; |
slirp/tcp_input.c
| @@ -47,9 +47,6 @@ | @@ -47,9 +47,6 @@ | ||
| 47 | 47 | ||
| 48 | struct socket tcb; | 48 | struct socket tcb; |
| 49 | 49 | ||
| 50 | -#define min(x,y) ((x) < (y) ? (x) : (y)) | ||
| 51 | -#define max(x,y) ((x) > (y) ? (x) : (y)) | ||
| 52 | - | ||
| 53 | int tcprexmtthresh = 3; | 50 | int tcprexmtthresh = 3; |
| 54 | struct socket *tcp_last_so = &tcb; | 51 | struct socket *tcp_last_so = &tcb; |
| 55 | 52 |
slirp/tcp_output.c
| @@ -44,9 +44,6 @@ | @@ -44,9 +44,6 @@ | ||
| 44 | 44 | ||
| 45 | #include <slirp.h> | 45 | #include <slirp.h> |
| 46 | 46 | ||
| 47 | -#define max(x,y) ((x) > (y) ? (x) : (y)) | ||
| 48 | -#define min(x,y) ((x) < (y) ? (x) : (y)) | ||
| 49 | - | ||
| 50 | /* | 47 | /* |
| 51 | * Since this is only used in "stats socket", we give meaning | 48 | * Since this is only used in "stats socket", we give meaning |
| 52 | * names instead of the REAL names | 49 | * names instead of the REAL names |
slirp/tcp_subr.c
| @@ -301,7 +301,7 @@ tcp_close(tp) | @@ -301,7 +301,7 @@ tcp_close(tp) | ||
| 301 | /* clobber input socket cache if we're closing the cached connection */ | 301 | /* clobber input socket cache if we're closing the cached connection */ |
| 302 | if (so == tcp_last_so) | 302 | if (so == tcp_last_so) |
| 303 | tcp_last_so = &tcb; | 303 | tcp_last_so = &tcb; |
| 304 | - close(so->s); | 304 | + closesocket(so->s); |
| 305 | sbfree(&so->so_rcv); | 305 | sbfree(&so->so_rcv); |
| 306 | sbfree(&so->so_snd); | 306 | sbfree(&so->so_snd); |
| 307 | sofree(so); | 307 | sofree(so); |
| @@ -477,7 +477,7 @@ tcp_connect(inso) | @@ -477,7 +477,7 @@ tcp_connect(inso) | ||
| 477 | } else { | 477 | } else { |
| 478 | if ((so = socreate()) == NULL) { | 478 | if ((so = socreate()) == NULL) { |
| 479 | /* If it failed, get rid of the pending connection */ | 479 | /* If it failed, get rid of the pending connection */ |
| 480 | - close(accept(inso->s,(struct sockaddr *)&addr,&addrlen)); | 480 | + closesocket(accept(inso->s,(struct sockaddr *)&addr,&addrlen)); |
| 481 | return; | 481 | return; |
| 482 | } | 482 | } |
| 483 | if (tcp_attach(so) < 0) { | 483 | if (tcp_attach(so) < 0) { |
| @@ -508,7 +508,7 @@ tcp_connect(inso) | @@ -508,7 +508,7 @@ tcp_connect(inso) | ||
| 508 | 508 | ||
| 509 | /* Close the accept() socket, set right state */ | 509 | /* Close the accept() socket, set right state */ |
| 510 | if (inso->so_state & SS_FACCEPTONCE) { | 510 | if (inso->so_state & SS_FACCEPTONCE) { |
| 511 | - close(so->s); /* If we only accept once, close the accept() socket */ | 511 | + closesocket(so->s); /* If we only accept once, close the accept() socket */ |
| 512 | so->so_state = SS_NOFDREF; /* Don't select it yet, even though we have an FD */ | 512 | so->so_state = SS_NOFDREF; /* Don't select it yet, even though we have an FD */ |
| 513 | /* if it's not FACCEPTONCE, it's already NOFDREF */ | 513 | /* if it's not FACCEPTONCE, it's already NOFDREF */ |
| 514 | } | 514 | } |
slirp/tcp_timer.c
| @@ -36,9 +36,6 @@ | @@ -36,9 +36,6 @@ | ||
| 36 | 36 | ||
| 37 | #include <slirp.h> | 37 | #include <slirp.h> |
| 38 | 38 | ||
| 39 | -#define max(x,y) ((x) > (y) ? (x) : (y)) | ||
| 40 | -#define min(x,y) ((x) < (y) ? (x) : (y)) | ||
| 41 | - | ||
| 42 | int tcp_keepidle = TCPTV_KEEP_IDLE; | 39 | int tcp_keepidle = TCPTV_KEEP_IDLE; |
| 43 | int tcp_keepintvl = TCPTV_KEEPINTVL; | 40 | int tcp_keepintvl = TCPTV_KEEPINTVL; |
| 44 | int tcp_maxidle; | 41 | int tcp_maxidle; |
slirp/udp.c
| @@ -329,7 +329,7 @@ udp_attach(so) | @@ -329,7 +329,7 @@ udp_attach(so) | ||
| 329 | addr.sin_addr.s_addr = INADDR_ANY; | 329 | addr.sin_addr.s_addr = INADDR_ANY; |
| 330 | if(bind(so->s, (struct sockaddr *)&addr, sizeof(addr))<0) { | 330 | if(bind(so->s, (struct sockaddr *)&addr, sizeof(addr))<0) { |
| 331 | int lasterrno=errno; | 331 | int lasterrno=errno; |
| 332 | - close(so->s); | 332 | + closesocket(so->s); |
| 333 | so->s=-1; | 333 | so->s=-1; |
| 334 | errno=lasterrno; | 334 | errno=lasterrno; |
| 335 | } else { | 335 | } else { |
| @@ -345,7 +345,7 @@ void | @@ -345,7 +345,7 @@ void | ||
| 345 | udp_detach(so) | 345 | udp_detach(so) |
| 346 | struct socket *so; | 346 | struct socket *so; |
| 347 | { | 347 | { |
| 348 | - close(so->s); | 348 | + closesocket(so->s); |
| 349 | /* if (so->so_m) m_free(so->so_m); done by sofree */ | 349 | /* if (so->so_m) m_free(so->so_m); done by sofree */ |
| 350 | 350 | ||
| 351 | sofree(so); | 351 | sofree(so); |
| @@ -527,7 +527,7 @@ struct cu_header { | @@ -527,7 +527,7 @@ struct cu_header { | ||
| 527 | addr.sin_port = htons(518); | 527 | addr.sin_port = htons(518); |
| 528 | sendto(s, (char *)nmsg, sizeof(*nmsg), 0, | 528 | sendto(s, (char *)nmsg, sizeof(*nmsg), 0, |
| 529 | (struct sockaddr *) &addr, sizeof(addr)); | 529 | (struct sockaddr *) &addr, sizeof(addr)); |
| 530 | - close(s) ; | 530 | + closesocket(s) ; |
| 531 | 531 | ||
| 532 | omsg->type = nmsg->type = ANNOUNCE; | 532 | omsg->type = nmsg->type = ANNOUNCE; |
| 533 | OTOSIN(omsg, ctl_addr)->sin_port = temp_port; | 533 | OTOSIN(omsg, ctl_addr)->sin_port = temp_port; |
| @@ -558,7 +558,7 @@ struct cu_header { | @@ -558,7 +558,7 @@ struct cu_header { | ||
| 558 | addr.sin_port = htons(518); | 558 | addr.sin_port = htons(518); |
| 559 | sendto(s, (char *)nmsg, sizeof(*nmsg), 0, | 559 | sendto(s, (char *)nmsg, sizeof(*nmsg), 0, |
| 560 | (struct sockaddr *)&addr, sizeof(addr)); | 560 | (struct sockaddr *)&addr, sizeof(addr)); |
| 561 | - close(s); | 561 | + closesocket(s); |
| 562 | 562 | ||
| 563 | OTOSIN(omsg, ctl_addr)->sin_port = temp_port; | 563 | OTOSIN(omsg, ctl_addr)->sin_port = temp_port; |
| 564 | OTOSIN(nmsg, ctl_addr)->sin_port = temp_port; | 564 | OTOSIN(nmsg, ctl_addr)->sin_port = temp_port; |