diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2016-09-17 09:30:27 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2016-09-17 09:30:27 +0000 |
commit | e1b11cec4b2f7fe3ccdd65f8ac6356f246164c89 (patch) | |
tree | 89768254dce19606a4d567f9204bb5bbbd35cd86 | |
parent | 91992dc2e747ba5b513cbe9f2991d91690d4f49e (diff) |
Introduce AF independent from.
-rw-r--r-- | sbin/ping/ping.c | 8 | ||||
-rw-r--r-- | sbin/ping6/ping6.c | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 0a37e4fdf81..fcff9d60551 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.195 2016/09/17 09:30:00 florian Exp $ */ +/* $OpenBSD: ping.c,v 1.196 2016/09/17 09:30:26 florian Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -224,7 +224,7 @@ main(int argc, char *argv[]) { struct addrinfo hints, *res; struct itimerval itimer; - struct sockaddr *dst; + struct sockaddr *from, *dst; struct sockaddr_in from4, dst4; socklen_t maxsizelen; int64_t preload; @@ -409,6 +409,7 @@ main(int argc, char *argv[]) if (res->ai_addrlen != sizeof(dst4)) errx(1, "size of sockaddr mismatch"); dst = (struct sockaddr *)&dst4; + from = (struct sockaddr *)&from4; break; case AF_INET6: default: @@ -612,8 +613,7 @@ main(int argc, char *argv[]) printf("PING %s (", hostname); if (0 && (options & F_VERBOSE)) - printf("%s --> ", pr_addr((struct sockaddr *)&from4, - sizeof(from4))); + printf("%s --> ", pr_addr(from, from->sa_len)); printf("%s): %d data bytes\n", pr_addr(dst, dst->sa_len), datalen); smsghdr.msg_name = dst; diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 9e192f7395f..833271924fc 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping6.c,v 1.211 2016/09/17 09:30:00 florian Exp $ */ +/* $OpenBSD: ping6.c,v 1.212 2016/09/17 09:30:26 florian Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -222,7 +222,7 @@ main(int argc, char *argv[]) { struct addrinfo hints, *res; struct itimerval itimer; - struct sockaddr *dst; + struct sockaddr *from, *dst; struct sockaddr_in6 from6, dst6; struct cmsghdr *scmsg = NULL; struct in6_pktinfo *pktinfo = NULL; @@ -390,6 +390,7 @@ main(int argc, char *argv[]) if (res->ai_addrlen != sizeof(dst6)) errx(1, "size of sockaddr mismatch"); dst = (struct sockaddr *)&dst6; + from = (struct sockaddr *)&from6; break; case AF_INET: default: @@ -620,8 +621,7 @@ main(int argc, char *argv[]) printf("PING6 %s (", hostname); if (options & F_VERBOSE) - printf("%s --> ", pr_addr((struct sockaddr *)&from6, - sizeof(from6))); + printf("%s --> ", pr_addr(from, from->sa_len)); printf("%s): %d data bytes\n", pr_addr(dst, dst->sa_len), datalen); smsghdr.msg_name = dst; |