1 /*****************************************************************************
2 * error.c: Network error handling
3 *****************************************************************************
4 * Copyright (C) 2006 Rémi Denis-Courmont
7 * Author : Rémi Denis-Courmont <rem # videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
29 #include <vlc_network.h>
31 #if defined (WIN32) || defined (UNDER_CE)
38 static const wsaerrmsg_t wsaerrmsg[] =
40 { WSA_INVALID_HANDLE, "Specified event object handle is invalid" },
41 { WSA_NOT_ENOUGH_MEMORY, "Insufficient memory available" },
42 { WSA_INVALID_PARAMETER, "One or more parameters are invalid" },
43 { WSA_OPERATION_ABORTED, "Overlapped operation aborted" },
44 { WSA_IO_INCOMPLETE, "Overlapped I/O event object not in signaled state" },
45 { WSA_IO_PENDING, "Overlapped operations will complete later" },
46 { WSAEINTR, "Interrupted function call" },
47 { WSAEBADF, "File handle is not valid" },
48 { WSAEACCES, "Access denied" },
49 { WSAEFAULT, "Invalid memory address" },
50 { WSAEINVAL, "Invalid argument" },
51 { WSAEMFILE, "Too many open sockets" },
52 { WSAEWOULDBLOCK, "Resource temporarily unavailable" },
53 { WSAEINPROGRESS, "Operation now in progress" },
54 { WSAEALREADY, "Operation already in progress" },
55 { WSAENOTSOCK, "Non-socket handle specified" },
56 { WSAEDESTADDRREQ, "Missing destination address" },
57 { WSAEMSGSIZE, "Message too long" },
58 { WSAEPROTOTYPE, "Protocol wrong type for socket", },
59 { WSAENOPROTOOPT, "Option not supported by protocol" },
60 { WSAEPROTONOSUPPORT, "Protocol not supported" },
61 { WSAESOCKTNOSUPPORT, "Socket type not supported" },
62 { WSAEOPNOTSUPP, "Operation not supported" },
63 { WSAEPFNOSUPPORT, "Protocol family not supported" },
64 { WSAEAFNOSUPPORT, "Address family not supported by protocol family" },
65 { WSAEADDRINUSE, "Address already in use" },
66 { WSAEADDRNOTAVAIL, "Cannot assign requested address" },
67 { WSAENETDOWN, "Network is down" },
68 { WSAENETUNREACH, "Network unreachable" },
69 { WSAENETRESET, "Network dropped connection on reset" },
70 { WSAECONNABORTED, "Software caused connection abort" },
71 { WSAECONNRESET, "Connection reset by peer" },
72 { WSAENOBUFS, "No buffer space available (not enough memory)" },
73 { WSAEISCONN, "Socket is already connected" },
74 { WSAENOTCONN, "Socket is not connected" },
75 { WSAESHUTDOWN, "Cannot send after socket shutdown" },
76 { WSAETOOMANYREFS, "Too many references" },
77 { WSAETIMEDOUT, "Connection timed out" },
78 { WSAECONNREFUSED, "Connection refused by peer" },
79 { WSAELOOP, "Cannot translate name" },
80 { WSAENAMETOOLONG, "Name too long" },
81 { WSAEHOSTDOWN, "Remote host is down" },
82 { WSAEHOSTUNREACH, "No route to host (unreachable)" },
83 { WSAENOTEMPTY, "Directory not empty" },
84 { WSAEPROCLIM, "Too many processes" },
85 { WSAEUSERS, "User quota exceeded" },
86 { WSAEDQUOT, "Disk quota exceeded" },
87 { WSAESTALE, "Stale file handle reference" },
88 { WSAEREMOTE, "Item is remote", },
89 { WSASYSNOTREADY, "Network subsystem is unavailable (network stack not ready)" },
90 { WSAVERNOTSUPPORTED, "Winsock.dll version out of range (network stack version not supported" },
91 { WSANOTINITIALISED, "Network not initialized" },
92 { WSAEDISCON, "Graceful shutdown in progress" },
93 { WSAENOMORE, "No more results" },
94 { WSAECANCELLED, "Call has been cancelled" },
95 { WSAEINVALIDPROCTABLE, "Procedure call table is invalid" },
96 { WSAEINVALIDPROVIDER, "Service provider is invalid" },
97 { WSAEPROVIDERFAILEDINIT, "Service provider failed to initialize" },
98 { WSASYSCALLFAILURE, "System call failure" },
99 { WSASERVICE_NOT_FOUND, "Service not found" },
100 { WSATYPE_NOT_FOUND, "Class type not found" },
101 { WSA_E_NO_MORE, "No more results" },
102 { WSA_E_CANCELLED, "Call was cancelled" },
103 { WSAEREFUSED, "Database query was refused" },
104 { WSAHOST_NOT_FOUND, "Host not found" },
105 { WSATRY_AGAIN, "Nonauthoritative host not found (temporary hostname error)" },
106 { WSANO_RECOVERY, "Non-recoverable hostname error" },
107 { WSANO_DATA, "Valid name, no data record of requested type" },
108 { WSA_QOS_RECEIVERS, "QOS receivers" },
109 { WSA_QOS_SENDERS, "QOS senders" },
110 { WSA_QOS_NO_SENDERS, "No QOS senders" },
111 { WSA_QOS_NO_RECEIVERS, "QOS no receivers" },
112 { WSA_QOS_REQUEST_CONFIRMED, "QOS request confirmed" },
113 { WSA_QOS_ADMISSION_FAILURE, "QOS admission error" },
114 { WSA_QOS_POLICY_FAILURE, "QOS policy failure" },
115 { WSA_QOS_BAD_STYLE, "QOS bad style" },
116 { WSA_QOS_BAD_OBJECT, "QOS bad object" },
117 { WSA_QOS_TRAFFIC_CTRL_ERROR, "QOS traffic control error" },
118 { WSA_QOS_GENERIC_ERROR, "QOS generic error" },
119 { WSA_QOS_ESERVICETYPE, "QOS service type error" },
120 { WSA_QOS_EFLOWSPEC, "QOS flowspec error" },
121 { WSA_QOS_EPROVSPECBUF, "Invalid QOS provider buffer" },
122 { WSA_QOS_EFILTERSTYLE, "Invalid QOS filter style" },
123 { WSA_QOS_EFILTERTYPE, "Invalid QOS filter type" },
124 { WSA_QOS_EFILTERCOUNT, "Incorrect QOS filter count" },
125 { WSA_QOS_EOBJLENGTH, "Invalid QOS object length" },
126 { WSA_QOS_EFLOWCOUNT, "Incorrect QOS flow count" },
127 { WSA_QOS_EUNKNOWNPSOBJ, "Unrecognized QOS object" },
128 { WSA_QOS_EPOLICYOBJ, "Invalid QOS policy object" },
129 { WSA_QOS_EFLOWDESC, "Invalid QOS flow descriptor" },
130 { WSA_QOS_EPSFLOWSPEC, "Invalid QOS provider-specific flowspec" },
131 { WSA_QOS_EPSFILTERSPEC, "Invalid QOS provider-specific filterspec" },
132 { WSA_QOS_ESDMODEOBJ, "Invalid QOS shape discard mode object" },
133 { WSA_QOS_ESHAPERATEOBJ, "Invalid QOS shaping rate object" },
134 { WSA_QOS_RESERVED_PETYPE, "Reserved policy QOS element type" },
136 /* Winsock2 error codes are missing, they "never" occur */
140 const char *net_strerror( int value )
142 /* There doesn't seem to be any portable error message generation for
143 * Winsock errors. Some old versions had s_error, but it appears to be
144 * gone, and is not documented.
146 for( const wsaerrmsg_t *e = wsaerrmsg; e->msg != NULL; e++ )
147 if( e->code == value )
150 /* Remember to update src/misc/messages.c if you change this one */
151 return "Unknown network stack error";