+ } else if (length == NTP_MSG_MINLEN + 4 + 20) { /* Optional: key-id + 160-bit digest */
+ ND_TCHECK(bp->key_id);
+ ND_PRINT((ndo, "\n\tKey id: %u", EXTRACT_32BITS(&bp->key_id)));
+ ND_TCHECK2(bp->message_digest, 20);
+ ND_PRINT((ndo, "\n\tAuthentication: %08x%08x%08x%08x%08x",
+ EXTRACT_32BITS(bp->message_digest),
+ EXTRACT_32BITS(bp->message_digest + 4),
+ EXTRACT_32BITS(bp->message_digest + 8),
+ EXTRACT_32BITS(bp->message_digest + 12),
+ EXTRACT_32BITS(bp->message_digest + 16)));
+ } else if (length > NTP_MSG_MINLEN) {
+ ND_PRINT((ndo, "\n\t(%u more bytes after the header)", length - NTP_MSG_MINLEN));
+ }
+ return;
+
+invalid:
+ ND_PRINT((ndo, " %s", istr));
+ ND_TCHECK2(*bp, length);
+ return;
+
+trunc:
+ ND_PRINT((ndo, " %s", tstr));
+}
+
+/*
+ * Print NTP control message requests and responses
+ */
+static void
+ntp_control_print(netdissect_options *ndo,
+ register const struct ntp_control_data *cd, u_int length)
+{
+ u_char R, E, M, opcode;
+ uint16_t sequence, status, assoc, offset, count;
+
+ R = (cd->control & 0x80) != 0;
+ E = (cd->control & 0x40) != 0;
+ M = (cd->control & 0x20) != 0;
+ opcode = cd->control & 0x1f;
+ ND_PRINT((ndo, ", %s, %s, %s, OpCode=%u\n",
+ R ? "Response" : "Request", E ? "Error" : "OK",
+ M ? "More" : "Last", (unsigned)opcode));
+
+ sequence = EXTRACT_16BITS(&cd->sequence);
+ ND_PRINT((ndo, "\tSequence=%hu", sequence));
+
+ status = EXTRACT_16BITS(&cd->status);
+ ND_PRINT((ndo, ", Status=%#hx", status));
+
+ assoc = EXTRACT_16BITS(&cd->assoc);
+ ND_PRINT((ndo, ", Assoc.=%hu", assoc));
+
+ offset = EXTRACT_16BITS(&cd->offset);
+ ND_PRINT((ndo, ", Offset=%hu", offset));
+
+ count = EXTRACT_16BITS(&cd->count);
+ ND_PRINT((ndo, ", Count=%hu", count));
+
+ if ((cd->data - (const u_char *)cd) + count > length)
+ goto trunc;
+ if (count != 0)
+ ND_PRINT((ndo, "\n\tTO-BE-DONE: data not interpreted"));