Deprecate Val(double, TypeTag) ctor, add TimeVal/DoubleVal subclasses

This also updates all usages of the deprecated Val ctor to use
either IntervalVal, TimeVal, or DoubleVal ctors.  The reason for
doing away with the old constructor is that using it with TYPE_INTERVAL
isn't strictly correct since there exists a more specific subclass,
IntervalVal, with overriden ValDescribe() method that ought to be used
to print such values in a more descriptive way.
This commit is contained in:
Jon Siwek 2020-06-02 18:19:40 -07:00
parent a431f6b45d
commit 5b4313b593
76 changed files with 847 additions and 782 deletions

View file

@ -4,8 +4,20 @@
@load base/protocols/ntp
global msg_count = 0;
event ntp_message(c: connection, is_orig: bool, msg: NTP::Message)
{
++msg_count;
if ( msg_count == 9 || msg_count == 10 )
{
# Hack around some unstable floating point output on 32-bit
local d = interval_to_double(msg$std_msg$root_disp);
local s = cat(d)[0:-1];
msg$std_msg$root_disp = double_to_interval(to_double(s));
}
print fmt("ntp_message %s -> %s:%d %s", c$id$orig_h, c$id$resp_h, c$id$resp_p, msg);
}

View file

@ -4,8 +4,24 @@
@load base/protocols/ntp
global msg_count = 0;
event ntp_message(c: connection, is_orig: bool, msg: NTP::Message)
{
++msg_count;
if ( msg_count == 20 || msg_count == 23 )
{
# Hack around some unstable floating point output on 32-bit
local d = interval_to_double(msg$std_msg$root_disp);
local s = cat(d)[0:-1];
msg$std_msg$root_disp = double_to_interval(to_double(s));
d = interval_to_double(msg$std_msg$root_delay);
s = cat(d)[0:-1];
msg$std_msg$root_delay = double_to_interval(to_double(s));
}
print fmt("ntp_message %s -> %s:%d %s", c$id$orig_h, c$id$resp_h, c$id$resp_p, msg);
}