00001 /* 00002 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. Neither the name of the project nor the names of its contributors 00014 * may be used to endorse or promote products derived from this software 00015 * without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 00018 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 00021 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00023 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00024 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00025 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00027 * SUCH DAMAGE. 00028 */ 00029 00030 /** 00031 * @file addrinfo.h 00032 * 00033 * Replacement getaddrinfo() for machines that don't have it. The new 00034 * getaddrinfo()/getnameinfo() interface is implemented on top of the 00035 * traditional resolver calls. 00036 **/ 00037 00038 #ifndef HAVE_GETADDRINFO 00039 00040 #ifndef EAI_ADDRFAMILY 00041 /* 00042 * Error return codes from getaddrinfo() 00043 */ 00044 #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ 00045 #define EAI_AGAIN 2 /* temporary failure in name resolution */ 00046 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 00047 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 00048 #define EAI_FAMILY 5 /* ai_family not supported */ 00049 #define EAI_MEMORY 6 /* memory allocation failure */ 00050 #define EAI_NODATA 7 /* no address associated with hostname */ 00051 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */ 00052 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 00053 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 00054 #define EAI_SYSTEM 11 /* system error returned in errno */ 00055 #define EAI_BADHINTS 12 00056 #define EAI_PROTOCOL 13 00057 #define EAI_MAX 14 00058 #endif /* ndef EAI_ADDRFAMILY */ 00059 00060 /* 00061 * Flag values for getaddrinfo() 00062 */ 00063 00064 #ifndef AI_PASSIVE 00065 00066 #define AI_PASSIVE 0x00000001 /* get address to use bind() */ 00067 #define AI_CANONNAME 0x00000002 /* fill ai_canonname */ 00068 #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ 00069 /* valid flags for addrinfo */ 00070 #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) 00071 00072 #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ 00073 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ 00074 #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ 00075 #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ 00076 /* special recommended flags for getipnodebyname */ 00077 #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) 00078 00079 /* 00080 * Constants for getnameinfo() 00081 */ 00082 #define NI_MAXHOST 1025 00083 #define NI_MAXSERV 32 00084 00085 /* 00086 * Flag values for getnameinfo() 00087 */ 00088 #define NI_NOFQDN 0x00000001 00089 #define NI_NUMERICHOST 0x00000002 00090 #define NI_NAMEREQD 0x00000004 00091 #define NI_NUMERICSERV 0x00000008 00092 #define NI_DGRAM 0x00000010 00093 00094 struct addrinfo { 00095 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 00096 int ai_family; /* PF_xxx */ 00097 int ai_socktype; /* SOCK_xxx */ 00098 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 00099 size_t ai_addrlen; /* length of ai_addr */ 00100 char *ai_canonname; /* canonical name for hostname */ 00101 struct sockaddr *ai_addr; /* binary address */ 00102 struct addrinfo *ai_next; /* next structure in linked list */ 00103 }; 00104 00105 extern void freehostent(struct hostent *); 00106 extern char *gai_strerror(int); 00107 #endif /* AI_PASSIVE */ 00108 #endif /* HAVE_GETADDRINFO */ 00109 00110 #ifndef HAVE_SOCKADDR_STORAGE 00111 struct sockaddr_storage { 00112 unsigned long align; 00113 unsigned char fill[128 - sizeof (unsigned long)]; 00114 }; 00115 #endif