Index: usr.sbin/arp/arp.c =================================================================== --- usr.sbin/arp/arp.c +++ usr.sbin/arp/arp.c @@ -271,21 +271,23 @@ static struct sockaddr_in * getaddr(char *host) { - struct hostent *hp; + struct addrinfo hints, *res; static struct sockaddr_in reply; + int err; - bzero(&reply, sizeof(reply)); - reply.sin_len = sizeof(reply); - reply.sin_family = AF_INET; - reply.sin_addr.s_addr = inet_addr(host); - if (reply.sin_addr.s_addr == INADDR_NONE) { - if (!(hp = gethostbyname(host))) { - xo_warnx("%s: %s", host, hstrerror(h_errno)); - return (NULL); - } - bcopy((char *)hp->h_addr, (char *)&reply.sin_addr, - sizeof reply.sin_addr); + bzero(&hints, sizeof(hints)); + hints.ai_flags = AF_INET; + + err = getaddrinfo(host, NULL, &hints, &res); + + if (err != 0) { + xo_errx(1, "unable to resolve host: %s", gai_strerror(err)); + return NULL; } + + memcpy(&reply, res->ai_addr, res->ai_addrlen); + + freeaddrinfo(res); return (&reply); }