NetXMS Support Forum

English Support => General Support => Topic started by: bdallen83 on September 27, 2022, 07:14:44 AM

Title: Convert SNMP Hex to IP Address String
Post by: bdallen83 on September 27, 2022, 07:14:44 AM
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
Title: Re: Convert SNMP Hex to IP Address String
Post by: Victor Kirhenshtein on September 27, 2022, 12:37:45 PM
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