2 * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* Id: netdb.h.in,v 1.41 2009/01/18 23:48:14 tbox Exp */
23 #define LWRES_NETDB_H 1
25 #include <stddef.h> /* Required on FreeBSD (and others?) for size_t. */
26 #include <netdb.h> /* Contractual provision. */
28 #include <lwres/lang.h>
31 * Define if <netdb.h> does not declare struct addrinfo.
33 #undef ISC_LWRES_NEEDADDRINFO
35 #ifdef ISC_LWRES_NEEDADDRINFO
37 int ai_flags
; /* AI_PASSIVE, AI_CANONNAME */
38 int ai_family
; /* PF_xxx */
39 int ai_socktype
; /* SOCK_xxx */
40 int ai_protocol
; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
41 size_t ai_addrlen
; /* Length of ai_addr */
42 char *ai_canonname
; /* Canonical name for hostname */
43 struct sockaddr
*ai_addr
; /* Binary address */
44 struct addrinfo
*ai_next
; /* Next structure in linked list */
49 * Undefine all #defines we are interested in as <netdb.h> may or may not have
54 * Error return codes from gethostbyname() and gethostbyaddr()
55 * (left in extern int h_errno).
66 #define NETDB_INTERNAL -1 /* see errno */
67 #define NETDB_SUCCESS 0 /* no problem */
68 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
69 #define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */
70 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
71 #define NO_DATA 4 /* Valid name, no data record of requested type */
72 #define NO_ADDRESS NO_DATA /* no address, look for MX record */
75 * Error return codes from getaddrinfo()
93 #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
94 #define EAI_AGAIN 2 /* temporary failure in name resolution */
95 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
96 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
97 #define EAI_FAMILY 5 /* ai_family not supported */
98 #define EAI_MEMORY 6 /* memory allocation failure */
99 #define EAI_NODATA 7 /* no address associated with hostname */
100 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */
101 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
102 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
103 #define EAI_SYSTEM 11 /* system error returned in errno */
104 #define EAI_BADHINTS 12
105 #define EAI_PROTOCOL 13
109 * Flag values for getaddrinfo()
113 #undef AI_NUMERICHOST
115 #define AI_PASSIVE 0x00000001
116 #define AI_CANONNAME 0x00000002
117 #define AI_NUMERICHOST 0x00000004
120 * Flag values for getipnodebyname()
127 #define AI_V4MAPPED 0x00000008
128 #define AI_ALL 0x00000010
129 #define AI_ADDRCONFIG 0x00000020
130 #define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG)
133 * Constants for lwres_getnameinfo()
138 #define NI_MAXHOST 1025
139 #define NI_MAXSERV 32
142 * Flag values for lwres_getnameinfo()
145 #undef NI_NUMERICHOST
147 #undef NI_NUMERICSERV
149 #undef NI_NUMERICSCOPE
151 #define NI_NOFQDN 0x00000001
152 #define NI_NUMERICHOST 0x00000002
153 #define NI_NAMEREQD 0x00000004
154 #define NI_NUMERICSERV 0x00000008
155 #define NI_DGRAM 0x00000010
156 #define NI_NUMERICSCOPE 0x00000020 /*2553bis-00*/
159 * Define if <netdb.h> does not declare struct rrsetinfo.
161 #define ISC_LWRES_NEEDRRSETINFO 1
163 #ifdef ISC_LWRES_NEEDRRSETINFO
165 * Structures for getrrsetbyname()
168 unsigned int rdi_length
;
169 unsigned char *rdi_data
;
173 unsigned int rri_flags
;
176 unsigned int rri_ttl
;
177 unsigned int rri_nrdatas
;
178 unsigned int rri_nsigs
;
180 struct rdatainfo
*rri_rdatas
;
181 struct rdatainfo
*rri_sigs
;
185 * Flags for getrrsetbyname()
187 #define RRSET_VALIDATED 0x00000001
188 /* Set was dnssec validated */
191 * Return codes for getrrsetbyname()
193 #define ERRSET_SUCCESS 0
194 #define ERRSET_NOMEMORY 1
195 #define ERRSET_FAIL 2
196 #define ERRSET_INVAL 3
197 #define ERRSET_NONAME 4
198 #define ERRSET_NODATA 5
202 * Define to map into lwres_ namespace.
205 #define LWRES_NAMESPACE
207 #ifdef LWRES_NAMESPACE
210 * Use our versions not the ones from the C library.
216 #define getnameinfo lwres_getnameinfo
221 #define getaddrinfo lwres_getaddrinfo
226 #define freeaddrinfo lwres_freeaddrinfo
231 #define gai_strerror lwres_gai_strerror
236 #define herror lwres_herror
241 #define hstrerror lwres_hstrerror
243 #ifdef getipnodebyname
244 #undef getipnodebyname
246 #define getipnodebyname lwres_getipnodebyname
248 #ifdef getipnodebyaddr
249 #undef getipnodebyaddr
251 #define getipnodebyaddr lwres_getipnodebyaddr
256 #define freehostent lwres_freehostent
261 #define gethostbyname lwres_gethostbyname
263 #ifdef gethostbyname2
264 #undef gethostbyname2
266 #define gethostbyname2 lwres_gethostbyname2
271 #define gethostbyaddr lwres_gethostbyaddr
276 #define gethostent lwres_gethostent
281 #define sethostent lwres_sethostent
286 #define endhostent lwres_endhostent
288 /* #define sethostfile lwres_sethostfile */
290 #ifdef gethostbyname_r
291 #undef gethostbyname_r
293 #define gethostbyname_r lwres_gethostbyname_r
295 #ifdef gethostbyaddr_r
296 #undef gethostbyaddr_r
298 #define gethostbyaddr_r lwres_gethostbyaddr_r
303 #define gethostent_r lwres_gethostent_r
308 #define sethostent_r lwres_sethostent_r
313 #define endhostent_r lwres_endhostent_r
315 #ifdef getrrsetbyname
316 #undef getrrsetbyname
318 #define getrrsetbyname lwres_getrrsetbyname
323 #define freerrset lwres_freerrset
326 #define getservbyname lwres_getservbyname
327 #define getservbyport lwres_getservbyport
328 #define getservent lwres_getservent
329 #define setservent lwres_setservent
330 #define endservent lwres_endservent
332 #define getservbyname_r lwres_getservbyname_r
333 #define getservbyport_r lwres_getservbyport_r
334 #define getservent_r lwres_getservent_r
335 #define setservent_r lwres_setservent_r
336 #define endservent_r lwres_endservent_r
338 #define getprotobyname lwres_getprotobyname
339 #define getprotobynumber lwres_getprotobynumber
340 #define getprotoent lwres_getprotoent
341 #define setprotoent lwres_setprotoent
342 #define endprotoent lwres_endprotoent
344 #define getprotobyname_r lwres_getprotobyname_r
345 #define getprotobynumber_r lwres_getprotobynumber_r
346 #define getprotoent_r lwres_getprotoent_r
347 #define setprotoent_r lwres_setprotoent_r
348 #define endprotoent_r lwres_endprotoent_r
353 #define getnetbyname lwres_getnetbyname
358 #define getnetbyaddr lwres_getnetbyaddr
363 #define getnetent lwres_getnetent
368 #define setnetent lwres_setnetent
373 #define endnetent lwres_endnetent
376 #ifdef getnetbyname_r
377 #undef getnetbyname_r
379 #define getnetbyname_r lwres_getnetbyname_r
381 #ifdef getnetbyaddr_r
382 #undef getnetbyaddr_r
384 #define getnetbyaddr_r lwres_getnetbyaddr_r
389 #define getnetent_r lwres_getnetent_r
394 #define setnetent_r lwres_setnetent_r
399 #define endnetent_r lwres_endnetent_r
405 #define h_errno lwres_h_errno
407 #endif /* LWRES_NAMESPACE */
409 LWRES_LANG_BEGINDECLS
411 extern int lwres_h_errno
;
413 int lwres_getaddrinfo(const char *, const char *,
414 const struct addrinfo
*, struct addrinfo
**);
415 int lwres_getnameinfo(const struct sockaddr
*, size_t, char *,
416 size_t, char *, size_t, int);
417 void lwres_freeaddrinfo(struct addrinfo
*);
418 char *lwres_gai_strerror(int);
420 struct hostent
*lwres_gethostbyaddr(const char *, int, int);
421 struct hostent
*lwres_gethostbyname(const char *);
422 struct hostent
*lwres_gethostbyname2(const char *, int);
423 struct hostent
*lwres_gethostent(void);
424 struct hostent
*lwres_getipnodebyname(const char *, int, int, int *);
425 struct hostent
*lwres_getipnodebyaddr(const void *, size_t, int, int *);
426 void lwres_endhostent(void);
427 void lwres_sethostent(int);
428 /* void lwres_sethostfile(const char *); */
429 void lwres_freehostent(struct hostent
*);
431 int lwres_getrrsetbyname(const char *, unsigned int, unsigned int,
432 unsigned int, struct rrsetinfo
**);
433 void lwres_freerrset(struct rrsetinfo
*);
436 struct netent
*lwres_getnetbyaddr(unsigned long, int);
437 struct netent
*lwres_getnetbyname(const char *);
438 struct netent
*lwres_getnetent(void);
439 void lwres_endnetent(void);
440 void lwres_setnetent(int);
442 struct protoent
*lwres_getprotobyname(const char *);
443 struct protoent
*lwres_getprotobynumber(int);
444 struct protoent
*lwres_getprotoent(void);
445 void lwres_endprotoent(void);
446 void lwres_setprotoent(int);
448 struct servent
*lwres_getservbyname(const char *, const char *);
449 struct servent
*lwres_getservbyport(int, const char *);
450 struct servent
*lwres_getservent(void);
451 void lwres_endservent(void);
452 void lwres_setservent(int);
455 void lwres_herror(const char *);
456 const char *lwres_hstrerror(int);
459 struct hostent
*lwres_gethostbyaddr_r(const char *, int, int, struct hostent
*,
461 struct hostent
*lwres_gethostbyname_r(const char *, struct hostent
*,
463 struct hostent
*lwres_gethostent_r(struct hostent
*, char *, int, int *);
464 void lwres_sethostent_r(int);
465 void lwres_endhostent_r(void);
468 struct netent
*lwres_getnetbyname_r(const char *, struct netent
*,
470 struct netent
*lwres_getnetbyaddr_r(long, int, struct netent
*,
472 struct netent
*lwres_getnetent_r(struct netent
*, char *, int);
473 void lwres_setnetent_r(int);
474 void lwres_endnetent_r(void);
476 struct protoent
*lwres_getprotobyname_r(const char *,
477 struct protoent
*, char *, int);
478 struct protoent
*lwres_getprotobynumber_r(int,
479 struct protoent
*, char *, int);
480 struct protoent
*lwres_getprotoent_r(struct protoent
*, char *, int);
481 void lwres_setprotoent_r(int);
482 void lwres_endprotoent_r(void);
484 struct servent
*lwres_getservbyname_r(const char *name
, const char *,
485 struct servent
*, char *, int);
486 struct servent
*lwres_getservbyport_r(int port
, const char *,
487 struct servent
*, char *, int);
488 struct servent
*lwres_getservent_r(struct servent
*, char *, int);
489 void lwres_setservent_r(int);
490 void lwres_endservent_r(void);
496 /* This is nec'y to make this include file properly replace the sun version. */
498 #ifdef __GNU_LIBRARY__
499 #include <rpc/netdb.h> /* Required. */
500 #else /* !__GNU_LIBRARY__ */
502 char *r_name
; /* name of server for this rpc program */
503 char **r_aliases
; /* alias list */
504 int r_number
; /* rpc program number */
506 struct rpcent
*lwres_getrpcbyname();
507 struct rpcent
*lwres_getrpcbynumber(),
508 struct rpcent
*lwres_getrpcent();
509 #endif /* __GNU_LIBRARY__ */
514 * Tell Emacs to use C mode on this file.
520 #endif /* LWRES_NETDB_H */