diff options
Diffstat (limited to 'contrib/tcpdump/print-ntp.c')
-rw-r--r-- | contrib/tcpdump/print-ntp.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c index 8676cbe..9088fa3 100644 --- a/contrib/tcpdump/print-ntp.c +++ b/contrib/tcpdump/print-ntp.c @@ -27,7 +27,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.42 2005-05-06 07:56:53 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.43 2007-11-30 13:45:10 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -74,6 +74,12 @@ static struct tok ntp_leapind_values[] = { { 0, NULL } }; +static struct tok ntp_stratum_values[] = { + { UNSPECIFIED, "unspecified" }, + { PRIM_REF, "primary reference" }, + { 0, NULL } +}; + /* * Print ntp requests */ @@ -108,7 +114,9 @@ ntp_print(register const u_char *cp, u_int length) leapind); TCHECK(bp->stratum); - printf(", Stratum %u", bp->stratum); + printf(", Stratum %u (%s)", + bp->stratum, + tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum)); TCHECK(bp->ppoll); printf(", poll %us", bp->ppoll); @@ -176,8 +184,19 @@ ntp_print(register const u_char *cp, u_int length) fputs("\n\t Originator - Transmit Timestamp: ", stdout); p_ntp_delta(&(bp->org_timestamp), &(bp->xmt_timestamp)); - /* FIXME key-id, authentication */ - + if ( (sizeof(struct ntpdata) - length) == 16) { /* Optional: key-id */ + TCHECK(bp->key_id); + printf("\n\tKey id: %u", bp->key_id); + } else if ( (sizeof(struct ntpdata) - length) == 0) { /* Optional: key-id + authentication */ + TCHECK(bp->key_id); + printf("\n\tKey id: %u", bp->key_id); + TCHECK2(bp->message_digest, sizeof (bp->message_digest)); + printf("\n\tAuthentication: %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)); + } return; trunc: |