summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2016-09-11 18:19:32 +0000
committerflorian <florian@openbsd.org>2016-09-11 18:19:32 +0000
commit86f9d4f2e84b28585f71e258b34761e8e557e62d (patch)
tree3882079a37da5cdb9aa89683466b0951eb0f7325
parentHoist fill() up, it's AF independent; no obj change. (diff)
downloadwireguard-openbsd-86f9d4f2e84b28585f71e258b34761e8e557e62d.tar.xz
wireguard-openbsd-86f9d4f2e84b28585f71e258b34761e8e557e62d.zip
Hoist summary() up, it's AF independent; no obj change.
Diff between ping and ping6 is easier to read if all identical or as close as possible to being identical functions are in one place.
-rw-r--r--sbin/ping/ping.c58
-rw-r--r--sbin/ping6/ping6.c58
2 files changed, 58 insertions, 58 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index d53c50abfb9..7dc7cce5851 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping.c,v 1.169 2016/09/11 18:18:25 florian Exp $ */
+/* $OpenBSD: ping.c,v 1.170 2016/09/11 18:19:32 florian Exp $ */
/* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */
/*
@@ -681,6 +681,34 @@ fill(char *bp, char *patp)
}
}
+void
+summary(void)
+{
+ printf("\n--- %s ping statistics ---\n", hostname);
+ printf("%lld packets transmitted, ", ntransmitted);
+ printf("%lld packets received, ", nreceived);
+
+ if (nrepeats)
+ printf("%lld duplicates, ", nrepeats);
+ if (ntransmitted) {
+ if (nreceived > ntransmitted)
+ printf("-- somebody's duplicating packets!");
+ else
+ printf("%.1f%% packet loss",
+ ((((double)ntransmitted - nreceived) * 100) /
+ ntransmitted));
+ }
+ printf("\n");
+ if (timinginfo) {
+ /* Only display average to microseconds */
+ double num = nreceived + nrepeats;
+ double avg = tsum / num;
+ double dev = sqrt(fmax(0, tsumsq / num - avg * avg));
+ printf("round-trip min/avg/max/std-dev = %.3f/%.3f/%.3f/%.3f ms\n",
+ tmin, avg, tmax, dev);
+ }
+}
+
/*
* retransmit --
* This routine transmits another ping.
@@ -1096,34 +1124,6 @@ in_cksum(u_short *addr, int len)
return(answer);
}
-void
-summary(void)
-{
- printf("\n--- %s ping statistics ---\n", hostname);
- printf("%lld packets transmitted, ", ntransmitted);
- printf("%lld packets received, ", nreceived);
-
- if (nrepeats)
- printf("%lld duplicates, ", nrepeats);
- if (ntransmitted) {
- if (nreceived > ntransmitted)
- printf("-- somebody's duplicating packets!");
- else
- printf("%.1f%% packet loss",
- ((((double)ntransmitted - nreceived) * 100) /
- ntransmitted));
- }
- printf("\n");
- if (timinginfo) {
- /* Only display average to microseconds */
- double num = nreceived + nrepeats;
- double avg = tsum / num;
- double dev = sqrt(fmax(0, tsumsq / num - avg * avg));
- printf("round-trip min/avg/max/std-dev = %.3f/%.3f/%.3f/%.3f ms\n",
- tmin, avg, tmax, dev);
- }
-}
-
/*
* pr_icmph --
* Print a descriptive string about an ICMP header.
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index 08173162212..18724e57267 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping6.c,v 1.174 2016/09/11 18:18:25 florian Exp $ */
+/* $OpenBSD: ping6.c,v 1.175 2016/09/11 18:19:32 florian Exp $ */
/* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */
/*
@@ -785,6 +785,34 @@ fill(char *bp, char *patp)
}
}
+void
+summary(void)
+{
+ printf("\n--- %s ping6 statistics ---\n", hostname);
+ printf("%lld packets transmitted, ", ntransmitted);
+ printf("%lld packets received, ", nreceived);
+
+ if (nrepeats)
+ printf("%lld duplicates, ", nrepeats);
+ if (ntransmitted) {
+ if (nreceived > ntransmitted)
+ printf("-- somebody's duplicating packets!");
+ else
+ printf("%.1f%% packet loss",
+ ((((double)ntransmitted - nreceived) * 100) /
+ ntransmitted));
+ }
+ printf("\n");
+ if (timinginfo) {
+ /* Only display average to microseconds */
+ double num = nreceived + nrepeats;
+ double avg = tsum / num;
+ double dev = sqrt(fmax(0, tsumsq / num - avg * avg));
+ printf("round-trip min/avg/max/std-dev = %.3f/%.3f/%.3f/%.3f ms\n",
+ tmin, avg, tmax, dev);
+ }
+}
+
/*
* retransmit --
* This routine transmits another ping6.
@@ -1260,34 +1288,6 @@ get_pathmtu(struct msghdr *mhdr)
return(0);
}
-void
-summary(void)
-{
- printf("\n--- %s ping6 statistics ---\n", hostname);
- printf("%lld packets transmitted, ", ntransmitted);
- printf("%lld packets received, ", nreceived);
-
- if (nrepeats)
- printf("%lld duplicates, ", nrepeats);
- if (ntransmitted) {
- if (nreceived > ntransmitted)
- printf("-- somebody's duplicating packets!");
- else
- printf("%.1f%% packet loss",
- ((((double)ntransmitted - nreceived) * 100) /
- ntransmitted));
- }
- printf("\n");
- if (timinginfo) {
- /* Only display average to microseconds */
- double num = nreceived + nrepeats;
- double avg = tsum / num;
- double dev = sqrt(fmax(0, tsumsq / num - avg * avg));
- printf("round-trip min/avg/max/std-dev = %.3f/%.3f/%.3f/%.3f ms\n",
- tmin, avg, tmax, dev);
- }
-}
-
/*
* pr_icmph --
* Print a descriptive string about an ICMP header.