From: Martin Willi Date: Fri, 9 May 2014 08:17:03 +0000 (+0200) Subject: windows: Provide POSIX supplement errno values missing in MinGW X-Git-Tag: 5.2.0dr6~24^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7659f67af3d32e65a3099dcbb688f11734d8a0ad;p=thirdparty%2Fstrongswan.git windows: Provide POSIX supplement errno values missing in MinGW MinGW headers do not define these values, but Windows system headers do. Windows defines them for POSIX compatibility, we do the same locally. --- diff --git a/src/libstrongswan/utils/windows.c b/src/libstrongswan/utils/windows.c index c0ae3d87a2..741d199ec3 100644 --- a/src/libstrongswan/utils/windows.c +++ b/src/libstrongswan/utils/windows.c @@ -322,9 +322,13 @@ static int wserr(int retval) errno = EBADF; break; case WSAENETDOWN: + errno = ENETDOWN; + break; case WSAENETRESET: + errno = ENETRESET; + break; case WSAESHUTDOWN: - errno = EPIPE; + errno = ECONNABORTED; break; case WSAEACCES: errno = EACCES; @@ -333,37 +337,43 @@ static int wserr(int retval) errno = EINTR; break; case WSAEINPROGRESS: - errno = EBUSY; + errno = EINPROGRESS; break; case WSAEFAULT: errno = EFAULT; break; case WSAENOBUFS: - errno = ENOMEM; + errno = ENOBUFS; break; case WSAENOTSOCK: - errno = EINVAL; + errno = ENOTSOCK; break; case WSAEOPNOTSUPP: - errno = ENOSYS; + errno = EOPNOTSUPP; break; case WSAEWOULDBLOCK: errno = EWOULDBLOCK; break; case WSAEMSGSIZE: - errno = ENOSPC; + errno = EMSGSIZE; break; case WSAEINVAL: errno = EINVAL; break; case WSAENOTCONN: + errno = ENOTCONN; + break; case WSAEHOSTUNREACH: + errno = EHOSTUNREACH; + break; case WSAECONNABORTED: + errno = ECONNABORTED; + break; case WSAECONNRESET: - errno = EIO; + errno = ECONNRESET; break; case WSAETIMEDOUT: - errno = ESRCH; + errno = ETIMEDOUT; break; default: errno = ENOENT; diff --git a/src/libstrongswan/utils/windows.h b/src/libstrongswan/utils/windows.h index 766050d236..b661386449 100644 --- a/src/libstrongswan/utils/windows.h +++ b/src/libstrongswan/utils/windows.h @@ -265,21 +265,6 @@ char* getpass(const char *prompt); */ #define MSG_DONTWAIT MSG_INTERRUPT -/** - * EWOULDBLOCK is EAGAIN on other systems as well - */ -#ifndef EWOULDBLOCK -#define EWOULDBLOCK EAGAIN -#endif - -/** - * ECONNRESET is mapped to something arbitrary. It is returned by - * stream->read_all() but should not be mapped from a send/recv WSA error. - */ -#ifndef ECONNRESET -#define ECONNRESET ENXIO -#endif - /** * shutdown(2) "how"-aliases, to use Unix variant on Windows */ @@ -319,6 +304,135 @@ ssize_t windows_send(int sockfd, const void *buf, size_t len, int flags); ssize_t windows_sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); +/** + * MinGW does provide extended errno values. Windows itself knowns them + * for POSIX compatibility; we define them as well. + */ +#ifndef EADDRINUSE +#define EADDRINUSE 100 +#endif +#ifndef EADDRNOTAVAIL +#define EADDRNOTAVAIL 101 +#endif +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT 102 +#endif +#ifndef EALREADY +#define EALREADY 103 +#endif +#ifndef EBADMSG +#define EBADMSG 104 +#endif +#ifndef ECANCELED +#define ECANCELED 105 +#endif +#ifndef ECONNABORTED +#define ECONNABORTED 106 +#endif +#ifndef ECONNREFUSED +#define ECONNREFUSED 107 +#endif +#ifndef ECONNRESET +#define ECONNRESET 108 +#endif +#ifndef EDESTADDRREQ +#define EDESTADDRREQ 109 +#endif +#ifndef EHOSTUNREACH +#define EHOSTUNREACH 110 +#endif +#ifndef EIDRM +#define EIDRM 111 +#endif +#ifndef EINPROGRESS +#define EINPROGRESS 112 +#endif +#ifndef EISCONN +#define EISCONN 113 +#endif +#ifndef ELOOP +#define ELOOP 114 +#endif +#ifndef EMSGSIZE +#define EMSGSIZE 115 +#endif +#ifndef ENETDOWN +#define ENETDOWN 116 +#endif +#ifndef ENETRESET +#define ENETRESET 117 +#endif +#ifndef ENETUNREACH +#define ENETUNREACH 118 +#endif +#ifndef ENOBUFS +#define ENOBUFS 119 +#endif +#ifndef ENODATA +#define ENODATA 120 +#endif +#ifndef ENOLINK +#define ENOLINK 121 +#endif +#ifndef ENOMSG +#define ENOMSG 122 +#endif +#ifndef ENOPROTOOPT +#define ENOPROTOOPT 123 +#endif +#ifndef ENOSR +#define ENOSR 124 +#endif +#ifndef ENOSTR +#define ENOSTR 125 +#endif +#ifndef ENOTCONN +#define ENOTCONN 126 +#endif +#ifndef ENOTRECOVERABLE +#define ENOTRECOVERABLE 127 +#endif +#ifndef ENOTSOCK +#define ENOTSOCK 128 +#endif +#ifndef ENOTSUP +#define ENOTSUP 129 +#endif +#ifndef EOPNOTSUPP +#define EOPNOTSUPP 130 +#endif +#ifndef EOTHER +#define EOTHER 131 +#endif +#ifndef EOVERFLOW +#define EOVERFLOW 132 +#endif +#ifndef EOWNERDEAD +#define EOWNERDEAD 133 +#endif +#ifndef EPROTO +#define EPROTO 134 +#endif +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT 135 +#endif +#ifndef EPROTOTYPE +#define EPROTOTYPE 136 +#endif +#ifndef ETIME +#define ETIME 137 +#endif +#ifndef ETIMEDOUT +#define ETIMEDOUT 138 +#endif +#ifndef ETXTBSY +#define ETXTBSY 139 +#endif +#ifndef EWOULDBLOCK +#define EWOULDBLOCK 140 +#endif + + /* Windows does not support "ll" format printf length modifiers. Mingw * therefore maps these to the Windows specific I64 length modifier. That * won't work for us, as we use our own printf backend on Windows, which works