From fa2472c13520e232e3e9621dce062cdc71549b76 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 26 Oct 2010 15:49:09 +0200 Subject: [PATCH] Fix printing the ToS value. Apparently "%#04x" prints 0 as "0000" instead of "0x00". *sigh* --- src/liboping.c | 4 ++-- src/oping.c | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/liboping.c b/src/liboping.c index 6aee297..6e8d755 100644 --- a/src/liboping.c +++ b/src/liboping.c @@ -513,7 +513,7 @@ static int ping_receive_one (pingobj_t *obj, const pinghost_t *ph, { memcpy (&recv_tos, CMSG_DATA (cmsg), sizeof (recv_tos)); - dprintf ("TOSv4 = %#04"PRIx8";\n", recv_tos); + dprintf ("TOSv4 = 0x%02"PRIx8";\n", recv_tos); } else if (cmsg->cmsg_type == IP_TTL) { @@ -536,7 +536,7 @@ static int ping_receive_one (pingobj_t *obj, const pinghost_t *ph, { memcpy (&recv_tos, CMSG_DATA (cmsg), sizeof (recv_tos)); - dprintf ("TOSv6 = %#04"PRIx8";\n", recv_tos); + dprintf ("TOSv6 = 0x%02"PRIx8";\n", recv_tos); } else if (cmsg->cmsg_type == IPV6_HOPLIMIT) { diff --git a/src/oping.c b/src/oping.c index 313b83d..0f8e413 100644 --- a/src/oping.c +++ b/src/oping.c @@ -25,6 +25,8 @@ # include # include # include +# include +# include # include # include #else @@ -631,7 +633,7 @@ static void update_host_hook (pingobj_iter_t *iter, /* {{{ */ double latency; unsigned int sequence; int recv_ttl; - unsigned recv_tos; + uint8_t recv_tos; size_t buffer_len; size_t data_len; ping_context_t *context; @@ -694,8 +696,8 @@ static void update_host_hook (pingobj_iter_t *iter, /* {{{ */ || (latency > (average + stddev))) color = OPING_YELLOW; - HOST_PRINTF ("%zu bytes from %s (%s): icmp_seq=%u ttl=%i tos=%u " - "time=", + HOST_PRINTF ("%zu bytes from %s (%s): icmp_seq=%u ttl=%i tos=0x%02"PRIx8 + " time=", data_len, context->host, context->addr, sequence, recv_ttl, recv_tos); wattron (main_win, COLOR_PAIR(color)); @@ -706,8 +708,8 @@ static void update_host_hook (pingobj_iter_t *iter, /* {{{ */ else { #endif - HOST_PRINTF ("%zu bytes from %s (%s): icmp_seq=%u ttl=%i tos=%u " - "time=%.2f ms\n", + HOST_PRINTF ("%zu bytes from %s (%s): icmp_seq=%u ttl=%i tos=0x%02"PRIx8 + " time=%.2f ms\n", data_len, context->host, context->addr, sequence, recv_ttl, recv_tos, latency); -- 2.11.0