about summary refs log tree commit diff
path: root/resolv/nss_dns
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-09-15 10:10:05 +0000
committerUlrich Drepper <drepper@redhat.com>2004-09-15 10:10:05 +0000
commitd1fe1f22192f27425accde26c562f456d835e74a (patch)
tree71f5e13d2d55c9d44a2dda0e73abfb4d2875fc70 /resolv/nss_dns
parentdc4f1624fce3d89df08923600837cace1329a88d (diff)
downloadglibc-d1fe1f22192f27425accde26c562f456d835e74a.tar.gz
glibc-d1fe1f22192f27425accde26c562f456d835e74a.tar.xz
glibc-d1fe1f22192f27425accde26c562f456d835e74a.zip
Update.
	* nscd/aicache.c: Prefer using gethostbyname3_r NSS callback to also
	get ttl and canonical name.  Use these two values.
	* resolv/Versions: Export _nss_dns_gethostbyname3_r from libnss_dns.
	* resolv/nss_dns/dns-host.c (getanswer_r): Take two new parameters.
	If nonnull fill with TTL and pointer to canonical name respectively.
	(_nss_dns_gethostbyaddr_r): Pass NULL in new parameters of getanswer_r.
	(_nss_dns_gethostbyname2_r): Just wrapper around
	_nss_dns_gethostbyname3_r.
	(_nss_dns_gethostbyname3_r): Renamed from _nss_dns_gethostbyname2_r.
	Take two new parameters which as passed to getanswer_r.
Diffstat (limited to 'resolv/nss_dns')
-rw-r--r--resolv/nss_dns/dns-host.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index 91699cc50d..f6a2fa65d6 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -125,12 +125,12 @@ static enum nss_status getanswer_r (const querybuf *answer, int anslen,
 				    const char *qname, int qtype,
 				    struct hostent *result, char *buffer,
 				    size_t buflen, int *errnop, int *h_errnop,
-				    int map);
+				    int map, int32_t *ttlp, char **canonp);
 
 enum nss_status
-_nss_dns_gethostbyname2_r (const char *name, int af, struct hostent *result,
+_nss_dns_gethostbyname3_r (const char *name, int af, struct hostent *result,
 			   char *buffer, size_t buflen, int *errnop,
-			   int *h_errnop)
+			   int *h_errnop, int32_t *ttlp, char **canonp)
 {
   union
   {
@@ -211,7 +211,7 @@ _nss_dns_gethostbyname2_r (const char *name, int af, struct hostent *result,
     }
 
   status = getanswer_r (host_buffer.buf, n, name, type, result, buffer, buflen,
-			errnop, h_errnop, map);
+			errnop, h_errnop, map, ttlp, canonp);
   if (host_buffer.buf != orig_host_buffer)
     free (host_buffer.buf);
   return status;
@@ -219,6 +219,16 @@ _nss_dns_gethostbyname2_r (const char *name, int af, struct hostent *result,
 
 
 enum nss_status
+_nss_dns_gethostbyname2_r (const char *name, int af, struct hostent *result,
+			   char *buffer, size_t buflen, int *errnop,
+			   int *h_errnop)
+{
+  return _nss_dns_gethostbyname3_r (name, af, result, buffer, buflen, errnop,
+				    h_errnop, NULL, NULL);
+}
+
+
+enum nss_status
 _nss_dns_gethostbyname_r (const char *name, struct hostent *result,
 			  char *buffer, size_t buflen, int *errnop,
 			  int *h_errnop)
@@ -355,7 +365,7 @@ _nss_dns_gethostbyaddr_r (const void *addr, socklen_t len, int af,
 
  got_it_already:
   status = getanswer_r (host_buffer.buf, n, qbuf, T_PTR, result, buffer, buflen,
-			errnop, h_errnop, 0 /* XXX */);
+			errnop, h_errnop, 0 /* XXX */, NULL, NULL);
   if (host_buffer.buf != orig_host_buffer)
     free (host_buffer.buf);
   if (status != NSS_STATUS_SUCCESS)
@@ -439,7 +449,7 @@ addrsort (char **ap, int num)
 static enum nss_status
 getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
 	     struct hostent *result, char *buffer, size_t buflen,
-	     int *errnop, int *h_errnop, int map)
+	     int *errnop, int *h_errnop, int map, int32_t *ttlp, char **canonp)
 {
   struct host_data
   {
@@ -458,6 +468,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
   int (*name_ok) (const char *);
   u_char packtmp[NS_MAXCDNAME];
   int have_to_map = 0;
+  int32_t ttl = 0;
 
   if (__builtin_expect (linebuflen, 0) < 0)
     {
@@ -577,7 +588,9 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
       type = ns_get16 (cp);
       cp += INT16SZ;			/* type */
       class = ns_get16 (cp);
-      cp += INT16SZ + INT32SZ;		/* class, TTL */
+      cp += INT16SZ;			/* class */
+      ttl = ns_get32 (cp);
+      cp += INT32SZ;			/* TTL */
       n = ns_get16 (cp);
       cp += INT16SZ;			/* len */
       if (class != C_IN)
@@ -749,6 +762,10 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,
 	    {
 	      register int nn;
 
+	      if (ttlp != NULL && ttl != 0)
+		*ttlp = ttl;
+	      if (canonp != NULL)
+		*canonp = bp;
 	      result->h_name = bp;
 	      nn = strlen (bp) + 1;	/* for the \0 */
 	      bp += nn;