Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
itojun
committed
May 27, 2000
1 parent
e5ac98c
commit 54ff940
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
$NetBSD$ | ||
|
||
Index: PctestIpv6.cc | ||
=================================================================== | ||
RCS file: /cvsroot/apps/pchar/PctestIpv6.cc,v | ||
retrieving revision 1.1.1.1 | ||
retrieving revision 1.3 | ||
diff -u -r1.1.1.1 -r1.3 | ||
--- PctestIpv6.cc 2000/05/27 08:18:36 1.1.1.1 | ||
+++ PctestIpv6.cc 2000/05/27 08:41:33 1.3 | ||
@@ -210,28 +210,28 @@ | ||
// | ||
char *PctestIpv6::GetName(void *a) | ||
{ | ||
- struct addrinfo *host, hints; | ||
- char *h_name; | ||
- int error_num; | ||
+ static char hbuf[NI_MAXHOST]; | ||
+ struct sockaddr_in6 sin6; | ||
+ int niflags; | ||
|
||
- memset(&hints, 0, sizeof(hints)); | ||
- hints.ai_family = PF_INET6; | ||
- getaddrinfo((char *) a, NULL, &hints, &host); | ||
+ memset(&sin6, 0, sizeof(sin6)); | ||
+ sin6.sin6_family = AF_INET6; | ||
+#ifdef HAVE_SOCKADDR_SA_LEN | ||
+ sin6.sin6_len = sizeof(struct sockaddr_in6); | ||
+#endif | ||
+ memcpy(&sin6.sin6_addr, a, sizeof(sin6.sin6_addr)); | ||
+ /* XXX scope */ | ||
|
||
- if (host) { | ||
- | ||
- h_name = host->ai_canonname; | ||
- /* | ||
- * XXX We don't free the addrinfo, since we return the canonname field. | ||
- */ | ||
- | ||
- /* freeaddrinfo(host); */ | ||
- return h_name; | ||
- } | ||
- else { | ||
- return (GetPrintableAddress(a)); | ||
- } | ||
- | ||
+#if 0 | ||
+ niflags = NumericFlag ? NI_NUMERICHOST : 0; | ||
+#else | ||
+ niflags = NI_NUMERICHOST; | ||
+#endif | ||
+ if (getnameinfo((struct sockaddr *)&sin6, sizeof(struct sockaddr_in6), | ||
+ hbuf, sizeof(hbuf), NULL, 0, niflags) == 0) { | ||
+ return hbuf; | ||
+ } else | ||
+ return "(invalid)"; | ||
} | ||
|
||
// |