]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ntp.c
CI: Add warning exemptions for Sun C (suncc-5.14) on Solaris 10
[tcpdump] / print-ntp.c
index 5f6368f14fadbe0caa55f051cddf9b94f05a95d5..5f791feb676865bc92026f03bcb77651c0be5295 100644 (file)
  * RFC 5905 - NTPv4
  */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
+#include "netdissect-ctype.h"
 
 #define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
@@ -67,7 +66,7 @@
  * |                                                               |
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  * |                                                               |
- * |                   Originate Timestamp (64)                    |
+ * |                     Origin Timestamp (64)                     |
  * |                                                               |
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  * |                                                               |
@@ -270,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:
@@ -298,7 +309,7 @@ ntp_time_print(netdissect_options *ndo,
        ND_PRINT("\n\t  Reference Timestamp:  ");
        p_ntp_time(ndo, &(bp->ref_timestamp));
 
-       ND_PRINT("\n\t  Originator Timestamp: ");
+       ND_PRINT("\n\t  Origin Timestamp:     ");
        p_ntp_time(ndo, &(bp->org_timestamp));
 
        ND_PRINT("\n\t  Receive Timestamp:    ");
@@ -589,7 +600,7 @@ p_ext_fields(netdissect_options *ndo, const u_char *cp, u_int length)
                p_ntp_ef(ndo, ef_type, ef_len, (const u_char *)(ef + 1));
 
                /*
-                * The entire extension field is guaranted to be in the
+                * The entire extension field is guaranteed to be in the
                 * captured data, as p_ntp_ef() will longjmp out if it
                 * isn't.
                 *