2011-12-15 22:36:53 +00:00
<? php
2012-05-16 13:25:50 +00:00
$vlans = dbFetchRows ( "SELECT * FROM `ports_vlans` AS PV, vlans AS V WHERE PV.`port_id` = '" . $port [ 'port_id' ] . "' and PV.`device_id` = '" . $device [ 'device_id' ] . "' AND V.`vlan_vlan` = PV.vlan AND V.device_id = PV.device_id" );
2011-12-15 22:36:53 +00:00
2015-07-10 13:36:21 +02:00
echo '<table border="0" cellspacing="0" cellpadding="5" width="100%">' ;
echo '<tr><th>VLAN</th><th>Description</th><th>Cost</th><th>Priority</th><th>State</th><th>Other Ports</th></tr>' ;
$row = 0 ;
foreach ( $vlans as $vlan ) {
$row ++ ;
if ( is_integer ( $row / 2 )) {
2019-06-23 00:29:12 -05:00
$row_colour = \LibreNMS\Config :: get ( 'list_colour.even' );
2016-08-18 20:28:22 -05:00
} else {
2019-06-23 00:29:12 -05:00
$row_colour = \LibreNMS\Config :: get ( 'list_colour.odd' );
2015-07-10 13:36:21 +02:00
}
echo '<tr bgcolor="' . $row_colour . '">' ;
echo '<td width=100 class=list-large> Vlan ' . $vlan [ 'vlan' ] . '</td>' ;
2018-05-10 13:56:53 -05:00
echo '<td width=200 class=box-desc>' . $vlan [ 'vlan_name' ] . '</td>' ;
2015-07-10 13:36:21 +02:00
if ( $vlan [ 'state' ] == 'blocking' ) {
$class = 'red' ;
2016-08-18 20:28:22 -05:00
} elseif ( $vlan [ 'state' ] == 'forwarding' ) {
2015-07-10 13:36:21 +02:00
$class = 'green' ;
2016-08-18 20:28:22 -05:00
} else {
2015-07-10 13:36:21 +02:00
$class = 'none' ;
}
echo '<td>' . $vlan [ 'cost' ] . '</td><td>' . $vlan [ 'priority' ] . "</td><td class= $class >" . $vlan [ 'state' ] . '</td>' ;
2016-10-11 15:29:06 -06:00
$traverse_ifvlan = true ;
2015-07-10 13:36:21 +02:00
$vlan_ports = array ();
$otherports = dbFetchRows ( 'SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id' , array ( $device [ 'device_id' ], $vlan [ 'vlan' ]));
foreach ( $otherports as $otherport ) {
2016-10-11 15:29:06 -06:00
if ( $otherport [ 'untagged' ]) {
$traverse_ifvlan = false ;
}
2018-07-13 17:08:00 -05:00
$vlan_ports [ $otherport [ 'ifIndex' ]] = $otherport ;
2015-07-10 13:36:21 +02:00
}
2016-10-11 15:29:06 -06:00
if ( $traverse_ifvlan ) {
$otherports = dbFetchRows (
'SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?' ,
array ( $device [ 'device_id' ], $vlan [ 'vlan' ])
);
foreach ( $otherports as $otherport ) {
2018-07-13 17:08:00 -05:00
$vlan_ports [ $otherport [ 'ifIndex' ]] = array_merge ( $otherport , array ( 'untagged' => '1' ));
2016-10-11 15:29:06 -06:00
}
2015-07-10 13:36:21 +02:00
}
ksort ( $vlan_ports );
echo '<td>' ;
$vsep = '' ;
foreach ( $vlan_ports as $otherport ) {
2017-04-04 08:08:23 +01:00
$otherport = cleanPort ( $otherport );
2015-07-10 13:36:21 +02:00
echo $vsep . generate_port_link ( $otherport , makeshortif ( $otherport [ 'ifDescr' ]));
if ( $otherport [ 'untagged' ]) {
echo '(U)' ;
}
$vsep = ', ' ;
}
echo '</td>' ;
echo '</tr>' ;
} //end foreach
echo '</table>' ;