1258945Sroberto/*
2258945Sroberto * Copyright (C) 2004, 2006, 2007, 2009  Internet Systems Consortium, Inc. ("ISC")
3258945Sroberto * Copyright (C) 2000, 2001  Internet Software Consortium.
4258945Sroberto *
5258945Sroberto * Permission to use, copy, modify, and/or distribute this software for any
6258945Sroberto * purpose with or without fee is hereby granted, provided that the above
7258945Sroberto * copyright notice and this permission notice appear in all copies.
8258945Sroberto *
9258945Sroberto * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10258945Sroberto * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11258945Sroberto * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12258945Sroberto * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13258945Sroberto * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14258945Sroberto * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15258945Sroberto * PERFORMANCE OF THIS SOFTWARE.
16258945Sroberto */
17258945Sroberto
18280849Scy/* $Id: netdb.h,v 1.9 2009/01/18 23:48:14 tbox Exp $ */
19258945Sroberto
20258945Sroberto#ifndef NETDB_H
21258945Sroberto#define NETDB_H 1
22258945Sroberto
23258945Sroberto#include <stddef.h>
24258945Sroberto#include <winsock2.h>
25258945Sroberto
26258945Sroberto/*
27258945Sroberto * Define if <netdb.h> does not declare struct addrinfo.
28258945Sroberto */
29258945Sroberto
30258945Srobertostruct addrinfo {
31258945Sroberto	int		ai_flags;      /* AI_PASSIVE, AI_CANONNAME */
32258945Sroberto	int		ai_family;     /* PF_xxx */
33258945Sroberto	int		ai_socktype;   /* SOCK_xxx */
34258945Sroberto	int		ai_protocol;   /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
35258945Sroberto	size_t		ai_addrlen;    /* Length of ai_addr */
36258945Sroberto	char		*ai_canonname; /* Canonical name for hostname */
37258945Sroberto	struct sockaddr	*ai_addr;      /* Binary address */
38258945Sroberto	struct addrinfo	*ai_next;      /* Next structure in linked list */
39258945Sroberto};
40258945Sroberto
41258945Sroberto
42258945Sroberto/*
43258945Sroberto * Undefine all \#defines we are interested in as <netdb.h> may or may not have
44258945Sroberto * defined them.
45258945Sroberto */
46258945Sroberto
47258945Sroberto/*
48258945Sroberto * Error return codes from gethostbyname() and gethostbyaddr()
49258945Sroberto * (left in extern int h_errno).
50258945Sroberto */
51258945Sroberto
52258945Sroberto#undef	NETDB_INTERNAL
53258945Sroberto#undef	NETDB_SUCCESS
54258945Sroberto#undef	HOST_NOT_FOUND
55258945Sroberto#undef	TRY_AGAIN
56258945Sroberto#undef	NO_RECOVERY
57258945Sroberto#undef	NO_DATA
58258945Sroberto#undef	NO_ADDRESS
59258945Sroberto
60258945Sroberto#define	NETDB_INTERNAL	-1	/* see errno */
61258945Sroberto#define	NETDB_SUCCESS	0	/* no problem */
62258945Sroberto#define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
63258945Sroberto#define	TRY_AGAIN	2 /* Non-Authoritative Host not found, or SERVERFAIL */
64258945Sroberto#define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
65258945Sroberto#define	NO_DATA		4 /* Valid name, no data record of requested type */
66258945Sroberto#define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
67258945Sroberto
68258945Sroberto/*
69258945Sroberto * Error return codes from getaddrinfo()
70258945Sroberto */
71258945Sroberto
72258945Sroberto#undef	EAI_ADDRFAMILY
73258945Sroberto#undef	EAI_AGAIN
74258945Sroberto#undef	EAI_BADFLAGS
75258945Sroberto#undef	EAI_FAIL
76258945Sroberto#undef	EAI_FAMILY
77258945Sroberto#undef	EAI_MEMORY
78258945Sroberto#undef	EAI_NODATA
79258945Sroberto#undef	EAI_NONAME
80258945Sroberto#undef	EAI_SERVICE
81258945Sroberto#undef	EAI_SOCKTYPE
82258945Sroberto#undef	EAI_SYSTEM
83258945Sroberto#undef	EAI_BADHINTS
84258945Sroberto#undef	EAI_PROTOCOL
85258945Sroberto#undef	EAI_MAX
86258945Sroberto
87258945Sroberto#define	EAI_ADDRFAMILY	 1	/* address family for hostname not supported */
88258945Sroberto#define	EAI_AGAIN	 2	/* temporary failure in name resolution */
89258945Sroberto#define	EAI_BADFLAGS	 3	/* invalid value for ai_flags */
90258945Sroberto#define	EAI_FAIL	 4	/* non-recoverable failure in name resolution */
91258945Sroberto#define	EAI_FAMILY	 5	/* ai_family not supported */
92258945Sroberto#define	EAI_MEMORY	 6	/* memory allocation failure */
93258945Sroberto#define	EAI_NODATA	 7	/* no address associated with hostname */
94258945Sroberto#define	EAI_NONAME	 8	/* hostname nor servname provided, or not known */
95258945Sroberto#define	EAI_SERVICE	 9	/* servname not supported for ai_socktype */
96258945Sroberto#define	EAI_SOCKTYPE	10	/* ai_socktype not supported */
97258945Sroberto#define	EAI_SYSTEM	11	/* system error returned in errno */
98258945Sroberto#define EAI_BADHINTS	12
99258945Sroberto#define EAI_PROTOCOL	13
100258945Sroberto#define EAI_MAX		14
101258945Sroberto
102258945Sroberto/*
103258945Sroberto * Flag values for getaddrinfo()
104258945Sroberto */
105258945Sroberto#undef	AI_PASSIVE
106258945Sroberto#undef	AI_CANONNAME
107258945Sroberto#undef	AI_NUMERICHOST
108258945Sroberto
109258945Sroberto#define	AI_PASSIVE	0x00000001
110258945Sroberto#define	AI_CANONNAME	0x00000002
111258945Sroberto#define AI_NUMERICHOST	0x00000004
112258945Sroberto
113258945Sroberto/*
114258945Sroberto * Flag values for getipnodebyname()
115258945Sroberto */
116258945Sroberto#undef AI_V4MAPPED
117258945Sroberto#undef AI_ALL
118258945Sroberto#undef AI_ADDRCONFIG
119258945Sroberto#undef AI_DEFAULT
120258945Sroberto
121258945Sroberto#define AI_V4MAPPED	0x00000008
122258945Sroberto#define AI_ALL		0x00000010
123258945Sroberto#define AI_ADDRCONFIG	0x00000020
124258945Sroberto#define AI_DEFAULT	(AI_V4MAPPED|AI_ADDRCONFIG)
125258945Sroberto
126258945Sroberto/*
127258945Sroberto * Constants for getnameinfo()
128258945Sroberto */
129258945Sroberto#undef	NI_MAXHOST
130258945Sroberto#undef	NI_MAXSERV
131258945Sroberto
132258945Sroberto#define	NI_MAXHOST	1025
133258945Sroberto#define	NI_MAXSERV	32
134258945Sroberto
135258945Sroberto/*
136258945Sroberto * Flag values for getnameinfo()
137258945Sroberto */
138258945Sroberto#undef	NI_NOFQDN
139258945Sroberto#undef	NI_NUMERICHOST
140258945Sroberto#undef	NI_NAMEREQD
141258945Sroberto#undef	NI_NUMERICSERV
142258945Sroberto#undef	NI_DGRAM
143258945Sroberto#undef	NI_NUMERICSCOPE
144258945Sroberto
145258945Sroberto#define	NI_NOFQDN	0x00000001
146258945Sroberto#define	NI_NUMERICHOST	0x00000002
147258945Sroberto#define	NI_NAMEREQD	0x00000004
148258945Sroberto#define	NI_NUMERICSERV	0x00000008
149258945Sroberto#define	NI_DGRAM	0x00000010
150258945Sroberto#define	NI_NUMERICSCOPE	0x00000020	/*2553bis-00*/
151258945Sroberto
152258945Sroberto/*
153258945Sroberto * Structures for getrrsetbyname()
154258945Sroberto */
155258945Srobertostruct rdatainfo {
156258945Sroberto	unsigned int		rdi_length;
157258945Sroberto	unsigned char		*rdi_data;
158258945Sroberto};
159258945Sroberto
160258945Srobertostruct rrsetinfo {
161258945Sroberto	unsigned int		rri_flags;
162258945Sroberto	int			rri_rdclass;
163258945Sroberto	int			rri_rdtype;
164258945Sroberto	unsigned int		rri_ttl;
165258945Sroberto	unsigned int		rri_nrdatas;
166258945Sroberto	unsigned int		rri_nsigs;
167258945Sroberto	char			*rri_name;
168258945Sroberto	struct rdatainfo	*rri_rdatas;
169258945Sroberto	struct rdatainfo	*rri_sigs;
170258945Sroberto};
171258945Sroberto
172258945Sroberto/*
173258945Sroberto * Flags for getrrsetbyname()
174258945Sroberto */
175258945Sroberto#define RRSET_VALIDATED		0x00000001
176258945Sroberto	/* Set was dnssec validated */
177258945Sroberto
178258945Sroberto/*
179258945Sroberto * Return codes for getrrsetbyname()
180258945Sroberto */
181258945Sroberto#define ERRSET_SUCCESS		0
182258945Sroberto#define ERRSET_NOMEMORY		1
183258945Sroberto#define ERRSET_FAIL		2
184258945Sroberto#define ERRSET_INVAL		3
185258945Sroberto
186258945Sroberto
187258945Sroberto#endif /* NETDB_H */
188