From b7b8da0848c3aad4a197c91f943ecf797d52214a Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Thu, 18 Aug 2011 12:05:30 +0000 Subject: [PATCH] Fixed the computation of IPs in a subnet that failed (returned negative numbers) on some versions of PHP compiled in 32-bit. SVN:trunk[1469] --- modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php b/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php index 20d7ef4d9b..19cb7ae3a5 100644 --- a/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php +++ b/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php @@ -451,9 +451,9 @@ class Subnet extends cmdbAbstractObject $bit_ip = ip2long($this->Get('ip')); $bit_mask = ip2long($this->Get('ip_mask')); - $iIPMin = ($bit_ip & $bit_mask) + 1; // exclude the first one: identifies the subnet itsel - $iIPMax = ($bit_ip | (~$bit_mask)) - 1; // exclude the last one : reserved for DHCP - + $iIPMin = sprintf('%u', ($bit_ip & $bit_mask) | 1); // exclude the first one: identifies the subnet itself + $iIPMax = sprintf('%u', (($bit_ip | (~$bit_mask))) & 0xfffffffe); // exclude the last one : broadcast address + $sIPMin = long2ip($iIPMin); $sIPMax = long2ip($iIPMax); @@ -465,7 +465,7 @@ class Subnet extends cmdbAbstractObject $oBlock->Display($oPage, 'nwif', array('menu' => false)); $iCountUsed = $oIfSet->Count(); - $iCountRange = $iIPMax - $iIPMin; + $iCountRange = $iIPMax - $iIPMin; // On 32-bit systems the substraction will be computed using floats for values greater than PHP_MAX_INT; $iFreeCount = $iCountRange - $iCountUsed; $oPage->SetCurrentTab(Dict::S('Class:Subnet/Tab:FreeIPs'));