- i = EXTRACT_16BITS(&sfp->int_part);
- f = EXTRACT_16BITS(&sfp->fraction);
- ff = f / 65536.0; /* shift radix point by 16 bits */
- f = (int)(ff * 1000000.0); /* Treat fraction as parts per million */
- ND_PRINT((ndo, "%d.%06d", i, f));
+ if (length < NTP_CTRLMSG_MINLEN)
+ goto invalid;
+
+ control = GET_U_1(cd->control);
+ R = (control & 0x80) != 0;
+ E = (control & 0x40) != 0;
+ M = (control & 0x20) != 0;
+ opcode = control & 0x1f;
+ ND_PRINT(", %s, %s, %s, OpCode=%u\n",
+ R ? "Response" : "Request", E ? "Error" : "OK",
+ M ? "More" : "Last", opcode);
+
+ sequence = GET_BE_U_2(cd->sequence);
+ ND_PRINT("\tSequence=%hu", sequence);
+
+ status = GET_BE_U_2(cd->status);
+ ND_PRINT(", Status=%#hx", status);
+
+ assoc = GET_BE_U_2(cd->assoc);
+ ND_PRINT(", Assoc.=%hu", assoc);
+
+ offset = GET_BE_U_2(cd->offset);
+ ND_PRINT(", Offset=%hu", offset);
+
+ count = GET_BE_U_2(cd->count);
+ ND_PRINT(", Count=%hu", count);
+
+ if (NTP_CTRLMSG_MINLEN + count > length)
+ goto invalid;
+ if (count != 0) {
+ ND_TCHECK_LEN(cd->data, count);
+ ND_PRINT("\n\tTO-BE-DONE: data not interpreted");
+ }
+ return;
+
+invalid:
+ nd_print_invalid(ndo);
+ ND_TCHECK_LEN(cd, length);