]> git.sesse.net Git - vlc/blob - src/network/error.c
71b423f1dd36b0ff69798f0c33df960036eafc54
[vlc] / src / network / error.c
1 /*****************************************************************************
2  * error.c: Network error handling
3  *****************************************************************************
4  * Copyright (C) 2006 Rémi Denis-Courmont
5  * $Id$
6  *
7  * Author : Rémi Denis-Courmont <rem # videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <vlc/vlc.h>
32 #include <errno.h>
33 #include <vlc_network.h>
34
35 #if defined (WIN32) || defined (UNDER_CE)
36 typedef struct
37 {
38     int code;
39     const char *msg;
40 } wsaerrmsg_t;
41
42 static const wsaerrmsg_t wsaerrmsg[] =
43 {
44     { WSA_INVALID_HANDLE, "Specified event object handle is invalid" },
45     { WSA_NOT_ENOUGH_MEMORY, "Insufficient memory available" },
46     { WSA_INVALID_PARAMETER, "One or more parameters are invalid" },
47     { WSA_OPERATION_ABORTED, "Overlapped operation aborted" },
48     { WSA_IO_INCOMPLETE, "Overlapped I/O event object not in signaled state" },
49     { WSA_IO_PENDING, "Overlapped operations will complete later" },
50     { WSAEINTR, "Interrupted function call" },
51     { WSAEBADF, "File handle is not valid" },
52     { WSAEACCES, "Access denied" },
53     { WSAEFAULT, "Invalid memory address" },
54     { WSAEINVAL, "Invalid argument" },
55     { WSAEMFILE, "Too many open sockets" },
56     { WSAEWOULDBLOCK, "Resource temporarily unavailable" },
57     { WSAEINPROGRESS, "Operation now in progress" },
58     { WSAEALREADY, "Operation already in progress" },
59     { WSAENOTSOCK, "Non-socket handle specified" },
60     { WSAEDESTADDRREQ, "Missing destination address" },
61     { WSAEMSGSIZE, "Message too long" },
62     { WSAEPROTOTYPE, "Protocol wrong type for socket", },
63     { WSAENOPROTOOPT, "Option not supported by protocol" },
64     { WSAEPROTONOSUPPORT, "Protocol not supported" },
65     { WSAESOCKTNOSUPPORT, "Socket type not supported" },
66     { WSAEOPNOTSUPP, "Operation not supported" },
67     { WSAEPFNOSUPPORT, "Protocol family not supported" },
68     { WSAEAFNOSUPPORT, "Address family not supported by protocol family" },
69     { WSAEADDRINUSE, "Address already in use" },
70     { WSAEADDRNOTAVAIL, "Cannot assign requested address" },
71     { WSAENETDOWN, "Network is down" },
72     { WSAENETUNREACH, "Network unreachable" },
73     { WSAENETRESET, "Network dropped connection on reset" },
74     { WSAECONNABORTED, "Software caused connection abort" },
75     { WSAECONNRESET, "Connection reset by peer" },
76     { WSAENOBUFS, "No buffer space available (not enough memory)" },
77     { WSAEISCONN, "Socket is already connected" },
78     { WSAENOTCONN, "Socket is not connected" },
79     { WSAESHUTDOWN, "Cannot send after socket shutdown" },
80     { WSAETOOMANYREFS, "Too many references" },
81     { WSAETIMEDOUT, "Connection timed out" },
82     { WSAECONNREFUSED, "Connection refused by peer" },
83     { WSAELOOP, "Cannot translate name" },
84     { WSAENAMETOOLONG, "Name too long" },
85     { WSAEHOSTDOWN, "Remote host is down" },
86     { WSAEHOSTUNREACH, "No route to host (unreachable)" },
87     { WSAENOTEMPTY, "Directory not empty" },
88     { WSAEPROCLIM, "Too many processes" },
89     { WSAEUSERS, "User quota exceeded" },
90     { WSAEDQUOT, "Disk quota exceeded" },
91     { WSAESTALE, "Stale file handle reference" },
92     { WSAEREMOTE, "Item is remote", },
93     { WSASYSNOTREADY, "Network subsystem is unavailable (network stack not ready)" },
94     { WSAVERNOTSUPPORTED, "Winsock.dll version out of range (network stack version not supported" },
95     { WSANOTINITIALISED, "Network not initialized" },
96     { WSAEDISCON, "Graceful shutdown in progress" },
97     { WSAENOMORE, "No more results" },
98     { WSAECANCELLED, "Call has been cancelled" },
99     { WSAEINVALIDPROCTABLE, "Procedure call table is invalid" },
100     { WSAEINVALIDPROVIDER, "Service provider is invalid" },
101     { WSAEPROVIDERFAILEDINIT, "Service provider failed to initialize" },
102     { WSASYSCALLFAILURE, "System call failure" },
103     { WSASERVICE_NOT_FOUND, "Service not found" },
104     { WSATYPE_NOT_FOUND, "Class type not found" },
105     { WSA_E_NO_MORE, "No more results" },
106     { WSA_E_CANCELLED, "Call was cancelled" },
107     { WSAEREFUSED, "Database query was refused" },
108     { WSAHOST_NOT_FOUND, "Host not found" },
109     { WSATRY_AGAIN, "Nonauthoritative host not found (temporary hostname error)" },
110     { WSANO_RECOVERY, "Non-recoverable hostname error" },
111     { WSANO_DATA, "Valid name, no data record of requested type" },
112     { WSA_QOS_RECEIVERS, "QOS receivers" },
113     { WSA_QOS_SENDERS, "QOS senders" },
114     { WSA_QOS_NO_SENDERS, "No QOS senders" },
115     { WSA_QOS_NO_RECEIVERS, "QOS no receivers" },
116     { WSA_QOS_REQUEST_CONFIRMED, "QOS request confirmed" },
117     { WSA_QOS_ADMISSION_FAILURE, "QOS admission error" },
118     { WSA_QOS_POLICY_FAILURE, "QOS policy failure" },
119     { WSA_QOS_BAD_STYLE, "QOS bad style" },
120     { WSA_QOS_BAD_OBJECT, "QOS bad object" },
121     { WSA_QOS_TRAFFIC_CTRL_ERROR, "QOS traffic control error" },
122     { WSA_QOS_GENERIC_ERROR, "QOS generic error" },
123     { WSA_QOS_ESERVICETYPE, "QOS service type error" },
124     { WSA_QOS_EFLOWSPEC, "QOS flowspec error" },
125     { WSA_QOS_EPROVSPECBUF, "Invalid QOS provider buffer" },
126     { WSA_QOS_EFILTERSTYLE, "Invalid QOS filter style" },
127     { WSA_QOS_EFILTERTYPE, "Invalid QOS filter type" },
128     { WSA_QOS_EFILTERCOUNT, "Incorrect QOS filter count" },
129     { WSA_QOS_EOBJLENGTH, "Invalid QOS object length" },
130     { WSA_QOS_EFLOWCOUNT, "Incorrect QOS flow count" },
131     { WSA_QOS_EUNKNOWNPSOBJ, "Unrecognized QOS object" },
132     { WSA_QOS_EPOLICYOBJ, "Invalid QOS policy object" },
133     { WSA_QOS_EFLOWDESC, "Invalid QOS flow descriptor" },
134     { WSA_QOS_EPSFLOWSPEC, "Invalid QOS provider-specific flowspec" },
135     { WSA_QOS_EPSFILTERSPEC, "Invalid QOS provider-specific filterspec" },
136     { WSA_QOS_ESDMODEOBJ, "Invalid QOS shape discard mode object" },
137     { WSA_QOS_ESHAPERATEOBJ, "Invalid QOS shaping rate object" },
138     { WSA_QOS_RESERVED_PETYPE, "Reserved policy QOS element type" },
139     { 0, NULL }
140     /* Winsock2 error codes are missing, they "never" occur */
141 };
142
143
144 const char *net_strerror( int value )
145 {
146     /* There doesn't seem to be any portable error message generation for
147      * Winsock errors. Some old versions had s_error, but it appears to be
148      * gone, and is not documented.
149      */
150     for( const wsaerrmsg_t *e = wsaerrmsg; e->msg != NULL; e++ )
151         if( e->code == value )
152             return e->msg;
153
154     /* Remember to update src/misc/messages.c if you change this one */
155     return "Unknown network stack error";
156 }
157 #endif