]>
Commit | Line | Data |
---|---|---|
997358a6 MW |
1 | /* |
2 | * Copyright (C) 2000, 2001 Internet Software Consortium. | |
3 | * | |
4 | * Permission to use, copy, modify, and distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM | |
9 | * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL | |
10 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL | |
11 | * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, | |
12 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING | |
13 | * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | |
14 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | |
15 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
16 | */ | |
17 | ||
18 | /* $Id: netdb.h,v 1.1 2004/03/15 20:35:25 as Exp $ */ | |
19 | ||
20 | #ifndef LWRES_NETDB_H | |
21 | #define LWRES_NETDB_H 1 | |
22 | ||
23 | #include <stddef.h> /* Required on FreeBSD (and others?) for size_t. */ | |
24 | #include <netdb.h> /* Contractual provision. */ | |
25 | ||
26 | #include <lwres/lang.h> | |
27 | ||
28 | /* | |
29 | * Define if <netdb.h> does not declare struct addrinfo. | |
30 | */ | |
31 | #undef ISC_LWRES_NEEDADDRINFO | |
32 | ||
33 | #ifdef ISC_LWRES_NEEDADDRINFO | |
34 | struct addrinfo { | |
35 | int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ | |
36 | int ai_family; /* PF_xxx */ | |
37 | int ai_socktype; /* SOCK_xxx */ | |
38 | int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ | |
39 | size_t ai_addrlen; /* Length of ai_addr */ | |
40 | char *ai_canonname; /* Canonical name for hostname */ | |
41 | struct sockaddr *ai_addr; /* Binary address */ | |
42 | struct addrinfo *ai_next; /* Next structure in linked list */ | |
43 | }; | |
44 | #endif | |
45 | ||
46 | /* | |
47 | * Undefine all #defines we are interested in as <netdb.h> may or may not have | |
48 | * defined them. | |
49 | */ | |
50 | ||
51 | /* | |
52 | * Error return codes from gethostbyname() and gethostbyaddr() | |
53 | * (left in extern int h_errno). | |
54 | */ | |
55 | ||
56 | #undef NETDB_INTERNAL | |
57 | #undef NETDB_SUCCESS | |
58 | #undef HOST_NOT_FOUND | |
59 | #undef TRY_AGAIN | |
60 | #undef NO_RECOVERY | |
61 | #undef NO_DATA | |
62 | #undef NO_ADDRESS | |
63 | ||
64 | #define NETDB_INTERNAL -1 /* see errno */ | |
65 | #define NETDB_SUCCESS 0 /* no problem */ | |
66 | #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ | |
67 | #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ | |
68 | #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ | |
69 | #define NO_DATA 4 /* Valid name, no data record of requested type */ | |
70 | #define NO_ADDRESS NO_DATA /* no address, look for MX record */ | |
71 | ||
72 | /* | |
73 | * Error return codes from getaddrinfo() | |
74 | */ | |
75 | ||
76 | #undef EAI_ADDRFAMILY | |
77 | #undef EAI_AGAIN | |
78 | #undef EAI_BADFLAGS | |
79 | #undef EAI_FAIL | |
80 | #undef EAI_FAMILY | |
81 | #undef EAI_MEMORY | |
82 | #undef EAI_NODATA | |
83 | #undef EAI_NONAME | |
84 | #undef EAI_SERVICE | |
85 | #undef EAI_SOCKTYPE | |
86 | #undef EAI_SYSTEM | |
87 | #undef EAI_BADHINTS | |
88 | #undef EAI_PROTOCOL | |
89 | #undef EAI_MAX | |
90 | ||
91 | #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ | |
92 | #define EAI_AGAIN 2 /* temporary failure in name resolution */ | |
93 | #define EAI_BADFLAGS 3 /* invalid value for ai_flags */ | |
94 | #define EAI_FAIL 4 /* non-recoverable failure in name resolution */ | |
95 | #define EAI_FAMILY 5 /* ai_family not supported */ | |
96 | #define EAI_MEMORY 6 /* memory allocation failure */ | |
97 | #define EAI_NODATA 7 /* no address associated with hostname */ | |
98 | #define EAI_NONAME 8 /* hostname nor servname provided, or not known */ | |
99 | #define EAI_SERVICE 9 /* servname not supported for ai_socktype */ | |
100 | #define EAI_SOCKTYPE 10 /* ai_socktype not supported */ | |
101 | #define EAI_SYSTEM 11 /* system error returned in errno */ | |
102 | #define EAI_BADHINTS 12 | |
103 | #define EAI_PROTOCOL 13 | |
104 | #define EAI_MAX 14 | |
105 | ||
106 | /* | |
107 | * Flag values for getaddrinfo() | |
108 | */ | |
109 | #undef AI_PASSIVE | |
110 | #undef AI_CANONNAME | |
111 | #undef AI_NUMERICHOST | |
112 | ||
113 | #define AI_PASSIVE 0x00000001 | |
114 | #define AI_CANONNAME 0x00000002 | |
115 | #define AI_NUMERICHOST 0x00000004 | |
116 | ||
117 | /* | |
118 | * Flag values for getipnodebyname() | |
119 | */ | |
120 | #undef AI_V4MAPPED | |
121 | #undef AI_ALL | |
122 | #undef AI_ADDRCONFIG | |
123 | #undef AI_DEFAULT | |
124 | ||
125 | #define AI_V4MAPPED 0x00000008 | |
126 | #define AI_ALL 0x00000010 | |
127 | #define AI_ADDRCONFIG 0x00000020 | |
128 | #define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG) | |
129 | ||
130 | /* | |
131 | * Constants for lwres_getnameinfo() | |
132 | */ | |
133 | #undef NI_MAXHOST | |
134 | #undef NI_MAXSERV | |
135 | ||
136 | #define NI_MAXHOST 1025 | |
137 | #define NI_MAXSERV 32 | |
138 | ||
139 | /* | |
140 | * Flag values for lwres_getnameinfo() | |
141 | */ | |
142 | #undef NI_NOFQDN | |
143 | #undef NI_NUMERICHOST | |
144 | #undef NI_NAMEREQD | |
145 | #undef NI_NUMERICSERV | |
146 | #undef NI_DGRAM | |
147 | #undef NI_NUMERICSCOPE | |
148 | ||
149 | #define NI_NOFQDN 0x00000001 | |
150 | #define NI_NUMERICHOST 0x00000002 | |
151 | #define NI_NAMEREQD 0x00000004 | |
152 | #define NI_NUMERICSERV 0x00000008 | |
153 | #define NI_DGRAM 0x00000010 | |
154 | #define NI_NUMERICSCOPE 0x00000020 /*2553bis-00*/ | |
155 | ||
156 | /* | |
157 | * Define if <netdb.h> does not declare struct rrsetinfo. | |
158 | */ | |
159 | #define ISC_LWRES_NEEDRRSETINFO 1 | |
160 | ||
161 | #ifdef ISC_LWRES_NEEDRRSETINFO | |
162 | /* | |
163 | * Structures for getrrsetbyname() | |
164 | */ | |
165 | struct rdatainfo { | |
166 | unsigned int rdi_length; | |
167 | unsigned char *rdi_data; | |
168 | }; | |
169 | ||
170 | struct rrsetinfo { | |
171 | unsigned int rri_flags; | |
172 | int rri_rdclass; | |
173 | int rri_rdtype; | |
174 | unsigned int rri_ttl; | |
175 | unsigned int rri_nrdatas; | |
176 | unsigned int rri_nsigs; | |
177 | char *rri_name; | |
178 | struct rdatainfo *rri_rdatas; | |
179 | struct rdatainfo *rri_sigs; | |
180 | }; | |
181 | ||
182 | /* | |
183 | * Flags for getrrsetbyname() | |
184 | */ | |
185 | #define RRSET_VALIDATED 0x00000001 | |
186 | /* Set was dnssec validated */ | |
187 | ||
188 | /* | |
189 | * Return codes for getrrsetbyname() | |
190 | */ | |
191 | #define ERRSET_SUCCESS 0 | |
192 | #define ERRSET_NOMEMORY 1 | |
193 | #define ERRSET_FAIL 2 | |
194 | #define ERRSET_INVAL 3 | |
195 | #define ERRSET_NONAME 4 | |
196 | #define ERRSET_NODATA 5 | |
197 | #define ERRSET_RETRY 6 | |
198 | #endif | |
199 | ||
200 | /* | |
201 | * Define to map into lwres_ namespace. | |
202 | */ | |
203 | ||
204 | #define LWRES_NAMESPACE | |
205 | ||
206 | #ifdef LWRES_NAMESPACE | |
207 | ||
208 | /* | |
209 | * Use our versions not the ones from the C library. | |
210 | */ | |
211 | ||
212 | #ifdef getnameinfo | |
213 | #undef getnameinfo | |
214 | #endif | |
215 | #define getnameinfo lwres_getnameinfo | |
216 | ||
217 | #ifdef getaddrinfo | |
218 | #undef getaddrinfo | |
219 | #endif | |
220 | #define getaddrinfo lwres_getaddrinfo | |
221 | ||
222 | #ifdef freeaddrinfo | |
223 | #undef freeaddrinfo | |
224 | #endif | |
225 | #define freeaddrinfo lwres_freeaddrinfo | |
226 | ||
227 | #ifdef gai_strerror | |
228 | #undef gai_strerror | |
229 | #endif | |
230 | #define gai_strerror lwres_gai_strerror | |
231 | ||
232 | #ifdef herror | |
233 | #undef herror | |
234 | #endif | |
235 | #define herror lwres_herror | |
236 | ||
237 | #ifdef hstrerror | |
238 | #undef hstrerror | |
239 | #endif | |
240 | #define hstrerror lwres_hstrerror | |
241 | ||
242 | #ifdef getipnodebyname | |
243 | #undef getipnodebyname | |
244 | #endif | |
245 | #define getipnodebyname lwres_getipnodebyname | |
246 | ||
247 | #ifdef getipnodebyaddr | |
248 | #undef getipnodebyaddr | |
249 | #endif | |
250 | #define getipnodebyaddr lwres_getipnodebyaddr | |
251 | ||
252 | #ifdef freehostent | |
253 | #undef freehostent | |
254 | #endif | |
255 | #define freehostent lwres_freehostent | |
256 | ||
257 | #ifdef gethostbyname | |
258 | #undef gethostbyname | |
259 | #endif | |
260 | #define gethostbyname lwres_gethostbyname | |
261 | ||
262 | #ifdef gethostbyname2 | |
263 | #undef gethostbyname2 | |
264 | #endif | |
265 | #define gethostbyname2 lwres_gethostbyname2 | |
266 | ||
267 | #ifdef gethostbyaddr | |
268 | #undef gethostbyaddr | |
269 | #endif | |
270 | #define gethostbyaddr lwres_gethostbyaddr | |
271 | ||
272 | #ifdef gethostent | |
273 | #undef gethostent | |
274 | #endif | |
275 | #define gethostent lwres_gethostent | |
276 | ||
277 | #ifdef sethostent | |
278 | #undef sethostent | |
279 | #endif | |
280 | #define sethostent lwres_sethostent | |
281 | ||
282 | #ifdef endhostent | |
283 | #undef endhostent | |
284 | #endif | |
285 | #define endhostent lwres_endhostent | |
286 | ||
287 | /* #define sethostfile lwres_sethostfile */ | |
288 | ||
289 | #ifdef gethostbyname_r | |
290 | #undef gethostbyname_r | |
291 | #endif | |
292 | #define gethostbyname_r lwres_gethostbyname_r | |
293 | ||
294 | #ifdef gethostbyaddr_r | |
295 | #undef gethostbyaddr_r | |
296 | #endif | |
297 | #define gethostbyaddr_r lwres_gethostbyaddr_r | |
298 | ||
299 | #ifdef gethostent_r | |
300 | #undef gethostent_r | |
301 | #endif | |
302 | #define gethostent_r lwres_gethostent_r | |
303 | ||
304 | #ifdef sethostent_r | |
305 | #undef sethostent_r | |
306 | #endif | |
307 | #define sethostent_r lwres_sethostent_r | |
308 | ||
309 | #ifdef endhostent_r | |
310 | #undef endhostent_r | |
311 | #endif | |
312 | #define endhostent_r lwres_endhostent_r | |
313 | ||
314 | #ifdef getrrsetbyname | |
315 | #undef getrrsetbyname | |
316 | #endif | |
317 | #define getrrsetbyname lwres_getrrsetbyname | |
318 | ||
319 | #ifdef freerrset | |
320 | #undef freerrset | |
321 | #endif | |
322 | #define freerrset lwres_freerrset | |
323 | ||
324 | #ifdef notyet | |
325 | #define getservbyname lwres_getservbyname | |
326 | #define getservbyport lwres_getservbyport | |
327 | #define getservent lwres_getservent | |
328 | #define setservent lwres_setservent | |
329 | #define endservent lwres_endservent | |
330 | ||
331 | #define getservbyname_r lwres_getservbyname_r | |
332 | #define getservbyport_r lwres_getservbyport_r | |
333 | #define getservent_r lwres_getservent_r | |
334 | #define setservent_r lwres_setservent_r | |
335 | #define endservent_r lwres_endservent_r | |
336 | ||
337 | #define getprotobyname lwres_getprotobyname | |
338 | #define getprotobynumber lwres_getprotobynumber | |
339 | #define getprotoent lwres_getprotoent | |
340 | #define setprotoent lwres_setprotoent | |
341 | #define endprotoent lwres_endprotoent | |
342 | ||
343 | #define getprotobyname_r lwres_getprotobyname_r | |
344 | #define getprotobynumber_r lwres_getprotobynumber_r | |
345 | #define getprotoent_r lwres_getprotoent_r | |
346 | #define setprotoent_r lwres_setprotoent_r | |
347 | #define endprotoent_r lwres_endprotoent_r | |
348 | ||
349 | #ifdef getnetbyname | |
350 | #undef getnetbyname | |
351 | #endif | |
352 | #define getnetbyname lwres_getnetbyname | |
353 | ||
354 | #ifdef getnetbyaddr | |
355 | #undef getnetbyaddr | |
356 | #endif | |
357 | #define getnetbyaddr lwres_getnetbyaddr | |
358 | ||
359 | #ifdef getnetent | |
360 | #undef getnetent | |
361 | #endif | |
362 | #define getnetent lwres_getnetent | |
363 | ||
364 | #ifdef setnetent | |
365 | #undef setnetent | |
366 | #endif | |
367 | #define setnetent lwres_setnetent | |
368 | ||
369 | #ifdef endnetent | |
370 | #undef endnetent | |
371 | #endif | |
372 | #define endnetent lwres_endnetent | |
373 | ||
374 | ||
375 | #ifdef getnetbyname_r | |
376 | #undef getnetbyname_r | |
377 | #endif | |
378 | #define getnetbyname_r lwres_getnetbyname_r | |
379 | ||
380 | #ifdef getnetbyaddr_r | |
381 | #undef getnetbyaddr_r | |
382 | #endif | |
383 | #define getnetbyaddr_r lwres_getnetbyaddr_r | |
384 | ||
385 | #ifdef getnetent_r | |
386 | #undef getnetent_r | |
387 | #endif | |
388 | #define getnetent_r lwres_getnetent_r | |
389 | ||
390 | #ifdef setnetent_r | |
391 | #undef setnetent_r | |
392 | #endif | |
393 | #define setnetent_r lwres_setnetent_r | |
394 | ||
395 | #ifdef endnetent_r | |
396 | #undef endnetent_r | |
397 | #endif | |
398 | #define endnetent_r lwres_endnetent_r | |
399 | #endif /* notyet */ | |
400 | ||
401 | #ifdef h_errno | |
402 | #undef h_errno | |
403 | #endif | |
404 | #define h_errno lwres_h_errno | |
405 | ||
406 | #endif /* LWRES_NAMESPACE */ | |
407 | ||
408 | LWRES_LANG_BEGINDECLS | |
409 | ||
410 | extern int lwres_h_errno; | |
411 | ||
412 | int lwres_getaddrinfo(const char *, const char *, | |
413 | const struct addrinfo *, struct addrinfo **); | |
414 | int lwres_getnameinfo(const struct sockaddr *, size_t, char *, | |
415 | size_t, char *, size_t, int); | |
416 | void lwres_freeaddrinfo(struct addrinfo *); | |
417 | char *lwres_gai_strerror(int); | |
418 | ||
419 | struct hostent *lwres_gethostbyaddr(const char *, int, int); | |
420 | struct hostent *lwres_gethostbyname(const char *); | |
421 | struct hostent *lwres_gethostbyname2(const char *, int); | |
422 | struct hostent *lwres_gethostent(void); | |
423 | struct hostent *lwres_getipnodebyname(const char *, int, int, int *); | |
424 | struct hostent *lwres_getipnodebyaddr(const void *, size_t, int, int *); | |
425 | void lwres_endhostent(void); | |
426 | void lwres_sethostent(int); | |
427 | /* void lwres_sethostfile(const char *); */ | |
428 | void lwres_freehostent(struct hostent *); | |
429 | ||
430 | int lwres_getrrsetbyname(const char *, unsigned int, unsigned int, | |
431 | unsigned int, struct rrsetinfo **); | |
432 | int lwres_getrrsetbyname_all(const char *, unsigned int, | |
433 | unsigned int, | |
434 | unsigned int, struct rrsetinfo **); | |
435 | void lwres_freerrset(struct rrsetinfo *); | |
436 | ||
437 | #ifdef notyet | |
438 | struct netent *lwres_getnetbyaddr(unsigned long, int); | |
439 | struct netent *lwres_getnetbyname(const char *); | |
440 | struct netent *lwres_getnetent(void); | |
441 | void lwres_endnetent(void); | |
442 | void lwres_setnetent(int); | |
443 | ||
444 | struct protoent *lwres_getprotobyname(const char *); | |
445 | struct protoent *lwres_getprotobynumber(int); | |
446 | struct protoent *lwres_getprotoent(void); | |
447 | void lwres_endprotoent(void); | |
448 | void lwres_setprotoent(int); | |
449 | ||
450 | struct servent *lwres_getservbyname(const char *, const char *); | |
451 | struct servent *lwres_getservbyport(int, const char *); | |
452 | struct servent *lwres_getservent(void); | |
453 | void lwres_endservent(void); | |
454 | void lwres_setservent(int); | |
455 | #endif /* notyet */ | |
456 | ||
457 | void lwres_herror(const char *); | |
458 | const char *lwres_hstrerror(int); | |
459 | ||
460 | ||
461 | struct hostent *lwres_gethostbyaddr_r(const char *, int, int, struct hostent *, | |
462 | char *, int, int *); | |
463 | struct hostent *lwres_gethostbyname_r(const char *, struct hostent *, | |
464 | char *, int, int *); | |
465 | struct hostent *lwres_gethostent_r(struct hostent *, char *, int, int *); | |
466 | void lwres_sethostent_r(int); | |
467 | void lwres_endhostent_r(void); | |
468 | ||
469 | #ifdef notyet | |
470 | struct netent *lwres_getnetbyname_r(const char *, struct netent *, | |
471 | char *, int); | |
472 | struct netent *lwres_getnetbyaddr_r(long, int, struct netent *, | |
473 | char *, int); | |
474 | struct netent *lwres_getnetent_r(struct netent *, char *, int); | |
475 | void lwres_setnetent_r(int); | |
476 | void lwres_endnetent_r(void); | |
477 | ||
478 | struct protoent *lwres_getprotobyname_r(const char *, | |
479 | struct protoent *, char *, int); | |
480 | struct protoent *lwres_getprotobynumber_r(int, | |
481 | struct protoent *, char *, int); | |
482 | struct protoent *lwres_getprotoent_r(struct protoent *, char *, int); | |
483 | void lwres_setprotoent_r(int); | |
484 | void lwres_endprotoent_r(void); | |
485 | ||
486 | struct servent *lwres_getservbyname_r(const char *name, const char *, | |
487 | struct servent *, char *, int); | |
488 | struct servent *lwres_getservbyport_r(int port, const char *, | |
489 | struct servent *, char *, int); | |
490 | struct servent *lwres_getservent_r(struct servent *, char *, int); | |
491 | void lwres_setservent_r(int); | |
492 | void lwres_endservent_r(void); | |
493 | #endif /* notyet */ | |
494 | ||
495 | LWRES_LANG_ENDDECLS | |
496 | ||
497 | #ifdef notyet | |
498 | /* This is nec'y to make this include file properly replace the sun version. */ | |
499 | #ifdef sun | |
500 | #ifdef __GNU_LIBRARY__ | |
501 | #include <rpc/netdb.h> /* Required. */ | |
502 | #else /* !__GNU_LIBRARY__ */ | |
503 | struct rpcent { | |
504 | char *r_name; /* name of server for this rpc program */ | |
505 | char **r_aliases; /* alias list */ | |
506 | int r_number; /* rpc program number */ | |
507 | }; | |
508 | struct rpcent *lwres_getrpcbyname(); | |
509 | struct rpcent *lwres_getrpcbynumber(), | |
510 | struct rpcent *lwres_getrpcent(); | |
511 | #endif /* __GNU_LIBRARY__ */ | |
512 | #endif /* sun */ | |
513 | #endif /* notyet */ | |
514 | ||
515 | /* | |
516 | * Tell Emacs to use C mode on this file. | |
517 | * Local variables: | |
518 | * mode: c | |
519 | * End: | |
520 | */ | |
521 | ||
522 | #endif /* LWRES_NETDB_H */ |