From 24ea71e942d6c4aaf6577f6fca7b4c4968a34565 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 17 Mar 1997 03:57:03 +0000 Subject: (_nss_nis_gethostbyname2_r): New functions. Compare result for correct address type. (_nss_nis_gethostbyname_r): Use _nss_nis_gethostbyname2_r. --- nis/nss_nis/nis-hosts.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c index bab7f4c5f4..42fc5aeac7 100644 --- a/nis/nss_nis/nis-hosts.c +++ b/nis/nss_nis/nis-hosts.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1996. @@ -242,7 +242,7 @@ _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen, } enum nss_status -_nss_nis_gethostbyname_r (const char *name, struct hostent *host, +_nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host, char *buffer, size_t buflen, int *h_errnop) { enum nss_status retval; @@ -297,9 +297,9 @@ _nss_nis_gethostbyname_r (const char *name, struct hostent *host, parse_res = parse_line (p, host, data, buflen); - if (!parse_res) + if (!parse_res || host->h_addrtype != af) { - if (errno == ERANGE) + if (!parse_res && errno == ERANGE) { *h_errnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; @@ -315,6 +315,24 @@ _nss_nis_gethostbyname_r (const char *name, struct hostent *host, return NSS_STATUS_SUCCESS; } +enum nss_status +_nss_nis_gethostbyname_r (const char *name, struct hostent *host, + char *buffer, size_t buflen, int *h_errnop) +{ + if (_res.options & RES_USE_INET6) + { + enum nss_status status; + + status = _nss_nis_gethostbyname2_r (name, AF_INET6, host, buffer, buflen, + h_errnop); + if (status == NSS_STATUS_SUCCESS) + return status; + } + + return _nss_nis_gethostbyname2_r (name, AF_INET, host, buffer, buflen, + h_errnop); +} + enum nss_status _nss_nis_gethostbyaddr_r (char *addr, int addrlen, int type, struct hostent *host, char *buffer, size_t buflen, -- cgit v1.2.3