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