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