1290001Sglebius/* 2290001Sglebius * Copyright (C) 2004, 2006, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") 3290001Sglebius * Copyright (C) 2000, 2001 Internet Software Consortium. 4290001Sglebius * 5290001Sglebius * Permission to use, copy, modify, and/or distribute this software for any 6290001Sglebius * purpose with or without fee is hereby granted, provided that the above 7290001Sglebius * copyright notice and this permission notice appear in all copies. 8290001Sglebius * 9290001Sglebius * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10290001Sglebius * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11290001Sglebius * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12290001Sglebius * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13290001Sglebius * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14290001Sglebius * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15290001Sglebius * PERFORMANCE OF THIS SOFTWARE. 16290001Sglebius */ 17290001Sglebius 18290001Sglebius/* $Id: netdb.h,v 1.9 2009/01/18 23:48:14 tbox Exp $ */ 19290001Sglebius 20290001Sglebius#ifndef NETDB_H 21290001Sglebius#define NETDB_H 1 22290001Sglebius 23290001Sglebius#include <stddef.h> 24290001Sglebius#include <winsock2.h> 25290001Sglebius 26290001Sglebius/* 27290001Sglebius * Define if <netdb.h> does not declare struct addrinfo. 28290001Sglebius */ 29290001Sglebius 30290001Sglebiusstruct addrinfo { 31290001Sglebius int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 32290001Sglebius int ai_family; /* PF_xxx */ 33290001Sglebius int ai_socktype; /* SOCK_xxx */ 34290001Sglebius int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 35290001Sglebius size_t ai_addrlen; /* Length of ai_addr */ 36290001Sglebius char *ai_canonname; /* Canonical name for hostname */ 37290001Sglebius struct sockaddr *ai_addr; /* Binary address */ 38290001Sglebius struct addrinfo *ai_next; /* Next structure in linked list */ 39290001Sglebius}; 40290001Sglebius 41290001Sglebius 42290001Sglebius/* 43290001Sglebius * Undefine all \#defines we are interested in as <netdb.h> may or may not have 44290001Sglebius * defined them. 45290001Sglebius */ 46290001Sglebius 47290001Sglebius/* 48290001Sglebius * Error return codes from gethostbyname() and gethostbyaddr() 49290001Sglebius * (left in extern int h_errno). 50290001Sglebius */ 51290001Sglebius 52290001Sglebius#undef NETDB_INTERNAL 53290001Sglebius#undef NETDB_SUCCESS 54290001Sglebius#undef HOST_NOT_FOUND 55290001Sglebius#undef TRY_AGAIN 56290001Sglebius#undef NO_RECOVERY 57290001Sglebius#undef NO_DATA 58290001Sglebius#undef NO_ADDRESS 59290001Sglebius 60290001Sglebius#define NETDB_INTERNAL -1 /* see errno */ 61290001Sglebius#define NETDB_SUCCESS 0 /* no problem */ 62290001Sglebius#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ 63290001Sglebius#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */ 64290001Sglebius#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ 65290001Sglebius#define NO_DATA 4 /* Valid name, no data record of requested type */ 66290001Sglebius#define NO_ADDRESS NO_DATA /* no address, look for MX record */ 67290001Sglebius 68290001Sglebius/* 69290001Sglebius * Error return codes from getaddrinfo() 70290001Sglebius */ 71290001Sglebius 72290001Sglebius#undef EAI_ADDRFAMILY 73290001Sglebius#undef EAI_AGAIN 74290001Sglebius#undef EAI_BADFLAGS 75290001Sglebius#undef EAI_FAIL 76290001Sglebius#undef EAI_FAMILY 77290001Sglebius#undef EAI_MEMORY 78290001Sglebius#undef EAI_NODATA 79290001Sglebius#undef EAI_NONAME 80290001Sglebius#undef EAI_SERVICE 81290001Sglebius#undef EAI_SOCKTYPE 82290001Sglebius#undef EAI_SYSTEM 83290001Sglebius#undef EAI_BADHINTS 84290001Sglebius#undef EAI_PROTOCOL 85290001Sglebius#undef EAI_MAX 86290001Sglebius 87290001Sglebius#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ 88290001Sglebius#define EAI_AGAIN 2 /* temporary failure in name resolution */ 89290001Sglebius#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 90290001Sglebius#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 91290001Sglebius#define EAI_FAMILY 5 /* ai_family not supported */ 92290001Sglebius#define EAI_MEMORY 6 /* memory allocation failure */ 93290001Sglebius#define EAI_NODATA 7 /* no address associated with hostname */ 94290001Sglebius#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ 95290001Sglebius#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 96290001Sglebius#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 97290001Sglebius#define EAI_SYSTEM 11 /* system error returned in errno */ 98290001Sglebius#define EAI_BADHINTS 12 99290001Sglebius#define EAI_PROTOCOL 13 100290001Sglebius#define EAI_MAX 14 101290001Sglebius 102290001Sglebius/* 103290001Sglebius * Flag values for getaddrinfo() 104290001Sglebius */ 105290001Sglebius#undef AI_PASSIVE 106290001Sglebius#undef AI_CANONNAME 107290001Sglebius#undef AI_NUMERICHOST 108290001Sglebius 109290001Sglebius#define AI_PASSIVE 0x00000001 110290001Sglebius#define AI_CANONNAME 0x00000002 111290001Sglebius#define AI_NUMERICHOST 0x00000004 112290001Sglebius 113290001Sglebius/* 114290001Sglebius * Flag values for getipnodebyname() 115290001Sglebius */ 116290001Sglebius#undef AI_V4MAPPED 117290001Sglebius#undef AI_ALL 118290001Sglebius#undef AI_ADDRCONFIG 119290001Sglebius#undef AI_DEFAULT 120290001Sglebius 121290001Sglebius#define AI_V4MAPPED 0x00000008 122290001Sglebius#define AI_ALL 0x00000010 123290001Sglebius#define AI_ADDRCONFIG 0x00000020 124290001Sglebius#define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG) 125290001Sglebius 126290001Sglebius/* 127290001Sglebius * Constants for getnameinfo() 128290001Sglebius */ 129290001Sglebius#undef NI_MAXHOST 130290001Sglebius#undef NI_MAXSERV 131290001Sglebius 132290001Sglebius#define NI_MAXHOST 1025 133290001Sglebius#define NI_MAXSERV 32 134290001Sglebius 135290001Sglebius/* 136290001Sglebius * Flag values for getnameinfo() 137290001Sglebius */ 138290001Sglebius#undef NI_NOFQDN 139290001Sglebius#undef NI_NUMERICHOST 140290001Sglebius#undef NI_NAMEREQD 141290001Sglebius#undef NI_NUMERICSERV 142290001Sglebius#undef NI_DGRAM 143290001Sglebius#undef NI_NUMERICSCOPE 144290001Sglebius 145290001Sglebius#define NI_NOFQDN 0x00000001 146290001Sglebius#define NI_NUMERICHOST 0x00000002 147290001Sglebius#define NI_NAMEREQD 0x00000004 148290001Sglebius#define NI_NUMERICSERV 0x00000008 149290001Sglebius#define NI_DGRAM 0x00000010 150290001Sglebius#define NI_NUMERICSCOPE 0x00000020 /*2553bis-00*/ 151290001Sglebius 152290001Sglebius/* 153290001Sglebius * Structures for getrrsetbyname() 154290001Sglebius */ 155290001Sglebiusstruct rdatainfo { 156290001Sglebius unsigned int rdi_length; 157290001Sglebius unsigned char *rdi_data; 158290001Sglebius}; 159290001Sglebius 160290001Sglebiusstruct rrsetinfo { 161290001Sglebius unsigned int rri_flags; 162290001Sglebius int rri_rdclass; 163290001Sglebius int rri_rdtype; 164290001Sglebius unsigned int rri_ttl; 165290001Sglebius unsigned int rri_nrdatas; 166290001Sglebius unsigned int rri_nsigs; 167290001Sglebius char *rri_name; 168290001Sglebius struct rdatainfo *rri_rdatas; 169290001Sglebius struct rdatainfo *rri_sigs; 170290001Sglebius}; 171290001Sglebius 172290001Sglebius/* 173290001Sglebius * Flags for getrrsetbyname() 174290001Sglebius */ 175290001Sglebius#define RRSET_VALIDATED 0x00000001 176290001Sglebius /* Set was dnssec validated */ 177290001Sglebius 178290001Sglebius/* 179290001Sglebius * Return codes for getrrsetbyname() 180290001Sglebius */ 181290001Sglebius#define ERRSET_SUCCESS 0 182290001Sglebius#define ERRSET_NOMEMORY 1 183290001Sglebius#define ERRSET_FAIL 2 184290001Sglebius#define ERRSET_INVAL 3 185290001Sglebius 186290001Sglebius 187290001Sglebius#endif /* NETDB_H */ 188