]>
git.ipfire.org Git - thirdparty/dhcp.git/blob - omapip/errwarn.c
3 Errors and warnings... */
6 * Copyright (c) 1995 RadioMail Corporation.
7 * Copyright (c) 1996-2000 Internet Software Consortium.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of The Internet Software Consortium nor the names
20 * of its contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
24 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
31 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
34 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * This software was written for RadioMail Corporation by Ted Lemon
38 * under a contract with Vixie Enterprises. Further modifications have
39 * been made for the Internet Software Consortium under a contract
40 * with Vixie Laboratories.
44 static char copyright
[] =
45 "$Id: errwarn.c,v 1.5 2000/06/29 20:05:13 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
48 #include <omapip/omapip_p.h>
57 void (*log_cleanup
) (void);
59 static char mbuf
[1024];
60 static char fbuf
[1024];
62 /* Log an error message, then exit... */
64 void log_fatal (const char * fmt
, ... )
68 do_percentm (fbuf
, fmt
);
71 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
75 syslog (log_priority
| LOG_ERR
, "%s", mbuf
);
78 /* Also log it to stderr? */
80 write (2, mbuf
, strlen (mbuf
));
84 syslog (LOG_CRIT
, "exiting.");
86 fprintf (stderr
, "exiting.\n");
94 /* Log an error message... */
96 int log_error (const char * fmt
, ...)
100 do_percentm (fbuf
, fmt
);
102 va_start (list
, fmt
);
103 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
107 syslog (log_priority
| LOG_ERR
, "%s", mbuf
);
111 write (2, mbuf
, strlen (mbuf
));
120 int log_info (const char *fmt
, ...)
124 do_percentm (fbuf
, fmt
);
126 va_start (list
, fmt
);
127 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
131 syslog (log_priority
| LOG_INFO
, "%s", mbuf
);
135 write (2, mbuf
, strlen (mbuf
));
142 /* Log a debug message... */
144 int log_debug (const char *fmt
, ...)
148 do_percentm (fbuf
, fmt
);
150 va_start (list
, fmt
);
151 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
155 syslog (log_priority
| LOG_DEBUG
, "%s", mbuf
);
159 write (2, mbuf
, strlen (mbuf
));
166 /* Find %m in the input string and substitute an error message string. */
168 void do_percentm (obuf
, ibuf
)
172 const char *s
= ibuf
;
184 m
= strerror (errno
);
189 m
= "<unknown error>";
212 extern char *sys_errlist
[];
214 static char errbuf
[128];
216 if (err
< 0 || err
>= sys_nerr
) {
217 sprintf (errbuf
, "Error %d", err
);
220 return sys_errlist
[err
];
222 #endif /* NO_STRERROR */
227 int err
= WSAGetLastError ();
232 return "Permission denied";
234 return "Address already in use";
235 case WSAEADDRNOTAVAIL
:
236 return "Cannot assign requested address";
237 case WSAEAFNOSUPPORT
:
238 return "Address family not supported by protocol family";
240 return "Operation already in progress";
241 case WSAECONNABORTED
:
242 return "Software caused connection abort";
243 case WSAECONNREFUSED
:
244 return "Connection refused";
246 return "Connection reset by peer";
247 case WSAEDESTADDRREQ
:
248 return "Destination address required";
250 return "Bad address";
252 return "Host is down";
253 case WSAEHOSTUNREACH
:
254 return "No route to host";
256 return "Operation now in progress";
258 return "Interrupted function call";
260 return "Invalid argument";
262 return "Socket is already connected";
264 return "Too many open files";
266 return "Message too long";
268 return "Network is down";
270 return "Network dropped connection on reset";
272 return "Network is unreachable";
274 return "No buffer space available";
276 return "Bad protocol option";
278 return "Socket is not connected";
280 return "Socket operation on non-socket";
282 return "Operation not supported";
283 case WSAEPFNOSUPPORT
:
284 return "Protocol family not supported";
286 return "Too many processes";
287 case WSAEPROTONOSUPPORT
:
288 return "Protocol not supported";
290 return "Protocol wrong type for socket";
292 return "Cannot send after socket shutdown";
293 case WSAESOCKTNOSUPPORT
:
294 return "Socket type not supported";
296 return "Connection timed out";
298 return "Resource temporarily unavailable";
299 case WSAHOST_NOT_FOUND
:
300 return "Host not found";
302 case WSA_INVALID_HANDLE
:
303 return "Specified event object handle is invalid";
304 case WSA_INVALID_PARAMETER
:
305 return "One or more parameters are invalid";
306 case WSAINVALIDPROCTABLE
:
307 return "Invalid procedure table from service provider";
308 case WSAINVALIDPROVIDER
:
309 return "Invalid service provider version number";
311 return "Overlapped operations will complete later";
312 case WSA_IO_INCOMPLETE
:
313 return "Overlapped I/O event object not in signaled state";
314 case WSA_NOT_ENOUGH_MEMORY
:
315 return "Insufficient memory available";
317 case WSANOTINITIALISED
:
318 return "Successful WSAStartup not yet performer";
320 return "Valid name, no data record of requested type";
322 return "This is a non-recoverable error";
324 case WSAPROVIDERFAILEDINIT
:
325 return "Unable to initialize a service provider";
326 case WSASYSCALLFAILURE
:
327 return "System call failure";
330 return "Network subsystem is unavailable";
332 return "Non-authoritative host not found";
333 case WSAVERNOTSUPPORTED
:
334 return "WINSOCK.DLL version out of range";
336 return "Graceful shutdown in progress";
338 case WSA_OPERATION_ABORTED
:
339 return "Overlapped operation aborted";
342 return "Unknown WinSock error";