diff --git a/scapy/layers/ntp.py b/scapy/layers/ntp.py index 9b0d4e4ae6b..57d155e9af9 100644 --- a/scapy/layers/ntp.py +++ b/scapy/layers/ntp.py @@ -448,8 +448,8 @@ class NTPHeader(NTP): BitField("version", 4, 3), BitEnumField("mode", 3, 3, _ntp_modes), BitField("stratum", 2, 8), - BitField("poll", 0xa, 8), - BitField("precision", 0, 8), + SignedByteField("poll", 0xa), + SignedByteField("precision", 0), FixedPointField("delay", 0, size=32, frac_bits=16), FixedPointField("dispersion", 0, size=32, frac_bits=16), ConditionalField(IPField("id", "127.0.0.1"), lambda p: p.stratum > 1), @@ -1120,7 +1120,7 @@ class NTPInfoSys(Packet): ByteField("peer_mode", 0), ByteField("leap", 0), ByteField("stratum", 0), - ByteField("precision", 0), + SignedByteField("precision", 0), FixedPointField("rootdelay", 0, size=32, frac_bits=16), FixedPointField("rootdispersion", 0, size=32, frac_bits=16), IPField("refid", 0), diff --git a/test/scapy/layers/ntp.uts b/test/scapy/layers/ntp.uts index eddac823816..6ae79063f11 100644 --- a/test/scapy/layers/ntp.uts +++ b/test/scapy/layers/ntp.uts @@ -582,7 +582,7 @@ assert p.data[0].peer == "127.127.1.0" assert p.data[0].peer_mode == 3 assert p.data[0].leap == 0 assert p.data[0].stratum == 11 -assert p.data[0].precision == 240 +assert p.data[0].precision == -16 assert p.data[0].refid == "127.127.1.0" @@ -1113,7 +1113,7 @@ assert p.data[0].ifname.startswith(b"lo") from decimal import Decimal -precision = b"\xec" # 236 +precision = b"\xec" # -20 dispersion = b"\x00\x00\xf2\xce" # 0.948455810546875 time_stamp = b"\xe6}gt\x00\x00\x00\x00" # Sat, 16 Jul 2022 16:36:04 +0000 @@ -1142,7 +1142,7 @@ assert pkt_1.recv.val == time_stamp, pkt_1.recv.val time_stamp_hex = 0x00000000e67d6774 pkt_2 = NTP( - precision=236, + precision=-20, dispersion=Decimal('0.948455810546875'), orig=time_stamp_hex, sent=time_stamp_hex,