• Home
  • Raw
  • Download

Lines Matching +full:- +full:ntp

22  *	loosely based on print-bootp.c
25 /* \summary: Network Time Protocol (NTP) printer */
30 * RFC 1119 - NTPv2
31 * RFC 1305 - NTPv3
32 * RFC 5905 - NTPv4
37 #include "netdissect-stdinc.h"
43 #include "ntp.h"
46 * Based on ntp.h from the U of MD implementation
47 * This file is based on Version 2 of the NTP spec (RFC1119).
53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
69 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
85 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
88 /* Length of the NTP data message with the mandatory fields ("the header")
170 { MINUS_SEC, "-1s" },
181 /* draft-ietf-ntp-mode-6-cmds-02
184 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
186 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
188 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
190 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
194 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
196 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
200 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
202 * Figure 1: NTP Control Message Header
205 /* Length of the NTP control message with the mandatory fields ("the header")
222 * Print NTP time requests and responses
233 stratum = GET_U_1(bp->stratum); in ntp_time_print()
238 ND_PRINT(", poll %d", GET_S_1(bp->ppoll)); in ntp_time_print()
239 p_poll(ndo, GET_S_1(bp->ppoll)); in ntp_time_print()
241 ND_PRINT(", precision %d", GET_S_1(bp->precision)); in ntp_time_print()
243 ND_TCHECK_SIZE(&bp->root_delay); in ntp_time_print()
245 p_sfix(ndo, &bp->root_delay); in ntp_time_print()
247 ND_TCHECK_SIZE(&bp->root_dispersion); in ntp_time_print()
249 p_sfix(ndo, &bp->root_dispersion); in ntp_time_print()
251 ND_TCHECK_4(bp->refid); in ntp_time_print()
252 ND_PRINT(", Reference-ID: "); in ntp_time_print()
261 if (nd_printn(ndo, (const u_char *)&(bp->refid), 4, ndo->ndo_snapend)) in ntp_time_print()
266 ND_PRINT("%s INFO_QUERY", GET_IPADDR_STRING(bp->refid)); in ntp_time_print()
271 ND_PRINT("%s INFO_REPLY", GET_IPADDR_STRING(bp->refid)); in ntp_time_print()
278 ND_PRINT("0x%08x", GET_BE_U_4(bp->refid)); in ntp_time_print()
282 ND_TCHECK_SIZE(&bp->ref_timestamp); in ntp_time_print()
284 p_ntp_time(ndo, &(bp->ref_timestamp)); in ntp_time_print()
286 ND_TCHECK_SIZE(&bp->org_timestamp); in ntp_time_print()
288 p_ntp_time(ndo, &(bp->org_timestamp)); in ntp_time_print()
290 ND_TCHECK_SIZE(&bp->rec_timestamp); in ntp_time_print()
292 p_ntp_time(ndo, &(bp->rec_timestamp)); in ntp_time_print()
294 ND_TCHECK_SIZE(&bp->xmt_timestamp); in ntp_time_print()
296 p_ntp_time(ndo, &(bp->xmt_timestamp)); in ntp_time_print()
298 ND_PRINT("\n\t Originator - Receive Timestamp: "); in ntp_time_print()
299 p_ntp_delta(ndo, &(bp->org_timestamp), &(bp->rec_timestamp)); in ntp_time_print()
301 ND_PRINT("\n\t Originator - Transmit Timestamp: "); in ntp_time_print()
302 p_ntp_delta(ndo, &(bp->org_timestamp), &(bp->xmt_timestamp)); in ntp_time_print()
305 if (length == NTP_TIMEMSG_MINLEN + 4) { /* Optional: key-id (crypto-NAK) */ in ntp_time_print()
306 ND_PRINT("\n\tKey id: %u", GET_BE_U_4(bp->key_id)); in ntp_time_print()
307 } else if (length == NTP_TIMEMSG_MINLEN + 4 + 16) { /* Optional: key-id + 128-bit digest */ in ntp_time_print()
308 ND_PRINT("\n\tKey id: %u", GET_BE_U_4(bp->key_id)); in ntp_time_print()
309 ND_TCHECK_LEN(bp->message_digest, 16); in ntp_time_print()
311 GET_BE_U_4(bp->message_digest), in ntp_time_print()
312 GET_BE_U_4(bp->message_digest + 4), in ntp_time_print()
313 GET_BE_U_4(bp->message_digest + 8), in ntp_time_print()
314 GET_BE_U_4(bp->message_digest + 12)); in ntp_time_print()
315 } else if (length == NTP_TIMEMSG_MINLEN + 4 + 20) { /* Optional: key-id + 160-bit digest */ in ntp_time_print()
316 ND_PRINT("\n\tKey id: %u", GET_BE_U_4(bp->key_id)); in ntp_time_print()
317 ND_TCHECK_LEN(bp->message_digest, 20); in ntp_time_print()
319 GET_BE_U_4(bp->message_digest), in ntp_time_print()
320 GET_BE_U_4(bp->message_digest + 4), in ntp_time_print()
321 GET_BE_U_4(bp->message_digest + 8), in ntp_time_print()
322 GET_BE_U_4(bp->message_digest + 12), in ntp_time_print()
323 GET_BE_U_4(bp->message_digest + 16)); in ntp_time_print()
325 ND_PRINT("\n\t(%u more bytes after the header)", length - NTP_TIMEMSG_MINLEN); in ntp_time_print()
339 * Print NTP control message requests and responses
351 control = GET_U_1(cd->control); in ntp_control_print()
360 sequence = GET_BE_U_2(cd->sequence); in ntp_control_print()
363 status = GET_BE_U_2(cd->status); in ntp_control_print()
366 assoc = GET_BE_U_2(cd->assoc); in ntp_control_print()
369 offset = GET_BE_U_2(cd->offset); in ntp_control_print()
372 count = GET_BE_U_2(cd->count); in ntp_control_print()
378 ND_TCHECK_LEN(cd->data, count); in ntp_control_print()
379 ND_PRINT("\n\tTO-BE-DONE: data not interpreted"); in ntp_control_print()
398 * Print NTP requests, handling the common VN, LI, and Mode
408 ndo->ndo_protocol = "ntp"; in ntp_print()
409 status = GET_U_1(bp->td.status); in ntp_print()
415 if (!ndo->ndo_vflag) { in ntp_print()
439 ntp_time_print(ndo, &bp->td, length); in ntp_print()
443 ntp_control_print(ndo, &bp->cd, length); in ntp_print()
459 i = GET_BE_U_2(sfp->int_part); in p_sfix()
460 f = GET_BE_U_2(sfp->fraction); in p_sfix()
479 u = GET_BE_U_4(lfp->int_part); in p_ntp_delta()
480 ou = GET_BE_U_4(olfp->int_part); in p_ntp_delta()
481 uf = GET_BE_U_4(lfp->fraction); in p_ntp_delta()
482 ouf = GET_BE_U_4(olfp->fraction); in p_ntp_delta()
490 i = u - ou; in p_ntp_delta()
491 f = uf - ouf; in p_ntp_delta()
492 if (ouf > uf) /* must borrow from high-order bits */ in p_ntp_delta()
493 i -= 1; in p_ntp_delta()
496 i = ou - u; in p_ntp_delta()
497 f = ouf - uf; in p_ntp_delta()
498 if (uf > ouf) /* must borrow from the high-order bits */ in p_ntp_delta()
499 i -= 1; in p_ntp_delta()
504 f = uf - ouf; in p_ntp_delta()
507 f = ouf - uf; in p_ntp_delta()
516 ND_PRINT("%s%u.%09u", signbit ? "-" : "+", i, f); in p_ntp_delta()
524 if (poll_interval <= -32 || poll_interval >= 32) in p_poll()
530 ND_PRINT(" (1/%us)", 1U << -poll_interval); in p_poll()