0.3.14
This commit is contained in:
parent
87bd7947d4
commit
1ba1d850d8
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// $pathArray contains all necessary path data
|
// pathArray contains all necessary path data
|
||||||
$pathArray = array();
|
$pathArray = array();
|
||||||
|
|
||||||
if($connectorCode39) {
|
if($connectorCode39) {
|
||||||
@ -20,46 +20,59 @@ $selectedObjPort2 = $objPort;
|
|||||||
|
|
||||||
// Retrieve initial connection set
|
// Retrieve initial connection set
|
||||||
$connSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2);
|
$connSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2);
|
||||||
detectDivergence($connSet);
|
detectDivergence($connSet[0]);
|
||||||
|
detectDivergence($connSet[1]);
|
||||||
array_push($pathArray, $connSet);
|
array_push($pathArray, $connSet);
|
||||||
|
|
||||||
for($direction=0; $direction<2; $direction++) {
|
for($direction=0; $direction<2; $direction++) {
|
||||||
|
|
||||||
// Set path array pointer
|
$trunkFound = true;
|
||||||
// 0 for up, -1 for down
|
while($trunkFound){
|
||||||
$pathArrayPointer = ($direction == 0) ? 0 : -1;
|
|
||||||
|
|
||||||
while(count($pathArray[$pathArrayPointer][$direction])){
|
// Set path array pointer
|
||||||
|
// 0 for up, -1 for down
|
||||||
|
$pathArrayPointer = ($direction == 0) ? 0 : count($pathArray)-1;
|
||||||
|
|
||||||
// Get port trunk peer
|
// Get port trunk peer
|
||||||
error_log('Debug (crawlTrunkData): '.json_encode($pathArray[$pathArrayPointer][$direction]));
|
$trunkSet = crawlTrunk($qls, $pathArray[$pathArrayPointer][$direction]);
|
||||||
//$trunkSet = crawlTrunk($qls, $pathArray[$pathArrayPointer][$direction]);
|
|
||||||
$trunkSet = array();
|
|
||||||
detectDivergence($trunkSet);
|
detectDivergence($trunkSet);
|
||||||
|
$trunkFound = (count($trunkSet)) ? true : false;
|
||||||
|
|
||||||
|
// Find connections for each trunked port
|
||||||
|
$workingConnSet = array(array(),array());
|
||||||
foreach($trunkSet as $port) {
|
foreach($trunkSet as $port) {
|
||||||
|
|
||||||
$selectedObjID2 = $port['objID'];
|
// Store port info
|
||||||
$selectedObjFace2 = $port['objFace'];
|
$selectedObjID2 = $port['objID'];
|
||||||
$selectedObjDepth2 = $port['objDepth'];
|
$selectedObjFace2 = $port['objFace'];
|
||||||
$selectedObjPort2 = $port['objDepth'];
|
$selectedObjDepth2 = $port['objDepth'];
|
||||||
|
$selectedObjPort2 = $port['objPort'];
|
||||||
|
|
||||||
$workingConnSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2);
|
// Find connections
|
||||||
detectDivergence($workingConnSet);
|
$connSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2);
|
||||||
|
detectDivergence($connSet[0]);
|
||||||
|
detectDivergence($connSet[1]);
|
||||||
|
|
||||||
if($direction == 0) {
|
// Add ports to workingConnSet
|
||||||
array_unshift($pathArray, $workingConnSet);
|
foreach($connSet[0] as $port) {
|
||||||
} else {
|
array_push($workingConnSet[0], $port);
|
||||||
array_push($pathArray, $workingConnSet);
|
}
|
||||||
}
|
foreach($connSet[1] as $port) {
|
||||||
|
array_push($workingConnSet[1], $port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add connection set to appropriate end of pathArray
|
||||||
|
if($trunkFound) {
|
||||||
|
if($direction == 0) {
|
||||||
|
array_unshift($pathArray, $workingConnSet);
|
||||||
|
} else {
|
||||||
|
array_push($pathArray, $workingConnSet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
error_log('Debug (pathArray): '.json_encode($pathArray));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error_log('Debug (pathArray): '.json_encode($pathArray));
|
|
||||||
error_log('Debug (trunkSet): '.json_encode($trunkSet));
|
|
||||||
|
|
||||||
function crawlTrunk(&$qls, $portSet) {
|
function crawlTrunk(&$qls, $portSet) {
|
||||||
|
|
||||||
$trunkSet = array();
|
$trunkSet = array();
|
||||||
@ -154,34 +167,31 @@ function detectDivergence(&$dataSet) {
|
|||||||
$pathDiverges = false;
|
$pathDiverges = false;
|
||||||
|
|
||||||
// Detect path divergence
|
// Detect path divergence
|
||||||
foreach($dataSet as &$data) {
|
foreach($dataSet as $portIndex => $port) {
|
||||||
foreach($data as $portIndex => $port) {
|
|
||||||
|
|
||||||
// Identify parent object ID
|
// Identify parent object ID
|
||||||
$portObjID = $port['objID'];
|
$portObjID = $port['objID'];
|
||||||
$portObj = $qls->App->objectArray[$portObjID];
|
$portObj = $qls->App->objectArray[$portObjID];
|
||||||
|
$portObjParentID = $portObj['parent_id'];
|
||||||
|
while($portObjParentID != 0) {
|
||||||
|
$portObj = $qls->App->objectArray[$portObjParentID];
|
||||||
$portObjParentID = $portObj['parent_id'];
|
$portObjParentID = $portObj['parent_id'];
|
||||||
while($portObjParentID != 0) {
|
}
|
||||||
$portObj = $qls->App->objectArray[$portObjParentID];
|
|
||||||
$portObjParentID = $portObj['parent_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine path divergence
|
// Determine path divergence
|
||||||
if($portIndex == 0) {
|
if($portIndex == 0) {
|
||||||
$baselineParentID = $portObjParentID;
|
$baselineParentID = $portObjParentID;
|
||||||
} else {
|
} else {
|
||||||
if($portObjParentID != $baselineParentID) {
|
if($portObjParentID != $baselineParentID) {
|
||||||
|
|
||||||
// Flag this path as divergent
|
// Flag this path as divergent
|
||||||
$pathDiverges = true;
|
$pathDiverges = true;
|
||||||
|
|
||||||
// Remove divergent connection
|
// Remove divergent connection
|
||||||
unset($data[$portIndex]);
|
unset($dataSet[$portIndex]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($data);
|
|
||||||
|
|
||||||
return $pathDiverges;
|
return $pathDiverges;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user