diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-13 15:10:07 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-13 15:10:07 +0100 |
commit | d067acb0052c20edbfe7f13c99b8947ce8911eb7 (patch) | |
tree | 3aaedcf6d4c0480ff2db65f86dcf69128dd9e8e1 | |
parent | b4b182807687a872c49a89b840754a553c00f8a1 (diff) | |
download | busybox-d067acb0052c20edbfe7f13c99b8947ce8911eb7.tar.gz |
traceroute: simpler hexdump()
function old new delta
hexdump 270 239 -31
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/traceroute.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c index 4d0ebc3b7..8ab4caefe 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -608,7 +608,7 @@ hexdump(const struct icmp *icp, int len) const unsigned char *p; int i; - printf("\n%d bytes from %s to %s: icmp type %d (%s) code %d\n", + printf("\n%d bytes from %s to %s: icmp type %u (%s) code %u\n", len, auto_string(xmalloc_sockaddr2dotted_noport(&G.from_lsa->u.sa)), auto_string(xmalloc_sockaddr2dotted_noport(G.to)), @@ -617,13 +617,9 @@ hexdump(const struct icmp *icp, int len) ); p = (const void *)icp; for (i = 0; i < len; i++) { - if (i % 16 == 0) - printf("%04x:", i); - if (i % 4 == 0) - bb_putchar(' '); - printf("%02x", p[i]); - if ((i % 16 == 15) && (i + 1 < len)) - bb_putchar('\n'); + if (!(i & 0xf)) + printf("\n%04x:" + (i==0), i); + printf(" %02x", p[i]); } bb_putchar('\n'); } @@ -706,7 +702,7 @@ packet4_ok(int read_len, int seq) } } } - if (verbose) + if (verbose) /* testcase: traceroute -vI 127.0.0.1 (sees its own echo requests) */ hexdump(icp, read_len); return 0; } |