• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* MIT License
2  *
3  * Copyright (c) 1998 Massachusetts Institute of Technology
4  * Copyright (c) The c-ares project and its contributors
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the next
14  * paragraph) shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  *
25  * SPDX-License-Identifier: MIT
26  */
27 
28 #include "ares_setup.h"
29 #include <assert.h>
30 #include "ares.h"
31 
ares_strerror(int code)32 const char *ares_strerror(int code)
33 {
34   ares_status_t status = (ares_status_t)code;
35   switch (status) {
36     case ARES_SUCCESS:
37       return "Successful completion";
38     case ARES_ENODATA:
39       return "DNS server returned answer with no data";
40     case ARES_EFORMERR:
41       return "DNS server claims query was misformatted";
42     case ARES_ESERVFAIL:
43       return "DNS server returned general failure";
44     case ARES_ENOTFOUND:
45       return "Domain name not found";
46     case ARES_ENOTIMP:
47       return "DNS server does not implement requested operation";
48     case ARES_EREFUSED:
49       return "DNS server refused query";
50     case ARES_EBADQUERY:
51       return "Misformatted DNS query";
52     case ARES_EBADNAME:
53       return "Misformatted domain name";
54     case ARES_EBADFAMILY:
55       return "Unsupported address family";
56     case ARES_EBADRESP:
57       return "Misformatted DNS reply";
58     case ARES_ECONNREFUSED:
59       return "Could not contact DNS servers";
60     case ARES_ETIMEOUT:
61       return "Timeout while contacting DNS servers";
62     case ARES_EOF:
63       return "End of file";
64     case ARES_EFILE:
65       return "Error reading file";
66     case ARES_ENOMEM:
67       return "Out of memory";
68     case ARES_EDESTRUCTION:
69       return "Channel is being destroyed";
70     case ARES_EBADSTR:
71       return "Misformatted string";
72     case ARES_EBADFLAGS:
73       return "Illegal flags specified";
74     case ARES_ENONAME:
75       return "Given hostname is not numeric";
76     case ARES_EBADHINTS:
77       return "Illegal hints flags specified";
78     case ARES_ENOTINITIALIZED:
79       return "c-ares library initialization not yet performed";
80     case ARES_ELOADIPHLPAPI:
81       return "Error loading iphlpapi.dll";
82     case ARES_EADDRGETNETWORKPARAMS:
83       return "Could not find GetNetworkParams function";
84     case ARES_ECANCELLED:
85       return "DNS query cancelled";
86     case ARES_ESERVICE:
87       return "Invalid service name or number";
88     case ARES_ENOSERVER:
89       return "No DNS servers were configured";
90   }
91 
92   return "unknown";
93 }
94