1 /* $NetBSD: addrinfo.h,v 1.3 2014/12/10 04:37:56 christos Exp $ */ 2 3 /* 4 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the project nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32 #ifndef HAVE_GETADDRINFO 33 34 /* 35 * Error return codes from getaddrinfo() 36 */ 37 #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ 38 #define EAI_AGAIN 2 /* temporary failure in name resolution */ 39 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 40 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 41 #define EAI_FAMILY 5 /* ai_family not supported */ 42 #define EAI_MEMORY 6 /* memory allocation failure */ 43 #define EAI_NODATA 7 /* no address associated with hostname */ 44 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */ 45 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 46 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 47 #define EAI_SYSTEM 11 /* system error returned in errno */ 48 #define EAI_BADHINTS 12 49 #define EAI_PROTOCOL 13 50 #define EAI_MAX 14 51 52 /* 53 * Flag values for getaddrinfo() 54 */ 55 #define AI_PASSIVE 0x00000001 /* get address to use bind() */ 56 #define AI_CANONNAME 0x00000002 /* fill ai_canonname */ 57 #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ 58 /* valid flags for addrinfo */ 59 #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) 60 61 #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ 62 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ 63 #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ 64 #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ 65 /* special recommended flags for getipnodebyname */ 66 #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) 67 68 /* 69 * Constants for getnameinfo() 70 */ 71 #define NI_MAXHOST 1025 72 #define NI_MAXSERV 32 73 74 /* 75 * Flag values for getnameinfo() 76 */ 77 #define NI_NOFQDN 0x00000001 78 #define NI_NUMERICHOST 0x00000002 79 #define NI_NAMEREQD 0x00000004 80 #define NI_NUMERICSERV 0x00000008 81 #define NI_DGRAM 0x00000010 82 83 struct addrinfo { 84 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 85 int ai_family; /* PF_xxx */ 86 int ai_socktype; /* SOCK_xxx */ 87 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 88 size_t ai_addrlen; /* length of ai_addr */ 89 char *ai_canonname; /* canonical name for hostname */ 90 struct sockaddr *ai_addr; /* binary address */ 91 struct addrinfo *ai_next; /* next structure in linked list */ 92 }; 93 94 struct sockaddr_storage { 95 u_char __ss_len; 96 u_char __ss_family; 97 u_char fill[126]; 98 }; 99 100 extern void freehostent(struct hostent *); 101 extern char *gai_strerror(int); 102 #endif 103