r2751 - listCells(): initialise additional fields in 'ipv4net' like getIPv4NetworkIn...
authorDenis Ovsienko <infrastation@yandex.ru>
Thu, 14 May 2009 22:13:39 +0000 (22:13 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Thu, 14 May 2009 22:13:39 +0000 (22:13 +0000)
 - spotEntity(): ditto
 - getFileLinks(): switch from getIPv4NetworkInfo() to spotEntity()
 - renderRackObject(): ditto
 - renderIPv4ForObject(): ditto
 - renderIPv4Space(): ditto
 - renderIPv4SpaceEditor(): ditto
 - renderIPv4NetworkProperties(): ditto
 - renderSearchResults(): ditto
 - renderLivePTR(): ditto
 - dynamic_title_decoder(): ditto
 - renderIPv4Network(): ditto, and also save on spotEntity() calls

inc/database.php
inc/interface.php

index 8745fdb7a6bb8180e74230e2b38f5c6d03dcbb43..53e31503719250494c7f01f348050ca9e39e8616 100644 (file)
@@ -325,6 +325,13 @@ function listCells ($realm, $parent_id = 0)
                case 'object':
                        $ret[$entity_id]['dname'] = displayedName ($ret[$entity_id]);
                        break;
+               case 'ipv4net':
+                       $ret[$entity_id]['ip_bin'] = ip2long ($ret[$entity_id]['ip']);
+                       $ret[$entity_id]['mask_bin'] = binMaskFromDec ($ret[$entity_id]['mask']);
+                       $ret[$entity_id]['mask_bin_inv'] = binInvMaskFromDec ($ret[$entity_id]['mask']);
+                       $ret[$entity_id]['db_first'] = sprintf ('%u', 0x00000000 + $ret[$entity_id]['ip_bin'] & $ret[$entity_id]['mask_bin']);
+                       $ret[$entity_id]['db_last'] = sprintf ('%u', 0x00000000 + $ret[$entity_id]['ip_bin'] | ($ret[$entity_id]['mask_bin_inv']));
+                       break;
                default:
                        break;
                }
@@ -385,6 +392,13 @@ function spotEntity ($realm, $id)
        case 'object':
                $ret['dname'] = displayedName ($ret);
                break;
+       case 'ipv4net':
+               $ret['ip_bin'] = ip2long ($ret['ip']);
+               $ret['mask_bin'] = binMaskFromDec ($ret['mask']);
+               $ret['mask_bin_inv'] = binInvMaskFromDec ($ret['mask']);
+               $ret['db_first'] = sprintf ('%u', 0x00000000 + $ret['ip_bin'] & $ret['mask_bin']);
+               $ret['db_last'] = sprintf ('%u', 0x00000000 + $ret['ip_bin'] | ($ret['mask_bin_inv']));
+               break;
        default:
                break;
        }
@@ -3431,7 +3445,7 @@ function getFileLinks ($file_id = 0)
                        case 'ipv4net':
                                $page = 'ipv4net';
                                $id_name = 'id';
-                               $parent = getIPv4NetworkInfo($row['entity_id']);
+                               $parent = spotEntity ($row['entity_type'], $row['entity_id']);
                                $name = sprintf("%s (%s/%s)", $parent['name'], $parent['ip'], $parent['mask']);
                                break;
                        case 'ipv4rspool':
index 0445b92e62783f07a7849b608b68c6ff2901b75b..668b08694ebfe910f37ac3b4ad3ca240900cee30 100644 (file)
@@ -976,7 +976,7 @@ function renderRackObject ($object_id)
                        $netid = getIPv4AddressNetworkId ($dottedquad);
                        if (NULL !== $netid)
                        {
-                               $netinfo = getIPv4NetworkInfo ($netid);
+                               $netinfo = spotEntity ('ipv4net', $netid);
                                loadIPv4AddrList ($netinfo);
                        }
                        echo "<tr class='${class}' valign=top><td class=tdleft>${alloc['osif']}</td><td class='${secondclass}'>";
@@ -1298,7 +1298,7 @@ function renderIPv4ForObject ($object_id)
                $netid = getIPv4AddressNetworkId ($dottedquad);
                if (NULL !== $netid)
                {
-                       $netinfo = getIPv4NetworkInfo ($netid);
+                       $netinfo = spotEntity ('ipv4net', $netid);
                        loadIPv4AddrList ($netinfo);
                }
                printOpFormIntro ('updIPv4Allocation', array ('ip' => $dottedquad));
@@ -2060,7 +2060,7 @@ function renderIPv4Space ()
                        $cellfilter['urlextra'] . "'>auto-collapse</a>)";
        else
        {
-               $netinfo = getIPv4NetworkInfo ($eid);
+               $netinfo = spotEntity ('ipv4net', $eid);
                echo "expanding ${netinfo['ip']}/${netinfo['mask']} (<a href='".makeHref(array('page'=>$pageno, 'tab'=>$tabno))."'>auto-collapse</a> / <a href='".makeHref(array('page'=>$pageno, 'tab'=>$tabno, 'eid'=>'ALL'))."'>expand&nbsp;all</a>)"; 
        }
        echo "</h4><table class='widetable' border=0 cellpadding=5 cellspacing=0 align='center'>\n";
