+2001-05-07 Ken Raeburn <raeburn@mit.edu>
+
+ * locate_kdc.c (add_sockaddr_to_list) [TEST]: If getnameinfo is
+ available, use it instead of inet_ntoa to get the printable
+ address.
+ (add_host_to_list): Share declaration sections as much as
+ possible. Propagate errors back correctly from gethostbyname
+ path.
+
2001-04-26 Ken Raeburn <raeburn@mit.edu>
* hst_realm.c (T_TXT): Define if not defined by header files.
#ifdef TEST
fprintf (stderr, "\tadding sockaddr family %2d, len %d", addr->sa_family,
len);
+#ifdef HAVE_GETNAMEINFO
+ {
+ char name[NI_MAXHOST];
+ int err;
+
+ err = getnameinfo (addr, len, name, sizeof (name), NULL, 0,
+ NI_NUMERICHOST | NI_NUMERICSERV);
+ if (err == 0)
+ fprintf (stderr, "\t%s", name);
+ }
+#else
if (addr->sa_family == AF_INET)
fprintf (stderr, "\t%s",
inet_ntoa (((const struct sockaddr_in *)addr)->sin_addr));
+#endif
fprintf (stderr, "\n");
#endif
int port, int secport)
{
#ifdef HAVE_GETADDRINFO
- int err;
struct addrinfo *addrs, *a;
+#else
+ struct hostent *hp;
+#endif
+ int err;
#ifdef TEST
fprintf (stderr, "adding hostname %s, ports %d,%d\n", hostname,
ntohs (port), ntohs (secport));
#endif
+#ifdef HAVE_GETADDRINFO
err = getaddrinfo (hostname, NULL, NULL, &addrs);
if (err)
return translate_ai_error (err);
break;
}
freeaddrinfo (addrs);
- return err;
#else
- /* If we don't have getaddrinfo, we're not bothering with IPv6
- support. */
- int err;
- struct hostent *hp;
- int i;
-
-#ifdef TEST
- fprintf (stderr, "adding hostname %s, ports %d,%d\n", hostname, port, secport);
-#endif
-
hp = gethostbyname (hostname);
if (hp != NULL) {
+ int i;
for (i = 0; hp->h_addr_list[i] != 0; i++) {
struct sockaddr_in sin4;
break;
}
}
- return 0;
#endif
+ return err;
}
/*