1/* 2 * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14 * PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17/* Id: netdb.h.in,v 1.3 2009/09/02 23:48:02 tbox Exp */ 18 19/*! \file */ 20 21#ifndef IRS_NETDB_H 22#define IRS_NETDB_H 1 23 24#include <stddef.h> /* Required on FreeBSD (and others?) for size_t. */ 25#include <netdb.h> /* Contractual provision. */ 26 27/* 28 * Define if <netdb.h> does not declare struct addrinfo. 29 */ 30@ISC_IRS_NEEDADDRINFO@ 31 32#ifdef ISC_IRS_NEEDADDRINFO 33struct 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 * Undefine all #defines we are interested in as <netdb.h> may or may not have 47 * defined them. 48 */ 49 50/* 51 * Error return codes from gethostbyname() and gethostbyaddr() 52 * (left in extern int h_errno). 53 */ 54 55#undef NETDB_INTERNAL 56#undef NETDB_SUCCESS 57#undef HOST_NOT_FOUND 58#undef TRY_AGAIN 59#undef NO_RECOVERY 60#undef NO_DATA 61#undef NO_ADDRESS 62 63#define NETDB_INTERNAL -1 /* see errno */ 64#define NETDB_SUCCESS 0 /* no problem */ 65#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ 66#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ 67#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ 68#define NO_DATA 4 /* Valid name, no data record of requested type */ 69#define NO_ADDRESS NO_DATA /* no address, look for MX record */ 70 71/* 72 * Error return codes from getaddrinfo(). EAI_INSECUREDATA is our own extension 73 * and it's very unlikely to be already defined, but undef it just in case; it 74 * at least doesn't do any harm. 75 */ 76 77#undef EAI_ADDRFAMILY 78#undef EAI_AGAIN 79#undef EAI_BADFLAGS 80#undef EAI_FAIL 81#undef EAI_FAMILY 82#undef EAI_MEMORY 83#undef EAI_NODATA 84#undef EAI_NONAME 85#undef EAI_SERVICE 86#undef EAI_SOCKTYPE 87#undef EAI_SYSTEM 88#undef EAI_BADHINTS 89#undef EAI_PROTOCOL 90#undef EAI_OVERFLOW 91#undef EAI_INSECUREDATA 92#undef EAI_MAX 93 94#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ 95#define EAI_AGAIN 2 /* temporary failure in name resolution */ 96#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 97#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 98#define EAI_FAMILY 5 /* ai_family not supported */ 99#define EAI_MEMORY 6 /* memory allocation failure */ 100#define EAI_NODATA 7 /* no address associated with hostname */ 101#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ 102#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 103#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 104#define EAI_SYSTEM 11 /* system error returned in errno */ 105#define EAI_BADHINTS 12 106#define EAI_PROTOCOL 13 107#define EAI_OVERFLOW 14 108#define EAI_INSECUREDATA 15 109#define EAI_MAX 16 110 111/* 112 * Flag values for getaddrinfo() 113 */ 114#undef AI_PASSIVE 115#undef AI_CANONNAME 116#undef AI_NUMERICHOST 117 118#define AI_PASSIVE 0x00000001 119#define AI_CANONNAME 0x00000002 120#define AI_NUMERICHOST 0x00000004 121 122/* 123 * Flag values for getipnodebyname() 124 */ 125#undef AI_V4MAPPED 126#undef AI_ALL 127#undef AI_ADDRCONFIG 128#undef AI_DEFAULT 129 130#define AI_V4MAPPED 0x00000008 131#define AI_ALL 0x00000010 132#define AI_ADDRCONFIG 0x00000020 133#define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG) 134 135/* 136 * Constants for lwres_getnameinfo() 137 */ 138#undef NI_MAXHOST 139#undef NI_MAXSERV 140 141#define NI_MAXHOST 1025 142#define NI_MAXSERV 32 143 144/* 145 * Flag values for lwres_getnameinfo() 146 */ 147#undef NI_NOFQDN 148#undef NI_NUMERICHOST 149#undef NI_NAMEREQD 150#undef NI_NUMERICSERV 151#undef NI_DGRAM 152#undef NI_NUMERICSCOPE 153 154#define NI_NOFQDN 0x00000001 155#define NI_NUMERICHOST 0x00000002 156#define NI_NAMEREQD 0x00000004 157#define NI_NUMERICSERV 0x00000008 158#define NI_DGRAM 0x00000010 159 160/* 161 * Tell Emacs to use C mode on this file. 162 * Local variables: 163 * mode: c 164 * End: 165 */ 166 167#endif /* IRS_NETDB_H */ 168