diff options
-rw-r--r-- | networking/traceroute.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c index c1eb2d92e..2f4d6bb43 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -602,12 +602,15 @@ pr_type(unsigned char t) | |||
602 | 602 | ||
603 | return ttab[t]; | 603 | return ttab[t]; |
604 | } | 604 | } |
605 | static void | 605 | static int |
606 | hexdump(const struct icmp *icp, int len) | 606 | hexdump_if_verbose(const struct icmp *icp, int len) |
607 | { | 607 | { |
608 | const unsigned char *p; | 608 | const unsigned char *p; |
609 | int i; | 609 | int i; |
610 | 610 | ||
611 | if (!verbose) | ||
612 | return 0; | ||
613 | |||
611 | printf("\n%d bytes from %s to %s: icmp type %u (%s) code %u\n", | 614 | printf("\n%d bytes from %s to %s: icmp type %u (%s) code %u\n", |
612 | len, | 615 | len, |
613 | auto_string(xmalloc_sockaddr2dotted_noport(&G.from_lsa->u.sa)), | 616 | auto_string(xmalloc_sockaddr2dotted_noport(&G.from_lsa->u.sa)), |
@@ -622,9 +625,10 @@ hexdump(const struct icmp *icp, int len) | |||
622 | printf(" %02x", p[i]); | 625 | printf(" %02x", p[i]); |
623 | } | 626 | } |
624 | bb_putchar('\n'); | 627 | bb_putchar('\n'); |
628 | return 0; | ||
625 | } | 629 | } |
626 | #else | 630 | #else |
627 | # define hexdump(...) ((void)0) | 631 | # define hexdump_if_verbose(...) 0 |
628 | #endif | 632 | #endif |
629 | 633 | ||
630 | static int | 634 | static int |
@@ -704,9 +708,8 @@ packet4_ok(int read_len, int seq) | |||
704 | } | 708 | } |
705 | } | 709 | } |
706 | } | 710 | } |
707 | if (verbose) /* testcase: traceroute -vI 127.0.0.1 (sees its own echo requests) */ | 711 | /* testcase: traceroute -vI 127.0.0.1 (sees its own echo requests) */ |
708 | hexdump(icp, read_len); | 712 | return hexdump_if_verbose(icp, read_len); |
709 | return 0; | ||
710 | } | 713 | } |
711 | 714 | ||
712 | #if ENABLE_TRACEROUTE6 | 715 | #if ENABLE_TRACEROUTE6 |
@@ -767,10 +770,8 @@ packet6_ok(int read_len, int seq) | |||
767 | } | 770 | } |
768 | } | 771 | } |
769 | } | 772 | } |
770 | if (verbose) | 773 | /* cast is safe since the beginning of icmp4 and icmp6 layouts match */ |
771 | /* cast is safe since the beginning of icmp4 and icmp6 layouts match */ | 774 | return hexdump_if_verbose((const struct icmp *)icp, read_len); |
772 | hexdump((const struct icmp *)icp, read_len); | ||
773 | return 0; | ||
774 | } | 775 | } |
775 | 776 | ||
776 | static int | 777 | static int |