]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Print NTP refid as hexadecimal number.
authorMiroslav Lichvar <[email protected]>
Mon, 19 Jun 2017 14:31:36 +0000 (16:31 +0200)
committerMiroslav Lichvar <[email protected]>
Tue, 29 Aug 2017 10:37:58 +0000 (12:37 +0200)
In NTPv4 (RFC 5905) the refid field for stratum > 1 is an IPv4 address
or first 32 bits of MD5 sum of an IPv6 address. It's not possible to
tell which of the two it actually is. Print the field as a hexadecimal
number in order to not confuse refids generated from IPv6 addresses with
IPv4 addresses.

print-ntp.c

index 1593ca6bdb061d536f554d3d0d748e0d1507d91c..63e69d5c2cfcae5b5d8b63595d903ab23df46520 100644 (file)
@@ -279,7 +279,9 @@ ntp_print(netdissect_options *ndo,
                return;
 
        default:
-               ND_PRINT((ndo, "%s", ipaddr_string(ndo, &(bp->refid))));
+               /* In NTPv4 (RFC 5905) refid is an IPv4 address or first 32 bits of
+                  MD5 sum of IPv6 address */
+               ND_PRINT((ndo, "%08x", EXTRACT_32BITS(&bp->refid)));
                break;
        }