]>
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.6 2000/09/01 23:04:37 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 #if !defined (NOMINUM)
85 log_error ("If you did not get this software from ftp.isc.org, please");
86 log_error ("get the latest from ftp.isc.org and install that before");
87 log_error ("requesting help.");
88 log_error ("If you did get this software from ftp.isc.org and have not");
89 log_error ("yet read the README, please read it before requesting help.");
90 log_error ("If you intend to request help from the dhcp-server@isc.org");
91 log_error ("mailing list, please read the section on the README about");
92 log_error ("submitting bug reports and requests for help.");
94 log_error ("exiting.");
101 /* Log an error message... */
103 int log_error (const char * fmt
, ...)
107 do_percentm (fbuf
, fmt
);
109 va_start (list
, fmt
);
110 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
114 syslog (log_priority
| LOG_ERR
, "%s", mbuf
);
118 write (2, mbuf
, strlen (mbuf
));
127 int log_info (const char *fmt
, ...)
131 do_percentm (fbuf
, fmt
);
133 va_start (list
, fmt
);
134 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
138 syslog (log_priority
| LOG_INFO
, "%s", mbuf
);
142 write (2, mbuf
, strlen (mbuf
));
149 /* Log a debug message... */
151 int log_debug (const char *fmt
, ...)
155 do_percentm (fbuf
, fmt
);
157 va_start (list
, fmt
);
158 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
162 syslog (log_priority
| LOG_DEBUG
, "%s", mbuf
);
166 write (2, mbuf
, strlen (mbuf
));
173 /* Find %m in the input string and substitute an error message string. */
175 void do_percentm (obuf
, ibuf
)
179 const char *s
= ibuf
;
191 m
= strerror (errno
);
196 m
= "<unknown error>";
219 extern char *sys_errlist
[];
221 static char errbuf
[128];
223 if (err
< 0 || err
>= sys_nerr
) {
224 sprintf (errbuf
, "Error %d", err
);
227 return sys_errlist
[err
];
229 #endif /* NO_STRERROR */
234 int err
= WSAGetLastError ();
239 return "Permission denied";
241 return "Address already in use";
242 case WSAEADDRNOTAVAIL
:
243 return "Cannot assign requested address";
244 case WSAEAFNOSUPPORT
:
245 return "Address family not supported by protocol family";
247 return "Operation already in progress";
248 case WSAECONNABORTED
:
249 return "Software caused connection abort";
250 case WSAECONNREFUSED
:
251 return "Connection refused";
253 return "Connection reset by peer";
254 case WSAEDESTADDRREQ
:
255 return "Destination address required";
257 return "Bad address";
259 return "Host is down";
260 case WSAEHOSTUNREACH
:
261 return "No route to host";
263 return "Operation now in progress";
265 return "Interrupted function call";
267 return "Invalid argument";
269 return "Socket is already connected";
271 return "Too many open files";
273 return "Message too long";
275 return "Network is down";
277 return "Network dropped connection on reset";
279 return "Network is unreachable";
281 return "No buffer space available";
283 return "Bad protocol option";
285 return "Socket is not connected";
287 return "Socket operation on non-socket";
289 return "Operation not supported";
290 case WSAEPFNOSUPPORT
:
291 return "Protocol family not supported";
293 return "Too many processes";
294 case WSAEPROTONOSUPPORT
:
295 return "Protocol not supported";
297 return "Protocol wrong type for socket";
299 return "Cannot send after socket shutdown";
300 case WSAESOCKTNOSUPPORT
:
301 return "Socket type not supported";
303 return "Connection timed out";
305 return "Resource temporarily unavailable";
306 case WSAHOST_NOT_FOUND
:
307 return "Host not found";
309 case WSA_INVALID_HANDLE
:
310 return "Specified event object handle is invalid";
311 case WSA_INVALID_PARAMETER
:
312 return "One or more parameters are invalid";
313 case WSAINVALIDPROCTABLE
:
314 return "Invalid procedure table from service provider";
315 case WSAINVALIDPROVIDER
:
316 return "Invalid service provider version number";
318 return "Overlapped operations will complete later";
319 case WSA_IO_INCOMPLETE
:
320 return "Overlapped I/O event object not in signaled state";
321 case WSA_NOT_ENOUGH_MEMORY
:
322 return "Insufficient memory available";
324 case WSANOTINITIALISED
:
325 return "Successful WSAStartup not yet performer";
327 return "Valid name, no data record of requested type";
329 return "This is a non-recoverable error";
331 case WSAPROVIDERFAILEDINIT
:
332 return "Unable to initialize a service provider";
333 case WSASYSCALLFAILURE
:
334 return "System call failure";
337 return "Network subsystem is unavailable";
339 return "Non-authoritative host not found";
340 case WSAVERNOTSUPPORTED
:
341 return "WINSOCK.DLL version out of range";
343 return "Graceful shutdown in progress";
345 case WSA_OPERATION_ABORTED
:
346 return "Overlapped operation aborted";
349 return "Unknown WinSock error";