Convert SNMP Hex to IP Address String

Started by bdallen83, September 27, 2022, 07:14:44 AM

Previous topic - Next topic

bdallen83

Hi all,


I cant seem to work out how to do a transformation script to convert hex string as exampe AC140016 to an IP Address string of 172.20.0.22.

Any help would be appreciated.

Thanks in advance

Victor Kirhenshtein

Hi,

something like this:
result = "";
for(i = 0; i < 8; i += 2)
{
  if (result->length > 0)
      result .= ".";
  result .= x2d($1[i : i + 2]);
}
return result;

This script assumes that 8 hex digits passed as input.

Best regards,
Victor