1224090Sdougb/*
2224090Sdougb * Copyright (C) 2009  Internet Systems Consortium, Inc. ("ISC")
3224090Sdougb *
4224090Sdougb * Permission to use, copy, modify, and/or distribute this software for any
5224090Sdougb * purpose with or without fee is hereby granted, provided that the above
6224090Sdougb * copyright notice and this permission notice appear in all copies.
7224090Sdougb *
8224090Sdougb * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9224090Sdougb * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10224090Sdougb * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11224090Sdougb * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12224090Sdougb * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13224090Sdougb * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14224090Sdougb * PERFORMANCE OF THIS SOFTWARE.
15224090Sdougb */
16224090Sdougb
17234010Sdougb/* $Id: netdb.h.in,v 1.3 2009/09/02 23:48:02 tbox Exp $ */
18224090Sdougb
19224090Sdougb/*! \file */
20224090Sdougb
21224090Sdougb#ifndef IRS_NETDB_H
22224090Sdougb#define IRS_NETDB_H 1
23224090Sdougb
24224090Sdougb#include <stddef.h>	/* Required on FreeBSD (and  others?) for size_t. */
25224090Sdougb#include <netdb.h>	/* Contractual provision. */
26224090Sdougb
27224090Sdougb/*
28224090Sdougb * Define if <netdb.h> does not declare struct addrinfo.
29224090Sdougb */
30224090Sdougb@ISC_IRS_NEEDADDRINFO@
31224090Sdougb
32224090Sdougb#ifdef ISC_IRS_NEEDADDRINFO
33224090Sdougbstruct addrinfo {
34224090Sdougb	int		ai_flags;      /* AI_PASSIVE, AI_CANONNAME */
35224090Sdougb	int		ai_family;     /* PF_xxx */
36224090Sdougb	int		ai_socktype;   /* SOCK_xxx */
37224090Sdougb	int		ai_protocol;   /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
38224090Sdougb	size_t		ai_addrlen;    /* Length of ai_addr */
39224090Sdougb	char		*ai_canonname; /* Canonical name for hostname */
40224090Sdougb	struct sockaddr	*ai_addr;      /* Binary address */
41224090Sdougb	struct addrinfo	*ai_next;      /* Next structure in linked list */
42224090Sdougb};
43224090Sdougb#endif
44224090Sdougb
45224090Sdougb/*
46224090Sdougb * Undefine all #defines we are interested in as <netdb.h> may or may not have
47224090Sdougb * defined them.
48224090Sdougb */
49224090Sdougb
50224090Sdougb/*
51224090Sdougb * Error return codes from gethostbyname() and gethostbyaddr()
52224090Sdougb * (left in extern int h_errno).
53224090Sdougb */
54224090Sdougb
55224090Sdougb#undef	NETDB_INTERNAL
56224090Sdougb#undef	NETDB_SUCCESS
57224090Sdougb#undef	HOST_NOT_FOUND
58224090Sdougb#undef	TRY_AGAIN
59224090Sdougb#undef	NO_RECOVERY
60224090Sdougb#undef	NO_DATA
61224090Sdougb#undef	NO_ADDRESS
62224090Sdougb
63224090Sdougb#define	NETDB_INTERNAL	-1	/* see errno */
64224090Sdougb#define	NETDB_SUCCESS	0	/* no problem */
65224090Sdougb#define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
66224090Sdougb#define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
67224090Sdougb#define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
68224090Sdougb#define	NO_DATA		4 /* Valid name, no data record of requested type */
69224090Sdougb#define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
70224090Sdougb
71224090Sdougb/*
72224090Sdougb * Error return codes from getaddrinfo().  EAI_INSECUREDATA is our own extension
73224090Sdougb * and it's very unlikely to be already defined, but undef it just in case; it
74224090Sdougb * at least doesn't do any harm.
75224090Sdougb */
76224090Sdougb
77224090Sdougb#undef	EAI_ADDRFAMILY
78224090Sdougb#undef	EAI_AGAIN
79224090Sdougb#undef	EAI_BADFLAGS
80224090Sdougb#undef	EAI_FAIL
81224090Sdougb#undef	EAI_FAMILY
82224090Sdougb#undef	EAI_MEMORY
83224090Sdougb#undef	EAI_NODATA
84224090Sdougb#undef	EAI_NONAME
85224090Sdougb#undef	EAI_SERVICE
86224090Sdougb#undef	EAI_SOCKTYPE
87224090Sdougb#undef	EAI_SYSTEM
88224090Sdougb#undef	EAI_BADHINTS
89224090Sdougb#undef	EAI_PROTOCOL
90224090Sdougb#undef	EAI_OVERFLOW
91224090Sdougb#undef	EAI_INSECUREDATA
92224090Sdougb#undef	EAI_MAX
93224090Sdougb
94224090Sdougb#define	EAI_ADDRFAMILY	 1	/* address family for hostname not supported */
95224090Sdougb#define	EAI_AGAIN	 2	/* temporary failure in name resolution */
96224090Sdougb#define	EAI_BADFLAGS	 3	/* invalid value for ai_flags */
97224090Sdougb#define	EAI_FAIL	 4	/* non-recoverable failure in name resolution */
98224090Sdougb#define	EAI_FAMILY	 5	/* ai_family not supported */
99224090Sdougb#define	EAI_MEMORY	 6	/* memory allocation failure */
100224090Sdougb#define	EAI_NODATA	 7	/* no address associated with hostname */
101224090Sdougb#define	EAI_NONAME	 8	/* hostname nor servname provided, or not known */
102224090Sdougb#define	EAI_SERVICE	 9	/* servname not supported for ai_socktype */
103224090Sdougb#define	EAI_SOCKTYPE	10	/* ai_socktype not supported */
104224090Sdougb#define	EAI_SYSTEM	11	/* system error returned in errno */
105224090Sdougb#define EAI_BADHINTS	12
106224090Sdougb#define EAI_PROTOCOL	13
107224090Sdougb#define EAI_OVERFLOW	14
108224090Sdougb#define EAI_INSECUREDATA 15
109224090Sdougb#define EAI_MAX		16
110224090Sdougb
111224090Sdougb/*
112224090Sdougb * Flag values for getaddrinfo()
113224090Sdougb */
114224090Sdougb#undef	AI_PASSIVE
115224090Sdougb#undef	AI_CANONNAME
116224090Sdougb#undef	AI_NUMERICHOST
117224090Sdougb
118224090Sdougb#define	AI_PASSIVE	0x00000001
119224090Sdougb#define	AI_CANONNAME	0x00000002
120224090Sdougb#define AI_NUMERICHOST	0x00000004
121224090Sdougb
122224090Sdougb/*
123224090Sdougb * Flag values for getipnodebyname()
124224090Sdougb */
125224090Sdougb#undef AI_V4MAPPED
126224090Sdougb#undef AI_ALL
127224090Sdougb#undef AI_ADDRCONFIG
128224090Sdougb#undef AI_DEFAULT
129224090Sdougb
130224090Sdougb#define AI_V4MAPPED	0x00000008
131224090Sdougb#define AI_ALL		0x00000010
132224090Sdougb#define AI_ADDRCONFIG	0x00000020
133224090Sdougb#define AI_DEFAULT	(AI_V4MAPPED|AI_ADDRCONFIG)
134224090Sdougb
135224090Sdougb/*
136224090Sdougb * Constants for lwres_getnameinfo()
137224090Sdougb */
138224090Sdougb#undef	NI_MAXHOST
139224090Sdougb#undef	NI_MAXSERV
140224090Sdougb
141224090Sdougb#define	NI_MAXHOST	1025
142224090Sdougb#define	NI_MAXSERV	32
143224090Sdougb
144224090Sdougb/*
145224090Sdougb * Flag values for lwres_getnameinfo()
146224090Sdougb */
147224090Sdougb#undef	NI_NOFQDN
148224090Sdougb#undef	NI_NUMERICHOST
149224090Sdougb#undef	NI_NAMEREQD
150224090Sdougb#undef	NI_NUMERICSERV
151224090Sdougb#undef	NI_DGRAM
152224090Sdougb#undef	NI_NUMERICSCOPE
153224090Sdougb
154224090Sdougb#define	NI_NOFQDN	0x00000001
155224090Sdougb#define	NI_NUMERICHOST	0x00000002
156224090Sdougb#define	NI_NAMEREQD	0x00000004
157224090Sdougb#define	NI_NUMERICSERV	0x00000008
158224090Sdougb#define	NI_DGRAM	0x00000010
159224090Sdougb
160224090Sdougb/*
161224090Sdougb * Tell Emacs to use C mode on this file.
162224090Sdougb * Local variables:
163224090Sdougb * mode: c
164224090Sdougb * End:
165224090Sdougb */
166224090Sdougb
167224090Sdougb#endif /* IRS_NETDB_H */
168