Index: lib/libcasper/services/cap_dns/cap_dns.3 =================================================================== --- lib/libcasper/services/cap_dns/cap_dns.3 +++ lib/libcasper/services/cap_dns/cap_dns.3 @@ -162,11 +162,14 @@ casper service and uses it to resolve an IP address. .Bd -literal cap_channel_t *capcas, *capdns; +const char *ipstr = "127.0.0.1"; const char *typelimit = "ADDR"; int familylimit; -const char *ipstr = "127.0.0.1"; -struct in_addr ip; -struct hostent *hp; +char host[NI_MAXHOST]; +struct sockaddr_in sa; + +memset(&sa, 0, sizeof(sa)); +sa.sin_family = AF_INET; /* Open capability to Casper. */ capcas = cap_init(); @@ -195,15 +198,16 @@ err(1, "Unable to limit access to the system.dns service"); /* Convert IP address in C-string to in_addr. */ -if (!inet_aton(ipstr, &ip)) +if (!inet_pton(AF_INET, ipstr, &sa.sin_addr)) errx(1, "Unable to parse IP address %s.", ipstr); /* Find hostname for the given IP address. */ -hp = cap_gethostbyaddr(capdns, (const void *)&ip, sizeof(ip), AF_INET); -if (hp == NULL) +if (cap_getnameinfo(capdns, (const struct sockaddr *)&sa, sizeof(sa), host, + sizeof(host), NULL, 0, NI_NAMEREQD) != 0) { errx(1, "No name associated with %s.", ipstr); +} -printf("Name associated with %s is %s.\\n", ipstr, hp->h_name); +printf("Name associated with %s is %s.\\n", ipstr, host); .Ed .Sh SEE ALSO .Xr cap_enter 2 ,