summaryrefslogtreecommitdiff
path: root/sbin/ping/ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/ping/ping.c')
-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)