aboutsummaryrefslogtreecommitdiff
path: root/contrib/tcpdump/print-ntp.c
diff options
context:
space:
mode:
authorRui Paulo <rpaulo@FreeBSD.org>2010-10-28 19:06:17 +0000
committerRui Paulo <rpaulo@FreeBSD.org>2010-10-28 19:06:17 +0000
commit27df3f5dddcc52e19be97c5e876161208987d4f1 (patch)
treedf5e0d876c3ec2ff0e3d9c6795cb5c1e20b7d5c4 /contrib/tcpdump/print-ntp.c
parentba2a27351bcd9e7c4ba485cf914d9071eebc2c60 (diff)
parent6d59e2f382406def185ce5261b8723a174cd28a3 (diff)
downloadsrc-27df3f5dddcc52e19be97c5e876161208987d4f1.tar.gz
src-27df3f5dddcc52e19be97c5e876161208987d4f1.zip
Notes
Diffstat (limited to 'contrib/tcpdump/print-ntp.c')
-rw-r--r--contrib/tcpdump/print-ntp.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c
index 8676cbe383b2..9088fa37557a 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: