12949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/* 22949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. 32949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * All rights reserved. 42949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 52949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * Redistribution and use in source and binary forms, with or without 62949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * modification, are permitted provided that the following conditions 72949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * are met: 82949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 92949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * notice, this list of conditions and the following disclaimer. 102949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 112949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 122949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * documentation and/or other materials provided with the distribution. 132949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 3. Neither the name of the project nor the names of its contributors 142949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * may be used to endorse or promote products derived from this software 152949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * without specific prior written permission. 162949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * 172949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 182949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 192949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 202949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 212949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 222949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 232949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 242949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 252949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 262949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 272949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * SUCH DAMAGE. 282949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project */ 292949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project 302949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/* $Id: addrinfo.h,v 1.4 2002/06/11 17:13:36 itojun Exp $ */ 312949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project 322949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#ifndef HAVE_ADDRINFO 332949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project 342949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/* 352949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * Error return codes from getaddrinfo() 362949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project */ 372949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ 382949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_AGAIN 2 /* temporary failure in name resolution */ 392949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 402949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 412949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_FAMILY 5 /* ai_family not supported */ 422949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_MEMORY 6 /* memory allocation failure */ 432949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_NODATA 7 /* no address associated with hostname */ 442949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ 452949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 462949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 472949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_SYSTEM 11 /* system error returned in errno */ 482949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_BADHINTS 12 492949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_PROTOCOL 13 502949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define EAI_MAX 14 512949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project 522949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/* internal error */ 532949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define NETDB_INTERNAL -1 /* see errno */ 542949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project 552949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/* 562949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * Flag values for getaddrinfo() 572949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project */ 582949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define AI_PASSIVE 0x00000001 /* get address to use bind() */ 592949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define AI_CANONNAME 0x00000002 /* fill ai_canonname */ 602949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ 612949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/* valid flags for addrinfo */ 622949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) 632949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project 642949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ 652949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ 662949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ 672949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ 682949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/* special recommended flags for getipnodebyname */ 692949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) 702949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project 712949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectstruct addrinfo { 722949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 732949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project int ai_family; /* PF_xxx */ 742949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project int ai_socktype; /* SOCK_xxx */ 752949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 762949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project size_t ai_addrlen; /* length of ai_addr */ 772949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project char *ai_canonname; /* canonical name for hostname */ 782949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project struct sockaddr *ai_addr; /* binary address */ 792949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project struct addrinfo *ai_next; /* next structure in linked list */ 802949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project}; 812949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project 822949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectextern void freeaddrinfo (struct addrinfo *); 832949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectextern void freehostent (struct hostent *); 842949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectextern char *gai_strerror (int); 852949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectextern int getaddrinfo (const char *, const char *, 862949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project const struct addrinfo *, struct addrinfo **); 872949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectextern int getnameinfo (const struct sockaddr *, size_t, char *, 882949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project size_t, char *, size_t, int); 892949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectextern struct hostent *getipnodebyaddr (const void *, size_t, int, int *); 902949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectextern struct hostent *getipnodebyname (const char *, int, int, int *); 912949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectextern int inet_pton (int, const char *, void *); 922949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Projectextern const char *inet_ntop (int, const void *, char *, size_t); 932949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#endif /* HAVE_ADDRINFO */ 942949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project 952949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/* 962949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * Constants for getnameinfo() 972949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project */ 982949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#ifndef NI_MAXHOST 992949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define NI_MAXHOST 1025 1002949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#endif 1012949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#ifndef NI_MAXSERV 1022949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define NI_MAXSERV 32 1032949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#endif 1042949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project 1052949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project/* 1062949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project * Flag values for getnameinfo() 1072949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project */ 1082949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#ifndef NI_NOFQDN 1092949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define NI_NOFQDN 0x00000001 1102949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#endif 1112949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#ifndef NI_NUMERICHOST 1122949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define NI_NUMERICHOST 0x00000002 1132949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#endif 1142949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#ifndef NI_NAMEREQD 1152949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define NI_NAMEREQD 0x00000004 1162949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#endif 1172949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#ifndef NI_NUMERICSERV 1182949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define NI_NUMERICSERV 0x00000008 1192949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#endif 1202949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#ifndef NI_DGRAM 1212949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#define NI_DGRAM 0x00000010 1222949f58a438f6fd85f66a8b7ed4708042cde4b37The Android Open Source Project#endif 123