2 * ++Copyright++ 1985, 1988, 1993
4 * Copyright (c) 1985, 1988, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 4. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
33 * Permission to use, copy, modify, and distribute this software for any
34 * purpose with or without fee is hereby granted, provided that the above
35 * copyright notice and this permission notice appear in all copies, and that
36 * the name of Digital Equipment Corporation not be used in advertising or
37 * publicity pertaining to distribution of the document or software without
38 * specific, written prior permission.
40 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
41 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
42 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
43 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
44 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
45 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
46 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
52 /* XXX This file is not used by any of the resolver functions implemented by
53 glibc (i.e. get*info and gethostby*). It cannot be removed however because
54 it exports symbols in the libresolv ABI. The file is not maintained any
55 more, nor are these functions. */
57 #if defined(LIBC_SCCS) && !defined(lint)
58 static char sccsid
[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
59 #endif /* LIBC_SCCS and not lint */
61 #include <sys/types.h>
62 #include <sys/param.h>
63 #include <sys/socket.h>
64 #include <netinet/in.h>
65 #include <arpa/inet.h>
66 #include <arpa/nameser.h>
81 #define MULTI_PTRS_ARE_ALIASES 1 /* XXX - experimental */
83 #if defined(BSD) && (BSD >= 199103) && defined(AF_INET6)
87 # include "../conf/portability.h"
90 #if defined(USE_OPTIONS_H)
91 # include <../conf/options.h>
95 # define SPRINTF(x) strlen(sprintf/**/x)
97 # define SPRINTF(x) ((size_t)sprintf x)
100 #define MAXALIASES 35
103 static const char AskedForGot
[] =
104 "gethostby*.getanswer: asked for \"%s\", got \"%s\"";
106 static char *h_addr_ptrs
[MAXADDRS
+ 1];
108 static struct hostent host
;
109 static char *host_aliases
[MAXALIASES
];
110 static char hostbuf
[8*1024];
111 static u_char host_addr
[16]; /* IPv4 or IPv6 */
112 static FILE *hostf
= NULL
;
113 static int stayopen
= 0;
115 static void map_v4v6_address (const char *src
, char *dst
) __THROW
;
116 static void map_v4v6_hostent (struct hostent
*hp
, char **bp
, int *len
) __THROW
;
119 extern void addrsort (char **, int) __THROW
;
123 #define MAXPACKET PACKETSZ
125 #define MAXPACKET 65536
128 /* As per RFC 1034 and 1035 a host name cannot exceed 255 octets in length. */
129 #ifdef MAXHOSTNAMELEN
130 # undef MAXHOSTNAMELEN
132 #define MAXHOSTNAMELEN 256
136 u_char buf
[MAXPACKET
];
150 Dprintf (char *msg
, int num
)
152 if (_res
.options
& RES_DEBUG
) {
160 # define Dprintf(msg, num) /*nada*/
163 #define BOUNDED_INCR(x) \
167 __set_h_errno (NO_RECOVERY); \
172 #define BOUNDS_CHECK(ptr, count) \
174 if ((ptr) + (count) > eom) { \
175 __set_h_errno (NO_RECOVERY); \
181 static struct hostent
*
182 getanswer (const querybuf
*answer
, int anslen
, const char *qname
, int qtype
)
187 const u_char
*eom
, *erdata
;
188 char *bp
, **ap
, **hap
;
189 int type
, class, buflen
, ancount
, qdcount
;
190 int haveanswer
, had_error
;
194 int (*name_ok
) (const char *);
198 eom
= answer
->buf
+ anslen
;
208 return (NULL
); /* XXX should be abort(); */
211 * find first satisfactory answer
214 ancount
= ntohs(hp
->ancount
);
215 qdcount
= ntohs(hp
->qdcount
);
217 buflen
= sizeof hostbuf
;
219 BOUNDED_INCR(HFIXEDSZ
);
221 __set_h_errno (NO_RECOVERY
);
224 n
= dn_expand(answer
->buf
, eom
, cp
, bp
, buflen
);
225 if ((n
< 0) || !(*name_ok
)(bp
)) {
226 __set_h_errno (NO_RECOVERY
);
229 BOUNDED_INCR(n
+ QFIXEDSZ
);
230 if (qtype
== T_A
|| qtype
== T_AAAA
) {
231 /* res_send() has already verified that the query name is the
232 * same as the one we sent; this just gets the expanded name
233 * (i.e., with the succeeding search-domain tacked on).
235 n
= strlen(bp
) + 1; /* for the \0 */
236 if (n
>= MAXHOSTNAMELEN
) {
237 __set_h_errno (NO_RECOVERY
);
243 /* The qname can be abbreviated, but h_name is now absolute. */
248 host
.h_aliases
= host_aliases
;
251 host
.h_addr_list
= h_addr_ptrs
;
254 while (ancount
-- > 0 && cp
< eom
&& !had_error
) {
255 n
= dn_expand(answer
->buf
, eom
, cp
, bp
, buflen
);
256 if ((n
< 0) || !(*name_ok
)(bp
)) {
261 BOUNDS_CHECK(cp
, 3 * INT16SZ
+ INT32SZ
);
263 cp
+= INT16SZ
; /* type */
264 class = ns_get16(cp
);
265 cp
+= INT16SZ
+ INT32SZ
; /* class, TTL */
267 cp
+= INT16SZ
; /* len */
271 /* XXX - debug? syslog? */
273 continue; /* XXX - had_error++ ? */
275 if ((qtype
== T_A
|| qtype
== T_AAAA
) && type
== T_CNAME
) {
276 if (ap
>= &host_aliases
[MAXALIASES
-1])
278 n
= dn_expand(answer
->buf
, eom
, cp
, tbuf
, sizeof tbuf
);
279 if ((n
< 0) || !(*name_ok
)(tbuf
)) {
285 __set_h_errno (NO_RECOVERY
);
290 n
= strlen(bp
) + 1; /* for the \0 */
291 if (n
>= MAXHOSTNAMELEN
) {
297 /* Get canonical name. */
298 n
= strlen(tbuf
) + 1; /* for the \0 */
299 if (n
> buflen
|| n
>= MAXHOSTNAMELEN
) {
309 if (qtype
== T_PTR
&& type
== T_CNAME
) {
310 n
= dn_expand(answer
->buf
, eom
, cp
, tbuf
, sizeof tbuf
);
311 if (n
< 0 || !res_dnok(tbuf
)) {
317 __set_h_errno (NO_RECOVERY
);
320 /* Get canonical name. */
321 n
= strlen(tbuf
) + 1; /* for the \0 */
322 if (n
> buflen
|| n
>= MAXHOSTNAMELEN
) {
333 /* Log a low priority message if we get an unexpected
334 * record, but skip it if we are using DNSSEC since it
335 * uses many different types in responses that do not
338 if ((_res
.options
& RES_USE_DNSSEC
) == 0) {
339 syslog(LOG_NOTICE
|LOG_AUTH
,
340 "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"",
341 qname
, p_class(C_IN
), p_type(qtype
),
345 continue; /* XXX - had_error++ ? */
349 if (strcasecmp(tname
, bp
) != 0) {
350 syslog(LOG_NOTICE
|LOG_AUTH
,
351 AskedForGot
, qname
, bp
);
353 continue; /* XXX - had_error++ ? */
355 n
= dn_expand(answer
->buf
, eom
, cp
, bp
, buflen
);
356 if ((n
< 0) || !res_hnok(bp
)) {
360 #if MULTI_PTRS_ARE_ALIASES
363 __set_h_errno (NO_RECOVERY
);
368 else if (ap
< &host_aliases
[MAXALIASES
-1])
373 n
= strlen(bp
) + 1; /* for the \0 */
374 if (n
>= MAXHOSTNAMELEN
) {
384 if (_res
.options
& RES_USE_INET6
) {
385 n
= strlen(bp
) + 1; /* for the \0 */
386 if (n
>= MAXHOSTNAMELEN
) {
392 map_v4v6_hostent(&host
, &bp
, &buflen
);
394 __set_h_errno (NETDB_SUCCESS
);
399 if (strcasecmp(host
.h_name
, bp
) != 0) {
400 syslog(LOG_NOTICE
|LOG_AUTH
,
401 AskedForGot
, host
.h_name
, bp
);
403 continue; /* XXX - had_error++ ? */
405 if (n
!= host
.h_length
) {
413 nn
= strlen(bp
) + 1; /* for the \0 */
418 /* XXX: when incrementing bp, we have to decrement
419 * buflen by the same amount --okir */
420 buflen
-= sizeof(align
) - ((u_long
)bp
% sizeof(align
));
422 bp
+= sizeof(align
) - ((u_long
)bp
% sizeof(align
));
424 if (bp
+ n
>= &hostbuf
[sizeof hostbuf
]) {
425 Dprintf("size (%d) too big\n", n
);
429 if (hap
>= &h_addr_ptrs
[MAXADDRS
-1]) {
431 Dprintf("Too many addresses (%d)\n",
437 memmove(*hap
++ = bp
, cp
, n
);
442 __set_h_errno (NO_RECOVERY
);
455 # if defined(RESOLVSORT)
457 * Note: we sort even if host can take only one address
458 * in its return structures - should give it the "best"
459 * address in that case, not some random one
461 if (_res
.nsort
&& haveanswer
> 1 && qtype
== T_A
)
462 addrsort(h_addr_ptrs
, haveanswer
);
463 # endif /*RESOLVSORT*/
465 n
= strlen(qname
) + 1; /* for the \0 */
466 if (n
> buflen
|| n
>= MAXHOSTNAMELEN
)
473 if (_res
.options
& RES_USE_INET6
)
474 map_v4v6_hostent(&host
, &bp
, &buflen
);
475 __set_h_errno (NETDB_SUCCESS
);
479 __set_h_errno (NO_RECOVERY
);
483 extern struct hostent
*gethostbyname2(const char *name
, int af
);
484 libresolv_hidden_proto (gethostbyname2
)
487 gethostbyname (const char *name
)
491 if (__res_maybe_init (&_res
, 0) == -1) {
492 __set_h_errno (NETDB_INTERNAL
);
495 if (_res
.options
& RES_USE_INET6
) {
496 hp
= gethostbyname2(name
, AF_INET6
);
500 return (gethostbyname2(name
, AF_INET
));
504 gethostbyname2 (const char *name
, int af
)
514 int n
, size
, type
, len
;
517 if (__res_maybe_init (&_res
, 0) == -1) {
518 __set_h_errno (NETDB_INTERNAL
);
532 __set_h_errno (NETDB_INTERNAL
);
533 __set_errno (EAFNOSUPPORT
);
537 host
.h_addrtype
= af
;
538 host
.h_length
= size
;
541 * if there aren't any dots, it could be a user-level alias.
542 * this is also done in res_query() since we are not the only
543 * function that looks up host names.
545 if (!strchr(name
, '.') && (cp
= __hostalias(name
)))
549 * disallow names consisting only of digits/dots, unless
552 if (isdigit(name
[0]))
553 for (cp
= name
;; ++cp
) {
558 * All-numeric, no dot at the end.
559 * Fake up a hostent as if we'd actually
562 if (inet_pton(af
, name
, host_addr
) <= 0) {
563 __set_h_errno (HOST_NOT_FOUND
);
566 strncpy(hostbuf
, name
, MAXDNAME
);
567 hostbuf
[MAXDNAME
] = '\0';
568 bp
= hostbuf
+ MAXDNAME
;
569 len
= sizeof hostbuf
- MAXDNAME
;
570 host
.h_name
= hostbuf
;
571 host
.h_aliases
= host_aliases
;
572 host_aliases
[0] = NULL
;
573 h_addr_ptrs
[0] = (char *)host_addr
;
574 h_addr_ptrs
[1] = NULL
;
575 host
.h_addr_list
= h_addr_ptrs
;
576 if (_res
.options
& RES_USE_INET6
)
577 map_v4v6_hostent(&host
, &bp
, &len
);
578 __set_h_errno (NETDB_SUCCESS
);
581 if (!isdigit(*cp
) && *cp
!= '.')
584 if ((isxdigit(name
[0]) && strchr(name
, ':') != NULL
) ||
586 for (cp
= name
;; ++cp
) {
591 * All-IPv6-legal, no dot at the end.
592 * Fake up a hostent as if we'd actually
595 if (inet_pton(af
, name
, host_addr
) <= 0) {
596 __set_h_errno (HOST_NOT_FOUND
);
599 strncpy(hostbuf
, name
, MAXDNAME
);
600 hostbuf
[MAXDNAME
] = '\0';
601 bp
= hostbuf
+ MAXDNAME
;
602 len
= sizeof hostbuf
- MAXDNAME
;
603 host
.h_name
= hostbuf
;
604 host
.h_aliases
= host_aliases
;
605 host_aliases
[0] = NULL
;
606 h_addr_ptrs
[0] = (char *)host_addr
;
607 h_addr_ptrs
[1] = NULL
;
608 host
.h_addr_list
= h_addr_ptrs
;
609 __set_h_errno (NETDB_SUCCESS
);
612 if (!isxdigit(*cp
) && *cp
!= ':' && *cp
!= '.')
616 buf
.buf
= origbuf
= (querybuf
*) alloca (1024);
618 if ((n
= __libc_res_nsearch(&_res
, name
, C_IN
, type
, buf
.buf
->buf
, 1024,
619 &buf
.ptr
, NULL
, NULL
, NULL
, NULL
)) < 0) {
620 if (buf
.buf
!= origbuf
)
622 Dprintf("res_nsearch failed (%d)\n", n
);
623 if (errno
== ECONNREFUSED
)
624 return (_gethtbyname2(name
, af
));
627 ret
= getanswer(buf
.buf
, n
, name
, type
);
628 if (buf
.buf
!= origbuf
)
632 libresolv_hidden_def (gethostbyname2
)
635 gethostbyaddr (const void *addr
, socklen_t len
, int af
)
637 const u_char
*uaddr
= (const u_char
*)addr
;
638 static const u_char mapped
[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff };
639 static const u_char tunnelled
[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 };
649 char qbuf
[MAXDNAME
+1], *qp
= NULL
;
654 char hname2
[MAXDNAME
+1];
655 #endif /*SUNSECURITY*/
657 if (__res_maybe_init (&_res
, 0) == -1) {
658 __set_h_errno (NETDB_INTERNAL
);
661 if (af
== AF_INET6
&& len
== IN6ADDRSZ
&&
662 (!memcmp(uaddr
, mapped
, sizeof mapped
) ||
663 !memcmp(uaddr
, tunnelled
, sizeof tunnelled
))) {
665 addr
+= sizeof mapped
;
666 uaddr
+= sizeof mapped
;
678 __set_errno (EAFNOSUPPORT
);
679 __set_h_errno (NETDB_INTERNAL
);
683 __set_errno (EINVAL
);
684 __set_h_errno (NETDB_INTERNAL
);
689 (void) sprintf(qbuf
, "%u.%u.%u.%u.in-addr.arpa",
697 for (n
= IN6ADDRSZ
- 1; n
>= 0; n
--) {
698 qp
+= SPRINTF((qp
, "%x.%x.",
700 (uaddr
[n
] >> 4) & 0xf));
702 strcpy(qp
, "ip6.arpa");
708 buf
.buf
= orig_buf
= (querybuf
*) alloca (1024);
710 n
= __libc_res_nquery(&_res
, qbuf
, C_IN
, T_PTR
, buf
.buf
->buf
, 1024,
711 &buf
.ptr
, NULL
, NULL
, NULL
, NULL
);
712 if (n
< 0 && af
== AF_INET6
&& (_res
.options
& RES_NOIP6DOTINT
) == 0) {
713 strcpy(qp
, "ip6.int");
714 n
= __libc_res_nquery(&_res
, qbuf
, C_IN
, T_PTR
, buf
.buf
->buf
,
715 buf
.buf
!= orig_buf
? MAXPACKET
: 1024,
716 &buf
.ptr
, NULL
, NULL
, NULL
, NULL
);
719 if (buf
.buf
!= orig_buf
)
721 Dprintf("res_nquery failed (%d)\n", n
);
722 if (errno
== ECONNREFUSED
)
723 return (_gethtbyaddr(addr
, len
, af
));
726 hp
= getanswer(buf
.buf
, n
, qbuf
, T_PTR
);
727 if (buf
.buf
!= orig_buf
)
730 return (NULL
); /* h_errno was set by getanswer() */
734 * turn off search as the name should be absolute,
735 * 'localhost' should be matched by defnames
737 strncpy(hname2
, hp
->h_name
, MAXDNAME
);
738 hname2
[MAXDNAME
] = '\0';
739 old_options
= _res
.options
;
740 _res
.options
&= ~RES_DNSRCH
;
741 _res
.options
|= RES_DEFNAMES
;
742 if (!(rhp
= gethostbyname(hname2
))) {
743 syslog(LOG_NOTICE
|LOG_AUTH
,
744 "gethostbyaddr: No A record for %s (verifying [%s])",
745 hname2
, inet_ntoa(*((struct in_addr
*)addr
)));
746 _res
.options
= old_options
;
747 __set_h_errno (HOST_NOT_FOUND
);
750 _res
.options
= old_options
;
751 for (haddr
= rhp
->h_addr_list
; *haddr
; haddr
++)
752 if (!memcmp(*haddr
, addr
, INADDRSZ
))
755 syslog(LOG_NOTICE
|LOG_AUTH
,
756 "gethostbyaddr: A record of %s != PTR record [%s]",
757 hname2
, inet_ntoa(*((struct in_addr
*)addr
)));
758 __set_h_errno (HOST_NOT_FOUND
);
762 #endif /*SUNSECURITY*/
765 memmove(host_addr
, addr
, len
);
766 h_addr_ptrs
[0] = (char *)host_addr
;
767 h_addr_ptrs
[1] = NULL
;
768 if (af
== AF_INET
&& (_res
.options
& RES_USE_INET6
)) {
769 map_v4v6_address((char*)host_addr
, (char*)host_addr
);
770 hp
->h_addrtype
= AF_INET6
;
771 hp
->h_length
= IN6ADDRSZ
;
773 __set_h_errno (NETDB_SUCCESS
);
781 hostf
= fopen(_PATH_HOSTS
, "rce" );
786 libresolv_hidden_def (_sethtent
)
791 if (hostf
&& !stayopen
) {
792 (void) fclose(hostf
);
804 if (!hostf
&& !(hostf
= fopen(_PATH_HOSTS
, "rce" ))) {
805 __set_h_errno (NETDB_INTERNAL
);
809 if (!(p
= fgets(hostbuf
, sizeof hostbuf
, hostf
))) {
810 __set_h_errno (HOST_NOT_FOUND
);
815 if (!(cp
= strpbrk(p
, "#\n")))
818 if (!(cp
= strpbrk(p
, " \t")))
821 if (inet_pton(AF_INET6
, p
, host_addr
) > 0) {
824 } else if (inet_pton(AF_INET
, p
, host_addr
) > 0) {
825 if (_res
.options
& RES_USE_INET6
) {
826 map_v4v6_address((char*)host_addr
, (char*)host_addr
);
836 h_addr_ptrs
[0] = (char *)host_addr
;
837 h_addr_ptrs
[1] = NULL
;
838 host
.h_addr_list
= h_addr_ptrs
;
840 host
.h_addrtype
= af
;
841 while (*cp
== ' ' || *cp
== '\t')
844 q
= host
.h_aliases
= host_aliases
;
845 if ((cp
= strpbrk(cp
, " \t")))
848 if (*cp
== ' ' || *cp
== '\t') {
852 if (q
< &host_aliases
[MAXALIASES
- 1])
854 if ((cp
= strpbrk(cp
, " \t")))
858 __set_h_errno (NETDB_SUCCESS
);
861 libresolv_hidden_def (_gethtent
)
864 _gethtbyname (const char *name
)
868 if (_res
.options
& RES_USE_INET6
) {
869 hp
= _gethtbyname2(name
, AF_INET6
);
873 return (_gethtbyname2(name
, AF_INET
));
877 _gethtbyname2 (const char *name
, int af
)
883 while ((p
= _gethtent())) {
884 if (p
->h_addrtype
!= af
)
886 if (strcasecmp(p
->h_name
, name
) == 0)
888 for (cp
= p
->h_aliases
; *cp
!= 0; cp
++)
889 if (strcasecmp(*cp
, name
) == 0)
896 libresolv_hidden_def (_gethtbyname2
)
899 _gethtbyaddr (const char *addr
, size_t len
, int af
)
904 while ((p
= _gethtent()))
905 if (p
->h_addrtype
== af
&& !memcmp(p
->h_addr
, addr
, len
))
910 libresolv_hidden_def (_gethtbyaddr
)
913 map_v4v6_address (const char *src
, char *dst
)
915 u_char
*p
= (u_char
*)dst
;
919 /* Stash a temporary copy so our caller can update in place. */
920 memcpy(tmp
, src
, INADDRSZ
);
921 /* Mark this ipv6 addr as a mapped ipv4. */
922 for (i
= 0; i
< 10; i
++)
926 /* Retrieve the saved copy and we're done. */
927 memcpy((void*)p
, tmp
, INADDRSZ
);
931 map_v4v6_hostent (struct hostent
*hp
, char **bpp
, int *lenp
)
935 if (hp
->h_addrtype
!= AF_INET
|| hp
->h_length
!= INADDRSZ
)
937 hp
->h_addrtype
= AF_INET6
;
938 hp
->h_length
= IN6ADDRSZ
;
939 for (ap
= hp
->h_addr_list
; *ap
; ap
++) {
940 int i
= sizeof(align
) - ((u_long
)*bpp
% sizeof(align
));
942 if (*lenp
< (i
+ IN6ADDRSZ
)) {
943 /* Out of memory. Truncate address list here. XXX */
949 map_v4v6_address(*ap
, *bpp
);
958 addrsort (char **ap
, int num
)
962 short aval
[MAXADDRS
];
966 for (i
= 0; i
< num
; i
++, p
++) {
967 for (j
= 0 ; (unsigned)j
< _res
.nsort
; j
++)
968 if (_res
.sort_list
[j
].addr
.s_addr
==
969 (((struct in_addr
*)(*p
))->s_addr
& _res
.sort_list
[j
].mask
))
972 if (needsort
== 0 && i
> 0 && j
< aval
[i
-1])
978 while (needsort
< num
) {
979 for (j
= needsort
- 1; j
>= 0; j
--) {
980 if (aval
[j
] > aval
[j
+1]) {
999 #if defined(BSD43_BSD43_NFS) || defined(sun)
1000 /* some libc's out there are bound internally to these names (UMIPS) */
1002 ht_sethostent (int stayopen
)
1004 _sethtent(stayopen
);
1008 ht_endhostent (void)
1014 ht_gethostbyname (char *name
)
1016 return (_gethtbyname(name
));
1020 ht_gethostbyaddr (const char *addr
, size_t len
, int af
)
1022 return (_gethtbyaddr(addr
, len
, af
));
1028 return (_gethtent());
1038 dn_skipname(comp_dn
, eom
)
1039 const u_char
*comp_dn
, *eom
;
1041 return (__dn_skipname(comp_dn
, eom
));
1043 #endif /*old-style libc with yp junk in it*/