Projekt

Obecné

Profil

« Předchozí | Další » 

Revize c478920d

Přidáno uživatelem Ondřej Fibich před asi 9 roky(ů)

Undo my stupid mistake (I have pushed issue-957 to master instead of develop). Do I have copied files from GitHub master and push them back..

Zobrazit rozdíly:

application/libraries/snmp/SignamaxOld_Snmp.php
try
{
$this->startErrorHandler();
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
$row = snmp2_get(
$device_ip, $this->comunity, 'iso.3.6.1.2.1.1.5.0',
$this->timeout, $this->retries
......
return FALSE;
}
return ($row == '065-7850' || $row == '065-7710');
// parse result
$matches = array();
if (preg_match('/STRING: "?([^"]*)"?/', $row, $matches) > 0)
{
return (
$matches[1] == '065-7850' ||
$matches[1] == '065-7710'
);
}
else
{
return FALSE;
}
}
/**
......
{
// obtain
$this->startErrorHandler();
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
$row = snmp2_get(
$this->deviceIp, $this->comunity,
'iso.3.6.1.2.1.17.4.3.1.2.' . $dec_mac_address,
......
}
}
/**
* Obtain names of all network interfaces of device
*
* @return array Network interfaces of device
* @throws Exception On SNMP error or wrong SNMP response
*/
public function getIfaces()
{
return array();
}
/**
* Obtain current state of device's ports
*
* @return array Current states of all ports
* @throws Exception On SNMP error or wrong SNMP response
*/
public function getPortStates()
{
$this->startErrorHandler();
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
$port_states = snmp2_real_walk(
$this->deviceIp, $this->comunity,
'iso.3.6.1.2.1.2.2.1.8',
$this->timeout, $this->retries
);
$this->stopErrorHandler();
$states = array();
foreach ($port_states as $key => $value)
{
$pieces = explode('.', $key);
$port_nr = array_pop($pieces);
$states[$port_nr] = $value == 1 ? 1 : 0;
}
return $states;
}
/**
* Obtain ARP table of device
*
* @return array Whole ARP table from device
* @throws Exception On SNMP error or wrong SNMP response
*/
public function getARPTable()
{
return array();
}
/**
* Obtain DHCP leases of device
*
* @return array All DHCP leases
* @throws Exception On SNMP error or wrong SNMP response
*/
public function getDHCPLeases()
{
return array();
}
/**
* Obtain device's hostname from DHCP leases of device
*
* @param string $device_ip IP address to which we will search for hostname
* @return string Hostname for given IP address
* @throws Exception On SNMP error or wrong SNMP response
* @throws InvalidArgumentException On wrong IP address
*/
public function getDHCPHostnameOf($device_ip)
{
return FALSE;
}
/**
* Obtain wireless info of device
*
* @return array Current wireless info
* @throws Exception On SNMP error or wrong SNMP response
*/
public function getWirelessInfo()
{
return array();
}
/**
* Obtain MAC table from device
*
* @return array Whole MAC table
* @throws Exception On SNMP error or wrong SNMP response
*/
public function getMacTable()
{
$this->startErrorHandler();
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
$mac_table = snmp2_real_walk(
$this->deviceIp, $this->comunity,
'iso.3.6.1.2.1.17.4.3.1.2',
$this->timeout, $this->retries
);
$this->stopErrorHandler();
$items = array();
$ports = array();
foreach ($mac_table as $key => $value)
{
$pieces = explode('.', $key);
$item = new stdClass();
$item->port_nr = $value;
$i = implode('.', array_slice($pieces, -6));
$item->mac_address = network::dec2mac($i);
$items[] = $item;
$ports[] = $value;
}
array_multisort($ports, $items);
return $items;
}
}

Také k dispozici: Unified diff