netdb.h revision 290001
1/* 2 * Copyright (C) 2004, 2006, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") 3 * Copyright (C) 2000, 2001 Internet Software Consortium. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15 * PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18/* $Id: netdb.h,v 1.9 2009/01/18 23:48:14 tbox Exp $ */ 19 20#ifndef NETDB_H 21#define NETDB_H 1 22 23#include <stddef.h> 24#include <winsock2.h> 25 26/* 27 * Define if <netdb.h> does not declare struct addrinfo. 28 */ 29 30struct addrinfo { 31 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 32 int ai_family; /* PF_xxx */ 33 int ai_socktype; /* SOCK_xxx */ 34 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 35 size_t ai_addrlen; /* Length of ai_addr */ 36 char *ai_canonname; /* Canonical name for hostname */ 37 struct sockaddr *ai_addr; /* Binary address */ 38 struct addrinfo *ai_next; /* Next structure in linked list */ 39}; 40 41 42/* 43 * Undefine all \#defines we are interested in as <netdb.h> may or may not have 44 * defined them. 45 */ 46 47/* 48 * Error return codes from gethostbyname() and gethostbyaddr() 49 * (left in extern int h_errno). 50 */ 51 52#undef NETDB_INTERNAL 53#undef NETDB_SUCCESS 54#undef HOST_NOT_FOUND 55#undef TRY_AGAIN 56#undef NO_RECOVERY 57#undef NO_DATA 58#undef NO_ADDRESS 59 60#define NETDB_INTERNAL -1 /* see errno */ 61#define NETDB_SUCCESS 0 /* no problem */ 62#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ 63#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */ 64#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ 65#define NO_DATA 4 /* Valid name, no data record of requested type */ 66#define NO_ADDRESS NO_DATA /* no address, look for MX record */ 67 68/* 69 * Error return codes from getaddrinfo() 70 */ 71 72#undef EAI_ADDRFAMILY 73#undef EAI_AGAIN 74#undef EAI_BADFLAGS 75#undef EAI_FAIL 76#undef EAI_FAMILY 77#undef EAI_MEMORY 78#undef EAI_NODATA 79#undef EAI_NONAME 80#undef EAI_SERVICE 81#undef EAI_SOCKTYPE 82#undef EAI_SYSTEM 83#undef EAI_BADHINTS 84#undef EAI_PROTOCOL 85#undef EAI_MAX 86 87#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ 88#define EAI_AGAIN 2 /* temporary failure in name resolution */ 89#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 90#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 91#define EAI_FAMILY 5 /* ai_family not supported */ 92#define EAI_MEMORY 6 /* memory allocation failure */ 93#define EAI_NODATA 7 /* no address associated with hostname */ 94#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ 95#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 96#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 97#define EAI_SYSTEM 11 /* system error returned in errno */ 98#define EAI_BADHINTS 12 99#define EAI_PROTOCOL 13 100#define EAI_MAX 14 101 102/* 103 * Flag values for getaddrinfo() 104 */ 105#undef AI_PASSIVE 106#undef AI_CANONNAME 107#undef AI_NUMERICHOST 108 109#define AI_PASSIVE 0x00000001 110#define AI_CANONNAME 0x00000002 111#define AI_NUMERICHOST 0x00000004 112 113/* 114 * Flag values for getipnodebyname() 115 */ 116#undef AI_V4MAPPED 117#undef AI_ALL 118#undef AI_ADDRCONFIG 119#undef AI_DEFAULT 120 121#define AI_V4MAPPED 0x00000008 122#define AI_ALL 0x00000010 123#define AI_ADDRCONFIG 0x00000020 124#define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG) 125 126/* 127 * Constants for getnameinfo() 128 */ 129#undef NI_MAXHOST 130#undef NI_MAXSERV 131 132#define NI_MAXHOST 1025 133#define NI_MAXSERV 32 134 135/* 136 * Flag values for getnameinfo() 137 */ 138#undef NI_NOFQDN 139#undef NI_NUMERICHOST 140#undef NI_NAMEREQD 141#undef NI_NUMERICSERV 142#undef NI_DGRAM 143#undef NI_NUMERICSCOPE 144 145#define NI_NOFQDN 0x00000001 146#define NI_NUMERICHOST 0x00000002 147#define NI_NAMEREQD 0x00000004 148#define NI_NUMERICSERV 0x00000008 149#define NI_DGRAM 0x00000010 150#define NI_NUMERICSCOPE 0x00000020 /*2553bis-00*/ 151 152/* 153 * Structures for getrrsetbyname() 154 */ 155struct rdatainfo { 156 unsigned int rdi_length; 157 unsigned char *rdi_data; 158}; 159 160struct rrsetinfo { 161 unsigned int rri_flags; 162 int rri_rdclass; 163 int rri_rdtype; 164 unsigned int rri_ttl; 165 unsigned int rri_nrdatas; 166 unsigned int rri_nsigs; 167 char *rri_name; 168 struct rdatainfo *rri_rdatas; 169 struct rdatainfo *rri_sigs; 170}; 171 172/* 173 * Flags for getrrsetbyname() 174 */ 175#define RRSET_VALIDATED 0x00000001 176 /* Set was dnssec validated */ 177 178/* 179 * Return codes for getrrsetbyname() 180 */ 181#define ERRSET_SUCCESS 0 182#define ERRSET_NOMEMORY 1 183#define ERRSET_FAIL 2 184#define ERRSET_INVAL 3 185 186 187#endif /* NETDB_H */ 188