Explorar el Código

patch detect vlan pvid at port for tp-link devices

rajven hace 3 años
padre
commit
54ae8ad21b
Se han modificado 3 ficheros con 10 adiciones y 6 borrados
  1. 2 2
      html/admin/devices/switchstatus.php
  2. 3 3
      html/inc/common.php
  3. 5 1
      html/inc/consts.php

+ 2 - 2
html/admin/devices/switchstatus.php

@@ -156,7 +156,7 @@ if ($device['snmp_version']>0) {
         $ifname= $row['ifName'];
 
         if ($snmp_ok) {
-            $vlan = get_port_vlan($row['port'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version'], $device['fdb_snmp_index']);
+            $vlan = get_port_vlan($device['vendor_id'], $row['port'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version'], $device['fdb_snmp_index']);
             $ifname = get_snmp_ifname1($device['ip'], $device['community'], $device['snmp_version'], $row['snmp_index']);
             if (empty($ifname)) { $ifname = get_snmp_ifname2($device['ip'], $device['community'], $device['snmp_version'], $row['snmp_index']); }
             $sfp_status = get_sfp_status($device['vendor_id'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version'], $modules_oids);
@@ -164,7 +164,7 @@ if ($device['snmp_version']>0) {
             if (isset($poe_status)) {
                 if ($poe_status == 1) {
                     $port_poe_detail = get_port_poe_detail($device['vendor_id'], $row['port'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version']);
-                    $poe_info="POE:On " . $port_poe_detail;
+                    if (empty($port_poe_detail)) { $poe_info = 'POE:on'; } else { $poe_info = $port_poe_detail; }
                     }
                 if ($poe_status == 2) { $poe_info="POE:Off"; }
                 }

+ 3 - 3
html/inc/common.php

@@ -2210,7 +2210,7 @@ function get_sfp_status($vendor_id, $port, $ip, $community, $version, $modules_o
     return;
 }
 
-function get_port_vlan($port, $port_index, $ip, $community, $version, $fdb_by_snmp)
+function get_port_vlan($vendor, $port, $port_index, $ip, $community, $version, $fdb_by_snmp)
 {
     if (! isset($port)) {
         return;
@@ -2228,7 +2228,7 @@ function get_port_vlan($port, $port_index, $ip, $community, $version, $fdb_by_sn
 
     if ($fdb_by_snmp == 1) { $port = $port_index; }
 
-    $port_oid = PORT_VLAN_OID . $port;
+    if ($vendor == 69) { $port_oid = TPLINK_VLAN_PVID . "." . $port; } else { $port_oid = PORT_VLAN_OID . "." . $port; }
     $port_vlan = get_snmp($ip, $community, $version, $port_oid);
     $port_vlan = preg_replace('/.*\:/','',$port_vlan);
     $port_vlan = intval(trim($port_vlan));
@@ -2393,7 +2393,7 @@ function get_port_poe_detail($vendor_id, $port, $port_snmp_index, $ip, $communit
             }
         }
     }
-    
+
     if (isset($poe_current)) {
         $c_current = get_snmp($ip, $community, $version, $poe_current);
         if (isset($c_current)) {

+ 5 - 1
html/inc/consts.php

@@ -6,7 +6,11 @@ define("PORT_STATUS_OID",".1.3.6.1.2.1.2.2.1.8.");
 define("PORT_ADMIN_STATUS_OID",".1.3.6.1.2.1.2.2.1.7.");
 define("PORT_SPEED_OID",".1.3.6.1.2.1.2.2.1.5.");
 define("PORT_ERRORS_OID",".1.3.6.1.2.1.2.2.1.14.");
-define("PORT_VLAN_OID",".1.3.6.1.2.1.17.7.1.4.5.1.1.");
+
+//VLANS
+define("PORT_VLAN_OID",".1.3.6.1.2.1.17.7.1.4.5.1.1");
+//tp-link
+define("TPLINK_VLAN_PVID",".1.3.6.1.4.1.11863.6.14.1.1.1.1.2");
 
 define("IFMIB_IFINDEX",".1.3.6.1.2.1.2.2.1.1");
 define("IFMIB_IFINDEX_MAP",".1.3.6.1.2.1.17.1.4.1.2");