This commit is contained in:
Garrett K 2021-02-26 04:14:21 +00:00
parent 8c66c08f64
commit 692c850d59

View File

@ -1,6 +1,7 @@
<?php <?php
$path2 = array(); // $pathArray contains all necessary path data
$pathArray = array();
if($connectorCode39) { if($connectorCode39) {
$connectorID2 = base_convert($connectorCode39, 36, 10); $connectorID2 = base_convert($connectorCode39, 36, 10);
@ -17,81 +18,89 @@ $selectedObjFace2 = $objFace;
$selectedObjDepth2 = $objDepth; $selectedObjDepth2 = $objDepth;
$selectedObjPort2 = $objPort; $selectedObjPort2 = $objPort;
// Retrieve initial connection set
$connSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2); $connSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2);
detectDivergence($connSet); detectDivergence($connSet);
array_push($pathArray, $connSet);
while(count($connSet[0]) or count($connSet[1])){ for($direction=0; $direction<2; $direction++) {
$trunkSet = crawlTrunk($qls, $connSet); // Set path array pointer
detectDivergence($trunkSet); // 0 for up, -1 for down
$pathArrayPointer = ($direction == 0) ? 0 : -1;
foreach($trunkSet as $trunk) { while(count($pathArray[$pathArrayPointer][$direction])){
foreach($trunk as $port) {
$selectedObjID2 = $port['objID']; // Get port trunk peer
$selectedObjFace2 = $port['objFace']; error_log('Debug (crawlTrunkData): '.json_encode($pathArray[$pathArrayPointer][$direction]));
$selectedObjDepth2 = $port['objDepth']; //$trunkSet = crawlTrunk($qls, $pathArray[$pathArrayPointer][$direction]);
$selectedObjPort2 = $port['objDepth']; $trunkSet = array();
detectDivergence($trunkSet);
$workingConnSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2); foreach($trunkSet as $port) {
detectDivergence($workingConnSet);
foreach($workingConnSet as $workingConn) { $selectedObjID2 = $port['objID'];
$selectedObjFace2 = $port['objFace'];
$selectedObjDepth2 = $port['objDepth'];
$selectedObjPort2 = $port['objDepth'];
} $workingConnSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2);
detectDivergence($workingConnSet);
if($direction == 0) {
array_unshift($pathArray, $workingConnSet);
} else {
array_push($pathArray, $workingConnSet);
}
} }
} }
} }
error_log('Debug (connSet): '.json_encode($connSet)); error_log('Debug (pathArray): '.json_encode($pathArray));
error_log('Debug (trunkSet): '.json_encode($trunkSet)); error_log('Debug (trunkSet): '.json_encode($trunkSet));
function crawlTrunk(&$qls, $connSet) { function crawlTrunk(&$qls, $portSet) {
$trunkSet = array(array(),array()); $trunkSet = array();
// Loop over each side of $connSet // Loop over each port of $conn
foreach($connSet as $connSetID => $conn) { foreach($portSet as $portSetID => $port) {
// Loop over each port of $conn // Gather port data
foreach($conn as $connID => $port) { $objID = $port['objID'];
$objFace = $port['objFace'];
$objDepth = $port['objDepth'];
$objPort = $port['objPort'];
// Gather port data // Gather trunk peer data
$objID = $port['objID']; if(isset($qls->App->peerArray[$objID][$objFace][$objDepth])) {
$objFace = $port['objFace'];
$objDepth = $port['objDepth']; // Gather trunk peer object
$objPort = $port['objPort']; $peer = $qls->App->peerArray[$objID][$objFace][$objDepth];
// Gather trunk peer data // Gather trunk peer data
if(isset($qls->App->peerArray[$objID][$objFace][$objDepth])) { $peerObjID = $peer['peerID'];
$peerObjFace = $peer['peerFace'];
$peerObjDepth = $peer['peerDepth'];
$peerObjPort = $objPort;
// Gather trunk peer object // Create a working array for cleanliness
$peer = $qls->App->peerArray[$objID][$objFace][$objDepth]; $workingArray = array(
'objID' => $peerObjID,
'objFace' => $peerObjFace,
'objDepth' => $peerObjDepth,
'objPort' => $peerObjPort
);
// Gather trunk peer data // Store trunk data
$peerObjID = $peer['peerID']; $trunkSet[$portSetID] = $workingArray;
$peerObjFace = $peer['peerFace'];
$peerObjDepth = $peer['peerDepth'];
$peerObjPort = $objPort;
// Create a working array for cleanliness
$workingArray = array(
'objID' => $peerObjID,
'objFace' => $peerObjFace,
'objDepth' => $peerObjDepth,
'objPort' => $peerObjPort
);
// Store trunk data
$trunkSet[$connSetID][$connID] = $workingArray;
}
} }
} }
return $trunkSet; return $trunkSet;
} }
function crawlConn(&$qls, $objID, $objFace, $objDepth, $objPort, $connSetID=0, &$connSet=array(array(),array())) { function crawlConn(&$qls, $objID, $objFace, $objDepth, $objPort, &$connSet=array(array(),array()), $connSetID=0) {
// Store port details // Store port details
$workingArray = array( $workingArray = array(
@ -131,7 +140,7 @@ function crawlConn(&$qls, $objID, $objFace, $objDepth, $objPort, $connSetID=0, &
} }
if(!$alreadySeen) { if(!$alreadySeen) {
crawlConn($qls, $remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $connSetID, $connSet); crawlConn($qls, $remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $connSet, $connSetID);
} }
} }
} }