PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Networking » Net_IPv4 » Bug #7092

calculate function not working correctly

Details

Submitted2006-03-10 19:06 UTC
Frombrandon at homeisp dot com
Assignedfa
StatusWont fix
PackageNet_IPv4
PHP Version4.3.11
OSWindows
Roadmaps(Not assigned)

Comments

[2006-03-10 19:06 UTC] brandon at homeisp dot com

Description:
------------
When calculating multiple broadcast and network address, the subnet does not change. I have also had quite a few other problems with calculate not giving the correct answers... but for now I will assume it is all related.

thanks

Test script:
---------------
$ip_calc->ip = "1.1.1.60";
$ip_calc->netmask = "255.255.255.192";
$error = $ip_calc->calculate();
//echo "$error";
if(!is_object($error))
{
echo "<br>IP: $ip_calc->ip & Sub: $ip_calc->netmask & network: $ip_calc->network & broadcast: $ip_calc->broadcast<br>";
}

$ip_calc->ip = "1.1.1.250";
$ip_calc->netmask = "255.255.255.252";
$error = $ip_calc->calculate();
//echo "$error";
if(!is_object($error))
{
echo "<br>IP: $ip_calc->ip & Sub: $ip_calc->netmask & network: $ip_calc->network & broadcast: $ip_calc->broadcast<br>";
}

$ip_calc->ip = "1.1.1.80";
$ip_calc->netmask = "255.255.255.32";
$error = $ip_calc->calculate();
//echo "$error";
if(!is_object($error))
{
echo "<br>IP: $ip_calc->ip & Sub: $ip_calc->netmask & network: $ip_calc->network & broadcast: $ip_calc->broadcast<br>";
}

Expected result:
----------------
IP: 1.1.1.60 & Sub: 255.255.255.192 & network: 1.1.1.0 & broadcast: 1.1.1.63

IP: 1.1.1.250 & Sub: 255.255.255.252 & network: 1.1.1.248 & broadcast: 1.1.1.251

IP: 1.1.1.80 & Sub: 255.255.255.32 & network: NOT 1.1.1.64 & broadcast: NOT 1.1.1.127

Actual result:
--------------
IP: 1.1.1.60 & Sub: 255.255.255.192 & network: 1.1.1.0 & broadcast: 1.1.1.63

IP: 1.1.1.250 & Sub: 255.255.255.192 & network: 1.1.1.192 & broadcast: 1.1.1.255

IP: 1.1.1.80 & Sub: 255.255.255.192 & network: 1.1.1.64 & broadcast: 1.1.1.127