- do DNS lookup for symbolic names specified for a destination

or gateway.
- improves error reporting using gai_strerror(3) instead of
  printing "bad value".
- remove "0" for servname argument for getaddrinfo(3).

Submitted by:	Andreas Kohn <andreas __at__ syndrom23.de>
MFC after:	1 week
This commit is contained in:
Hajimu UMEMOTO 2005-05-23 14:12:32 +00:00
parent 2dc628b54a
commit c60a8b32a2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=146546

View File

@ -963,18 +963,19 @@ getaddr(which, s, hpp)
case AF_INET6:
{
struct addrinfo hints, *res;
int ecode;
q = NULL;
if (which == RTA_DST && (q = strchr(s, '/')) != NULL)
*q = '\0';
memset(&hints, 0, sizeof(hints));
hints.ai_family = afamily; /*AF_INET6*/
hints.ai_flags = AI_NUMERICHOST;
hints.ai_socktype = SOCK_DGRAM; /*dummy*/
if (getaddrinfo(s, "0", &hints, &res) != 0 ||
res->ai_family != AF_INET6 ||
ecode = getaddrinfo(s, NULL, &hints, &res);
if (ecode != 0 || res->ai_family != AF_INET6 ||
res->ai_addrlen != sizeof(su->sin6)) {
(void) fprintf(stderr, "%s: bad value\n", s);
(void) fprintf(stderr, "%s: %s\n", s,
gai_strerror(ecode));
exit(1);
}
memcpy(&su->sin6, res->ai_addr, sizeof(su->sin6));