diff options
author | morriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-02-07 03:31:40 +0000 |
---|---|---|
committer | morriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-02-07 03:31:40 +0000 |
commit | e0f335aacf8145a4c02917d23f018b8140b21e9b (patch) | |
tree | 888b1cdfb3c526c6f42ac39df8141f888a5ebe7e /epan/dissectors/packet-ntp.c | |
parent | 50c47c989aca9e17cd52c5937daf40ef8b103db7 (diff) |
Add support for passing NTP times to proto_tree_add_item() by specifying
an encoding of ENC_TIME_NTP.
This increases the number of decimal places shown for NTP times (from 6 to 9),
so round the value to the nearest microsecond. (I can't tell if NTP times are
ever more precise than a microsecond--this rounding is mainly to be closer to
the old behavior.)
Use proto_tree_add_item() for some NTP times.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35840 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-ntp.c')
-rw-r--r-- | epan/dissectors/packet-ntp.c | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/epan/dissectors/packet-ntp.c b/epan/dissectors/packet-ntp.c index 06feae87fb..186d372da1 100644 --- a/epan/dissectors/packet-ntp.c +++ b/epan/dissectors/packet-ntp.c @@ -659,10 +659,6 @@ dissect_ntp_std(tvbuff_t *tvb, proto_tree *ntp_tree, guint8 flags) double rootdelay; double rootdispersion; guint32 refid_addr; - const guint8 *reftime; - const guint8 *org; - const guint8 *rec; - const guint8 *xmt; const gchar *buffc; gchar *buff; int i; @@ -776,38 +772,22 @@ dissect_ntp_std(tvbuff_t *tvb, proto_tree *ntp_tree, guint8 flags) /* Reference Timestamp: This is the time at which the local clock was * last set or corrected. */ - reftime = tvb_get_ptr(tvb, 16, 8); - proto_tree_add_bytes_format(ntp_tree, hf_ntp_reftime, tvb, 16, 8, - reftime, - "Reference Clock Update Time: %s", - ntp_fmt_ts(reftime)); + proto_tree_add_item(ntp_tree, hf_ntp_reftime, tvb, 16, 8, ENC_TIME_NTP); /* Originate Timestamp: This is the time at which the request departed * the client for the server. */ - org = tvb_get_ptr(tvb, 24, 8); - proto_tree_add_bytes_format(ntp_tree, hf_ntp_org, tvb, 24, 8, - org, - "Originate Time Stamp: %s", - ntp_fmt_ts(org)); + proto_tree_add_item(ntp_tree, hf_ntp_org, tvb, 24, 8, ENC_TIME_NTP); /* Receive Timestamp: This is the time at which the request arrived at * the server. */ - rec = tvb_get_ptr(tvb, 32, 8); - proto_tree_add_bytes_format(ntp_tree, hf_ntp_rec, tvb, 32, 8, - rec, - "Receive Time Stamp: %s", - ntp_fmt_ts(rec)); + proto_tree_add_item(ntp_tree, hf_ntp_rec, tvb, 32, 8, ENC_TIME_NTP); /* Transmit Timestamp: This is the time at which the reply departed the * server for the client. */ - xmt = tvb_get_ptr(tvb, 40, 8); - proto_tree_add_bytes_format(ntp_tree, hf_ntp_xmt, tvb, 40, 8, - xmt, - "Transmit Time Stamp: %s", - ntp_fmt_ts(xmt)); + proto_tree_add_item(ntp_tree, hf_ntp_xmt, tvb, 40, 8, ENC_TIME_NTP); /* MAX_MAC_LEN is the largest message authentication code * (MAC) length. If we have more data left in the packet @@ -1248,16 +1228,16 @@ proto_register_ntp(void) "Reference Clock ID", "ntp.refid", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }}, { &hf_ntp_reftime, { - "Reference Clock Update Time", "ntp.reftime", FT_BYTES, BASE_NONE, + "Reference Clock Update Time", "ntp.reftime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0, NULL, HFILL }}, { &hf_ntp_org, { - "Originate Time Stamp", "ntp.org", FT_BYTES, BASE_NONE, + "Originate Time Stamp", "ntp.org", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0, NULL, HFILL }}, { &hf_ntp_rec, { - "Receive Time Stamp", "ntp.rec", FT_BYTES, BASE_NONE, + "Receive Time Stamp", "ntp.rec", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0, NULL, HFILL }}, { &hf_ntp_xmt, { - "Transmit Time Stamp", "ntp.xmt", FT_BYTES, BASE_NONE, + "Transmit Time Stamp", "ntp.xmt", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0, NULL, HFILL }}, { &hf_ntp_keyid, { "Key ID", "ntp.keyid", FT_BYTES, BASE_NONE, |