Use Number::constrainInteger instead of unsignedToSigned in Cisco NTP poller (#15667)

* switch to constrainInteger for cisco ntp too
* correct styleci issue
This commit is contained in:
RobJE
2023-12-21 19:15:02 +01:00
committed by GitHub
parent 6bea8cffa6
commit 4469df10f4

View File

@@ -11,6 +11,7 @@
* the source code distribution for details.
*/
use LibreNMS\Enum\IntegerType;
use LibreNMS\RRD\RrdDefinition;
use LibreNMS\Util\Number;
@@ -63,10 +64,10 @@ if (is_array($components) && count($components) > 0) {
// the last 16 bits.
$hexoffset = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][23][$array['UID']];
$rrd['offset'] = Number::unsignedAsSigned(hexdec(substr($hexoffset, 0, 5)), 16) + hexdec(substr($hexoffset, -5)) / 65536;
$rrd['offset'] = Number::constrainInteger(hexdec(substr($hexoffset, 0, 5)), IntegerType::int16) + hexdec(substr($hexoffset, -5)) / 65536;
$hexdelay = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][24][$array['UID']];
$rrd['delay'] = Number::unsignedAsSigned(hexdec(substr($hexdelay, 0, 5)), 16) + hexdec(substr($hexdelay, -5)) / 65536;
$rrd['delay'] = Number::constrainInteger(hexdec(substr($hexdelay, 0, 5)), IntegerType::int16) + hexdec(substr($hexdelay, -5)) / 65536;
// Cisco NTPUnsignedTimeValue - 16 bits of unsignedint, and 16 bits of unsignedint for fractional
$hexdisp = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][25][$array['UID']];