From 6134c9bc7094e7958f601135d4e70be6eaaa3774 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 1 Apr 2017 20:11:26 +0300 Subject: [PATCH] Slirp cleanups. --- slirp/ip_input.cpp | 2 +- slirp/slirp.cpp | 4 ++-- slirp/slirp.h | 14 +++++++++++++- slirp/tcp_input.cpp | 2 +- slirp/udp.cpp | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/slirp/ip_input.cpp b/slirp/ip_input.cpp index 9705c7e7..9f06064c 100644 --- a/slirp/ip_input.cpp +++ b/slirp/ip_input.cpp @@ -81,7 +81,7 @@ void ip_input(struct mbuf *m) DEBUG_CALL("ip_input"); DEBUG_ARG("m = %p", m); - DEBUG_ARG("m_len = %d", m->m_len); + DEBUG_ARG("m_len = %zu", m->m_len); ipstat.ips_total++; diff --git a/slirp/slirp.cpp b/slirp/slirp.cpp index 55059b35..b5b55835 100644 --- a/slirp/slirp.cpp +++ b/slirp/slirp.cpp @@ -121,13 +121,13 @@ static int get_dns_addr(struct in_addr *pdns_addr) #endif -static int inited; - int slirp_init(void) { // debug_init("/tmp/slirp.log", DEBUG_DEFAULT); #ifdef _WIN32 + static int inited; + if (!inited) { WSADATA Data; WSAStartup(MAKEWORD(2,0), &Data); diff --git a/slirp/slirp.h b/slirp/slirp.h index 945e0d7a..77b2e318 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -50,8 +50,20 @@ typedef unsigned long ioctlsockopt_t; # define write_udp slirp_write_udp # define init_udp slirp_init_udp # define final_udp slirp_final_udp -#else +#else //!_WIN32 typedef int ioctlsockopt_t; + +# define WSAGetLastError() (int)(errno) +# define WSASetLastError(e) (void)(errno = (e)) +# define WSAEWOULDBLOCK EWOULDBLOCK +# define WSAEINPROGRESS EINPROGRESS +# define WSAENOTCONN ENOTCONN +# define WSAEHOSTUNREACH EHOSTUNREACH +# define WSAENETUNREACH ENETUNREACH +# define WSAECONNREFUSED ECONNREFUSED + +# define SLIRP_SOCKET int + # define ioctlsocket ioctl # define closesocket(s) close(s) # define O_BINARY 0 diff --git a/slirp/tcp_input.cpp b/slirp/tcp_input.cpp index ae5331bb..6973ffb4 100644 --- a/slirp/tcp_input.cpp +++ b/slirp/tcp_input.cpp @@ -1072,7 +1072,7 @@ findso: if (ti->ti_len == 0 && tiwin == tp->snd_wnd) { tcpstat.tcps_rcvdupack++; DEBUG_MISC((" dup ack m = %p so = %p \n", - (long)m, (long)so)); + m, so)); /* * If we have outstanding data (other than * a window probe), this is a completely diff --git a/slirp/udp.cpp b/slirp/udp.cpp index fc30fb95..b82c13ae 100644 --- a/slirp/udp.cpp +++ b/slirp/udp.cpp @@ -341,7 +341,7 @@ SLIRP_SOCKET udp_attach(struct socket *so) if(bind(so->s, (struct sockaddr *)&addr, sizeof(addr))<0) { int error = WSAGetLastError(); closesocket(so->s); - so->s =- 1; + so->s = -1; WSASetLastError(error); } else { /* success, insert in queue */ -- 2.47.3