@@ -2197,7 +2197,7 @@ function renderIPv4SpaceEditor ()
                        }
                        else // only render clickable image for empty networks
                        {
-                               $netdata = getIPv4NetworkInfo ($netinfo['id']);
+                               $netdata = spotEntity ('ipv4net', $netinfo['id']);
                                loadIPv4AddrList ($netdata);
                                if (count ($netdata['addrlist']))
                                        printImageHREF ('nodestroy', 'There are ' . count ($netdata['addrlist']) . ' allocations inside');
@@ -2299,7 +2299,7 @@ function renderIPv4Network ($id)
        else
                $page=0;
 
-       $range = getIPv4NetworkInfo ($id);
+       $range = spotEntity ('ipv4net', $id);
        loadIPv4AddrList ($range);
        echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>";
        echo "<tr><td colspan=2 align=center><h1>${range['ip']}/${range['mask']}</h1><h2>${range['name']}</h2></td></tr>\n";
@@ -2321,14 +2321,13 @@ function renderIPv4Network ($id)
                $backtrace = array();
                while (NULL !== ($upperid = getIPv4AddressNetworkId ($range['ip'], $clen)))
                {
-                       $upperinfo = getIPv4NetworkInfo ($upperid);
+                       $upperinfo = spotEntity ('ipv4net', $upperid);
                        $clen = $upperinfo['mask'];
-                       $backtrace[] = $upperid;
+                       $backtrace[] = $upperinfo;
                }
                $arrows = count ($backtrace);
-               foreach (array_reverse ($backtrace) as $ancestorid)
+               foreach (array_reverse ($backtrace) as $ainfo)
                {
-                       $ainfo = getIPv4NetworkInfo ($ancestorid);
                        echo "<tr><th width='50%' class=tdright>";
                        for ($i = 0; $i < $arrows; $i++)
                                echo '&uarr;';
@@ -2470,7 +2469,7 @@ function renderIPv4Network ($id)
 
 function renderIPv4NetworkProperties ($id)
 {
-       $netdata = getIPv4NetworkInfo ($id);
+       $netdata = spotEntity ('ipv4net', $id);
        echo "<center><h1>${netdata['ip']}/${netdata['mask']}</h1></center>\n";
        echo "<table border=0 cellpadding=10 cellpadding=1 align='center'>\n";
        printOpFormIntro ('editRange');
@@ -2909,7 +2908,7 @@ function renderSearchResults ()
                {
                        $nhits++;
                        $lasthit = 'ipv4network';
-                       $summary['ipv4network'][] = getIPv4NetworkInfo ($tmp);
+                       $summary['ipv4network'][] = spotEntity ('ipv4net', $tmp);
                }
        }
        else
@@ -4536,7 +4535,7 @@ function renderLivePTR ($id)
                $page=0;
        global $pageno, $tabno;
        $maxperpage = getConfigVar ('IPV4_ADDRS_PER_PAGE');
-       $range = getIPv4NetworkInfo ($id);
+       $range = spotEntity ('ipv4net', $id);
        loadIPv4AddrList ($range);
        echo "<center><h1>${range['ip']}/${range['mask']}</h1><h2>${range['name']}</h2></center>\n";
 
@@ -5285,7 +5284,7 @@ function renderFile ($file_id)
                                                renderCell ($userinfo);
                                        break;
                                case 'ipv4net':
-                                       renderIPv4NetCell (getIPv4NetworkInfo ($link['entity_id']));
+                                       renderIPv4NetCell (spotEntity ($link['entity_type'], $link['entity_id']));
                                        break;
                                default:
                                        echo formatEntityName ($link['entity_type']) . ': ';
@@ -5983,7 +5982,7 @@ function dynamic_title_decoder ($path_position)
                {
                case 'ipv4net':
                        assertUIntArg ('id', __FUNCTION__);
-                       $range = getIPv4NetworkInfo ($_REQUEST['id']);
+                       $range = spotEntity ('ipv4net', $_REQUEST['id']);
                        return array
                        (
                                'name' => $range['ip'] . '/' . $range['mask'],
@@ -5991,7 +5990,7 @@ function dynamic_title_decoder ($path_position)
                        );
                case 'ipaddress':
                        assertIPv4Arg ('ip', __FUNCTION__);
-                       $range = getIPv4NetworkInfo (getIPv4AddressNetworkId ($_REQUEST['ip']));
+                       $range = spotEntity ('ipv4net', getIPv4AddressNetworkId ($_REQUEST['ip']));
                        return array
                        (
                                'name' => $range['ip'] . '/' . $range['mask'],