class InterfacesMIB(metaclass=MIBMeta, prefix='.1.3.6.1.2.1.2'): """ 'interfaces' https://tools.ietf.org/html/rfc1213#section-3.5 """ if_updater = InterfacesUpdater() oidtree_updater = mibs.RedisOidTreeUpdater(prefix_str='1.3.6.1.2.1.2') # (subtree, value_type, callable_, *args, handler=None) ifNumber = MIBEntry('1', ValueType.INTEGER, if_updater.get_if_number) # ifTable ::= { interfaces 2 } # ifEntry ::= { ifTable 1 } ifIndex = \ SubtreeMIBEntry('2.1.1', if_updater, ValueType.INTEGER, if_updater.if_index) ifDescr = \ SubtreeMIBEntry('2.1.2', if_updater, ValueType.OCTET_STRING, if_updater.interface_description) ifType = \ SubtreeMIBEntry('2.1.3', if_updater, ValueType.INTEGER, if_updater.get_if_type) ifMtu = \ SubtreeMIBEntry('2.1.4', if_updater, ValueType.INTEGER, if_updater.get_mtu) ifSpeed = \ SubtreeMIBEntry('2.1.5', if_updater, ValueType.GAUGE_32, if_updater.get_speed_bps) # FIXME Placeholder. ifPhysAddress = \ SubtreeMIBEntry('2.1.6', if_updater, ValueType.OCTET_STRING, lambda sub_id: '') ifAdminStatus = \ SubtreeMIBEntry('2.1.7', if_updater, ValueType.INTEGER, if_updater.get_admin_status) ifOperStatus = \ SubtreeMIBEntry('2.1.8', if_updater, ValueType.INTEGER, if_updater.get_oper_status) # FIXME Placeholder. ifLastChange = \ SubtreeMIBEntry('2.1.9', if_updater, ValueType.TIME_TICKS, lambda sub_id: 0) ifInOctets = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.10', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(10)), OidMIBEntry('2.1.10', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifInUcastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.11', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(11)), OidMIBEntry('2.1.11', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifInNUcastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.12', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(12)), OidMIBEntry('2.1.12', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifInDiscards = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.13', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(13)), OidMIBEntry('2.1.13', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifInErrors = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.14', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(14)), OidMIBEntry('2.1.14', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifInUnknownProtos = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.15', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(15)), OidMIBEntry('2.1.15', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifOutOctets = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.16', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(16)), OidMIBEntry('2.1.16', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifOutUcastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.17', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(17)), OidMIBEntry('2.1.17', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifOutNUcastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.18', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(18)), OidMIBEntry('2.1.18', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifOutDiscards = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.19', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(19)), OidMIBEntry('2.1.19', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifOutErrors = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.20', if_updater, ValueType.COUNTER_32, if_updater.get_counter, DbTables(20)), OidMIBEntry('2.1.20', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifOutQLen = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('2.1.21', if_updater, ValueType.GAUGE_32, if_updater.get_counter, DbTables(21)), OidMIBEntry('2.1.21', ValueType.GAUGE_32, oidtree_updater.get_oidvalue) ) # FIXME Placeholder ifSpecific = \ SubtreeMIBEntry('2.1.22', if_updater, ValueType.OBJECT_IDENTIFIER, lambda sub_id: ObjectIdentifier.null_oid())
class InterfaceMIBObjects(metaclass=MIBMeta, prefix='.1.3.6.1.2.1.31.1'): """ 'ifMIBObjects' https://tools.ietf.org/html/rfc2863#section-6 """ if_updater = InterfaceMIBUpdater() oidtree_updater = mibs.RedisOidTreeUpdater(prefix_str='1.3.6.1.2.1.31.1') # ifXTable = '1' # ifXEntry = '1.1' ifName = \ SubtreeMIBEntry('1.1.1', if_updater, ValueType.OCTET_STRING, if_updater.interface_name) ifInMulticastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.2', if_updater, ValueType.COUNTER_32, if_updater.get_counter32, DbTables32(2)), OidMIBEntry('1.1.2', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifInBroadcastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.3', if_updater, ValueType.COUNTER_32, if_updater.get_counter32, DbTables32(3)), OidMIBEntry('1.1.3', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifOutMulticastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.4', if_updater, ValueType.COUNTER_32, if_updater.get_counter32, DbTables32(4)), OidMIBEntry('1.1.4', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifOutBroadcastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.5', if_updater, ValueType.COUNTER_32, if_updater.get_counter32, DbTables32(5)), OidMIBEntry('1.1.5', ValueType.COUNTER_32, oidtree_updater.get_oidvalue) ) ifHCInOctets = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.6', if_updater, ValueType.COUNTER_64, if_updater.get_counter64, DbTables64(6)), OidMIBEntry('1.1.6', ValueType.COUNTER_64, oidtree_updater.get_oidvalue) ) ifHCInUcastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.7', if_updater, ValueType.COUNTER_64, if_updater.get_counter64, DbTables64(7)), OidMIBEntry('1.1.7', ValueType.COUNTER_64, oidtree_updater.get_oidvalue) ) ifHCInMulticastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.8', if_updater, ValueType.COUNTER_64, if_updater.get_counter64, DbTables64(8)), OidMIBEntry('1.1.8', ValueType.COUNTER_64, oidtree_updater.get_oidvalue) ) ifHCInBroadcastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.9', if_updater, ValueType.COUNTER_64, if_updater.get_counter64, DbTables64(9)), OidMIBEntry('1.1.9', ValueType.COUNTER_64, oidtree_updater.get_oidvalue) ) ifHCOutOctets = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.10', if_updater, ValueType.COUNTER_64, if_updater.get_counter64, DbTables64(10)), OidMIBEntry('1.1.10', ValueType.COUNTER_64, oidtree_updater.get_oidvalue) ) ifHCOutUcastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.11', if_updater, ValueType.COUNTER_64, if_updater.get_counter64, DbTables64(11)), OidMIBEntry('1.1.11', ValueType.COUNTER_64, oidtree_updater.get_oidvalue) ) ifHCOutMulticastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.12', if_updater, ValueType.COUNTER_64, if_updater.get_counter64, DbTables64(12)), OidMIBEntry('1.1.12', ValueType.COUNTER_64, oidtree_updater.get_oidvalue) ) ifHCOutBroadcastPkts = \ OverlayAdpaterMIBEntry( SubtreeMIBEntry('1.1.13', if_updater, ValueType.COUNTER_64, if_updater.get_counter64, DbTables64(13)), OidMIBEntry('1.1.13', ValueType.COUNTER_64, oidtree_updater.get_oidvalue) ) """ ifLinkUpDownTrapEnable OBJECT-TYPE SYNTAX INTEGER { enabled(1), disabled(2) } MAX-ACCESS read-write STATUS current DESCRIPTION "Indicates whether linkUp/linkDown traps should be generated for this interface. By default, this object should have the value enabled(1) for interfaces which do not operate on 'top' of any other interface (as defined in the ifStackTable), and disabled(2) otherwise." """ # FIXME: Placeholder (original impl reported 0) ifLinkUpDownTrapEnable = SubtreeMIBEntry('1.1.14', if_updater, ValueType.INTEGER, lambda sub_id: 2) ifHighSpeed = SubtreeMIBEntry('1.1.15', if_updater, ValueType.GAUGE_32, if_updater.get_high_speed) """ ifPromiscuousMode OBJECT-TYPE SYNTAX TruthValue MAX-ACCESS read-write STATUS current DESCRIPTION "This object has a value of false(2) if this interface only accepts packets/frames that are addressed to this station. This object has a value of true(1) when the station accepts all packets/frames transmitted on the media. The value true(1) is only legal on certain types of media. If legal, setting this object to a value of true(1) may require the interface to be reset before becoming effective. The value of ifPromiscuousMode does not affect the reception of broadcast and multicast packets/frames by the interface." """ # FIXME: Placeholder ifPromiscuousMode = SubtreeMIBEntry('1.1.16', if_updater, ValueType.INTEGER, lambda sub_id: 1) """ ifConnectorPresent OBJECT-TYPE SYNTAX TruthValue MAX-ACCESS read-only STATUS current DESCRIPTION "This object has the value 'true(1)' if the interface sublayer has a physical connector and the value 'false(2)' otherwise." """ # FIXME: Placeholder ifConnectorPresent = SubtreeMIBEntry('1.1.17', if_updater, ValueType.INTEGER, lambda sub_id: 1) ifAlias = SubtreeMIBEntry('1.1.18', if_updater, ValueType.OCTET_STRING, if_updater.interface_alias) """ ifCounterDiscontinuityTime OBJECT-TYPE SYNTAX TimeStamp MAX-ACCESS read-only STATUS current DESCRIPTION "The value of sysUpTime on the most recent occasion at which any one or more of this interface's counters suffered a discontinuity. The relevant counters are the specific instances associated with this interface of any Counter32 or Counter64 object contained in the ifTable or ifXTable. If no such discontinuities have occurred since the last re- initialization of the local management subsystem, then this object contains a zero value." """ # FIXME: Placeholder ifCounterDiscontinuityTime = SubtreeMIBEntry('1.1.19', if_updater, ValueType.TIME_TICKS, lambda sub_id: 0)