addrinfo.h revision 75115
138919Salex/* 238919Salex * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. 338919Salex * All rights reserved. 438919Salex * 538919Salex * Redistribution and use in source and binary forms, with or without 638919Salex * modification, are permitted provided that the following conditions 738919Salex * are met: 838919Salex * 1. Redistributions of source code must retain the above copyright 938919Salex * notice, this list of conditions and the following disclaimer. 1038919Salex * 2. Redistributions in binary form must reproduce the above copyright 1138919Salex * notice, this list of conditions and the following disclaimer in the 1238919Salex * documentation and/or other materials provided with the distribution. 1338919Salex * 3. Neither the name of the project nor the names of its contributors 1438919Salex * may be used to endorse or promote products derived from this software 1538919Salex * without specific prior written permission. 1638919Salex * 1738919Salex * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 1838919Salex * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1938919Salex * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2038919Salex * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2138919Salex * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2238919Salex * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2338919Salex * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2438919Salex * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2550476Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2638919Salex * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2738919Salex * SUCH DAMAGE. 2838919Salex */ 2938919Salex 3038919Salex/* $Id: addrinfo.h,v 1.3 2000/10/24 00:56:52 fenner Exp $ */ 3138919Salex 3238919Salex#ifndef HAVE_ADDRINFO 3338919Salex 3459501Sphantom/* 35124535Sru * Error return codes from getaddrinfo() 3638919Salex */ 3784306Sru#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ 3838919Salex#define EAI_AGAIN 2 /* temporary failure in name resolution */ 3938919Salex#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 4038919Salex#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 4138919Salex#define EAI_FAMILY 5 /* ai_family not supported */ 4238919Salex#define EAI_MEMORY 6 /* memory allocation failure */ 4338919Salex#define EAI_NODATA 7 /* no address associated with hostname */ 4438919Salex#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ 4538919Salex#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 4638919Salex#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 4738919Salex#define EAI_SYSTEM 11 /* system error returned in errno */ 4838919Salex#define EAI_BADHINTS 12 4938919Salex#define EAI_PROTOCOL 13 50131530Sru#define EAI_MAX 14 51131530Sru 5238919Salex/* internal error */ 5338919Salex#define NETDB_INTERNAL -1 /* see errno */ 5438919Salex 5538919Salex/* 5638919Salex * Flag values for getaddrinfo() 5738919Salex */ 58131530Sru#define AI_PASSIVE 0x00000001 /* get address to use bind() */ 5938919Salex#define AI_CANONNAME 0x00000002 /* fill ai_canonname */ 6038919Salex#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ 61131530Sru/* valid flags for addrinfo */ 62131530Sru#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) 6338919Salex 6438919Salex#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ 6538919Salex#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ 6638919Salex#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ 6738919Salex#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ 6838919Salex/* special recommended flags for getipnodebyname */ 6938919Salex#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) 7038919Salex 7138919Salexstruct addrinfo { 7238919Salex int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 7338919Salex int ai_family; /* PF_xxx */ 7438919Salex int ai_socktype; /* SOCK_xxx */ 75131530Sru int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 76131530Sru size_t ai_addrlen; /* length of ai_addr */ 7738919Salex char *ai_canonname; /* canonical name for hostname */ 7838919Salex struct sockaddr *ai_addr; /* binary address */ 7938919Salex struct addrinfo *ai_next; /* next structure in linked list */ 8038919Salex}; 8138919Salex 8238919Salexextern void freeaddrinfo (struct addrinfo *); 8338919Salexextern void freehostent (struct hostent *); 8438919Salexextern char *gai_strerror (int); 8538919Salexextern int getaddrinfo (const char *, const char *, 8638919Salex const struct addrinfo *, struct addrinfo **); 8738919Salexextern int getnameinfo (const struct sockaddr *, size_t, char *, 8838919Salex size_t, char *, size_t, int); 8938919Salexextern struct hostent *getipnodebyaddr (const void *, size_t, int, int *); 9038919Salexextern struct hostent *getipnodebyname (const char *, int, int, int *); 9138919Salexextern int inet_pton (int, const char *, void *); 9238919Salexextern const char *inet_ntop (int, const void *, char *, size_t); 9338919Salex#endif /* HAVE_ADDRINFO */ 9438919Salex 9538919Salex/* 9638919Salex * Constants for getnameinfo() 9738919Salex */ 9838919Salex#ifndef NI_MAXHOST 9938919Salex#define NI_MAXHOST 1025 10038919Salex#endif 10138919Salex#ifndef NI_MAXSERV 10238919Salex#define NI_MAXSERV 32 10338919Salex#endif 10438919Salex 10538919Salex/* 10638919Salex * Flag values for getnameinfo() 10738919Salex */ 10838919Salex#ifndef NI_NOFQDN 10938919Salex#define NI_NOFQDN 0x00000001 11038919Salex#endif 111140561Sru#ifndef NI_NUMERICHOST 112140561Sru#define NI_NUMERICHOST 0x00000002 113140561Sru#endif 114140561Sru#ifndef NI_NAMEREQD 115140561Sru#define NI_NAMEREQD 0x00000004 116140561Sru#endif 117140561Sru#ifndef NI_NUMERICSERV 118140561Sru#define NI_NUMERICSERV 0x00000008 119140561Sru#endif 120140561Sru#ifndef NI_DGRAM 121140561Sru#define NI_DGRAM 0x00000010 122140561Sru#endif 12338919Salex