1/*	$NetBSD: netdb.h,v 1.2.6.1 2012/06/05 21:15:32 bouyer Exp $	*/
2
3/*
4 * Copyright (C) 2004, 2006, 2007, 2009  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
32struct addrinfo {
33	int		ai_flags;      /* AI_PASSIVE, AI_CANONNAME */
34	int		ai_family;     /* PF_xxx */
35	int		ai_socktype;   /* SOCK_xxx */
36	int		ai_protocol;   /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
37	size_t		ai_addrlen;    /* Length of ai_addr */
38	char		*ai_canonname; /* Canonical name for hostname */
39	struct sockaddr	*ai_addr;      /* Binary address */
40	struct addrinfo	*ai_next;      /* Next structure in linked list */
41};
42
43
44/*
45 * Undefine all \#defines we are interested in as <netdb.h> may or may not have
46 * defined them.
47 */
48
49/*
50 * Error return codes from gethostbyname() and gethostbyaddr()
51 * (left in extern int h_errno).
52 */
53
54#undef	NETDB_INTERNAL
55#undef	NETDB_SUCCESS
56#undef	HOST_NOT_FOUND
57#undef	TRY_AGAIN
58#undef	NO_RECOVERY
59#undef	NO_DATA
60#undef	NO_ADDRESS
61
62#define	NETDB_INTERNAL	-1	/* see errno */
63#define	NETDB_SUCCESS	0	/* no problem */
64#define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
65#define	TRY_AGAIN	2 /* Non-Authoritative Host not found, or SERVERFAIL */
66#define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
67#define	NO_DATA		4 /* Valid name, no data record of requested type */
68#define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
69
70/*
71 * Error return codes from getaddrinfo()
72 */
73
74#undef	EAI_ADDRFAMILY
75#undef	EAI_AGAIN
76#undef	EAI_BADFLAGS
77#undef	EAI_FAIL
78#undef	EAI_FAMILY
79#undef	EAI_MEMORY
80#undef	EAI_NODATA
81#undef	EAI_NONAME
82#undef	EAI_SERVICE
83#undef	EAI_SOCKTYPE
84#undef	EAI_SYSTEM
85#undef	EAI_BADHINTS
86#undef	EAI_PROTOCOL
87#undef	EAI_MAX
88
89#define	EAI_ADDRFAMILY	 1	/* address family for hostname not supported */
90#define	EAI_AGAIN	 2	/* temporary failure in name resolution */
91#define	EAI_BADFLAGS	 3	/* invalid value for ai_flags */
92#define	EAI_FAIL	 4	/* non-recoverable failure in name resolution */
93#define	EAI_FAMILY	 5	/* ai_family not supported */
94#define	EAI_MEMORY	 6	/* memory allocation failure */
95#define	EAI_NODATA	 7	/* no address associated with hostname */
96#define	EAI_NONAME	 8	/* hostname nor servname provided, or not known */
97#define	EAI_SERVICE	 9	/* servname not supported for ai_socktype */
98#define	EAI_SOCKTYPE	10	/* ai_socktype not supported */
99#define	EAI_SYSTEM	11	/* system error returned in errno */
100#define EAI_BADHINTS	12
101#define EAI_PROTOCOL	13
102#define EAI_MAX		14
103
104/*
105 * Flag values for getaddrinfo()
106 */
107#undef	AI_PASSIVE
108#undef	AI_CANONNAME
109#undef	AI_NUMERICHOST
110
111#define	AI_PASSIVE	0x00000001
112#define	AI_CANONNAME	0x00000002
113#define AI_NUMERICHOST	0x00000004
114
115/*
116 * Flag values for getipnodebyname()
117 */
118#undef AI_V4MAPPED
119#undef AI_ALL
120#undef AI_ADDRCONFIG
121#undef AI_DEFAULT
122
123#define AI_V4MAPPED	0x00000008
124#define AI_ALL		0x00000010
125#define AI_ADDRCONFIG	0x00000020
126#define AI_DEFAULT	(AI_V4MAPPED|AI_ADDRCONFIG)
127
128/*
129 * Constants for getnameinfo()
130 */
131#undef	NI_MAXHOST
132#undef	NI_MAXSERV
133
134#define	NI_MAXHOST	1025
135#define	NI_MAXSERV	32
136
137/*
138 * Flag values for getnameinfo()
139 */
140#undef	NI_NOFQDN
141#undef	NI_NUMERICHOST
142#undef	NI_NAMEREQD
143#undef	NI_NUMERICSERV
144#undef	NI_DGRAM
145#undef	NI_NUMERICSCOPE
146
147#define	NI_NOFQDN	0x00000001
148#define	NI_NUMERICHOST	0x00000002
149#define	NI_NAMEREQD	0x00000004
150#define	NI_NUMERICSERV	0x00000008
151#define	NI_DGRAM	0x00000010
152#define	NI_NUMERICSCOPE	0x00000020	/*2553bis-00*/
153
154/*
155 * Structures for getrrsetbyname()
156 */
157struct rdatainfo {
158	unsigned int		rdi_length;
159	unsigned char		*rdi_data;
160};
161
162struct rrsetinfo {
163	unsigned int		rri_flags;
164	int			rri_rdclass;
165	int			rri_rdtype;
166	unsigned int		rri_ttl;
167	unsigned int		rri_nrdatas;
168	unsigned int		rri_nsigs;
169	char			*rri_name;
170	struct rdatainfo	*rri_rdatas;
171	struct rdatainfo	*rri_sigs;
172};
173
174/*
175 * Flags for getrrsetbyname()
176 */
177#define RRSET_VALIDATED		0x00000001
178	/* Set was dnssec validated */
179
180/*
181 * Return codes for getrrsetbyname()
182 */
183#define ERRSET_SUCCESS		0
184#define ERRSET_NOMEMORY		1
185#define ERRSET_FAIL		2
186#define ERRSET_INVAL		3
187
188
189#endif /* NETDB_H */
190