X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/94a3708f00f658994293a440fbbb7e71e2047a0f..7e68ce3fa8ab1e7edd71c5653b3ca7908a35a14f:/print-ntp.c diff --git a/print-ntp.c b/print-ntp.c index d1c0433c..69d7709c 100644 --- a/print-ntp.c +++ b/print-ntp.c @@ -35,6 +35,7 @@ #include #include "netdissect-stdinc.h" +#include "netdissect-ctype.h" #define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" @@ -268,8 +269,20 @@ ntp_time_print(netdissect_options *ndo, switch (stratum) { case UNSPECIFIED: - ND_PRINT("(unspec)"); - ND_TCHECK_4(bp->refid); + /* NTPv4 (RFC 5905, section 7.4) formalizes that refid _may_ + * contain a printable, four-character, left justified, zero + * filled ASCII string ("kiss code") for status reporting + * and debugging. Some kiss codes are defined in the RFC as + * initial set for a new IANA registry, but the list may be + * modified or extended in the future, and unregistered kiss + * codes are possible (and are being seen in the field). + */ + if (!ND_ASCII_ISPRINT(GET_U_1(bp->refid))) { + ND_PRINT("(unspec)"); + ND_TCHECK_4(bp->refid); + } else { + nd_printjn(ndo, (const u_char *)&(bp->refid), 4); + } break; case PRIM_REF: