summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2014-04-18 17:00:07 +0000
committerflorian <florian@openbsd.org>2014-04-18 17:00:07 +0000
commit0919a36e689e51db3a9da172c10138969c9a19af (patch)
treea3c22a1e2064d00da65d97950b5b91e9b31c7372
parentDeclare socklen_t len in main, it's used in two places, no need (diff)
downloadwireguard-openbsd-0919a36e689e51db3a9da172c10138969c9a19af.tar.xz
wireguard-openbsd-0919a36e689e51db3a9da172c10138969c9a19af.zip
sync to traceroute6: use getnameinfo for destination ip
OK benno@
-rw-r--r--usr.sbin/traceroute/traceroute.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c
index 650059ea6cb..6bb761b4e00 100644
--- a/usr.sbin/traceroute/traceroute.c
+++ b/usr.sbin/traceroute/traceroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traceroute.c,v 1.107 2014/04/18 16:58:02 florian Exp $ */
+/* $OpenBSD: traceroute.c,v 1.108 2014/04/18 17:00:07 florian Exp $ */
/* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */
/*-
@@ -647,8 +647,10 @@ main(int argc, char *argv[])
err(1, "getsockname");
srcport = ntohs(from.sin_port);
- fprintf(stderr, "traceroute to %s (%s)", hostname,
- inet_ntoa(to.sin_addr));
+ if (getnameinfo((struct sockaddr *)&to, to.sin_len, hbuf,
+ sizeof(hbuf), NULL, 0, NI_NUMERICHOST))
+ strlcpy(hbuf, "(invalid)", sizeof(hbuf));
+ fprintf(stderr, "%s to %s (%s)", __progname, hostname, hbuf);
if (source)
fprintf(stderr, " from %s", source);
fprintf(stderr, ", %u hops max, %d byte packets\n", max_ttl, datalen);