]>
git.ipfire.org Git - thirdparty/dhcp.git/blob - omapip/errwarn.c
3 Errors and warnings... */
6 * Copyright (c) 1995 RadioMail Corporation.
7 * Copyright (c) 2009,2014 by Internet Systems Consortium, Inc. ("ISC")
8 * Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
9 * Copyright (c) 1996-2003 by Internet Software Consortium
11 * Permission to use, copy, modify, and distribute this software for any
12 * purpose with or without fee is hereby granted, provided that the above
13 * copyright notice and this permission notice appear in all copies.
15 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
16 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
18 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Internet Systems Consortium, Inc.
25 * Redwood City, CA 94063
27 * https://www.isc.org/
29 * This software was written for RadioMail Corporation by Ted Lemon
30 * under a contract with Vixie Enterprises. Further modifications have
31 * been made for Internet Systems Consortium under a contract
32 * with Vixie Laboratories.
37 #include <omapip/omapip_p.h>
46 void (*log_cleanup
) (void);
48 #define CVT_BUF_MAX 1023
49 static char mbuf
[CVT_BUF_MAX
+ 1];
50 static char fbuf
[CVT_BUF_MAX
+ 1];
52 /* Log an error message, then exit... */
54 void log_fatal (const char * fmt
, ... )
58 do_percentm (fbuf
, fmt
);
60 /* %Audit% This is log output. %2004.06.17,Safe%
61 * If we truncate we hope the user can get a hint from the log.
64 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
68 syslog (LOG_ERR
, "%s", mbuf
);
71 /* Also log it to stderr? */
73 IGNORE_RET (write (STDERR_FILENO
, mbuf
, strlen (mbuf
)));
74 IGNORE_RET (write (STDERR_FILENO
, "\n", 1));
78 log_error ("If you think you have received this message due to a bug rather");
79 log_error ("than a configuration issue please read the section on submitting");
80 log_error ("bugs on either our web page at www.isc.org or in the README file");
81 log_error ("before submitting a bug. These pages explain the proper");
82 log_error ("process and the information we find helpful for debugging..");
84 log_error ("exiting.");
91 /* Log an error message... */
93 int log_error (const char * fmt
, ...)
97 do_percentm (fbuf
, fmt
);
99 /* %Audit% This is log output. %2004.06.17,Safe%
100 * If we truncate we hope the user can get a hint from the log.
102 va_start (list
, fmt
);
103 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
107 syslog (LOG_ERR
, "%s", mbuf
);
111 IGNORE_RET (write (STDERR_FILENO
, mbuf
, strlen (mbuf
)));
112 IGNORE_RET (write (STDERR_FILENO
, "\n", 1));
120 int log_info (const char *fmt
, ...)
124 do_percentm (fbuf
, fmt
);
126 /* %Audit% This is log output. %2004.06.17,Safe%
127 * If we truncate we hope the user can get a hint from the log.
129 va_start (list
, fmt
);
130 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
134 syslog (LOG_INFO
, "%s", mbuf
);
138 IGNORE_RET (write (STDERR_FILENO
, mbuf
, strlen (mbuf
)));
139 IGNORE_RET (write (STDERR_FILENO
, "\n", 1));
145 /* Log a debug message... */
147 int log_debug (const char *fmt
, ...)
151 do_percentm (fbuf
, fmt
);
153 /* %Audit% This is log output. %2004.06.17,Safe%
154 * If we truncate we hope the user can get a hint from the log.
156 va_start (list
, fmt
);
157 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
161 syslog (LOG_DEBUG
, "%s", mbuf
);
165 IGNORE_RET (write (STDERR_FILENO
, mbuf
, strlen (mbuf
)));
166 IGNORE_RET (write (STDERR_FILENO
, "\n", 1));
172 /* Find %m in the input string and substitute an error message string. */
174 void do_percentm (obuf
, ibuf
)
178 const char *s
= ibuf
;
188 m
= strerror (errno
);
193 m
= "<unknown error>";
195 if (len
> CVT_BUF_MAX
)
201 if (++len
> CVT_BUF_MAX
)
209 if (++len
> CVT_BUF_MAX
)
222 extern char *sys_errlist
[];
224 static char errbuf
[128];
226 if (err
< 0 || err
>= sys_nerr
) {
227 sprintf (errbuf
, "Error %d", err
);
230 return sys_errlist
[err
];
232 #endif /* NO_STRERROR */
237 int err
= WSAGetLastError ();
242 return "Permission denied";
244 return "Address already in use";
245 case WSAEADDRNOTAVAIL
:
246 return "Cannot assign requested address";
247 case WSAEAFNOSUPPORT
:
248 return "Address family not supported by protocol family";
250 return "Operation already in progress";
251 case WSAECONNABORTED
:
252 return "Software caused connection abort";
253 case WSAECONNREFUSED
:
254 return "Connection refused";
256 return "Connection reset by peer";
257 case WSAEDESTADDRREQ
:
258 return "Destination address required";
260 return "Bad address";
262 return "Host is down";
263 case WSAEHOSTUNREACH
:
264 return "No route to host";
266 return "Operation now in progress";
268 return "Interrupted function call";
270 return "Invalid argument";
272 return "Socket is already connected";
274 return "Too many open files";
276 return "Message too long";
278 return "Network is down";
280 return "Network dropped connection on reset";
282 return "Network is unreachable";
284 return "No buffer space available";
286 return "Bad protocol option";
288 return "Socket is not connected";
290 return "Socket operation on non-socket";
292 return "Operation not supported";
293 case WSAEPFNOSUPPORT
:
294 return "Protocol family not supported";
296 return "Too many processes";
297 case WSAEPROTONOSUPPORT
:
298 return "Protocol not supported";
300 return "Protocol wrong type for socket";
302 return "Cannot send after socket shutdown";
303 case WSAESOCKTNOSUPPORT
:
304 return "Socket type not supported";
306 return "Connection timed out";
308 return "Resource temporarily unavailable";
309 case WSAHOST_NOT_FOUND
:
310 return "Host not found";
312 case WSA_INVALID_HANDLE
:
313 return "Specified event object handle is invalid";
314 case WSA_INVALID_PARAMETER
:
315 return "One or more parameters are invalid";
316 case WSAINVALIDPROCTABLE
:
317 return "Invalid procedure table from service provider";
318 case WSAINVALIDPROVIDER
:
319 return "Invalid service provider version number";
321 return "Overlapped operations will complete later";
322 case WSA_IO_INCOMPLETE
:
323 return "Overlapped I/O event object not in signaled state";
324 case WSA_NOT_ENOUGH_MEMORY
:
325 return "Insufficient memory available";
327 case WSANOTINITIALISED
:
328 return "Successful WSAStartup not yet performer";
330 return "Valid name, no data record of requested type";
332 return "This is a non-recoverable error";
334 case WSAPROVIDERFAILEDINIT
:
335 return "Unable to initialize a service provider";
336 case WSASYSCALLFAILURE
:
337 return "System call failure";
340 return "Network subsystem is unavailable";
342 return "Non-authoritative host not found";
343 case WSAVERNOTSUPPORTED
:
344 return "WINSOCK.DLL version out of range";
346 return "Graceful shutdown in progress";
348 case WSA_OPERATION_ABORTED
:
349 return "Overlapped operation aborted";
352 return "Unknown WinSock error";