1238106Sdes/* 2238106Sdes * util/log.c - implementation of the log code 3238106Sdes * 4238106Sdes * Copyright (c) 2007, NLnet Labs. All rights reserved. 5238106Sdes * 6238106Sdes * This software is open source. 7238106Sdes * 8238106Sdes * Redistribution and use in source and binary forms, with or without 9238106Sdes * modification, are permitted provided that the following conditions 10238106Sdes * are met: 11238106Sdes * 12238106Sdes * Redistributions of source code must retain the above copyright notice, 13238106Sdes * this list of conditions and the following disclaimer. 14238106Sdes * 15238106Sdes * Redistributions in binary form must reproduce the above copyright notice, 16238106Sdes * this list of conditions and the following disclaimer in the documentation 17238106Sdes * and/or other materials provided with the distribution. 18238106Sdes * 19238106Sdes * Neither the name of the NLNET LABS nor the names of its contributors may 20238106Sdes * be used to endorse or promote products derived from this software without 21238106Sdes * specific prior written permission. 22238106Sdes * 23238106Sdes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24269257Sdes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25269257Sdes * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26269257Sdes * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27269257Sdes * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28269257Sdes * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29269257Sdes * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30269257Sdes * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31269257Sdes * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32269257Sdes * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33269257Sdes * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34238106Sdes */ 35238106Sdes/** 36238106Sdes * \file 37238106Sdes * Implementation of log.h. 38238106Sdes */ 39238106Sdes 40238106Sdes#include "config.h" 41238106Sdes#include "util/log.h" 42238106Sdes#include "util/locks.h" 43269257Sdes#include "ldns/sbuffer.h" 44269257Sdes#include <stdarg.h> 45238106Sdes#ifdef HAVE_TIME_H 46238106Sdes#include <time.h> 47238106Sdes#endif 48238106Sdes#ifdef HAVE_SYSLOG_H 49238106Sdes# include <syslog.h> 50238106Sdes#else 51238106Sdes/**define LOG_ constants */ 52238106Sdes# define LOG_CRIT 2 53238106Sdes# define LOG_ERR 3 54238106Sdes# define LOG_WARNING 4 55238106Sdes# define LOG_NOTICE 5 56238106Sdes# define LOG_INFO 6 57238106Sdes# define LOG_DEBUG 7 58238106Sdes#endif 59238106Sdes#ifdef UB_ON_WINDOWS 60238106Sdes# include "winrc/win_svc.h" 61238106Sdes#endif 62238106Sdes 63238106Sdes/* default verbosity */ 64238106Sdesenum verbosity_value verbosity = 0; 65238106Sdes/** the file logged to. */ 66238106Sdesstatic FILE* logfile = 0; 67238106Sdes/** if key has been created */ 68238106Sdesstatic int key_created = 0; 69238106Sdes/** pthread key for thread ids in logfile */ 70238106Sdesstatic ub_thread_key_t logkey; 71285206Sdes#ifndef THREADS_DISABLED 72285206Sdes/** pthread mutex to protect FILE* */ 73285206Sdesstatic lock_quick_t log_lock; 74285206Sdes#endif 75238106Sdes/** the identity of this executable/process */ 76238106Sdesstatic const char* ident="unbound"; 77238106Sdes#if defined(HAVE_SYSLOG_H) || defined(UB_ON_WINDOWS) 78238106Sdes/** are we using syslog(3) to log to */ 79238106Sdesstatic int logging_to_syslog = 0; 80238106Sdes#endif /* HAVE_SYSLOG_H */ 81238106Sdes/** time to print in log, if NULL, use time(2) */ 82269257Sdesstatic time_t* log_now = NULL; 83238106Sdes/** print time in UTC or in secondsfrom1970 */ 84238106Sdesstatic int log_time_asc = 0; 85238106Sdes 86238106Sdesvoid 87238106Sdeslog_init(const char* filename, int use_syslog, const char* chrootdir) 88238106Sdes{ 89238106Sdes FILE *f; 90238106Sdes if(!key_created) { 91238106Sdes key_created = 1; 92238106Sdes ub_thread_key_create(&logkey, NULL); 93285206Sdes lock_quick_init(&log_lock); 94238106Sdes } 95285206Sdes lock_quick_lock(&log_lock); 96238106Sdes if(logfile 97238106Sdes#if defined(HAVE_SYSLOG_H) || defined(UB_ON_WINDOWS) 98238106Sdes || logging_to_syslog 99238106Sdes#endif 100285206Sdes ) { 101285206Sdes lock_quick_unlock(&log_lock); /* verbose() needs the lock */ 102285206Sdes verbose(VERB_QUERY, "switching log to %s", 103285206Sdes use_syslog?"syslog":(filename&&filename[0]?filename:"stderr")); 104285206Sdes lock_quick_lock(&log_lock); 105285206Sdes } 106238106Sdes if(logfile && logfile != stderr) 107238106Sdes fclose(logfile); 108238106Sdes#ifdef HAVE_SYSLOG_H 109238106Sdes if(logging_to_syslog) { 110238106Sdes closelog(); 111238106Sdes logging_to_syslog = 0; 112238106Sdes } 113238106Sdes if(use_syslog) { 114238106Sdes /* do not delay opening until first write, because we may 115238106Sdes * chroot and no longer be able to access dev/log and so on */ 116238106Sdes openlog(ident, LOG_NDELAY, LOG_DAEMON); 117238106Sdes logging_to_syslog = 1; 118285206Sdes lock_quick_unlock(&log_lock); 119238106Sdes return; 120238106Sdes } 121238106Sdes#elif defined(UB_ON_WINDOWS) 122238106Sdes if(logging_to_syslog) { 123238106Sdes logging_to_syslog = 0; 124238106Sdes } 125238106Sdes if(use_syslog) { 126238106Sdes logging_to_syslog = 1; 127285206Sdes lock_quick_unlock(&log_lock); 128238106Sdes return; 129238106Sdes } 130238106Sdes#endif /* HAVE_SYSLOG_H */ 131238106Sdes if(!filename || !filename[0]) { 132238106Sdes logfile = stderr; 133285206Sdes lock_quick_unlock(&log_lock); 134238106Sdes return; 135238106Sdes } 136238106Sdes /* open the file for logging */ 137238106Sdes if(chrootdir && chrootdir[0] && strncmp(filename, chrootdir, 138238106Sdes strlen(chrootdir)) == 0) 139238106Sdes filename += strlen(chrootdir); 140238106Sdes f = fopen(filename, "a"); 141238106Sdes if(!f) { 142285206Sdes lock_quick_unlock(&log_lock); 143238106Sdes log_err("Could not open logfile %s: %s", filename, 144238106Sdes strerror(errno)); 145238106Sdes return; 146238106Sdes } 147238106Sdes#ifndef UB_ON_WINDOWS 148238106Sdes /* line buffering does not work on windows */ 149238106Sdes setvbuf(f, NULL, (int)_IOLBF, 0); 150238106Sdes#endif 151238106Sdes logfile = f; 152285206Sdes lock_quick_unlock(&log_lock); 153238106Sdes} 154238106Sdes 155238106Sdesvoid log_file(FILE *f) 156238106Sdes{ 157285206Sdes lock_quick_lock(&log_lock); 158238106Sdes logfile = f; 159285206Sdes lock_quick_unlock(&log_lock); 160238106Sdes} 161238106Sdes 162238106Sdesvoid log_thread_set(int* num) 163238106Sdes{ 164238106Sdes ub_thread_key_set(logkey, num); 165238106Sdes} 166238106Sdes 167238106Sdesvoid log_ident_set(const char* id) 168238106Sdes{ 169238106Sdes ident = id; 170238106Sdes} 171238106Sdes 172269257Sdesvoid log_set_time(time_t* t) 173238106Sdes{ 174238106Sdes log_now = t; 175238106Sdes} 176238106Sdes 177238106Sdesvoid log_set_time_asc(int use_asc) 178238106Sdes{ 179238106Sdes log_time_asc = use_asc; 180238106Sdes} 181238106Sdes 182238106Sdesvoid 183238106Sdeslog_vmsg(int pri, const char* type, 184238106Sdes const char *format, va_list args) 185238106Sdes{ 186238106Sdes char message[MAXSYSLOGMSGLEN]; 187238106Sdes unsigned int* tid = (unsigned int*)ub_thread_key_get(logkey); 188238106Sdes time_t now; 189238106Sdes#if defined(HAVE_STRFTIME) && defined(HAVE_LOCALTIME_R) 190238106Sdes char tmbuf[32]; 191238106Sdes struct tm tm; 192249141Sdes#elif defined(UB_ON_WINDOWS) 193249141Sdes char tmbuf[128], dtbuf[128]; 194238106Sdes#endif 195238106Sdes (void)pri; 196238106Sdes vsnprintf(message, sizeof(message), format, args); 197238106Sdes#ifdef HAVE_SYSLOG_H 198238106Sdes if(logging_to_syslog) { 199238106Sdes syslog(pri, "[%d:%x] %s: %s", 200238106Sdes (int)getpid(), tid?*tid:0, type, message); 201238106Sdes return; 202238106Sdes } 203238106Sdes#elif defined(UB_ON_WINDOWS) 204238106Sdes if(logging_to_syslog) { 205238106Sdes char m[32768]; 206238106Sdes HANDLE* s; 207238106Sdes LPCTSTR str = m; 208238106Sdes DWORD tp = MSG_GENERIC_ERR; 209238106Sdes WORD wt = EVENTLOG_ERROR_TYPE; 210238106Sdes if(strcmp(type, "info") == 0) { 211238106Sdes tp=MSG_GENERIC_INFO; 212238106Sdes wt=EVENTLOG_INFORMATION_TYPE; 213238106Sdes } else if(strcmp(type, "warning") == 0) { 214238106Sdes tp=MSG_GENERIC_WARN; 215238106Sdes wt=EVENTLOG_WARNING_TYPE; 216238106Sdes } else if(strcmp(type, "notice") == 0 217238106Sdes || strcmp(type, "debug") == 0) { 218238106Sdes tp=MSG_GENERIC_SUCCESS; 219238106Sdes wt=EVENTLOG_SUCCESS; 220238106Sdes } 221238106Sdes snprintf(m, sizeof(m), "[%s:%x] %s: %s", 222238106Sdes ident, tid?*tid:0, type, message); 223238106Sdes s = RegisterEventSource(NULL, SERVICE_NAME); 224238106Sdes if(!s) return; 225238106Sdes ReportEvent(s, wt, 0, tp, NULL, 1, 0, &str, NULL); 226238106Sdes DeregisterEventSource(s); 227238106Sdes return; 228238106Sdes } 229238106Sdes#endif /* HAVE_SYSLOG_H */ 230285206Sdes lock_quick_lock(&log_lock); 231285206Sdes if(!logfile) { 232285206Sdes lock_quick_unlock(&log_lock); 233285206Sdes return; 234285206Sdes } 235238106Sdes if(log_now) 236238106Sdes now = (time_t)*log_now; 237238106Sdes else now = (time_t)time(NULL); 238238106Sdes#if defined(HAVE_STRFTIME) && defined(HAVE_LOCALTIME_R) 239238106Sdes if(log_time_asc && strftime(tmbuf, sizeof(tmbuf), "%b %d %H:%M:%S", 240238106Sdes localtime_r(&now, &tm))%(sizeof(tmbuf)) != 0) { 241238106Sdes /* %sizeof buf!=0 because old strftime returned max on error */ 242238106Sdes fprintf(logfile, "%s %s[%d:%x] %s: %s\n", tmbuf, 243238106Sdes ident, (int)getpid(), tid?*tid:0, type, message); 244238106Sdes } else 245249141Sdes#elif defined(UB_ON_WINDOWS) 246249141Sdes if(log_time_asc && GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, 247249141Sdes tmbuf, sizeof(tmbuf)) && GetDateFormat(LOCALE_USER_DEFAULT, 0, 248249141Sdes NULL, NULL, dtbuf, sizeof(dtbuf))) { 249249141Sdes fprintf(logfile, "%s %s %s[%d:%x] %s: %s\n", dtbuf, tmbuf, 250249141Sdes ident, (int)getpid(), tid?*tid:0, type, message); 251249141Sdes } else 252238106Sdes#endif 253269257Sdes fprintf(logfile, "[" ARG_LL "d] %s[%d:%x] %s: %s\n", (long long)now, 254238106Sdes ident, (int)getpid(), tid?*tid:0, type, message); 255238106Sdes#ifdef UB_ON_WINDOWS 256238106Sdes /* line buffering does not work on windows */ 257238106Sdes fflush(logfile); 258238106Sdes#endif 259285206Sdes lock_quick_unlock(&log_lock); 260238106Sdes} 261238106Sdes 262238106Sdes/** 263238106Sdes * implementation of log_info 264238106Sdes * @param format: format string printf-style. 265238106Sdes */ 266238106Sdesvoid 267238106Sdeslog_info(const char *format, ...) 268238106Sdes{ 269238106Sdes va_list args; 270238106Sdes va_start(args, format); 271238106Sdes log_vmsg(LOG_INFO, "info", format, args); 272238106Sdes va_end(args); 273238106Sdes} 274238106Sdes 275238106Sdes/** 276238106Sdes * implementation of log_err 277238106Sdes * @param format: format string printf-style. 278238106Sdes */ 279238106Sdesvoid 280238106Sdeslog_err(const char *format, ...) 281238106Sdes{ 282238106Sdes va_list args; 283238106Sdes va_start(args, format); 284238106Sdes log_vmsg(LOG_ERR, "error", format, args); 285238106Sdes va_end(args); 286238106Sdes} 287238106Sdes 288238106Sdes/** 289238106Sdes * implementation of log_warn 290238106Sdes * @param format: format string printf-style. 291238106Sdes */ 292238106Sdesvoid 293238106Sdeslog_warn(const char *format, ...) 294238106Sdes{ 295238106Sdes va_list args; 296238106Sdes va_start(args, format); 297238106Sdes log_vmsg(LOG_WARNING, "warning", format, args); 298238106Sdes va_end(args); 299238106Sdes} 300238106Sdes 301238106Sdes/** 302238106Sdes * implementation of fatal_exit 303238106Sdes * @param format: format string printf-style. 304238106Sdes */ 305238106Sdesvoid 306238106Sdesfatal_exit(const char *format, ...) 307238106Sdes{ 308238106Sdes va_list args; 309238106Sdes va_start(args, format); 310238106Sdes log_vmsg(LOG_CRIT, "fatal error", format, args); 311238106Sdes va_end(args); 312238106Sdes exit(1); 313238106Sdes} 314238106Sdes 315238106Sdes/** 316238106Sdes * implementation of verbose 317238106Sdes * @param level: verbose level for the message. 318238106Sdes * @param format: format string printf-style. 319238106Sdes */ 320238106Sdesvoid 321238106Sdesverbose(enum verbosity_value level, const char* format, ...) 322238106Sdes{ 323238106Sdes va_list args; 324238106Sdes va_start(args, format); 325238106Sdes if(verbosity >= level) { 326238106Sdes if(level == VERB_OPS) 327238106Sdes log_vmsg(LOG_NOTICE, "notice", format, args); 328238106Sdes else if(level == VERB_DETAIL) 329238106Sdes log_vmsg(LOG_INFO, "info", format, args); 330238106Sdes else log_vmsg(LOG_DEBUG, "debug", format, args); 331238106Sdes } 332238106Sdes va_end(args); 333238106Sdes} 334238106Sdes 335238106Sdes/** log hex data */ 336238106Sdesstatic void 337238106Sdeslog_hex_f(enum verbosity_value v, const char* msg, void* data, size_t length) 338238106Sdes{ 339238106Sdes size_t i, j; 340238106Sdes uint8_t* data8 = (uint8_t*)data; 341238106Sdes const char* hexchar = "0123456789ABCDEF"; 342238106Sdes char buf[1024+1]; /* alloc blocksize hex chars + \0 */ 343238106Sdes const size_t blocksize = 512; 344238106Sdes size_t len; 345238106Sdes 346238106Sdes if(length == 0) { 347238106Sdes verbose(v, "%s[%u]", msg, (unsigned)length); 348238106Sdes return; 349238106Sdes } 350238106Sdes 351238106Sdes for(i=0; i<length; i+=blocksize/2) { 352238106Sdes len = blocksize/2; 353238106Sdes if(length - i < blocksize/2) 354238106Sdes len = length - i; 355238106Sdes for(j=0; j<len; j++) { 356238106Sdes buf[j*2] = hexchar[ data8[i+j] >> 4 ]; 357238106Sdes buf[j*2 + 1] = hexchar[ data8[i+j] & 0xF ]; 358238106Sdes } 359238106Sdes buf[len*2] = 0; 360238106Sdes verbose(v, "%s[%u:%u] %.*s", msg, (unsigned)length, 361238106Sdes (unsigned)i, (int)len*2, buf); 362238106Sdes } 363238106Sdes} 364238106Sdes 365238106Sdesvoid 366238106Sdeslog_hex(const char* msg, void* data, size_t length) 367238106Sdes{ 368238106Sdes log_hex_f(verbosity, msg, data, length); 369238106Sdes} 370238106Sdes 371269257Sdesvoid log_buf(enum verbosity_value level, const char* msg, sldns_buffer* buf) 372238106Sdes{ 373238106Sdes if(verbosity < level) 374238106Sdes return; 375269257Sdes log_hex_f(level, msg, sldns_buffer_begin(buf), sldns_buffer_limit(buf)); 376238106Sdes} 377238106Sdes 378238106Sdes#ifdef USE_WINSOCK 379238106Sdeschar* wsa_strerror(DWORD err) 380238106Sdes{ 381238106Sdes static char unknown[32]; 382238106Sdes 383238106Sdes switch(err) { 384238106Sdes case WSA_INVALID_HANDLE: return "Specified event object handle is invalid."; 385238106Sdes case WSA_NOT_ENOUGH_MEMORY: return "Insufficient memory available."; 386238106Sdes case WSA_INVALID_PARAMETER: return "One or more parameters are invalid."; 387238106Sdes case WSA_OPERATION_ABORTED: return "Overlapped operation aborted."; 388238106Sdes case WSA_IO_INCOMPLETE: return "Overlapped I/O event object not in signaled state."; 389238106Sdes case WSA_IO_PENDING: return "Overlapped operations will complete later."; 390238106Sdes case WSAEINTR: return "Interrupted function call."; 391238106Sdes case WSAEBADF: return "File handle is not valid."; 392238106Sdes case WSAEACCES: return "Permission denied."; 393238106Sdes case WSAEFAULT: return "Bad address."; 394238106Sdes case WSAEINVAL: return "Invalid argument."; 395238106Sdes case WSAEMFILE: return "Too many open files."; 396238106Sdes case WSAEWOULDBLOCK: return "Resource temporarily unavailable."; 397238106Sdes case WSAEINPROGRESS: return "Operation now in progress."; 398238106Sdes case WSAEALREADY: return "Operation already in progress."; 399238106Sdes case WSAENOTSOCK: return "Socket operation on nonsocket."; 400238106Sdes case WSAEDESTADDRREQ: return "Destination address required."; 401238106Sdes case WSAEMSGSIZE: return "Message too long."; 402238106Sdes case WSAEPROTOTYPE: return "Protocol wrong type for socket."; 403238106Sdes case WSAENOPROTOOPT: return "Bad protocol option."; 404238106Sdes case WSAEPROTONOSUPPORT: return "Protocol not supported."; 405238106Sdes case WSAESOCKTNOSUPPORT: return "Socket type not supported."; 406238106Sdes case WSAEOPNOTSUPP: return "Operation not supported."; 407238106Sdes case WSAEPFNOSUPPORT: return "Protocol family not supported."; 408238106Sdes case WSAEAFNOSUPPORT: return "Address family not supported by protocol family."; 409238106Sdes case WSAEADDRINUSE: return "Address already in use."; 410238106Sdes case WSAEADDRNOTAVAIL: return "Cannot assign requested address."; 411238106Sdes case WSAENETDOWN: return "Network is down."; 412238106Sdes case WSAENETUNREACH: return "Network is unreachable."; 413238106Sdes case WSAENETRESET: return "Network dropped connection on reset."; 414238106Sdes case WSAECONNABORTED: return "Software caused connection abort."; 415238106Sdes case WSAECONNRESET: return "Connection reset by peer."; 416238106Sdes case WSAENOBUFS: return "No buffer space available."; 417238106Sdes case WSAEISCONN: return "Socket is already connected."; 418238106Sdes case WSAENOTCONN: return "Socket is not connected."; 419238106Sdes case WSAESHUTDOWN: return "Cannot send after socket shutdown."; 420238106Sdes case WSAETOOMANYREFS: return "Too many references."; 421238106Sdes case WSAETIMEDOUT: return "Connection timed out."; 422238106Sdes case WSAECONNREFUSED: return "Connection refused."; 423238106Sdes case WSAELOOP: return "Cannot translate name."; 424238106Sdes case WSAENAMETOOLONG: return "Name too long."; 425238106Sdes case WSAEHOSTDOWN: return "Host is down."; 426238106Sdes case WSAEHOSTUNREACH: return "No route to host."; 427238106Sdes case WSAENOTEMPTY: return "Directory not empty."; 428238106Sdes case WSAEPROCLIM: return "Too many processes."; 429238106Sdes case WSAEUSERS: return "User quota exceeded."; 430238106Sdes case WSAEDQUOT: return "Disk quota exceeded."; 431238106Sdes case WSAESTALE: return "Stale file handle reference."; 432238106Sdes case WSAEREMOTE: return "Item is remote."; 433238106Sdes case WSASYSNOTREADY: return "Network subsystem is unavailable."; 434238106Sdes case WSAVERNOTSUPPORTED: return "Winsock.dll version out of range."; 435238106Sdes case WSANOTINITIALISED: return "Successful WSAStartup not yet performed."; 436238106Sdes case WSAEDISCON: return "Graceful shutdown in progress."; 437238106Sdes case WSAENOMORE: return "No more results."; 438238106Sdes case WSAECANCELLED: return "Call has been canceled."; 439238106Sdes case WSAEINVALIDPROCTABLE: return "Procedure call table is invalid."; 440238106Sdes case WSAEINVALIDPROVIDER: return "Service provider is invalid."; 441238106Sdes case WSAEPROVIDERFAILEDINIT: return "Service provider failed to initialize."; 442238106Sdes case WSASYSCALLFAILURE: return "System call failure."; 443238106Sdes case WSASERVICE_NOT_FOUND: return "Service not found."; 444238106Sdes case WSATYPE_NOT_FOUND: return "Class type not found."; 445238106Sdes case WSA_E_NO_MORE: return "No more results."; 446238106Sdes case WSA_E_CANCELLED: return "Call was canceled."; 447238106Sdes case WSAEREFUSED: return "Database query was refused."; 448238106Sdes case WSAHOST_NOT_FOUND: return "Host not found."; 449238106Sdes case WSATRY_AGAIN: return "Nonauthoritative host not found."; 450238106Sdes case WSANO_RECOVERY: return "This is a nonrecoverable error."; 451238106Sdes case WSANO_DATA: return "Valid name, no data record of requested type."; 452238106Sdes case WSA_QOS_RECEIVERS: return "QOS receivers."; 453238106Sdes case WSA_QOS_SENDERS: return "QOS senders."; 454238106Sdes case WSA_QOS_NO_SENDERS: return "No QOS senders."; 455238106Sdes case WSA_QOS_NO_RECEIVERS: return "QOS no receivers."; 456238106Sdes case WSA_QOS_REQUEST_CONFIRMED: return "QOS request confirmed."; 457238106Sdes case WSA_QOS_ADMISSION_FAILURE: return "QOS admission error."; 458238106Sdes case WSA_QOS_POLICY_FAILURE: return "QOS policy failure."; 459238106Sdes case WSA_QOS_BAD_STYLE: return "QOS bad style."; 460238106Sdes case WSA_QOS_BAD_OBJECT: return "QOS bad object."; 461238106Sdes case WSA_QOS_TRAFFIC_CTRL_ERROR: return "QOS traffic control error."; 462238106Sdes case WSA_QOS_GENERIC_ERROR: return "QOS generic error."; 463238106Sdes case WSA_QOS_ESERVICETYPE: return "QOS service type error."; 464238106Sdes case WSA_QOS_EFLOWSPEC: return "QOS flowspec error."; 465238106Sdes case WSA_QOS_EPROVSPECBUF: return "Invalid QOS provider buffer."; 466238106Sdes case WSA_QOS_EFILTERSTYLE: return "Invalid QOS filter style."; 467238106Sdes case WSA_QOS_EFILTERTYPE: return "Invalid QOS filter type."; 468238106Sdes case WSA_QOS_EFILTERCOUNT: return "Incorrect QOS filter count."; 469238106Sdes case WSA_QOS_EOBJLENGTH: return "Invalid QOS object length."; 470238106Sdes case WSA_QOS_EFLOWCOUNT: return "Incorrect QOS flow count."; 471238106Sdes /*case WSA_QOS_EUNKOWNPSOBJ: return "Unrecognized QOS object.";*/ 472238106Sdes case WSA_QOS_EPOLICYOBJ: return "Invalid QOS policy object."; 473238106Sdes case WSA_QOS_EFLOWDESC: return "Invalid QOS flow descriptor."; 474238106Sdes case WSA_QOS_EPSFLOWSPEC: return "Invalid QOS provider-specific flowspec."; 475238106Sdes case WSA_QOS_EPSFILTERSPEC: return "Invalid QOS provider-specific filterspec."; 476238106Sdes case WSA_QOS_ESDMODEOBJ: return "Invalid QOS shape discard mode object."; 477238106Sdes case WSA_QOS_ESHAPERATEOBJ: return "Invalid QOS shaping rate object."; 478238106Sdes case WSA_QOS_RESERVED_PETYPE: return "Reserved policy QOS element type."; 479238106Sdes default: 480238106Sdes snprintf(unknown, sizeof(unknown), 481238106Sdes "unknown WSA error code %d", (int)err); 482238106Sdes return unknown; 483238106Sdes } 484238106Sdes} 485238106Sdes#endif /* USE_WINSOCK */ 486