add basic STP/RSTP support

This commit is contained in:
vitalisator
2016-01-03 21:10:35 +01:00
parent f031467fdc
commit d12c7803e0
7 changed files with 361 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
<?php
$stp_raw = dbFetchRow('SELECT * FROM `stp` WHERE `device_id` = ?', array($device['device_id']));
$stp = array (
'Root bridge' => ($stp_raw['rootBridge'] == 1) ? 'Yes' : 'No',
'Bridge address (MAC)' => $stp_raw['bridgeAddress'],
'Protocol specification' => $stp_raw['protocolSpecification'],
'Priority (0-61440)' => $stp_raw['priority'],
'Time since topology change' => formatUptime($stp_raw['timeSinceTopologyChange']),
'Topology changes' => $stp_raw['topChanges'],
'Designated root (MAC)' => $stp_raw['designatedRoot'],
'Root cost' => $stp_raw['rootCost'],
'Root port' => $stp_raw['rootPort'],
'Max age (s)' => $stp_raw['maxAge'],
'Hello time (s)' => $stp_raw['helloTime'],
'Hold time (s)' => $stp_raw['holdTime'],
'Forward delay (s)' => $stp_raw['forwardDelay'],
'Bridge max age (s)' => $stp_raw['bridgeMaxAge'],
'Bridge hello time (s)' => $stp_raw['bridgeHelloTime'],
'Bridge forward delay (s)' => $stp_raw['bridgeForwardDelay']
);
foreach (array_keys($stp) as $key) {
echo "
<tr>
<td width=280 class=list-large>$key</td>
<td class=box-desc>$stp[$key]</td>
</tr>
";
}
+8
View File
@@ -229,6 +229,14 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) {
</a>
</li>');
if (@dbFetchCell("SELECT COUNT(stp_id) FROM stp WHERE device_id = '".$device['device_id']."'") > '0') {
echo '<li class="'.$select['stp'].'">
<a href="'.generate_device_url($device, array('tab' => 'stp')).'">
<img src="images/16/chart_organisation.png" align="absmiddle" border="0" /> STP
</a>
</li>';
}
if (@dbFetchCell("SELECT COUNT(*) FROM `packages` WHERE device_id = '".$device['device_id']."'") > '0') {
echo '<li class="'.$select['packages'].'">
<a href="'.generate_device_url($device, array('tab' => 'packages')).'">
+50
View File
@@ -0,0 +1,50 @@
<?php
$link_array = array(
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'stp',
);
print_optionbar_start();
echo "<span style='font-weight: bold;'>STP</span> &#187; ";
if (!$vars['view']) {
$vars['view'] = 'basic';
}
$menu_options['basic'] = 'Basic';
// $menu_options['details'] = 'Details';
$sep = '';
foreach ($menu_options as $option => $text) {
echo $sep;
if ($vars['view'] == $option) {
echo "<span class='pagemenu-selected'>";
}
echo generate_link($text, $link_array, array('view' => $option));
if ($vars['view'] == $option) {
echo '</span>';
}
$sep = ' | ';
}
unset($sep);
print_optionbar_end();
echo '<table border="0" cellspacing="0" cellpadding="5" width="100%">';
$i = '1';
foreach (dbFetchRows("SELECT * FROM `stp` WHERE `device_id` = ? ORDER BY 'stp_id'", array($device['device_id'])) as $stp) {
include 'includes/print-stp.inc.php';
$i++;
}
echo '</table>';
$pagetitle[] = 'STP';