summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-ntp.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-12-11 19:16:52 -0500
committerMichael Mann <mmann78@netscape.net>2016-12-13 13:08:39 +0000
commit4e97f74f1156db5c2cb139a404bc6423cebf7236 (patch)
treebce553ff7dbbe9977fb1adbfc2dc6440be0307c4 /epan/dissectors/packet-ntp.c
parent97b41a494c214161b358cc99fad843a6f061b283 (diff)
downloadwireshark-4e97f74f1156db5c2cb139a404bc6423cebf7236.tar.gz
Add support for adding unit names to hf_ fields.
This was inspired by the https://www.wireshark.org/lists/wireshark-dev/201505/msg00029.html thread. Used TCP and NTP dissectors as the guinea pig with sample use. Documentation updates includes some unrelated cleanup just because it was noticed. Change-Id: I59b26e1ca3b95e3473e4757f1759d7ad82976965 Reviewed-on: https://code.wireshark.org/review/19211 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-ntp.c')
-rw-r--r--epan/dissectors/packet-ntp.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/epan/dissectors/packet-ntp.c b/epan/dissectors/packet-ntp.c
index cfd2cf3e3e..7c3606cc88 100644
--- a/epan/dissectors/packet-ntp.c
+++ b/epan/dissectors/packet-ntp.c
@@ -955,10 +955,7 @@ dissect_ntp_std(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree)
*/
rootdelay = ((gint16)tvb_get_ntohs(tvb, 4)) +
(tvb_get_ntohs(tvb, 6) / 65536.0);
- proto_tree_add_double_format_value(ntp_tree, hf_ntp_rootdelay, tvb, 4, 4,
- rootdelay,
- "%9.4f sec",
- rootdelay);
+ proto_tree_add_double(ntp_tree, hf_ntp_rootdelay, tvb, 4, 4, rootdelay);
/* Root Dispersion, 32-bit unsigned fixed-point number indicating
* the nominal error relative to the primary reference source, in
@@ -966,10 +963,7 @@ dissect_ntp_std(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree)
*/
rootdispersion = ((gint16)tvb_get_ntohs(tvb, 8)) +
(tvb_get_ntohs(tvb, 10) / 65536.0);
- proto_tree_add_double_format_value(ntp_tree, hf_ntp_rootdispersion, tvb, 8, 4,
- rootdispersion,
- "%9.4f sec",
- rootdispersion);
+ proto_tree_add_double(ntp_tree, hf_ntp_rootdispersion, tvb, 8, 4, rootdispersion);
/* Now, there is a problem with secondary servers. Standards
* asks from stratum-2 - stratum-15 servers to set this to the
@@ -1428,11 +1422,11 @@ proto_register_ntp(void)
"Peer Clock Precision", "ntp.precision", FT_INT8, BASE_DEC,
NULL, 0, "The precision of the system clock", HFILL }},
{ &hf_ntp_rootdelay, {
- "Root Delay", "ntp.rootdelay", FT_DOUBLE, BASE_NONE,
- NULL, 0, "Total round-trip delay to the reference clock", HFILL }},
+ "Root Delay", "ntp.rootdelay", FT_DOUBLE, BASE_NONE|BASE_UNIT_STRING,
+ &units_second_seconds, 0, "Total round-trip delay to the reference clock", HFILL }},
{ &hf_ntp_rootdispersion, {
- "Root Dispersion", "ntp.rootdispersion", FT_DOUBLE, BASE_NONE,
- NULL, 0, "Total dispersion to the reference clock", HFILL }},
+ "Root Dispersion", "ntp.rootdispersion", FT_DOUBLE, BASE_NONE|BASE_UNIT_STRING,
+ &units_second_seconds, 0, "Total dispersion to the reference clock", HFILL }},
{ &hf_ntp_refid, {
"Reference ID", "ntp.refid", FT_BYTES, BASE_NONE,
NULL, 0, "Particular server or reference clock being used", HFILL }},