diff options
author | 2016-09-11 19:46:10 +0000 | |
---|---|---|
committer | 2016-09-11 19:46:10 +0000 | |
commit | d6c301e106a71d6271fc3b5b55248f1b32362a44 (patch) | |
tree | 03cfebf8bd2207ef21d70f75aad40789cb7a1621 | |
parent | The canonical way to find out if we can have timing stats is timinginfo. (diff) | |
download | wireguard-openbsd-d6c301e106a71d6271fc3b5b55248f1b32362a44.tar.xz wireguard-openbsd-d6c301e106a71d6271fc3b5b55248f1b32362a44.zip |
In this day and age use tcpdump to figure out to whom an ICMP echo
reply was sent. We already print the source IP for the echo request in
verbose mode. The destination IP should be the same in the replies.
Gets rid of 37 LOC and makes unification with ping easier.
-rw-r--r-- | sbin/ping6/ping6.c | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 987df76472b..17481335846 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping6.c,v 1.180 2016/09/11 19:44:43 florian Exp $ */ +/* $OpenBSD: ping6.c,v 1.181 2016/09/11 19:46:10 florian Exp $ */ /* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */ /* @@ -214,7 +214,6 @@ __dead void usage(void); int get_hoplim(struct msghdr *); int get_pathmtu(struct msghdr *); -struct in6_pktinfo *get_rcvpktinfo(struct msghdr *); void pr_icmph(struct icmp6_hdr *, u_char *); void pr_iph(struct ip6_hdr *); void pr_exthdrs(struct msghdr *); @@ -950,7 +949,6 @@ pinger(void) void pr_pack(u_char *buf, int cc, struct msghdr *mhdr) { - struct in6_pktinfo *pktinfo = NULL; struct icmp6_hdr *icp; struct timespec ts, tp; struct payload payload; @@ -986,10 +984,6 @@ pr_pack(u_char *buf, int cc, struct msghdr *mhdr) warnx("failed to get receiving hop limit"); return; } - if ((pktinfo = get_rcvpktinfo(mhdr)) == NULL) { - warnx("failed to get receiving packet information"); - return; - } if (icp->icmp6_type == ICMP6_ECHO_REPLY) { if (ntohs(icp->icmp6_id) != ident) @@ -1056,18 +1050,6 @@ pr_pack(u_char *buf, int cc, struct msghdr *mhdr) (void)printf("%d bytes from %s: icmp_seq=%u", cc, pr_addr(from, fromlen), ntohs(seq)); (void)printf(" hlim=%d", hoplim); - if ((options & F_VERBOSE) != 0) { - struct sockaddr_in6 dstsa; - - memset(&dstsa, 0, sizeof(dstsa)); - dstsa.sin6_family = AF_INET6; - dstsa.sin6_len = sizeof(dstsa); - dstsa.sin6_scope_id = pktinfo->ipi6_ifindex; - dstsa.sin6_addr = pktinfo->ipi6_addr; - (void)printf(" dst=%s", - pr_addr((struct sockaddr *)&dstsa, - sizeof(dstsa))); - } if (timinginfo) (void)printf(" time=%.3f ms", triptime); if (dupflag) @@ -1234,25 +1216,6 @@ get_hoplim(struct msghdr *mhdr) return(-1); } -struct in6_pktinfo * -get_rcvpktinfo(struct msghdr *mhdr) -{ - struct cmsghdr *cm; - - for (cm = (struct cmsghdr *)CMSG_FIRSTHDR(mhdr); cm; - cm = (struct cmsghdr *)CMSG_NXTHDR(mhdr, cm)) { - if (cm->cmsg_len == 0) - return(NULL); - - if (cm->cmsg_level == IPPROTO_IPV6 && - cm->cmsg_type == IPV6_PKTINFO && - cm->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo))) - return((struct in6_pktinfo *)CMSG_DATA(cm)); - } - - return(NULL); -} - int get_pathmtu(struct msghdr *mhdr) { |