1*06201dd4Sguenther /* $OpenBSD: gai_strerror.c,v 1.8 2015/09/14 07:38:38 guenther Exp $ */
292f92416Sitojun
3bc4c5135Scmetz /*
4bc4c5135Scmetz * Copyright (c) 1997-1999, Craig Metz, All rights reserved.
5bc4c5135Scmetz *
6bc4c5135Scmetz * Redistribution and use in source and binary forms, with or without
7bc4c5135Scmetz * modification, are permitted provided that the following conditions
8bc4c5135Scmetz * are met:
9bc4c5135Scmetz * 1. Redistributions of source code must retain the above copyright
10bc4c5135Scmetz * notice, this list of conditions and the following disclaimer.
11bc4c5135Scmetz * 2. Redistributions in binary form must reproduce the above copyright
12bc4c5135Scmetz * notice, this list of conditions and the following disclaimer in the
13bc4c5135Scmetz * documentation and/or other materials provided with the distribution.
14bc4c5135Scmetz * 3. All advertising materials mentioning features or use of this software
15bc4c5135Scmetz * must display the following acknowledgement:
16bc4c5135Scmetz * This product includes software developed by Craig Metz and
17bc4c5135Scmetz * by other contributors.
18bc4c5135Scmetz * 4. Neither the name of the author nor the names of contributors
19bc4c5135Scmetz * may be used to endorse or promote products derived from this software
20bc4c5135Scmetz * without specific prior written permission.
21bc4c5135Scmetz *
22bc4c5135Scmetz * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23bc4c5135Scmetz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24bc4c5135Scmetz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25bc4c5135Scmetz * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26bc4c5135Scmetz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27bc4c5135Scmetz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28bc4c5135Scmetz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29bc4c5135Scmetz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30bc4c5135Scmetz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31bc4c5135Scmetz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32bc4c5135Scmetz * SUCH DAMAGE.
33bc4c5135Scmetz */
34bc4c5135Scmetz
35bc4c5135Scmetz /* gai_strerror() v1.38 */
36bc4c5135Scmetz
37bc4c5135Scmetz #include <sys/types.h>
38bc4c5135Scmetz #include <netdb.h>
39bc4c5135Scmetz #include <errno.h>
40bc4c5135Scmetz
416de6e276Smillert const char *
gai_strerror(int errnum)422c8de75eSderaadt gai_strerror(int errnum)
43bc4c5135Scmetz {
44bc4c5135Scmetz switch (errnum) {
45bc4c5135Scmetz case 0:
46bc4c5135Scmetz return "no error";
47bc4c5135Scmetz case EAI_BADFLAGS:
48bc4c5135Scmetz return "invalid value for ai_flags";
49bc4c5135Scmetz case EAI_NONAME:
50bc4c5135Scmetz return "name or service is not known";
51bc4c5135Scmetz case EAI_AGAIN:
52bc4c5135Scmetz return "temporary failure in name resolution";
53bc4c5135Scmetz case EAI_FAIL:
54bc4c5135Scmetz return "non-recoverable failure in name resolution";
55bc4c5135Scmetz case EAI_NODATA:
56bc4c5135Scmetz return "no address associated with name";
57bc4c5135Scmetz case EAI_FAMILY:
58bc4c5135Scmetz return "ai_family not supported";
59bc4c5135Scmetz case EAI_SOCKTYPE:
60bc4c5135Scmetz return "ai_socktype not supported";
61bc4c5135Scmetz case EAI_SERVICE:
62bc4c5135Scmetz return "service not supported for ai_socktype";
63bc4c5135Scmetz case EAI_ADDRFAMILY:
64bc4c5135Scmetz return "address family for name not supported";
65bc4c5135Scmetz case EAI_MEMORY:
66bc4c5135Scmetz return "memory allocation failure";
67bc4c5135Scmetz case EAI_SYSTEM:
68bc4c5135Scmetz return "system error";
6992f92416Sitojun case EAI_BADHINTS:
7092f92416Sitojun return "invalid value for hints";
7192f92416Sitojun case EAI_PROTOCOL:
7292f92416Sitojun return "resolved protocol is unknown";
73ab0c76cfSjasper case EAI_OVERFLOW:
74ab0c76cfSjasper return "argument buffer overflow";
75bc4c5135Scmetz default:
76bc4c5135Scmetz return "unknown/invalid error";
772c8de75eSderaadt }
782c8de75eSderaadt }
79*06201dd4Sguenther DEF_WEAK(gai_strerror);
80