Просмотр исходного кода

change snmp port index in walk vlan table

Roman Dmitriev 2 лет назад
Родитель
Сommit
5152b49aba
2 измененных файлов с 10 добавлено и 6 удалено
  1. 1 1
      html/admin/devices/switchstatus.php
  2. 9 5
      html/inc/common.php

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

@@ -169,7 +169,7 @@ print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['log
             $ifname = $row['ifName'];
 
             if ($snmp_ok) {
-                $vlan = get_port_vlan($device['vendor_id'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version']);
+                $vlan = get_port_vlan($device['vendor_id'],  $row['port'] , $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version']);
                 $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']);

+ 9 - 5
html/inc/common.php

@@ -408,7 +408,7 @@ function cidrToRange($cidr)
 
 function crypt_string($simple_string)
 {
-    // Storingthe cipher method
+    // Storin gthe cipher method
     $ciphering = "aes-128-cbc";
     // Using OpenSSl Encryption method
     $iv_length = openssl_cipher_iv_length($ciphering);
@@ -419,7 +419,7 @@ function crypt_string($simple_string)
 
 function decrypt_string($crypted_string)
 {
-    // Storingthe cipher method
+    // Storin gthe cipher method
     $ciphering = "aes-128-cbc";
     // Using OpenSSl Encryption method
     $iv_length = openssl_cipher_iv_length($ciphering);
@@ -2514,7 +2514,7 @@ function get_sfp_status($vendor_id, $port, $ip, $community, $version, $modules_o
     return;
 }
 
-function get_port_vlan($vendor, $port_index, $ip, $community, $version)
+function get_port_vlan($vendor, $port, $port_index, $ip, $community, $version)
 {
     if (!isset($port_index)) {
         return;
@@ -2529,11 +2529,15 @@ function get_port_vlan($vendor, $port_index, $ip, $community, $version)
         $version = '2';
     }
 
+    $port_oid = PORT_VLAN_OID . "." . $port;
+    //tplink
     if ($vendor == 69) {
         $port_oid = TPLINK_VLAN_PVID . "." . $port_index;
-    } else {
+    } 
+    //eltex
+    if ($vendor == 2) {
         $port_oid = PORT_VLAN_OID . "." . $port_index;
-    }
+    } 
 
     $port_vlan = get_snmp($ip, $community, $version, $port_oid);
     $port_vlan = preg_replace('/.*\:/', '', $port_vlan);