1 /*	$NetBSD: nt_err.c,v 1.3 2021/08/14 16:14:55 christos Exp $	*/
2 
3 /* $OpenLDAP$ */
4 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5  *
6  * Copyright 1998-2021 The OpenLDAP Foundation.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted only as authorized by the OpenLDAP
11  * Public License.
12  *
13  * A copy of this license is available in the file LICENSE in the
14  * top-level directory of the distribution or, alternatively, at
15  * <http://www.OpenLDAP.org/license.html>.
16  */
17 
18 #include <sys/cdefs.h>
19 __RCSID("$NetBSD: nt_err.c,v 1.3 2021/08/14 16:14:55 christos Exp $");
20 
21 #include "portable.h"
22 
23 #ifdef HAVE_WINSOCK2
24 #include <winsock2.h>
25 #elif defined(HAVE_WINSOCK)
26 #include <winsock.h>
27 #endif /* HAVE_WINSOCK(2) */
28 
29 #define LBER_RETSTR( x ) case x: return #x;
30 
ber_pvt_wsa_err2string(int err)31 char *ber_pvt_wsa_err2string( int err )
32 {
33 	switch( err ) {
34 		LBER_RETSTR( WSAEINTR )
35 		LBER_RETSTR( WSAEBADF )
36 		LBER_RETSTR( WSAEACCES )
37 		LBER_RETSTR( WSAEFAULT )
38 		LBER_RETSTR( WSAEINVAL )
39 		LBER_RETSTR( WSAEMFILE )
40 		LBER_RETSTR( WSAEWOULDBLOCK )
41 		LBER_RETSTR( WSAEINPROGRESS )
42 		LBER_RETSTR( WSAEALREADY )
43 		LBER_RETSTR( WSAENOTSOCK )
44 		LBER_RETSTR( WSAEDESTADDRREQ )
45 		LBER_RETSTR( WSAEMSGSIZE )
46 		LBER_RETSTR( WSAEPROTOTYPE )
47 		LBER_RETSTR( WSAENOPROTOOPT )
48 		LBER_RETSTR( WSAEPROTONOSUPPORT )
49 		LBER_RETSTR( WSAESOCKTNOSUPPORT )
50 		LBER_RETSTR( WSAEOPNOTSUPP )
51 		LBER_RETSTR( WSAEPFNOSUPPORT )
52 		LBER_RETSTR( WSAEAFNOSUPPORT )
53 		LBER_RETSTR( WSAEADDRINUSE )
54 		LBER_RETSTR( WSAEADDRNOTAVAIL )
55 		LBER_RETSTR( WSAENETDOWN )
56 		LBER_RETSTR( WSAENETUNREACH )
57 		LBER_RETSTR( WSAENETRESET )
58 		LBER_RETSTR( WSAECONNABORTED )
59 		LBER_RETSTR( WSAECONNRESET )
60 		LBER_RETSTR( WSAENOBUFS )
61 		LBER_RETSTR( WSAEISCONN )
62 		LBER_RETSTR( WSAENOTCONN )
63 		LBER_RETSTR( WSAESHUTDOWN )
64 		LBER_RETSTR( WSAETOOMANYREFS )
65 		LBER_RETSTR( WSAETIMEDOUT )
66 		LBER_RETSTR( WSAECONNREFUSED )
67 		LBER_RETSTR( WSAELOOP )
68 		LBER_RETSTR( WSAENAMETOOLONG )
69 		LBER_RETSTR( WSAEHOSTDOWN )
70 		LBER_RETSTR( WSAEHOSTUNREACH )
71 		LBER_RETSTR( WSAENOTEMPTY )
72 		LBER_RETSTR( WSAEPROCLIM )
73 		LBER_RETSTR( WSAEUSERS )
74 		LBER_RETSTR( WSAEDQUOT )
75 		LBER_RETSTR( WSAESTALE )
76 		LBER_RETSTR( WSAEREMOTE )
77 		LBER_RETSTR( WSASYSNOTREADY )
78 		LBER_RETSTR( WSAVERNOTSUPPORTED )
79 		LBER_RETSTR( WSANOTINITIALISED )
80 		LBER_RETSTR( WSAEDISCON )
81 
82 #ifdef HAVE_WINSOCK2
83 		LBER_RETSTR( WSAENOMORE )
84 		LBER_RETSTR( WSAECANCELLED )
85 		LBER_RETSTR( WSAEINVALIDPROCTABLE )
86 		LBER_RETSTR( WSAEINVALIDPROVIDER )
87 		LBER_RETSTR( WSASYSCALLFAILURE )
88 		LBER_RETSTR( WSASERVICE_NOT_FOUND )
89 		LBER_RETSTR( WSATYPE_NOT_FOUND )
90 		LBER_RETSTR( WSA_E_NO_MORE )
91 		LBER_RETSTR( WSA_E_CANCELLED )
92 		LBER_RETSTR( WSAEREFUSED )
93 #endif /* HAVE_WINSOCK2	*/
94 
95 		LBER_RETSTR( WSAHOST_NOT_FOUND )
96 		LBER_RETSTR( WSATRY_AGAIN )
97 		LBER_RETSTR( WSANO_RECOVERY )
98 		LBER_RETSTR( WSANO_DATA )
99 	}
100 	return "unknown WSA error";
101 }
102