]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
windows: Provide POSIX supplement errno values missing in MinGW
authorMartin Willi <martin@revosec.ch>
Fri, 9 May 2014 08:17:03 +0000 (10:17 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 4 Jun 2014 13:53:12 +0000 (15:53 +0200)
MinGW headers do not define these values, but Windows system headers do.
Windows defines them for POSIX compatibility, we do the same locally.

src/libstrongswan/utils/windows.c
src/libstrongswan/utils/windows.h

index c0ae3d87a2f6261f8bc265ddcf581a0194827def..741d199ec340314ed137dd8f1105fd0e6c68978c 100644 (file)
@@ -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;
index 766050d23628ff3bce652534bd47e98f3407487e..b6613864495282c24decc52a825c7919f76710a2 100644 (file)
@@ -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