ntp: change root delay and dispersion to integer for fixed precision.

dfilter/group_double tests have been removed and need to be replaced by leveraging
another protocol.

Bug: 15049
Change-Id: I354a27a5217336ee5c9b1d021a2d3226e3532eec
Reviewed-on: https://code.wireshark.org/review/29035
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Dario Lombardo 2018-10-18 16:53:33 +02:00 committed by Michael Mann
parent af55deabbc
commit aa038336ce
2 changed files with 19 additions and 12 deletions

View File

@ -913,8 +913,10 @@ dissect_ntp_std(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree)
guint8 stratum; guint8 stratum;
guint8 ppoll; guint8 ppoll;
gint8 precision; gint8 precision;
double rootdelay; guint32 rootdelay;
double rootdispersion; double rootdelay_double;
guint32 rootdispersion;
double rootdispersion_double;
guint32 refid_addr; guint32 refid_addr;
gchar *buff; gchar *buff;
int i; int i;
@ -952,17 +954,19 @@ dissect_ntp_std(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree)
* the total roundtrip delay to the primary reference source, * the total roundtrip delay to the primary reference source,
* in seconds with fraction point between bits 15 and 16. * in seconds with fraction point between bits 15 and 16.
*/ */
rootdelay = tvb_get_ntohis(tvb, 4) + rootdelay = tvb_get_ntohl(tvb, 4);
(tvb_get_ntohs(tvb, 6) / 65536.0); rootdelay_double = (rootdelay >> 16) + (rootdelay & 0xffff) / 65536.0;
proto_tree_add_double(ntp_tree, hf_ntp_rootdelay, tvb, 4, 4, rootdelay); proto_tree_add_uint_format_value(ntp_tree, hf_ntp_rootdelay, tvb, 4, 4,
rootdelay, "%8.6f seconds", rootdelay_double);
/* Root Dispersion, 32-bit unsigned fixed-point number indicating /* Root Dispersion, 32-bit unsigned fixed-point number indicating
* the nominal error relative to the primary reference source, in * the nominal error relative to the primary reference source, in
* seconds with fraction point between bits 15 and 16. * seconds with fraction point between bits 15 and 16.
*/ */
rootdispersion = tvb_get_ntohis(tvb, 8) + rootdispersion = tvb_get_ntohl(tvb, 8);
(tvb_get_ntohs(tvb, 10) / 65536.0); rootdispersion_double = (rootdispersion >> 16) + (rootdispersion & 0xffff) / 65536.0;
proto_tree_add_double(ntp_tree, hf_ntp_rootdispersion, tvb, 8, 4, rootdispersion); proto_tree_add_uint_format_value(ntp_tree, hf_ntp_rootdispersion, tvb, 8, 4,
rootdispersion, "%8.6f seconds", rootdispersion_double);
/* Now, there is a problem with secondary servers. Standards /* Now, there is a problem with secondary servers. Standards
* asks from stratum-2 - stratum-15 servers to set this to the * asks from stratum-2 - stratum-15 servers to set this to the
@ -1451,11 +1455,11 @@ proto_register_ntp(void)
"Peer Clock Precision", "ntp.precision", FT_UINT8, BASE_DEC, "Peer Clock Precision", "ntp.precision", FT_UINT8, BASE_DEC,
NULL, 0, "The precision of the system clock", HFILL }}, NULL, 0, "The precision of the system clock", HFILL }},
{ &hf_ntp_rootdelay, { { &hf_ntp_rootdelay, {
"Root Delay", "ntp.rootdelay", FT_DOUBLE, BASE_NONE|BASE_UNIT_STRING, "Root Delay", "ntp.rootdelay", FT_UINT32, BASE_DEC,
&units_second_seconds, 0, "Total round-trip delay to the reference clock", HFILL }}, NULL, 0, "Total round-trip delay to the reference clock", HFILL }},
{ &hf_ntp_rootdispersion, { { &hf_ntp_rootdispersion, {
"Root Dispersion", "ntp.rootdispersion", FT_DOUBLE, BASE_NONE|BASE_UNIT_STRING, "Root Dispersion", "ntp.rootdispersion", FT_UINT32, BASE_DEC,
&units_second_seconds, 0, "Total dispersion to the reference clock", HFILL }}, NULL, 0, "Total dispersion to the reference clock", HFILL }},
{ &hf_ntp_refid, { { &hf_ntp_refid, {
"Reference ID", "ntp.refid", FT_BYTES, BASE_NONE, "Reference ID", "ntp.refid", FT_BYTES, BASE_NONE,
NULL, 0, "Particular server or reference clock being used", HFILL }}, NULL, 0, "Particular server or reference clock being used", HFILL }},

View File

@ -2,8 +2,11 @@
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
import unittest
from suite_dfilter import dfiltertest from suite_dfilter import dfiltertest
@unittest.skip("Need to find a replacement to NTP for those tests")
class case_double(dfiltertest.DFTestCase): class case_double(dfiltertest.DFTestCase):
trace_file = "ntp.pcap" trace_file = "ntp.pcap"