subnet_address;
$subnet_mask = $row->subnet_mask;
$vlan_id = $row->vlan_id;
$subnet_info = $row->subnet_info;
}
// determine current range
$iprange = explode('.', $subnet_address);
$iprange1 = $iprange[0];
$iprange2 = $iprange[1];
$iprange3 = $iprange[2];
$iprange4 = $iprange[3];
// calculate no. of hosts
$hostcount = pow(2,(32-$subnet_mask));
// is there a need for pagination?
if ($hostcount>256) {
$maxdisplayedip = 256;
// calculate broadcast address and create pagination
if ($hostcount>65536) {
// class A subnet
echo 'Class A subnets (>65536 nodes) are not supported';
exit;
} else {
// class B subnet
$broadcast_address = $iprange1 . '.' . $iprange2 . '.' . ($hostcount/256-1) . '.255';
$pagination = 'Page: ';
}
} else {
// // class C subnet so no pagination needed, set static variables
$pagination = ' ';
$page = 0;
$maxdisplayedip = $hostcount;
$broadcast_address = $iprange1 . '.' . $iprange2 . '.' . $iprange3 . '.' . ($iprange4+$hostcount-1);
}
?>
Subnet:
';
for ($i=1;$i<=$maxdisplayedip;$i++) {
// build current ip
$ip = $iprange1 . '.' . $iprange2 . '.' . ($iprange3+$page) . '.' . ($i+$iprange4-1);
// disable subnet_address and broadcast_address
if ($ip==$subnet_address) {
echo '
';
} else if ($ip==$broadcast_address) {
echo '
';
} else {
// check for current ip address
$result = mysql_query("SELECT a.asset_name, acg.color, n.node_id FROM asset a, assetclass ac, assetclassgroup acg, node n WHERE n.ip='$ip' AND a.asset_id=n.asset_id AND ac.assetclass_id=a.assetclass_id AND acg.assetclassgroup_id=ac.assetclassgroup_id");
if (mysql_num_rows($result)==0) {
// ip not in use
echo '
';
} else {
// ip in use
while ($row = mysql_fetch_object($result)) {
$node_id = $row->node_id;
echo '