]>
git.ipfire.org Git - thirdparty/dhcp.git/blob - omapip/errwarn.c
3 Errors and warnings... */
6 * Copyright (c) 1995 RadioMail Corporation.
7 * Copyright (c) 2004-2019 by Internet Systems Consortium, Inc. ("ISC")
8 * Copyright (c) 1996-2003 by Internet Software Consortium
10 * This Source Code Form is subject to the terms of the Mozilla Public
11 * License, v. 2.0. If a copy of the MPL was not distributed with this
12 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
14 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * Internet Systems Consortium, Inc.
24 * Newmarket, NH 03857 USA
26 * https://www.isc.org/
28 * This software was written for RadioMail Corporation by Ted Lemon
29 * under a contract with Vixie Enterprises. Further modifications have
30 * been made for Internet Systems Consortium under a contract
31 * with Vixie Laboratories.
36 #include <omapip/omapip_p.h>
45 void (*log_cleanup
) (void);
47 #define CVT_BUF_MAX 1023
48 static char mbuf
[CVT_BUF_MAX
+ 1];
49 static char fbuf
[CVT_BUF_MAX
+ 1];
51 /* Log an error message, then exit... */
53 void log_fatal (const char * fmt
, ... )
57 do_percentm (fbuf
, sizeof fbuf
, fmt
);
59 /* %Audit% This is log output. %2004.06.17,Safe%
60 * If we truncate we hope the user can get a hint from the log.
63 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
67 syslog (LOG_ERR
, "%s", mbuf
);
70 /* Also log it to stderr? */
72 IGNORE_RET (write (STDERR_FILENO
, mbuf
, strlen (mbuf
)));
73 IGNORE_RET (write (STDERR_FILENO
, "\n", 1));
77 log_error ("If you think you have received this message due to a bug rather");
78 log_error ("than a configuration issue please read the section on submitting");
79 log_error ("bugs on either our web page at www.isc.org or in the README file");
80 log_error ("before submitting a bug. These pages explain the proper");
81 log_error ("process and the information we find helpful for debugging.");
83 log_error ("exiting.");
90 /* Log an error message... */
92 int log_error (const char * fmt
, ...)
96 do_percentm (fbuf
, sizeof fbuf
, fmt
);
98 /* %Audit% This is log output. %2004.06.17,Safe%
99 * If we truncate we hope the user can get a hint from the log.
101 va_start (list
, fmt
);
102 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
106 syslog (LOG_ERR
, "%s", mbuf
);
110 IGNORE_RET (write (STDERR_FILENO
, mbuf
, strlen (mbuf
)));
111 IGNORE_RET (write (STDERR_FILENO
, "\n", 1));
119 int log_info (const char *fmt
, ...)
123 do_percentm (fbuf
, sizeof fbuf
, fmt
);
125 /* %Audit% This is log output. %2004.06.17,Safe%
126 * If we truncate we hope the user can get a hint from the log.
128 va_start (list
, fmt
);
129 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
133 syslog (LOG_INFO
, "%s", mbuf
);
137 IGNORE_RET (write (STDERR_FILENO
, mbuf
, strlen (mbuf
)));
138 IGNORE_RET (write (STDERR_FILENO
, "\n", 1));
144 /* Log a debug message... */
146 int log_debug (const char *fmt
, ...)
150 do_percentm (fbuf
, sizeof fbuf
, fmt
);
152 /* %Audit% This is log output. %2004.06.17,Safe%
153 * If we truncate we hope the user can get a hint from the log.
155 va_start (list
, fmt
);
156 vsnprintf (mbuf
, sizeof mbuf
, fbuf
, list
);
160 syslog (LOG_DEBUG
, "%s", mbuf
);
164 IGNORE_RET (write (STDERR_FILENO
, mbuf
, strlen (mbuf
)));
165 IGNORE_RET (write (STDERR_FILENO
, "\n", 1));
171 /* Find %m in the input string and substitute an error message string. */
173 void do_percentm (obuf
, obufsize
, ibuf
)
178 const char *s
= ibuf
;
188 m
= strerror (errno
);
193 m
= "<unknown error>";
195 if (len
> obufsize
- 1)
201 if (++len
> obufsize
- 1)
209 if (++len
> obufsize
- 1)
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";