Sentinel: IP address is converted to a negative number

  • 3544368
  • 17-Jan-2007
  • 26-Apr-2012

Environment

Sentinel
Microsoft Windows Server 2003 Standard Edition
Microsoft Windows 2000 Server
RedHat Linux
Solaris 9

Situation

In some cases, the IP address is converted to the decimal number just fine, but in other cases, a negative number for a valid IP address. Here's some examples:

AGENT CODE:
IPTONUM(s_DIP, i_value, i_valid)
PRINTF(s_CV1, "%d", i_value)

s_SIP = "10.0.0.5"
RETURNS a value of 167772165 for i_value (copied into s_CV1 just fine)

s_SIP = "192.168.0.9"
RETURNS a value of -1062731767 for i_value

s_SIP = "192.168.0.8"
RETURNS a value of -1062731768 for i_value

All i_valid values are 1 (meaning it's a valid IP addres).

Resolution

The scripting language only supports 32 bit signed integers. An ip address of 128.0.0.0 or greater will convert to a negative number because the sign bit is set. This view is correct. To recalculate, take the negative number and feed it into numtoip it will return back the correct ip address.