summaryrefslogtreecommitdiff
path: root/sbin/ping
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2016-09-11 18:18:26 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2016-09-11 18:18:26 +0000
commit5cee5cff0a08c25fa4265c04e26da9c8a3658ccd (patch)
treebbd265081ccc14430ef747268c82e0c9d2925819 /sbin/ping
parentb916416f09b70061d44c2ba5ca9bcbd5d077c92a (diff)
Hoist fill() 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.
Diffstat (limited to 'sbin/ping')
-rw-r--r--sbin/ping/ping.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index bb904909353..d53c50abfb9 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping.c,v 1.168 2016/09/11 18:04:07 florian Exp $ */
+/* $OpenBSD: ping.c,v 1.169 2016/09/11 18:18:25 florian Exp $ */
/* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */
/*
@@ -651,6 +651,36 @@ onsignal(int sig)
}
}
+void
+fill(char *bp, char *patp)
+{
+ int ii, jj, kk;
+ int pat[16];
+ char *cp;
+
+ for (cp = patp; *cp; cp++)
+ if (!isxdigit((unsigned char)*cp))
+ errx(1, "patterns must be specified as hex digits");
+ ii = sscanf(patp,
+ "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
+ &pat[0], &pat[1], &pat[2], &pat[3], &pat[4], &pat[5], &pat[6],
+ &pat[7], &pat[8], &pat[9], &pat[10], &pat[11], &pat[12],
+ &pat[13], &pat[14], &pat[15]);
+
+ if (ii > 0)
+ for (kk = 0;
+ kk <= MAXPAYLOAD - (8 + sizeof(struct payload) + ii);
+ kk += ii)
+ for (jj = 0; jj < ii; ++jj)
+ bp[jj + kk] = pat[jj];
+ if (!(options & F_QUIET)) {
+ (void)printf("PATTERN: 0x");
+ for (jj = 0; jj < ii; ++jj)
+ (void)printf("%02x", bp[jj] & 0xFF);
+ (void)printf("\n");
+ }
+}
+
/*
* retransmit --
* This routine transmits another ping.
@@ -1334,36 +1364,6 @@ pr_retip(struct ip *ip)
(*cp * 256 + *(cp + 1)), (*(cp + 2) * 256 + *(cp + 3)));
}
-void
-fill(char *bp, char *patp)
-{
- int ii, jj, kk;
- int pat[16];
- char *cp;
-
- for (cp = patp; *cp; cp++)
- if (!isxdigit((unsigned char)*cp))
- errx(1, "patterns must be specified as hex digits");
- ii = sscanf(patp,
- "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
- &pat[0], &pat[1], &pat[2], &pat[3], &pat[4], &pat[5], &pat[6],
- &pat[7], &pat[8], &pat[9], &pat[10], &pat[11], &pat[12],
- &pat[13], &pat[14], &pat[15]);
-
- if (ii > 0)
- for (kk = 0;
- kk <= MAXPAYLOAD - (8 + sizeof(struct payload) + ii);
- kk += ii)
- for (jj = 0; jj < ii; ++jj)
- bp[jj + kk] = pat[jj];
- if (!(options & F_QUIET)) {
- (void)printf("PATTERN: 0x");
- for (jj = 0; jj < ii; ++jj)
- (void)printf("%02x", bp[jj] & 0xFF);
- (void)printf("\n");
- }
-}
-
#ifndef SMALL
int
map_tos(char *key, int *val)