0 Replies Latest reply on Feb 26, 2014 9:41 AM by bozhinov

    API bug in IP address listing

    bozhinov

      Hello,

       

      I have a query that gets the list of detections

      Problem is that the IP address is listed as LONG

      using PHP long2ip function brings out wrong result

       

      here is how I fixed it:

       

      function McAfee_long2ip($long) {

                  // Valid range: 0.0.0.0 -> 255.255.255.255

                 if ($long < 0 || $long > 4294967295) return false;

                  $ip = "";

       

                 for ($i=3;$i>=0;$i--) {

                   if ($i == 3){

                            $ip .= (int)($long / pow(256,$i)) + 128; # <--- FIX HERE + 128

                            $long -= (int)($long / pow(256,$i))*pow(256,$i);

                  } else {

                       $ip .= (int)($long / pow(256,$i));

                       $long -= (int)($long / pow(256,$i))*pow(256,$i);

                  }

       

                   if ($i>0) $ip .= ".";

                 }

         return $ip;

      }

       

      Message was edited by: bozhinov on 2/26/14 9:41:56 AM CST