Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh OSS_SNMP to latest version #1339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 47 additions & 8 deletions OSS_SNMP/MIBS/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,62 @@
* @copyright Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland
* @author Barry O'Donovan <[email protected]>
*/
class Bridge extends \OSS_SNMP\MIB
{
const OID_BRIDGE_BASE_PORT_IF_INDEX = '.1.3.6.1.2.1.17.1.4.1.2';
class Bridge extends \OSS_SNMP\MIB {

const OID_BRIDGE_BASE_PORT_IF_INDEX = '.1.3.6.1.2.1.17.1.4.1.2';
const OID_BRIDGE_MAC_ADDRESS = '.1.3.6.1.2.1.17.4.3.1.1';
const OID_BRIDGE_MAC_ADDRESS_BASE_PORT = '.1.3.6.1.2.1.17.4.3.1.2';

/**
* Returns an associate array of STP port IDs (key) to interface IDs (value)
*
* e.g. [22] => 10122
*
*
* @return array Associate array of STP port IDs (key) to interface IDs (value)
* @param $baseport int base port to ask for
* @return array Associate array of STP port IDs (key) to interface IDs (value) or only for $baseport if supplied
*/
public function basePortIfIndexes()
public function basePortIfIndexes($baseport = null)
{
return $this->getSNMP()->walk1d( self::OID_BRIDGE_BASE_PORT_IF_INDEX );
$oid = self::OID_BRIDGE_BASE_PORT_IF_INDEX;
if ($baseport) {
$oid .= "." . $baseport;
}
return $this->getSNMP()->subOidWalk($oid, 12);
}

}
/**
* Returns array Associative MAC ADDRESSES (value) to unique index (key)
* NOTE: unique index (key) is the decimal macaddress
* (ex. 0.0.136.54.152.12 is 00:00:88:36:98:0C
*
* e.g. [0.0.136.54.152.12] => 00008836980C
*
* @return array Associative MAC ADDRESSES (value) to unique index (key)
*/
public function macAddressList() {
return $this->getSNMP()->subOidWalk(self::OID_BRIDGE_MAC_ADDRESS, 12, -1);
}

/**
* Returns array Associative of BasePort (value) to unique index (key)
* for mac address listed in self::macAddressList()
* Use basePortIfIndexes to obtain interface
* NOTE: unique index (key) is the decimal macaddress
* (ex. 0.0.136.54.152.12 is 00:00:88:36:98:0C
*
* e.g. [0.0.136.54.152.12] => 2
*
*
* @param $decimalmac string macaddress in decimal format (see NOTE) to search for
* @return array Associative of BasePort (value) to unique index (key)
* for mac address listed in self::macAddressList() or only for $decimalmac if supplied
*/
public function macAddressBasePort($decimalmac = null) {
$oid = self::OID_BRIDGE_MAC_ADDRESS_BASE_PORT;
if ($decimalmac) {
$oid .= "." . $decimalmac;
}
return $this->getSNMP()->subOidWalk($oid, 12, -1);
}

}
81 changes: 81 additions & 0 deletions OSS_SNMP/MIBS/Cisco/PAGP.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/*
Copyright (c) 2012-2016, Open Source Solutions Limited, Dublin, Ireland
All rights reserved.

Contact: Barry O'Donovan - barry (at) opensolutions (dot) ie
http://www.opensolutions.ie/

This file is part of the OSS_SNMP package.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Open Source Solutions Limited nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

namespace OSS_SNMP\MIBS\Cisco;

/**
* A class for performing SNMP V2 queries on Cisco devices
*
* @copyright Copyright (c) 2012-2016, Open Source Solutions Limited, Dublin, Ireland
* @author Luis Alberto Herrero <[email protected]>
*/
class PAGP extends \OSS_SNMP\MIBS\Cisco
{

const OID_PAGP_GROUPIFINDEX = '1.3.6.1.4.1.9.9.98.1.1.1.1.8';

/**
*
* @return associative array with the physic interface index (key) and the agregation port ifindex (value)
* if key == value OR value == 0 not agregation
*/
public function groupIfIndex() {
return $this->getSNMP()->subOidWalk( self::OID_PAGP_GROUPIFINDEX, 15 );
}

/**
* Gets an associate array of PAGP ports with the [id] => name of it's constituent ports
*
* E.g.:
* [5048] => Array
* (
* [10111] => GigabitEthernet1/0/11
* [10112] => GigabitEthernet1/0/12
* )
*
* @return array Associate array of LAG ports with the [id] => name of it's constituent ports
*/
public function getPAGPPorts()
{
$ports = array();

foreach( $this->groupIfIndex() as $portId => $aggPortId )
if( $aggPortId != 0 && $portId != $aggPortId)
$ports[ $aggPortId ][$portId] = $this->getSNMP()->useIface()->names()[$portId];

return $ports;
}

}
184 changes: 184 additions & 0 deletions OSS_SNMP/MIBS/Cisco/VlanMembership.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<?php

