1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-28 11:57:28 +00:00

Small bug fix and improvements

(1)added error check of if_nameindex() return value at getaddrinfo().
  (2)print out more detailed information when getaddrinfo() error value
     is EAI_SYSTEM.(in this case system error num is kept in errno)

(1) is Discovered by: jinmei@kame.net in KAME environment.
This commit is contained in:
Yoshinobu Inoue 1999-12-28 05:37:39 +00:00
parent 0e17bca17c
commit 9b59fde4e0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=55167
3 changed files with 20 additions and 3 deletions

View File

@ -766,6 +766,10 @@ explore_numeric_scope(pai, hostname, servname, res)
#ifdef INET6
case AF_INET6:
scope = if_nametoindex(cp);
if (scope == 0) {
error = EAI_SYSTEM;
goto free;
}
break;
#endif
}
@ -784,6 +788,9 @@ explore_numeric_scope(pai, hostname, servname, res)
}
}
#ifdef INET6
free:
#endif
free(hostname2);
return error;

View File

@ -434,6 +434,8 @@ main(argc, argv)
ret_ga = getaddrinfo(target, NULL, &hints, &res);
if (ret_ga) {
fprintf(stderr, "ping6: %s\n", gai_strerror(ret_ga));
if (ret_ga == EAI_SYSTEM)
errx(1, "%s", strerror(errno));
exit(1);
}
if (res->ai_canonname)
@ -586,8 +588,12 @@ main(argc, argv)
for (hops = 0; hops < argc - 1; hops++) {
struct addrinfo *iaip;
if ((error = getaddrinfo(argv[hops], NULL, &hints, &iaip)))
errx(1, gai_strerror(error));
if ((error = getaddrinfo(argv[hops], NULL, &hints, &iaip))) {
fprintf(stderr, "ping6: %s\n", gai_strerror(error));
if (error == EAI_SYSTEM)
errx(1, strerror(errno));
exit(1);
}
if (SIN6(res->ai_addr)->sin6_family != AF_INET6)
errx(1,
"bad addr family of an intermediate addr");

View File

@ -119,7 +119,11 @@ main(argc, argv)
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(argv[0], pbuf, &hints, &res);
if (error) {
errx(1, "%s: %s", argv[0], gai_strerror(error));
fprintf(stderr, "rip6query: %s: %s\n", argv[0],
gai_strerror(error));
if (error == EAI_SYSTEM)
errx(1, "%s", strerror(errno));
exit(1);
/*NOTREACHED*/
}
if (res->ai_next) {