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