/*
Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland
All rights reserved.

Contact: Barry O'Donovan - barry (at) opensolutions (dot) ie
http://www.opensolutions.ie/

This file is part of the OSS_SNMP package.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Open Source Solutions Limited nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

namespace OSS_SNMP\MIBS\Cisco;

/**
* A class for performing SNMP V2 queries on generic devices.
*
* @copyright Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland
* @author Sergio Gómez Bachiller <[email protected]>
*/
class VlanMembership extends \OSS_SNMP\MIBS\Cisco
{
const OID_VLAN_MEMBERSHIP_VLAN_TYPE = '.1.3.6.1.4.1.9.9.68.1.2.2.1.1';
const OID_VLAN_MEMBERSHIP_VLAN = '.1.3.6.1.4.1.9.9.68.1.2.2.1.2';
const OID_VLAN_MEMBERSHIP_PORT_STATUS = '.1.3.6.1.4.1.9.9.68.1.2.2.1.3';

/**
* Constant for possible value of interface vlan type.
*
* @see vlanTypes()
*/
const VLAN_MEMBERSHIP_VLAN_TYPE_STATIC = 1;

/**
* Constant for possible value of interface vlan type.
*
* @see vlanTypes()
*/
const VLAN_MEMBERSHIP_VLAN_TYPE_DYNAMIC = 2;

/**
* Constant for possible value of interface vlan type.
*
* @see vlanTypes()
*/
const VLAN_MEMBERSHIP_VLAN_TYPE_MULTI_VLAN = 3;

/**
* Text representation of interface vlan type.
*
* @see vlanTypes()
*
* @var array Text representations of interface vlan type.
*/
public static $VLAN_MEMBERSHIP_VLAN_TYPES = [
self::VLAN_MEMBERSHIP_VLAN_TYPE_STATIC => 'static',
self::VLAN_MEMBERSHIP_VLAN_TYPE_DYNAMIC => 'dynamic',
self::VLAN_MEMBERSHIP_VLAN_TYPE_MULTI_VLAN => 'multiVlan',
];

/**
* Get an array of the type of VLAN membership of each device port.
*
* E.g. the follow SNMP output yields the shown array:
*
* .1.3.6.1.4.1.9.9.68.1.2.2.1.1.10128 = INTEGER: static(1)
* .1.3.6.1.4.1.9.9.68.1.2.2.1.1.10129 = INTEGER: dynamic(2)
* ...
*
* [10128] => 1
* [10129] => 2
*
* @return array
*/
public function vlanTypes($translate = false)
{
$states = $this->getSNMP()->walk1d(self::OID_VLAN_MEMBERSHIP_VLAN_TYPE);

if (!$translate) {
return $states;
}

return $this->getSNMP()->translate($states, self::$VLAN_MEMBERSHIP_VLAN_TYPES);
}

/**
* Get an array of the VLAN id of each device port in access mode.
*
* E.g. the follow SNMP output yields the shown array:
*
* .1.3.6.1.4.1.9.9.68.1.2.2.1.2.10128 = INTEGER: 1
* .1.3.6.1.4.1.9.9.68.1.2.2.1.2.10129 = INTEGER: 10
* ...
*
* [10128] => 1
* [10129] => 10
*/
public function vlans()
{
return $this->getSNMP()->walk1d(self::OID_VLAN_MEMBERSHIP_VLAN);
}

/**
* Constant for possible value of the current VLAN status of the port.
*
* @see portStatus()
*/
const VLAN_MEMBERSHIP_PORT_STATUS_INACTIVE = 1;

/**
* Constant for possible value of the current VLAN status of the port.
*
* @see portStatus()
*/
const VLAN_MEMBERSHIP_PORT_STATUS_ACTIVE = 2;

/**
* Constant for possible value of the current VLAN status of the port.
*
* @see portStatus()
*/
const VLAN_MEMBERSHIP_PORT_STATUS_SHUTDOWN = 3;

/**
* Text representation of VLAN status of the port.
*
* @see vlanTypes()
*
* @var array Text representations of interface vlan type.
*/
public static $VLAN_MEMBERSHIP_PORT_STATUS = [
self::VLAN_MEMBERSHIP_PORT_STATUS_INACTIVE => 'inactive',
self::VLAN_MEMBERSHIP_PORT_STATUS_ACTIVE => 'active',
self::VLAN_MEMBERSHIP_PORT_STATUS_SHUTDOWN => 'shutdown',
];

/**
* Get an array of the current status of VLAN in each device port.
*
* .1.3.6.1.4.1.9.9.68.1.2.2.1.1.10128 = INTEGER: inactive(1)
* .1.3.6.1.4.1.9.9.68.1.2.2.1.1.10129 = INTEGER: active(2)
* ...
*
* [10128] => 1
* [10129] => 2
*
* @param bool $translate If true, return the string representation.
*
* @return array An array with the current VLAN status of ports.
*/
public function portStatus($translate = false)
{
$states = $this->getSNMP()->walk1d(self::OID_VLAN_MEMBERSHIP_PORT_STATUS);

if (!$translate) {
return $states;
}

return $this->getSNMP()->translate($states, self::$VLAN_MEMBERSHIP_PORT_STATUS);
}
}
Loading