diff -Nru python-pysnmp4-4.3.2/CHANGES.txt python-pysnmp4-4.4.3/CHANGES.txt --- python-pysnmp4-4.3.2/CHANGES.txt 2016-02-13 21:07:58.000000000 +0000 +++ python-pysnmp4-4.4.3/CHANGES.txt 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,161 @@ -Revision 4.3.3, work in progress --------------------------------- +Revision 4.4.3, released 2017-12-22 +----------------------------------- + +- Migrated references from SourceForge +- Added missing SHA2 support for Blumenthal key localization +- Fixed named bits handling at rfc1902.Bits +- Fixed missing SmiError exception class at pysnmp.proto.rfc1155 +- Fixed SNMP v1->v2c PDU proxy -- error-status & error-index fields + from v1 PDU get copied over to v2c PDU in addition to the exception + sentinels being set + +Revision 4.4.2, released 2017-11-11 +----------------------------------- + +- The pysnmp version being used gets exposed to the MIB modules + via the `MibBuilder` instance +- The .setObjects() method of the SMI types now accepts + `append=False` parameter to let the caller adding more + than 255 elements over the course of multiple calls +- Added support for some more missing fields of SMIv2 MACRO types +- Example scripts rearranged in a way that IPv6 requirement is + clearly encoded in the script's name +- Fixed SNMPv2-SMI.NotificationType to expose .set/getReference() + instead of .set/getRevision() which should not be there in the + first place +- Fixed non-implied-OID encoding in SNMP table indices +- Fixed inconsistent SNMPv3 discovery and retrying algorithm + +Revision 4.4.1, released 2017-10-23 +----------------------------------- + +- HMAC-SHA-2 Authentication Protocols support added (RFC-7860) +- The pycryptodome dependency replaced with pycryptodomex as + it is recommended by the upstream to avoid unwanted interference + with PyCrypto package should it also be installed +- Sphinx theme changed to Alabaster in the documentation +- Minor adjustments towards pyasn1 0.4.x compatibility +- Fixed ObjectIdentifier-into-ObjectIdentity casting at + rfc1902.ObjectType MIB resolution harness +- Fixed NetworkAddress object handling in SNMP table indices +- Fixed MIB lookup by module:object.indices MIB object with + InetAddressIPv{4,6} objects being in the index +- Fixed non-translated PDU being retries at CommandGenerator what + leads to wrong PDU version being sent and even a crash on + incompatible PDU/SNMP message combination + +Revision 4.3.10, released 2017-10-06 +------------------------------------ + +- Refactored partial SNMP message decoding to make it less dependent + on unpublished pyasn1 API features. +- Fix to MibTableRow.setFromName() to keep the input parameter type when + it propagates to the return value. Before this fix + ObjectIdentity.prettyPrint() may crash when rendering malformed SNMP + table indices. +- Fixed NotificationReceiver to include SNMPv1 TRAP Message community + string into SNMPv2c/v3 TRAP PDU +- Fixed multiple bugs in SNMP table indices rendering, especially + the InetAddressIPv6 type which was severely broken. +- Fixed crashing Bits.prettyPrint() implementation +- Fixed crashing Bits.clone()/subtype() implementation +- Fixed leaking exceptions bubbling up from the asyncio and Twisted adapters + +Revision 4.3.9, released 2017-07-26 +----------------------------------- + +- Deprecated UsmUserData initializaton parameters removed +- Adapted to pyasn1 API changes introduced by release 0.3.1 +- Fix to a crash happening on inbound SNMP message having non-initialized fields +- Fix to (persistent SNMP engine ID) file writing on Windows + +Revision 4.3.8, released 2017-06-15 +----------------------------------- + +- Security fix to the bug introduced in 4.3.6: msgAuthoritativeEngineTime + stopped changing over time and was returning the same timestamp (process + start time). This fix makes it growing as it should. + +Revision 4.3.7, released 2017-05-29 +----------------------------------- + +* Fixed import error in legacy NotificationOriginator implementation + +Revision 4.3.6, released 2017-05-28 +----------------------------------- + +- More instrumentation hooks added addressing security failures + auditing needs. +- SNMP table indices correlation implemented within SMI framework. + The opaque InetAddress type implemented. INET-ADDRESS-MIB included + into the distribution. +- SNMP table indices resolution logic made more robust against + malformed indices. +- Fixes to *lexicographicMode* option documentation to make it + unambiguous. +- The `ErrorIndication` object is now derived from `Exception` so + that it could be raised in exceptions. +- The `errorIndication` values produced by various parts of + SNMP engine unified to be `ErrorIndication` instances. This fixes + an issue with Twisted. +- Embedded MIB modules rebuilt with the latest pysmi adding previously + missing attributes like `status`, `description` etc. +- Fixed potential SNMP engine crash on handling incoming message + at unsupported security level + +Revision 4.3.5, released 2017-03-24 +----------------------------------- + +- The getNext() and getBulk() calls of Twisted interface. + now support ignoreNonIncreasingOid option. +- TextualConvention is now a new-style class. +- Fix to accidentally reset error-status when building confirmed class + SNMPv1 PDU. +- Fix to possible infinite recursion in TextualConvention.prettyIn(). +- Fixed crash when attempting to report unsupported request/notification + PDU back to sender. + +Revision 4.3.4, released 2017-03-01 +----------------------------------- + +- Fix to low-level SNMP API example to accommodate changed pyasn1 + SEQUENCE supporting iterator protocol. +- The pyasn1 version dependency bumped (0.2.3), SEQUENCE/SEQUENCE OF + API calls adjusted to accommodate changed pyasn1 API (in part + of .setComponentBy*() kw flags). +- Fixed crash on SNMP engine's invalid message counter increment. + +Revision 4.3.3, released 2017-02-04 +----------------------------------- -Repository `tarball download `_ +- Switched from now unmaintained PyCrypto to PyCryptodome. +- Switched to new-style classes. +- NotificationType now allows additional var-binds specified as + MIB objects. A side effect of this change is that additional + var-binds can only be added prior to .resolveMibObjects() is + run. +- Non-standard (but apparently used by many vendors) Reeder AES192/256 + key localization algorithm implemented and set as default for + usmAesCfb192Protocol and usmAesCfb256Protocol identifiers. + Original and more standard implementation can still be used + with the usmAesBlumenthalCfb192Protocol and + usmAesBlumenthalCfb192Protocol IDs respectively. +- TextualConvention.prettyOut() improved to produce prettier and + more SMI-compliant output. +- TextualConvention.prettyIn() implemented to handle DISPLAY-HINT + based value parsing. +- Fix to NotificationType to make additional var-binds overriding + MIB objects implicitly included through NOTIFICATION-TYPE OBJECTS. +- Fix to SNMP engine boots counter persistence on Python 3. +- Fix to Pythonized MIBs loading when only .pyc files are + present (e.g. py2exe/cx_freeze environments). +- Fix broken 3DES key localization and encryption procedures. +- Updated IP address for demo.snmplabs.com in examples. +- Missing index added to bundled RFC1213::atEntry MIB table. +- Twisted integration made Python3 compatible. +- Accommodated ASN.1 SEQUENCE iteration rules change in upcoming pyasn1 version. +- Author's email changed, copyright extended to 2017. Revision 4.3.2, released 2016-02-12 ----------------------------------- diff -Nru python-pysnmp4-4.3.2/debian/changelog python-pysnmp4-4.4.3/debian/changelog --- python-pysnmp4-4.3.2/debian/changelog 2016-07-17 05:28:27.000000000 +0000 +++ python-pysnmp4-4.4.3/debian/changelog 2017-12-31 13:08:51.000000000 +0000 @@ -1,3 +1,15 @@ +python-pysnmp4 (4.4.3-1) unstable; urgency=medium + + * New upstream release. + + Update dependencies. + * d/patches: update privacy-breach patch. + * d/watch: tarballs are now released on GitHub. + * d/control: bump Standards-Version. + * d/control: add test suite. + * d/copyright: move from BSD-3-clause to BSD-2-clause. + + -- Vincent Bernat Sun, 31 Dec 2017 14:08:51 +0100 + python-pysnmp4 (4.3.2-2) unstable; urgency=medium * Disable network access for Sphinx. Closes: #830605. diff -Nru python-pysnmp4-4.3.2/debian/control python-pysnmp4-4.4.3/debian/control --- python-pysnmp4-4.3.2/debian/control 2016-07-17 05:28:27.000000000 +0000 +++ python-pysnmp4-4.4.3/debian/control 2017-12-31 13:08:51.000000000 +0000 @@ -5,18 +5,20 @@ Uploaders: Jan Lübbe , Deepak Tripathi , Vincent Bernat -Standards-Version: 3.9.8 +Standards-Version: 4.1.2 Build-Depends: debhelper (>= 9), dh-python, - python-sphinx, python-sphinx-rtd-theme, + python3-sphinx, python3-sphinx-rtd-theme, python-all (>= 2.6.6-3~), python3-all, python-setuptools, python3-setuptools, - python-crypto, python3-crypto, - python-pyasn1, python3-pyasn1 + python-pycryptodome, python3-pycryptodome, + python-twisted, python3-twisted, + python-pysmi, python3-pysmi, + python-pyasn1 (>= 0.2.3) , python3-pyasn1 (>= 0.2.3) Homepage: http://pysnmp.sourceforge.net/ -X-Python-Version: >= 2.4 Vcs-Git: https://anonscm.debian.org/git/python-modules/packages/python-pysnmp4.git Vcs-Browser: https://anonscm.debian.org/cgit/python-modules/packages/python-pysnmp4.git +Testsuite: autopkgtest-pkg-python Package: python-pysnmp4 Architecture: all @@ -26,7 +28,6 @@ Recommends: python-pysnmp4-mibs, python-pysnmp4-apps, python-twisted -Suggests: python-pysnmp4-doc Conflicts: python-pysnmp2, python-pysnmp-common Replaces: python-pysnmp2, @@ -48,7 +49,6 @@ Architecture: all Depends: ${python3:Depends}, ${misc:Depends} -Suggests: python-pysnmp4-doc Description: Python SNMP library for agents and managers (Python 3 module) This is a Python implementation of SNMP v.1/v.2c/v.3 engine. Its general functionality is to assemble/disassemble SNMP messages diff -Nru python-pysnmp4-4.3.2/debian/copyright python-pysnmp4-4.4.3/debian/copyright --- python-pysnmp4-4.3.2/debian/copyright 2016-07-17 05:28:27.000000000 +0000 +++ python-pysnmp4-4.4.3/debian/copyright 2017-12-31 13:08:51.000000000 +0000 @@ -4,40 +4,20 @@ Source: http://pysnmp.sourceforge.net/download.html Files: * -Copyright: 1999-2012, Ilya Etingof , all rights reserved. -License: BSD-3-clause - THIS SOFTWARE IS NOT FAULT TOLERANT AND SHOULD NOT BE USED IN ANY SITUATION - ENDANGERING HUMAN LIFE OR PROPERTY. - . - 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. - . - * The name of the authors may not 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 REGENTS 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. +Copyright: 1999-2017, Ilya Etingof , all rights reserved. +License: BSD-2-clause Files: pysnmp/carrier/twisted/dispatch.py pysnmp/carrier/twisted/base.py Copyright: 2008 Truelite Srl License: GPL-2 +Files: pysnmp/carrier/asyncio/* + pysnmp/hlapi/asyncio/* +Copyright: 2005-2017, Ilya Etingof + 2014, Zebra Technologies +License: BSD-2-clause + Files: debian/* Copyright: 2006-2012 Jan Lübbe 2006-2012 Arnaud Fontaine @@ -60,3 +40,26 @@ . On Debian systems, the full text of the GNU General Public License version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. + +License: BSD-2-clause + 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. + . + 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 HOLDER 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. diff -Nru python-pysnmp4-4.3.2/debian/gbp.conf python-pysnmp4-4.4.3/debian/gbp.conf --- python-pysnmp4-4.3.2/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/debian/gbp.conf 2017-12-31 13:08:51.000000000 +0000 @@ -0,0 +1,2 @@ +[DEFAULT] +debian-branch=debian/master diff -Nru python-pysnmp4-4.3.2/debian/.git-dpm python-pysnmp4-4.4.3/debian/.git-dpm --- python-pysnmp4-4.3.2/debian/.git-dpm 2016-07-17 05:28:27.000000000 +0000 +++ python-pysnmp4-4.4.3/debian/.git-dpm 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -# see git-dpm(1) from git-dpm package -c2e3edc600b3c8548fdb0a9b919ef505b631411f -c2e3edc600b3c8548fdb0a9b919ef505b631411f -c4be338869467b796fd2fecff2c13ac8563ee08a -c4be338869467b796fd2fecff2c13ac8563ee08a -python-pysnmp4_4.3.2.orig.tar.gz -9060d4d80145828470e27bfca931880940f4b468 -398593 -debianTag="debian/%e%v" -patchedTag="patched/%e%v" -upstreamTag="upstream/%e%u" diff -Nru python-pysnmp4-4.3.2/debian/patches/0001-Do-not-include-analytics-in-documentation.patch python-pysnmp4-4.4.3/debian/patches/0001-Do-not-include-analytics-in-documentation.patch --- python-pysnmp4-4.3.2/debian/patches/0001-Do-not-include-analytics-in-documentation.patch 2016-07-17 05:28:27.000000000 +0000 +++ python-pysnmp4-4.4.3/debian/patches/0001-Do-not-include-analytics-in-documentation.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -From c2e3edc600b3c8548fdb0a9b919ef505b631411f Mon Sep 17 00:00:00 2001 -From: Vincent Bernat -Date: Sat, 2 Jul 2016 16:05:27 +0200 -Subject: Do not include analytics in documentation - ---- - docs/source/.templates/layout.html | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/docs/source/.templates/layout.html b/docs/source/.templates/layout.html -index 0f25e0e76b7e..bada42868146 100644 ---- a/docs/source/.templates/layout.html -+++ b/docs/source/.templates/layout.html -@@ -133,10 +133,7 @@ -
- {% include "breadcrumbs.html" %} -
-- {% include "top.html" %} - {% block body %}{% endblock %} -- {% include "bottom.html" %} -- {% include "analytics.html" %} -
-
- {% include "footer.html" %} diff -Nru python-pysnmp4-4.3.2/debian/patches/0001-Remove-privacy-breach-badges.patch python-pysnmp4-4.4.3/debian/patches/0001-Remove-privacy-breach-badges.patch --- python-pysnmp4-4.3.2/debian/patches/0001-Remove-privacy-breach-badges.patch 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/debian/patches/0001-Remove-privacy-breach-badges.patch 2017-12-31 13:08:51.000000000 +0000 @@ -0,0 +1,21 @@ +From: Vincent Bernat +Date: Sun, 31 Dec 2017 14:09:42 +0100 +Subject: Remove privacy-breach badges + +--- + docs/source/conf.py | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/docs/source/conf.py b/docs/source/conf.py +index 0fddca0..3df0c03 100644 +--- a/docs/source/conf.py ++++ b/docs/source/conf.py +@@ -122,8 +122,6 @@ html_theme_options = { + 'logo': 'logo.svg', + 'description': '

Brewing free software for the greater good

', + 'show_powered_by': False, +- 'github_user': 'etingof', +- 'github_repo': 'pysnmp', + 'fixed_sidebar': True, + } + diff -Nru python-pysnmp4-4.3.2/debian/patches/series python-pysnmp4-4.4.3/debian/patches/series --- python-pysnmp4-4.3.2/debian/patches/series 2016-07-17 05:28:27.000000000 +0000 +++ python-pysnmp4-4.4.3/debian/patches/series 2017-12-31 13:08:51.000000000 +0000 @@ -1 +1 @@ -0001-Do-not-include-analytics-in-documentation.patch +0001-Remove-privacy-breach-badges.patch diff -Nru python-pysnmp4-4.3.2/debian/watch python-pysnmp4-4.4.3/debian/watch --- python-pysnmp4-4.3.2/debian/watch 2016-07-17 05:28:27.000000000 +0000 +++ python-pysnmp4-4.4.3/debian/watch 2017-12-31 13:08:51.000000000 +0000 @@ -1,2 +1,4 @@ -version=3 -http://qa.debian.org/watch/sf.php/pysnmp/ pysnmp-(4.*).tar.gz +version=4 +opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%pysnmp-$1.tar.gz%" \ + https://github.com/etingof/pysnmp/tags \ + (?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate diff -Nru python-pysnmp4-4.3.2/devel-requirements.txt python-pysnmp4-4.4.3/devel-requirements.txt --- python-pysnmp4-4.3.2/devel-requirements.txt 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/devel-requirements.txt 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,3 @@ +sphinx +twisted +trollius; python_version < '3.0' diff -Nru python-pysnmp4-4.3.2/docs/mibs/PYSNMP-MIB.txt python-pysnmp4-4.4.3/docs/mibs/PYSNMP-MIB.txt --- python-pysnmp4-4.3.2/docs/mibs/PYSNMP-MIB.txt 2005-06-14 10:46:51.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/mibs/PYSNMP-MIB.txt 2017-12-22 11:53:40.000000000 +0000 @@ -8,15 +8,16 @@ MODULE-IDENTITY, enterprises FROM SNMPv2-SMI; pysnmp MODULE-IDENTITY - LAST-UPDATED "200505140000Z" - ORGANIZATION "pysnmp.sf.net" - CONTACT-INFO - "email: ilya@glas.net" + LAST-UPDATED "201704140000Z" + ORGANIZATION "The PySNMP Project" + CONTACT-INFO "E-mail: Ilya Etingof + GitHub: https://github.com/etingof/pysnmp" DESCRIPTION - "Top-level infrastructure of the PySNMP project enterprise MIB tree" + "PySNMP top-level MIB tree infrastructure" + REVISION "201704140000Z" + DESCRIPTION "Updated addresses" REVISION "200505140000Z" - DESCRIPTION - "Initial revision" + DESCRIPTION "Initial revision" ::= { enterprises 20408 } diff -Nru python-pysnmp4-4.3.2/docs/mibs/PYSNMP-SOURCE-MIB.txt python-pysnmp4-4.4.3/docs/mibs/PYSNMP-SOURCE-MIB.txt --- python-pysnmp4-4.3.2/docs/mibs/PYSNMP-SOURCE-MIB.txt 2015-01-20 16:58:01.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/mibs/PYSNMP-SOURCE-MIB.txt 2017-12-22 11:53:40.000000000 +0000 @@ -12,16 +12,18 @@ FROM PYSNMP-MIB; pysnmpSourceMIB MODULE-IDENTITY - LAST-UPDATED "201501160000Z" -- 16 January 2015, midnight - ORGANIZATION "SNMP Laboratories" - CONTACT-INFO "E-mail: info@snmplabs.com - Subscribe: pysnmp-users-request@lists.sourceforge.net" - DESCRIPTION - "This MIB module defines implementation specific objects - that provide variable source transport endpoints feature to - SNMP Engine and Applications." - REVISION "201501160000Z" -- 16 January 2015, midnight - DESCRIPTION "The Initial Revision" + LAST-UPDATED "201704140000Z" + ORGANIZATION "The PySNMP Project" + CONTACT-INFO "E-mail: Ilya Etingof + GitHub: https://github.com/etingof/pysnmp" + DESCRIPTION + "This MIB module defines implementation specific objects + that provide variable source transport endpoints feature to + SNMP Engine and Standard SNMP Applications." + REVISION "201704140000Z" + DESCRIPTION "Updated addresses" + REVISION "201501160000Z" -- 16 January 2015, midnight + DESCRIPTION "Initial Revision" ::= { pysnmpModuleIDs 8 } -- Administrative assignments **************************************** diff -Nru python-pysnmp4-4.3.2/docs/mibs/PYSNMP-USM-MIB.txt python-pysnmp4-4.4.3/docs/mibs/PYSNMP-USM-MIB.txt --- python-pysnmp4-4.3.2/docs/mibs/PYSNMP-USM-MIB.txt 2005-12-16 17:00:30.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/mibs/PYSNMP-USM-MIB.txt 2017-12-22 11:53:40.000000000 +0000 @@ -14,15 +14,19 @@ FROM PYSNMP-MIB; pysnmpUsmMIB MODULE-IDENTITY - LAST-UPDATED "200505140000Z" -- 14 May 2005, midnight - ORGANIZATION "The PySNMP project" - CONTACT-INFO "E-mail: ilya@glas.net - Subscribe: pysnmp-users-request@lists.sourceforge.net" - DESCRIPTION - "This MIB module defines objects specific to User - Security Model (USM) implementation at PySNMP." - REVISION "200505140000Z" -- 14 May 2005, midnight - DESCRIPTION "The Initial Revision" + LAST-UPDATED "201704140000Z" + ORGANIZATION "The PySNMP Project" + CONTACT-INFO "E-mail: Ilya Etingof + GitHub: https://github.com/etingof/pysnmp" + DESCRIPTION + "This MIB module defines objects specific to User + Security Model (USM) implementation at PySNMP." + REVISION "201707300000Z" + DESCRIPTION "Extended authentication key size" + REVISION "201704140000Z" + DESCRIPTION "Updated addresses" + REVISION "200505140000Z" -- 14 May 2005, midnight + DESCRIPTION "The Initial Revision" ::= { pysnmpModuleIDs 1 } -- Administrative assignments **************************************** @@ -151,7 +155,7 @@ } pysnmpUsmKeyAuthLocalized OBJECT-TYPE - SYNTAX OCTET STRING (SIZE(8..32)) + SYNTAX OCTET STRING (SIZE(8..64)) MAX-ACCESS not-accessible STATUS current DESCRIPTION @@ -159,7 +163,7 @@ ::= { pysnmpUsmKeyEntry 1 } pysnmpUsmKeyPrivLocalized OBJECT-TYPE - SYNTAX OCTET STRING (SIZE(8..32)) + SYNTAX OCTET STRING (SIZE(8..64)) MAX-ACCESS not-accessible STATUS current DESCRIPTION @@ -167,7 +171,7 @@ ::= { pysnmpUsmKeyEntry 2 } pysnmpUsmKeyAuth OBJECT-TYPE - SYNTAX OCTET STRING (SIZE(8..32)) + SYNTAX OCTET STRING (SIZE(8..64)) MAX-ACCESS not-accessible STATUS current DESCRIPTION @@ -175,7 +179,7 @@ ::= { pysnmpUsmKeyEntry 3 } pysnmpUsmKeyPriv OBJECT-TYPE - SYNTAX OCTET STRING (SIZE(8..32)) + SYNTAX OCTET STRING (SIZE(8..64)) MAX-ACCESS not-accessible STATUS current DESCRIPTION diff -Nru python-pysnmp4-4.3.2/docs/README.txt python-pysnmp4-4.4.3/docs/README.txt --- python-pysnmp4-4.3.2/docs/README.txt 2015-11-13 17:21:55.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/README.txt 2017-12-22 11:53:40.000000000 +0000 @@ -2,7 +2,7 @@ Better run: -# pip sphinx +# pip install sphinx and once Sphinx is installed on your system, run: diff -Nru python-pysnmp4-4.3.2/docs/source/conf.py python-pysnmp4-4.4.3/docs/source/conf.py --- python-pysnmp4-4.3.2/docs/source/conf.py 2015-11-13 17:21:55.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/conf.py 2017-12-22 11:53:40.000000000 +0000 @@ -32,9 +32,7 @@ extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.napoleon', - 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', - 'sphinx.ext.todo' ] # Add any paths that contain templates here, relative to this directory. @@ -52,18 +50,18 @@ master_doc = 'contents' # General information about the project. -project = u'PySNMP' -copyright = u'2015, Ilya Etingof ' -author = u'Ilya Etingof ' +project = u'SNMP library for Python' +copyright = u'2005-2017, Ilya Etingof ' +author = u'Ilya Etingof ' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '4.3' +version = '4.4' # The full version, including alpha/beta/rc tags. -release = '4.3' +release = '4.4' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -107,20 +105,37 @@ #keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True +#todo_include_todos = True # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -#html_theme = 'alabaster' -html_theme = 'sphinx_rtd_theme' +html_theme = 'alabaster' +#html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +html_theme_options = { + 'logo': 'logo.svg', + 'description': '

Brewing free software for the greater good

', + 'show_powered_by': False, + 'github_user': 'etingof', + 'github_repo': 'pysnmp', + 'fixed_sidebar': True, +} + +html_sidebars = { + '**': [ + 'about.html', + 'navigation.html', + 'relations.html', + 'searchbox.html', + 'donate.html', + ] +} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] @@ -128,7 +143,7 @@ # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None -html_title = "PySNMP" +#html_title = "PySNMP" # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None @@ -140,17 +155,12 @@ # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +html_favicon = '.static/favicon.ico' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -if 'PYSNMPDEV' in os.environ: - html_static_path = ['.static'] - -# Custom CSS theme -if 'PYSNMPDEV' in os.environ: - html_style = 'css/rtdimproved.css' +html_static_path = ['.static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied @@ -236,7 +246,7 @@ # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'PySNMP.tex', u'PySNMP Documentation', - u'Ilya Etingof \\textless{}ilya@glas.net\\textgreater{}', 'manual'), + u'Ilya Etingof \\textless{}etingof@gmail.com\\textgreater{}', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -297,10 +307,13 @@ #texinfo_no_detailmenu = False -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { 'python': ('https://docs.python.org/3.4/', None), - 'pysmi': ('http://pysmi.sf.net/', None), - 'twisted': ('https://twistedmatrix.com/documents/15.4.0/api/', None) } +# Configuration for Intersphinx +intersphinx_mapping = { + 'python': ('https://docs.python.org/3.4/', None), + 'pyasn1': ('http://snmplabs.com/pyasn1/', None), + 'pysmi': ('http://snmplabs.com/pysmi/', None), + 'twisted': ('https://twistedmatrix.com/documents/15.4.0/api/', None) +} # this merges constructor docstring with class docstring autoclass_content = 'both' diff -Nru python-pysnmp4-4.3.2/docs/source/contents.rst python-pysnmp4-4.4.3/docs/source/contents.rst --- python-pysnmp4-4.3.2/docs/source/contents.rst 2016-02-13 19:38:13.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/contents.rst 2017-12-22 11:53:40.000000000 +0000 @@ -11,17 +11,17 @@ to act in Agent/Manager/Proxy roles, talking SNMP v1/v2c/v3 protocol versions over IPv4/IPv6 and other network transports. -Despite its name, SNMP is not a really simple protocol. For instance its +Despite its name, SNMP is not really a simple protocol. For instance its third version introduces complex and open-ended security framework, multilingual capabilities, remote configuration and other features. PySNMP implementation closely follows intricate system details and features bringing most possible power and flexibility to its users. -Current PySNMP stable version is 4.3. It runs with Python 2.4 through 3.5 -and is recommended for new applications as well as for migration from older, -now obsolete, PySNMP releases. All site documentation and examples are written -for the 4.3 and later versions in mind. Older materials are still -available under the obsolete section. +Current PySNMP stable version is 4.4. It runs with Python 2.4 through 3.6 +and is recommended for new applications as well as for migration from +older, now obsolete, PySNMP releases. All site documentation and +examples are written for the 4.4 and later versions in mind. +Older materials are still available under the obsolete section. Besides the libraries, a set of pure-Python `command-line tools `_ @@ -30,8 +30,11 @@ They may be useful in a cross-platform situations as well as a testing and prototyping instrument for pysnmp users. -PySNMP software is free and open-source. It's being distributed under a -liberal BSD-style license. PySNMP development has been initially sponsored +PySNMP software is free and open-source. Source code is hosted in +a `Github repo `_. +The library is being distributed under 2-clause BSD-style license. + +PySNMP library development has been initially sponsored by a `PSF `_ grant. Quick start @@ -40,10 +43,10 @@ You already know something about SNMP and have no courage to dive into this implementation? Try out quick start page! - .. toctree:: - :maxdepth: 2 +.. toctree:: + :maxdepth: 2 - /quick-start + /quick-start Documentation ------------- @@ -57,10 +60,10 @@ Examples -------- - .. toctree:: - :maxdepth: 2 +.. toctree:: + :maxdepth: 2 - /examples/contents + /examples/contents Download -------- @@ -74,26 +77,26 @@ If that does not work for you for some reason, you might need to read the following page. - .. toctree:: - :maxdepth: 2 +.. toctree:: + :maxdepth: 2 - /download + /download License ------- - .. toctree:: - :maxdepth: 2 +.. toctree:: + :maxdepth: 2 - /license + /license FAQ --- - .. toctree:: - :maxdepth: 2 +.. toctree:: + :maxdepth: 2 - /faq + /faq Further development ------------------- @@ -102,32 +105,30 @@ There you could also download the latest unreleased pysnmp tarball containing the latest fixes and improvements. - .. toctree:: - :maxdepth: 1 +.. toctree:: + :maxdepth: 1 - /changelog + /changelog Our development plans and new features we consider for eventual implementation are collected in the following section. - .. toctree:: - :maxdepth: 2 +.. toctree:: + :maxdepth: 2 - /development + /development Contact ------- -Please, use our -`mailing list `_ -or refer to -`Stack Overflow `_ -should you have any questions or issues in regards to PySNMP. +In case of questions or troubles using PySNMP, please open up an +`issue `_ at GitHub or ask at +`Stack Overflow `_ . Old site archive ---------------- - .. toctree:: - :maxdepth: 2 +.. toctree:: + :maxdepth: 2 - /oldsite + /oldsite diff -Nru python-pysnmp4-4.3.2/docs/source/development.rst python-pysnmp4-4.4.3/docs/source/development.rst --- python-pysnmp4-4.3.2/docs/source/development.rst 2015-09-14 05:39:35.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/development.rst 2017-12-22 11:53:40.000000000 +0000 @@ -11,17 +11,17 @@ PySNMP library ++++++++++++++ -#. Built-in MIB parser. PySNMP uses a data model of its own to work with - information contained in MIB files. To convert ASN.1-based MIB texts - into Python modules, an off-line, third-party tool is employed. As it - turns out, this approach has two major drawback: one is that PySNMP - users may need to pre-process MIB texts to use them with their - PySNMP-based applications. Another is that LibSMI's Python driver - seems to miss some information carried by MIBs. Thus the solution would - be to write another MIB parser and code generator which would produce +#. Built-in MIB parser. PySNMP uses a data model of its own to work with + information contained in MIB files. To convert ASN.1-based MIB texts + into Python modules, an off-line, third-party tool is employed. As it + turns out, this approach has two major drawback: one is that PySNMP + users may need to pre-process MIB texts to use them with their + PySNMP-based applications. Another is that LibSMI's Python driver + seems to miss some information carried by MIBs. Thus the solution would + be to write another MIB parser and code generator which would produce PySNMP compliant Python code right from MIB text files all by itself. - **Done:** see `PySMI project `_ in conjuction with the latest PySNMP codebase. + **Done:** see `PySMI project `_ in conjuction with the latest PySNMP codebase. #. Reverse MIB index. The variable-bindings received by the system whilst in Manager role could be post-processed using the information kept in @@ -54,7 +54,6 @@ SMI/MIB subsystem into a database. PySNMP engine would talk to it through its simple and well defined SMI API. - Stand-alone PySNMP-based tools ++++++++++++++++++++++++++++++ @@ -64,7 +63,7 @@ include extensive configuration facilities, fine-graned access control and logging. - **Done:** see `SNMP Proxy Forwarder `_. + **Done:** see `SNMP Proxy Forwarder `_. #. SNMP Trap Receiver. We see this application as a simple yet flexible SNMP TRAP collector. It would listen on network sockets of different @@ -82,10 +81,10 @@ a relational database application. So we are planning to put some more efforts into the Simulator project as time permits. - **Done:** since `snmpsim-0.2.4 `_ + **Done:** since `snmpsim-0.2.4 `_ If you need some particular feature - please, -`drop us a note `_ . Once we +`open a feature request `_ . Once we see a greater demand in particular area, we would re-arrange our development resources to meet it sooner. @@ -94,7 +93,7 @@ Contributions to the PySNMP source code is greatly appreciated as well. We require contributed code to run with Python 2.4 through the latest -Python version (which is 3.3 at the time of this writing). Contributed +Python version (which is 3.6 at the time of this writing). Contributed code will be redistributed under the terms of the same -`license `_ as PySNMP is. +`license `_ as PySNMP is. diff -Nru python-pysnmp4-4.3.2/docs/source/docs/api-reference.rst python-pysnmp4-4.4.3/docs/source/docs/api-reference.rst --- python-pysnmp4-4.3.2/docs/source/docs/api-reference.rst 2015-11-08 21:22:15.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/docs/api-reference.rst 2017-12-22 11:53:40.000000000 +0000 @@ -54,7 +54,10 @@ :maxdepth: 2 .. autoclass:: pysnmp.hlapi.UdpTransportTarget + :members: setLocalAddress + .. autoclass:: pysnmp.hlapi.Udp6TransportTarget + :members: setLocalAddress Asynchronous: asyncore ---------------------- @@ -87,7 +90,10 @@ :maxdepth: 2 .. autoclass:: pysnmp.hlapi.asyncore.UdpTransportTarget + :members: setLocalAddress + .. autoclass:: pysnmp.hlapi.asyncore.Udp6TransportTarget + :members: setLocalAddress Asynchronous: asyncio --------------------- @@ -121,7 +127,10 @@ :maxdepth: 2 .. autoclass:: pysnmp.hlapi.asyncio.UdpTransportTarget + :members: setLocalAddress + .. autoclass:: pysnmp.hlapi.asyncio.Udp6TransportTarget + :members: setLocalAddress Asynchronous: trollius ---------------------- @@ -166,6 +175,7 @@ :maxdepth: 2 .. autoclass:: pysnmp.hlapi.twisted.UdpTransportTarget + :members: setLocalAddress SNMP Engine ----------- @@ -215,6 +225,10 @@ .. autodata:: pysnmp.hlapi.usmNoAuthProtocol .. autodata:: pysnmp.hlapi.usmHMACMD5AuthProtocol .. autodata:: pysnmp.hlapi.usmHMACSHAAuthProtocol +.. autodata:: pysnmp.hlapi.usmHMAC128SHA224AuthProtocol +.. autodata:: pysnmp.hlapi.usmHMAC192SHA256AuthProtocol +.. autodata:: pysnmp.hlapi.usmHMAC256SHA384AuthProtocol +.. autodata:: pysnmp.hlapi.usmHMAC384SHA512AuthProtocol .. autodata:: pysnmp.hlapi.usmNoPrivProtocol .. autodata:: pysnmp.hlapi.usmDESPrivProtocol @@ -222,6 +236,8 @@ .. autodata:: pysnmp.hlapi.usmAesCfb128Protocol .. autodata:: pysnmp.hlapi.usmAesCfb192Protocol .. autodata:: pysnmp.hlapi.usmAesCfb256Protocol +.. autodata:: pysnmp.hlapi.usmAesBlumenthalCfb192Protocol +.. autodata:: pysnmp.hlapi.usmAesBlumenthalCfb256Protocol Transport configuration is I/O framework specific and is described in respective sections. @@ -230,16 +246,28 @@ ------------ SNMP engine may serve several instances of the same MIB within -possibly multiple SNMP entities. SNMP context is a method to -unambiguously identify a collection of MIB variables behind +possibly multiple SNMP entities. SNMP context is a tool for +unambiguously identifying a collection of MIB variables behind the SNMP engine. See :RFC:`3411#section-3.3.1` for details. .. note:: - SNMP context is only defined within SNMPv3 framework. For SNMPv1/v2c - architecture integration :RFC:`2576#section-5.1` introduces - interoperability aid which is available through - :py:class:`~pysnmp.hlapi.CommunityData`. + The SNMP context information is not tied to SNMPv3/USM user, + but it is transferred in SNMPv3 message header. + + Legacy SNMPv1/v2c protocols do not accommodate the SNMP context + information at all. + + To fit legacy SNMPv1/SNMPv2c systems into unified SNMPv3 + architecture, the mapping procedure is introduced by + :RFC:`2576#section-5.1` which essentially lets you first configure + and then supply the missing items (e.g. *contextName*, + *contextEngineId* and other) to the upper layers of SNMP stack + based on SNMPv1/v2c *communityName* and transport endpoint. + + The SNMP context information necessary for this mapping procedure + to operate is supplied through the + :py:class:`~pysnmp.hlapi.CommunityData` object. .. toctree:: :maxdepth: 2 @@ -301,7 +329,7 @@ of SNMP types (:RFC:`1902#section-2`) which, in turn, are based on `ASN.1 `_ data description language. PySNMP types are derived from -`Python ASN.1 types `_ implementation. +`Python ASN.1 types `_ implementation. .. toctree:: :maxdepth: 2 diff -Nru python-pysnmp4-4.3.2/docs/source/docs/pysnmp-hlapi-tutorial.rst python-pysnmp4-4.4.3/docs/source/docs/pysnmp-hlapi-tutorial.rst --- python-pysnmp4-4.3.2/docs/source/docs/pysnmp-hlapi-tutorial.rst 2015-11-12 20:09:07.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/docs/pysnmp-hlapi-tutorial.rst 2017-12-22 11:53:40.000000000 +0000 @@ -45,7 +45,6 @@ ['bulkCmd', 'getCmd', 'nextCmd', 'setCmd'] >>> getCmd - >>> g = getCmd( Choosing SNMP protocol and credentials -------------------------------------- @@ -101,7 +100,7 @@ PySNMP supports UDP-over-IPv4 and UDP-over-IPv6 network transports. In this example we will query -`public SNMP Simulator `_ +`public SNMP Simulator `_ available over IPv4 on the Internet at *demo.snmplabs.com*. Transport configuration is passed to SNMP LCD in form of properly initialized :py:class:`~pysnmp.hlapi.UdpTransportTarget` or @@ -215,7 +214,9 @@ The trailing zero is an indication of MIB object *instance*. Objects described in MIBs are just declarations, they never contain any data. -Data is stored in MIB object instances that are addressed by appending +Data is stored in MIB object instances addressed by appending extra +information (known as *index*) to MIB object identifiers. + For scalar MIB objects index is '0' by convention. The *ObjectIdentity* class takes indices as its initializers. @@ -240,7 +241,7 @@ By default PySNMP will search your local filesystem for ASN.1 MIB files you refer to. It can also be configured to automatically download -them from remove hosts, as +them from remote hosts, as :doc:`shown ` in the examples. We maintain a `collection `_ of ASN.1 MIB modules @@ -252,10 +253,10 @@ We are finally in a position to send SNMP query and hopefully receive something meaningful in response. -The distinctive feature of synchronous API is that it is build around +The distinctive feature of synchronous API is that it is built around the idea of Python generator. Any function invocation ends up with a generator object. Iteration over the generator object performs actual -SNMP communication. On each iteration SNMP message gets build and send +SNMP communication. On each iteration SNMP message gets built and sent out, response is awaited, received and parsed. .. code-block:: python @@ -556,7 +557,7 @@ ... NotificationType(ObjectIdentity('IF-MIB', 'linkUp'), instanceIndex=(123,)) ... ) >>> next(g) - (None, 0, 0, [ObjectType(ObjectIdentity('1.3.6.1.2.1.1.3.0'), TimeTicks(0)), ObjectType(ObjectIdentity('1.3.6.1.6.3.1.1.4.1.0'), ObjectIdentity('1.3.6.1.6.3.1.1.5.4')), ObjectType(ObjectName('1.3.6.1.2.1.2.2.1.1.123'), Null()), ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.7.123'), Null()), ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.8.123'), Null())]) + (None, 0, 0, [ObjectType(ObjectIdentity('1.3.6.1.2.1.1.3.0'), TimeTicks(0)), ObjectType(ObjectIdentity('1.3.6.1.6.3.1.1.4.1.0'), ObjectIdentity('1.3.6.1.6.3.1.1.5.4')), ObjectType(ObjectName('1.3.6.1.2.1.2.2.1.1.123'), Null('')), ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.7.123'), Null('')), ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.8.123'), Null(''))]) In the latter example you can see MIB objects (ifIndex, ifAdminStatus, ifOperStatus) being automatically expanded from IF-MIB::linkUp notification. diff -Nru python-pysnmp4-4.3.2/docs/source/docs/snmp-design.rst python-pysnmp4-4.4.3/docs/source/docs/snmp-design.rst --- python-pysnmp4-4.3.2/docs/source/docs/snmp-design.rst 2015-11-10 21:46:54.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/docs/snmp-design.rst 2017-12-22 11:53:40.000000000 +0000 @@ -98,14 +98,14 @@ In addition to these scalar types, SNMP defines a way to collect them into ordered arrays. From these arrays 2-d tables could be built. -PySNMP relies on the `PyASN1 `_ package for +PySNMP relies on the `PyASN1 `_ package for modeling all SNMP types. With PyASN1, instances of ASN.1 types are represented by Python objects that look like either a string or an integer. We can convert PyASN1 objects into Python types and back. PyASN1 -objects can participate in basic arethmetic operations (numbers) -or in operations with strings (concatination, subscrption etc). +objects can participate in basic arithmetic operations (numbers) +or in operations with strings (concatenation, subscription etc). All SNMP base types are immutable like their Python counterparts. .. code-block:: python @@ -198,7 +198,7 @@ definitions written in the MIB. So, the available data is actually not dependent on the database, but on the implementation. It is important to realize that MIB files never contain data, they are functionally -similar to database schemas rather than datastores. +similar to database schemas rather than data stores. To organize MIB modules and objects properly, all the manageable features of all products (from each vendor) are arranged in this MIB @@ -229,7 +229,7 @@ MIB convertion is performed automatically by PySNMP, but technically, it is handled by PySNMP sister project called -`PySMI `_. However you can also perform said +`PySMI `_. However you can also perform said conversion by hand with PySMI's *mibdump.py* tool. Protocol operations diff -Nru python-pysnmp4-4.3.2/docs/source/docs/snmp-history.rst python-pysnmp4-4.4.3/docs/source/docs/snmp-history.rst --- python-pysnmp4-4.3.2/docs/source/docs/snmp-history.rst 2015-11-08 21:22:15.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/docs/snmp-history.rst 2017-12-22 11:53:40.000000000 +0000 @@ -86,14 +86,14 @@ ----------------------- As for current SNMP deployment, its virtually impossible to estimate -how many SNMP-enabled devices run on the modern Internet. One can -possibly argue that SNMP monitors the all the Internet nowdays. +how many SNMP-enabled devices run on the modern Internet today. +For example, every home router and most of the desktop printers have +embedded SNMP agent inside. -You may found SNMP useful for your home network monitoring or -management needs. For instance you could easily setup an open source -network monitoring application to watch, collect and graph bandwidth -utilization at your Wi-Fi router for you home network (that helps -spotting bottlenecks). +Expanding on that, you may found SNMP useful for your home network monitoring. +For instance you could easily setup an open source network monitoring +application to watch, collect and graph bandwidth utilization of your +home Wi-Fi router. A significant innovation might be coming in the following years. And that is Internet of Things. All those small and low-power gadgets need to @@ -101,5 +101,5 @@ technology. Almost three decades ago SNMP was designed for heavily resource-constrained computers of that time. Later on the computers grew in power and resources. But now we are back to building a massive -amount of low-power computers for "things" and original SNMP lightweightness -can serve us again! +amount of low-power computers for "things" where original lightweight +and well-understood SNMP can serve us again! diff -Nru python-pysnmp4-4.3.2/docs/source/download.rst python-pysnmp4-4.4.3/docs/source/download.rst --- python-pysnmp4-4.3.2/docs/source/download.rst 2015-10-16 16:50:39.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/download.rst 2017-12-22 11:53:40.000000000 +0000 @@ -5,13 +5,14 @@ :maxdepth: 2 The PySNMP software is provided under terms and conditions of BSD-style -license, and can be freely downloaded from Source Forge -`download servers `_ or -`PyPI `_. +license, and can be freely downloaded from +`PyPI `_ or +GitHub (`master branch `_). + Besides official releases, it's advisable to try the cutting-edge development code that could be taken from PySNMP -`source code repository `_. +`source code repository `_. It may be less stable in regards to general operation and changes to public interfaces, but it's first to contain fixes to recently discovered bugs. @@ -30,11 +31,11 @@ In case you do not have the easy_install command on your system but still would like to use the on-line package installation method, please install `setuptools `_ package by -downloading and running `ez_setup.pz `_ bootstrap: +downloading and running `ez_setup.pz `_ bootstrap: .. code-block:: bash - # wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py + # wget https://bootstrap.pypa.io/ez_setup.py # python ez_setup.py In case you are installing PySNMP on an off-line system, the following @@ -48,9 +49,8 @@ Optional, but recommended: -* `PyCrypto `_, - used by SNMPv3 crypto features (Windows users need - `precompiled version `_) +* `PyCryptodomex `_, + used by SNMPv3 crypto features * `PySMI `_ for automatic MIB download and compilation. That helps visualizing more SNMP objects * `Ply `_, parser generator @@ -67,6 +67,6 @@ # cd .. # rm -rf package-X.X.X -In case of any issues, please `let us know `_ so we could try to help out. +In case of any issues, please open a `GitHub issue `_ so we could try to help out. diff -Nru python-pysnmp4-4.3.2/docs/source/examples/contents.rst python-pysnmp4-4.4.3/docs/source/examples/contents.rst --- python-pysnmp4-4.3.2/docs/source/examples/contents.rst 2016-02-13 19:38:13.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/contents.rst 2017-12-22 11:53:40.000000000 +0000 @@ -5,12 +5,12 @@ .. toctree:: :maxdepth: 2 -SNMP is not really simple (PySNMP implementation takes over 15K lines of -Python code), but PySNMP tries to isolate the complexities and let you -perform typical SNMP operations in a quick and intuitive way. +SNMP is not simple (PySNMP implementation takes over 15K lines of +Python code), but PySNMP tries to hide the complexities and let you +carry out typical SNMP operations in a quick and intuitive way. PySNMP offers three groups of programming interfaces to deal with -SNMP protocol. In the order from most consice to most detailed those +SNMP protocol. In the order from most concise to most detailed those APIs follow. High-level SNMP @@ -24,7 +24,7 @@ It comes in several flavours: one synchronous and a bunch of bindings to popular asynchronous I/O frameworks. Those varieties of APIs bring subtile differences, mostly to better match particular I/O framework -customs. Unless you have a vary specific task, one of high-level APIs might +customs. Unless you have a very specific task, the high-level API might solve your SNMP needs. .. toctree:: @@ -116,6 +116,15 @@ /examples/v1arch/asyncore/manager/ntfrcv/transport-tweaks +Low-level MIB access +-------------------- + +.. toctree:: + + /examples/smi/manager/browsing-mib-tree + /examples/smi/agent/implementing-mib-objects + + Using these examples -------------------- @@ -127,7 +136,7 @@ There's a public, multilingual SNMP Command Responder and Notification Receiver configured at -`demo.snmplabs.com `_ to let you run PySNMP examples scripts in a cut&paste fashion. If you +`demo.snmplabs.com `_ to let you run PySNMP examples scripts in a cut&paste fashion. If you wish to use your own SNMP Agent with these scripts, make sure to either configure your local snmpd and/or snmptrapd or use a valid address and SNMP credentials of your SNMP Agent in the examples to let them work. @@ -147,7 +156,7 @@ from pysnmp import debug # use specific flags or 'all' for full debugging - debug.setLogger(debug.Debug('dsp', 'msgproc', 'secmode')) + debug.setLogger(debug.Debug('dsp', 'msgproc', 'secmod')) Then run your app and watch stderr. The Debug initializer enables debugging for a particular PySNMP subsystem, 'all' enables full debugging. More diff -Nru python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncio/manager/cmdgen/advanced-topics.rst python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncio/manager/cmdgen/advanced-topics.rst --- python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncio/manager/cmdgen/advanced-topics.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncio/manager/cmdgen/advanced-topics.rst 2017-12-22 11:53:40.000000000 +0000 @@ -4,15 +4,15 @@ Advanced Command Generator -------------------------- -.. include:: /../../examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py +.. include:: /../../examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py +.. literalinclude:: /../../examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. .. include:: /../../examples/hlapi/asyncio/manager/cmdgen/multiple-sequential-queries.py diff -Nru python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncore/manager/cmdgen/advanced-topics.rst python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncore/manager/cmdgen/advanced-topics.rst --- python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncore/manager/cmdgen/advanced-topics.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncore/manager/cmdgen/advanced-topics.rst 2017-12-22 11:53:40.000000000 +0000 @@ -4,37 +4,37 @@ Advanced Command Generator -------------------------- -.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py +.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once-over-ipv4-and-ipv6.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py +.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once-over-ipv4-and-ipv6.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. -.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py +.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines-over-ipv4-and-ipv6.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py +.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines-over-ipv4-and-ipv6.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. -.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py +.. include:: /../../examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py +.. literalinclude:: /../../examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. See also: :doc:`library reference `. diff -Nru python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncore/sync/agent/ntforg/common-notifications.rst python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncore/sync/agent/ntforg/common-notifications.rst --- python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncore/sync/agent/ntforg/common-notifications.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncore/sync/agent/ntforg/common-notifications.rst 2017-12-22 11:53:40.000000000 +0000 @@ -4,15 +4,15 @@ Common notifications -------------------- -.. include:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py +.. include:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py +.. literalinclude:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. .. include:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v3-inform.py @@ -36,18 +36,6 @@ :download:`Download` script. - -.. include:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py - :start-after: """ - :end-before: """# - -.. literalinclude:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py - :start-after: """# - :language: python - -:download:`Download` script. - - .. include:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v3-trap.py :start-after: """ :end-before: """# diff -Nru python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncore/sync/agent/ntforg/evaluating-notification-type.rst python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncore/sync/agent/ntforg/evaluating-notification-type.rst --- python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncore/sync/agent/ntforg/evaluating-notification-type.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncore/sync/agent/ntforg/evaluating-notification-type.rst 2017-12-22 11:53:40.000000000 +0000 @@ -4,15 +4,15 @@ Evaluating NOTIFICATION-TYPE ---------------------------- -.. include:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py +.. include:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py +.. literalinclude:: /../../examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. .. include:: /../../examples/hlapi/asyncore/sync/agent/ntforg/send-notification-with-additional-varbinds.py diff -Nru python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/advanced-topics.rst python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/advanced-topics.rst --- python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/advanced-topics.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/advanced-topics.rst 2017-12-22 11:53:40.000000000 +0000 @@ -70,15 +70,15 @@ :download:`Download` script. -.. include:: /../../examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py +.. include:: /../../examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads-over-ipv4-and-ipv6.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py +.. literalinclude:: /../../examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads-over-ipv4-and-ipv6.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. See also: :doc:`library reference `. diff -Nru python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/table-operations.rst python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/table-operations.rst --- python-pysnmp4-4.3.2/docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/table-operations.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/table-operations.rst 2017-12-22 11:53:40.000000000 +0000 @@ -25,15 +25,15 @@ :download:`Download` script. -.. include:: /../../examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py +.. include:: /../../examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables-over-ipv6.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py +.. literalinclude:: /../../examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables-over-ipv6.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. .. include:: /../../examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-snmp-table.py diff -Nru python-pysnmp4-4.3.2/docs/source/examples/hlapi/twisted/agent/ntforg/common-notifications.rst python-pysnmp4-4.4.3/docs/source/examples/hlapi/twisted/agent/ntforg/common-notifications.rst --- python-pysnmp4-4.3.2/docs/source/examples/hlapi/twisted/agent/ntforg/common-notifications.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/hlapi/twisted/agent/ntforg/common-notifications.rst 2017-12-22 11:53:40.000000000 +0000 @@ -14,4 +14,14 @@ :download:`Download` script. +.. include:: /../../examples/hlapi/twisted/agent/ntforg/v2c-trap-inline-callbacks.py + :start-after: """ + :end-before: """# + +.. literalinclude:: /../../examples/hlapi/twisted/agent/ntforg/v2c-trap-inline-callbacks.py + :start-after: """# + :language: python + +:download:`Download` script. + See also: :doc:`library reference `. diff -Nru python-pysnmp4-4.3.2/docs/source/examples/smi/agent/implementing-mib-objects.rst python-pysnmp4-4.4.3/docs/source/examples/smi/agent/implementing-mib-objects.rst --- python-pysnmp4-4.3.2/docs/source/examples/smi/agent/implementing-mib-objects.rst 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/smi/agent/implementing-mib-objects.rst 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,29 @@ +.. toctree:: + :maxdepth: 2 + +Agent side +---------- + +.. include:: /../../examples/smi/agent/custom-managed-object.py + :start-after: """ + :end-before: """# + +.. literalinclude:: /../../examples/smi/agent/custom-managed-object.py + :start-after: """# + :language: python + +:download:`Download` script. + + +.. include:: /../../examples/smi/agent/operations-on-managed-objects.py + :start-after: """ + :end-before: """# + +.. literalinclude:: /../../examples/smi/agent/operations-on-managed-objects.py + :start-after: """# + :language: python + +:download:`Download` script. + + +See also: :doc:`library reference `. diff -Nru python-pysnmp4-4.3.2/docs/source/examples/smi/manager/browsing-mib-tree.rst python-pysnmp4-4.4.3/docs/source/examples/smi/manager/browsing-mib-tree.rst --- python-pysnmp4-4.3.2/docs/source/examples/smi/manager/browsing-mib-tree.rst 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/smi/manager/browsing-mib-tree.rst 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,41 @@ +.. toctree:: + :maxdepth: 2 + +Manager side +------------ + +.. include:: /../../examples/smi/manager/configure-mib-viewer-and-resolve-pdu-varbinds.py + :start-after: """ + :end-before: """# + +.. literalinclude:: /../../examples/smi/manager/configure-mib-viewer-and-resolve-pdu-varbinds.py + :start-after: """# + :language: python + +:download:`Download` script. + + +.. include:: /../../examples/smi/manager/convert-between-pdu-varbinds-and-mib-objects.py + :start-after: """ + :end-before: """# + +.. literalinclude:: /../../examples/smi/manager/convert-between-pdu-varbinds-and-mib-objects.py + :start-after: """# + :language: python + +:download:`Download` script. + + + +.. include:: /../../examples/smi/manager/mib-tree-inspection.py + :start-after: """ + :end-before: """# + +.. literalinclude:: /../../examples/smi/manager/mib-tree-inspection.py + :start-after: """# + :language: python + +:download:`Download` script. + + +See also: :doc:`library reference `. diff -Nru python-pysnmp4-4.3.2/docs/source/examples/v1arch/asyncore/agent/cmdrsp/agent-side-mib-implementations.rst python-pysnmp4-4.4.3/docs/source/examples/v1arch/asyncore/agent/cmdrsp/agent-side-mib-implementations.rst --- python-pysnmp4-4.3.2/docs/source/examples/v1arch/asyncore/agent/cmdrsp/agent-side-mib-implementations.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/v1arch/asyncore/agent/cmdrsp/agent-side-mib-implementations.rst 2017-12-22 11:53:40.000000000 +0000 @@ -4,15 +4,15 @@ Agent-side MIB implementations ------------------------------ -.. include:: /../../examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py +.. include:: /../../examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects-over-ipv4-and-ipv6.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py +.. literalinclude:: /../../examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects-over-ipv4-and-ipv6.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. See also: :doc:`library reference `. diff -Nru python-pysnmp4-4.3.2/docs/source/examples/v3arch/asyncore/agent/ntforg/evaluating-notification-type.rst python-pysnmp4-4.4.3/docs/source/examples/v3arch/asyncore/agent/ntforg/evaluating-notification-type.rst --- python-pysnmp4-4.3.2/docs/source/examples/v3arch/asyncore/agent/ntforg/evaluating-notification-type.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/v3arch/asyncore/agent/ntforg/evaluating-notification-type.rst 2017-12-22 11:53:40.000000000 +0000 @@ -13,15 +13,15 @@ set of OIDs into PDU. PySNMP offers this facility through NotificationType class. -.. include:: /../../examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py +.. include:: /../../examples/v3arch/asyncore/agent/ntforg/v2c-trap-with-notification-objects.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py +.. literalinclude:: /../../examples/v3arch/asyncore/agent/ntforg/v2c-trap-with-notification-objects.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. See also: :doc:`library reference `. diff -Nru python-pysnmp4-4.3.2/docs/source/examples/v3arch/asyncore/manager/ntfrcv/advanced-topics.rst python-pysnmp4-4.4.3/docs/source/examples/v3arch/asyncore/manager/ntfrcv/advanced-topics.rst --- python-pysnmp4-4.3.2/docs/source/examples/v3arch/asyncore/manager/ntfrcv/advanced-topics.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/v3arch/asyncore/manager/ntfrcv/advanced-topics.rst 2017-12-22 11:53:40.000000000 +0000 @@ -4,15 +4,15 @@ Advanced topics --------------- -.. include:: /../../examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py +.. include:: /../../examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing-over-ipv4-and-ipv6.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py +.. literalinclude:: /../../examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing-over-ipv4-and-ipv6.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. .. include:: /../../examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py diff -Nru python-pysnmp4-4.3.2/docs/source/examples/v3arch/asyncore/manager/ntfrcv/transport-tweaks.rst python-pysnmp4-4.4.3/docs/source/examples/v3arch/asyncore/manager/ntfrcv/transport-tweaks.rst --- python-pysnmp4-4.3.2/docs/source/examples/v3arch/asyncore/manager/ntfrcv/transport-tweaks.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/v3arch/asyncore/manager/ntfrcv/transport-tweaks.rst 2017-12-22 11:53:40.000000000 +0000 @@ -15,15 +15,15 @@ :download:`Download` script. -.. include:: /../../examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py +.. include:: /../../examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports-incl-ipv4-and-ipv6.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py +.. literalinclude:: /../../examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports-incl-ipv4-and-ipv6.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. .. include:: /../../examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py diff -Nru python-pysnmp4-4.3.2/docs/source/examples/v3arch/asyncore/proxy/command/transport-conversion.rst python-pysnmp4-4.4.3/docs/source/examples/v3arch/asyncore/proxy/command/transport-conversion.rst --- python-pysnmp4-4.3.2/docs/source/examples/v3arch/asyncore/proxy/command/transport-conversion.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/examples/v3arch/asyncore/proxy/command/transport-conversion.rst 2017-12-22 11:53:40.000000000 +0000 @@ -4,15 +4,15 @@ Transport conversion -------------------- -.. include:: /../../examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py +.. include:: /../../examples/v3arch/asyncore/proxy/command/ipv6-to-ipv4-conversion.py :start-after: """ :end-before: """# -.. literalinclude:: /../../examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py +.. literalinclude:: /../../examples/v3arch/asyncore/proxy/command/ipv6-to-ipv4-conversion.py :start-after: """# :language: python -:download:`Download` script. +:download:`Download` script. See also: :doc:`library-reference `. diff -Nru python-pysnmp4-4.3.2/docs/source/faq/non-printable-snmp-values-apps.rst python-pysnmp4-4.4.3/docs/source/faq/non-printable-snmp-values-apps.rst --- python-pysnmp4-4.3.2/docs/source/faq/non-printable-snmp-values-apps.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/faq/non-printable-snmp-values-apps.rst 2017-12-22 11:53:40.000000000 +0000 @@ -35,6 +35,6 @@ > > > rfc1902.IpAddress.prettyPrint(a) '1.2.3.4' -See `pyasn1 tutorial `_ for more information +See `pyasn1 docs `_ for more information on pyasn1 data model. diff -Nru python-pysnmp4-4.3.2/docs/source/faq/non-printable-snmp-values-tools.rst python-pysnmp4-4.4.3/docs/source/faq/non-printable-snmp-values-tools.rst --- python-pysnmp4-4.3.2/docs/source/faq/non-printable-snmp-values-tools.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/faq/non-printable-snmp-values-tools.rst 2017-12-22 11:53:40.000000000 +0000 @@ -1,4 +1,4 @@ - + Garbaged SNMP values (tools) ---------------------------- diff -Nru python-pysnmp4-4.3.2/docs/source/faq/oids-not-increasing.rst python-pysnmp4-4.4.3/docs/source/faq/oids-not-increasing.rst --- python-pysnmp4-4.3.2/docs/source/faq/oids-not-increasing.rst 2015-09-14 05:45:34.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/faq/oids-not-increasing.rst 2017-12-22 11:53:40.000000000 +0000 @@ -1,29 +1,46 @@ -Dealing with OIDs not increasing error --------------------------------------- +Dealing with the "OID not increasing" error +------------------------------------------- -Q. I'm walking a particular Agent with the CommandGenerator.nextCmd() - and CommandGenerator.bulkCmd() methods. It works for some OIDs, but - invariably fails at certain OID with the 'OIDs are not increasing' - diagnostics. What does it mean and how do I fix that? - -A. The Agent you are talking to seems to be broken. The 'OIDs are not - increasing' message means that in the course of fetching OIDs from Agent, - Manager receives an OID that is not greater than those used in request. - Due to the nature of GETNEXT/GETBULK algorithm, passing the same or +Q. I'm walking a particular Agent with the `nextCmd()` or `bulkCmd()` + functions. It works for some OIDs, but invariably fails at certain + OID with the *OID not increasing* error. What does it mean and + how do I fix that? + +A. The Agent you are talking to seems to be broken. The + *OID not increasing* message means that in the course of fetching + OIDs from the Agent, Manager receives an OID that is not greater than those + passed in request. + Due to the nature of GETNEXT/GETBULK algorithm, passing the same or lesser OID to Manager would result in fetching the same set of OIDs over and over again effectively creating an infinite loop between Manager - and Agent so they may never reach the end of MIB. So Manager tries - to intervene and prevent loop from happenning. + and Agent so they may never reach the end of MIB. To prevent this the + Manager tries to intervene and prevent such loop from happening. - If have to work with a broken Agent and prepared some other mean - for stopping GETNEXT/GETBULK app at some point, you could set the - ignoreNonIncreasingOid option at CommandGenerator class instance - to disable OID verification on Manager side. + If you have to work with a broken Agent and can terminate the + GETNEXT/GETBULK command at some point, you can pass the + `ignoreNonIncreasingOid=True` keyword parameter to the `nextCmd()` or `bulkCmd()` + to disable OID verification at the Manager side. .. code-block:: python - cmdGen = cmdgen.CommandGenerator() - cmdGen.ignoreNonIncreasingOid = True - errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.bulkCmd(...) - + for (errorIndication, + errorStatus, + errorIndex, + varBinds) in nextCmd(SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('1.3.6')), + ignoreNonIncreasingOid=True): + + if errorIndication: + print(errorIndication) + break + elif errorStatus: + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) + break + else: + for varBind in varBinds: + print(' = '.join([x.prettyPrint() for x in varBind]) diff -Nru python-pysnmp4-4.3.2/docs/source/faq/pass-custom-mib-to-manager.rst python-pysnmp4-4.4.3/docs/source/faq/pass-custom-mib-to-manager.rst --- python-pysnmp4-4.3.2/docs/source/faq/pass-custom-mib-to-manager.rst 2015-11-13 17:21:56.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/faq/pass-custom-mib-to-manager.rst 2017-12-22 11:53:40.000000000 +0000 @@ -6,7 +6,7 @@ A. Starting from PySNMP 4.3.x, plain-text (ASN.1) MIBs can be automatically parsed into PySNMP form by the - `PySMI `_ tool. PySNMP will call PySMI + `PySMI `_ tool. PySNMP will call PySMI automatically, parsed PySNMP MIB will be cached in $HOME/.pysnmp/mibs/ (default location). @@ -24,6 +24,6 @@ :download:`Download` script. Alternatively, you can invoke the -`mibdump.py `_ +`mibdump.py `_ (shipped with PySMI) by hand and this way compile plain-text MIB into PySNMP format. diff -Nru python-pysnmp4-4.3.2/docs/source/faq.rst python-pysnmp4-4.4.3/docs/source/faq.rst --- python-pysnmp4-4.3.2/docs/source/faq.rst 2015-09-14 05:39:35.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/faq.rst 2017-12-22 11:53:40.000000000 +0000 @@ -4,7 +4,7 @@ Here we have an ever-growing list of frequently asked questions regarding PySNMP usage issues. If you got an issue that you think is worth noting -here, please `drop us a note `_. +here, please open a `GitHub issue `_. Keep in mind that some the answers below may not be universally applicable to any PySNMP revision. diff -Nru python-pysnmp4-4.3.2/docs/source/oldsite.rst python-pysnmp4-4.4.3/docs/source/oldsite.rst --- python-pysnmp4-4.3.2/docs/source/oldsite.rst 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/oldsite.rst 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,10 @@ + +Old site archive +================ + +Starting from PySNMP 4.3.0, we redesigned all documentation and web-site. +For previous versions of those please follow these links for +`old examples `_ +and +`old documentation `_ +. diff -Nru python-pysnmp4-4.3.2/docs/source/quick-start.rst python-pysnmp4-4.4.3/docs/source/quick-start.rst --- python-pysnmp4-4.3.2/docs/source/quick-start.rst 2016-02-13 19:38:13.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/quick-start.rst 2017-12-22 11:53:40.000000000 +0000 @@ -16,7 +16,7 @@ So just cut&paste the following code right into your Python prompt. The code will performs SNMP GET operation for a sysDescr.0 object at a publically available SNMP Command Responder at -`demo.snmplabs.com `_: +`demo.snmplabs.com `_: .. literalinclude:: /../../examples/hlapi/asyncore/sync/manager/cmdgen/v1-get.py :start-after: """# @@ -38,7 +38,7 @@ -------------- To send a trivial TRAP message to our hosted Notification Receiver at -`demo.snmplabs.com `_ +`demo.snmplabs.com `_ , just cut&paste the following code into your interactive Python session: .. literalinclude:: /../../examples/hlapi/asyncore/sync/agent/ntforg/default-v1-trap.py Binary files /tmp/tmpn5Zi2e/zXUsDK919T/python-pysnmp4-4.3.2/docs/source/.static/favicon.ico and /tmp/tmpn5Zi2e/lrepObQdAV/python-pysnmp4-4.4.3/docs/source/.static/favicon.ico differ diff -Nru python-pysnmp4-4.3.2/docs/source/.static/logo.svg python-pysnmp4-4.4.3/docs/source/.static/logo.svg --- python-pysnmp4-4.3.2/docs/source/.static/logo.svg 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/.static/logo.svg 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru python-pysnmp4-4.3.2/docs/source/.templates/layout.html python-pysnmp4-4.4.3/docs/source/.templates/layout.html --- python-pysnmp4-4.3.2/docs/source/.templates/layout.html 2015-09-14 05:39:35.000000000 +0000 +++ python-pysnmp4-4.4.3/docs/source/.templates/layout.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,185 +0,0 @@ -{# TEMPLATE VAR SETTINGS #} -{%- set url_root = pathto('', 1) %} -{%- if url_root == '#' %}{% set url_root = '' %}{% endif %} -{%- if not embedded and docstitle %} - {%- set titlesuffix = " — "|safe + docstitle|e %} -{%- else %} - {%- set titlesuffix = "" %} -{%- endif %} - - - - - - - {{ metatags }} - - {% block htmltitle %} - {{ title|striptags|e }}{{ titlesuffix }} - {% endblock %} - - {# FAVICON #} - {% if favicon %} - - {% endif %} - - {# CSS #} - - {# OPENSEARCH #} - {% if not embedded %} - {% if use_opensearch %} - - {% endif %} - - {% endif %} - - {# RTD hosts this file, so just load on non RTD builds #} - {% if not READTHEDOCS %} - - {% endif %} - - {% for cssfile in css_files %} - - {% endfor %} - - {% for cssfile in extra_css_files %} - - {% endfor %} - - {%- block linktags %} - {%- if hasdoc('about') %} - - {%- endif %} - {%- if hasdoc('genindex') %} - - {%- endif %} - {%- if hasdoc('search') %} - - {%- endif %} - {%- if hasdoc('copyright') %} - - {%- endif %} - - {%- if parents %} - - {%- endif %} - {%- if next %} - - {%- endif %} - {%- if prev %} - - {%- endif %} - {%- endblock %} - {%- block extrahead %} {% endblock %} - - {# Keep modernizr in head - http://modernizr.com/docs/#installing #} - - - - - - -
- - {# SIDE NAV, TOGGLES ON MOBILE #} - - -
- - {# MOBILE NAV, TRIGGLES SIDE NAV ON TOGGLE #} - - - - {# PAGE CONTENT #} -
-
- {% include "breadcrumbs.html" %} -
- {% include "top.html" %} - {% block body %}{% endblock %} - {% include "bottom.html" %} - {% include "analytics.html" %} -
-
- {% include "footer.html" %} -
-
- -
- -
- {% include "versions.html" %} - - {% if not embedded %} - - - {%- for scriptfile in script_files %} - - {%- endfor %} - - {% endif %} - - {# RTD hosts this file, so just load on non RTD builds #} - {% if not READTHEDOCS %} - - {% endif %} - - {# STICKY NAVIGATION #} - {% if theme_sticky_navigation %} - - {% endif %} - - {%- block footer %} {% endblock %} - - - diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncio/agent/ntforg/default-v1-trap.py python-pysnmp4-4.4.3/examples/hlapi/asyncio/agent/ntforg/default-v1-trap.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncio/agent/ntforg/default-v1-trap.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncio/agent/ntforg/default-v1-trap.py 2017-12-22 11:53:40.000000000 +0000 @@ -23,6 +23,7 @@ import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def run(): snmpEngine = SnmpEngine() @@ -45,4 +46,5 @@ snmpEngine.transportDispatcher.closeDispatcher() + asyncio.get_event_loop().run_until_complete(run()) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncio/agent/ntforg/multiple-notifications-at-once.py python-pysnmp4-4.4.3/examples/hlapi/asyncio/agent/ntforg/multiple-notifications-at-once.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncio/agent/ntforg/multiple-notifications-at-once.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncio/agent/ntforg/multiple-notifications-at-once.py 2017-12-22 11:53:40.000000000 +0000 @@ -26,10 +26,13 @@ import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def sendone(snmpEngine, hostname, notifyType): - errorIndication, errorStatus, \ - errorIndex, varBinds = yield from sendNotification( + (errorIndication, + errorStatus, + errorIndex, + varBinds) = yield from sendNotification( snmpEngine, CommunityData('public', tag=hostname), UdpTransportTarget((hostname, 162), tagList=hostname), @@ -46,11 +49,12 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s: at %s' % (errorStatus.prettyPrint(), errorIndex and varBinds[int(errorIndex)-1][0] or '?')) + print('%s: at %s' % (errorStatus.prettyPrint(), errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: print(' = '.join([x.prettyPrint() for x in varBind])) + snmpEngine = SnmpEngine() loop = asyncio.get_event_loop() diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py python-pysnmp4-4.4.3/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py 2015-09-27 10:26:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py 2017-12-22 11:53:40.000000000 +0000 @@ -20,32 +20,35 @@ import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def run(varBinds): snmpEngine = SnmpEngine() while True: - errorIndication, errorStatus, errorIndex, \ - varBindTable = yield from bulkCmd( - snmpEngine, - UsmUserData('usr-none-none'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 50, - *varBinds) + (errorIndication, + errorStatus, + errorIndex, + varBindTable) = yield from bulkCmd( + snmpEngine, + UsmUserData('usr-none-none'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + 0, 50, + *varBinds) if errorIndication: print(errorIndication) break elif errorStatus: print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?' ) + ) else: for varBindRow in varBindTable: for varBind in varBindRow: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) varBinds = varBindTable[-1] if isEndOfMib(varBinds): @@ -53,6 +56,7 @@ snmpEngine.transportDispatcher.closeDispatcher() + loop = asyncio.get_event_loop() loop.run_until_complete( run([ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'))]) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,54 @@ +""" +Concurrent queries +++++++++++++++++++ + +Send multiple SNMP GET requests at once using the following options: + +* with SNMPv2c, community 'public' +* over IPv4/UDP +* to multiple Agents at demo.snmplabs.com +* for instance of SNMPv2-MIB::sysDescr.0 MIB object +* based on asyncio I/O framework + +Functionally similar to: + +| $ snmpget -v2c -c public demo.snmplabs.com:1161 SNMPv2-MIB::sysDescr.0 +| $ snmpget -v2c -c public demo.snmplabs.com:2161 SNMPv2-MIB::sysDescr.0 +| $ snmpget -v2c -c public demo.snmplabs.com:3161 SNMPv2-MIB::sysDescr.0 + +"""# +import asyncio +from pysnmp.hlapi.asyncio import * + + +@asyncio.coroutine +def getone(snmpEngine, hostname): + errorIndication, errorStatus, errorIndex, varBinds = yield from getCmd( + snmpEngine, + CommunityData('public'), + UdpTransportTarget(hostname), + ContextData(), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)) + ) + + if errorIndication: + print(errorIndication) + elif errorStatus: + print('%s at %s' % ( + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?' + ) + ) + else: + for varBind in varBinds: + print(' = '.join([x.prettyPrint() for x in varBind])) + + +snmpEngine = SnmpEngine() + +loop = asyncio.get_event_loop() +loop.run_until_complete( + asyncio.wait([getone(snmpEngine, ('demo.snmplabs.com', 1161)), + getone(snmpEngine, ('demo.snmplabs.com', 2161)), + getone(snmpEngine, ('demo.snmplabs.com', 3161))]) +) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py python-pysnmp4-4.4.3/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py 2015-09-27 10:26:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -""" -Concurrent queries -++++++++++++++++++ - -Send multiple SNMP GET requests at once using the following options: - -* with SNMPv2c, community 'public' -* over IPv4/UDP -* to multiple Agents at demo.snmplabs.com -* for instance of SNMPv2-MIB::sysDescr.0 MIB object -* based on asyncio I/O framework - -Functionally similar to: - -| $ snmpget -v2c -c public demo.snmplabs.com:1161 SNMPv2-MIB::sysDescr.0 -| $ snmpget -v2c -c public demo.snmplabs.com:2161 SNMPv2-MIB::sysDescr.0 -| $ snmpget -v2c -c public demo.snmplabs.com:3161 SNMPv2-MIB::sysDescr.0 - -"""# -import asyncio -from pysnmp.hlapi.asyncio import * - -@asyncio.coroutine -def getone(snmpEngine, hostname): - errorIndication, errorStatus, errorIndex, varBinds = yield from getCmd( - snmpEngine, - CommunityData('public'), - UdpTransportTarget(hostname), - ContextData(), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)) - ) - - if errorIndication: - print(errorIndication) - elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) - else: - for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) - -snmpEngine = SnmpEngine() - -loop = asyncio.get_event_loop() -loop.run_until_complete( - asyncio.wait([getone(snmpEngine, ('demo.snmplabs.com', 1161)), - getone(snmpEngine, ('demo.snmplabs.com', 2161)), - getone(snmpEngine, ('demo.snmplabs.com', 3161))]) -) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncio/manager/cmdgen/multiple-sequential-queries.py python-pysnmp4-4.4.3/examples/hlapi/asyncio/manager/cmdgen/multiple-sequential-queries.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncio/manager/cmdgen/multiple-sequential-queries.py 2015-09-27 17:29:37.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncio/manager/cmdgen/multiple-sequential-queries.py 2017-12-22 11:53:40.000000000 +0000 @@ -20,6 +20,7 @@ import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def getone(snmpEngine, hostname): errorIndication, errorStatus, errorIndex, varBinds = yield from getCmd( @@ -34,19 +35,21 @@ print(errorIndication) elif errorStatus: print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?' ) + ) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + @asyncio.coroutine def getall(snmpEngine, hostnames): for hostname in hostnames: yield from getone(snmpEngine, hostname) + snmpEngine = SnmpEngine() loop = asyncio.get_event_loop() diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncio/manager/cmdgen/v1-get.py python-pysnmp4-4.4.3/examples/hlapi/asyncio/manager/cmdgen/v1-get.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncio/manager/cmdgen/v1-get.py 2015-09-27 10:26:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncio/manager/cmdgen/v1-get.py 2017-12-22 11:53:40.000000000 +0000 @@ -18,6 +18,7 @@ import asyncio from pysnmp.hlapi.asyncio import * + @asyncio.coroutine def run(): snmpEngine = SnmpEngine() @@ -33,14 +34,15 @@ print(errorIndication) elif errorStatus: print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?' ) + ) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) snmpEngine.transportDispatcher.closeDispatcher() + asyncio.get_event_loop().run_until_complete(run()) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/agent/ntforg/multiple-informs-at-once.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/agent/ntforg/multiple-informs-at-once.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/agent/ntforg/multiple-informs-at-once.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/agent/ntforg/multiple-informs-at-once.py 2017-12-22 11:53:40.000000000 +0000 @@ -31,8 +31,10 @@ ContextData()), ) -def cbFun(snmpEngine, sendRequestHandle, errorIndication, - errorStatus, errorIndex, varBinds, cbctx): + +# noinspection PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print('Notification %s not sent: %s' % (sendRequestHandle, errorIndication)) elif errorStatus: @@ -43,6 +45,7 @@ for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) + snmpEngine = SnmpEngine() for authData, transportTarget, contextData in targets: @@ -51,10 +54,10 @@ authData, transportTarget, contextData, - 'inform', # NotifyType + 'inform', # NotifyType NotificationType( ObjectIdentity('SNMPv2-MIB', 'coldStart') - ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ), + ).addVarBinds(('1.3.6.1.2.1.1.1.0', 'my name')), cbFun=cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/agent/ntforg/multiple-traps-at-once.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/agent/ntforg/multiple-traps-at-once.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/agent/ntforg/multiple-traps-at-once.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/agent/ntforg/multiple-traps-at-once.py 2017-12-22 11:53:40.000000000 +0000 @@ -13,7 +13,7 @@ * with TRAP ID 'coldStart' specified as a MIB symbol * include managed object information specified as var-bind objects pair -| $ snmptrap -v1 -c public demo.snmplabs.com 1.3.6.1.4.1.20408.4.1.1.2 195.218.195.228 6 432 12345 1.3.6.1.2.1.1.1.0 s "my system" +| $ snmptrap -v1 -c public demo.snmplabs.com 1.3.6.1.4.1.20408.4.1.1.2 demo.snmplabs.com 6 432 12345 1.3.6.1.2.1.1.1.0 s "my system" | $ snmptrap -v2c -c public demo.snmplabs.com 123 1.3.6.1.6.3.1.1.5.1 """# @@ -23,13 +23,13 @@ # ( ( authData, transportTarget ), ... ) targets = ( # 1-st target (SNMPv1 over IPv4/UDP) - ( CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData() ), + (CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData()), # 2-nd target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData() ), + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData()), ) snmpEngine = SnmpEngine() @@ -40,12 +40,12 @@ authData, transportTarget, contextData, - 'trap', # NotifyType + 'trap', # NotifyType NotificationType( ObjectIdentity('SNMPv2-MIB', 'coldStart') ).addVarBinds( - ( ObjectIdentifier('1.3.6.1.2.1.1.1.0'), - OctetString('my name') ) + (ObjectIdentifier('1.3.6.1.2.1.1.1.0'), + OctetString('my name')) ) ) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/agent/ntforg/running-multiple-snmp-engines-at-once.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/agent/ntforg/running-multiple-snmp-engines-at-once.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/agent/ntforg/running-multiple-snmp-engines-at-once.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/agent/ntforg/running-multiple-snmp-engines-at-once.py 2017-12-22 11:53:40.000000000 +0000 @@ -28,7 +28,7 @@ | $ snmpinform -v2c -c public demo.snmplabs.com:1162 123 1.3.6.1.6.3.1.1.5.1 | $ snmpinform -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 demo.snmplabs.com 123 1.3.6.1.6.3.1.1.5.1 -"""# +"""# from pysnmp.hlapi.asyncore import * from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher @@ -36,16 +36,18 @@ # ( ( authData, transportTarget ), ... ) targets = ( # 1-st target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 1162)), - ContextData() ), + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 1162)), + ContextData()), # 2-nd target (SNMPv3 over IPv4/UDP) - ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData() ), + (UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData()), ) -def cbFun(snmpEngine, sendRequestHandle, errorIndication, + +# noinspection PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): snmpEngine = cbCtx if errorIndication: @@ -57,12 +59,13 @@ for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) + # Instantiate the single transport dispatcher object transportDispatcher = AsyncoreDispatcher() # Setup a custom data routing function to select snmpEngine by transportDomain transportDispatcher.registerRoutingCbFun( - lambda td,ta,d: ta[1] % 3 and 'A' or 'B' + lambda td, ta, d: ta[1] % 3 and 'A' or 'B' ) snmpEngineA = SnmpEngine() @@ -72,17 +75,17 @@ snmpEngineB.registerTransportDispatcher(transportDispatcher, 'B') for authData, transportTarget, contextData in targets: - snmpEngine = transportTarget.getTransportInfo()[1][1] % 3 and \ - snmpEngineA or snmpEngineB + snmpEngine = (transportTarget.getTransportInfo()[1][1] % 3 and + snmpEngineA or snmpEngineB) sendPduHandle = sendNotification( snmpEngine, authData, transportTarget, contextData, - 'inform', # NotifyType + 'inform', # NotifyType NotificationType( ObjectIdentity('SNMPv2-MIB', 'coldStart') - ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ), + ).addVarBinds(('1.3.6.1.2.1.1.1.0', 'my name')), cbFun=cbFun, cbCtx=snmpEngine ) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries-over-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,80 @@ +""" +Multiple concurrent queries ++++++++++++++++++++++++++++ + +Send a bunch of different SNMP GET requests to different peers all at once, +wait for responses asynchronously: + +* with SNMPv1, community 'public' and + with SNMPv2c, community 'public' and + with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy +* over IPv4/UDP and + over IPv6/UDP +* to an Agent at demo.snmplabs.com:161 and + to an Agent at [::1]:161 +* for instances of SNMPv2-MIB::sysDescr.0 and + SNMPv2-MIB::sysLocation.0 MIB objects + +"""# +from pysnmp.hlapi.asyncore import * + +# List of targets in the followin format: +# ( ( authData, transportTarget, varNames ), ... ) +targets = ( + # 1-st target (SNMPv1 over IPv4/UDP) + (CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), + # 2-nd target (SNMPv2c over IPv4/UDP) + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), + # 3-nd target (SNMPv2c over IPv4/UDP) - same community and + # different transport address. + (CommunityData('public'), + UdpTransportTarget(('localhost', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysContact', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0)))), + # 4-nd target (SNMPv3 over IPv4/UDP) + (UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), + # 5-th target (SNMPv3 over IPv6/UDP) + (UsmUserData('usr-md5-none', 'authkey1'), + Udp6TransportTarget(('::1', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), + # N-th target + # ... +) + + +# Wait for responses or errors +# noinspection PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): + authData, transportTarget = cbCtx + print('%s via %s' % (authData, transportTarget)) + if errorIndication: + print(errorIndication) + return True + elif errorStatus: + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) + return True + else: + for varBind in varBinds: + print(' = '.join([x.prettyPrint() for x in varBind])) + + +snmpEngine = SnmpEngine() + +# Submit GET requests +for authData, transportTarget, varNames in targets: + getCmd(snmpEngine, authData, transportTarget, ContextData(), *varNames, + **dict(cbFun=cbFun, cbCtx=(authData, transportTarget))) + +snmpEngine.transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py 2015-09-27 15:27:21.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -""" -Multiple concurrent queries -+++++++++++++++++++++++++++ - -Send a bunch of different SNMP GET requests to different peers all at once, -wait for responses asynchronously: - -* with SNMPv1, community 'public' and - with SNMPv2c, community 'public' and - with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy -* over IPv4/UDP and - over IPv6/UDP -* to an Agent at demo.snmplabs.com:161 and - to an Agent at [::1]:161 -* for instances of SNMPv2-MIB::sysDescr.0 and - SNMPv2-MIB::sysLocation.0 MIB objects - -"""# -from pysnmp.hlapi.asyncore import * - -# List of targets in the followin format: -# ( ( authData, transportTarget, varNames ), ... ) -targets = ( - # 1-st target (SNMPv1 over IPv4/UDP) - ( CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), - # 2-nd target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), - # 3-nd target (SNMPv2c over IPv4/UDP) - same community and - # different transport address. - ( CommunityData('public'), - UdpTransportTarget(('localhost', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysContact', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0))) ), - # 4-nd target (SNMPv3 over IPv4/UDP) - ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), - # 5-th target (SNMPv3 over IPv6/UDP) - ( UsmUserData('usr-md5-none', 'authkey1'), - Udp6TransportTarget(('::1', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), - # N-th target - # ... -) - -# Wait for responses or errors -def cbFun(snmpEngine, sendRequestHandle, errorIndication, - errorStatus, errorIndex, varBinds, cbCtx): - authData, transportTarget = cbCtx - print('%s via %s' % (authData, transportTarget)) - if errorIndication: - print(errorIndication) - return True - elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) - return True - else: - for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) - -snmpEngine = SnmpEngine() - -# Submit GET requests -for authData, transportTarget, varNames in targets: - getCmd(snmpEngine, authData, transportTarget, ContextData(), *varNames, - **dict(cbFun=cbFun, cbCtx=(authData, transportTarget))) - -snmpEngine.transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once-over-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once-over-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once-over-ipv4-and-ipv6.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once-over-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,73 @@ +""" +Walk multiple Agents at once +++++++++++++++++++++++++++++ + +Iterate over MIBs of multiple SNMP Agents asynchronously using the +following options: + +* with SNMPv1, community 'public' and + with SNMPv2c, community 'public' and + with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy +* over IPv4/UDP and + over IPv6/UDP +* to an Agent at demo.snmplabs.com:161 and + to an Agent at [::1]:161 +* pull variables till EOM + +"""# +from pysnmp.hlapi.asyncore import * + +# List of targets in the followin format: +# ( ( authData, transportTarget, varNames ), ... ) +targets = ( + # 1-st target (SNMPv1 over IPv4/UDP) + (CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('1.3.6.1.2.1')), + ObjectType(ObjectIdentity('1.3.6.1.3.1')))), + # 2-nd target (SNMPv2c over IPv4/UDP) + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('1.3.6.1.4.1')),)), + # 3-nd target (SNMPv3 over IPv4/UDP) + (UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')),)), + # 4-th target (SNMPv3 over IPv6/UDP) + (UsmUserData('usr-md5-none', 'authkey1'), + Udp6TransportTarget(('::1', 161)), + (ObjectType(ObjectIdentity('IF-MIB', 'ifTable')),)) + # N-th target + # ... +) + + +# Wait for responses or errors, submit GETNEXT requests for further OIDs +# noinspection PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBindTable, cbCtx): + (authData, transportTarget) = cbCtx + print('%s via %s' % (authData, transportTarget)) + if errorIndication: + print(errorIndication) + return + elif errorStatus: + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) + return + else: + for varBindRow in varBindTable: + for varBind in varBindRow: + print(' = '.join([x.prettyPrint() for x in varBind])) + + return True # continue table retrieval + + +snmpEngine = SnmpEngine() + +# Submit initial GETNEXT requests and wait for responses +for authData, transportTarget, varBinds in targets: + nextCmd(snmpEngine, authData, transportTarget, ContextData(), + *varBinds, **dict(cbFun=cbFun, cbCtx=(authData, transportTarget))) + +snmpEngine.transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py 2015-09-27 15:27:21.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -""" -Walk multiple Agents at once -++++++++++++++++++++++++++++ - -Iterate over MIBs of multiple SNMP Agents asynchronously using the -following options: - -* with SNMPv1, community 'public' and - with SNMPv2c, community 'public' and - with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy -* over IPv4/UDP and - over IPv6/UDP -* to an Agent at demo.snmplabs.com:161 and - to an Agent at [::1]:161 -* pull variables till EOM - -"""# -from pysnmp.hlapi.asyncore import * - -# List of targets in the followin format: -# ( ( authData, transportTarget, varNames ), ... ) -targets = ( - # 1-st target (SNMPv1 over IPv4/UDP) - ( CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('1.3.6.1.2.1')), - ObjectType(ObjectIdentity('1.3.6.1.3.1')) ) ), - # 2-nd target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('1.3.6.1.4.1')), ) ), - # 3-nd target (SNMPv3 over IPv4/UDP) - ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), ) ), - # 4-th target (SNMPv3 over IPv6/UDP) - ( UsmUserData('usr-md5-none', 'authkey1'), - Udp6TransportTarget(('::1', 161)), - ( ObjectType(ObjectIdentity('IF-MIB', 'ifTable')), ) ) - # N-th target - # ... -) - -# Wait for responses or errors, submit GETNEXT requests for further OIDs -def cbFun(snmpEngine, sendRequestHandle, errorIndication, - errorStatus, errorIndex, varBindTable, cbCtx): - (authData, transportTarget) = cbCtx - print('%s via %s' % (authData, transportTarget)) - if errorIndication: - print(errorIndication) - return - elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?' - ) - ) - return - else: - for varBindRow in varBindTable: - for varBind in varBindRow: - print(' = '.join([ x.prettyPrint() for x in varBind ])) - - return True # continue table retrieval - -snmpEngine = SnmpEngine() - -# Submit initial GETNEXT requests and wait for responses -for authData, transportTarget, varBinds in targets: - nextCmd(snmpEngine, authData, transportTarget, ContextData(), - *varBinds, **dict(cbFun=cbFun, cbCtx=(authData, transportTarget))) - -snmpEngine.transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py 2015-09-27 15:27:21.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py 2017-12-22 11:53:40.000000000 +0000 @@ -17,33 +17,33 @@ """# from pysnmp.hlapi.asyncore import * -def cbFun(snmpEngine, sendRequestHandle, errorIndication, + +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return else: for varBindRow in varBindTable: for varBind in varBindRow: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) return True # request lower layers to do GETNEXT and call us back + snmpEngine = SnmpEngine() nextCmd(snmpEngine, - UsmUserData('usr-md5-none', 'authkey1'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), - ObjectType(ObjectIdentity('IF-MIB', 'ifTable')), - cbFun=cbFun) + UsmUserData('usr-md5-none', 'authkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), + ObjectType(ObjectIdentity('IF-MIB', 'ifTable')), + cbFun=cbFun) snmpEngine.transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines-over-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines-over-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines-over-ipv4-and-ipv6.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines-over-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,95 @@ +""" +Multiple SNMP engines ++++++++++++++++++++++ + +Send multiple SNMP GET requests to multiple peers using multiple +independend SNMP engines. Deal with peers asynchronously. SNMP options +are: + +* with SNMPv1, community 'public' and + with SNMPv2c, community 'public' and + with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy +* over IPv4/UDP and + over IPv6/UDP +* to an Agent at demo.snmplabs.com:161 and + to an Agent at [::1]:161 +* for instances of SNMPv2-MIB::sysDescr.0 and + SNMPv2-MIB::sysLocation.0 MIB objects + +Within this script we have a single asynchronous TransportDispatcher +and a single UDP-based transport serving two independent SNMP engines. +We use a single instance of AsyncCommandGenerator with each of +SNMP Engines to comunicate GET command request to remote systems. + +When we receive a [response] message from remote system we use +a custom message router to choose what of the two SNMP engines +data packet should be handed over. The selection criteria we +employ here is based on peer's UDP port number. Other selection +criterias are also possible. + +"""# +from pysnmp.hlapi.asyncore import * +from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher + +# List of targets in the following format: +# ( ( authData, transportTarget, varNames ), ... ) +targets = ( + # 1-st target (SNMPv1 over IPv4/UDP) + (CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), + # 2-nd target (SNMPv2c over IPv4/UDP) + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 1161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), + # 3-nd target (SNMPv3 over IPv4/UDP) + (UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 2161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))) + # N-th target + # ... +) + + +# Wait for responses or errors +# noinspection PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): + (snmpEngine, authData, transportTarget) = cbCtx + print('snmpEngine %s: %s via %s' % (snmpEngine.snmpEngineID.prettyPrint(), authData, transportTarget)) + if errorIndication: + print(errorIndication) + return True + elif errorStatus: + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) + return True + else: + for varBind in varBinds: + print(' = '.join([x.prettyPrint() for x in varBind])) + + +# Instantiate the single transport dispatcher object +transportDispatcher = AsyncoreDispatcher() + +# Setup a custom data routing function to select snmpEngine by transportDomain +transportDispatcher.registerRoutingCbFun( + lambda td, ta, d: ta[1] % 3 and 'A' or 'B' +) + +snmpEngineA = SnmpEngine() +snmpEngineA.registerTransportDispatcher(transportDispatcher, 'A') + +snmpEngineB = SnmpEngine() +snmpEngineB.registerTransportDispatcher(transportDispatcher, 'B') + +for authData, transportTarget, varBinds in targets: + snmpEngine = transportTarget.getTransportInfo()[1][1] % 3 and \ + snmpEngineA or snmpEngineB + getCmd(snmpEngine, authData, transportTarget, ContextData(), *varBinds, + **dict(cbFun=cbFun, cbCtx=(snmpEngine, authData, transportTarget))) + +transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py 2015-09-27 15:27:21.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -""" -Multiple SNMP engines -+++++++++++++++++++++ - -Send multiple SNMP GET requests to multiple peers using multiple -independend SNMP engines. Deal with peers asynchronously. SNMP options -are: - -* with SNMPv1, community 'public' and - with SNMPv2c, community 'public' and - with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy -* over IPv4/UDP and - over IPv6/UDP -* to an Agent at demo.snmplabs.com:161 and - to an Agent at [::1]:161 -* for instances of SNMPv2-MIB::sysDescr.0 and - SNMPv2-MIB::sysLocation.0 MIB objects - -Within this script we have a single asynchronous TransportDispatcher -and a single UDP-based transport serving two independent SNMP engines. -We use a single instance of AsyncCommandGenerator with each of -SNMP Engines to comunicate GET command request to remote systems. - -When we receive a [response] message from remote system we use -a custom message router to choose what of the two SNMP engines -data packet should be handed over. The selection criteria we -employ here is based on peer's UDP port number. Other selection -criterias are also possible. - -"""# -from pysnmp.hlapi.asyncore import * -from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher - -# List of targets in the following format: -# ( ( authData, transportTarget, varNames ), ... ) -targets = ( - # 1-st target (SNMPv1 over IPv4/UDP) - ( CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), - # 2-nd target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 1161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ), - # 3-nd target (SNMPv3 over IPv4/UDP) - ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 2161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) )) ) - # N-th target - # ... -) - -# Wait for responses or errors -def cbFun(snmpEngine, sendRequestHandle, errorIndication, - errorStatus, errorIndex, varBinds, cbCtx): - (snmpEngine, authData, transportTarget) = cbCtx - print('snmpEngine %s: %s via %s' % - (snmpEngine.snmpEngineID.prettyPrint(), authData, transportTarget) - ) - if errorIndication: - print(errorIndication) - return 1 - elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) - return 1 - else: - for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) - -# Instantiate the single transport dispatcher object -transportDispatcher = AsyncoreDispatcher() - -# Setup a custom data routing function to select snmpEngine by transportDomain -transportDispatcher.registerRoutingCbFun( - lambda td,ta,d: ta[1] % 3 and 'A' or 'B' -) - -snmpEngineA = SnmpEngine() -snmpEngineA.registerTransportDispatcher(transportDispatcher, 'A') - -snmpEngineB = SnmpEngine() -snmpEngineB.registerTransportDispatcher(transportDispatcher, 'B') - -for authData, transportTarget, varBinds in targets: - snmpEngine = transportTarget.getTransportInfo()[1][1] % 3 and \ - snmpEngineA or snmpEngineB - getCmd(snmpEngine, authData, transportTarget, ContextData(), *varBinds, - **dict(cbFun=cbFun, cbCtx=(snmpEngine, authData, transportTarget))) - -transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py 2015-09-27 15:27:21.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/manager/cmdgen/v2c-get.py 2017-12-22 11:53:40.000000000 +0000 @@ -16,21 +16,21 @@ """# from pysnmp.hlapi.asyncore import * -def cbFun(snmpEngine, sendRequestHandle, errorIndication, + +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) return elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + snmpEngine = SnmpEngine() diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextengineid.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextengineid.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextengineid.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextengineid.py 2017-12-22 11:53:40.000000000 +0000 @@ -34,11 +34,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextname.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextname.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextname.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/custom-contextname.py 2017-12-22 11:53:40.000000000 +0000 @@ -34,11 +34,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/custom-v1-trap.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/custom-v1-trap.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/custom-v1-trap.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/custom-v1-trap.py 2017-12-22 11:53:40.000000000 +0000 @@ -25,19 +25,20 @@ from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(), - CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'trap', - NotificationType( - ObjectIdentity('1.3.6.1.4.1.20408.4.1.1.2.0.432'), - ).addVarBinds( - ('1.3.6.1.2.1.1.3.0', 12345), - ('1.3.6.1.6.3.18.1.3.0', '127.0.0.1'), - ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), - ('1.3.6.1.2.1.1.1.0', OctetString('my system')) - ) + sendNotification( + SnmpEngine(), + CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'trap', + NotificationType( + ObjectIdentity('1.3.6.1.4.1.20408.4.1.1.2.0.432'), + ).addVarBinds( + ('1.3.6.1.2.1.1.3.0', 12345), + ('1.3.6.1.6.3.18.1.3.0', '127.0.0.1'), + ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), + ('1.3.6.1.2.1.1.1.0', OctetString('my system')) + ) ) ) if errorIndication: diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/default-v1-trap.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/default-v1-trap.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/default-v1-trap.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/default-v1-trap.py 2017-12-22 11:53:40.000000000 +0000 @@ -23,18 +23,20 @@ from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(), - CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'trap', - NotificationType( - ObjectIdentity('1.3.6.1.6.3.1.1.5.2') - ).addVarBinds( - ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), - ('1.3.6.1.2.1.1.1.0', OctetString('my system')) - ) + sendNotification( + SnmpEngine(), + CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'trap', + NotificationType( + ObjectIdentity('1.3.6.1.6.3.1.1.5.2') + ).addVarBinds( + ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), + ('1.3.6.1.2.1.1.1.0', OctetString('my system')) + ) ) ) + if errorIndication: print(errorIndication) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/send-notification-with-additional-varbinds.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/send-notification-with-additional-varbinds.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/send-notification-with-additional-varbinds.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/send-notification-with-additional-varbinds.py 2017-12-22 11:53:40.000000000 +0000 @@ -19,27 +19,25 @@ from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'inform', - NotificationType( - ObjectIdentity('SNMPv2-MIB', 'coldStart') - ).addVarBinds( - ObjectType(ObjectIdentity('SNMPv2-MIB','sysName',0), - 'my system') - )) + sendNotification( + SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'inform', + NotificationType( + ObjectIdentity('SNMPv2-MIB', 'coldStart') + ).addVarBinds( + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0), 'my system') + ) + ) ) if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -""" -SNMPv2c TRAP via NOTIFICATION-TYPE -++++++++++++++++++++++++++++++++++ - -Initialize TRAP message contents from variables specified -in *NOTIFICATION-TYPE* SMI macro. - -* SNMPv2c -* with community name 'public' -* over IPv4/UDP -* send TRAP notification -* with TRAP ID 'coldStart' specified as a MIB symbol -* include managed object information specified as a MIB symbol - -Functionally similar to: - -| $ snmptrap -v2c -c public demo.snmplabs.com 12345 1.3.6.1.4.1.20408.4.1.1.2 - -"""# -from pysnmp.hlapi import * - -errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'trap', - NotificationType( - ObjectIdentity('SNMPv2-MIB', 'coldStart') - ) - ) -) - -if errorIndication: - print(errorIndication) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-with-notification-objects.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,41 @@ +""" +SNMPv2c TRAP via NOTIFICATION-TYPE +++++++++++++++++++++++++++++++++++ + +Initialize TRAP message contents from variables specified +in *NOTIFICATION-TYPE* SMI macro. + +* SNMPv2c +* with community name 'public' +* over IPv4/UDP +* send TRAP notification +* with TRAP ID 'linkUp' specified as a MIB symbol +* include values for managed objects implicitly added to notification + (via NOTIFICATION-TYPE->OBJECTS) + +Functionally similar to: + +| $ snmptrap -v2c -c public demo.snmplabs.com 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.2.2.1.1.123 i 123 1.3.6.1.2.1.2.2.1.7.123 i 1 1.3.6.1.2.1.2.2.1.8.123 i 1 + +"""# +from pysnmp.hlapi import * + +errorIndication, errorStatus, errorIndex, varBinds = next( + sendNotification( + SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'trap', + NotificationType( + ObjectIdentity('IF-MIB', 'linkUp'), + instanceIndex=(123,), + objects={('IF-MIB', 'ifIndex'): 123, + ('IF-MIB', 'ifAdminStatus'): 'up', + ('IF-MIB', 'ifOperStatus'): 'up'} + ) + ) +) + +if errorIndication: + print(errorIndication) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/v3-inform.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/v3-inform.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/v3-inform.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/v3-inform.py 2017-12-22 11:53:40.000000000 +0000 @@ -19,27 +19,25 @@ from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(), - UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'inform', - NotificationType( - ObjectIdentity('1.3.6.1.6.3.1.1.5.2') - ).addVarBinds( - ObjectType(ObjectIdentity('1.3.6.1.2.1.1.5.0'), - 'system name') - )) + sendNotification( + SnmpEngine(), + UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'inform', + NotificationType( + ObjectIdentity('1.3.6.1.6.3.1.1.5.2') + ).addVarBinds( + ObjectType(ObjectIdentity('1.3.6.1.2.1.1.5.0'), 'system name') + ) + ) ) if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/v3-trap.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/v3-trap.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/agent/ntforg/v3-trap.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/agent/ntforg/v3-trap.py 2017-12-22 11:53:40.000000000 +0000 @@ -25,17 +25,17 @@ from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( - sendNotification(SnmpEngine(OctetString(hexValue='8000000001020304')), - UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', - authProtocol=usmHMACSHAAuthProtocol, - privProtocol=usmAesCfb128Protocol), - UdpTransportTarget(('demo.snmplabs.com', 162)), - ContextData(), - 'trap', - NotificationType( - ObjectIdentity('SNMPv2-MIB', 'authenticationFailure') - ) + sendNotification( + SnmpEngine(OctetString(hexValue='8000000001020304')), + UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', + authProtocol=usmHMACSHAAuthProtocol, + privProtocol=usmAesCfb128Protocol), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'trap', + NotificationType(ObjectIdentity('SNMPv2-MIB', 'authenticationFailure')) ) ) + if errorIndication: print(errorIndication) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/coerce-set-value-to-mib-spec.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/coerce-set-value-to-mib-spec.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/coerce-set-value-to-mib-spec.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/coerce-set-value-to-mib-spec.py 2017-12-22 11:53:40.000000000 +0000 @@ -11,8 +11,7 @@ Functionally similar to: -| $ snmpset -v2c -c public demo.snmplabs.com SNMPv2-MIB::sysDescr.0 \ -| = "new system name" +| $ snmpset -v2c -c public demo.snmplabs.com SNMPv2-MIB::sysDescr.0 = "new system name" """# from pysnmp.hlapi import * @@ -29,11 +28,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-asn1-mib-search-path.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-asn1-mib-search-path.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-asn1-mib-search-path.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-asn1-mib-search-path.py 2017-12-22 11:53:40.000000000 +0000 @@ -12,8 +12,7 @@ Functionally similar to: -| $ snmpget -v2c -c public -M /usr/share/snmp demo.snmplabs.com \ -| IF-MIB::ifInOctets.1 +| $ snmpget -v2c -c public -M /usr/share/snmp demo.snmplabs.com IF-MIB::ifInOctets.1 """# from pysnmp.hlapi import * @@ -23,17 +22,15 @@ CommunityData('public'), UdpTransportTarget(('demo.snmplabs.com', 161)), ContextData(), - ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1).addAsn1MibSource('file:///usr/share/snmp', 'http://mibs.snmplabs.com/asn1/@mib@'))) + ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1).addAsn1MibSource('file:///usr/share/snmp', + 'http://mibs.snmplabs.com/asn1/@mib@'))) ) if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid-and-contextname.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid-and-contextname.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid-and-contextname.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid-and-contextname.py 2017-12-22 11:53:40.000000000 +0000 @@ -14,10 +14,7 @@ Functionally similar to: -| $ snmpset -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 \ -| -E 80004fb805636c6f75644dab22cc -n a172334d7d97871b72241397f713fa12 \ -| demo.snmplabs.com \ -| SNMPv2-MIB::sysORDescr.1 = "new system name" +| $ snmpset -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 -E 80004fb805636c6f75644dab22cc -n a172334d7d97871b72241397f713fa12 demo.snmplabs.com SNMPv2-MIB::sysORDescr.1 = "new system name" """# from pysnmp.hlapi import * @@ -28,18 +25,14 @@ UdpTransportTarget(('demo.snmplabs.com', 161)), ContextData(contextEngineId=OctetString(hexValue='80004fb805636c6f75644dab22cc'), contextName='da761cfc8c94d3aceef4f60f049105ba'), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysORDescr', 1), - 'new system name')) + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysORDescr', 1), 'new system name')) ) if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid.py 2017-12-22 11:53:40.000000000 +0000 @@ -13,9 +13,7 @@ Functionally similar to: -| $ snmpset -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 \ -| -E 80004fb805636c6f75644dab22cc demo.snmplabs.com \ -| SNMPv2-MIB::sysORDescr.1 = "new system name" +| $ snmpset -v3 -u usr-md5-des -l authPriv -A authkey1 -X privkey1 -E 80004fb805636c6f75644dab22cc demo.snmplabs.com SNMPv2-MIB::sysORDescr.1 = "new system name" """# from pysnmp.hlapi import * @@ -26,18 +24,14 @@ securityEngineId=OctetString(hexValue='80004fb805636c6f75644dab22cc')), UdpTransportTarget(('demo.snmplabs.com', 161)), ContextData(), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0), - 'new system name')) + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0), 'new system name')) ) if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-pysnmp-mibs-search-path.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-pysnmp-mibs-search-path.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-pysnmp-mibs-search-path.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-pysnmp-mibs-search-path.py 2017-12-22 11:53:40.000000000 +0000 @@ -14,32 +14,31 @@ Functionally similar to: -| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 \ -| demo.snmplabs.com TCP-MIB::tcpConnTable +| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 demo.snmplabs.com TCP-MIB::tcpConnTable """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in bulkCmd(SnmpEngine(), - UsmUserData('usr-none-none'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 50, - ObjectType(ObjectIdentity('TCP-MIB', 'tcpConnTable').addMibSource('/opt/mibs/pysnmp').addMibSource('python_packaged_mibs')), - lexicographicMode=False): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in bulkCmd(SnmpEngine(), + UsmUserData('usr-none-none'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + 0, 50, + ObjectType( + ObjectIdentity('TCP-MIB', 'tcpConnTable').addMibSource('/opt/mibs/pysnmp').addMibSource('python_packaged_mibs') + ), + lexicographicMode=False): if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-timeout-and-retries.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-timeout-and-retries.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-timeout-and-retries.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-timeout-and-retries.py 2017-12-22 11:53:40.000000000 +0000 @@ -43,11 +43,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-v3-security-name.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-v3-security-name.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/custom-v3-security-name.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/custom-v3-security-name.py 2017-12-22 11:53:40.000000000 +0000 @@ -28,11 +28,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/fetch-variables-over-ipv6.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/fetch-variables-over-ipv6.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/fetch-variables-over-ipv6.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/fetch-variables-over-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -11,11 +11,7 @@ Functionally similar to: -| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| udp6:[::1]:161 \ -| 1.3.6.1.2.1.1.1.0 \ -| 1.3.6.1.2.1.1.2.0 \ -| 1.3.6.1.2.1.1.3.0 +| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 udp6:[::1]:161 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.2.0 1.3.6.1.2.1.1.3.0 """# from pysnmp.hlapi import * @@ -32,11 +28,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables-over-ipv6.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables-over-ipv6.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables-over-ipv6.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables-over-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,42 @@ +""" +Fetch scalar and table variables +++++++++++++++++++++++++++++++++ + +Send a series of SNMP GETBULK requests using the following options: + +* with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols +* over IPv6/UDP +* to an Agent at [::1]:161 +* with values non-repeaters = 1, max-repetitions = 25 +* for IP-MIB::ipAdEntAddr and all columns of the IF-MIB::ifEntry table +* stop when response OIDs leave the scopes of the table + +Functionally similar to: + +| $ snmpbulkwalk -v3 -lauthPriv -u usr-md5-des -A authkey1 -X privkey1 -Cn1, -Cr25 demo.snmplabs.com IP-MIB::ipAdEntAddr IP-MIB::ipAddrEntry + +"""# +from pysnmp.hlapi import * + +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in bulkCmd(SnmpEngine(), + UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + Udp6TransportTarget(('::1', 161)), + ContextData(), + 1, 25, + ObjectType(ObjectIdentity('IP-MIB', 'ipAdEntAddr')), + ObjectType(ObjectIdentity('IP-MIB', 'ipAddrEntry')), + lexicographicMode=False): + + if errorIndication: + print(errorIndication) + break + elif errorStatus: + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) + break + else: + for varBind in varBinds: + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -""" -Fetch scalar and table variables -++++++++++++++++++++++++++++++++ - -Send a series of SNMP GETBULK requests using the following options: - -* with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols -* over IPv6/UDP -* to an Agent at [::1]:161 -* with values non-repeaters = 1, max-repetitions = 25 -* for IP-MIB::ipAdEntAddr and all columns of the IF-MIB::ifEntry table -* stop when response OIDs leave the scopes of the table - -Functionally similar to: - -| $ snmpbulkwalk -v3 -lauthPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| -Cn1, -Cr25 \ -| demo.snmplabs.com \ -| IP-MIB::ipAdEntAddr \ -| IP-MIB::ipAddrEntry - -"""# -from pysnmp.hlapi import * - -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in bulkCmd(SnmpEngine(), - UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - Udp6TransportTarget(('::1', 161)), - ContextData(), - 1, 25, - ObjectType(ObjectIdentity('IP-MIB', 'ipAdEntAddr')), - ObjectType(ObjectIdentity('IP-MIB', 'ipAddrEntry')), - lexicographicMode=False): - - if errorIndication: - print(errorIndication) - break - elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) - break - else: - for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-packets.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-packets.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-packets.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-packets.py 2017-12-22 11:53:40.000000000 +0000 @@ -13,32 +13,29 @@ Functionally similar to: -| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 \ -| demo.snmplabs.com SNMPv2-MIB::system +| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 demo.snmplabs.com SNMPv2-MIB::system """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in bulkCmd(SnmpEngine(), - UsmUserData('usr-none-none'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 50, - ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), - maxCalls=10): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in bulkCmd(SnmpEngine(), + UsmUserData('usr-none-none'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + 0, 50, + ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), + maxCalls=10): if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-variables.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-variables.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-variables.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-variables.py 2017-12-22 11:53:40.000000000 +0000 @@ -14,33 +14,29 @@ Functionally similar to: -| $ snmpbulkwalk -v2c -c public demo.snmplabs.com \ -| -Cn0 -Cr25 \ -| 1.3.6.1.2.1.2.2 1.3.6.1.2.1.2.3 +| $ snmpbulkwalk -v2c -c public demo.snmplabs.com -Cn0 -Cr25 1.3.6.1.2.1.2.2 1.3.6.1.2.1.2.3 """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in bulkCmd(SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 25, - ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2')), - ObjectType(ObjectIdentity('1.3.6.1.2.1.2.3')), - lexicographicMode=False, maxRows=20): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in bulkCmd(SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + 0, 25, + ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2')), + ObjectType(ObjectIdentity('1.3.6.1.2.1.2.3')), + lexicographicMode=False, maxRows=20): if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex)-1][0] or '?')) break else: for varBind in varBinds: diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-limit-number-of-variables.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-limit-number-of-variables.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-limit-number-of-variables.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-limit-number-of-variables.py 2017-12-22 11:53:40.000000000 +0000 @@ -13,34 +13,30 @@ Functionally similar to: -| $ snmpwalk -v3 -lauthPriv -u usr-sha-aes128 -A authkey1 -X privkey1 \ -| -a MD5 -x AES demo.snmplabs.com \ -| SNMPv2-MIB::system +| $ snmpwalk -v3 -lauthPriv -u usr-sha-aes128 -A authkey1 -X privkey1 -a MD5 -x AES demo.snmplabs.com SNMPv2-MIB::system """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in nextCmd(SnmpEngine(), - UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', - authProtocol=usmHMACSHAAuthProtocol, - privProtocol=usmAesCfb128Protocol), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('SNMPv2-MIB')), - maxRows=100, ignoreNonIncreasingOid=True): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in nextCmd(SnmpEngine(), + UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', + authProtocol=usmHMACSHAAuthProtocol, + privProtocol=usmAesCfb128Protocol), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('SNMPv2-MIB')), + maxRows=100, ignoreNonIncreasingOid=True): if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-multiple-oids-to-eom.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-multiple-oids-to-eom.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-multiple-oids-to-eom.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/getnext-multiple-oids-to-eom.py 2017-12-22 11:53:40.000000000 +0000 @@ -12,31 +12,28 @@ Functionally similar to: -| $ snmpwalk -v2c -c public demo.snmplabs.com \ -| 1.3.6.1.2.1.2.2.1.2 1.3.6.1.2.1.2.2.1.3 +| $ snmpwalk -v2c -c public demo.snmplabs.com 1.3.6.1.2.1.2.2.1.2 1.3.6.1.2.1.2.2.1.3 """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in nextCmd(SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.2')), - ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.3')), - lexicographicMode=False): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in nextCmd(SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.2')), + ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.3')), + lexicographicMode=False): if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex)-1][0] or '?')) break else: for varBind in varBinds: diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py 2017-12-22 11:53:40.000000000 +0000 @@ -12,9 +12,7 @@ Functionally similar to: -| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| demo.snmplabs.com \ -| IF-MIB::ifInOctets.1 IF-MIB::ifOutOctets.1 +| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 demo.snmplabs.com IF-MIB::ifInOctets.1 IF-MIB::ifOutOctets.1 """# from pysnmp.hlapi import * @@ -31,11 +29,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-multiple-indices.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-multiple-indices.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-multiple-indices.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-multiple-indices.py 2017-12-22 11:53:40.000000000 +0000 @@ -11,10 +11,7 @@ Functionally similar to: -| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| -a SHA -x AES \ -| demo.snmplabs.com \ -| TCP-MIB::tcpConnLocalAddress."0.0.0.0".22."0.0.0.0".0 +| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -a SHA -x AES demo.snmplabs.com TCP-MIB::tcpConnLocalAddress."0.0.0.0".22."0.0.0.0".0 """# from pysnmp.hlapi import * @@ -23,24 +20,20 @@ getCmd(SnmpEngine(), UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', authProtocol=usmHMACSHAAuthProtocol, - privProtocol=usmAesCfb128Protocol ), + privProtocol=usmAesCfb128Protocol), UdpTransportTarget(('demo.snmplabs.com', 161)), ContextData(), ObjectType(ObjectIdentity('TCP-MIB', 'tcpConnLocalAddress', '0.0.0.0', 22, - '0.0.0.0', 0)) - ) + '0.0.0.0', 0))) ) if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/multiple-get-calls.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/multiple-get-calls.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/multiple-get-calls.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/multiple-get-calls.py 2017-12-22 11:53:40.000000000 +0000 @@ -16,14 +16,13 @@ Functionally similar to: -| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 demo.snmplabs.com \ -| IF-MIB::ifInOctets.1 +| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 demo.snmplabs.com IF-MIB::ifInOctets.1 """# from pysnmp.hlapi import * -queue = [ [ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1)) ], - [ ObjectType(ObjectIdentity('IF-MIB', 'ifOutOctets', 1)) ] ] +queue = [[ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1))], + [ObjectType(ObjectIdentity('IF-MIB', 'ifOutOctets', 1))]] iter = getCmd(SnmpEngine(), UsmUserData('usr-md5-none', 'authkey1'), @@ -37,11 +36,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/preload-pysnmp-mibs.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/preload-pysnmp-mibs.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/preload-pysnmp-mibs.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/preload-pysnmp-mibs.py 2017-12-22 11:53:40.000000000 +0000 @@ -5,39 +5,34 @@ Send a series of SNMP GETNEXT requests using the following options: * with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols -* over IPv6/UDP -* to an Agent at [::1]:161 +* over IPv4/UDP +* to an Agent at demo.snmplabs.com:161 * for all OIDs starting from 1.3.6 * preload all Python MIB modules found in search path Functionally similar to: -| $ snmpwalk -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| -m ALL -| udp6:[::1]:161 \ -| 1.3.6 +| $ snmpwalk -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -m ALL demo.snmplabs.com:161 1.3.6 """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in nextCmd(SnmpEngine(), - UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - Udp6TransportTarget(('::1', 161)), - ContextData(), - ObjectType(ObjectIdentity('1.3.6').loadMibs())): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in nextCmd(SnmpEngine(), + UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('1.3.6').loadMibs())): if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-mib.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-mib.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-mib.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-mib.py 2017-12-22 11:53:40.000000000 +0000 @@ -11,30 +11,27 @@ Functionally similar to: -| $ snmpwalk -v3 -lauthPriv -u usr-md5-none -A authkey1 -X privkey1 \ -| demo.snmplabs.com IF-MIB:: +| $ snmpwalk -v3 -lauthPriv -u usr-md5-none -A authkey1 -X privkey1 demo.snmplabs.com IF-MIB:: """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in nextCmd(SnmpEngine(), - UsmUserData('usr-md5-none', 'authkey1'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('IF-MIB'))): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in nextCmd(SnmpEngine(), + UsmUserData('usr-md5-none', 'authkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('IF-MIB'))): if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-snmp-table.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-snmp-table.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-snmp-table.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-snmp-table.py 2017-12-22 11:53:40.000000000 +0000 @@ -12,42 +12,33 @@ Functionally similar to: -| $ snmpwalk -v1 -c public demo.snmplabs.com \ -| IF-MIB::ifDescr \ -| IF-MIB::ifType \ -| IF-MIB::ifMtu \ -| IF-MIB::ifSpeed \ -| IF-MIB::ifPhysAddress \ -| IF-MIB::ifType \ +| $ snmpwalk -v1 -c public demo.snmplabs.com IF-MIB::ifDescr IF-MIB::ifType IF-MIB::ifMtu IF-MIB::ifSpeed IF-MIB::ifPhysAddress IF-MIB::ifType """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, \ - errorIndex, \ - varBinds in nextCmd(SnmpEngine(), - CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('IF-MIB', 'ifDescr')), - ObjectType(ObjectIdentity('IF-MIB', 'ifType')), - ObjectType(ObjectIdentity('IF-MIB', 'ifMtu')), - ObjectType(ObjectIdentity('IF-MIB', 'ifSpeed')), - ObjectType(ObjectIdentity('IF-MIB', 'ifPhysAddress')), - ObjectType(ObjectIdentity('IF-MIB', 'ifType')), - lexicographicMode=False): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in nextCmd(SnmpEngine(), + CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('IF-MIB', 'ifDescr')), + ObjectType(ObjectIdentity('IF-MIB', 'ifType')), + ObjectType(ObjectIdentity('IF-MIB', 'ifMtu')), + ObjectType(ObjectIdentity('IF-MIB', 'ifSpeed')), + ObjectType(ObjectIdentity('IF-MIB', 'ifPhysAddress')), + ObjectType(ObjectIdentity('IF-MIB', 'ifType')), + lexicographicMode=False): if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex)-1][0] or '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads-over-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads-over-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads-over-ipv4-and-ipv6.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads-over-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,124 @@ +""" +Query Agents from multiple threads +++++++++++++++++++++++++++++++++++ + +Send a bunch of SNMP GET requests simultaneously using the following options: + +* process 5 GET requests in 3 parallel threads +* with SNMPv1, community 'public' and + with SNMPv2c, community 'public' and + with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy +* over IPv4/UDP and + over IPv6/UDP +* to an Agent at demo.snmplabs.com:161 and + to an Agent at [::1]:161 +* for instances of SNMPv2-MIB::sysDescr.0 and + SNMPv2-MIB::sysLocation.0 MIB objects + +"""# +from sys import version_info +from threading import Thread +from pysnmp.hlapi import * + +if version_info[0] == 2: + from Queue import Queue +else: + from queue import Queue + +# List of targets in the following format: +# ( ( authData, transportTarget, varNames ), ... ) +targets = ( + # 1-st target (SNMPv1 over IPv4/UDP) + (CommunityData('public', mpModel=0), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), + # 2-nd target (SNMPv2c over IPv4/UDP) + (CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), + # 3-nd target (SNMPv2c over IPv4/UDP) - same community and + # different transport address. + (CommunityData('public'), + UdpTransportTarget(('localhost', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysContact', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0)))), + # 4-nd target (SNMPv3 over IPv4/UDP) + (UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), + # 5-th target (SNMPv3 over IPv6/UDP) + (UsmUserData('usr-md5-none', 'authkey1'), + Udp6TransportTarget(('::1', 161)), + (ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), + # N-th target + # ... +) + + +class Worker(Thread): + def __init__(self, requests, responses): + Thread.__init__(self) + self.snmpEngine = SnmpEngine() + self.requests = requests + self.responses = responses + self.setDaemon(True) + self.start() + + def run(self): + while True: + authData, transportTarget, varBinds = self.requests.get() + self.responses.append( + next(getCmd(self.snmpEngine, + authData, transportTarget, ContextData(), *varBinds)) + ) + if hasattr(self.requests, 'task_done'): # 2.5+ + self.requests.task_done() + + +class ThreadPool(object): + def __init__(self, num_threads): + self.requests = Queue(num_threads) + self.responses = [] + for _ in range(num_threads): + Worker(self.requests, self.responses) + + def addRequest(self, authData, transportTarget, varBinds): + self.requests.put((authData, transportTarget, varBinds)) + + def getResponses(self): + return self.responses + + def waitCompletion(self): + if hasattr(self.requests, 'join'): + self.requests.join() # 2.5+ + else: + from time import sleep + # this is a lame substitute for missing .join() + # adding an explicit synchronization might be a better solution + while not self.requests.empty(): + sleep(1) + + +pool = ThreadPool(3) + +# Submit GET requests +for authData, transportTarget, varBinds in targets: + pool.addRequest(authData, transportTarget, varBinds) + +# Wait for responses or errors +pool.waitCompletion() + +# Walk through responses +for errorIndication, errorStatus, errorIndex, varBinds in pool.getResponses(): + if errorIndication: + print(errorIndication) + elif errorStatus: + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) + else: + for varBind in varBinds: + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ -""" -Query Agents from multiple threads -++++++++++++++++++++++++++++++++++ - -Send a bunch of SNMP GET requests simultaneously using the following options: - -* process 5 GET requests in 3 parallel threads -* with SNMPv1, community 'public' and - with SNMPv2c, community 'public' and - with SNMPv3, user 'usr-md5-des', MD5 auth and DES privacy -* over IPv4/UDP and - over IPv6/UDP -* to an Agent at demo.snmplabs.com:161 and - to an Agent at [::1]:161 -* for instances of SNMPv2-MIB::sysDescr.0 and - SNMPv2-MIB::sysLocation.0 MIB objects - -"""# -from sys import version_info -if version_info[0] == 2: - from Queue import Queue -else: - from queue import Queue -from threading import Thread -from pysnmp.hlapi import * - -# List of targets in the followin format: -# ( ( authData, transportTarget, varNames ), ... ) -targets = ( - # 1-st target (SNMPv1 over IPv4/UDP) - ( CommunityData('public', mpModel=0), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), - # 2-nd target (SNMPv2c over IPv4/UDP) - ( CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), - # 3-nd target (SNMPv2c over IPv4/UDP) - same community and - # different transport address. - ( CommunityData('public'), - UdpTransportTarget(('localhost', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysContact', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0)))), - # 4-nd target (SNMPv3 over IPv4/UDP) - ( UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0) ))), - # 5-th target (SNMPv3 over IPv6/UDP) - ( UsmUserData('usr-md5-none', 'authkey1'), - Udp6TransportTarget(('::1', 161)), - ( ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))), - # N-th target - # ... -) - -class Worker(Thread): - def __init__(self, requests, responses): - Thread.__init__(self) - self.snmpEngine = SnmpEngine() - self.requests = requests - self.responses = responses - self.setDaemon(True) - self.start() - - def run(self): - while True: - authData, transportTarget, varBinds = self.requests.get() - self.responses.append( - next( - getCmd( - self.snmpEngine, - authData, transportTarget, ContextData(), *varBinds - ) - ) - ) - if hasattr(self.requests, 'task_done'): # 2.5+ - self.requests.task_done() - -class ThreadPool: - def __init__(self, num_threads): - self.requests = Queue(num_threads) - self.responses = [] - for _ in range(num_threads): - Worker(self.requests, self.responses) - - def addRequest(self, authData, transportTarget, varBinds): - self.requests.put((authData, transportTarget, varBinds)) - - def getResponses(self): return self.responses - - def waitCompletion(self): - if hasattr(self.requests, 'join'): - self.requests.join() # 2.5+ - else: - from time import sleep - # this is a lame substitute for missing .join() - # adding an explicit synchronization might be a better solution - while not self.requests.empty(): - sleep(1) - -pool = ThreadPool(3) - -# Submit GET requests -for authData, transportTarget, varBinds in targets: - pool.addRequest(authData, transportTarget, varBinds) - -# Wait for responses or errors -pool.waitCompletion() - -# Walk through responses -for errorIndication, errorStatus, errorIndex, varBinds in pool.getResponses(): - print('Response for %s from %s:' % (authData, transportTarget)) - if errorIndication: - print(errorIndication) - elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) - else: - for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/set-multiple-scalar-values.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/set-multiple-scalar-values.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/set-multiple-scalar-values.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/set-multiple-scalar-values.py 2017-12-22 11:53:40.000000000 +0000 @@ -15,10 +15,7 @@ Functionally similar to: -| $ snmpset -v1 -c public demo.snmplabs.com \ -| 1.3.6.1.2.1.1.9.1.2.1 o 1.3.6.1.4.1.20408.1.1 \ -| 1.3.6.1.2.1.1.9.1.2.1 = 1.3.6.1.4.1.20408.1.1 \ -| 1.3.6.1.2.1.1.9.1.3.1 s "new system name" +| $ snmpset -v1 -c public demo.snmplabs.com 1.3.6.1.2.1.1.9.1.2.1 o 1.3.6.1.4.1.20408.1.1 1.3.6.1.2.1.1.9.1.2.1 = 1.3.6.1.4.1.20408.1.1 1.3.6.1.2.1.1.9.1.3.1 s "new system name" """# from pysnmp.hlapi import * @@ -39,11 +36,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/specific-v3-engine-id.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/specific-v3-engine-id.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/specific-v3-engine-id.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/specific-v3-engine-id.py 2017-12-22 11:53:40.000000000 +0000 @@ -34,7 +34,7 @@ # Register a callback to be invoked at specified execution point of # SNMP Engine and passed local variables at execution point's local scope snmpEngine.observer.registerObserver( - lambda e,p,v,c: c.update(securityEngineId=v['securityEngineId']), + lambda e, p, v, c: c.update(securityEngineId=v['securityEngineId']), 'rfc3412.prepareDataElements:internal', cbCtx=observerContext ) @@ -62,7 +62,7 @@ # Query remote SNMP Engine using usmUserTable entry configured for it # -authData = UsmUserData('usr-md5-none', 'authkey1', +authData = UsmUserData('usr-md5-none', 'authkey1', securityEngineId=securityEngineId) errorIndication, errorStatus, errorIndex, varBinds = next( @@ -76,11 +76,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/usm-md5-des.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/usm-md5-des.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/usm-md5-des.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/usm-md5-des.py 2017-12-22 11:53:40.000000000 +0000 @@ -11,29 +11,24 @@ Functionally similar to: -| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 \ -| demo.snmplabs.com \ -| IF-MIB::ifInOctets.1 +| $ snmpget -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 demo.snmplabs.com IF-MIB::ifInOctets.1 """# from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( getCmd(SnmpEngine(), - UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1))) + UsmUserData('usr-md5-des', 'authkey1', 'privkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1))) ) if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/usm-md5-none.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/usm-md5-none.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/usm-md5-none.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/usm-md5-none.py 2017-12-22 11:53:40.000000000 +0000 @@ -11,28 +11,24 @@ Functionally similar to: -| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 demo.snmplabs.com \ -| IF-MIB::ifInOctets.1 +| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 demo.snmplabs.com IF-MIB::ifInOctets.1 """# from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( getCmd(SnmpEngine(), - UsmUserData('usr-md5-none', 'authkey1'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1))) + UsmUserData('usr-md5-none', 'authkey1'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1))) ) if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/usm-none-none.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/usm-none-none.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/usm-none-none.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/usm-none-none.py 2017-12-22 11:53:40.000000000 +0000 @@ -11,29 +11,23 @@ Functionally similar to: -| $ snmpget -v3 -l noAuthNoPriv -u usr-none-none -| demo.snmplabs.com \ -| IF-MIB::ifInOctets.1 +| $ snmpget -v3 -l noAuthNoPriv -u usr-none-none demo.snmplabs.com IF-MIB::ifInOctets.1 """# from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( getCmd(SnmpEngine(), - UsmUserData('usr-none-none'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1))) + UsmUserData('usr-none-none'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets', 1))) ) if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py 2017-12-22 11:53:40.000000000 +0000 @@ -13,6 +13,10 @@ #. usmHMACMD5AuthProtocol #. usmHMACSHAAuthProtocol +#. usmHMAC128SHA224AuthProtocol +#. usmHMAC192SHA256AuthProtocol +#. usmHMAC256SHA384AuthProtocol +#. usmHMAC384SHA512AuthProtocol #. usmNoAuthProtocol Available privacy protocols: @@ -26,32 +30,26 @@ Functionally similar to: -| $ snmpget -v3 -l authPriv -u usr-sha-aes -A authkey1 -X privkey1 \ -| -a SHA -x AES \ -| demo.snmplabs.com \ -| SNMPv2-MIB::sysDescr.0 +| $ snmpget -v3 -l authPriv -u usr-sha-aes -A authkey1 -X privkey1 -a SHA -x AES demo.snmplabs.com SNMPv2-MIB::sysDescr.0 """# from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( getCmd(SnmpEngine(), - UsmUserData('usr-sha-aes', 'authkey1', 'privkey1', - authProtocol=usmHMACSHAAuthProtocol, - privProtocol=usmAesCfb128Protocol), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))) + UsmUserData('usr-sha-aes', 'authkey1', 'privkey1', + authProtocol=usmHMACSHAAuthProtocol, + privProtocol=usmAesCfb128Protocol), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))) ) if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/v1-get.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/v1-get.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/v1-get.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/v1-get.py 2017-12-22 11:53:40.000000000 +0000 @@ -27,11 +27,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/v2c-getbulk.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/v2c-getbulk.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/v2c-getbulk.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/v2c-getbulk.py 2017-12-22 11:53:40.000000000 +0000 @@ -13,34 +13,30 @@ Functionally similar to: -| $ snmpbulkwalk -v2c -c public demo.snmplabs.com \ -| -Cn0 -Cr25 \ -| 1.3.6.1.2.1.2.2 1.3.6.1.2.1.2.3 +| $ snmpbulkwalk -v2c -c public demo.snmplabs.com -Cn0 -Cr25 1.3.6.1.2.1.2.2 1.3.6.1.2.1.2.3 """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in bulkCmd(SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 25, - ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2')), - ObjectType(ObjectIdentity('1.3.6.1.2.1.2.3')), - lexicographicMode=False): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in bulkCmd(SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + 0, 25, + ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2')), + ObjectType(ObjectIdentity('1.3.6.1.2.1.2.3')), + lexicographicMode=False): if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/v2c-get.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/v2c-get.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/v2c-get.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/v2c-get.py 2017-12-22 11:53:40.000000000 +0000 @@ -11,8 +11,7 @@ Functionally similar to: -| $ snmpget -v2c -c public demo.snmplabs.com 1.3.6.1.2.1.1.1.0 \ -| 1.3.6.1.2.1.1.6.0 +| $ snmpget -v2c -c public demo.snmplabs.com 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.6.0 """# from pysnmp.hlapi import * @@ -29,11 +28,8 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/waive-mib-lookup.py python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/waive-mib-lookup.py --- python-pysnmp4-4.3.2/examples/hlapi/asyncore/sync/manager/cmdgen/waive-mib-lookup.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/asyncore/sync/manager/cmdgen/waive-mib-lookup.py 2017-12-22 11:53:40.000000000 +0000 @@ -21,25 +21,23 @@ """# from pysnmp.hlapi import * -for errorIndication, \ - errorStatus, errorIndex, \ - varBinds in nextCmd(SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('1.3.6.1.2.1.1')), - lookupMib=False): +for (errorIndication, + errorStatus, + errorIndex, + varBinds) in nextCmd(SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('1.3.6.1.2.1.1')), + lookupMib=False): if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) break else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/trollius/agent/ntforg/default-v1-trap.py python-pysnmp4-4.4.3/examples/hlapi/trollius/agent/ntforg/default-v1-trap.py --- python-pysnmp4-4.3.2/examples/hlapi/trollius/agent/ntforg/default-v1-trap.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/trollius/agent/ntforg/default-v1-trap.py 2017-12-22 11:53:40.000000000 +0000 @@ -24,14 +24,17 @@ import trollius from pysnmp.hlapi.asyncio import * + @trollius.coroutine def run(): snmpEngine = SnmpEngine() - errorIndication, errorStatus, \ - errorIndex, varBinds = yield trollius.From( + (errorIndication, + errorStatus, + errorIndex, + varBinds) = yield trollius.From( sendNotification( snmpEngine, - CommunityData('public'), # mpModel=0), + CommunityData('public'), # mpModel=0), UdpTransportTarget(('demo.snmplabs.com', 162)), ContextData(), 'inform', @@ -47,11 +50,13 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s: at %s' % (errorStatus.prettyPrint(), errorIndex and varBinds[int(errorIndex)-1][0] or '?')) + print('%s: at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: print(' = '.join([x.prettyPrint() for x in varBind])) snmpEngine.transportDispatcher.closeDispatcher() + trollius.get_event_loop().run_until_complete(run()) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/trollius/manager/cmdgen/getbulk-to-eom.py python-pysnmp4-4.4.3/examples/hlapi/trollius/manager/cmdgen/getbulk-to-eom.py --- python-pysnmp4-4.3.2/examples/hlapi/trollius/manager/cmdgen/getbulk-to-eom.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/trollius/manager/cmdgen/getbulk-to-eom.py 2017-12-22 11:53:40.000000000 +0000 @@ -13,40 +13,39 @@ Functionally similar to: -| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 \ -| demo.snmplabs.com SNMPv2-MIB::system +| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 demo.snmplabs.com SNMPv2-MIB::system """# import trollius from pysnmp.hlapi.asyncio import * + @trollius.coroutine def run(varBinds): snmpEngine = SnmpEngine() while True: - errorIndication, errorStatus, errorIndex, \ - varBindTable = yield trollius.From( - bulkCmd(snmpEngine, - UsmUserData('usr-none-none'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - 0, 50, - *varBinds) - ) + (errorIndication, + errorStatus, + errorIndex, + varBindTable) = yield trollius.From( + bulkCmd(snmpEngine, + UsmUserData('usr-none-none'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + 0, 50, + *varBinds) + ) if errorIndication: print(errorIndication) break elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBindRow in varBindTable: for varBind in varBindRow: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) varBinds = varBindTable[-1] if isEndOfMib(varBinds): @@ -54,7 +53,9 @@ snmpEngine.transportDispatcher.closeDispatcher() + loop = trollius.get_event_loop() + loop.run_until_complete( run([ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'))]) ) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/trollius/manager/cmdgen/v1-get.py python-pysnmp4-4.4.3/examples/hlapi/trollius/manager/cmdgen/v1-get.py --- python-pysnmp4-4.3.2/examples/hlapi/trollius/manager/cmdgen/v1-get.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/trollius/manager/cmdgen/v1-get.py 2017-12-22 11:53:40.000000000 +0000 @@ -18,11 +18,14 @@ import trollius from pysnmp.hlapi.asyncio import * + @trollius.coroutine def run(): snmpEngine = SnmpEngine() - errorIndication, errorStatus, \ - errorIndex, varBinds = yield trollius.From( + (errorIndication, + errorStatus, + errorIndex, + varBinds) = yield trollius.From( getCmd(snmpEngine, CommunityData('public', mpModel=0), UdpTransportTarget(('demo.snmplabs.com', 161)), @@ -33,15 +36,13 @@ if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) snmpEngine.transportDispatcher.closeDispatcher() + trollius.get_event_loop().run_until_complete(run()) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/twisted/agent/ntforg/default-v1-trap.py python-pysnmp4-4.4.3/examples/hlapi/twisted/agent/ntforg/default-v1-trap.py --- python-pysnmp4-4.3.2/examples/hlapi/twisted/agent/ntforg/default-v1-trap.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/twisted/agent/ntforg/default-v1-trap.py 2017-12-22 11:53:40.000000000 +0000 @@ -23,21 +23,27 @@ from twisted.internet.task import react from pysnmp.hlapi.twisted import * -def success((errorStatus, errorIndex, varBinds), hostname): + +def success(args, hostname): + (errorStatus, errorIndex, varBinds) = args + if errorStatus: print('%s: %s at %s' % ( - hostname, - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) + hostname, + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?' ) + ) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + def failure(errorIndication, hostname): print('%s failure: %s' % (hostname, errorIndication)) + +# noinspection PyUnusedLocal def run(reactor, hostname): d = sendNotification( SnmpEngine(), @@ -55,4 +61,5 @@ d.addCallback(success, hostname).addErrback(failure, hostname) return d + react(run, ['demo.snmplabs.com']) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/twisted/agent/ntforg/multiple-notifications-at-once.py python-pysnmp4-4.4.3/examples/hlapi/twisted/agent/ntforg/multiple-notifications-at-once.py --- python-pysnmp4-4.3.2/examples/hlapi/twisted/agent/ntforg/multiple-notifications-at-once.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/twisted/agent/ntforg/multiple-notifications-at-once.py 2017-12-22 11:53:40.000000000 +0000 @@ -26,21 +26,24 @@ from twisted.internet.task import react from pysnmp.hlapi.twisted import * -def success((errorStatus, errorIndex, varBinds), hostname): + +def success(args, hostname): + (errorStatus, errorIndex, varBinds) = args + if errorStatus: - print('%s: %s at %s' % ( - hostname, - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s: %s at %s' % (hostname, + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + def failure(errorIndication, hostname): print('%s failure: %s' % (hostname, errorIndication)) + +# noinspection PyUnusedLocal def sendone(reactor, snmpEngine, hostname, notifyType): d = sendNotification( snmpEngine, @@ -58,13 +61,15 @@ d.addCallback(success, hostname).addErrback(failure, hostname) return d + def sendall(reactor, destinations): snmpEngine = SnmpEngine() return DeferredList( - [ sendone(reactor, snmpEngine, hostname, notifyType) - for hostname, notifyType in destinations ] + [sendone(reactor, snmpEngine, hostname, notifyType) + for hostname, notifyType in destinations] ) + react(sendall, [[('demo.snmplabs.com', 'trap'), ('demo.snmplabs.com', 'inform')]]) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/twisted/agent/ntforg/v2c-trap-inline-callbacks.py python-pysnmp4-4.4.3/examples/hlapi/twisted/agent/ntforg/v2c-trap-inline-callbacks.py --- python-pysnmp4-4.3.2/examples/hlapi/twisted/agent/ntforg/v2c-trap-inline-callbacks.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/twisted/agent/ntforg/v2c-trap-inline-callbacks.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,44 @@ +""" +SNMPv2c TRAP via Twisted inline callbacks ++++++++++++++++++++++++++++++++++++++++++ + +Send SNMPv2c TRAP through unified SNMPv3 message processing framework +using the following options: + +* SNMPv2c +* with community name 'public' +* over IPv4/UDP +* send TRAP notification +* with Generic Trap #1 (warmStart) and Specific Trap 0 +* include managed object information '1.3.6.1.2.1.1.1.0' = 'my system' + +Functionally similar to: + +| $ snmptrap -v2c -c public demo.snmplabs.com 12345 1.3.6.1.6.3.1.1.5.2 1.3.6.1.2.1.1.1.0 s "Hello from Twisted" + +"""# +from twisted.internet.task import react, defer +from pysnmp.hlapi.twisted import * + + +@defer.inlineCallbacks +def sendtrap(reactor, snmpEngine, hostname): + + yield sendNotification( + snmpEngine, + CommunityData('public', mpModel=0), + UdpTransportTarget((hostname, 162)), + ContextData(), + 'trap', + NotificationType( + ObjectIdentity('1.3.6.1.6.3.1.1.5.2') + ).addVarBinds( + ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0'), OctetString('Hello from Twisted')) + ) + ) + +# Preserve SnmpEngine instance across [potentially] multiple calls to safe on initialization +snmpEngine = SnmpEngine() + +react(sendtrap, [snmpEngine, 'demo.snmplabs.com']) + diff -Nru python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/custom-timeout-and-retries.py python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/custom-timeout-and-retries.py --- python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/custom-timeout-and-retries.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/custom-timeout-and-retries.py 2017-12-22 11:53:40.000000000 +0000 @@ -18,21 +18,24 @@ from twisted.internet.task import react from pysnmp.hlapi.twisted import * -def success((errorStatus, errorIndex, varBinds), hostname): + +def success(args, hostname): + (errorStatus, errorIndex, varBinds) = args + if errorStatus: - print('%s: %s at %s' % ( - hostname, - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s: %s at %s' % (hostname, + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + def failure(errorIndication, hostname): print('%s failure: %s' % (hostname, errorIndication)) + +# noinspection PyUnusedLocal def getSysDescr(reactor, hostname): snmpEngine = SnmpEngine() @@ -46,4 +49,5 @@ return d + react(getSysDescr, ['demo.snmplabs.com']) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/getbulk-to-eom.py python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/getbulk-to-eom.py --- python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/getbulk-to-eom.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/getbulk-to-eom.py 2017-12-22 11:53:40.000000000 +0000 @@ -13,32 +13,33 @@ Functionally similar to: -| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 \ -| demo.snmplabs.com SNMPv2-MIB::system +| $ snmpbulkwalk -v3 -lnoAuthNoPriv -u usr-none-none -Cn0 -Cr50 demo.snmplabs.com SNMPv2-MIB::system """# from twisted.internet.task import react from pysnmp.hlapi.twisted import * -def success((errorStatus, errorIndex, varBindTable), reactor, snmpEngine): + +def success(args, reactor, snmpEngine): + (errorStatus, errorIndex, varBindTable) = args + if errorStatus: - print('%s: %s at %s' % ( - hostname, - errorStatus.prettyPrint(), - errorIndex and varBindTable[0][int(errorIndex)-1][0] or '?' - ) - ) + print('%s: %s at %s' % (hostname, + errorStatus.prettyPrint(), + errorIndex and varBindTable[0][int(errorIndex) - 1][0] or '?')) else: for varBindRow in varBindTable: for varBind in varBindRow: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) if not isEndOfMib(varBindTable[-1]): return getbulk(reactor, snmpEngine, *varBindTable[-1]) + def failure(errorIndication): print(errorIndication) + def getbulk(reactor, snmpEngine, varBinds): d = bulkCmd(snmpEngine, UsmUserData('usr-none-none'), @@ -49,4 +50,5 @@ d.addCallback(success, reactor, snmpEngine).addErrback(failure) return d + react(getbulk, [SnmpEngine(), ObjectType(ObjectIdentity('SNMPv2-MIB', 'system'))]) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/multiple-concurrent-queries.py python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/multiple-concurrent-queries.py --- python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/multiple-concurrent-queries.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/multiple-concurrent-queries.py 2017-12-22 11:53:40.000000000 +0000 @@ -21,21 +21,24 @@ from twisted.internet.task import react from pysnmp.hlapi.twisted import * -def success((errorStatus, errorIndex, varBinds), hostname): + +def success(args, hostname): + (errorStatus, errorIndex, varBinds) = args + if errorStatus: - print('%s: %s at %s' % ( - hostname, - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s: %s at %s' % (hostname, + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + def failure(errorIndication, hostname): print('%s failure: %s' % (hostname, errorIndication)) + +# noinspection PyUnusedLocal def getSystem(reactor, hostname): snmpEngine = SnmpEngine() @@ -53,4 +56,5 @@ getScalar(ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)))] ) + react(getSystem, ['demo.snmplabs.com']) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py --- python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py 2017-12-22 11:53:40.000000000 +0000 @@ -19,25 +19,27 @@ from twisted.internet.task import react from pysnmp.hlapi.twisted import * -def success((errorStatus, errorIndex, varBindTable), reactor, snmpEngine, hostname): + +def success(args, reactor, snmpEngine, hostname): + (errorStatus, errorIndex, varBindTable) = args + if errorStatus: - print('%s: %s at %s' % ( - hostname, - errorStatus.prettyPrint(), - errorIndex and varBindTable[0][int(errorIndex)-1][0] or '?' - ) - ) + print('%s: %s at %s' % (hostname, + errorStatus.prettyPrint(), + errorIndex and varBindTable[0][int(errorIndex) - 1][0] or '?')) else: for varBindRow in varBindTable: for varBind in varBindRow: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) if not isEndOfMib(varBindTable[-1]): return getbulk(reactor, snmpEngine, hostname, *varBindTable[-1]) + def failure(errorIndication): print(errorIndication) + def getbulk(reactor, snmpEngine, hostname, varBinds): d = bulkCmd(snmpEngine, UsmUserData('usr-md5-none', 'authkey1'), @@ -48,14 +50,15 @@ d.addCallback(success, reactor, snmpEngine, hostname).addErrback(failure) return d + def getall(reactor, hostnames): snmpEngine = SnmpEngine() return DeferredList( - [ getbulk(reactor, snmpEngine, hostname, - ObjectType(ObjectIdentity('SNMPv2-MIB', 'system'))) - for hostname in hostnames ] + [getbulk(reactor, snmpEngine, hostname, + ObjectType(ObjectIdentity('SNMPv2-MIB', 'system'))) + for hostname in hostnames] ) -react(getall, [(('demo.snmplabs.com', 161), ('demo.snmplabs.com', 1161))]) +react(getall, [(('demo.snmplabs.com', 161), ('demo.snmplabs.com', 1161))]) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/pull-whole-mib.py python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/pull-whole-mib.py --- python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/pull-whole-mib.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/pull-whole-mib.py 2017-12-22 11:53:40.000000000 +0000 @@ -12,32 +12,33 @@ Functionally similar to: -| $ snmpwalk -v3 -lauthPriv -u usr-md5-none -A authkey1 -X privkey1 \ -| demo.snmplabs.com IF-MIB:: +| $ snmpwalk -v3 -lauthPriv -u usr-md5-none -A authkey1 -X privkey1 demo.snmplabs.com IF-MIB:: """# from twisted.internet.task import react from pysnmp.hlapi.twisted import * -def success((errorStatus, errorIndex, varBindTable), reactor, snmpEngine): + +def success(args, reactor, snmpEngine): + (errorStatus, errorIndex, varBindTable) = args + if errorStatus: - print('%s: %s at %s' % ( - hostname, - errorStatus.prettyPrint(), - errorIndex and varBindTable[0][int(errorIndex)-1][0] or '?' - ) - ) + print('%s: %s at %s' % (hostname, + errorStatus.prettyPrint(), + errorIndex and varBindTable[0][int(errorIndex) - 1][0] or '?')) else: for varBindRow in varBindTable: for varBind in varBindRow: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) if not isEndOfMib(varBindTable[-1]): return getnext(reactor, snmpEngine, *varBindTable[-1]) + def failure(errorIndication): print(errorIndication) + def getnext(reactor, snmpEngine, varBinds): d = nextCmd(snmpEngine, UsmUserData('usr-md5-none', 'authkey1'), @@ -47,4 +48,5 @@ d.addCallback(success, reactor, snmpEngine).addErrback(failure) return d + react(getnext, [SnmpEngine(), ObjectType(ObjectIdentity('SNMPv2-MIB', 'system'))]) diff -Nru python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/v1-get.py python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/v1-get.py --- python-pysnmp4-4.3.2/examples/hlapi/twisted/manager/cmdgen/v1-get.py 2015-09-27 10:26:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/hlapi/twisted/manager/cmdgen/v1-get.py 2017-12-22 11:53:40.000000000 +0000 @@ -18,21 +18,24 @@ from twisted.internet.task import react from pysnmp.hlapi.twisted import * -def success((errorStatus, errorIndex, varBinds), hostname): + +def success(args, hostname): + (errorStatus, errorIndex, varBinds) = args + if errorStatus: - print('%s: %s at %s' % ( - hostname, - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s: %s at %s' % (hostname, + errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for varBind in varBinds: - print(' = '.join([ x.prettyPrint() for x in varBind ])) + print(' = '.join([x.prettyPrint() for x in varBind])) + def failure(errorIndication, hostname): print('%s failure: %s' % (hostname, errorIndication)) + +# noinspection PyUnusedLocal def getSysDescr(reactor, hostname): d = getCmd(SnmpEngine(), CommunityData('public', mpModel=0), @@ -44,4 +47,5 @@ return d + react(getSysDescr, ['demo.snmplabs.com']) diff -Nru python-pysnmp4-4.3.2/examples/smi/agent/custom-managed-object.py python-pysnmp4-4.4.3/examples/smi/agent/custom-managed-object.py --- python-pysnmp4-4.3.2/examples/smi/agent/custom-managed-object.py 2011-11-06 20:37:09.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/smi/agent/custom-managed-object.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,4 +1,11 @@ -# Managed Objects implementation +""" +Implementing MIB objects +++++++++++++++++++++++++ + +This script explains how SNMP Agent application could model +real-world data as Managed Objects defined in MIB. + +"""# from pysnmp.smi import builder # MIB Builder is normally pre-created by SNMP engine @@ -12,26 +19,29 @@ # A base class for a custom Managed Object MibScalarInstance, = mibBuilder.importSymbols( 'SNMPv2-SMI', 'MibScalarInstance' - ) +) # Managed object specification sysLocation, = mibBuilder.importSymbols('SNMPv2-MIB', 'sysLocation') + # Custom Managed Object class MySysLocationInstance(MibScalarInstance): + # noinspection PyUnusedLocal def readGet(self, name, *args): # Just return a custom value return name, self.syntax.clone('The Leaky Cauldron') - + + sysLocationInstance = MySysLocationInstance( sysLocation.name, (0,), sysLocation.syntax - ) +) # Register Managed Object with a MIB tree mibBuilder.exportSymbols( # '__' prefixed MIB modules take precedence on indexing '__MY-LOCATION-MIB', sysLocationInstance=sysLocationInstance - ) +) if __name__ == '__main__': # diff -Nru python-pysnmp4-4.3.2/examples/smi/agent/operations-on-managed-objects.py python-pysnmp4-4.4.3/examples/smi/agent/operations-on-managed-objects.py --- python-pysnmp4-4.3.2/examples/smi/agent/operations-on-managed-objects.py 2014-01-24 12:33:49.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/smi/agent/operations-on-managed-objects.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,10 +1,18 @@ +""" +Agent operations on MIB ++++++++++++++++++++++++ + +This script explains how SNMP Agent application manipulates +its MIB possibly triggered by SNMP Manager's commands. + +"""# # SNMP agent backend e.g. Agent access to Managed Objects from pysnmp.smi import builder, instrum, exval print('Loading MIB modules...'), mibBuilder = builder.MibBuilder().loadModules( 'SNMPv2-MIB', 'SNMP-FRAMEWORK-MIB', 'SNMP-COMMUNITY-MIB' - ) +) print('done') print('Building MIB tree...'), @@ -20,21 +28,21 @@ print('Create/update SNMP-COMMUNITY-MIB::snmpCommunityEntry table row: ') varBinds = mibInstrum.writeVars( - ( (snmpCommunityEntry.name+(2,)+instanceId, 'mycomm'), - (snmpCommunityEntry.name+(3,)+instanceId, 'mynmsname'), - (snmpCommunityEntry.name+(7,)+instanceId, 'volatile') ) + ((snmpCommunityEntry.name + (2,) + instanceId, 'mycomm'), + (snmpCommunityEntry.name + (3,) + instanceId, 'mynmsname'), + (snmpCommunityEntry.name + (7,) + instanceId, 'volatile')) ) for oid, val in varBinds: - print('%s = %s' % ('.'.join([str(x) for x in oid]), val.prettyPrint())) + print('%s = %s' % ('.'.join([str(x) for x in oid]), not val.isValue and 'N/A' or val.prettyPrint())) print('done') print('Read whole MIB (table walk)') oid, val = (), None -while 1: +while True: oid, val = mibInstrum.readNextVars(((oid, val),))[0] if exval.endOfMib.isSameTypeWith(val): break - print('%s = %s' % ('.'.join([str(x) for x in oid]), val.prettyPrint())) + print('%s = %s' % ('.'.join([str(x) for x in oid]), not val.isValue and 'N/A' or val.prettyPrint())) print('done') print('Unloading MIB modules...'), diff -Nru python-pysnmp4-4.3.2/examples/smi/manager/configure-mib-viewer-and-resolve-pdu-varbinds.py python-pysnmp4-4.4.3/examples/smi/manager/configure-mib-viewer-and-resolve-pdu-varbinds.py --- python-pysnmp4-4.3.2/examples/smi/manager/configure-mib-viewer-and-resolve-pdu-varbinds.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/smi/manager/configure-mib-viewer-and-resolve-pdu-varbinds.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,37 @@ +""" +PDU var-binds to MIB objects +++++++++++++++++++++++++++++ + +This script explains how Python application could turn SNMP PDU +variable-bindings into MIB objects or the other way around. + +The code that configures MIB compiler is similar to what +happens inside the pysnmp.hlapi API. +"""# +from pysnmp.smi import builder, view, compiler, rfc1902 + +# Assemble MIB browser +mibBuilder = builder.MibBuilder() +mibViewController = view.MibViewController(mibBuilder) +compiler.addMibCompiler(mibBuilder, sources=['file:///usr/share/snmp/mibs', + 'http://mibs.snmplabs.com/asn1/@mib@']) + +# Pre-load MIB modules we expect to work with +mibBuilder.loadModules('SNMPv2-MIB', 'SNMP-COMMUNITY-MIB') + +# This is what we can get in TRAP PDU +varBinds = [ + ('1.3.6.1.2.1.1.3.0', 12345), + ('1.3.6.1.6.3.1.1.4.1.0', '1.3.6.1.6.3.1.1.5.2'), + ('1.3.6.1.6.3.18.1.3.0', '0.0.0.0'), + ('1.3.6.1.6.3.18.1.4.0', ''), + ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), + ('1.3.6.1.2.1.1.1.0', 'my system') +] + +# Run var-binds through MIB resolver +# You may want to catch and ignore resolution errors here +varBinds = [rfc1902.ObjectType(rfc1902.ObjectIdentity(x[0]), x[1]).resolveWithMib(mibViewController) for x in varBinds] + +for varBind in varBinds: + print(varBind.prettyPrint()) diff -Nru python-pysnmp4-4.3.2/examples/smi/manager/convert-between-pdu-varbinds-and-mib-objects.py python-pysnmp4-4.4.3/examples/smi/manager/convert-between-pdu-varbinds-and-mib-objects.py --- python-pysnmp4-4.3.2/examples/smi/manager/convert-between-pdu-varbinds-and-mib-objects.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/smi/manager/convert-between-pdu-varbinds-and-mib-objects.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,104 @@ +""" +MIB objects to PDU var-binds +++++++++++++++++++++++++++++ + +This script explains how Python application (typically pysnmp-based +SNMP Manager) could turn SNMP PDU variable-bindings into MIB objects +or the other way around. + +The code below does not explicitly add MIB compiler - that happens +behind the scenes. Examples below try to demo different kinds +of MIB objects to work with. +"""# +from pysnmp.smi import builder, view, rfc1902, error + +# MIB Builder manages pysnmp MIBs +mibBuilder = builder.MibBuilder() + +# MIB View Controller implements various queries to loaded MIBs +mibView = view.MibViewController(mibBuilder) + +# Obtain MIB object information by MIB object name +mibVar = rfc1902.ObjectIdentity('IF-MIB', 'ifInOctets', 1) + +# Optionally attach PySMI MIB compiler to MIB Builder that would +# create pysnmp MIBs on demand from ASN.1 sources downloaded from +# a web site. +try: + mibVar.addAsn1MibSource('http://mibs.snmplabs.com/asn1/@mib@') +except error.SmiError: + print('WARNING: not using MIB compiler (PySMI not installed)') + +mibVar.resolveWithMib(mibView) + +print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) + +# Obtain MIB object information by its [sequence] OID +mibVar = rfc1902.ObjectIdentity(tuple(mibVar)).resolveWithMib(mibView) + +print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) + +# Obtain MIB object information by its [string] OID +mibVar = rfc1902.ObjectIdentity(str(mibVar)).resolveWithMib(mibView) + +print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) + +# Obtain MIB object information by a mix of OID/label parts +mibVar = rfc1902.ObjectIdentity((1, 3, 6, 1, 2, 'mib-2', 1, 'sysDescr')).resolveWithMib(mibView) + +print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) + +# Obtain MIB object information by a label +mibVar = rfc1902.ObjectIdentity('iso.org.dod.internet.mgmt.mib-2.system.sysDescr').resolveWithMib(mibView) + +print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) + +# Obtain the first MIB object in given MIB module +mibVar = rfc1902.ObjectIdentity('SNMPv2-MIB').resolveWithMib(mibView) + +print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) + +# Obtain the last MIB object in given MIB module +mibVar = rfc1902.ObjectIdentity('SNMPv2-MIB', last=True).resolveWithMib(mibView) + +print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) + +# Another way to obtain the first (or last) symbol in MIB module +mibVar = rfc1902.ObjectIdentity('SNMPv2-MIB', '').resolveWithMib(mibView) + +print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) + +# Obtain MIB symbol from whatever MIB it is defined at (MIB should be loaded) +mibVar = rfc1902.ObjectIdentity('', 'sysDescr', 0).resolveWithMib(mibView) + +print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) + +# Create an OID-value pair (called variable-binding in SNMP) +varBind = rfc1902.ObjectType( + rfc1902.ObjectIdentity('SNMPv2-MIB', 'sysObjectID', 0), '1.3.6.1' +).resolveWithMib(mibView) + +print(varBind[0].prettyPrint(), varBind[1].__class__.__name__, varBind[1].prettyPrint()) + +# Create just OID +varBind = rfc1902.ObjectType( + rfc1902.ObjectIdentity('SNMPv2-MIB', 'sysObjectID', 0) +).resolveWithMib(mibView) + +print(varBind[0].prettyPrint(), varBind[1].__class__.__name__, varBind[1].prettyPrint()) + +# Create var-binds from MIB notification object (without OBJECTS clause) +varBinds = rfc1902.NotificationType( + rfc1902.ObjectIdentity('SNMPv2-MIB', 'coldStart') +).resolveWithMib(mibView) + +print(['%s = %s(%s)' % (x[0].prettyPrint(), x[1].__class__.__name__, x[1].prettyPrint()) for x in varBinds]) + +# Create var-binds from MIB notification object (with OBJECTS clause) +varBinds = rfc1902.NotificationType( + rfc1902.ObjectIdentity('IF-MIB', 'linkUp'), + instanceIndex=(1,), + objects={('IF-MIB', 'ifOperStatus'): 'down'} +).resolveWithMib(mibView) + +print(varBinds.prettyPrint()) diff -Nru python-pysnmp4-4.3.2/examples/smi/manager/mib-tree-inspection.py python-pysnmp4-4.4.3/examples/smi/manager/mib-tree-inspection.py --- python-pysnmp4-4.3.2/examples/smi/manager/mib-tree-inspection.py 2015-05-17 21:01:43.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/smi/manager/mib-tree-inspection.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,4 +1,12 @@ -# SNMP manager-side MIB management +""" +SNMP MIB browser +++++++++++++++++ + +This script explains how Python application (typically SNMP Manager) +could load SNMP MIB modules into memory and introspect Managed Objects +defined in MIB. + +"""# from pysnmp.smi import builder, view, compiler, error # Create MIB loader/builder diff -Nru python-pysnmp4-4.3.2/examples/smi/manager/var-binds-mib-resolution.py python-pysnmp4-4.4.3/examples/smi/manager/var-binds-mib-resolution.py --- python-pysnmp4-4.3.2/examples/smi/manager/var-binds-mib-resolution.py 2015-07-04 16:30:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/smi/manager/var-binds-mib-resolution.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -# SNMP variables MIB resolution -from pysnmp.smi import builder, view, rfc1902, error - -# MIB Builder manages pysnmp MIBs -mibBuilder = builder.MibBuilder() - -# MIB View Controller implements various queries to loaded MIBs -mibView = view.MibViewController(mibBuilder) - -# Obtain MIB object information by MIB object name -mibVar = rfc1902.ObjectIdentity('IF-MIB', 'ifInOctets', 1) - -# Optionally attach PySMI MIB compiler to MIB Builder that would -# create pysnmp MIBs on demand from ASN.1 sources downloaded from -# a web site. -try: - mibVar.addAsn1MibSource('http://mibs.snmplabs.com/asn1/@mib@') -except error.SmiError: - print('WARNING: not using MIB compiler (PySMI not installed)') - -mibVar.resolveWithMib(mibView) - -print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) - -# Obtain MIB object information by its [sequence] OID -mibVar = rfc1902.ObjectIdentity(tuple(mibVar)).resolveWithMib(mibView) - -print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) - -# Obtain MIB object information by its [string] OID -mibVar = rfc1902.ObjectIdentity(str(mibVar)).resolveWithMib(mibView) - -print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) - -# Obtain MIB object information by a mix of OID/label parts -mibVar = rfc1902.ObjectIdentity((1,3,6,1,2,'mib-2',1,'sysDescr')).resolveWithMib(mibView) - -print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) - -# Obtain MIB object information by a label -mibVar = rfc1902.ObjectIdentity('iso.org.dod.internet.mgmt.mib-2.system.sysDescr').resolveWithMib(mibView) - -print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) - -# Obtain the first MIB object in given MIB module -mibVar = rfc1902.ObjectIdentity('SNMPv2-MIB').resolveWithMib(mibView) - -print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) - -# Obtain the last MIB object in given MIB module -mibVar = rfc1902.ObjectIdentity('SNMPv2-MIB', last=True).resolveWithMib(mibView) - -print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) - -# Another way to obtain the first (or last) symbol in MIB module -mibVar = rfc1902.ObjectIdentity('SNMPv2-MIB', '').resolveWithMib(mibView) - -print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) - -# Obtain MIB symbol from whatever MIB it is defined at (MIB should be loaded) -mibVar = rfc1902.ObjectIdentity('', 'sysDescr', 0).resolveWithMib(mibView) - -print(mibVar.prettyPrint(), tuple(mibVar), str(mibVar)) - -# Create an OID-value pair (called variable-binding in SNMP) -varBind = rfc1902.ObjectType( - rfc1902.ObjectIdentity('SNMPv2-MIB', 'sysObjectID', 0), '1.3.6.1' -).resolveWithMib(mibView) - -print(varBind[0].prettyPrint(), varBind[1].__class__.__name__, varBind[1].prettyPrint()) - -# Create just OID -varBind = rfc1902.ObjectType( - rfc1902.ObjectIdentity('SNMPv2-MIB', 'sysObjectID', 0) -).resolveWithMib(mibView) - -print(varBind[0].prettyPrint(), varBind[1].__class__.__name__, varBind[1].prettyPrint()) - -# Create var-binds from MIB notification object (without OBJECTS clause) -varBinds = rfc1902.NotificationType( - rfc1902.ObjectIdentity('SNMPv2-MIB', 'coldStart') -).resolveWithMib(mibView) - -print([ '%s = %s(%s)' % (x[0].prettyPrint(), x[1].__class__.__name__, x[1].prettyPrint()) for x in varBinds]) - -# Create var-binds from MIB notification object (with OBJECTS clause) -varBinds = rfc1902.NotificationType( - rfc1902.ObjectIdentity('IF-MIB', 'linkUp'), - instanceIndex = (1,), - objects= { ('IF-MIB', 'ifOperStatus'): 'down' } -).resolveWithMib(mibView) - -print(varBinds.prettyPrint()) - diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects-over-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects-over-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects-over-ipv4-and-ipv6.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects-over-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,165 @@ +""" +Implementing scalar MIB objects ++++++++++++++++++++++++++++++++ + +Listen and respond to SNMP GET/GETNEXT queries with the following options: + +* SNMPv1 or SNMPv2c +* with SNMP community "public" +* over IPv4/UDP, listening at 127.0.0.1:161 +* over IPv6/UDP, listening at [::1]:161 +* serving two Managed Objects Instances (sysDescr.0 and sysUptime.0) + +Either of the following Net-SNMP commands will walk this Agent: + +| $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 +| $ snmpwalk -v2c -c public udp6:[::1] .1.3.6 + +The Command Receiver below uses two distinct transports for communication +with Command Generators - UDP over IPv4 and UDP over IPv6. + +"""# +from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher +from pysnmp.carrier.asyncore.dgram import udp, udp6, unix +from pyasn1.codec.ber import encoder, decoder +from pysnmp.proto import api +import time, bisect + + +class SysDescr(object): + name = (1, 3, 6, 1, 2, 1, 1, 1, 0) + + def __eq__(self, other): return self.name == other + + def __ne__(self, other): return self.name != other + + def __lt__(self, other): return self.name < other + + def __le__(self, other): return self.name <= other + + def __gt__(self, other): return self.name > other + + def __ge__(self, other): return self.name >= other + + def __call__(self, protoVer): + return api.protoModules[protoVer].OctetString( + 'PySNMP example command responder' + ) + + +class Uptime(object): + name = (1, 3, 6, 1, 2, 1, 1, 3, 0) + birthday = time.time() + + def __eq__(self, other): return self.name == other + + def __ne__(self, other): return self.name != other + + def __lt__(self, other): return self.name < other + + def __le__(self, other): return self.name <= other + + def __gt__(self, other): return self.name > other + + def __ge__(self, other): return self.name >= other + + def __call__(self, protoVer): + return api.protoModules[protoVer].TimeTicks( + (time.time() - self.birthday) * 100 + ) + + +mibInstr = ( + SysDescr(), Uptime() # sorted by object name +) + +mibInstrIdx = {} +for mibVar in mibInstr: + mibInstrIdx[mibVar.name] = mibVar + + +def cbFun(transportDispatcher, transportDomain, transportAddress, wholeMsg): + while wholeMsg: + msgVer = api.decodeMessageVersion(wholeMsg) + if msgVer in api.protoModules: + pMod = api.protoModules[msgVer] + else: + print('Unsupported SNMP version %s' % msgVer) + return + reqMsg, wholeMsg = decoder.decode( + wholeMsg, asn1Spec=pMod.Message(), + ) + rspMsg = pMod.apiMessage.getResponse(reqMsg) + rspPDU = pMod.apiMessage.getPDU(rspMsg) + reqPDU = pMod.apiMessage.getPDU(reqMsg) + varBinds = [] + pendingErrors = [] + errorIndex = 0 + # GETNEXT PDU + if reqPDU.isSameTypeWith(pMod.GetNextRequestPDU()): + # Produce response var-binds + for oid, val in pMod.apiPDU.getVarBinds(reqPDU): + errorIndex = errorIndex + 1 + # Search next OID to report + nextIdx = bisect.bisect(mibInstr, oid) + if nextIdx == len(mibInstr): + # Out of MIB + varBinds.append((oid, val)) + pendingErrors.append( + (pMod.apiPDU.setEndOfMibError, errorIndex) + ) + else: + # Report value if OID is found + varBinds.append( + (mibInstr[nextIdx].name, mibInstr[nextIdx](msgVer)) + ) + elif reqPDU.isSameTypeWith(pMod.GetRequestPDU()): + for oid, val in pMod.apiPDU.getVarBinds(reqPDU): + if oid in mibInstrIdx: + varBinds.append((oid, mibInstrIdx[oid](msgVer))) + else: + # No such instance + varBinds.append((oid, val)) + pendingErrors.append( + (pMod.apiPDU.setNoSuchInstanceError, errorIndex) + ) + break + else: + # Report unsupported request type + pMod.apiPDU.setErrorStatus(rspPDU, 'genErr') + pMod.apiPDU.setVarBinds(rspPDU, varBinds) + # Commit possible error indices to response PDU + for f, i in pendingErrors: + f(rspPDU, i) + transportDispatcher.sendMessage( + encoder.encode(rspMsg), transportDomain, transportAddress + ) + return wholeMsg + + +transportDispatcher = AsyncoreDispatcher() +transportDispatcher.registerRecvCbFun(cbFun) + +# UDP/IPv4 +transportDispatcher.registerTransport( + udp.domainName, udp.UdpSocketTransport().openServerMode(('localhost', 161)) +) + +# UDP/IPv6 +transportDispatcher.registerTransport( + udp6.domainName, udp6.Udp6SocketTransport().openServerMode(('::1', 161)) +) + +## Local domain socket +# transportDispatcher.registerTransport( +# unix.domainName, unix.UnixSocketTransport().openServerMode('/tmp/snmp-agent') +# ) + +transportDispatcher.jobStarted(1) + +try: + # Dispatcher will never finish as job#1 never reaches zero + transportDispatcher.runDispatcher() +except: + transportDispatcher.closeDispatcher() + raise diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py 2015-09-14 05:20:25.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -""" -Implementing scalar MIB objects -+++++++++++++++++++++++++++++++ - -Listen and respond to SNMP GET/GETNEXT queries with the following options: - -* SNMPv1 or SNMPv2c -* with SNMP community "public" -* over IPv4/UDP, listening at 127.0.0.1:161 -* over IPv6/UDP, listening at [::1]:161 -* serving two Managed Objects Instances (sysDescr.0 and sysUptime.0) - -Either of the following Net-SNMP commands will walk this Agent: - -| $ snmpwalk -v2c -c public 127.0.0.1 .1.3.6 -| $ snmpwalk -v2c -c public udp6:[::1] .1.3.6 - -The Command Receiver below uses two distinct transports for communication -with Command Generators - UDP over IPv4 and UDP over IPv6. - -"""# -from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher -from pysnmp.carrier.asyncore.dgram import udp, udp6, unix -from pyasn1.codec.ber import encoder, decoder -from pysnmp.proto import api -import time, bisect - -class SysDescr: - name = (1,3,6,1,2,1,1,1,0) - def __eq__(self, other): return self.name == other - def __ne__(self, other): return self.name != other - def __lt__(self, other): return self.name < other - def __le__(self, other): return self.name <= other - def __gt__(self, other): return self.name > other - def __ge__(self, other): return self.name >= other - def __call__(self, protoVer): - return api.protoModules[protoVer].OctetString( - 'PySNMP example command responder' - ) - -class Uptime: - name = (1,3,6,1,2,1,1,3,0) - birthday = time.time() - def __eq__(self, other): return self.name == other - def __ne__(self, other): return self.name != other - def __lt__(self, other): return self.name < other - def __le__(self, other): return self.name <= other - def __gt__(self, other): return self.name > other - def __ge__(self, other): return self.name >= other - def __call__(self, protoVer): - return api.protoModules[protoVer].TimeTicks( - (time.time()-self.birthday)*100 - ) - -mibInstr = ( - SysDescr(), Uptime() # sorted by object name - ) - -mibInstrIdx = {} -for mibVar in mibInstr: - mibInstrIdx[mibVar.name] = mibVar - -def cbFun(transportDispatcher, transportDomain, transportAddress, wholeMsg): - while wholeMsg: - msgVer = api.decodeMessageVersion(wholeMsg) - if msgVer in api.protoModules: - pMod = api.protoModules[msgVer] - else: - print('Unsupported SNMP version %s' % msgVer) - return - reqMsg, wholeMsg = decoder.decode( - wholeMsg, asn1Spec=pMod.Message(), - ) - rspMsg = pMod.apiMessage.getResponse(reqMsg) - rspPDU = pMod.apiMessage.getPDU(rspMsg) - reqPDU = pMod.apiMessage.getPDU(reqMsg) - varBinds = []; pendingErrors = [] - errorIndex = 0 - # GETNEXT PDU - if reqPDU.isSameTypeWith(pMod.GetNextRequestPDU()): - # Produce response var-binds - for oid, val in pMod.apiPDU.getVarBinds(reqPDU): - errorIndex = errorIndex + 1 - # Search next OID to report - nextIdx = bisect.bisect(mibInstr, oid) - if nextIdx == len(mibInstr): - # Out of MIB - varBinds.append((oid, val)) - pendingErrors.append( - (pMod.apiPDU.setEndOfMibError, errorIndex) - ) - else: - # Report value if OID is found - varBinds.append( - (mibInstr[nextIdx].name, mibInstr[nextIdx](msgVer)) - ) - elif reqPDU.isSameTypeWith(pMod.GetRequestPDU()): - for oid, val in pMod.apiPDU.getVarBinds(reqPDU): - if oid in mibInstrIdx: - varBinds.append((oid, mibInstrIdx[oid](msgVer))) - else: - # No such instance - varBinds.append((oid, val)) - pendingErrors.append( - (pMod.apiPDU.setNoSuchInstanceError, errorIndex) - ) - break - else: - # Report unsupported request type - pMod.apiPDU.setErrorStatus(rspPDU, 'genErr') - pMod.apiPDU.setVarBinds(rspPDU, varBinds) - # Commit possible error indices to response PDU - for f, i in pendingErrors: - f(rspPDU, i) - transportDispatcher.sendMessage( - encoder.encode(rspMsg), transportDomain, transportAddress - ) - return wholeMsg - -transportDispatcher = AsyncoreDispatcher() -transportDispatcher.registerRecvCbFun(cbFun) - -# UDP/IPv4 -transportDispatcher.registerTransport( - udp.domainName, udp.UdpSocketTransport().openServerMode(('localhost', 161)) -) - -# UDP/IPv6 -transportDispatcher.registerTransport( - udp6.domainName, udp6.Udp6SocketTransport().openServerMode(('::1', 161)) -) - -## Local domain socket -#transportDispatcher.registerTransport( -# unix.domainName, unix.UnixSocketTransport().openServerMode('/tmp/snmp-agent') -#) - -transportDispatcher.jobStarted(1) - -try: - # Dispatcher will never finish as job#1 never reaches zero - transportDispatcher.runDispatcher() -except: - transportDispatcher.closeDispatcher() - raise diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/agent/ntforg/send-inform-over-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/agent/ntforg/send-inform-over-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/agent/ntforg/send-inform-over-ipv4-and-ipv6.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/agent/ntforg/send-inform-over-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -8,7 +8,7 @@ * with community name 'public' * over IPv4/UDP and IPv6/UDP * send INFORM notification -* to a Manager at 195.218.195.228:162 and [::1]:162 +* to a Manager at demo.snmplabs.com:162 and [::1]:162 * with TRAP ID 'coldStart' specified as an OID The following Net-SNMP command will produce similar SNMP notification: @@ -20,11 +20,11 @@ from time import time from pysnmp.carrier.asynsock.dispatch import AsynsockDispatcher from pysnmp.carrier.asynsock.dgram import udp, udp6 -from pyasn1.codec.ber import encoder +from pyasn1.codec.ber import encoder, decoder from pysnmp.proto.api import v2c as pMod # Build PDU -reqPDU = pMod.InformRequestPDU() +reqPDU = pMod.InformRequestPDU() pMod.apiTrapPDU.setDefaults(reqPDU) # Build message @@ -35,17 +35,20 @@ startedAt = time() + def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise Exception("Request timed out") - + + +# noinspection PyUnusedLocal,PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU): while wholeMsg: rspMsg, wholeMsg = decoder.decode(wholeMsg, asn1Spec=pMod.Message()) rspPDU = pMod.apiMessage.getPDU(rspMsg) # Match response to request - if pMod.apiPDU.getRequestID(reqPDU)==pMod.apiPDU.getRequestID(rspPDU): + if pMod.apiPDU.getRequestID(reqPDU) == pMod.apiPDU.getRequestID(rspPDU): # Check for SNMP errors reported errorStatus = pMod.apiPDU.getErrorStatus(rspPDU) if errorStatus: @@ -56,7 +59,8 @@ print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) transportDispatcher.jobFinished(1) return wholeMsg - + + transportDispatcher = AsynsockDispatcher() transportDispatcher.registerRecvCbFun(cbRecvFun) @@ -72,13 +76,13 @@ transportDispatcher.jobStarted(1) # UDP/IPv6 -transportDispatcher.registerTransport( - udp6.domainName, udp6.Udp6SocketTransport().openClientMode() -) -transportDispatcher.sendMessage( - encoder.encode(trapMsg), udp6.domainName, ('::1', 162) -) -transportDispatcher.jobStarted(1) +# transportDispatcher.registerTransport( +# udp6.domainName, udp6.Udp6SocketTransport().openClientMode() +# ) +# transportDispatcher.sendMessage( +# encoder.encode(trapMsg), udp6.domainName, ('::1', 162) +# ) +# transportDispatcher.jobStarted(1) # Dispatcher will finish as all scheduled messages are sent transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/agent/ntforg/send-trap-over-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/agent/ntforg/send-trap-over-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/agent/ntforg/send-trap-over-ipv4-and-ipv6.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/agent/ntforg/send-trap-over-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -9,7 +9,7 @@ * with community name 'public' * over IPv4/UDP and IPv6/UDP * send TRAP notification -* to a Manager at 195.218.195.228:162 and [::1] +* to a Manager at demo.snmplabs.com:162 and [::1] * with TRAP ID 'coldStart' specified as an OID * include managed objects information: * with default Uptime value @@ -29,15 +29,15 @@ # Protocol version to use pMod = api.protoModules[api.protoVersion1] -#pMod = api.protoModules[api.protoVersion2c] +# pMod = api.protoModules[api.protoVersion2c] # Build PDU -trapPDU = pMod.TrapPDU() +trapPDU = pMod.TrapPDU() pMod.apiTrapPDU.setDefaults(trapPDU) # Traps have quite different semantics across proto versions if pMod == api.protoModules[api.protoVersion1]: - pMod.apiTrapPDU.setEnterprise(trapPDU, (1,3,6,1,1,2,3,4,1)) + pMod.apiTrapPDU.setEnterprise(trapPDU, (1, 3, 6, 1, 1, 2, 3, 4, 1)) pMod.apiTrapPDU.setGenericTrap(trapPDU, 'coldStart') # Build message @@ -65,12 +65,12 @@ ) ## Local domain socket -#transportDispatcher.registerTransport( +# transportDispatcher.registerTransport( # unix.domainName, unix.UnixSocketTransport().openClientMode() -#) -#transportDispatcher.sendMessage( +# ) +# transportDispatcher.sendMessage( # encoder.encode(trapMsg), unix.domainName, '/tmp/snmp-manager' -#) +# ) # Dispatcher will finish as all scheduled messages are sent transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py 2015-09-14 05:20:25.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py 2017-12-22 11:53:40.000000000 +0000 @@ -31,16 +31,16 @@ maxNumberResponses = 10 # Protocol version to use -#pMod = api.protoModules[api.protoVersion1] +# pMod = api.protoModules[api.protoVersion1] pMod = api.protoModules[api.protoVersion2c] # Build PDU -reqPDU = pMod.GetRequestPDU() +reqPDU = pMod.GetRequestPDU() pMod.apiPDU.setDefaults(reqPDU) pMod.apiPDU.setVarBinds( - reqPDU, ( ('1.3.6.1.2.1.1.1.0', pMod.Null('')), - ('1.3.6.1.2.1.1.3.0', pMod.Null('')) ) - ) + reqPDU, (('1.3.6.1.2.1.1.1.0', pMod.Null('')), + ('1.3.6.1.2.1.1.3.0', pMod.Null(''))) +) # Build message reqMsg = pMod.Message() @@ -50,19 +50,23 @@ startedAt = time() + class StopWaiting(Exception): pass + def cbTimerFun(timeNow): if timeNow - startedAt > maxWaitForResponses: raise StopWaiting() - + + +# noinspection PyUnusedLocal,PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU): while wholeMsg: rspMsg, wholeMsg = decoder.decode(wholeMsg, asn1Spec=pMod.Message()) rspPDU = pMod.apiMessage.getPDU(rspMsg) # Match response to request - if pMod.apiPDU.getRequestID(reqPDU)==pMod.apiPDU.getRequestID(rspPDU): + if pMod.apiPDU.getRequestID(reqPDU) == pMod.apiPDU.getRequestID(rspPDU): # Check for SNMP errors reported errorStatus = pMod.apiPDU.getErrorStatus(rspPDU) if errorStatus: @@ -73,6 +77,7 @@ transportDispatcher.jobFinished(1) return wholeMsg + transportDispatcher = AsyncoreDispatcher() transportDispatcher.registerRecvCbFun(cbRecvFun) diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/fetch-scalar-value.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/fetch-scalar-value.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/fetch-scalar-value.py 2015-09-14 05:20:25.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/fetch-scalar-value.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,12 +6,12 @@ * with SNMPv1, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at demo.snmplabs.com:161 * for OIDs in tuple form This script performs similar to the following Net-SNMP command: -| $ snmpget -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.3.0 +| $ snmpget -v1 -c public -ObentU demo.snmplabs.com 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.3.0 """# from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher @@ -22,15 +22,15 @@ # Protocol version to use pMod = api.protoModules[api.protoVersion1] -#pMod = api.protoModules[api.protoVersion2c] +# pMod = api.protoModules[api.protoVersion2c] # Build PDU -reqPDU = pMod.GetRequestPDU() +reqPDU = pMod.GetRequestPDU() pMod.apiPDU.setDefaults(reqPDU) pMod.apiPDU.setVarBinds( - reqPDU, ( ('1.3.6.1.2.1.1.1.0', pMod.Null('')), - ('1.3.6.1.2.1.1.3.0', pMod.Null('')) ) - ) + reqPDU, (('1.3.6.1.2.1.1.1.0', pMod.Null('')), + ('1.3.6.1.2.1.1.3.0', pMod.Null(''))) +) # Build message reqMsg = pMod.Message() @@ -40,17 +40,20 @@ startedAt = time() + def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise Exception("Request timed out") - + + +# noinspection PyUnusedLocal,PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU): while wholeMsg: rspMsg, wholeMsg = decoder.decode(wholeMsg, asn1Spec=pMod.Message()) rspPDU = pMod.apiMessage.getPDU(rspMsg) # Match response to request - if pMod.apiPDU.getRequestID(reqPDU)==pMod.apiPDU.getRequestID(rspPDU): + if pMod.apiPDU.getRequestID(reqPDU) == pMod.apiPDU.getRequestID(rspPDU): # Check for SNMP errors reported errorStatus = pMod.apiPDU.getErrorStatus(rspPDU) if errorStatus: @@ -61,6 +64,7 @@ transportDispatcher.jobFinished(1) return wholeMsg + transportDispatcher = AsyncoreDispatcher() transportDispatcher.registerRecvCbFun(cbRecvFun) @@ -78,26 +82,26 @@ transportDispatcher.jobStarted(1) ## UDP/IPv6 (second copy of the same PDU will be sent) -transportDispatcher.registerTransport( - udp6.domainName, udp6.Udp6SocketTransport().openClientMode() -) +# transportDispatcher.registerTransport( +# udp6.domainName, udp6.Udp6SocketTransport().openClientMode() +# ) # Pass message to dispatcher -transportDispatcher.sendMessage( - encoder.encode(reqMsg), udp6.domainName, ('::1', 161) -) -transportDispatcher.jobStarted(1) +# transportDispatcher.sendMessage( +# encoder.encode(reqMsg), udp6.domainName, ('::1', 161) +# ) +# transportDispatcher.jobStarted(1) ## Local domain socket -#transportDispatcher.registerTransport( +# transportDispatcher.registerTransport( # unix.domainName, unix.UnixSocketTransport().openClientMode() -#) +# ) # # Pass message to dispatcher -#transportDispatcher.sendMessage( +# transportDispatcher.sendMessage( # encoder.encode(reqMsg), unix.domainName, '/tmp/snmp-agent' -#) -#transportDispatcher.jobStarted(1) +# ) +# transportDispatcher.jobStarted(1) # Dispatcher will finish as job#1 counter reaches zero transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/getbulk-pull-whole-mib.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/getbulk-pull-whole-mib.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/getbulk-pull-whole-mib.py 2015-09-14 05:20:25.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/getbulk-pull-whole-mib.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,13 +6,13 @@ * with SNMPv2c, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at demo.snmplabs.com:161 * for OID in tuple form * with non-repeaters=0 and max-repeaters=25 This script performs similar to the following Net-SNMP command: -| $ snmpbulkwalk -v2c -c public -ObentU -Cn0 -Cr25 195.218.195.228 1.3.6 +| $ snmpbulkwalk -v2c -c public -ObentU -Cn0 -Cr25 demo.snmplabs.com 1.3.6 """# from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher @@ -22,14 +22,14 @@ from time import time # SNMP table header -headVars = [ v2c.ObjectIdentifier((1,3,6)) ] +headVars = [v2c.ObjectIdentifier((1, 3, 6))] # Build PDU -reqPDU = v2c.GetBulkRequestPDU() +reqPDU = v2c.GetBulkRequestPDU() v2c.apiBulkPDU.setDefaults(reqPDU) v2c.apiBulkPDU.setNonRepeaters(reqPDU, 0) v2c.apiBulkPDU.setMaxRepetitions(reqPDU, 25) -v2c.apiBulkPDU.setVarBinds(reqPDU, [ (x, v2c.null) for x in headVars ]) +v2c.apiBulkPDU.setVarBinds(reqPDU, [(x, v2c.null) for x in headVars]) # Build message reqMsg = v2c.Message() @@ -39,10 +39,13 @@ startedAt = time() + def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise Exception("Request timed out") + +# noinspection PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU, headVars=headVars): while wholeMsg: @@ -51,7 +54,7 @@ rspPDU = v2c.apiMessage.getPDU(rspMsg) # Match response to request - if v2c.apiBulkPDU.getRequestID(reqPDU)==v2c.apiBulkPDU.getRequestID(rspPDU): + if v2c.apiBulkPDU.getRequestID(reqPDU) == v2c.apiBulkPDU.getRequestID(rspPDU): # Format var-binds table varBindTable = v2c.apiBulkPDU.getVarBindTable(reqPDU, rspPDU) @@ -60,7 +63,7 @@ if errorStatus and errorStatus != 2: errorIndex = v2c.apiBulkPDU.getErrorIndex(rspPDU) print('%s at %s' % (errorStatus.prettyPrint(), - errorIndex and varBindTable[int(errorIndex)-1] or '?')) + errorIndex and varBindTable[int(errorIndex) - 1] or '?')) transportDispatcher.jobFinished(1) break @@ -69,8 +72,8 @@ for name, val in tableRow: print('from: %s, %s = %s' % ( transportAddress, name.prettyPrint(), val.prettyPrint() - ) ) + ) # Stop on EOM for oid, val in varBindTable[-1]: @@ -78,21 +81,22 @@ break else: transportDispatcher.jobFinished(1) - + # Generate request for next row v2c.apiBulkPDU.setVarBinds( - reqPDU, [ (x, v2c.null) for x,y in varBindTable[-1] ] - ) + reqPDU, [(x, v2c.null) for x, y in varBindTable[-1]] + ) v2c.apiBulkPDU.setRequestID(reqPDU, v2c.getNextRequestID()) transportDispatcher.sendMessage( encoder.encode(reqMsg), transportDomain, transportAddress - ) + ) global startedAt if time() - startedAt > 3: raise Exception('Request timed out') startedAt = time() return wholeMsg + transportDispatcher = AsyncoreDispatcher() transportDispatcher.registerRecvCbFun(cbRecvFun) diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/getnext-pull-whole-mib.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/getnext-pull-whole-mib.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/getnext-pull-whole-mib.py 2015-09-14 05:20:25.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/getnext-pull-whole-mib.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,12 +6,12 @@ * with SNMPv1, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at demo.snmplabs.com:161 * for OID in tuple form This script performs similar to the following Net-SNMP command: -| $ snmpwalk -v1 -c public -ObentU 195.218.195.228 1.3.6 +| $ snmpwalk -v1 -c public -ObentU demo.snmplabs.com 1.3.6 """# from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher @@ -22,15 +22,15 @@ # Protocol version to use pMod = api.protoModules[api.protoVersion1] -#pMod = api.protoModules[api.protoVersion2c] +# pMod = api.protoModules[api.protoVersion2c] # SNMP table header -headVars = [ pMod.ObjectIdentifier((1,3,6)) ] +headVars = [pMod.ObjectIdentifier((1, 3, 6))] # Build PDU -reqPDU = pMod.GetNextRequestPDU() +reqPDU = pMod.GetNextRequestPDU() pMod.apiPDU.setDefaults(reqPDU) -pMod.apiPDU.setVarBinds(reqPDU, [ (x, pMod.null) for x in headVars ]) +pMod.apiPDU.setVarBinds(reqPDU, [(x, pMod.null) for x in headVars]) # Build message reqMsg = pMod.Message() @@ -40,17 +40,20 @@ startedAt = time() + def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise Exception("Request timed out") + +# noinspection PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU, headVars=headVars): while wholeMsg: rspMsg, wholeMsg = decoder.decode(wholeMsg, asn1Spec=pMod.Message()) rspPDU = pMod.apiMessage.getPDU(rspMsg) # Match response to request - if pMod.apiPDU.getRequestID(reqPDU)==pMod.apiPDU.getRequestID(rspPDU): + if pMod.apiPDU.getRequestID(reqPDU) == pMod.apiPDU.getRequestID(rspPDU): # Check for SNMP errors reported errorStatus = pMod.apiPDU.getErrorStatus(rspPDU) if errorStatus and errorStatus != 2: @@ -62,29 +65,30 @@ for name, val in tableRow: print('from: %s, %s = %s' % ( transportAddress, name.prettyPrint(), val.prettyPrint() - ) ) + ) # Stop on EOM for oid, val in varBindTable[-1]: if not isinstance(val, pMod.Null): break else: transportDispatcher.jobFinished(1) - + # Generate request for next row pMod.apiPDU.setVarBinds( - reqPDU, [ (x, pMod.null) for x,y in varBindTable[-1] ] - ) + reqPDU, [(x, pMod.null) for x, y in varBindTable[-1]] + ) pMod.apiPDU.setRequestID(reqPDU, pMod.getNextRequestID()) transportDispatcher.sendMessage( encoder.encode(reqMsg), transportDomain, transportAddress - ) + ) global startedAt if time() - startedAt > 3: raise Exception('Request timed out') startedAt = time() return wholeMsg + transportDispatcher = AsyncoreDispatcher() transportDispatcher.registerRecvCbFun(cbRecvFun) diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/spoof-source-address.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/spoof-source-address.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/spoof-source-address.py 2015-09-14 05:20:25.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/spoof-source-address.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,13 +6,13 @@ * with SNMPv2c, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * from a non-local, spoofed IP 1.2.3.4 (root and Python 3.3+ required) * for OIDs in string form This script performs similar to the following Net-SNMP command: -| $ snmpget -v2c -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.3.0 +| $ snmpget -v2c -c public -ObentU 104.236.166.95 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.3.0 But unlike the above command, this script issues SNMP request from a non-default, non-local IP address. @@ -35,22 +35,22 @@ from time import time # Send request message to this address -transportAddress = udp.UdpTransportAddress(('195.218.195.228', 161)) +transportAddress = udp.UdpTransportAddress(('104.236.166.95', 161)) # Send request message from this non-local (!) IP address transportAddress.setLocalAddress(('1.2.3.4', 0)) # Protocol version to use -#pMod = api.protoModules[api.protoVersion1] +# pMod = api.protoModules[api.protoVersion1] pMod = api.protoModules[api.protoVersion2c] # Build PDU -reqPDU = pMod.GetRequestPDU() +reqPDU = pMod.GetRequestPDU() pMod.apiPDU.setDefaults(reqPDU) pMod.apiPDU.setVarBinds( - reqPDU, ( ('1.3.6.1.2.1.1.1.0', pMod.Null('')), - ('1.3.6.1.2.1.1.3.0', pMod.Null('')) ) - ) + reqPDU, (('1.3.6.1.2.1.1.1.0', pMod.Null('')), + ('1.3.6.1.2.1.1.3.0', pMod.Null(''))) +) # Build message reqMsg = pMod.Message() @@ -60,19 +60,23 @@ startedAt = time() + class StopWaiting(Exception): pass + def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise StopWaiting() - + + +# noinspection PyUnusedLocal,PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU): while wholeMsg: rspMsg, wholeMsg = decoder.decode(wholeMsg, asn1Spec=pMod.Message()) rspPDU = pMod.apiMessage.getPDU(rspMsg) # Match response to request - if pMod.apiPDU.getRequestID(reqPDU)==pMod.apiPDU.getRequestID(rspPDU): + if pMod.apiPDU.getRequestID(reqPDU) == pMod.apiPDU.getRequestID(rspPDU): # Check for SNMP errors reported errorStatus = pMod.apiPDU.getErrorStatus(rspPDU) if errorStatus: @@ -83,6 +87,7 @@ transportDispatcher.jobFinished(1) return wholeMsg + transportDispatcher = AsyncoreDispatcher() transportDispatcher.registerRecvCbFun(cbRecvFun) diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/v2c-set.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/v2c-set.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/cmdgen/v2c-set.py 2015-09-14 05:20:25.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/cmdgen/v2c-set.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,12 +6,12 @@ * with SNMPv2c, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at demo.snmplabs.com:161 * for OIDs in string form and values in form of pyasn1 objects This script performs similar to the following Net-SNMP command: -| $ snmpset -v2c -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1.9.1.3.1 s 'New description' 1.3.6.1.2.1.1.9.1.4.1 t 12 +| $ snmpset -v2c -c public -ObentU demo.snmplabs.com 1.3.6.1.2.1.1.9.1.3.1 s 'New description' 1.3.6.1.2.1.1.9.1.4.1 t 12 """# from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher @@ -21,18 +21,18 @@ from time import time # Protocol version to use -#pMod = api.protoModules[api.protoVersion1] +# pMod = api.protoModules[api.protoVersion1] pMod = api.protoModules[api.protoVersion2c] # Build PDU -reqPDU = pMod.SetRequestPDU() +reqPDU = pMod.SetRequestPDU() pMod.apiPDU.setDefaults(reqPDU) pMod.apiPDU.setVarBinds( reqPDU, # A list of Var-Binds to SET - ( ('1.3.6.1.2.1.1.9.1.3.1', pMod.OctetString('New system description')), - ('1.3.6.1.2.1.1.9.1.4.1', pMod.TimeTicks(12)) ) - ) + (('1.3.6.1.2.1.1.9.1.3.1', pMod.OctetString('New system description')), + ('1.3.6.1.2.1.1.9.1.4.1', pMod.TimeTicks(12))) +) # Build message reqMsg = pMod.Message() @@ -42,17 +42,20 @@ startedAt = time() + def cbTimerFun(timeNow): if timeNow - startedAt > 3: raise Exception("Request timed out") - + + +# noinspection PyUnusedLocal,PyUnusedLocal def cbRecvFun(transportDispatcher, transportDomain, transportAddress, wholeMsg, reqPDU=reqPDU): while wholeMsg: rspMsg, wholeMsg = decoder.decode(wholeMsg, asn1Spec=pMod.Message()) rspPDU = pMod.apiMessage.getPDU(rspMsg) # Match response to request - if pMod.apiPDU.getRequestID(reqPDU)==pMod.apiPDU.getRequestID(rspPDU): + if pMod.apiPDU.getRequestID(reqPDU) == pMod.apiPDU.getRequestID(rspPDU): # Check for SNMP errors reported errorStatus = pMod.apiPDU.getErrorStatus(rspPDU) if errorStatus: @@ -63,6 +66,7 @@ transportDispatcher.jobFinished(1) return wholeMsg + transportDispatcher = AsyncoreDispatcher() transportDispatcher.registerRecvCbFun(cbRecvFun) diff -Nru python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/ntfrcv/listen-on-ipv4-and-ipv6-interfaces.py python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/ntfrcv/listen-on-ipv4-and-ipv6-interfaces.py --- python-pysnmp4-4.3.2/examples/v1arch/asyncore/manager/ntfrcv/listen-on-ipv4-and-ipv6-interfaces.py 2015-09-14 05:20:25.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v1arch/asyncore/manager/ntfrcv/listen-on-ipv4-and-ipv6-interfaces.py 2017-12-22 11:53:40.000000000 +0000 @@ -25,6 +25,8 @@ from pyasn1.codec.ber import decoder from pysnmp.proto import api + +# noinspection PyUnusedLocal def cbFun(transportDispatcher, transportDomain, transportAddress, wholeMsg): while wholeMsg: msgVer = int(api.decodeMessageVersion(wholeMsg)) @@ -35,42 +37,28 @@ return reqMsg, wholeMsg = decoder.decode( wholeMsg, asn1Spec=pMod.Message(), - ) + ) print('Notification message from %s:%s: ' % ( transportDomain, transportAddress - ) ) + ) reqPDU = pMod.apiMessage.getPDU(reqMsg) if reqPDU.isSameTypeWith(pMod.TrapPDU()): if msgVer == api.protoVersion1: - print('Enterprise: %s' % ( - pMod.apiTrapPDU.getEnterprise(reqPDU).prettyPrint() - ) - ) - print('Agent Address: %s' % ( - pMod.apiTrapPDU.getAgentAddr(reqPDU).prettyPrint() - ) - ) - print('Generic Trap: %s' % ( - pMod.apiTrapPDU.getGenericTrap(reqPDU).prettyPrint() - ) - ) - print('Specific Trap: %s' % ( - pMod.apiTrapPDU.getSpecificTrap(reqPDU).prettyPrint() - ) - ) - print('Uptime: %s' % ( - pMod.apiTrapPDU.getTimeStamp(reqPDU).prettyPrint() - ) - ) - varBinds = pMod.apiTrapPDU.getVarBindList(reqPDU) + print('Enterprise: %s' % (pMod.apiTrapPDU.getEnterprise(reqPDU).prettyPrint())) + print('Agent Address: %s' % (pMod.apiTrapPDU.getAgentAddr(reqPDU).prettyPrint())) + print('Generic Trap: %s' % (pMod.apiTrapPDU.getGenericTrap(reqPDU).prettyPrint())) + print('Specific Trap: %s' % (pMod.apiTrapPDU.getSpecificTrap(reqPDU).prettyPrint())) + print('Uptime: %s' % (pMod.apiTrapPDU.getTimeStamp(reqPDU).prettyPrint())) + varBinds = pMod.apiTrapPDU.getVarBinds(reqPDU) else: - varBinds = pMod.apiPDU.getVarBindList(reqPDU) + varBinds = pMod.apiPDU.getVarBinds(reqPDU) print('Var-binds:') for oid, val in varBinds: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) return wholeMsg + transportDispatcher = AsyncoreDispatcher() transportDispatcher.registerRecvCbFun(cbFun) @@ -86,9 +74,9 @@ ) ## Local domain socket -#transportDispatcher.registerTransport( +# transportDispatcher.registerTransport( # unix.domainName, unix.UnixSocketTransport().openServerMode('/tmp/snmp-manager') -#) +# ) transportDispatcher.jobStarted(1) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py python-pysnmp4-4.4.3/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py 2015-09-14 05:20:25.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py 2017-12-22 11:53:40.000000000 +0000 @@ -65,9 +65,9 @@ ) # Allow full MIB access for each user at VACM -config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) -config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) -config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) +config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) +config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py python-pysnmp4-4.4.3/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py 2017-12-22 11:53:40.000000000 +0000 @@ -53,21 +53,22 @@ # SecurityName <-> CommunityName mapping config.addV1System(snmpEngine, 'my-area', 'public') + # Callback function for receiving notifications +# noinspection PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): transportDomain, transportAddress = snmpEngine.msgAndPduDsp.getTransportInfo(stateReference) - print('Notification from %s, SNMP Engine %s, Context %s' % ( - transportAddress, contextEngineId.prettyPrint(), - contextName.prettyPrint() - ) - ) + print('Notification from %s, SNMP Engine %s, Context %s' % (transportAddress, + contextEngineId.prettyPrint(), + contextName.prettyPrint())) for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) - + + # Register SNMP Application at the SNMP engine ntfrcv.NotificationReceiver(snmpEngine, cbFun) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py 2017-12-22 11:53:40.000000000 +0000 @@ -45,7 +45,7 @@ ) # Allow full MIB access for each user at VACM -config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Create an SNMP context with ContextEngineId = 8000000001020304 snmpContext = context.SnmpContext( @@ -56,7 +56,7 @@ # Management Instrumentation Controller and register at SNMP Context # under ContextName 'my-context' snmpContext.registerContextName( - v2c.OctetString('my-context'), # Context Name + v2c.OctetString('my-context'), # Context Name instrum.MibInstrumController(builder.MibBuilder()) # Managed Objects ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py 2017-12-22 11:53:40.000000000 +0000 @@ -43,23 +43,25 @@ ) # Allow full MIB access for each user at VACM -config.addVacmUser(snmpEngine, 3, 'usr-none-none', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 3, 'usr-none-none', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Create an SNMP context snmpContext = context.SnmpContext(snmpEngine) + # Very basic Management Instrumentation Controller without # any Managed Objects attached. It supports only GET's and # always echos request var-binds in response. class EchoMibInstrumController(instrum.AbstractMibInstrumController): - def readVars(self, vars, acInfo=(None, None)): - return [ (ov[0], v2c.OctetString('You queried OID %s' % ov[0])) for ov in vars] + def readVars(self, varBinds, acInfo=(None, None)): + return [(ov[0], v2c.OctetString('You queried OID %s' % ov[0])) for ov in varBinds] + # Create a custom Management Instrumentation Controller and register at # SNMP Context under ContextName 'my-context' snmpContext.registerContextName( - v2c.OctetString('my-context'), # Context Name - EchoMibInstrumController() # Management Instrumentation + v2c.OctetString('my-context'), # Context Name + EchoMibInstrumController() # Management Instrumentation ) # Register GET&SET Applications at the SNMP engine for a custom SNMP context diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py 2017-12-22 11:53:40.000000000 +0000 @@ -43,7 +43,7 @@ ) # Allow full MIB access for each user at VACM -config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py 2017-12-22 11:53:40.000000000 +0000 @@ -40,7 +40,7 @@ config.addV1System(snmpEngine, 'my-area', 'public') # Allow read MIB access for this user / securityModels at VACM -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,5)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 5)) # Create an SNMP context snmpContext = context.SnmpContext(snmpEngine) @@ -53,15 +53,18 @@ 'SNMPv2-SMI', 'MibScalar', 'MibScalarInstance' ) + class MyStaticMibScalarInstance(MibScalarInstance): + # noinspection PyUnusedLocal,PyUnusedLocal def getValue(self, name, idx): return self.getSyntax().clone( 'Python %s running on a %s platform' % (sys.version, sys.platform) ) + mibBuilder.exportSymbols( - '__MY_MIB', MibScalar((1,3,6,5,1), v2c.OctetString()), - MyStaticMibScalarInstance((1,3,6,5,1), (0,), v2c.OctetString()) + '__MY_MIB', MibScalar((1, 3, 6, 5, 1), v2c.OctetString()), + MyStaticMibScalarInstance((1, 3, 6, 5, 1), (0,), v2c.OctetString()) ) # --- end of Managed Object Instance initialization ---- diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py 2017-12-22 11:53:40.000000000 +0000 @@ -47,7 +47,7 @@ config.addV1System(snmpEngine, 'my-area', 'public') # Allow read MIB access for this user / securityModels at VACM -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,6), (1,3,6,6)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 6), (1, 3, 6, 6)) # Create an SNMP context snmpContext = context.SnmpContext(snmpEngine) @@ -56,43 +56,43 @@ mibBuilder = snmpContext.getMibInstrum().getMibBuilder() -( MibTable, - MibTableRow, - MibTableColumn, - MibScalarInstance ) = mibBuilder.importSymbols( - 'SNMPv2-SMI', +(MibTable, + MibTableRow, + MibTableColumn, + MibScalarInstance) = mibBuilder.importSymbols( + 'SNMPv2-SMI', 'MibTable', 'MibTableRow', 'MibTableColumn', 'MibScalarInstance' - ) +) RowStatus, = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus') mibBuilder.exportSymbols( - '__EXAMPLE-MIB', - # table object - exampleTable=MibTable((1,3,6,6,1)).setMaxAccess('readcreate'), - # table row object, also carries references to table indices - exampleTableEntry=MibTableRow((1,3,6,6,1,5)).setMaxAccess('readcreate').setIndexNames((0, '__EXAMPLE-MIB', 'exampleTableColumn1')), - # table column: string index - exampleTableColumn1=MibTableColumn((1,3,6,6,1,5,1), v2c.OctetString()).setMaxAccess('readcreate'), - # table column: string value - exampleTableColumn2=MibTableColumn((1,3,6,6,1,5,2), v2c.OctetString()).setMaxAccess('readcreate'), - # table column: integer value with default - exampleTableColumn3=MibTableColumn((1,3,6,6,1,5,3), v2c.Integer32(123)).setMaxAccess('readcreate'), - # table column: row status - exampleTableStatus=MibTableColumn((1,3,6,6,1,5,4), RowStatus('notExists')).setMaxAccess('readcreate') + '__EXAMPLE-MIB', + # table object + exampleTable=MibTable((1, 3, 6, 6, 1)).setMaxAccess('readcreate'), + # table row object, also carries references to table indices + exampleTableEntry=MibTableRow((1, 3, 6, 6, 1, 5)).setMaxAccess('readcreate').setIndexNames((0, '__EXAMPLE-MIB', 'exampleTableColumn1')), + # table column: string index + exampleTableColumn1=MibTableColumn((1, 3, 6, 6, 1, 5, 1), v2c.OctetString()).setMaxAccess('readcreate'), + # table column: string value + exampleTableColumn2=MibTableColumn((1, 3, 6, 6, 1, 5, 2), v2c.OctetString()).setMaxAccess('readcreate'), + # table column: integer value with default + exampleTableColumn3=MibTableColumn((1, 3, 6, 6, 1, 5, 3), v2c.Integer32(123)).setMaxAccess('readcreate'), + # table column: row status + exampleTableStatus=MibTableColumn((1, 3, 6, 6, 1, 5, 4), RowStatus('notExists')).setMaxAccess('readcreate') ) # --- end of custom SNMP table definition, empty table now exists --- # --- populate custom SNMP table with one row --- -( exampleTableEntry, - exampleTableColumn2, - exampleTableColumn3, - exampleTableStatus ) = mibBuilder.importSymbols( +(exampleTableEntry, + exampleTableColumn2, + exampleTableColumn3, + exampleTableStatus) = mibBuilder.importSymbols( '__EXAMPLE-MIB', 'exampleTableEntry', 'exampleTableColumn2', @@ -102,9 +102,9 @@ rowInstanceId = exampleTableEntry.getInstIdFromIndices('example record one') mibInstrumentation = snmpContext.getMibInstrum() mibInstrumentation.writeVars( - ( (exampleTableColumn2.name+rowInstanceId, 'my string value'), - (exampleTableColumn3.name+rowInstanceId, 123456), - (exampleTableStatus.name+rowInstanceId, 'createAndGo') ) + ((exampleTableColumn2.name + rowInstanceId, 'my string value'), + (exampleTableColumn3.name + rowInstanceId, 123456), + (exampleTableStatus.name + rowInstanceId, 'createAndGo')) ) # --- end of SNMP table population --- diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py 2017-12-22 11:53:40.000000000 +0000 @@ -68,7 +68,7 @@ ) # Allow full MIB access for each user at VACM -config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py 2017-12-22 11:53:40.000000000 +0000 @@ -46,7 +46,7 @@ config.addV1System(snmpEngine, 'my-area', 'public') # Allow full MIB access for this user / securityModels at VACM -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py 2017-12-22 11:53:40.000000000 +0000 @@ -45,7 +45,7 @@ config.addV1System(snmpEngine, 'my-area', 'public') # Allow full MIB access for this user / securityModels at VACM -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py 2017-12-22 11:53:40.000000000 +0000 @@ -43,8 +43,8 @@ config.addV1System(snmpEngine, 'my-write-area', 'private') # Allow full MIB access for this user / securityModels at VACM -config.addVacmUser(snmpEngine, 1, 'my-read-area', 'noAuthNoPriv', (1,3,6,1,2,1)) -config.addVacmUser(snmpEngine, 1, 'my-write-area', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 1, 'my-read-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1)) +config.addVacmUser(snmpEngine, 1, 'my-write-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py 2017-12-22 11:53:40.000000000 +0000 @@ -33,15 +33,15 @@ # Configuration parameters for each of SNMP Engines snmpEngineInfo = ( - ( '0102030405060708', udp.domainName + (0,), ('127.0.0.1', 161) ), - ( '0807060504030201', udp.domainName + (1,), ('127.0.0.2', 161) ) + ('0102030405060708', udp.domainName + (0,), ('127.0.0.1', 161)), + ('0807060504030201', udp.domainName + (1,), ('127.0.0.2', 161)) ) # Instantiate the single transport dispatcher object transportDispatcher = AsyncoreDispatcher() # Setup a custom data routing function to select snmpEngine by transportDomain -transportDispatcher.registerRoutingCbFun(lambda td,t,d: td) +transportDispatcher.registerRoutingCbFun(lambda td, t, d: td) # Instantiate and configure SNMP Engines for snmpEngineId, transportDomain, transportAddress in snmpEngineInfo: @@ -71,7 +71,7 @@ ) # Allow full MIB access for this user / securityModels at VACM - config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6), (1,3,6,1,2,1)) + config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py 2017-12-22 11:53:40.000000000 +0000 @@ -56,9 +56,9 @@ ) # Allow full MIB access for each user at VACM -config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) -config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) -config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) +config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) +config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py 2017-12-22 11:53:40.000000000 +0000 @@ -27,10 +27,12 @@ # Create SNMP engine snmpEngine = engine.SnmpEngine() + # Execution point observer setup # Register a callback to be invoked at specified execution point of # SNMP Engine and passed local variables at code point's local scope +# noinspection PyUnusedLocal,PyUnusedLocal def requestObserver(snmpEngine, execpoint, variables, cbCtx): print('Execution point: %s' % execpoint) print('* transportDomain: %s' % '.'.join([str(x) for x in variables['transportDomain']])) @@ -42,6 +44,7 @@ print('* contextName: %s' % variables['contextName'].prettyPrint()) print('* PDU: %s' % variables['pdu'].prettyPrint()) + snmpEngine.observer.registerObserver( requestObserver, 'rfc3412.receiveMessage:request', @@ -67,7 +70,7 @@ ) # Allow full MIB access for each user at VACM -config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py 2017-12-22 11:53:40.000000000 +0000 @@ -12,15 +12,15 @@ * with user 'usr-md5-none', auth: MD5, priv NONE * over IPv4/UDP * send INFORM notification -* to multiple Managers at 195.218.195.228:162, 195.218.195.228:162 +* to multiple Managers at 104.236.166.95:162, 104.236.166.95:162 * with TRAP ID 'coldStart' specified as an OID * include managed objects information: 1.3.6.1.2.1.1.1.0 = 'Example Notificator' Functionally similar to: -| $ snmpinform -v3 -l authPriv -u usr-md5-none -A authkey1 195.218.195.228 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' -| $ snmpinform -v2c -c public 195.218.195.228 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' +| $ snmpinform -v3 -l authPriv -u usr-md5-none -A authkey1 104.236.166.95 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' +| $ snmpinform -v2c -c public 104.236.166.95 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' """# from pysnmp.entity import engine, config @@ -57,14 +57,14 @@ # First target config.addTargetAddr( snmpEngine, 'my-nms-1', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds-1', tagList='all-my-managers' ) # Second target config.addTargetAddr( snmpEngine, 'my-nms-2', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds-2', tagList='all-my-managers' ) @@ -79,33 +79,34 @@ # Allow NOTIFY access to Agent's MIB by this SNMP model (2&3), securityLevel # and SecurityName config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) -config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1, 3, 6)) # *** SNMP engine configuration is complete by this line *** # Create Notification Originator App instance. ntfOrg = ntforg.NotificationOriginator() + # Error/confirmation receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): - print('Notification %s, status - %s' % ( - sendRequestHandle, errorIndication and errorIndication or 'delivered' - ) - ) - + print('Notification %s, status - %s' % (sendRequestHandle, + errorIndication and errorIndication or 'delivered')) + + # Build and submit notification message to dispatcher sendRequestHandle = ntfOrg.sendVarBinds( snmpEngine, 'my-notification', # notification targets - None, '', # contextEngineId, contextName + None, '', # contextEngineId, contextName # var-binds [ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart - ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))), + ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))), # additional var-binds: ( (oid, value), ... ) - ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')) + ((1, 3, 6, 1, 2, 1, 1, 1, 0), v2c.OctetString('Example Notificator')) ], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py 2017-12-22 11:53:40.000000000 +0000 @@ -43,43 +43,46 @@ # Create named target config.addTargetAddr( snmpEngine, 'my-nms', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds' ) # *** SNMP engine configuration is complete by this line *** # Create SNMP v2c TRAP PDU with defaults -trapPDU = v2c.TrapPDU() +trapPDU = v2c.TrapPDU() v2c.apiTrapPDU.setDefaults(trapPDU) # Set custom var-binds to TRAP PDU v2c.apiTrapPDU.setVarBinds( trapPDU, [ # sysUpTime - ( v2c.ObjectIdentifier('1.3.6.1.2.1.1.3.0'), v2c.TimeTicks(123) ), + (v2c.ObjectIdentifier('1.3.6.1.2.1.1.3.0'), v2c.TimeTicks(123)), # snmpTrapPDU - ( (1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1)) ) + ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))) ] ) # Create Notification Originator App instance. ntfOrg = ntforg.NotificationOriginator() + # Error/confirmation receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( sendRequestHandle, errorIndication and errorIndication or 'delivered' - ) ) + ) + # Build and submit notification message to dispatcher ntfOrg.sendPdu( snmpEngine, # Notification targets - 'my-nms', # target address - None, '', # contextEngineId, contextName + 'my-nms', # target address + None, '', # contextEngineId, contextName trapPDU, cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py 2017-12-22 11:53:40.000000000 +0000 @@ -9,7 +9,7 @@ * with community name 'public' * over IPv4/UDP * send TRAP notification -* to multiple Managers at 195.218.195.228:162, 195.218.195.228:162 +* to multiple Managers at 104.236.166.95:162, 104.236.166.95:162 * with TRAP ID 'coldStart' specified as an OID * include managed objects information: 1.3.6.1.2.1.1.1.0 = 'Example Notificator' @@ -17,9 +17,9 @@ Functionally similar to: -| $ snmptrap -v2c -c public 195.218.195.228 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' -| $ snmptrap -v2c -c public 195.218.195.228 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' -| $ snmptrap -v2c -c public 195.218.195.228 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' +| $ snmptrap -v2c -c public 104.236.166.95 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' +| $ snmptrap -v2c -c public 104.236.166.95 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' +| $ snmptrap -v2c -c public 104.236.166.95 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' """# from pysnmp.entity import engine, config @@ -46,21 +46,21 @@ # First target config.addTargetAddr( snmpEngine, 'my-nms-1', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) # Second target config.addTargetAddr( snmpEngine, 'my-nms-2', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) # Third target config.addTargetAddr( snmpEngine, 'my-nms-3', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) @@ -75,7 +75,7 @@ # Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel # and SecurityName config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6)) # *** SNMP engine configuration is complete by this line *** @@ -87,14 +87,14 @@ snmpEngine, # Notification targets 'my-notification', # notification targets - None, '', # contextEngineId, contextName + None, '', # contextEngineId, contextName # var-binds [ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart - ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))), + ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))), # additional var-binds: ( (oid, value), ... ) - ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')), - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) + ((1, 3, 6, 1, 2, 1, 1, 1, 0), v2c.OctetString('Example Notificator')), + ((1, 3, 6, 1, 2, 1, 1, 5, 0), v2c.OctetString('Notificator Example')) ] ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -17,7 +17,7 @@ Functionally similar to: -| $ snmptrap -v2c -c public udp:195.218.195.228 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' +| $ snmptrap -v2c -c public udp:104.236.166.95 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' | $ snmptrap -v2c -c public udp6:[::1] 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' """# @@ -46,7 +46,7 @@ ) config.addTargetAddr( snmpEngine, 'my-nms-1', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) @@ -74,7 +74,7 @@ # Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel # and SecurityName config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6)) # *** SNMP engine configuration is complete by this line *** @@ -86,14 +86,14 @@ snmpEngine, # Notification targets 'my-notification', # notification targets - None, '', # contextEngineId, contextName + None, '', # contextEngineId, contextName # var-binds [ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart - ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))), + ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))), # additional var-binds: ( (oid, value), ... ) - ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')), - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) + ((1, 3, 6, 1, 2, 1, 1, 1, 0), v2c.OctetString('Example Notificator')), + ((1, 3, 6, 1, 2, 1, 1, 5, 0), v2c.OctetString('Notificator Example')) ] ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py 2017-12-22 11:53:40.000000000 +0000 @@ -7,14 +7,14 @@ * SNMPv1 * with community name 'public' * over IPv4/UDP -* to a Manager at 195.218.195.228 UDP port 162 +* to a Manager at 104.236.166.95 UDP port 162 * from local address 0.0.0.0, UDP port 61024 * send TRAP notification * with TRAP ID 'coldStart' specified as an OID Functionally similar to: -| $ snmptrap -v1 -c public 195.218.195.228 1.3.6.1.6.3.1.1.5.1 0.0.0.0 1 0 0 +| $ snmptrap -v1 -c public 104.236.166.95 1.3.6.1.6.3.1.1.5.1 0.0.0.0 1 0 0 """# from pysnmp.entity import engine, config @@ -42,7 +42,7 @@ ) config.addTargetAddr( snmpEngine, 'my-nms', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) @@ -57,7 +57,7 @@ # Allow NOTIFY access to Agent's MIB by this SNMP model (1), securityLevel # and SecurityName config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6)) # *** SNMP engine configuration is complete by this line *** @@ -68,11 +68,11 @@ ntfOrg.sendVarBinds( snmpEngine, 'my-notification', # notification targets - None, '', # contextEngineId, contextName + None, '', # contextEngineId, contextName # var-binds [ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart - ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))) + ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))) ] ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/send-trap-to-multiple-managers.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/send-trap-to-multiple-managers.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/send-trap-to-multiple-managers.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/send-trap-to-multiple-managers.py 2017-12-22 11:53:40.000000000 +0000 @@ -9,7 +9,7 @@ * with community name 'public' * over IPv4/UDP * send TRAP notification -* to multiple Managers at 195.218.195.228:162, 195.218.195.228:162 +* to multiple Managers at 104.236.166.95:162, 104.236.166.95:162 * with TRAP ID 'coldStart' specified as an OID * include managed objects information: 1.3.6.1.2.1.1.1.0 = 'Example Notificator' @@ -17,9 +17,9 @@ Functionally similar to: -| $ snmptrap -v2c -c public 195.218.195.228 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' -| $ snmptrap -v2c -c public 195.218.195.228 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' -| $ snmptrap -v2c -c public 195.218.195.228 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' +| $ snmptrap -v2c -c public 104.236.166.95 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' +| $ snmptrap -v2c -c public 104.236.166.95 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' +| $ snmptrap -v2c -c public 104.236.166.95 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example notification' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' """# from pysnmp.entity import engine, config @@ -46,21 +46,21 @@ # First target config.addTargetAddr( snmpEngine, 'my-nms-1', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) # Second target config.addTargetAddr( snmpEngine, 'my-nms-2', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) # Third target config.addTargetAddr( snmpEngine, 'my-nms-3', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) @@ -74,26 +74,26 @@ # Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel # and SecurityName config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6)) # *** SNMP engine configuration is complete by this line *** # Create Notification Originator App instance. ntfOrg = ntforg.NotificationOriginator() - + # Build and submit notification message to dispatcher ntfOrg.sendVarBinds( snmpEngine, # Notification targets 'my-notification', # notification targets - None, '', # contextEngineId, contextName + None, '', # contextEngineId, contextName # var-binds [ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart - ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))), + ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))), # additional var-binds: ( (oid, value), ... ) - ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')), - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) + ((1, 3, 6, 1, 2, 1, 1, 1, 0), v2c.OctetString('Example Notificator')), + ((1, 3, 6, 1, 2, 1, 1, 5, 0), v2c.OctetString('Notificator Example')) ] ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py 2017-12-22 11:53:40.000000000 +0000 @@ -41,7 +41,7 @@ ) config.addTargetAddr( snmpEngine, 'my-nms', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) @@ -56,29 +56,32 @@ # Allow NOTIFY access to Agent's MIB by this SNMP model (3), securityLevel # and SecurityName config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1, 3, 6)) # *** SNMP engine configuration is complete by this line *** # Create Notification Originator App instance. ntfOrg = ntforg.NotificationOriginator() - + + # Error/confirmation receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( sendRequestHandle, errorIndication and errorIndication or 'delivered' - ) ) + ) + # Build and submit notification message to dispatcher sendRequestHandle = ntfOrg.sendVarBinds( snmpEngine, 'my-notification', # notification targets - None, '', # contextEngineId, contextName + None, '', # contextEngineId, contextName # var-binds: SNMPv2-MIB::coldStart, ... - [ ((1,3,6,1,6,3,1,1,5,1), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))), - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('system name')) ], + [((1, 3, 6, 1, 6, 3, 1, 1, 5, 1), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))), + ((1, 3, 6, 1, 2, 1, 1, 5, 0), v2c.OctetString('system name'))], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v1-trap.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v1-trap.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v1-trap.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v1-trap.py 2017-12-22 11:53:40.000000000 +0000 @@ -7,18 +7,18 @@ * SNMPv1 * with community name 'public' * over IPv4/UDP -* to a Manager at 195.218.195.228:162 +* to a Manager at 104.236.166.95:162 * send TRAP notification * with TRAP ID 'coldStart' specified as an OID * include managed objects information: * overriding Uptime value with 12345 -* overriding Agent Address with '195.218.195.228' +* overriding Agent Address with '104.236.166.95' * overriding Enterprise OID with 1.3.6.1.4.1.20408.4.1.1.2 * include managed object information '1.3.6.1.2.1.1.1.0' = 'my system' Functionally similar to: -| $ snmptrap -v1 -c public demo.snmplabs.com 1.3.6.1.4.1.20408.4.1.1.2 195.218.195.228 6 432 12345 1.3.6.1.2.1.1.1.0 s "my system" +| $ snmptrap -v1 -c public demo.snmplabs.com 1.3.6.1.4.1.20408.4.1.1.2 104.236.166.95 6 432 12345 1.3.6.1.2.1.1.1.0 s "my system" """# from pysnmp.entity import engine, config @@ -44,7 +44,7 @@ ) config.addTargetAddr( snmpEngine, 'my-nms', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) @@ -59,7 +59,7 @@ # Allow NOTIFY access to Agent's MIB by this SNMP model (1), securityLevel # and SecurityName config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6)) # *** SNMP engine configuration is complete by this line *** @@ -71,9 +71,9 @@ snmpEngine, # Notification targets 'my-notification', # notification targets - None, '', # contextEngineId, contextName + None, '', # contextEngineId, contextName # var-binds - [ + [ # Uptime value with 12345 (v2c.ObjectIdentifier('1.3.6.1.2.1.1.3.0'), v2c.TimeTicks(12345)), diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py 2017-12-22 11:53:40.000000000 +0000 @@ -8,7 +8,7 @@ * with community name 'public' * over IPv4/UDP * send INFORM notification -* to a Manager at 195.218.195.228:162 +* to a Manager at 104.236.166.95:162 * with TRAP ID 'coldStart' specified as an OID * include managed objects information: 1.3.6.1.2.1.1.1.0 = 'Example Notificator' @@ -16,7 +16,7 @@ Functionally similar to: -| $ snmpinform -v2c -c public 195.218.195.228 12345 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example Notificator' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' +| $ snmpinform -v2c -c public 104.236.166.95 12345 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s 'Example Notificator' 1.3.6.1.2.1.1.5.0 s 'Notificator Example' """# from pysnmp.entity import engine, config @@ -28,7 +28,7 @@ snmpEngine = engine.SnmpEngine() # SecurityName <-> CommunityName mapping (+ transport binding) -config.addV1System(snmpEngine, 'my-area', 'public', +config.addV1System(snmpEngine, 'my-area', 'public', transportTag='all-my-managers') # Specify security settings per SecurityName (SNMPv2c -> 1) @@ -43,7 +43,7 @@ ) config.addTargetAddr( snmpEngine, 'my-nms', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) @@ -58,33 +58,36 @@ # Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel # and SecurityName config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6)) # *** SNMP engine configuration is complete by this line *** # Create Notification Originator App instance. ntfOrg = ntforg.NotificationOriginator() + # Error/confirmation receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( sendRequestHandle, errorIndication and errorIndication or 'delivered' - ) ) + ) + # Build and submit notification message to dispatcher sendRequestHandle = ntfOrg.sendVarBinds( snmpEngine, 'my-notification', # notification targets - None, '', # contextEngineId, contextName + None, '', # contextEngineId, contextName # var-binds [ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart - ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))), + ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))), # additional var-binds: ( (oid, value), ... ) - ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')), - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) + ((1, 3, 6, 1, 2, 1, 1, 1, 0), v2c.OctetString('Example Notificator')), + ((1, 3, 6, 1, 2, 1, 1, 5, 0), v2c.OctetString('Notificator Example')) ], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py 2017-12-22 11:53:40.000000000 +0000 @@ -8,7 +8,7 @@ * with community name 'public' * over IPv4/UDP * send TRAP notification -* to a Manager at 195.218.195.228:162 +* to a Manager at 104.236.166.95:162 * with TRAP ID 'coldStart' specified as an OID * include managed objects information: 1.3.6.1.2.1.1.1.0 = 'Example Notificator' @@ -16,7 +16,7 @@ Functionally similar to: -| $ snmptrap -v2c -c public 195.218.195.228 12345 1.3.6.1.4.1.20408.4.1.1.2 +| $ snmptrap -v2c -c public 104.236.166.95 12345 1.3.6.1.4.1.20408.4.1.1.2 """# from pysnmp.entity import engine, config @@ -42,7 +42,7 @@ ) config.addTargetAddr( snmpEngine, 'my-nms', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) @@ -57,34 +57,37 @@ # Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel # and SecurityName config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6)) # *** SNMP engine configuration is complete by this line *** # Create Notification Originator App instance. ntfOrg = ntforg.NotificationOriginator() + # Error/confirmation receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( sendRequestHandle, errorIndication and errorIndication or 'delivered' - ) ) + ) + # Build and submit notification message to dispatcher sendRequestHandle = ntfOrg.sendVarBinds( snmpEngine, # Notification targets 'my-notification', # notification targets - None, '', # contextEngineId, contextName + None, '', # contextEngineId, contextName # var-binds [ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart - ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))), + ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))), # additional var-binds: ( (oid, value), ... ) - ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')), - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) + ((1, 3, 6, 1, 2, 1, 1, 1, 0), v2c.OctetString('Example Notificator')), + ((1, 3, 6, 1, 2, 1, 1, 5, 0), v2c.OctetString('Notificator Example')) ], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -""" -Sending notification with OBJECT's -++++++++++++++++++++++++++++++++++ - -Send SNMP TRAP notification using the following options: - -* SNMPv2c -* with community name 'public' -* over IPv4/UDP -* send TRAP notification -* to a Manager at 195.218.195.228:162 -* with TRAP ID IF-MIB::ifLink as MIB symbol - -The IF-MIB::ifLink NOTIFICATION-TYPE implies including four other -var-binds into the notification message describing the incident -occurred. These var-binds are: -IF-MIB::ifIndex."x" -IF-MIB::ifAdminStatus."x" -IF-MIB::ifOperStatus."x" -IF-MIB::ifDescr."x" - -Where "x" is MIB table index (instance index). - -Functionally similar to: - -| $ snmptrap -v2c -c public 195.218.195.228 0 1.3.6.1.6.3.1.1.5.3 IF-MIB::ifIndex."1" IF-MIB::ifAdminStatus."1" IF-MIB::ifOperStatus."1" IF-MIB::ifDescr."1" - -"""# -from pysnmp.entity import engine, config -from pysnmp.carrier.asyncore.dgram import udp -from pysnmp.entity.rfc3413 import ntforg -from pysnmp.smi import rfc1902, view - -# -# Here we fill in some values for Managed Objects Instances (invoked -# later while building TRAP message) by NOTIFICATION-TYPE macro evaluation. -# In real Agent app, these values should already be initialized during -# Agent runtime. -# -instanceIndex = (1,) -objects = { - ('IF-MIB', 'ifIndex'): instanceIndex[0], - ('IF-MIB', 'ifAdminStatus'): 'up', - ('IF-MIB', 'ifOperStatus'): 'down', - ('IF-MIB', 'ifDescr'): 'eth0' -} - -# Create SNMP engine instance -snmpEngine = engine.SnmpEngine() - -# MIB view controller is used for MIB lookup purposes -mibViewController = view.MibViewController(snmpEngine.getMibBuilder()) - -# SecurityName <-> CommunityName mapping -config.addV1System(snmpEngine, 'my-area', 'public', transportTag='all-my-managers') - -# Specify security settings per SecurityName (SNMPv2c -> 1) -config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1) - -# Setup transport endpoints and bind it with security settings yielding -# a target name: - -# UDP/IPv4 -config.addTransport( - snmpEngine, - udp.domainName, - udp.UdpSocketTransport().openClientMode() -) -config.addTargetAddr( - snmpEngine, 'my-nms-1', - udp.domainName, ('195.218.195.228', 162), - 'my-creds', - tagList='all-my-managers' -) - -# Specify what kind of notification should be sent (TRAP or INFORM), -# to what targets (chosen by tag) and what filter should apply to -# the set of targets (selected by tag) -config.addNotificationTarget( - snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap' -) - -# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel -# and SecurityName -config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) - -# *** SNMP engine configuration is complete by this line *** - -# Create Notification Originator App instance. -ntfOrg = ntforg.NotificationOriginator() - -# Build and submit notification message to dispatcher -ntfOrg.sendVarBinds( - snmpEngine, - 'my-notification', # notification targets - None, '', # contextEngineId, contextName - rfc1902.NotificationType( - rfc1902.ObjectIdentity('IF-MIB', 'linkUp'), - instanceIndex=instanceIndex, - objects=objects - ).resolveWithMib(mibViewController) -) - -print('Notification is scheduled to be sent') - -# Run I/O dispatcher which would send pending message and process response -snmpEngine.transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v2c-trap-with-notification-objects.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v2c-trap-with-notification-objects.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v2c-trap-with-notification-objects.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v2c-trap-with-notification-objects.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,108 @@ +""" +Sending notification with OBJECT's +++++++++++++++++++++++++++++++++++ + +Send SNMP TRAP notification using the following options: + +* SNMPv2c +* with community name 'public' +* over IPv4/UDP +* send TRAP notification +* to a Manager at 104.236.166.95:162 +* with TRAP ID IF-MIB::ifLink as MIB symbol + +The IF-MIB::ifLink NOTIFICATION-TYPE implies including four other +var-binds into the notification message describing the incident +occurred. These var-binds are: +IF-MIB::ifIndex."x" +IF-MIB::ifAdminStatus."x" +IF-MIB::ifOperStatus."x" +IF-MIB::ifDescr."x" + +Where "x" is MIB table index (instance index). + +Functionally similar to: + +| $ snmptrap -v2c -c public 104.236.166.95 0 1.3.6.1.6.3.1.1.5.3 IF-MIB::ifIndex."1" IF-MIB::ifAdminStatus."1" IF-MIB::ifOperStatus."1" IF-MIB::ifDescr."1" + +"""# +from pysnmp.entity import engine, config +from pysnmp.carrier.asyncore.dgram import udp +from pysnmp.entity.rfc3413 import ntforg +from pysnmp.smi import rfc1902, view + +# +# Here we fill in some values for Managed Objects Instances (invoked +# later while building TRAP message) by NOTIFICATION-TYPE macro evaluation. +# In real Agent app, these values should already be initialized during +# Agent runtime. +# +instanceIndex = (1,) +objects = { + ('IF-MIB', 'ifIndex'): instanceIndex[0], + ('IF-MIB', 'ifAdminStatus'): 'up', + ('IF-MIB', 'ifOperStatus'): 'down', + ('IF-MIB', 'ifDescr'): 'eth0' +} + +# Create SNMP engine instance +snmpEngine = engine.SnmpEngine() + +# MIB view controller is used for MIB lookup purposes +mibViewController = view.MibViewController(snmpEngine.getMibBuilder()) + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public', transportTag='all-my-managers') + +# Specify security settings per SecurityName (SNMPv2c -> 1) +config.addTargetParams(snmpEngine, 'my-creds', 'my-area', 'noAuthNoPriv', 1) + +# Setup transport endpoints and bind it with security settings yielding +# a target name: + +# UDP/IPv4 +config.addTransport( + snmpEngine, + udp.domainName, + udp.UdpSocketTransport().openClientMode() +) +config.addTargetAddr( + snmpEngine, 'my-nms-1', + udp.domainName, ('104.236.166.95', 162), + 'my-creds', + tagList='all-my-managers' +) + +# Specify what kind of notification should be sent (TRAP or INFORM), +# to what targets (chosen by tag) and what filter should apply to +# the set of targets (selected by tag) +config.addNotificationTarget( + snmpEngine, 'my-notification', 'my-filter', 'all-my-managers', 'trap' +) + +# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel +# and SecurityName +config.addContext(snmpEngine, '') +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6)) + +# *** SNMP engine configuration is complete by this line *** + +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator() + +# Build and submit notification message to dispatcher +ntfOrg.sendVarBinds( + snmpEngine, + 'my-notification', # notification targets + None, '', # contextEngineId, contextName + rfc1902.NotificationType( + rfc1902.ObjectIdentity('IF-MIB', 'linkUp'), + instanceIndex=instanceIndex, + objects=objects + ).resolveWithMib(mibViewController) +) + +print('Notification is scheduled to be sent') + +# Run I/O dispatcher which would send pending message and process response +snmpEngine.transportDispatcher.runDispatcher() diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v3-trap.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v3-trap.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/agent/ntforg/v3-trap.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/agent/ntforg/v3-trap.py 2017-12-22 11:53:40.000000000 +0000 @@ -8,7 +8,7 @@ * with user 'usr-md5-des', auth: MD5, priv DES * over IPv4/UDP * send TRAP notification -* to a Manager at 195.218.195.228:162 +* to a Manager at 104.236.166.95:162 * with TRAP ID 'warmStart' specified as an OID * include managed object information 1.3.6.1.2.1.1.5.0 = 'system name' @@ -46,7 +46,7 @@ ) config.addTargetAddr( snmpEngine, 'my-nms', - udp.domainName, ('195.218.195.228', 162), + udp.domainName, ('104.236.166.95', 162), 'my-creds', tagList='all-my-managers' ) @@ -61,7 +61,7 @@ # Allow NOTIFY access to Agent's MIB by this SNMP model (3), securityLevel # and SecurityName config.addContext(snmpEngine, '') -config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (), (), (1,3,6)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (), (), (1, 3, 6)) # *** SNMP engine configuration is complete by this line *** @@ -73,13 +73,13 @@ snmpEngine, # Notification targets 'my-notification', # notification targets - None, '', # contextEngineId, contextName + None, '', # contextEngineId, contextName # var-binds [ # SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart - ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))), + ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))), # additional var-binds: ( (oid, value), ... ) - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) + ((1, 3, 6, 1, 2, 1, 1, 5, 0), v2c.OctetString('Notificator Example')) ] ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py 2017-12-22 11:53:40.000000000 +0000 @@ -9,12 +9,12 @@ * contextEngineId: 0x80004fb805636c6f75644dab22cc, * contextName: da761cfc8c94d3aceef4f60f049105ba * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * for an OID in tuple form This script performs similar to the following Net-SNMP command: -| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 -E 80004fb805636c6f75644dab22cc -n da761cfc8c94d3aceef4f60f049105ba -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 +| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 -E 80004fb805636c6f75644dab22cc -n da761cfc8c94d3aceef4f60f049105ba -ObentU 104.236.166.95:161 1.3.6.1.2.1.1.1.0 """# from pysnmp.entity import engine, config @@ -49,25 +49,25 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for oid, val in varBinds: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) + # Prepare and send a request message, pass custom ContextEngineId & ContextName cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, @@ -76,7 +76,7 @@ rfc1902.OctetString(hexValue='80004fb805636c6f75644dab22cc'), # contextName rfc1902.OctetString('da761cfc8c94d3aceef4f60f049105ba'), - [ ((1,3,6,1,2,1,1,1,0), None) ], + [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,13 +6,13 @@ * with SNMPv2c, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * wait 3 seconds for response, retry 5 times (plus one initial attempt) * for an OID in tuple form This script performs similar to the following Net-SNMP command: -| $ snmpget -v2c -c public -ObentU -r 5 -t 1 195.218.195.228 1.3.6.1.2.1.1.1.0 +| $ snmpget -v2c -c public -ObentU -r 5 -t 1 104.236.166.95 1.3.6.1.2.1.1.1.0 """# from pysnmp.entity import engine, config @@ -45,33 +45,33 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds', timeout=300, # in 1/100 sec retryCount=5 ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for oid, val in varBinds: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) + # Prepare and send a request message cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1,1,0), None) ], + None, '', # contextEngineId, contextName + [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -50,31 +50,31 @@ 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return if errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return # stop on error for varBindRow in varBindTable: for oid, val in varBindRow: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) - return True # signal dispatcher to continue + return True # signal dispatcher to continue + # Prepare initial request to be sent cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1), None), - ((1,3,6,1,4,1,1), None) ], + [((1, 3, 6, 1, 2, 1, 1), None), + ((1, 3, 6, 1, 4, 1, 1), None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,14 +6,14 @@ * with SNMPv3 with user 'usr-md5-des', MD5 auth and DES privacy protocols * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * with values non-repeaters = 1, max-repetitions = 25 * for two OIDs in tuple form (first OID is non-repeating) * stop on end-of-mib condition for both OIDs This script performs similar to the following Net-SNMP command: -| $ snmpbulkwalk -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -C n1 -C r25 -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 +| $ snmpbulkwalk -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -C n1 -C r25 -ObentU 104.236.166.95 1.3.6.1.2.1.1 1.3.6.1.4.1.1 """# from pysnmp.entity import engine, config @@ -48,36 +48,36 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequesthandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return # stop on error if errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return # stop on error for varBindRow in varBindTable: for oid, val in varBindRow: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) - return True # signal dispatcher to continue walking + return True # signal dispatcher to continue walking + # Prepare initial request to be sent cmdgen.BulkCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - 0, 25, # non-repeaters, max-repetitions - ( ((1,3,6,1,2,1,1), None), - ((1,3,6,1,4,1,1), None) ), + 0, 25, # non-repeaters, max-repetitions + (((1, 3, 6, 1, 2, 1, 1), None), + ((1, 3, 6, 1, 4, 1, 1), None)), cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py 2017-12-22 11:53:40.000000000 +0000 @@ -5,14 +5,14 @@ Send a series of SNMP GETBULK requests * with SNMPv2c, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * with values non-repeaters = 0, max-repetitions = 25 * for two OIDs in tuple form * stop on end-of-mib condition for both OIDs This script performs similar to the following Net-SNMP command: -| $ snmpbulkwalk -v2c -c public -C n0 -C r25 -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 +| $ snmpbulkwalk -v2c -c public -C n0 -C r25 -ObentU 104.236.166.95 1.3.6.1.2.1.1 1.3.6.1.4.1.1 """# from pysnmp.entity import engine, config @@ -45,36 +45,36 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequesthandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return # stop on error if errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return # stop on error for varBindRow in varBindTable: for oid, val in varBindRow: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) - return True # signal dispatcher to continue walking + return True # signal dispatcher to continue walking + # Prepare initial request to be sent cmdgen.BulkCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - 0, 25, # non-repeaters, max-repetitions - [ ((1,3,6,1,2,1,1), None), - ((1,3,6,1,4,1,1), None) ], + 0, 25, # non-repeaters, max-repetitions + [((1, 3, 6, 1, 2, 1, 1), None), + ((1, 3, 6, 1, 4, 1, 1), None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,13 +6,13 @@ * with SNMPv1, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * for two OIDs in tuple form * stop on end-of-mib condition for both OIDs This script performs similar to the following Net-SNMP command: -| $ snmpwalk -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 +| $ snmpwalk -v1 -c public -ObentU 104.236.166.95 1.3.6.1.2.1.1 1.3.6.1.4.1.1 """# from pysnmp.entity import engine, config @@ -27,7 +27,7 @@ # This call will fail if PySMI is not present on the system compiler.addMibCompiler(snmpEngine.getMibBuilder()) # ... alternatively, this call will not complain on missing PySMI -#compiler.addMibCompiler(snmpEngine.getMibBuilder(), ifAvailable=True) +# compiler.addMibCompiler(snmpEngine.getMibBuilder(), ifAvailable=True) # Used for MIB objects resolution mibViewController = view.MibViewController(snmpEngine.getMibBuilder()) @@ -56,11 +56,13 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: @@ -69,24 +71,23 @@ # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception, # so we ignore noSuchName error here if errorStatus and errorStatus != 2: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return # stop on error for varBindRow in varBindTable: for varBind in varBindRow: - print(rfc1902.ObjectType(rfc1902.ObjectIdentity(varBind[0]), varBind[1]).resolveWithMib(mibViewController).prettyPrint()) - return 1 # signal dispatcher to continue + print(rfc1902.ObjectType(rfc1902.ObjectIdentity(varBind[0]), + varBind[1]).resolveWithMib(mibViewController).prettyPrint()) + return 1 # signal dispatcher to continue + # Prepare initial request to be sent cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ rfc1902.ObjectType(rfc1902.ObjectIdentity('iso.org.dod')).resolveWithMib(mibViewController), - rfc1902.ObjectType(rfc1902.ObjectIdentity('IF-MIB', 'ifMIB')).resolveWithMib(mibViewController) ], + [rfc1902.ObjectType(rfc1902.ObjectIdentity('iso.org.dod')).resolveWithMib(mibViewController), + rfc1902.ObjectType(rfc1902.ObjectIdentity('IF-MIB', 'ifMIB')).resolveWithMib(mibViewController)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,13 +6,13 @@ * with SNMPv1, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * for two OIDs in tuple form * stop on end-of-mib condition for both OIDs This script performs similar to the following Net-SNMP command: -| $ snmpwalk -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 +| $ snmpwalk -v1 -c public -ObentU 104.236.166.95 1.3.6.1.2.1.1 1.3.6.1.4.1.1 """# from pysnmp.entity import engine, config @@ -45,11 +45,13 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: @@ -58,24 +60,22 @@ # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception, # so we ignore noSuchName error here if errorStatus and errorStatus != 2: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return # stop on error for varBindRow in varBindTable: for oid, val in varBindRow: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) - return 1 # signal dispatcher to continue + return 1 # signal dispatcher to continue + # Prepare initial request to be sent cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1), None), - ((1,3,6,1,4,1,1), None) ], + [((1, 3, 6, 1, 2, 1, 1), None), + ((1, 3, 6, 1, 4, 1, 1), None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,7 +6,7 @@ * with SNMPv3 with user 'usr-sha-aes', SHA auth and AES128 privacy protocols * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * for an OID in tuple form * also registers its own execution observer to snmpEngine @@ -15,7 +15,7 @@ This script performs similar to the following Net-SNMP command: -| $ snmpget -v3 -l authPriv -u usr-sha-aes -a SHA -A authkey1 -x AES -X privkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 +| $ snmpget -v3 -l authPriv -u usr-sha-aes -a SHA -A authkey1 -x AES -X privkey1 -ObentU 104.236.166.95:161 1.3.6.1.2.1.1.1.0 """# from pysnmp.entity import engine, config @@ -25,10 +25,12 @@ # Create SNMP engine instance snmpEngine = engine.SnmpEngine() + # Execution point observer setup # Register a callback to be invoked at specified execution point of # SNMP Engine and passed local variables at code point's local scope +# noinspection PyUnusedLocal,PyUnusedLocal def requestObserver(snmpEngine, execpoint, variables, cbCtx): print('Execution point: %s' % execpoint) print('* transportDomain: %s' % '.'.join([str(x) for x in variables['transportDomain']])) @@ -40,8 +42,9 @@ print('* contextName: %s' % variables['contextName'].prettyPrint()) print('* PDU: %s' % variables['pdu'].prettyPrint()) + snmpEngine.observer.registerObserver( - requestObserver, + requestObserver, 'rfc3412.sendPdu', 'rfc3412.receiveMessage:response' ) @@ -71,31 +74,31 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for oid, val in varBinds: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) + # Prepare and send a request message cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1,1,0), None) ], + [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py 2017-12-22 11:53:40.000000000 +0000 @@ -5,13 +5,13 @@ Send a series of SNMP GETNEXT requests * with SNMPv3 with user 'usr-none-none', no auth and no privacy protocols * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * for an OID in string form * stop whenever received OID goes out of initial prefix (it may be a table) This script performs similar to the following Net-SNMP command: -| $ snmpwalk -v3 -l noAuthNoPriv -u usr-none-none -ObentU 195.218.195.228:161 1.3.6.1.2.1.1 +| $ snmpwalk -v3 -l noAuthNoPriv -u usr-none-none -ObentU 104.236.166.95:161 1.3.6.1.2.1.1 """# from pysnmp.entity import engine, config @@ -48,37 +48,37 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return if errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return # stop on error for varBindRow in varBindTable: for oid, val in varBindRow: if initialOID.isPrefixOf(oid): print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) else: - return False # signal dispatcher to stop - return True # signal dispatcher to continue + return False # signal dispatcher to stop + return True # signal dispatcher to continue + # Prepare initial request to be sent cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ (initialOID, None) ], + [(initialOID, None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,14 +6,14 @@ * with SNMPv2c, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * sending packets from primary local interface 0.0.0.0, local port 61024 * for two OIDs in tuple form * stop on end-of-mib condition for both OIDs This script performs similar to the following Net-SNMP command: -| $ snmpwalk -v2c -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1 1.3.6.1.4.1.1 +| $ snmpwalk -v2c -c public -ObentU 104.236.166.95 1.3.6.1.2.1.1 1.3.6.1.4.1.1 """# from pysnmp.entity import engine, config @@ -46,35 +46,35 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return if errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?')) return # stop on error for varBindRow in varBindTable: for oid, val in varBindRow: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) - return 1 # signal dispatcher to continue + return 1 # signal dispatcher to continue + # Prepare initial request to be sent cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1), None), - ((1,3,6,1,2,1,11), None) ], + [((1, 3, 6, 1, 2, 1, 1), None), + ((1, 3, 6, 1, 2, 1, 11), None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,12 +6,12 @@ * with SNMPv1 with community name 'private' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * for OIDs in tuple form and an integer and string-typed values This script performs similar to the following Net-SNMP command: -| $ snmpset -v1 -c private -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.9.1.3.1 s 'my value' 1.3.6.1.2.1.1.9.1.4.1 t 123 +| $ snmpset -v1 -c private -ObentU 104.236.166.95:161 1.3.6.1.2.1.1.9.1.3.1 s 'my value' 1.3.6.1.2.1.1.9.1.4.1 t 123 """# from pysnmp.entity import engine, config @@ -45,11 +45,13 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: @@ -57,22 +59,20 @@ # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception, # so we ignore noSuchName error here elif errorStatus and errorStatus != 2: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for oid, val in varBinds: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) + # Prepare and send a request message cmdgen.SetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my value')), - ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.TimeTicks(123)) ], + [((1, 3, 6, 1, 2, 1, 1, 9, 1, 3, 1), rfc1902.OctetString('my value')), + ((1, 3, 6, 1, 2, 1, 1, 9, 1, 4, 1), rfc1902.TimeTicks(123))], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py 2017-12-22 11:53:40.000000000 +0000 @@ -5,13 +5,13 @@ Send a SNMP GET request * with SNMPv2c, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * from a non-local, spoofed IP 1.2.3.4 (root and Python 3.3+ required) * for an OID in tuple form This script performs similar to the following Net-SNMP command: -| $ snmpget -v2c -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1.1.0 +| $ snmpget -v2c -c public -ObentU 104.236.166.95 1.3.6.1.2.1.1.1.0 But unlike the above command, this script issues SNMP request from a non-default, non-local IP address. @@ -65,12 +65,14 @@ # Configure destination IPv4 address as well as source IPv4 address config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds', sourceAddress=('1.2.3.4', 0) ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: @@ -78,21 +80,19 @@ # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception, # so we ignore noSuchName error here elif errorStatus and errorStatus != 2: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for oid, val in varBinds: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) + # Prepare and send a request message cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1,1,0), None) ], + [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py 2017-12-22 11:53:40.000000000 +0000 @@ -5,12 +5,12 @@ Send a SNMP GET request * with SNMPv3 with user 'usr-sha-aes', SHA auth and AES128 privacy protocols * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * for an OID in tuple form This script performs similar to the following Net-SNMP command: -| $ snmpget -v3 -l authPriv -u usr-sha-aes -a SHA -A authkey1 -x AES -X privkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 +| $ snmpget -v3 -l authPriv -u usr-sha-aes -a SHA -A authkey1 -x AES -X privkey1 -ObentU 104.236.166.95:161 1.3.6.1.2.1.1.1.0 """# from pysnmp.entity import engine, config @@ -45,31 +45,31 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for oid, val in varBinds: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) + # Prepare and send a request message cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1,1,0), None) ], + [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py 2017-12-22 11:53:40.000000000 +0000 @@ -6,12 +6,12 @@ * with SNMPv3 with user 'usr-sha-none', SHA auth and no privacy protocols * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * for an OID in tuple form and a string-typed value This script performs similar to the following Net-SNMP command: -| $ snmpset -v3 -l authNoPriv -u usr-sha-none -a SHA -A authkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.9.1.3.1 s 'my new value' +| $ snmpset -v3 -l authNoPriv -u usr-sha-none -a SHA -A authkey1 -ObentU 104.236.166.95:161 1.3.6.1.2.1.1.9.1.3.1 s 'my new value' """# from pysnmp.entity import engine, config @@ -46,31 +46,31 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for oid, val in varBinds: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) + # Prepare and send a request message cmdgen.SetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my new value')) ], + [((1, 3, 6, 1, 2, 1, 1, 9, 1, 3, 1), rfc1902.OctetString('my new value'))], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/v1-get.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/v1-get.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/v1-get.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/v1-get.py 2017-12-22 11:53:40.000000000 +0000 @@ -4,12 +4,12 @@ * with SNMPv1, community 'public' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * for an OID in tuple form This script performs similar to the following Net-SNMP command: -| $ snmpget -v1 -c public -ObentU 195.218.195.228 1.3.6.1.2.1.1.1.0 +| $ snmpget -v1 -c public -ObentU 104.236.166.95 1.3.6.1.2.1.1.1.0 """# from pysnmp.entity import engine, config @@ -42,11 +42,13 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: @@ -54,21 +56,19 @@ # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception, # so we ignore noSuchName error here elif errorStatus and errorStatus != 2: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for oid, val in varBinds: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) + # Prepare and send a request message cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1,1,0), None) ], + [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py 2017-12-22 11:53:40.000000000 +0000 @@ -5,12 +5,12 @@ Send a SNMP SET request * with SNMPv2c with community name 'private' * over IPv4/UDP -* to an Agent at 195.218.195.228:161 +* to an Agent at 104.236.166.95:161 * for an OID in tuple form and an integer-typed value This script performs similar to the following Net-SNMP command: -| $ snmpset -v2c -c private -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.9.1.4.1 t 123 +| $ snmpset -v2c -c private -ObentU 104.236.166.95:161 1.3.6.1.2.1.1.9.1.4.1 t 123 """# from pysnmp.entity import engine, config @@ -44,31 +44,31 @@ ) config.addTargetAddr( snmpEngine, 'my-router', - udp.domainName, ('195.218.195.228', 161), + udp.domainName, ('104.236.166.95', 161), 'my-creds' ) + # Error/response receiver +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: - print('%s at %s' % ( - errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1][0] or '?' - ) - ) + print('%s at %s' % (errorStatus.prettyPrint(), + errorIndex and varBinds[int(errorIndex) - 1][0] or '?')) else: for oid, val in varBinds: print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) + # Prepare and send a request message cmdgen.SetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', None, '', # contextEngineId, contextName - [ ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.TimeTicks(123)) ], + [((1, 3, 6, 1, 2, 1, 1, 9, 1, 4, 1), rfc1902.TimeTicks(123))], cbFun ) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py 2017-12-22 11:53:40.000000000 +0000 @@ -38,7 +38,9 @@ # SecurityName <-> CommunityName mapping config.addV1System(snmpEngine, 'my-area', 'public') + # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): # Get an execution context... @@ -47,19 +49,17 @@ ) # ... and use inner SNMP engine data to figure out peer address - print('Notification from %s, ContextEngineId "%s", ContextName "%s"' % ( - '@'.join([str(x) for x in execContext['transportAddress']]), - contextEngineId.prettyPrint(), - contextName.prettyPrint() - ) - ) + print('Notification from %s, ContextEngineId "%s", ContextName "%s"' % ('@'.join([str(x) for x in execContext['transportAddress']]), + contextEngineId.prettyPrint(), + contextName.prettyPrint())) for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) + # Register SNMP Application at the SNMP engine ntfrcv.NotificationReceiver(snmpEngine, cbFun) -snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish +snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish # Run I/O dispatcher which would receive queries and send confirmations try: diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py 2017-12-22 11:53:40.000000000 +0000 @@ -46,21 +46,21 @@ # SecurityName <-> CommunityName mapping config.addV1System(snmpEngine, 'my-area', 'public') + # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): - print('Notification from ContextEngineId "%s", ContextName "%s"' % ( - contextEngineId.prettyPrint(), - contextName.prettyPrint() - ) - ) + print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(), + contextName.prettyPrint())) for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) + # Register SNMP Application at the SNMP engine ntfrcv.NotificationReceiver(snmpEngine, cbFun) -snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish +snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish # Run I/O dispatcher which would receive queries and send confirmations try: diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports-incl-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports-incl-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports-incl-ipv4-and-ipv6.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports-incl-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,71 @@ +""" +Using multiple network transports ++++++++++++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv1/SNMPv2c +* with SNMP community "public" +* over IPv4/UDP, listening at 127.0.0.1:162 + over IPv6/UDP, listening at [::1]:162 +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 1 1 123 1.3.6.1.2.1.1.1.0 s test +| $ snmptrap -v2c -c public udp6:[::1]:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test +| $ snmpinform -v2c -c public 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 + +"""# +from pysnmp.entity import engine, config +from pysnmp.carrier.asyncore.dgram import udp, udp6 +from pysnmp.entity.rfc3413 import ntfrcv + +# Create SNMP engine with autogenernated engineID and pre-bound +# to socket transport dispatcher +snmpEngine = engine.SnmpEngine() + +# Transport setup + +# UDP over IPv4 +config.addTransport( + snmpEngine, + udp.domainName, + udp.UdpTransport().openServerMode(('127.0.0.1', 162)) +) + +# UDP over IPv6 +config.addTransport( + snmpEngine, + udp6.domainName, + udp6.Udp6Transport().openServerMode(('::1', 162)) +) + +# SNMPv1/2c setup + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + + +# Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, stateReference, contextEngineId, contextName, + varBinds, cbCtx): + print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(), + contextName.prettyPrint())) + for name, val in varBinds: + print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) + + +# Register SNMP Application at the SNMP engine +ntfrcv.NotificationReceiver(snmpEngine, cbFun) + +snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish + +# Run I/O dispatcher which would receive queries and send confirmations +try: + snmpEngine.transportDispatcher.runDispatcher() +except: + snmpEngine.transportDispatcher.closeDispatcher() + raise diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -""" -Using multiple network transports -+++++++++++++++++++++++++++++++++ - -Receive SNMP TRAP/INFORM messages with the following options: - -* SNMPv1/SNMPv2c -* with SNMP community "public" -* over IPv4/UDP, listening at 127.0.0.1:162 - over IPv6/UDP, listening at [::1]:162 -* print received data on stdout - -Either of the following Net-SNMP commands will send notifications to this -receiver: - -| $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 1 1 123 1.3.6.1.2.1.1.1.0 s test -| $ snmptrap -v2c -c public udp6:[::1]:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test -| $ snmpinform -v2c -c public 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 - -"""# -from pysnmp.entity import engine, config -from pysnmp.carrier.asyncore.dgram import udp, udp6 -from pysnmp.entity.rfc3413 import ntfrcv - -# Create SNMP engine with autogenernated engineID and pre-bound -# to socket transport dispatcher -snmpEngine = engine.SnmpEngine() - -# Transport setup - -# UDP over IPv4 -config.addTransport( - snmpEngine, - udp.domainName, - udp.UdpTransport().openServerMode(('127.0.0.1', 162)) -) - -# UDP over IPv6 -config.addTransport( - snmpEngine, - udp6.domainName, - udp6.Udp6Transport().openServerMode(('::1', 162)) - ) - -# SNMPv1/2c setup - -# SecurityName <-> CommunityName mapping -config.addV1System(snmpEngine, 'my-area', 'public') - -# Callback function for receiving notifications -def cbFun(snmpEngine, stateReference, contextEngineId, contextName, - varBinds, cbCtx): - print('Notification from ContextEngineId "%s", ContextName "%s"' % ( - contextEngineId.prettyPrint(), - contextName.prettyPrint() - ) - ) - for name, val in varBinds: - print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) - -# Register SNMP Application at the SNMP engine -ntfrcv.NotificationReceiver(snmpEngine, cbFun) - -snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish - -# Run I/O dispatcher which would receive queries and send confirmations -try: - snmpEngine.transportDispatcher.runDispatcher() -except: - snmpEngine.transportDispatcher.closeDispatcher() - raise diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py 2017-12-22 11:53:40.000000000 +0000 @@ -87,21 +87,21 @@ securityEngineId=v2c.OctetString(hexValue='8000000001020304') ) + # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): - print('Notification from ContextEngineId "%s", ContextName "%s"' % ( - contextEngineId.prettyPrint(), - contextName.prettyPrint() - ) - ) + print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(), + contextName.prettyPrint())) for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) + # Register SNMP Application at the SNMP engine ntfrcv.NotificationReceiver(snmpEngine, cbFun) -snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish +snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish # Run I/O dispatcher which would receive queries and send confirmations try: diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing-over-ipv4-and-ipv6.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing-over-ipv4-and-ipv6.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing-over-ipv4-and-ipv6.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing-over-ipv4-and-ipv6.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,97 @@ +""" +Observe SNMP engine internal operations ++++++++++++++++++++++++++++++++++++++++ + +Receive SNMP TRAP/INFORM messages with the following options: + +* SNMPv1/SNMPv2c +* with SNMP community "public" +* over IPv4/UDP, listening at 127.0.0.1:162 + over IPv6/UDP, listening at [::1]:162 +* registers its own execution observer to snmpEngine +* print received data on stdout + +Either of the following Net-SNMP commands will send notifications to this +receiver: + +| $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 1 1 123 1.3.6.1.2.1.1.1.0 s test +| $ snmptrap -v2c -c public udp6:[::1]:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test +| $ snmpinform -v2c -c public 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 + +"""# +from pysnmp.entity import engine, config +from pysnmp.carrier.asyncore.dgram import udp, udp6 +from pysnmp.entity.rfc3413 import ntfrcv + +# Create SNMP engine with autogenernated engineID and pre-bound +# to socket transport dispatcher +snmpEngine = engine.SnmpEngine() + + +# Execution point observer setup + +# Register a callback to be invoked at specified execution point of +# SNMP Engine and passed local variables at code point's local scope +# noinspection PyUnusedLocal,PyUnusedLocal +def requestObserver(snmpEngine, execpoint, variables, cbCtx): + print('Execution point: %s' % execpoint) + print('* transportDomain: %s' % '.'.join([str(x) for x in variables['transportDomain']])) + print('* transportAddress: %s' % '@'.join([str(x) for x in variables['transportAddress']])) + print('* securityModel: %s' % variables['securityModel']) + print('* securityName: %s' % variables['securityName']) + print('* securityLevel: %s' % variables['securityLevel']) + print('* contextEngineId: %s' % variables['contextEngineId'].prettyPrint()) + print('* contextName: %s' % variables['contextName'].prettyPrint()) + print('* PDU: %s' % variables['pdu'].prettyPrint()) + + +snmpEngine.observer.registerObserver( + requestObserver, + 'rfc3412.receiveMessage:request', + 'rfc3412.returnResponsePdu' +) + +# Transport setup + +# UDP over IPv4 +config.addTransport( + snmpEngine, + udp.domainName, + udp.UdpTransport().openServerMode(('127.0.0.1', 162)) +) + +# UDP over IPv6 +config.addTransport( + snmpEngine, + udp6.domainName, + udp6.Udp6Transport().openServerMode(('::1', 162)) +) + +# SNMPv1/2c setup + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, 'my-area', 'public') + + +# Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal +def cbFun(snmpEngine, stateReference, contextEngineId, contextName, + varBinds, cbCtx): + print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(), + contextName.prettyPrint())) + for name, val in varBinds: + print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) + + +# Register SNMP Application at the SNMP engine +ntfrcv.NotificationReceiver(snmpEngine, cbFun) + +snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish + +# Run I/O dispatcher which would receive queries and send confirmations +try: + snmpEngine.transportDispatcher.runDispatcher() +except: + snmpEngine.observer.unregisterObserver() + snmpEngine.transportDispatcher.closeDispatcher() + raise diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -""" -Observe SNMP engine internal operations -+++++++++++++++++++++++++++++++++++++++ - -Receive SNMP TRAP/INFORM messages with the following options: - -* SNMPv1/SNMPv2c -* with SNMP community "public" -* over IPv4/UDP, listening at 127.0.0.1:162 - over IPv6/UDP, listening at [::1]:162 -* registers its own execution observer to snmpEngine -* print received data on stdout - -Either of the following Net-SNMP commands will send notifications to this -receiver: - -| $ snmptrap -v1 -c public 127.0.0.1 1.3.6.1.4.1.20408.4.1.1.2 127.0.0.1 1 1 123 1.3.6.1.2.1.1.1.0 s test -| $ snmptrap -v2c -c public udp6:[::1]:162 123 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.5.0 s test -| $ snmpinform -v2c -c public 127.0.0.1 123 1.3.6.1.6.3.1.1.5.1 - -"""# -from pysnmp.entity import engine, config -from pysnmp.carrier.asyncore.dgram import udp, udp6 -from pysnmp.entity.rfc3413 import ntfrcv - -# Create SNMP engine with autogenernated engineID and pre-bound -# to socket transport dispatcher -snmpEngine = engine.SnmpEngine() - -# Execution point observer setup - -# Register a callback to be invoked at specified execution point of -# SNMP Engine and passed local variables at code point's local scope -def requestObserver(snmpEngine, execpoint, variables, cbCtx): - print('Execution point: %s' % execpoint) - print('* transportDomain: %s' % '.'.join([str(x) for x in variables['transportDomain']])) - print('* transportAddress: %s' % '@'.join([str(x) for x in variables['transportAddress']])) - print('* securityModel: %s' % variables['securityModel']) - print('* securityName: %s' % variables['securityName']) - print('* securityLevel: %s' % variables['securityLevel']) - print('* contextEngineId: %s' % variables['contextEngineId'].prettyPrint()) - print('* contextName: %s' % variables['contextName'].prettyPrint()) - print('* PDU: %s' % variables['pdu'].prettyPrint()) - -snmpEngine.observer.registerObserver( - requestObserver, - 'rfc3412.receiveMessage:request', - 'rfc3412.returnResponsePdu' -) - -# Transport setup - -# UDP over IPv4 -config.addTransport( - snmpEngine, - udp.domainName, - udp.UdpTransport().openServerMode(('127.0.0.1', 162)) -) - -# UDP over IPv6 -config.addTransport( - snmpEngine, - udp6.domainName, - udp6.Udp6Transport().openServerMode(('::1', 162)) - ) - -# SNMPv1/2c setup - -# SecurityName <-> CommunityName mapping -config.addV1System(snmpEngine, 'my-area', 'public') - -# Callback function for receiving notifications -def cbFun(snmpEngine, stateReference, contextEngineId, contextName, - varBinds, cbCtx): - print('Notification from ContextEngineId "%s", ContextName "%s"' % ( - contextEngineId.prettyPrint(), - contextName.prettyPrint() - ) - ) - for name, val in varBinds: - print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) - -# Register SNMP Application at the SNMP engine -ntfrcv.NotificationReceiver(snmpEngine, cbFun) - -snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish - -# Run I/O dispatcher which would receive queries and send confirmations -try: - snmpEngine.transportDispatcher.runDispatcher() -except: - snmpEngine.observer.unregisterObserver() - snmpEngine.transportDispatcher.closeDispatcher() - raise diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py 2015-09-14 05:20:26.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py 2017-12-22 11:53:40.000000000 +0000 @@ -28,23 +28,25 @@ from pysnmp.entity import engine, config from pysnmp.carrier.asyncore.dgram import udp from pysnmp.entity.rfc3413 import ntfrcv -from pysnmp.proto.api import v2c import re # Create SNMP engine with autogenernated engineID and pre-bound # to socket transport dispatcher snmpEngine = engine.SnmpEngine() -# Register a callback to be invoked at specified execution point of + +# Register a callback to be invoked at specified execution point of # SNMP Engine and passed local variables at execution point's local scope. # If at this execution point passed variables are modified, their new # values will be propagated back and used by SNMP Engine for securityName # selection. +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def requestObserver(snmpEngine, execpoint, variables, cbCtx): if re.match('.*love.*', str(variables['communityName'])): print('Rewriting communityName \'%s\' from %s into \'public\'' % (variables['communityName'], ':'.join([str(x) for x in variables['transportInformation'][1]]))) variables['communityName'] = variables['communityName'].clone('public') + snmpEngine.observer.registerObserver( requestObserver, 'rfc2576.processIncomingMsg:writable' @@ -64,21 +66,21 @@ # SecurityName <-> CommunityName mapping config.addV1System(snmpEngine, 'my-area', 'public') + # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): - print('Notification from ContextEngineId "%s", ContextName "%s"' % ( - contextEngineId.prettyPrint(), - contextName.prettyPrint() - ) - ) + print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(), + contextName.prettyPrint())) for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) + # Register SNMP Application at the SNMP engine ntfrcv.NotificationReceiver(snmpEngine, cbFun) -snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish +snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish # Run I/O dispatcher which would receive queries and send confirmations try: diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/proxy/command/ipv6-to-ipv4-conversion.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/proxy/command/ipv6-to-ipv4-conversion.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/proxy/command/ipv6-to-ipv4-conversion.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/proxy/command/ipv6-to-ipv4-conversion.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,144 @@ +""" +IPv6-to-IPv4 conversion ++++++++++++++++++++++++ + +Act as a local SNMPv1/v2c Agent listening on a UDP/IPv6 transport, relay +messages to distant SNMPv1/2c Agent over UDP/IPv4 transport: + +* with local SNMPv2c community 'public' +* local Agent listening at [::1]:161 +* remote SNMPv2c community 'public' +* remote Agent listening at 104.236.166.95:161 + +This script can be queried with the following Net-SNMP command: + +| $ snmpget -v2c -c public udp6:[::1]:161 sysDescr.0 + +due to proxy, it is equivalent to + +| $ snmpget -v2c -c public 104.236.166.95:161 sysDescr.0 + +Warning: for production operation you would need to modify this script +so that it will re-map possible duplicate request-ID values, coming in +initial request PDUs from different Managers, into unique values to +avoid sending duplicate request-IDs to Agents. + +"""# +from pysnmp.carrier.asyncore.dgram import udp, udp6 +from pysnmp.entity import engine, config +from pysnmp.entity.rfc3413 import cmdrsp, cmdgen, context +from pysnmp.proto.api import v2c +from pysnmp import error + +# Create SNMP engine with autogenernated engineID and pre-bound +# to socket transport dispatcher +snmpEngine = engine.SnmpEngine() + +# +# Transport setup +# + +# Agent section + +# UDP over IPv6 +config.addTransport( + snmpEngine, + udp6.domainName, + udp6.Udp6Transport().openServerMode(('::1', 161)) +) + +# Manager section + +# UDP over IPv4 +config.addTransport( + snmpEngine, + udp.domainName, + udp.UdpTransport().openClientMode() +) + +# +# SNMPv1/2c setup (Agent role) +# + +# SecurityName <-> CommunityName mapping +config.addV1System(snmpEngine, '1-my-area', 'public') + +# +# SNMPv1/v2c setup (Manager role) +# +# Here we configure securityName lexicographically lesser than '1-my-area' +# to let it match first in snmpCommunityTable on response processing. +# + +config.addV1System(snmpEngine, '0-distant-area', 'public', transportTag='remote') + +# +# Transport target used by Manager +# + +config.addTargetParams( + snmpEngine, 'distant-agent-auth', '0-distant-area', 'noAuthNoPriv', 1 +) +config.addTargetAddr( + snmpEngine, 'distant-agent', + udp.domainName, ('104.236.166.95', 161), + 'distant-agent-auth', retryCount=0, tagList='remote' +) + +# Default SNMP context +config.addContext(snmpEngine, '') + + +class CommandResponder(cmdrsp.CommandResponderBase): + cmdGenMap = { + v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(), + v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(), + v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(), + v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun() + } + pduTypes = cmdGenMap.keys() # This app will handle these PDUs + + # SNMP request relay + def handleMgmtOperation(self, snmpEngine, stateReference, contextName, + PDU, acInfo): + cbCtx = stateReference, PDU + contextEngineId = None # address authoritative SNMP Engine + try: + self.cmdGenMap[PDU.tagSet].sendPdu( + snmpEngine, 'distant-agent', + contextEngineId, contextName, + PDU, + self.handleResponsePdu, cbCtx + ) + except error.PySnmpError: + self.handleResponsePdu( + snmpEngine, stateReference, 'error', None, cbCtx + ) + + # SNMP response relay + # noinspection PyUnusedLocal + def handleResponsePdu(self, snmpEngine, sendRequestHandle, + errorIndication, PDU, cbCtx): + stateReference, reqPDU = cbCtx + + if errorIndication: + PDU = v2c.apiPDU.getResponse(reqPDU) + PDU.setErrorStatus(PDU, 5) + + self.sendPdu( + snmpEngine, stateReference, PDU + ) + + self.releaseStateInformation(stateReference) + + +CommandResponder(snmpEngine, context.SnmpContext(snmpEngine)) + +snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish + +# Run I/O dispatcher which would receive queries and send responses +try: + snmpEngine.transportDispatcher.runDispatcher() +except: + snmpEngine.transportDispatcher.closeDispatcher() + raise diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py 2015-09-14 05:20:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ -""" -IPv6-to-IPv4 conversion -+++++++++++++++++++++++ - -Act as a local SNMPv1/v2c Agent listening on a UDP/IPv6 transport, relay -messages to distant SNMPv1/2c Agent over UDP/IPv4 transport: - -* with local SNMPv2c community 'public' -* local Agent listening at [::1]:161 -* remote SNMPv2c community 'public' -* remote Agent listening at 195.218.195.228:161 - -This script can be queried with the following Net-SNMP command: - -| $ snmpget -v2c -c public udp6:[::1]:161 sysDescr.0 - -due to proxy, it is equivalent to - -| $ snmpget -v2c -c public 195.218.195.228:161 sysDescr.0 - -Warning: for production operation you would need to modify this script -so that it will re-map possible duplicate request-ID values, coming in -initial request PDUs from different Managers, into unique values to -avoid sending duplicate request-IDs to Agents. - -"""# -from pysnmp.carrier.asyncore.dgram import udp, udp6 -from pysnmp.entity import engine, config -from pysnmp.entity.rfc3413 import cmdrsp, cmdgen, context -from pysnmp.proto.api import v2c -from pysnmp import error - -# Create SNMP engine with autogenernated engineID and pre-bound -# to socket transport dispatcher -snmpEngine = engine.SnmpEngine() - -# -# Transport setup -# - -# Agent section - -# UDP over IPv6 -config.addTransport( - snmpEngine, - udp6.domainName, - udp6.Udp6Transport().openServerMode(('::1', 161)) -) - -# Manager section - -# UDP over IPv4 -config.addTransport( - snmpEngine, - udp.domainName, - udp.UdpTransport().openClientMode() -) - -# -# SNMPv1/2c setup (Agent role) -# - -# SecurityName <-> CommunityName mapping -config.addV1System(snmpEngine, '1-my-area', 'public') - -# -# SNMPv1/v2c setup (Manager role) -# -# Here we configure securityName lexicographically lesser than '1-my-area' -# to let it match first in snmpCommunityTable on response processing. -# - -config.addV1System(snmpEngine, '0-distant-area', 'public', - transportTag='remote') - -# -# Transport target used by Manager -# - -config.addTargetParams( - snmpEngine, 'distant-agent-auth', '0-distant-area', 'noAuthNoPriv', 1 -) -config.addTargetAddr( - snmpEngine, 'distant-agent', - udp.domainName, ('195.218.195.228', 161), - 'distant-agent-auth', retryCount=0, tagList='remote' -) - -# Default SNMP context -config.addContext(snmpEngine, '') - -class CommandResponder(cmdrsp.CommandResponderBase): - cmdGenMap = { - v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(), - v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(), - v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(), - v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun() - } - pduTypes = cmdGenMap.keys() # This app will handle these PDUs - - # SNMP request relay - def handleMgmtOperation(self, snmpEngine, stateReference, contextName, - PDU, acInfo): - cbCtx = stateReference, PDU - contextEngineId = None # address authoritative SNMP Engine - try: - self.cmdGenMap[PDU.tagSet].sendPdu( - snmpEngine, 'distant-agent', - contextEngineId, contextName, - PDU, - self.handleResponsePdu, cbCtx - ) - except error.PySnmpError: - self.handleResponsePdu( - stateReference, 'error', None, cbCtx - ) - - # SNMP response relay - def handleResponsePdu(self, snmpEngine, sendRequestHandle, - errorIndication, PDU, cbCtx): - stateReference, reqPDU = cbCtx - - if errorIndication: - PDU = v2c.apiPDU.getResponse(reqPDU) - PDU.setErrorStatus(PDU, 5) - - self.sendPdu( - snmpEngine, stateReference, PDU - ) - - self.releaseStateInformation(stateReference) - -CommandResponder(snmpEngine, context.SnmpContext(snmpEngine)) - -snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish - -# Run I/O dispatcher which would receive queries and send responses -try: - snmpEngine.transportDispatcher.runDispatcher() -except: - snmpEngine.transportDispatcher.closeDispatcher() - raise diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py 2015-09-14 05:20:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py 2017-12-22 11:53:40.000000000 +0000 @@ -8,7 +8,7 @@ * with local SNMPv2c community public * local Agent listening at 127.0.0.1:161 * remote SNMPv1, community public -* remote Agent listening at 195.218.195.228:161 +* remote Agent listening at 104.236.166.95:161 This script can be queried with the following Net-SNMP command: @@ -16,7 +16,7 @@ due to proxy, it is equivalent to -| $ snmpwalk -v1 -c public 195.218.195.228:161 system +| $ snmpwalk -v1 -c public 104.236.166.95:161 system Warning: for production operation you would need to modify this script so that it will re-map possible duplicate request-ID values, coming in @@ -79,20 +79,21 @@ 'noAuthNoPriv', 0) config.addTargetAddr( - snmpEngine, 'distant-agent', - udp.domainName + (2,), ('195.218.195.228', 161), - 'distant-agent-auth', retryCount=0, tagList='distant' + snmpEngine, 'distant-agent', + udp.domainName + (2,), ('104.236.166.95', 161), + 'distant-agent-auth', retryCount=0, tagList='distant' ) # Default SNMP context config.addContext(snmpEngine, '') + class CommandResponder(cmdrsp.CommandResponderBase): - cmdGenMap = { + cmdGenMap = { v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(), v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(), v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(), - v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun() + v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun() } pduTypes = cmdGenMap.keys() # This app will handle these PDUs @@ -103,17 +104,18 @@ contextEngineId = None # address authoritative SNMP Engine try: self.cmdGenMap[PDU.tagSet].sendPdu( - snmpEngine, 'distant-agent', + snmpEngine, 'distant-agent', contextEngineId, contextName, PDU, self.handleResponsePdu, cbCtx ) except error.PySnmpError: self.handleResponsePdu( - stateReference, 'error', None, cbCtx + snmpEngine, stateReference, 'error', None, cbCtx ) # SNMP response relay + # noinspection PyUnusedLocal def handleResponsePdu(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): stateReference, reqPDU = cbCtx @@ -128,9 +130,10 @@ self.releaseStateInformation(stateReference) + CommandResponder(snmpEngine, context.SnmpContext(snmpEngine)) -snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish +snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish # Run I/O dispatcher which would receive queries and send responses try: diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py 2015-09-14 05:20:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py 2017-12-22 11:53:40.000000000 +0000 @@ -7,7 +7,7 @@ * with local SNMPv2c community 'public' * local Agent listening at 127.0.0.1:161 * remote SNMPv3 user usr-md5-none, MD5 auth and no privacy protocols -* remote Agent listening at 195.218.195.228:161 +* remote Agent listening at 104.236.166.95:161 This script can be queried with the following Net-SNMP command: @@ -15,7 +15,7 @@ due to proxy, it is equivalent to -| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 -ObentU 195.218.195.228:161 1.3.6.1.2.1.1.1.0 +| $ snmpget -v3 -l authNoPriv -u usr-md5-none -A authkey1 -ObentU 104.236.166.95:161 1.3.6.1.2.1.1.1.0 Warning: for production operation you would need to modify this script so that it will re-map possible duplicate request-ID values, coming in @@ -79,20 +79,21 @@ snmpEngine, 'distant-agent-auth', 'usr-md5-none', 'authNoPriv' ) config.addTargetAddr( - snmpEngine, 'distant-agent', - udp.domainName + (2,), ('195.218.195.228', 161), - 'distant-agent-auth', retryCount=0 + snmpEngine, 'distant-agent', + udp.domainName + (2,), ('104.236.166.95', 161), + 'distant-agent-auth', retryCount=0 ) # Default SNMP context config.addContext(snmpEngine, '') + class CommandResponder(cmdrsp.CommandResponderBase): - cmdGenMap = { + cmdGenMap = { v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(), v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(), v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(), - v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun() + v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun() } pduTypes = cmdGenMap.keys() # This app will handle these PDUs @@ -110,10 +111,11 @@ ) except error.PySnmpError: self.handleResponsePdu( - stateReference, 'error', None, cbCtx + snmpEngine, stateReference, 'error', None, cbCtx ) # SNMP response relay + # noinspection PyUnusedLocal def handleResponsePdu(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): stateReference, reqPDU = cbCtx @@ -128,9 +130,10 @@ self.releaseStateInformation(stateReference) + CommandResponder(snmpEngine, context.SnmpContext(snmpEngine)) -snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish +snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish # Run I/O dispatcher which would receive queries and send responses try: diff -Nru python-pysnmp4-4.3.2/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py python-pysnmp4-4.4.3/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py --- python-pysnmp4-4.3.2/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py 2015-09-14 05:20:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py 2017-12-22 11:53:40.000000000 +0000 @@ -7,7 +7,7 @@ * with local SNMPv3 user usr-md5-des, MD5 auth and DES privacy protocols * local Agent listening at 127.0.0.1:161 * remote SNMPv1, community public -* remote Agent listening at 195.218.195.228:161 +* remote Agent listening at 104.236.166.95:161 This script can be queried with the following Net-SNMP command: @@ -15,7 +15,7 @@ due to proxy, it is equivalent to -| $ snmpget -v2c -c public 195.218.195.228:161 1.3.6.1.2.1.1.1.0 +| $ snmpget -v2c -c public 104.236.166.95:161 1.3.6.1.2.1.1.1.0 Warning: for production operation you would need to modify this script so that it will re-map possible duplicate request-ID values, coming in @@ -82,20 +82,21 @@ 'noAuthNoPriv', 0) config.addTargetAddr( - snmpEngine, 'distant-agent', - udp.domainName + (2,), ('195.218.195.228', 161), - 'distant-agent-auth', retryCount=0 + snmpEngine, 'distant-agent', + udp.domainName + (2,), ('104.236.166.95', 161), + 'distant-agent-auth', retryCount=0 ) # Default SNMP context config.addContext(snmpEngine, '') + class CommandResponder(cmdrsp.CommandResponderBase): - cmdGenMap = { + cmdGenMap = { v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(), v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(), v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(), - v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun() + v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun() } pduTypes = cmdGenMap.keys() # This app will handle these PDUs @@ -106,17 +107,18 @@ contextEngineId = None # address authoritative SNMP Engine try: self.cmdGenMap[PDU.tagSet].sendPdu( - snmpEngine, 'distant-agent', + snmpEngine, 'distant-agent', contextEngineId, contextName, PDU, self.handleResponsePdu, cbCtx ) except error.PySnmpError: self.handleResponsePdu( - stateReference, 'error', None, cbCtx + snmpEngine, stateReference, 'error', None, cbCtx ) # SNMP response relay + # noinspection PyUnusedLocal def handleResponsePdu(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): stateReference, reqPDU = cbCtx @@ -125,15 +127,14 @@ PDU = v2c.apiPDU.getResponse(reqPDU) PDU.setErrorStatus(PDU, 5) - self.sendPdu( - snmpEngine, stateReference, PDU - ) + self.sendPdu(snmpEngine, stateReference, PDU) self.releaseStateInformation(stateReference) + CommandResponder(snmpEngine, context.SnmpContext(snmpEngine)) -snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish +snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish # Run I/O dispatcher which would receive queries and send responses try: diff -Nru python-pysnmp4-4.3.2/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py python-pysnmp4-4.4.3/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py --- python-pysnmp4-4.3.2/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py 2015-09-14 05:20:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py 2017-12-22 11:53:40.000000000 +0000 @@ -43,7 +43,7 @@ config.addV1System(snmpEngine, 'my-area', 'public') # Allow read MIB access for this user / securityModels at VACM -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,5)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 5)) # Create an SNMP context snmpContext = context.SnmpContext(snmpEngine) @@ -56,15 +56,18 @@ 'SNMPv2-SMI', 'MibScalar', 'MibScalarInstance' ) + class MyStaticMibScalarInstance(MibScalarInstance): + # noinspection PyUnusedLocal,PyUnusedLocal def getValue(self, name, idx): return self.getSyntax().clone( 'Python %s running on a %s platform' % (sys.version, sys.platform) ) + mibBuilder.exportSymbols( - '__MY_MIB', MibScalar((1,3,6,5,1), rfc1902.OctetString()), - MyStaticMibScalarInstance((1,3,6,5,1), (0,), rfc1902.OctetString()) + '__MY_MIB', MibScalar((1, 3, 6, 5, 1), rfc1902.OctetString()), + MyStaticMibScalarInstance((1, 3, 6, 5, 1), (0,), rfc1902.OctetString()) ) # --- end of Managed Object Instance initialization ---- diff -Nru python-pysnmp4-4.3.2/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py python-pysnmp4-4.4.3/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py --- python-pysnmp4-4.3.2/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py 2015-09-14 05:20:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py 2017-12-22 11:53:40.000000000 +0000 @@ -48,7 +48,7 @@ config.addV1System(snmpEngine, 'my-area', 'public') # Allow full MIB access for this user / securityModels at VACM -config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py python-pysnmp4-4.4.3/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py --- python-pysnmp4-4.3.2/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py 2015-09-14 05:20:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py 2017-12-22 11:53:40.000000000 +0000 @@ -44,8 +44,8 @@ config.addV1System(snmpEngine, 'my-write-area', 'private') # Allow full MIB access for this user / securityModels at VACM -config.addVacmUser(snmpEngine, 1, 'my-read-area', 'noAuthNoPriv', (1,3,6,1,2,1)) -config.addVacmUser(snmpEngine, 1, 'my-write-area', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 1, 'my-read-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1)) +config.addVacmUser(snmpEngine, 1, 'my-write-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py python-pysnmp4-4.4.3/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py --- python-pysnmp4-4.3.2/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py 2015-09-14 05:20:27.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py 2017-12-22 11:53:40.000000000 +0000 @@ -60,9 +60,9 @@ ) # Allow full MIB access for each user at VACM -config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) -config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) -config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1)) +config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) +config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) +config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1)) # Get default SNMP context this SNMP engine serves snmpContext = context.SnmpContext(snmpEngine) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py python-pysnmp4-4.4.3/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py --- python-pysnmp4-4.3.2/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py 2015-09-14 05:20:28.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py 2017-12-22 11:53:40.000000000 +0000 @@ -49,17 +49,17 @@ # SecurityName <-> CommunityName mapping config.addV1System(snmpEngine, 'my-area', 'public') + # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): - print('Notification from ContextEngineId "%s", Context "%s"' % ( - contextEngineId.prettyPrint(), - contextName.prettyPrint() - ) - ) + print('Notification from ContextEngineId "%s", Context "%s"' % (contextEngineId.prettyPrint(), + contextName.prettyPrint())) for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) - + + # Register SNMP Application at the SNMP engine ntfrcv.NotificationReceiver(snmpEngine, cbFun) diff -Nru python-pysnmp4-4.3.2/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py python-pysnmp4-4.4.3/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py --- python-pysnmp4-4.3.2/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py 2015-09-14 05:20:28.000000000 +0000 +++ python-pysnmp4-4.4.3/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py 2017-12-22 11:53:40.000000000 +0000 @@ -88,18 +88,19 @@ securityEngineId=rfc1902.OctetString(hexValue='8000000001020304') ) + # -- end of SNMPv3/USM setup # Callback function for receiving notifications +# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal def cbFun(snmpEngine, stateReference, contextEngineId, contextName, varBinds, cbCtx): - print('Notification from ContextEngineId "%s", ContextName "%s"' % ( - contextEngineId.prettyPrint(), contextName.prettyPrint() - ) - ) + print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(), + contextName.prettyPrint())) for name, val in varBinds: print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) - + + # Register SNMP Application at the SNMP engine ntfrcv.NotificationReceiver(snmpEngine, cbFun) diff -Nru python-pysnmp4-4.3.2/.gitignore python-pysnmp4-4.4.3/.gitignore --- python-pysnmp4-4.3.2/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/.gitignore 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,25 @@ +# Python stuff +*.pyc +__pycache__ + +# vim swapfiles +*.sw? + +# python packaging +MANIFEST +dist/ +build/ +*.egg-info/ + +# PyCharm stuff +.idea/ + +# Sphinx template +docs/source/.templates/layout.html + +# Eclipse stuff +.project +.pydevproject + +# Virtual envs +venv* diff -Nru python-pysnmp4-4.3.2/LICENSE.txt python-pysnmp4-4.4.3/LICENSE.txt --- python-pysnmp4-4.3.2/LICENSE.txt 2016-02-13 19:38:13.000000000 +0000 +++ python-pysnmp4-4.4.3/LICENSE.txt 2017-12-22 11:53:40.000000000 +0000 @@ -1,4 +1,4 @@ -Copyright (c) 2005-2016, Ilya Etingof +Copyright (c) 2005-2017, Ilya Etingof All rights reserved. Redistribution and use in source and binary forms, with or without diff -Nru python-pysnmp4-4.3.2/MANIFEST.in python-pysnmp4-4.4.3/MANIFEST.in --- python-pysnmp4-4.3.2/MANIFEST.in 2015-11-13 17:21:55.000000000 +0000 +++ python-pysnmp4-4.4.3/MANIFEST.in 2017-12-22 11:53:40.000000000 +0000 @@ -1,4 +1,4 @@ -include *.txt +include *.txt *.md *.sh recursive-include examples *.py recursive-include docs/source *.rst *.svg *.py recursive-include docs/mibs *.txt diff -Nru python-pysnmp4-4.3.2/PKG-INFO python-pysnmp4-4.4.3/PKG-INFO --- python-pysnmp4-4.3.2/PKG-INFO 2016-02-13 21:14:20.000000000 +0000 +++ python-pysnmp4-4.4.3/PKG-INFO 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -Metadata-Version: 1.1 -Name: pysnmp -Version: 4.3.2 -Summary: SNMP library for Python -Home-page: http://sourceforge.net/projects/pysnmp/ -Author: Ilya Etingof -Author-email: ilya@glas.net -License: BSD -Description: SNMP v1/v2c/v3 engine and apps written in pure-Python. Supports Manager/Agent/Proxy roles, scriptable MIBs, asynchronous operation and multiple transports. -Platform: any -Classifier: Development Status :: 5 - Production/Stable -Classifier: Environment :: Console -Classifier: Intended Audience :: Developers -Classifier: Intended Audience :: Education -Classifier: Intended Audience :: Information Technology -Classifier: Intended Audience :: System Administrators -Classifier: Intended Audience :: Telecommunications Industry -Classifier: License :: OSI Approved :: BSD License -Classifier: Natural Language :: English -Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 3 -Classifier: Topic :: Communications -Classifier: Topic :: Software Development :: Libraries :: Python Modules -Classifier: Topic :: System :: Monitoring -Classifier: Topic :: System :: Networking :: Monitoring -Classifier: Topic :: Software Development :: Libraries :: Python Modules diff -Nru python-pysnmp4-4.3.2/pysnmp/cache.py python-pysnmp4-4.4.3/pysnmp/cache.py --- python-pysnmp4-4.3.2/pysnmp/cache.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/cache.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,16 +1,18 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # Limited-size dictionary-like class to use for caches # -class Cache: + + +class Cache(object): def __init__(self, maxSize=256): self.__maxSize = maxSize self.__size = 0 - self.__chopSize = maxSize//10 + self.__chopSize = maxSize // 10 self.__chopSize = self.__chopSize and self.__chopSize or 1 self.__cache = {} self.__usage = {} @@ -27,12 +29,11 @@ def __setitem__(self, k, v): if self.__size >= self.__maxSize: - keys = list(self.__usage.keys()) - keys.sort(key=lambda x, d=self.__usage: d[x]) - for _k in keys[:self.__chopSize]: + usageKeys = sorted(self.__usage, key=lambda x, d=self.__usage: d[x]) + for _k in usageKeys[:self.__chopSize]: del self.__cache[_k] del self.__usage[_k] - self.__size = self.__size - self.__chopSize + self.__size -= self.__chopSize if k not in self.__cache: self.__size += 1 self.__usage[k] = 0 @@ -41,4 +42,4 @@ def __delitem__(self, k): del self.__cache[k] del self.__usage[k] - self.__size = self.__size - 1 + self.__size -= 1 diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncio/base.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncio/base.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncio/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncio/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # Copyright (C) 2014, Zebra Technologies # Authors: Matt Hooks @@ -33,6 +33,7 @@ from pysnmp.carrier.asyncio.dispatch import AsyncioDispatcher from pysnmp.carrier.base import AbstractTransport + class AbstractAsyncioTransport(AbstractTransport): protoTransportDispatcher = AsyncioDispatcher """Base Asyncio Transport, to be used with AsyncioDispatcher""" diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncio/dgram/base.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncio/dgram/base.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncio/dgram/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncio/dgram/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # Copyright (C) 2014, Zebra Technologies # Authors: Matt Hooks @@ -35,12 +35,12 @@ from pysnmp.carrier.asyncio.base import AbstractAsyncioTransport from pysnmp.carrier import error from pysnmp import debug + try: import asyncio except ImportError: import trollius as asyncio -loop = asyncio.get_event_loop() class DgramAsyncioProtocol(asyncio.DatagramProtocol, AbstractAsyncioTransport): """Base Asyncio datagram Transport, to be used with AsyncioDispatcher""" @@ -48,14 +48,18 @@ addressType = lambda x: x transport = None - def __init__(self, *args, **kwargs): + def __init__(self, sock=None, sockMap=None, loop=None): self._writeQ = [] + self._lport = None + if loop is None: + loop = asyncio.get_event_loop() + self.loop = loop def datagram_received(self, datagram, transportAddress): if self._cbFun is None: raise error.CarrierError('Unable to call cbFun') else: - loop.call_soon(self._cbFun, self, transportAddress, datagram) + self.loop.call_soon(self._cbFun, self, transportAddress, datagram) def connection_made(self, transport): self.transport = transport @@ -76,7 +80,7 @@ def openClientMode(self, iface=None): try: - c = loop.create_datagram_endpoint( + c = self.loop.create_datagram_endpoint( lambda: self, local_addr=iface, family=self.sockFamily ) self._lport = asyncio.async(c) @@ -86,7 +90,7 @@ def openServerMode(self, iface): try: - c = loop.create_datagram_endpoint( + c = self.loop.create_datagram_endpoint( lambda: self, local_addr=iface, family=self.sockFamily ) self._lport = asyncio.async(c) @@ -95,7 +99,8 @@ return self def closeTransport(self): - self._lport.cancel() + if self._lport is not None: + self._lport.cancel() if self.transport is not None: self.transport.close() AbstractAsyncioTransport.closeTransport(self) diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncio/dgram/udp6.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncio/dgram/udp6.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncio/dgram/udp6.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncio/dgram/udp6.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,24 +1,21 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import socket from pysnmp.carrier.base import AbstractTransportAddress from pysnmp.carrier.asyncio.dgram.base import DgramAsyncioProtocol -try: - import asyncio -except ImportError: - import trollius as asyncio -loop = asyncio.get_event_loop() domainName = snmpUDP6Domain = (1, 3, 6, 1, 2, 1, 100, 1, 2) + class Udp6TransportAddress(tuple, AbstractTransportAddress): pass + class Udp6AsyncioTransport(DgramAsyncioProtocol): sockFamily = socket.has_ipv6 and socket.AF_INET6 or None addressType = Udp6TransportAddress @@ -28,9 +25,10 @@ return self.addressType((transportAddress[0].split('%')[0], transportAddress[1], 0, # flowinfo - 0)) # scopeid + 0)) # scopeid else: return self.addressType((transportAddress[0], transportAddress[1], 0, 0)) + Udp6Transport = Udp6AsyncioTransport diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncio/dgram/udp.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncio/dgram/udp.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncio/dgram/udp.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncio/dgram/udp.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # Copyright (C) 2014, Zebra Technologies # Authors: Matt Hooks @@ -33,20 +33,17 @@ import socket from pysnmp.carrier.base import AbstractTransportAddress from pysnmp.carrier.asyncio.dgram.base import DgramAsyncioProtocol -try: - import asyncio -except ImportError: - import trollius as asyncio - -loop = asyncio.get_event_loop() domainName = snmpUDPDomain = (1, 3, 6, 1, 6, 1, 1) + class UdpTransportAddress(tuple, AbstractTransportAddress): pass + class UdpAsyncioTransport(DgramAsyncioProtocol): sockFamily = socket.AF_INET addressType = UdpTransportAddress + UdpTransport = UdpAsyncioTransport diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncio/dispatch.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncio/dispatch.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncio/dispatch.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncio/dispatch.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # Copyright (C) 2014, Zebra Technologies # Authors: Matt Hooks @@ -34,32 +34,34 @@ import traceback from pysnmp.carrier.base import AbstractTransportDispatcher from pysnmp.error import PySnmpError + try: import asyncio except ImportError: import trollius as asyncio -loop = asyncio.get_event_loop() class AsyncioDispatcher(AbstractTransportDispatcher): """AsyncioDispatcher based on asyncio event loop""" + def __init__(self, *args, **kwargs): AbstractTransportDispatcher.__init__(self) self.__transportCount = 0 if 'timeout' in kwargs: self.setTimerResolution(kwargs['timeout']) self.loopingcall = None + self.loop = kwargs.pop('loop', asyncio.get_event_loop()) @asyncio.coroutine def handle_timeout(self): while True: yield asyncio.From(asyncio.sleep(self.getTimerResolution())) - self.handleTimerTick(loop.time()) + self.handleTimerTick(self.loop.time()) def runDispatcher(self, timeout=0.0): - if not loop.is_running(): + if not self.loop.is_running(): try: - loop.run_forever() + self.loop.run_forever() except KeyboardInterrupt: raise except Exception: @@ -70,7 +72,7 @@ self.loopingcall = asyncio.async(self.handle_timeout()) AbstractTransportDispatcher.registerTransport( self, tDomain, transport - ) + ) self.__transportCount += 1 def unregisterTransport(self, tDomain): @@ -84,14 +86,14 @@ self.loopingcall.cancel() self.loopingcall = None + # Trollius or Tulip? if not hasattr(asyncio, "From"): - exec("""\ + exec ("""\ @asyncio.coroutine def handle_timeout(self): while True: yield from asyncio.sleep(self.getTimerResolution()) - self.handleTimerTick(loop.time()) + self.handleTimerTick(self.loop.time()) AsyncioDispatcher.handle_timeout = handle_timeout\ """) - diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/base.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/base.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,33 +1,37 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -import socket, sys +import socket +import sys import asyncore from pysnmp.carrier import error from pysnmp.carrier.base import AbstractTransport from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher from pysnmp import debug + class AbstractSocketTransport(asyncore.dispatcher, AbstractTransport): protoTransportDispatcher = AsyncoreDispatcher sockFamily = sockType = None retryCount = 0 retryInterval = 0 bufferSize = 131070 + + # noinspection PyUnusedLocal def __init__(self, sock=None, sockMap=None): asyncore.dispatcher.__init__(self) if sock is None: if self.sockFamily is None: raise error.CarrierError( 'Address family %s not supported' % self.__class__.__name__ - ) + ) if self.sockType is None: raise error.CarrierError( 'Socket type %s not supported' % self.__class__.__name__ - ) + ) try: sock = socket.socket(self.sockFamily, self.sockType) except socket.error: @@ -40,7 +44,7 @@ sock.setsockopt(socket.SOL_SOCKET, b, self.bufferSize) debug.logger & debug.flagIO and debug.logger('%s: socket %d buffer size increased from %d to %d for buffer %d' % (self.__class__.__name__, sock.fileno(), bsize, self.bufferSize, b)) except Exception: - debug.logger & debug.flagIO and debug.logger('%s: socket buffer size option mangling failure for buffer %d: %s' % (self.__class__.__name__, b, sys.exc_info()[1])) + debug.logger & debug.flagIO and debug.logger('%s: socket buffer size option mangling failure for buffer: %s' % (self.__class__.__name__, sys.exc_info()[1])) # The socket map is managed by the AsyncoreDispatcher on # which this transport is registered. Here we just prepare diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/dgram/base.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/dgram/base.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/dgram/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/dgram/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,10 +1,12 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -import socket, errno, sys +import socket +import errno +import sys from pysnmp.carrier.asyncore.base import AbstractSocketTransport from pysnmp.carrier import sockfix, sockmsg, error from pysnmp import debug @@ -21,17 +23,21 @@ # bad FD may happen upon FD closure on n-1 select() event sockErrors[errno.EBADFD] = True + class DgramSocketTransport(AbstractSocketTransport): sockType = socket.SOCK_DGRAM retryCount = 3 retryInterval = 1 addressType = lambda x: x + def __init__(self, sock=None, sockMap=None): self.__outQueue = [] self._sendto = lambda s, b, a: s.sendto(b, a) + def __recvfrom(s, sz): d, a = s.recvfrom(sz) return d, self.addressType(a) + self._recvfrom = __recvfrom AbstractSocketTransport.__init__(self, sock, sockMap) @@ -40,10 +46,11 @@ try: self.socket.bind(iface) except socket.error: - raise error.CarrierError('bind() for %s failed: %s' % (iface is None and "" or iface, sys.exc_info()[1])) + raise error.CarrierError( + 'bind() for %s failed: %s' % (iface is None and "" or iface, sys.exc_info()[1])) return self - def openServerMode(self, iface=None): + def openServerMode(self, iface): try: self.socket.bind(iface) except socket.error: @@ -61,8 +68,8 @@ return self def enablePktInfo(self, flag=1): - if not hasattr(self.socket, 'sendmsg') or \ - not hasattr(self.socket, 'recvmsg'): + if (not hasattr(self.socket, 'sendmsg') or + not hasattr(self.socket, 'recvmsg')): raise error.CarrierError('sendmsg()/recvmsg() interface is not supported by this OS and/or Python version') try: @@ -100,7 +107,7 @@ def sendMessage(self, outgoingMessage, transportAddress): self.__outQueue.append( (outgoingMessage, self.normalizeAddress(transportAddress)) - ) + ) debug.logger & debug.flagIO and debug.logger('sendMessage: outgoingMessage queued (%d octets) %s' % (len(outgoingMessage), debug.hexdump(outgoingMessage))) def normalizeAddress(self, transportAddress): @@ -114,8 +121,8 @@ # one evil OS does not seem to support getsockname() for DGRAM sockets try: return self.socket.getsockname() - except: - return ('0.0.0.0', 0) + except Exception: + return '0.0.0.0', 0 # asyncore API def handle_connect(self): @@ -145,11 +152,10 @@ def handle_read(self): try: - incomingMessage, transportAddress = self._recvfrom( - self.socket, 65535 - ) + incomingMessage, transportAddress = self._recvfrom(self.socket, 65535) transportAddress = self.normalizeAddress(transportAddress) - debug.logger & debug.flagIO and debug.logger('handle_read: transportAddress %r -> %r incomingMessage (%d octets) %s' % (transportAddress, transportAddress.getLocalAddress(), len(incomingMessage), debug.hexdump(incomingMessage))) + debug.logger & debug.flagIO and debug.logger( + 'handle_read: transportAddress %r -> %r incomingMessage (%d octets) %s' % (transportAddress, transportAddress.getLocalAddress(), len(incomingMessage), debug.hexdump(incomingMessage))) if not incomingMessage: self.handle_close() return @@ -165,4 +171,4 @@ raise error.CarrierError('recvfrom() failed: %s' % (sys.exc_info()[1],)) def handle_close(self): - pass # no datagram connection + pass # no datagram connection diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/dgram/udp6.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/dgram/udp6.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/dgram/udp6.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/dgram/udp6.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.carrier import sockfix from pysnmp.carrier.base import AbstractTransportAddress @@ -11,9 +11,11 @@ domainName = snmpUDP6Domain = (1, 3, 6, 1, 2, 1, 100, 1, 2) + class Udp6TransportAddress(tuple, AbstractTransportAddress): pass + class Udp6SocketTransport(DgramSocketTransport): sockFamily = socket.has_ipv6 and socket.AF_INET6 or None addressType = Udp6TransportAddress @@ -22,16 +24,17 @@ if '%' in transportAddress[0]: # strip zone ID ta = self.addressType((transportAddress[0].split('%')[0], transportAddress[1], - 0, # flowinfo + 0, # flowinfo 0)) # scopeid else: ta = self.addressType((transportAddress[0], transportAddress[1], 0, 0)) - if isinstance(transportAddress, self.addressType) and \ - transportAddress.getLocalAddress(): + if (isinstance(transportAddress, self.addressType) and + transportAddress.getLocalAddress()): return ta.setLocalAddress(transportAddress.getLocalAddress()) else: return ta.setLocalAddress(self.getLocalAddress()) + Udp6Transport = Udp6SocketTransport diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/dgram/udp.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/dgram/udp.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/dgram/udp.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/dgram/udp.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from socket import AF_INET from pysnmp.carrier.base import AbstractTransportAddress @@ -10,11 +10,14 @@ domainName = snmpUDPDomain = (1, 3, 6, 1, 6, 1, 1) + class UdpTransportAddress(tuple, AbstractTransportAddress): pass + class UdpSocketTransport(DgramSocketTransport): sockFamily = AF_INET addressType = UdpTransportAddress + UdpTransport = UdpSocketTransport diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/dgram/unix.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/dgram/unix.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/dgram/unix.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/dgram/unix.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,11 +1,12 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import os import random + try: from socket import AF_UNIX except ImportError: @@ -17,12 +18,15 @@ random.seed() + class UnixTransportAddress(str, AbstractTransportAddress): pass + class UnixSocketTransport(DgramSocketTransport): sockFamily = AF_UNIX addressType = UnixTransportAddress + _iface = '' def openClientMode(self, iface=None): if iface is None: @@ -35,21 +39,22 @@ if os.path.exists(iface): os.remove(iface) DgramSocketTransport.openClientMode(self, iface) - self.__iface = iface + self._iface = iface return self def openServerMode(self, iface): DgramSocketTransport.openServerMode(self, iface) - self.__iface = iface + self._iface = iface return self def closeTransport(self): DgramSocketTransport.closeTransport(self) try: - os.remove(self.__iface) + os.remove(self._iface) except OSError: pass + UnixTransport = UnixSocketTransport # Compatibility stub diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/dispatch.py python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/dispatch.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asyncore/dispatch.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asyncore/dispatch.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from time import time from sys import exc_info @@ -12,9 +12,10 @@ from pysnmp.carrier.base import AbstractTransportDispatcher from pysnmp.error import PySnmpError + class AsyncoreDispatcher(AbstractTransportDispatcher): def __init__(self): - self.__sockMap = {} # use own map for MT safety + self.__sockMap = {} # use own map for MT safety self.timeout = 0.5 AbstractTransportDispatcher.__init__(self) diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asynsock/dgram/udp6.py python-pysnmp4-4.4.3/pysnmp/carrier/asynsock/dgram/udp6.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asynsock/dgram/udp6.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asynsock/dgram/udp6.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,7 +1,7 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.carrier.asyncore.dgram.udp6 import * diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asynsock/dgram/udp.py python-pysnmp4-4.4.3/pysnmp/carrier/asynsock/dgram/udp.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asynsock/dgram/udp.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asynsock/dgram/udp.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,7 +1,7 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.carrier.asyncore.dgram.udp import * diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asynsock/dgram/unix.py python-pysnmp4-4.4.3/pysnmp/carrier/asynsock/dgram/unix.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asynsock/dgram/unix.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asynsock/dgram/unix.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,7 +1,7 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.carrier.asyncore.dgram.unix import * diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/asynsock/dispatch.py python-pysnmp4-4.4.3/pysnmp/carrier/asynsock/dispatch.py --- python-pysnmp4-4.3.2/pysnmp/carrier/asynsock/dispatch.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/asynsock/dispatch.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.carrier.asyncore.dispatch import * diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/base.py python-pysnmp4-4.4.3/pysnmp/carrier/base.py --- python-pysnmp4-4.3.2/pysnmp/carrier/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,12 +1,13 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.carrier import error -class TimerCallable: + +class TimerCallable(object): def __init__(self, cbFun, callInterval): self.__cbFun = cbFun self.__callInterval = callInterval @@ -35,7 +36,8 @@ def __ge__(self, cbFun): return self.__cbFun >= cbFun -class AbstractTransportDispatcher: + +class AbstractTransportDispatcher(object): def __init__(self): self.__transports = {} self.__transportDomainMap = {} @@ -54,7 +56,7 @@ else: raise error.CarrierError( 'Unregistered transport %s' % (incomingTransport,) - ) + ) if self.__routingCbFun: recvId = self.__routingCbFun( @@ -69,7 +71,7 @@ ) else: raise error.CarrierError( - 'No callback for "%r" found - loosing incoming event'%(recvId,) + 'No callback for "%r" found - loosing incoming event' % (recvId,) ) # Dispatcher API @@ -111,7 +113,7 @@ if tDomain in self.__transports: raise error.CarrierError( 'Transport %s already registered' % (tDomain,) - ) + ) transport.registerCbFun(self._cbFun) self.__transports[tDomain] = transport self.__transportDomainMap[transport] = tDomain @@ -120,7 +122,7 @@ if tDomain not in self.__transports: raise error.CarrierError( 'Transport %s not registered' % (tDomain,) - ) + ) self.__transports[tDomain].unregisterCbFun() del self.__transportDomainMap[self.__transports[tDomain]] del self.__transports[tDomain] @@ -130,18 +132,18 @@ return self.__transports[transportDomain] raise error.CarrierError( 'Transport %s not registered' % (transportDomain,) - ) + ) def sendMessage(self, outgoingMessage, transportDomain, transportAddress): if transportDomain in self.__transports: self.__transports[transportDomain].sendMessage( outgoingMessage, transportAddress - ) + ) else: raise error.CarrierError( 'No suitable transport domain for %s' % (transportDomain,) - ) + ) def getTimerResolution(self): return self.__timerResolution @@ -156,7 +158,7 @@ return self.__ticks def handleTimerTick(self, timeNow): - if self.__nextTime == 0: # initial initialization + if self.__nextTime == 0: # initial initialization self.__nextTime = timeNow + self.__timerResolution - self.__timerDelta if self.__nextTime >= timeNow: @@ -180,10 +182,7 @@ del self.__jobs[jobId] def jobsArePending(self): - if self.__jobs: - return 1 - else: - return 0 + return bool(self.__jobs) def runDispatcher(self, timeout=0.0): raise error.CarrierError('Method not implemented') @@ -196,8 +195,10 @@ self.unregisterRecvCbFun() self.unregisterTimerCbFun() -class AbstractTransportAddress: + +class AbstractTransportAddress(object): _localAddress = None + def setLocalAddress(self, s): self._localAddress = s return self @@ -208,10 +209,12 @@ def clone(self, localAddress=None): return self.__class__(self).setLocalAddress(localAddress is None and self.getLocalAddress() or localAddress) -class AbstractTransport: + +class AbstractTransport(object): protoTransportDispatcher = None addressType = AbstractTransportAddress _cbFun = None + @classmethod def isCompatibleWithDispatcher(cls, transportDispatcher): return isinstance(transportDispatcher, cls.protoTransportDispatcher) @@ -220,7 +223,7 @@ if self._cbFun: raise error.CarrierError( 'Callback function %s already registered at %s' % (self._cbFun, self) - ) + ) self._cbFun = cbFun def unregisterCbFun(self): @@ -234,7 +237,7 @@ def openClientMode(self, iface=None): raise error.CarrierError('Method not implemented') - def openServerMode(self, iface=None): + def openServerMode(self, iface): raise error.CarrierError('Method not implemented') def sendMessage(self, outgoingMessage, transportAddress): diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/error.py python-pysnmp4-4.4.3/pysnmp/carrier/error.py --- python-pysnmp4-4.3.2/pysnmp/carrier/error.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/error.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,10 +1,11 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp import error + class CarrierError(error.PySnmpError): pass diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/sockfix.py python-pysnmp4-4.4.3/pysnmp/carrier/sockfix.py --- python-pysnmp4-4.3.2/pysnmp/carrier/sockfix.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/sockfix.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,17 +1,17 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import socket symbols = { - 'IP_PKTINFO': 8, - 'IP_TRANSPARENT': 19, - 'SOL_IPV6': 41, + 'IP_PKTINFO': 8, + 'IP_TRANSPARENT': 19, + 'SOL_IPV6': 41, 'IPV6_RECVPKTINFO': 49, - 'IPV6_PKTINFO': 50 + 'IPV6_PKTINFO': 50 } for symbol in symbols: diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/sockmsg.py python-pysnmp4-4.4.3/pysnmp/carrier/sockmsg.py --- python-pysnmp4-4.3.2/pysnmp/carrier/sockmsg.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/sockmsg.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # The following routines act like sendto()/recvfrom() calls but additionally # support local address retrieval (what can be useful when listening on @@ -16,10 +16,13 @@ # http://carnivore.it/2012/10/12/python3.3_sendmsg_and_recvmsg # import sys + if sys.version_info[:2] < (3, 3): + # noinspection PyUnusedLocal def getRecvFrom(addressType): raise error.CarrierError('sendmsg()/recvmsg() interface is not supported by this OS and/or Python version') + def getSendTo(addressType): raise error.CarrierError('sendmsg()/recvmsg() interface is not supported by this OS and/or Python version') else: @@ -31,9 +34,11 @@ uint32_t = ctypes.c_uint32 in_addr_t = uint32_t + class in_addr(ctypes.Structure): _fields_ = [('s_addr', in_addr_t)] + class in6_addr_U(ctypes.Union): _fields_ = [ ('__u6_addr8', ctypes.c_uint8 * 16), @@ -41,11 +46,13 @@ ('__u6_addr32', ctypes.c_uint32 * 4), ] + class in6_addr(ctypes.Structure): _fields_ = [ ('__in6_u', in6_addr_U), ] + class in_pktinfo(ctypes.Structure): _fields_ = [ ('ipi_ifindex', ctypes.c_int), @@ -53,12 +60,14 @@ ('ipi_addr', in_addr), ] + class in6_pktinfo(ctypes.Structure): _fields_ = [ ('ipi6_addr', in6_addr), ('ipi6_ifindex', ctypes.c_uint), ] + def getRecvFrom(addressType): def recvfrom(s, sz): _to = None @@ -73,8 +82,10 @@ addr = ipaddress.ip_address(memoryview(addr.ipi6_addr).tobytes()) _to = (str(addr), s.getsockname()[1]) return data, addressType(_from).setLocalAddress(_to) + return recvfrom + def getSendTo(addressType): def sendto(s, _data, _to): ancdata = [] @@ -91,4 +102,5 @@ _f.ipi6_addr = in6_addr.from_buffer_copy(addr.packed) ancdata = [(socket.SOL_IPV6, socket.IPV6_PKTINFO, memoryview(_f).tobytes())] return s.sendmsg([_data], ancdata, 0, _to) + return sendto diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/twisted/base.py python-pysnmp4-4.4.3/pysnmp/carrier/twisted/base.py --- python-pysnmp4-4.3.2/pysnmp/carrier/twisted/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/twisted/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # Copyright (C) 2008 Truelite Srl # Author: Filippo Giunchedi @@ -15,7 +15,10 @@ from pysnmp.carrier.twisted.dispatch import TwistedDispatcher from pysnmp.carrier.base import AbstractTransport + class AbstractTwistedTransport(AbstractTransport): protoTransportDispatcher = TwistedDispatcher - def __init__(self): + + def __init__(self, sock=None, sockMap=None): self._writeQ = [] + AbstractTransport.__init__(self) diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/twisted/dgram/base.py python-pysnmp4-4.4.3/pysnmp/carrier/twisted/dgram/base.py --- python-pysnmp4-4.3.2/pysnmp/carrier/twisted/dgram/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/twisted/dgram/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from twisted.internet.protocol import DatagramProtocol @@ -11,6 +11,7 @@ from pysnmp.carrier import error from pysnmp import debug + class DgramTwistedTransport(DatagramProtocol, AbstractTwistedTransport): """Base Twisted datagram Transport, to be used with TwistedDispatcher""" diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/twisted/dgram/udp.py python-pysnmp4-4.4.3/pysnmp/carrier/twisted/dgram/udp.py --- python-pysnmp4-4.3.2/pysnmp/carrier/twisted/dgram/udp.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/twisted/dgram/udp.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from twisted.internet import reactor @@ -12,11 +12,14 @@ domainName = snmpUDPDomain = (1, 3, 6, 1, 6, 1, 1) + class UdpTransportAddress(tuple, AbstractTransportAddress): pass + class UdpTwistedTransport(DgramTwistedTransport): addressType = UdpTransportAddress + _lport = None # AbstractTwistedTransport API @@ -37,8 +40,11 @@ return self def closeTransport(self): - d = self._lport.stopListening() - d and d.addCallback(lambda x: None) - DgramTwistedTransport.closeTransport(self) + if self._lport is not None: + d = self._lport.stopListening() + if d: + d.addCallback(lambda x: None) + DgramTwistedTransport.closeTransport(self) + UdpTransport = UdpTwistedTransport diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/twisted/dgram/unix.py python-pysnmp4-4.4.3/pysnmp/carrier/twisted/dgram/unix.py --- python-pysnmp4-4.3.2/pysnmp/carrier/twisted/dgram/unix.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/twisted/dgram/unix.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from twisted.internet import reactor @@ -17,6 +17,7 @@ class UnixTwistedTransport(DgramTwistedTransport): addressType = UnixTransportAddress + _lport = None # AbstractTwistedTransport API @@ -27,7 +28,7 @@ raise error.CarrierError(sys.exc_info()[1]) return self - def openServerMode(self, iface=None): + def openServerMode(self, iface): try: self._lport = reactor.listenUNIXDatagram(iface, self) except Exception: @@ -36,8 +37,10 @@ return self def closeTransport(self): - d = self._lport.stopListening() - d and d.addCallback(lambda x: None) + if self._lport is not None: + d = self._lport.stopListening() + if d: + d.addCallback(lambda x: None) DgramTwistedTransport.closeTransport(self) UnixTransport = UnixTwistedTransport diff -Nru python-pysnmp4-4.3.2/pysnmp/carrier/twisted/dispatch.py python-pysnmp4-4.4.3/pysnmp/carrier/twisted/dispatch.py --- python-pysnmp4-4.3.2/pysnmp/carrier/twisted/dispatch.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/carrier/twisted/dispatch.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # Copyright (C) 2008 Truelite Srl # Author: Filippo Giunchedi @@ -17,8 +17,10 @@ from pysnmp.carrier.base import AbstractTransportDispatcher from pysnmp.error import PySnmpError + class TwistedDispatcher(AbstractTransportDispatcher): """TransportDispatcher based on twisted.internet.reactor""" + def __init__(self, *args, **kwargs): AbstractTransportDispatcher.__init__(self) self.__transportCount = 0 diff -Nru python-pysnmp4-4.3.2/pysnmp/debug.py python-pysnmp4-4.4.3/pysnmp/debug.py --- python-pysnmp4-4.3.2/pysnmp/debug.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/debug.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import logging from pyasn1.compat.octets import octs2ints @@ -34,7 +34,8 @@ 'app': flagApp, 'all': flagAll} -class Printer: + +class Printer(object): def __init__(self, logger=None, handler=None, formatter=None): if logger is None: logger = logging.getLogger('pysnmp') @@ -54,6 +55,7 @@ def __str__(self): return '' + if hasattr(logging, 'NullHandler'): NullHandler = logging.NullHandler else: @@ -62,8 +64,10 @@ def emit(self, record): pass -class Debug: + +class Debug(object): defaultPrinter = None + def __init__(self, *flags, **options): self._flags = flagNone if options.get('printer') is not None: @@ -106,13 +110,17 @@ def __rand__(self, flag): return flag & self._flags + # This will yield false from bitwise and with a flag, and save # on unnecessary calls logger = 0 + def setLogger(l): global logger logger = l + def hexdump(octets): - return ' '.join(['%s%.2X' % (n%16 == 0 and ('\n%.5d: ' % n) or '', x) for n, x in zip(range(len(octets)), octs2ints(octets))]) + return ' '.join( + ['%s%.2X' % (n % 16 == 0 and ('\n%.5d: ' % n) or '', x) for n, x in zip(range(len(octets)), octs2ints(octets))]) diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/config.py python-pysnmp4-4.4.3/pysnmp/entity/config.py --- python-pysnmp4-4.3.2/pysnmp/entity/config.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/config.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,14 +1,15 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.compat.octets import null from pysnmp.carrier.asyncore.dgram import udp, udp6, unix from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha, noauth from pysnmp.proto.secmod.rfc3414.priv import des, nopriv from pysnmp.proto.secmod.rfc3826.priv import aes +from pysnmp.proto.secmod.rfc7860.auth import hmacsha2 from pysnmp.proto.secmod.eso.priv import des3, aes192, aes256 from pysnmp.proto import rfc1905 from pysnmp import error @@ -23,36 +24,51 @@ # Auth protocol usmHMACMD5AuthProtocol = hmacmd5.HmacMd5.serviceID usmHMACSHAAuthProtocol = hmacsha.HmacSha.serviceID +usmHMAC128SHA224AuthProtocol = hmacsha2.HmacSha2.sha224ServiceID +usmHMAC192SHA256AuthProtocol = hmacsha2.HmacSha2.sha256ServiceID +usmHMAC256SHA384AuthProtocol = hmacsha2.HmacSha2.sha384ServiceID +usmHMAC384SHA512AuthProtocol = hmacsha2.HmacSha2.sha512ServiceID usmNoAuthProtocol = noauth.NoAuth.serviceID # Privacy protocol usmDESPrivProtocol = des.Des.serviceID usm3DESEDEPrivProtocol = des3.Des3.serviceID usmAesCfb128Protocol = aes.Aes.serviceID -usmAesCfb192Protocol = aes192.Aes192.serviceID -usmAesCfb256Protocol = aes256.Aes256.serviceID +usmAesBlumenthalCfb192Protocol = aes192.AesBlumenthal192.serviceID # semi-standard but not widely used +usmAesBlumenthalCfb256Protocol = aes256.AesBlumenthal256.serviceID # semi-standard but not widely used +usmAesCfb192Protocol = aes192.Aes192.serviceID # non-standard but used by many vendors +usmAesCfb256Protocol = aes256.Aes256.serviceID # non-standard but used by many vendors usmNoPrivProtocol = nopriv.NoPriv.serviceID # Auth services authServices = {hmacmd5.HmacMd5.serviceID: hmacmd5.HmacMd5(), hmacsha.HmacSha.serviceID: hmacsha.HmacSha(), + hmacsha2.HmacSha2.sha224ServiceID: hmacsha2.HmacSha2(hmacsha2.HmacSha2.sha224ServiceID), + hmacsha2.HmacSha2.sha256ServiceID: hmacsha2.HmacSha2(hmacsha2.HmacSha2.sha256ServiceID), + hmacsha2.HmacSha2.sha384ServiceID: hmacsha2.HmacSha2(hmacsha2.HmacSha2.sha384ServiceID), + hmacsha2.HmacSha2.sha512ServiceID: hmacsha2.HmacSha2(hmacsha2.HmacSha2.sha512ServiceID), noauth.NoAuth.serviceID: noauth.NoAuth()} # Privacy services privServices = {des.Des.serviceID: des.Des(), des3.Des3.serviceID: des3.Des3(), aes.Aes.serviceID: aes.Aes(), - aes192.Aes192.serviceID: aes192.Aes192(), - aes256.Aes256.serviceID: aes256.Aes256(), + aes192.AesBlumenthal192.serviceID: aes192.AesBlumenthal192(), + aes256.AesBlumenthal256.serviceID: aes256.AesBlumenthal256(), + aes192.Aes192.serviceID: aes192.Aes192(), # non-standard + aes256.Aes256.serviceID: aes256.Aes256(), # non-standard nopriv.NoPriv.serviceID: nopriv.NoPriv()} + def __cookV1SystemInfo(snmpEngine, communityIndex): - snmpEngineID, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder - snmpCommunityEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-COMMUNITY-MIB', 'snmpCommunityEntry') + snmpEngineID, = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + snmpCommunityEntry, = mibBuilder.importSymbols('SNMP-COMMUNITY-MIB', 'snmpCommunityEntry') tblIdx = snmpCommunityEntry.getInstIdFromIndices(communityIndex) return snmpCommunityEntry, tblIdx, snmpEngineID + def addV1System(snmpEngine, communityIndex, communityName, contextEngineId=None, contextName=None, transportTag=None, securityName=None): @@ -81,6 +97,7 @@ (snmpCommunityEntry.name + (8,) + tblIdx, 'createAndGo')) ) + def delV1System(snmpEngine, communityIndex): (snmpCommunityEntry, tblIdx, snmpEngineID) = __cookV1SystemInfo(snmpEngine, communityIndex) @@ -88,21 +105,26 @@ ((snmpCommunityEntry.name + (8,) + tblIdx, 'destroy'),) ) + def __cookV3UserInfo(snmpEngine, securityName, securityEngineId): - snmpEngineID, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + + snmpEngineID, = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + if securityEngineId is None: snmpEngineID = snmpEngineID.syntax else: snmpEngineID = snmpEngineID.syntax.clone(securityEngineId) - usmUserEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-USER-BASED-SM-MIB', 'usmUserEntry') + usmUserEntry, = mibBuilder.importSymbols('SNMP-USER-BASED-SM-MIB', 'usmUserEntry') tblIdx1 = usmUserEntry.getInstIdFromIndices(snmpEngineID, securityName) - pysnmpUsmSecretEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('PYSNMP-USM-MIB', 'pysnmpUsmSecretEntry') + pysnmpUsmSecretEntry, = mibBuilder.importSymbols('PYSNMP-USM-MIB', 'pysnmpUsmSecretEntry') tblIdx2 = pysnmpUsmSecretEntry.getInstIdFromIndices(securityName) return snmpEngineID, usmUserEntry, tblIdx1, pysnmpUsmSecretEntry, tblIdx2 + def addV3User(snmpEngine, userName, authProtocol=usmNoAuthProtocol, authKey=None, privProtocol=usmNoPrivProtocol, privKey=None, @@ -110,18 +132,20 @@ securityName=None, # deprecated parameters follow contextEngineId=None): + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + if securityName is None: securityName = userName if securityEngineId is None: # backward compatibility securityEngineId = contextEngineId - (snmpEngineID, usmUserEntry, tblIdx1, pysnmpUsmSecretEntry, - tblIdx2) = __cookV3UserInfo(snmpEngine, userName, securityEngineId) + (snmpEngineID, usmUserEntry, tblIdx1, + pysnmpUsmSecretEntry, tblIdx2) = __cookV3UserInfo(snmpEngine, userName, securityEngineId) # Load augmenting table before creating new row in base one - pysnmpUsmKeyEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('PYSNMP-USM-MIB', 'pysnmpUsmKeyEntry') + pysnmpUsmKeyEntry, = mibBuilder.importSymbols('PYSNMP-USM-MIB', 'pysnmpUsmKeyEntry') # Load clone-from (may not be needed) - zeroDotZero, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMPv2-SMI', 'zeroDotZero') + zeroDotZero, = mibBuilder.importSymbols('SNMPv2-SMI', 'zeroDotZero') snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((usmUserEntry.name + (13,) + tblIdx1, 'destroy'),) @@ -176,6 +200,7 @@ (pysnmpUsmSecretEntry.name + (4,) + tblIdx2, 'createAndGo')) ) + def delV3User(snmpEngine, userName, securityEngineId=None, @@ -196,7 +221,7 @@ varBinds = initialVarBinds = ( (usmUserEntry.name + (1,), None), # usmUserEngineID (usmUserEntry.name + (2,), None), # usmUserName - (usmUserEntry.name + (4,), None) # usmUserCloneFrom + (usmUserEntry.name + (4,), None) # usmUserCloneFrom ) while varBinds: varBinds = snmpEngine.msgAndPduDsp.mibInstrumController.readNextVars( @@ -210,11 +235,15 @@ delV3User(snmpEngine, varBinds[1][1], varBinds[0][1]) varBinds = initialVarBinds + def __cookTargetParamsInfo(snmpEngine, name): - snmpTargetParamsEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsEntry') + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + + snmpTargetParamsEntry, = mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsEntry') tblIdx = snmpTargetParamsEntry.getInstIdFromIndices(name) return snmpTargetParamsEntry, tblIdx + # mpModel: 0 == SNMPv1, 1 == SNMPv2c, 3 == SNMPv3 def addTargetParams(snmpEngine, name, securityName, securityLevel, mpModel=3): if mpModel == 0: @@ -240,32 +269,39 @@ (snmpTargetParamsEntry.name + (7,) + tblIdx, 'createAndGo')) ) + def delTargetParams(snmpEngine, name): snmpTargetParamsEntry, tblIdx = __cookTargetParamsInfo(snmpEngine, name) snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((snmpTargetParamsEntry.name + (7,) + tblIdx, 'destroy'),) ) + def __cookTargetAddrInfo(snmpEngine, addrName): - snmpTargetAddrEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetAddrEntry') - snmpSourceAddrEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('PYSNMP-SOURCE-MIB', 'snmpSourceAddrEntry') + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + + snmpTargetAddrEntry, = mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetAddrEntry') + snmpSourceAddrEntry, = mibBuilder.importSymbols('PYSNMP-SOURCE-MIB', 'snmpSourceAddrEntry') tblIdx = snmpTargetAddrEntry.getInstIdFromIndices(addrName) return snmpTargetAddrEntry, snmpSourceAddrEntry, tblIdx + def addTargetAddr(snmpEngine, addrName, transportDomain, transportAddress, params, timeout=None, retryCount=None, tagList=null, sourceAddress=None): + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + (snmpTargetAddrEntry, snmpSourceAddrEntry, tblIdx) = __cookTargetAddrInfo(snmpEngine, addrName) if transportDomain[:len(snmpUDPDomain)] == snmpUDPDomain: - SnmpUDPAddress, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMPv2-TM', 'SnmpUDPAddress') + SnmpUDPAddress, = mibBuilder.importSymbols('SNMPv2-TM', 'SnmpUDPAddress') transportAddress = SnmpUDPAddress(transportAddress) if sourceAddress is None: sourceAddress = ('0.0.0.0', 0) sourceAddress = SnmpUDPAddress(sourceAddress) elif transportDomain[:len(snmpUDP6Domain)] == snmpUDP6Domain: - TransportAddressIPv6, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('TRANSPORT-ADDRESS-MIB', 'TransportAddressIPv6') + TransportAddressIPv6, = mibBuilder.importSymbols('TRANSPORT-ADDRESS-MIB', 'TransportAddressIPv6') transportAddress = TransportAddressIPv6(transportAddress) if sourceAddress is None: sourceAddress = ('::', 0) @@ -286,6 +322,7 @@ (snmpTargetAddrEntry.name + (9,) + tblIdx, 'createAndGo')) ) + def delTargetAddr(snmpEngine, addrName): (snmpTargetAddrEntry, snmpSourceAddrEntry, tblIdx) = __cookTargetAddrInfo(snmpEngine, addrName) @@ -293,10 +330,12 @@ ((snmpTargetAddrEntry.name + (9,) + tblIdx, 'destroy'),) ) + def addTransport(snmpEngine, transportDomain, transport): if snmpEngine.transportDispatcher: if not transport.isCompatibleWithDispatcher(snmpEngine.transportDispatcher): - raise error.PySnmpError('Transport %r is not compatible with dispatcher %r' % (transport, snmpEngine.transportDispatcher)) + raise error.PySnmpError( + 'Transport %r is not compatible with dispatcher %r' % (transport, snmpEngine.transportDispatcher)) else: snmpEngine.registerTransportDispatcher( transport.protoTransportDispatcher() @@ -304,16 +343,16 @@ # here we note that we have created transportDispatcher automatically snmpEngine.setUserContext(automaticTransportDispatcher=0) - snmpEngine.transportDispatcher.registerTransport(transportDomain, - transport) + snmpEngine.transportDispatcher.registerTransport(transportDomain, transport) automaticTransportDispatcher = snmpEngine.getUserContext( 'automaticTransportDispatcher' ) if automaticTransportDispatcher is not None: snmpEngine.setUserContext( - automaticTransportDispatcher=automaticTransportDispatcher+1 + automaticTransportDispatcher=automaticTransportDispatcher + 1 ) + def getTransport(snmpEngine, transportDomain): if not snmpEngine.transportDispatcher: return @@ -322,6 +361,7 @@ except error.PySnmpError: return + def delTransport(snmpEngine, transportDomain): if not snmpEngine.transportDispatcher: return @@ -342,28 +382,33 @@ snmpEngine.delUserContext(automaticTransportDispatcher) return transport + addSocketTransport = addTransport delSocketTransport = delTransport + # VACM shortcuts def addContext(snmpEngine, contextName): - vacmContextEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( - 'SNMP-VIEW-BASED-ACM-MIB', 'vacmContextEntry' - ) + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + + vacmContextEntry, = mibBuilder.importSymbols('SNMP-VIEW-BASED-ACM-MIB', 'vacmContextEntry') tblIdx = vacmContextEntry.getInstIdFromIndices(contextName) snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((vacmContextEntry.name + (1,) + tblIdx, contextName),) ) + def __cookVacmGroupInfo(snmpEngine, securityModel, securityName): - vacmSecurityToGroupEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( - 'SNMP-VIEW-BASED-ACM-MIB', 'vacmSecurityToGroupEntry' - ) + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + + vacmSecurityToGroupEntry, = mibBuilder.importSymbols('SNMP-VIEW-BASED-ACM-MIB', + 'vacmSecurityToGroupEntry') tblIdx = vacmSecurityToGroupEntry.getInstIdFromIndices(securityModel, securityName) return vacmSecurityToGroupEntry, tblIdx + def addVacmGroup(snmpEngine, groupName, securityModel, securityName): (vacmSecurityToGroupEntry, tblIdx) = __cookVacmGroupInfo(snmpEngine, securityModel, securityName) @@ -377,6 +422,7 @@ (vacmSecurityToGroupEntry.name + (5,) + tblIdx, 'createAndGo')) ) + def delVacmGroup(snmpEngine, securityModel, securityName): vacmSecurityToGroupEntry, tblIdx = __cookVacmGroupInfo( snmpEngine, securityModel, securityName @@ -385,20 +431,24 @@ ((vacmSecurityToGroupEntry.name + (5,) + tblIdx, 'destroy'),) ) + def __cookVacmAccessInfo(snmpEngine, groupName, contextName, securityModel, securityLevel): - vacmAccessEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-VIEW-BASED-ACM-MIB', 'vacmAccessEntry') + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + + vacmAccessEntry, = mibBuilder.importSymbols('SNMP-VIEW-BASED-ACM-MIB', 'vacmAccessEntry') tblIdx = vacmAccessEntry.getInstIdFromIndices(groupName, contextName, securityModel, securityLevel) return vacmAccessEntry, tblIdx + def addVacmAccess(snmpEngine, groupName, contextName, securityModel, securityLevel, prefix, readView, writeView, notifyView): vacmAccessEntry, tblIdx = __cookVacmAccessInfo(snmpEngine, groupName, contextName, securityModel, securityLevel) - addContext(snmpEngine, contextName) # this is leaky + addContext(snmpEngine, contextName) # this is leaky snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((vacmAccessEntry.name + (9,) + tblIdx, 'destroy'),) @@ -414,6 +464,7 @@ (vacmAccessEntry.name + (9,) + tblIdx, 'createAndGo')) ) + def delVacmAccess(snmpEngine, groupName, contextName, securityModel, securityLevel): vacmAccessEntry, tblIdx = __cookVacmAccessInfo(snmpEngine, groupName, @@ -423,13 +474,17 @@ ((vacmAccessEntry.name + (9,) + tblIdx, 'destroy'),) ) + def __cookVacmViewInfo(snmpEngine, viewName, subTree): - vacmViewTreeFamilyEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + + vacmViewTreeFamilyEntry, = mibBuilder.importSymbols( 'SNMP-VIEW-BASED-ACM-MIB', 'vacmViewTreeFamilyEntry' ) tblIdx = vacmViewTreeFamilyEntry.getInstIdFromIndices(viewName, subTree) return vacmViewTreeFamilyEntry, tblIdx + def addVacmView(snmpEngine, viewName, viewType, subTree, mask): vacmViewTreeFamilyEntry, tblIdx = __cookVacmViewInfo(snmpEngine, viewName, subTree) @@ -444,6 +499,7 @@ (vacmViewTreeFamilyEntry.name + (6,) + tblIdx, 'createAndGo')) ) + def delVacmView(snmpEngine, viewName, subTree): vacmViewTreeFamilyEntry, tblIdx = __cookVacmViewInfo(snmpEngine, viewName, subTree) @@ -451,15 +507,19 @@ ((vacmViewTreeFamilyEntry.name + (6,) + tblIdx, 'destroy'),) ) + # VACM simplicity wrappers def __cookVacmUserInfo(snmpEngine, securityModel, securityName, securityLevel): + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + groupName = 'v-%s-%d' % (hash(securityName), securityModel) - SnmpSecurityLevel, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpSecurityLevel') + SnmpSecurityLevel, = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpSecurityLevel') securityLevel = SnmpSecurityLevel(securityLevel) return (groupName, securityLevel, 'r' + groupName, 'w' + groupName, 'n' + groupName) + def addVacmUser(snmpEngine, securityModel, securityName, securityLevel, readSubTree=(), writeSubTree=(), notifySubTree=(), contextName=null): @@ -476,6 +536,7 @@ if notifySubTree: addVacmView(snmpEngine, notifyView, "included", notifySubTree, null) + def delVacmUser(snmpEngine, securityModel, securityName, securityLevel, readSubTree=(), writeSubTree=(), notifySubTree=()): (groupName, securityLevel, readView, writeView, @@ -496,48 +557,59 @@ snmpEngine, notifyView, notifySubTree ) + # Obsolete shortcuts for add/delVacmUser() wrappers def addRoUser(snmpEngine, securityModel, securityName, securityLevel, subTree): addVacmUser(snmpEngine, securityModel, securityName, securityLevel, subTree) + def delRoUser(snmpEngine, securityModel, securityName, securityLevel, subTree): delVacmUser(snmpEngine, securityModel, securityName, securityLevel, subTree) + def addRwUser(snmpEngine, securityModel, securityName, securityLevel, subTree): addVacmUser(snmpEngine, securityModel, securityName, securityLevel, subTree, subTree) + def delRwUser(snmpEngine, securityModel, securityName, securityLevel, subTree): delVacmUser(snmpEngine, securityModel, securityName, securityLevel, subTree, subTree) + def addTrapUser(snmpEngine, securityModel, securityName, securityLevel, subTree): addVacmUser(snmpEngine, securityModel, securityName, securityLevel, (), (), subTree) + def delTrapUser(snmpEngine, securityModel, securityName, securityLevel, subTree): delVacmUser(snmpEngine, securityModel, securityName, securityLevel, (), (), subTree) + # Notification target setup def __cookNotificationTargetInfo(snmpEngine, notificationName, paramsName, filterSubtree=None): - snmpNotifyEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-NOTIFICATION-MIB', 'snmpNotifyEntry') + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + + snmpNotifyEntry, = mibBuilder.importSymbols('SNMP-NOTIFICATION-MIB', 'snmpNotifyEntry') tblIdx1 = snmpNotifyEntry.getInstIdFromIndices(notificationName) - snmpNotifyFilterProfileEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-NOTIFICATION-MIB', 'snmpNotifyFilterProfileEntry') + snmpNotifyFilterProfileEntry, = mibBuilder.importSymbols('SNMP-NOTIFICATION-MIB', + 'snmpNotifyFilterProfileEntry') tblIdx2 = snmpNotifyFilterProfileEntry.getInstIdFromIndices(paramsName) profileName = '%s-filter' % hash(notificationName) if filterSubtree: - snmpNotifyFilterEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-NOTIFICATION-MIB', 'snmpNotifyFilterEntry') + snmpNotifyFilterEntry, = mibBuilder.importSymbols('SNMP-NOTIFICATION-MIB', + 'snmpNotifyFilterEntry') tblIdx3 = snmpNotifyFilterEntry.getInstIdFromIndices(profileName, filterSubtree) else: @@ -547,6 +619,7 @@ snmpNotifyFilterProfileEntry, tblIdx2, profileName, snmpNotifyFilterEntry, tblIdx3) + def addNotificationTarget(snmpEngine, notificationName, paramsName, transportTag, notifyType=None, filterSubtree=None, filterMask=None, filterType=None): @@ -585,6 +658,7 @@ (snmpNotifyFilterEntry.name + (5,) + tblIdx3, 'createAndGo')) ) + def delNotificationTarget(snmpEngine, notificationName, paramsName, filterSubtree=None): (snmpNotifyEntry, tblIdx1, snmpNotifyFilterProfileEntry, @@ -607,6 +681,7 @@ ((snmpNotifyFilterEntry.name + (5,) + tblIdx3, 'destroy'),) ) + # rfc3415: A.1 def setInitialVacmParameters(snmpEngine): # rfc3415: A.1.1 --> initial-semi-security-configuration diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/engine.py python-pysnmp4-4.4.3/pysnmp/entity/engine.py --- python-pysnmp4-4.3.2/pysnmp/entity/engine.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/engine.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,18 +1,18 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import os +import shutil import sys import tempfile +from pyasn1.compat.octets import str2octs from pysnmp.proto.rfc3412 import MsgAndPduDispatcher -from pysnmp.proto.mpmod.rfc2576 import SnmpV1MessageProcessingModel, \ - SnmpV2cMessageProcessingModel +from pysnmp.proto.mpmod.rfc2576 import SnmpV1MessageProcessingModel, SnmpV2cMessageProcessingModel from pysnmp.proto.mpmod.rfc3412 import SnmpV3MessageProcessingModel -from pysnmp.proto.secmod.rfc2576 import SnmpV1SecurityModel, \ - SnmpV2cSecurityModel +from pysnmp.proto.secmod.rfc2576 import SnmpV1SecurityModel, SnmpV2cSecurityModel from pysnmp.proto.secmod.rfc3414 import SnmpUSMSecurityModel from pysnmp.proto.acmod import rfc3415, void from pysnmp.entity import observer @@ -21,7 +21,8 @@ __all__ = ['SnmpEngine'] -class SnmpEngine: + +class SnmpEngine(object): """Creates SNMP engine object. SNMP engine object is central in SNMP v3 architecture. It is an umbrella @@ -51,6 +52,7 @@ >>> """ + def __init__(self, snmpEngineID=None, maxMessageSize=65507, msgAndPduDsp=None): self.cache = {} @@ -63,11 +65,11 @@ self.msgAndPduDsp = msgAndPduDsp self.messageProcessingSubsystems = { SnmpV1MessageProcessingModel.messageProcessingModelID: - SnmpV1MessageProcessingModel(), + SnmpV1MessageProcessingModel(), SnmpV2cMessageProcessingModel.messageProcessingModelID: - SnmpV2cMessageProcessingModel(), + SnmpV2cMessageProcessingModel(), SnmpV3MessageProcessingModel.messageProcessingModelID: - SnmpV3MessageProcessingModel() + SnmpV3MessageProcessingModel() } self.securityModels = { SnmpV1SecurityModel.securityModelID: SnmpV1SecurityModel(), @@ -85,11 +87,14 @@ raise error.PySnmpError( 'MIB instrumentation does not yet exist' ) - snmpEngineMaxMessageSize, = self.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') + snmpEngineMaxMessageSize, = self.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + '__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') snmpEngineMaxMessageSize.syntax = snmpEngineMaxMessageSize.syntax.clone(maxMessageSize) - snmpEngineBoots, = self.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineBoots') + snmpEngineBoots, = self.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', + 'snmpEngineBoots') snmpEngineBoots.syntax += 1 - origSnmpEngineID, = self.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + origSnmpEngineID, = self.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', + 'snmpEngineID') if snmpEngineID is None: self.snmpEngineID = origSnmpEngineID.syntax @@ -97,7 +102,8 @@ origSnmpEngineID.syntax = origSnmpEngineID.syntax.clone(snmpEngineID) self.snmpEngineID = origSnmpEngineID.syntax - debug.logger & debug.flagApp and debug.logger('SnmpEngine: using custom SNMP Engine ID: %s' % self.snmpEngineID.prettyPrint()) + debug.logger & debug.flagApp and debug.logger( + 'SnmpEngine: using custom SNMP Engine ID: %s' % self.snmpEngineID.prettyPrint()) # Attempt to make some of snmp Engine settings persistent. # This should probably be generalized as a non-volatile MIB store. @@ -115,27 +121,28 @@ f = os.path.join(persistentPath, 'boots') try: snmpEngineBoots.syntax = snmpEngineBoots.syntax.clone(open(f).read()) - except: + except Exception: pass try: snmpEngineBoots.syntax += 1 - except: + except Exception: snmpEngineBoots.syntax = snmpEngineBoots.syntax.clone(1) try: fd, fn = tempfile.mkstemp(dir=persistentPath) - os.write(fd, snmpEngineBoots.syntax.prettyPrint()) + os.write(fd, str2octs(snmpEngineBoots.syntax.prettyPrint())) os.close(fd) - os.rename(fn, f) - except: - debug.logger & debug.flagApp and debug.logger('SnmpEngine: could not stored SNMP Engine Boots: %s' % sys.exc_info()[1]) + shutil.move(fn, f) + except Exception: + debug.logger & debug.flagApp and debug.logger( + 'SnmpEngine: could not stored SNMP Engine Boots: %s' % sys.exc_info()[1]) else: - debug.logger & debug.flagApp and debug.logger('SnmpEngine: stored SNMP Engine Boots: %s' % snmpEngineBoots.syntax.prettyPrint()) + debug.logger & debug.flagApp and debug.logger( + 'SnmpEngine: stored SNMP Engine Boots: %s' % snmpEngineBoots.syntax.prettyPrint()) def __repr__(self): - return '%s(snmpEngineID=%r)' % \ - (self.__class__.__name__, self.snmpEngineID) + return '%s(snmpEngineID=%r)' % (self.__class__.__name__, self.snmpEngineID) # Transport dispatcher bindings @@ -193,4 +200,3 @@ del self.cache['__%s' % arg] except KeyError: pass - diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/observer.py python-pysnmp4-4.4.3/pysnmp/entity/observer.py --- python-pysnmp4-4.3.2/pysnmp/entity/observer.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/observer.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,19 +1,20 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp import error -class MetaObserver: + +class MetaObserver(object): """This is a simple facility for exposing internal SNMP Engine working details to pysnmp applications. These details are basically local scope variables at a fixed point of execution. Two modes of operations are offered: - 1. App can request an execution point context by execution point ID. - 2. App can register its callback function (and context) to be invoked + 1. Consumer: app can request an execution point context by execution point ID. + 2. Provider: app can register its callback function (and context) to be invoked once execution reaches specified point. All local scope variables will be passed to the callback as in #1. @@ -21,6 +22,7 @@ to exist to functions that are at the same or deeper level of invocation relative to execution point specified. """ + def __init__(self): self.__observers = {} self.__contexts = {} @@ -32,7 +34,7 @@ else: self.__contexts[cbFun] = kwargs.get('cbCtx') for execpoint in execpoints: - if not execpoint in self.__observers: + if execpoint not in self.__observers: self.__observers[execpoint] = [] self.__observers[execpoint].append(cbFun) diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/cmdgen.py python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/cmdgen.py --- python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/cmdgen.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/cmdgen.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from pysnmp.entity.rfc3413 import config @@ -17,16 +17,17 @@ __null = univ.Null('') + def getNextVarBinds(varBinds, origVarBinds=None): errorIndication = None idx = nonNulls = len(varBinds) rspVarBinds = [] while idx: - idx = idx - 1 + idx -= 1 if varBinds[idx][1].tagSet in (rfc1905.NoSuchObject.tagSet, rfc1905.NoSuchInstance.tagSet, rfc1905.EndOfMibView.tagSet): - nonNulls = nonNulls - 1 + nonNulls -= 1 elif origVarBinds is not None: if v2c.ObjectIdentifier(origVarBinds[idx][0]).asTuple() >= varBinds[idx][0].asTuple(): errorIndication = errind.oidNotIncreasing @@ -38,9 +39,12 @@ return errorIndication, rspVarBinds -class CommandGenerator: + +class CommandGenerator(object): _null = univ.Null('') - def __init__(self): + + def __init__(self, **options): + self.__options = options self.__pendingReqs = {} def processResponsePdu(self, snmpEngine, messageProcessingModel, @@ -58,31 +62,44 @@ origSecurityName, origSecurityLevel, origContextEngineId, origContextName, origPduVersion, origPdu, origTimeout, origRetryCount, - origRetries) = self.__pendingReqs.pop(sendPduHandle) + origRetries, origDiscoveryRetries) = self.__pendingReqs.pop(sendPduHandle) snmpEngine.transportDispatcher.jobFinished(id(self)) # 3.1.3 if statusInformation: - debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendPduHandle %s, statusInformation %s' % (sendPduHandle, statusInformation)) + debug.logger & debug.flagApp and debug.logger( + 'processResponsePdu: sendPduHandle %s, statusInformation %s' % (sendPduHandle, statusInformation)) + errorIndication = statusInformation['errorIndication'] - # SNMP engine discovery will take extra retries, allow that - if errorIndication in (errind.notInTimeWindow, - errind.unknownEngineID) and \ - origRetries == origRetryCount + 2 or \ - errorIndication not in (errind.notInTimeWindow, - errind.unknownEngineID) and \ - origRetries == origRetryCount: - debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendPduHandle %s, retry count %d exceeded' % (sendPduHandle, origRetries)) - cbFun(snmpEngine, origSendRequestHandle, - statusInformation['errorIndication'], None, cbCtx) + + if errorIndication in (errind.notInTimeWindow, errind.unknownEngineID): + origDiscoveryRetries += 1 + origRetries = 0 + else: + origDiscoveryRetries = 0 + origRetries += 1 + + if origRetries > origRetryCount or origDiscoveryRetries > self.__options.get('discoveryRetries', 4): + debug.logger & debug.flagApp and debug.logger( + 'processResponsePdu: sendPduHandle %s, retry count %d exceeded' % (sendPduHandle, origRetries)) + cbFun(snmpEngine, origSendRequestHandle, errorIndication, None, cbCtx) return + + # User-side API assumes SMIv2 + if origMessageProcessingModel == 0: + reqPDU = rfc2576.v2ToV1(origPdu) + pduVersion = 0 + else: + reqPDU = origPdu + pduVersion = 1 + try: sendPduHandle = snmpEngine.msgAndPduDsp.sendPdu( snmpEngine, origTransportDomain, origTransportAddress, origMessageProcessingModel, origSecurityModel, origSecurityName, origSecurityLevel, origContextEngineId, - origContextName, origPduVersion, origPdu, + origContextName, pduVersion, reqPDU, True, origTimeout, self.processResponsePdu, (origSendRequestHandle, cbFun, cbCtx)) @@ -93,25 +110,28 @@ origMessageProcessingModel, origSecurityModel, origSecurityName, origSecurityLevel, origContextEngineId, origContextName, origPduVersion, origPdu, origTimeout, - origRetryCount, origRetries + 1 + origRetryCount, origRetries, origDiscoveryRetries ) return except StatusInformation: statusInformation = sys.exc_info()[1] - debug.logger & debug.flagApp and debug.logger('processResponsePdu: origSendRequestHandle %s, _sendPdu() failed with %r' % (sendPduHandle, statusInformation)) + debug.logger & debug.flagApp and debug.logger( + 'processResponsePdu: origSendRequestHandle %s, _sendPdu() failed with %r' % ( + sendPduHandle, statusInformation)) cbFun(snmpEngine, origSendRequestHandle, statusInformation['errorIndication'], None, cbCtx) return - if origMessageProcessingModel != messageProcessingModel or \ - origSecurityModel != securityModel or \ - origSecurityName != origSecurityName or \ - origContextEngineId and origContextEngineId != contextEngineId or \ - origContextName and origContextName != contextName or \ - origPduVersion != pduVersion: - debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendPduHandle %s, request/response data mismatch' % sendPduHandle) + if (origMessageProcessingModel != messageProcessingModel or + origSecurityModel != securityModel or + origSecurityName != origSecurityName or + origContextEngineId and origContextEngineId != contextEngineId or + origContextName and origContextName != contextName or + origPduVersion != pduVersion): + debug.logger & debug.flagApp and debug.logger( + 'processResponsePdu: sendPduHandle %s, request/response data mismatch' % sendPduHandle) cbFun(snmpEngine, origSendRequestHandle, 'badResponse', None, cbCtx) @@ -123,7 +143,8 @@ # 3.1.2 if v2c.apiPDU.getRequestID(PDU) != v2c.apiPDU.getRequestID(origPdu): - debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendPduHandle %s, request-id/response-id mismatch' % sendPduHandle) + debug.logger & debug.flagApp and debug.logger( + 'processResponsePdu: sendPduHandle %s, request-id/response-id mismatch' % sendPduHandle) cbFun(snmpEngine, origSendRequestHandle, 'badResponse', None, cbCtx) return @@ -138,9 +159,10 @@ securityLevel) = config.getTargetInfo(snmpEngine, targetName) # Convert timeout in seconds into timeout in timer ticks - timeoutInTicks = float(timeout)/100/snmpEngine.transportDispatcher.getTimerResolution() + timeoutInTicks = float(timeout) / 100 / snmpEngine.transportDispatcher.getTimerResolution() - SnmpEngineID, SnmpAdminString = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpEngineID', 'SnmpAdminString') + SnmpEngineID, SnmpAdminString = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + 'SNMP-FRAMEWORK-MIB', 'SnmpEngineID', 'SnmpAdminString') # Cast possible strings into bytes if contextEngineId: @@ -173,16 +195,20 @@ transportDomain, transportAddress, messageProcessingModel, securityModel, securityName, securityLevel, contextEngineId, contextName, pduVersion, origPDU, timeoutInTicks, - retryCount, 0 + retryCount, 0, 0 ) - debug.logger & debug.flagApp and debug.logger('sendPdu: sendPduHandle %s, timeout %d*10 ms/%d ticks, retry 0 of %d' % (sendPduHandle, timeout, timeoutInTicks, retryCount)) + debug.logger & debug.flagApp and debug.logger( + 'sendPdu: sendPduHandle %s, timeout %d*10 ms/%d ticks, retry 0 of %d' % ( + sendPduHandle, timeout, timeoutInTicks, retryCount)) return sendRequestHandle + # backward compatibility stub CommandGeneratorBase = CommandGenerator + class GetCommandGenerator(CommandGenerator): def processResponseVarBinds(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): @@ -204,6 +230,7 @@ contextName, reqPDU, self.processResponseVarBinds, (cbFun, cbCtx)) + class SetCommandGenerator(CommandGenerator): def processResponseVarBinds(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): @@ -225,6 +252,7 @@ contextName, reqPDU, self.processResponseVarBinds, (cbFun, cbCtx)) + class NextCommandGeneratorSingleRun(CommandGenerator): def processResponseVarBinds(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): @@ -247,6 +275,7 @@ (targetName, contextEngineId, contextName, reqPDU, cbFun, cbCtx)) + class NextCommandGenerator(NextCommandGeneratorSingleRun): def processResponseVarBinds(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): @@ -272,11 +301,12 @@ v2c.apiPDU.getErrorStatus(PDU), v2c.apiPDU.getErrorIndex(PDU, muteErrors=True), varBindTable, cbCtx): - debug.logger & debug.flagApp and debug.logger('processResponseVarBinds: sendRequestHandle %s, app says to stop walking' % sendRequestHandle) + debug.logger & debug.flagApp and debug.logger( + 'processResponseVarBinds: sendRequestHandle %s, app says to stop walking' % sendRequestHandle) return # app says enough if not varBinds: - return # no more objects available + return # no more objects available v2c.apiPDU.setRequestID(reqPDU, v2c.getNextRequestID()) v2c.apiPDU.setVarBinds(reqPDU, varBinds) @@ -290,11 +320,13 @@ except StatusInformation: statusInformation = sys.exc_info()[1] - debug.logger & debug.flagApp and debug.logger('sendVarBinds: sendPduHandle %s: sendPdu() failed with %r' % (sendRequestHandle, statusInformation)) + debug.logger & debug.flagApp and debug.logger( + 'sendVarBinds: sendPduHandle %s: sendPdu() failed with %r' % (sendRequestHandle, statusInformation)) cbFun(snmpEngine, sendRequestHandle, statusInformation['errorIndication'], 0, 0, (), cbCtx) + class BulkCommandGeneratorSingleRun(CommandGenerator): def processResponseVarBinds(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): @@ -324,6 +356,7 @@ contextEngineId, contextName, reqPDU, cbFun, cbCtx)) + class BulkCommandGenerator(BulkCommandGeneratorSingleRun): def processResponseVarBinds(self, snmpEngine, sendRequestHandle, errorIndication, PDU, cbCtx): @@ -353,16 +386,16 @@ v2c.apiBulkPDU.getErrorStatus(PDU), v2c.apiBulkPDU.getErrorIndex(PDU, muteErrors=True), varBindTable, cbCtx): - debug.logger & debug.flagApp and debug.logger('processResponseVarBinds: sendRequestHandle %s, app says to stop walking' % sendRequestHandle) - return # app says enough + debug.logger & debug.flagApp and debug.logger( + 'processResponseVarBinds: sendRequestHandle %s, app says to stop walking' % sendRequestHandle) + return # app says enough if not varBinds: - return # no more objects available + return # no more objects available v2c.apiBulkPDU.setRequestID(reqPDU, v2c.getNextRequestID()) v2c.apiBulkPDU.setVarBinds(reqPDU, varBinds) - try: self.sendPdu(snmpEngine, targetName, contextEngineId, contextName, reqPDU, @@ -372,10 +405,13 @@ except StatusInformation: statusInformation = sys.exc_info()[1] - debug.logger & debug.flagApp and debug.logger('processResponseVarBinds: sendPduHandle %s: _sendPdu() failed with %r' % (sendRequestHandle, statusInformation)) + debug.logger & debug.flagApp and debug.logger( + 'processResponseVarBinds: sendPduHandle %s: _sendPdu() failed with %r' % ( + sendRequestHandle, statusInformation)) cbFun(snmpEngine, sendRequestHandle, statusInformation['errorIndication'], 0, 0, (), cbCtx) + # # Obsolete, compatibility interfaces. # @@ -386,12 +422,14 @@ return cbFun(sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx) + def _sendReq(self, snmpEngine, targetName, varBinds, cbFun, cbCtx=None, contextEngineId=None, contextName=''): return self.sendVarBinds(snmpEngine, targetName, contextEngineId, contextName, varBinds, __sendReqCbFun, (cbFun, cbCtx)) + def _sendBulkReq(self, snmpEngine, targetName, nonRepeaters, maxRepetitions, varBinds, cbFun, cbCtx=None, contextEngineId=None, contextName=''): @@ -399,6 +437,7 @@ contextName, nonRepeaters, maxRepetitions, varBinds, __sendReqCbFun, (cbFun, cbCtx)) + # install compatibility wrappers GetCommandGenerator.sendReq = _sendReq SetCommandGenerator.sendReq = _sendReq diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/cmdrsp.py python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/cmdrsp.py --- python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/cmdrsp.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/cmdrsp.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from pysnmp.proto import rfc1902, rfc1905, rfc3411, errind, error @@ -11,15 +11,16 @@ import pysnmp.smi.error from pysnmp import debug + # 3.2 -class CommandResponderBase: +class CommandResponderBase(object): acmID = 3 # default MIB access control method to use pduTypes = () def __init__(self, snmpEngine, snmpContext): snmpEngine.msgAndPduDsp.registerContextEngineId( snmpContext.contextEngineId, self.pduTypes, self.processPdu - ) + ) self.snmpContext = snmpContext self.__pendingReqs = {} @@ -44,7 +45,10 @@ v2c.apiPDU.setErrorIndex(PDU, errorIndex) v2c.apiPDU.setVarBinds(PDU, varBinds) - debug.logger & debug.flagApp and debug.logger('sendVarBinds: stateReference %s, errorStatus %s, errorIndex %s, varBinds %s' % (stateReference, errorStatus, errorIndex, varBinds)) + debug.logger & debug.flagApp and debug.logger( + 'sendVarBinds: stateReference %s, errorStatus %s, errorIndex %s, varBinds %s' % ( + stateReference, errorStatus, errorIndex, varBinds) + ) self.sendPdu(snmpEngine, stateReference, PDU) @@ -79,8 +83,10 @@ ) except error.StatusInformation: - debug.logger & debug.flagApp and debug.logger('sendPdu: stateReference %s, statusInformation %s' % (stateReference, sys.exc_info()[1])) - snmpSilentDrops, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpSilentDrops') + debug.logger & debug.flagApp and debug.logger( + 'sendPdu: stateReference %s, statusInformation %s' % (stateReference, sys.exc_info()[1])) + snmpSilentDrops, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', + 'snmpSilentDrops') snmpSilentDrops.syntax += 1 _getRequestType = rfc1905.GetRequestPDU.tagSet @@ -104,8 +110,8 @@ origPdu = None # 3.2.1 - if PDU.tagSet not in rfc3411.readClassPDUs and \ - PDU.tagSet not in rfc3411.writeClassPDUs: + if (PDU.tagSet not in rfc3411.readClassPDUs and + PDU.tagSet not in rfc3411.writeClassPDUs): raise error.ProtocolError('Unexpected PDU class %s' % PDU.tagSet) # 3.2.2 --> no-op @@ -125,16 +131,18 @@ varBinds = v2c.apiPDU.getVarBinds(PDU) errorStatus, errorIndex = 'noError', 0 - debug.logger & debug.flagApp and debug.logger('processPdu: stateReference %s, varBinds %s' % (stateReference, varBinds)) + debug.logger & debug.flagApp and debug.logger( + 'processPdu: stateReference %s, varBinds %s' % (stateReference, varBinds)) try: self.handleMgmtOperation(snmpEngine, stateReference, - contextName, PDU, + contextName, PDU, (self.__verifyAccess, snmpEngine)) # SNMPv2 SMI exceptions except pysnmp.smi.error.GenError: errorIndication = sys.exc_info()[1] - debug.logger & debug.flagApp and debug.logger('processPdu: stateReference %s, errorIndication %s' % (stateReference, errorIndication)) + debug.logger & debug.flagApp and debug.logger( + 'processPdu: stateReference %s, errorIndication %s' % (stateReference, errorIndication)) if 'oid' in errorIndication: # Request REPORT generation statusInformation['oid'] = errorIndication['oid'] @@ -195,17 +203,19 @@ # Map ACM errors onto SMI ones except error.StatusInformation: statusInformation = sys.exc_info()[1] - debug.logger & debug.flagApp and debug.logger('__verifyAccess: name %s, statusInformation %s' % (name, statusInformation)) + debug.logger & debug.flagApp and debug.logger( + '__verifyAccess: name %s, statusInformation %s' % (name, statusInformation)) errorIndication = statusInformation['errorIndication'] # 3.2.5... - if errorIndication == errind.noSuchView or \ - errorIndication == errind.noAccessEntry or \ - errorIndication == errind.noGroupName: + if (errorIndication == errind.noSuchView or + errorIndication == errind.noAccessEntry or + errorIndication == errind.noGroupName): raise pysnmp.smi.error.AuthorizationError(name=name, idx=idx) elif errorIndication == errind.otherError: raise pysnmp.smi.error.GenError(name=name, idx=idx) elif errorIndication == errind.noSuchContext: - snmpUnknownContexts, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-TARGET-MIB', 'snmpUnknownContexts') + snmpUnknownContexts, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + '__SNMP-TARGET-MIB', 'snmpUnknownContexts') snmpUnknownContexts.syntax += 1 # Request REPORT generation raise pysnmp.smi.error.GenError(name=name, idx=idx, @@ -217,12 +227,13 @@ raise error.ProtocolError('Unknown ACM error %s' % errorIndication) else: # rfc2576: 4.1.2.1 - if securityModel == 1 and syntax is not None and \ - self._counter64Type == syntax.getTagSet() and \ - self._getNextRequestType == pduType: + if (securityModel == 1 and syntax is not None and + self._counter64Type == syntax.getTagSet() and + self._getNextRequestType == pduType): # This will cause MibTree to skip this OID-value raise pysnmp.smi.error.NoAccessError(name=name, idx=idx) + class GetCommandResponder(CommandResponderBase): pduTypes = (rfc1905.GetRequestPDU.tagSet,) @@ -236,6 +247,7 @@ mgmtFun(v2c.apiPDU.getVarBinds(PDU), (acFun, acCtx))) self.releaseStateInformation(stateReference) + class NextCommandResponder(CommandResponderBase): pduTypes = (rfc1905.GetNextRequestPDU.tagSet,) @@ -257,6 +269,7 @@ break self.releaseStateInformation(stateReference) + class BulkCommandResponder(CommandResponderBase): pduTypes = (rfc1905.GetBulkRequestPDU.tagSet,) maxVarBinds = 64 @@ -276,10 +289,10 @@ N = min(int(nonRepeaters), len(reqVarBinds)) M = int(maxRepetitions) - R = max(len(reqVarBinds)-N, 0) + R = max(len(reqVarBinds) - N, 0) if R: - M = min(M, self.maxVarBinds/R) + M = min(M, self.maxVarBinds / R) debug.logger & debug.flagApp and debug.logger('handleMgmtOperation: N %d, M %d, R %d' % (N, M, R)) @@ -294,7 +307,7 @@ while M and R: rspVarBinds.extend(mgmtFun(varBinds, (acFun, acCtx))) varBinds = rspVarBinds[-R:] - M = M - 1 + M -= 1 if len(rspVarBinds): self.sendVarBinds(snmpEngine, stateReference, 0, 0, rspVarBinds) @@ -302,6 +315,7 @@ else: raise pysnmp.smi.error.SmiError() + class SetCommandResponder(CommandResponderBase): pduTypes = (rfc1905.SetRequestPDU.tagSet,) diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/config.py python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/config.py --- python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/config.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/config.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,12 +1,13 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.smi.error import SmiError, NoSuchInstanceError from pysnmp.entity import config + def getTargetAddr(snmpEngine, snmpTargetAddrName): mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder @@ -30,10 +31,10 @@ snmpTargetAddrTimeout, snmpTargetAddrRetryCount, snmpTargetAddrParams) = mibBuilder.importSymbols( - 'SNMP-TARGET-MIB', 'snmpTargetAddrTDomain', - 'snmpTargetAddrTAddress', 'snmpTargetAddrTimeout', - 'snmpTargetAddrRetryCount', 'snmpTargetAddrParams' - ) + 'SNMP-TARGET-MIB', 'snmpTargetAddrTDomain', + 'snmpTargetAddrTAddress', 'snmpTargetAddrTimeout', + 'snmpTargetAddrRetryCount', 'snmpTargetAddrParams' + ) snmpSourceAddrTAddress, = mibBuilder.importSymbols('PYSNMP-SOURCE-MIB', 'snmpSourceAddrTAddress') tblIdx = snmpTargetAddrEntry.getInstIdFromIndices(snmpTargetAddrName) @@ -63,12 +64,14 @@ transport = snmpEngine.transportDispatcher.getTransport(snmpTargetAddrTDomain) if snmpTargetAddrTDomain[:len(config.snmpUDPDomain)] == config.snmpUDPDomain: - SnmpUDPAddress, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMPv2-TM', 'SnmpUDPAddress') + SnmpUDPAddress, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMPv2-TM', + 'SnmpUDPAddress') snmpTargetAddrTAddress = transport.addressType( SnmpUDPAddress(snmpTargetAddrTAddress) ).setLocalAddress(SnmpUDPAddress(snmpSourceAddrTAddress)) elif snmpTargetAddrTDomain[:len(config.snmpUDP6Domain)] == config.snmpUDP6Domain: - TransportAddressIPv6, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('TRANSPORT-ADDRESS-MIB', 'TransportAddressIPv6') + TransportAddressIPv6, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + 'TRANSPORT-ADDRESS-MIB', 'TransportAddressIPv6') snmpTargetAddrTAddress = transport.addressType( TransportAddressIPv6(snmpTargetAddrTAddress) ).setLocalAddress(TransportAddressIPv6(snmpSourceAddrTAddress)) @@ -111,10 +114,10 @@ (snmpTargetParamsMPModel, snmpTargetParamsSecurityModel, snmpTargetParamsSecurityName, snmpTargetParamsSecurityLevel) = mibBuilder.importSymbols( - 'SNMP-TARGET-MIB', 'snmpTargetParamsMPModel', - 'snmpTargetParamsSecurityModel', 'snmpTargetParamsSecurityName', - 'snmpTargetParamsSecurityLevel' - ) + 'SNMP-TARGET-MIB', 'snmpTargetParamsMPModel', + 'snmpTargetParamsSecurityModel', 'snmpTargetParamsSecurityName', + 'snmpTargetParamsSecurityLevel' + ) tblIdx = snmpTargetParamsEntry.getInstIdFromIndices(paramsName) @@ -143,6 +146,7 @@ return nameToParamsMap[paramsName] + def getTargetInfo(snmpEngine, snmpTargetAddrName): # Transport endpoint (snmpTargetAddrTDomain, @@ -162,6 +166,7 @@ snmpTargetParamsMPModel, snmpTargetParamsSecurityModel, snmpTargetParamsSecurityName, snmpTargetParamsSecurityLevel) + def getNotificationInfo(snmpEngine, notificationTarget): mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder @@ -206,6 +211,7 @@ return targetToNotifyMap[notificationTarget] + def getTargetNames(snmpEngine, tag): mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder @@ -226,9 +232,9 @@ (SnmpTagValue, snmpTargetAddrName, snmpTargetAddrTagList) = mibBuilder.importSymbols( - 'SNMP-TARGET-MIB', 'SnmpTagValue', 'snmpTargetAddrName', - 'snmpTargetAddrTagList' - ) + 'SNMP-TARGET-MIB', 'SnmpTagValue', 'snmpTargetAddrName', + 'snmpTargetAddrTagList' + ) mibNode = snmpTargetAddrTagList while True: try: diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/context.py python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/context.py --- python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/context.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/context.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,17 +1,19 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.type import univ from pyasn1.compat.octets import null from pysnmp import error from pysnmp import debug -class SnmpContext: + +class SnmpContext(object): def __init__(self, snmpEngine, contextEngineId=None): - snmpEngineId, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + snmpEngineId, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', + 'snmpEngineID') if contextEngineId is None: # Default to local snmpEngineId self.contextEngineId = snmpEngineId.syntax @@ -19,16 +21,17 @@ self.contextEngineId = snmpEngineId.syntax.clone(contextEngineId) debug.logger & debug.flagIns and debug.logger('SnmpContext: contextEngineId \"%r\"' % (self.contextEngineId,)) self.contextNames = { - null: snmpEngine.msgAndPduDsp.mibInstrumController # Default name - } + null: snmpEngine.msgAndPduDsp.mibInstrumController # Default name + } def registerContextName(self, contextName, mibInstrum=None): contextName = univ.OctetString(contextName).asOctets() if contextName in self.contextNames: raise error.PySnmpError( 'Duplicate contextName %s' % contextName - ) - debug.logger & debug.flagIns and debug.logger('registerContextName: registered contextName %r, mibInstrum %r' % (contextName, mibInstrum)) + ) + debug.logger & debug.flagIns and debug.logger( + 'registerContextName: registered contextName %r, mibInstrum %r' % (contextName, mibInstrum)) if mibInstrum is None: self.contextNames[contextName] = self.contextNames[null] else: @@ -37,7 +40,8 @@ def unregisterContextName(self, contextName): contextName = univ.OctetString(contextName).asOctets() if contextName in self.contextNames: - debug.logger & debug.flagIns and debug.logger('unregisterContextName: unregistered contextName %r' % contextName) + debug.logger & debug.flagIns and debug.logger( + 'unregisterContextName: unregistered contextName %r' % contextName) del self.contextNames[contextName] def getMibInstrum(self, contextName=null): @@ -46,7 +50,8 @@ debug.logger & debug.flagIns and debug.logger('getMibInstrum: contextName %r not registered' % contextName) raise error.PySnmpError( 'Missing contextName %s' % contextName - ) + ) else: - debug.logger & debug.flagIns and debug.logger('getMibInstrum: contextName %r, mibInstum %r' % (contextName, self.contextNames[contextName])) + debug.logger & debug.flagIns and debug.logger( + 'getMibInstrum: contextName %r, mibInstum %r' % (contextName, self.contextNames[contextName])) return self.contextNames[contextName] diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/mibvar.py python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/mibvar.py --- python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/mibvar.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/mibvar.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # THESE FUNCTIONS ARE OBSOLETE AND MUST NOT BE USED! # USE pysnmp.entity.rfc3413.oneliner.mibvar INSTEAD @@ -10,16 +10,17 @@ from pyasn1.type import univ from pysnmp.smi.error import NoSuchObjectError + # Name def mibNameToOid(mibView, name): if isinstance(name[0], tuple): f = lambda x='', y='': (x, y) modName, symName = f(*name[0]) - if modName: # load module if needed + if modName: # load module if needed mibView.mibBuilder.loadModules(modName) else: - mibView.mibBuilder.loadModules() # load all (slow) + mibView.mibBuilder.loadModules() # load all (slow) if symName: oid, label, suffix = mibView.getNodeNameByDesc(symName, modName) else: @@ -28,12 +29,12 @@ modName, symName, _s = mibView.getNodeLocation(oid) mibNode, = mibView.mibBuilder.importSymbols( modName, symName - ) - if hasattr(mibNode, 'createTest'): # table column XXX + ) + if hasattr(mibNode, 'createTest'): # table column XXX modName, symName, _s = mibView.getNodeLocation(oid[:-1]) rowNode, = mibView.mibBuilder.importSymbols(modName, symName) return oid, rowNode.getInstIdFromIndices(*suffix) - else: # scalar or incomplete spec + else: # scalar or incomplete spec return oid, suffix elif not isinstance(name, tuple): name = tuple(univ.ObjectIdentifier(name)) @@ -42,8 +43,10 @@ return oid, suffix + __scalarSuffix = (univ.Integer(0),) + def oidToMibName(mibView, oid): if not isinstance(oid, tuple): oid = tuple(univ.ObjectIdentifier(oid)) @@ -51,27 +54,29 @@ modName, symName, __suffix = mibView.getNodeLocation(_oid) mibNode, = mibView.mibBuilder.importSymbols( modName, symName - ) - if hasattr(mibNode, 'createTest'): # table column + ) + if hasattr(mibNode, 'createTest'): # table column __modName, __symName, __s = mibView.getNodeLocation(_oid[:-1]) rowNode, = mibView.mibBuilder.importSymbols(__modName, __symName) return (symName, modName), rowNode.getIndicesFromInstId(suffix) - elif not suffix: # scalar + elif not suffix: # scalar return (symName, modName), suffix - elif suffix == (0,): # scalar + elif suffix == (0,): # scalar return (symName, modName), __scalarSuffix else: raise NoSuchObjectError( - str='No MIB registered that defines %s object, closest known parent is %s (%s::%s)' % (univ.ObjectIdentifier(oid), univ.ObjectIdentifier(mibNode.name), modName, symName) - ) + str='No MIB registered that defines %s object, closest known parent is %s (%s::%s)' % ( + univ.ObjectIdentifier(oid), univ.ObjectIdentifier(mibNode.name), modName, symName) + ) + # Value def cloneFromMibValue(mibView, modName, symName, value): mibNode, = mibView.mibBuilder.importSymbols( modName, symName - ) - if hasattr(mibNode, 'syntax'): # scalar + ) + if hasattr(mibNode, 'syntax'): # scalar return mibNode.syntax.clone(value) else: - return # identifier + return # identifier diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/ntforg.py python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/ntforg.py --- python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/ntforg.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/ntforg.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from pyasn1.compat.octets import null @@ -10,19 +10,22 @@ from pysnmp.proto.proxy import rfc2576 from pysnmp.proto import rfc3411 from pysnmp.proto.api import v2c -from pysnmp.proto import error +from pysnmp.proto import errind, error from pysnmp.smi import view, rfc1902 from pysnmp import nextid from pysnmp import debug getNextHandle = nextid.Integer(0x7fffffff) -class NotificationOriginator: + +class NotificationOriginator(object): acmID = 3 # default MIB access control method to use - def __init__(self, snmpContext=None): + + def __init__(self, **options): self.__pendingReqs = {} self.__pendingNotifications = {} - self.snmpContext = snmpContext # this is deprecated + self.snmpContext = options.pop('snmpContext', None) # this is deprecated + self.__options = options def processResponsePdu(self, snmpEngine, messageProcessingModel, securityModel, securityName, securityLevel, @@ -38,20 +41,33 @@ origMessageProcessingModel, origSecurityModel, origSecurityName, origSecurityLevel, origContextEngineId, origContextName, origPdu, origTimeout, - origRetryCount, origRetries) = self.__pendingReqs.pop(sendPduHandle) + origRetryCount, origRetries, origDiscoveryRetries) = self.__pendingReqs.pop(sendPduHandle) snmpEngine.transportDispatcher.jobFinished(id(self)) if statusInformation: - debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendRequestHandle %s, sendPduHandle %s statusInformation %s' % (sendRequestHandle, sendPduHandle, statusInformation)) - if origRetries == origRetryCount: - debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendRequestHandle %s, sendPduHandle %s retry count %d exceeded' % (sendRequestHandle, sendPduHandle, origRetries)) - cbFun(snmpEngine, sendRequestHandle, - statusInformation['errorIndication'], None, cbCtx) + debug.logger & debug.flagApp and debug.logger( + 'processResponsePdu: sendRequestHandle %s, sendPduHandle %s statusInformation %s' % ( + sendRequestHandle, sendPduHandle, statusInformation)) + + errorIndication = statusInformation['errorIndication'] + + if errorIndication in (errind.notInTimeWindow, errind.unknownEngineID): + origDiscoveryRetries += 1 + origRetries = 0 + else: + origDiscoveryRetries = 0 + origRetries += 1 + + if origRetries > origRetryCount or origDiscoveryRetries > self.__options.get('discoveryRetries', 4): + debug.logger & debug.flagApp and debug.logger( + 'processResponsePdu: sendRequestHandle %s, sendPduHandle %s retry count %d exceeded' % ( + sendRequestHandle, sendPduHandle, origRetries)) + cbFun(snmpEngine, sendRequestHandle, errorIndication, None, cbCtx) return # Convert timeout in seconds into timeout in timer ticks - timeoutInTicks = float(origTimeout)/100/snmpEngine.transportDispatcher.getTimerResolution() + timeoutInTicks = float(origTimeout) / 100 / snmpEngine.transportDispatcher.getTimerResolution() # User-side API assumes SMIv2 if messageProcessingModel == 0: @@ -73,14 +89,18 @@ ) except error.StatusInformation: statusInformation = sys.exc_info()[1] - debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendRequestHandle %s: sendPdu() failed with %r ' % (sendRequestHandle, statusInformation)) + debug.logger & debug.flagApp and debug.logger( + 'processResponsePdu: sendRequestHandle %s: sendPdu() failed with %r ' % ( + sendRequestHandle, statusInformation)) cbFun(snmpEngine, sendRequestHandle, statusInformation['errorIndication'], None, cbCtx) return snmpEngine.transportDispatcher.jobStarted(id(self)) - debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendRequestHandle %s, sendPduHandle %s, timeout %d, retry %d of %d' % (sendRequestHandle, sendPduHandle, origTimeout, origRetries, origRetryCount)) + debug.logger & debug.flagApp and debug.logger( + 'processResponsePdu: sendRequestHandle %s, sendPduHandle %s, timeout %d, retry %d of %d' % ( + sendRequestHandle, sendPduHandle, origTimeout, origRetries, origRetryCount)) # 3.3.6b self.__pendingReqs[sendPduHandle] = ( @@ -88,7 +108,7 @@ origMessageProcessingModel, origSecurityModel, origSecurityName, origSecurityLevel, origContextEngineId, origContextName, origPdu, - origTimeout, origRetryCount, origRetries + 1 + origTimeout, origRetryCount, origRetries, origDiscoveryRetries ) return @@ -118,7 +138,7 @@ # 3.3.5 if reqPDU.tagSet in rfc3411.confirmedClassPDUs: # Convert timeout in seconds into timeout in timer ticks - timeoutInTicks = float(timeout)/100/snmpEngine.transportDispatcher.getTimerResolution() + timeoutInTicks = float(timeout) / 100 / snmpEngine.transportDispatcher.getTimerResolution() sendRequestHandle = getNextHandle() @@ -131,13 +151,14 @@ self.processResponsePdu, (sendRequestHandle, cbFun, cbCtx) ) - debug.logger & debug.flagApp and debug.logger('sendPdu: sendPduHandle %s, timeout %d' % (sendPduHandle, timeout)) + debug.logger & debug.flagApp and debug.logger( + 'sendPdu: sendPduHandle %s, timeout %d' % (sendPduHandle, timeout)) # 3.3.6b self.__pendingReqs[sendPduHandle] = ( transportDomain, transportAddress, messageProcessingModel, securityModel, securityName, securityLevel, contextEngineId, - contextName, pdu, timeout, retryCount, True + contextName, pdu, timeout, retryCount, 0, 0 ) snmpEngine.transportDispatcher.jobStarted(id(self)) else: @@ -160,10 +181,14 @@ self.__pendingNotifications[notificationHandle].remove(sendRequestHandle) - debug.logger & debug.flagApp and debug.logger('processResponseVarBinds: notificationHandle %s, sendRequestHandle %s, errorIndication %s, pending requests %s' % (notificationHandle, sendRequestHandle, errorIndication, self.__pendingNotifications[notificationHandle])) + debug.logger & debug.flagApp and debug.logger( + 'processResponseVarBinds: notificationHandle %s, sendRequestHandle %s, errorIndication %s, pending requests %s' % ( + notificationHandle, sendRequestHandle, errorIndication, self.__pendingNotifications[notificationHandle])) if not self.__pendingNotifications[notificationHandle]: - debug.logger & debug.flagApp and debug.logger('processResponseVarBinds: notificationHandle %s, sendRequestHandle %s -- completed' % (notificationHandle, sendRequestHandle)) + debug.logger & debug.flagApp and debug.logger( + 'processResponseVarBinds: notificationHandle %s, sendRequestHandle %s -- completed' % ( + notificationHandle, sendRequestHandle)) del self.__pendingNotifications[notificationHandle] cbFun(snmpEngine, sendRequestHandle, errorIndication, pdu and v2c.apiPDU.getErrorStatus(pdu) or 0, @@ -177,10 +202,13 @@ # def sendVarBinds(self, snmpEngine, notificationTarget, contextEngineId, contextName, varBinds=(), cbFun=None, cbCtx=None): - debug.logger & debug.flagApp and debug.logger('sendVarBinds: notificationTarget %s, contextEngineId %s, contextName "%s", varBinds %s' % (notificationTarget, contextEngineId or '', contextName, varBinds)) + debug.logger & debug.flagApp and debug.logger( + 'sendVarBinds: notificationTarget %s, contextEngineId %s, contextName "%s", varBinds %s' % ( + notificationTarget, contextEngineId or '', contextName, varBinds)) if contextName: - __SnmpAdminString, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString') + __SnmpAdminString, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + 'SNMP-FRAMEWORK-MIB', 'SnmpAdminString') contextName = __SnmpAdminString(contextName) # 3.3 @@ -188,12 +216,16 @@ notificationHandle = getNextHandle() - debug.logger & debug.flagApp and debug.logger('sendVarBinds: notificationHandle %s, notifyTag %s, notifyType %s' % (notificationHandle, notifyTag, notifyType)) + debug.logger & debug.flagApp and debug.logger( + 'sendVarBinds: notificationHandle %s, notifyTag %s, notifyType %s' % ( + notificationHandle, notifyTag, notifyType)) varBinds = [(v2c.ObjectIdentifier(x), y) for x, y in varBinds] # 3.3.2 & 3.3.3 - snmpTrapOID, sysUpTime = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpTrapOID', 'sysUpTime') + snmpTrapOID, sysUpTime = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', + 'snmpTrapOID', + 'sysUpTime') for idx in range(len(varBinds)): if idx and varBinds[idx][0] == sysUpTime.getName(): @@ -211,6 +243,8 @@ varBinds.insert(1, (v2c.ObjectIdentifier(snmpTrapOID.getName()), snmpTrapOID.getSyntax())) + sendRequestHandle = -1 + debug.logger & debug.flagApp and debug.logger('sendVarBinds: final varBinds %s' % (varBinds,)) for targetAddrName in config.getTargetNames(snmpEngine, notifyTag): @@ -221,13 +255,16 @@ securityLevel) = config.getTargetParams(snmpEngine, params) # 3.3.1 XXX -# XXX filtering's yet to be implemented -# filterProfileName = config.getNotifyFilterProfile(params) + # XXX filtering's yet to be implemented + # filterProfileName = config.getNotifyFilterProfile(params) -# (filterSubtree, filterMask, -# filterType) = config.getNotifyFilter(filterProfileName) + # (filterSubtree, filterMask, + # filterType) = config.getNotifyFilter(filterProfileName) - debug.logger & debug.flagApp and debug.logger('sendVarBinds: notificationHandle %s, notifyTag %s yields: transportDomain %s, transportAddress %r, securityModel %s, securityName %s, securityLevel %s' % (notificationHandle, notifyTag, transportDomain, transportAddress, securityModel, securityName, securityLevel)) + debug.logger & debug.flagApp and debug.logger( + 'sendVarBinds: notificationHandle %s, notifyTag %s yields: transportDomain %s, transportAddress %r, securityModel %s, securityName %s, securityLevel %s' % ( + notificationHandle, notifyTag, transportDomain, transportAddress, securityModel, + securityName, securityLevel)) for varName, varVal in varBinds: if varName in (sysUpTime.name, snmpTrapOID.name): @@ -238,10 +275,13 @@ securityLevel, 'notify', contextName, varName ) - debug.logger & debug.flagApp and debug.logger('sendVarBinds: ACL succeeded for OID %s securityName %s' % (varName, securityName)) + debug.logger & debug.flagApp and debug.logger( + 'sendVarBinds: ACL succeeded for OID %s securityName %s' % (varName, securityName)) except error.StatusInformation: - debug.logger & debug.flagApp and debug.logger('sendVarBinds: ACL denied access for OID %s securityName %s, droppping notification' % (varName, securityName)) + debug.logger & debug.flagApp and debug.logger( + 'sendVarBinds: ACL denied access for OID %s securityName %s, droppping notification' % ( + varName, securityName)) return # 3.3.4 @@ -265,9 +305,11 @@ except error.StatusInformation: statusInformation = sys.exc_info()[1] - debug.logger & debug.flagApp and debug.logger('sendVarBinds: sendRequestHandle %s: sendPdu() failed with %r' % (sendRequestHandle, statusInformation)) + debug.logger & debug.flagApp and debug.logger( + 'sendVarBinds: sendRequestHandle %s: sendPdu() failed with %r' % ( + sendRequestHandle, statusInformation)) if notificationHandle not in self.__pendingNotifications or \ - not self.__pendingNotifications[notificationHandle]: + not self.__pendingNotifications[notificationHandle]: if notificationHandle in self.__pendingNotifications: del self.__pendingNotifications[notificationHandle] if cbFun: @@ -276,17 +318,22 @@ cbCtx) return notificationHandle - debug.logger & debug.flagApp and debug.logger('sendVarBinds: notificationHandle %s, sendRequestHandle %s, timeout %d' % (notificationHandle, sendRequestHandle, timeout)) + debug.logger & debug.flagApp and debug.logger( + 'sendVarBinds: notificationHandle %s, sendRequestHandle %s, timeout %d' % ( + notificationHandle, sendRequestHandle, timeout)) if notifyType == 2: if notificationHandle not in self.__pendingNotifications: self.__pendingNotifications[notificationHandle] = set() self.__pendingNotifications[notificationHandle].add(sendRequestHandle) - debug.logger & debug.flagApp and debug.logger('sendVarBinds: notificationHandle %s, sendRequestHandle %s, notification(s) sent' % (notificationHandle, sendRequestHandle)) + debug.logger & debug.flagApp and debug.logger( + 'sendVarBinds: notificationHandle %s, sendRequestHandle %s, notification(s) sent' % ( + notificationHandle, sendRequestHandle)) return notificationHandle + # # Obsolete, compatibility interfaces. # @@ -303,6 +350,7 @@ # a backward compatible way of calling user function cbFun(sendRequestHandle, errorIndication, cbCtx) + def _sendNotification(self, snmpEngine, notificationTarget, notificationName, additionalVarBinds=(), cbFun=None, cbCtx=None, contextName=null, instanceIndex=None): @@ -342,6 +390,7 @@ contextName, varBinds + list(additionalVarBinds), _sendNotificationCbFun, (cbFun, cbCtx)) + # install compatibility wrapper NotificationOriginator.sendNotification = _sendNotification diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/ntfrcv.py python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/ntfrcv.py --- python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/ntfrcv.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/ntfrcv.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from pyasn1.compat.octets import null @@ -11,19 +11,27 @@ from pysnmp.proto.proxy import rfc2576 from pysnmp import debug + # 3.4 -class NotificationReceiver: +class NotificationReceiver(object): pduTypes = (v1.TrapPDU.tagSet, v2c.SNMPv2TrapPDU.tagSet, v2c.InformRequestPDU.tagSet) def __init__(self, snmpEngine, cbFun, cbCtx=None): snmpEngine.msgAndPduDsp.registerContextEngineId( - null, self.pduTypes, self.processPdu # '' is a wildcard + null, self.pduTypes, self.processPdu # '' is a wildcard ) + + self.__snmpTrapCommunity = '' self.__cbFunVer = 0 self.__cbFun = cbFun self.__cbCtx = cbCtx + def storeSnmpTrapCommunity(snmpEngine, execpoint, variables, cbCtx): + self.__snmpTrapCommunity = variables.get('communityName', '') + + snmpEngine.observer.registerObserver(storeSnmpTrapCommunity, 'rfc2576.processIncomingMsg') + def close(self, snmpEngine): snmpEngine.msgAndPduDsp.unregisterContextEngineId( null, self.pduTypes @@ -38,7 +46,7 @@ # Agent-side API complies with SMIv2 if messageProcessingModel == 0: origPdu = PDU - PDU = rfc2576.v1ToV2(PDU) + PDU = rfc2576.v1ToV2(PDU, snmpTrapCommunity=self.__snmpTrapCommunity) else: origPdu = None @@ -46,7 +54,8 @@ errorIndex = 0 varBinds = v2c.apiPDU.getVarBinds(PDU) - debug.logger & debug.flagApp and debug.logger('processPdu: stateReference %s, varBinds %s' % (stateReference, varBinds)) + debug.logger & debug.flagApp and debug.logger( + 'processPdu: stateReference %s, varBinds %s' % (stateReference, varBinds)) # 3.4 if PDU.tagSet in rfc3411.confirmedClassPDUs: @@ -59,7 +68,8 @@ v2c.apiPDU.setErrorIndex(rspPDU, errorIndex) v2c.apiPDU.setVarBinds(rspPDU, varBinds) - debug.logger & debug.flagApp and debug.logger('processPdu: stateReference %s, confirm PDU %s' % (stateReference, rspPDU.prettyPrint())) + debug.logger & debug.flagApp and debug.logger( + 'processPdu: stateReference %s, confirm PDU %s' % (stateReference, rspPDU.prettyPrint())) # Agent-side API complies with SMIv2 if messageProcessingModel == 0: @@ -76,8 +86,10 @@ stateReference, statusInformation) except error.StatusInformation: - debug.logger & debug.flagApp and debug.logger('processPdu: stateReference %s, statusInformation %s' % (stateReference, sys.exc_info()[1])) - snmpSilentDrops, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpSilentDrops') + debug.logger & debug.flagApp and debug.logger( + 'processPdu: stateReference %s, statusInformation %s' % (stateReference, sys.exc_info()[1])) + snmpSilentDrops, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', + 'snmpSilentDrops') snmpSilentDrops.syntax += 1 elif PDU.tagSet in rfc3411.unconfirmedClassPDUs: @@ -85,7 +97,9 @@ else: raise error.ProtocolError('Unexpected PDU class %s' % PDU.tagSet) - debug.logger & debug.flagApp and debug.logger('processPdu: stateReference %s, user cbFun %s, cbCtx %s, varBinds %s' % (stateReference, self.__cbFun, self.__cbCtx, varBinds)) + debug.logger & debug.flagApp and debug.logger( + 'processPdu: stateReference %s, user cbFun %s, cbCtx %s, varBinds %s' % ( + stateReference, self.__cbFun, self.__cbCtx, varBinds)) if self.__cbFunVer: self.__cbFun(snmpEngine, stateReference, contextEngineId, diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/oneliner/cmdgen.py python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/oneliner/cmdgen.py --- python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/oneliner/cmdgen.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/oneliner/cmdgen.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # All code in this file belongs to obsolete, compatibility wrappers. # Never use interfaces below for new applications! @@ -18,7 +18,8 @@ MibVariable = ObjectIdentity -class AsynCommandGenerator: + +class AsynCommandGenerator(object): _null = univ.Null('') vbProcessor = CommandGeneratorVarBinds() @@ -26,7 +27,7 @@ def __init__(self, snmpEngine=None): if snmpEngine is None: - self.snmpEngine = snmpEngine = SnmpEngine() + self.snmpEngine = SnmpEngine() else: self.snmpEngine = snmpEngine @@ -95,7 +96,6 @@ if contextName is null and authData.contextName: contextName = authData.contextName - return setCmd( self.snmpEngine, authData, transportTarget, ContextData(contextEngineId, contextName), *varBinds, @@ -159,8 +159,10 @@ asyncBulkCmd = bulkCmd -class CommandGenerator: + +class CommandGenerator(object): _null = univ.Null('') + def __init__(self, snmpEngine=None, asynCmdGen=None): # compatibility attributes self.snmpEngine = snmpEngine or SnmpEngine() @@ -171,14 +173,14 @@ if 'lookupValues' not in kwargs: kwargs['lookupValues'] = False errorIndication, errorStatus, errorIndex, varBinds = None, 0, 0, [] - for errorIndication, \ - errorStatus, errorIndex, \ - varBinds \ - in sync.getCmd(self.snmpEngine, authData, transportTarget, - ContextData(kwargs.get('contextEngineId'), - kwargs.get('contextName', null)), - *[(x, self._null) for x in varNames], - **kwargs): + for (errorIndication, + errorStatus, + errorIndex, + varBinds) in sync.getCmd(self.snmpEngine, authData, transportTarget, + ContextData(kwargs.get('contextEngineId'), + kwargs.get('contextName', null)), + *[(x, self._null) for x in varNames], + **kwargs): break return errorIndication, errorStatus, errorIndex, varBinds @@ -188,14 +190,14 @@ if 'lookupValues' not in kwargs: kwargs['lookupValues'] = False errorIndication, errorStatus, errorIndex, rspVarBinds = None, 0, 0, [] - for errorIndication, \ - errorStatus, errorIndex, \ - rspVarBinds \ - in sync.setCmd(self.snmpEngine, authData, transportTarget, - ContextData(kwargs.get('contextEngineId'), - kwargs.get('contextName', null)), - *varBinds, - **kwargs): + for (errorIndication, + errorStatus, + errorIndex, + rspVarBinds) in sync.setCmd(self.snmpEngine, authData, transportTarget, + ContextData(kwargs.get('contextEngineId'), + kwargs.get('contextName', null)), + *varBinds, + **kwargs): break return errorIndication, errorStatus, errorIndex, rspVarBinds @@ -209,14 +211,14 @@ kwargs['lexicographicMode'] = False errorIndication, errorStatus, errorIndex = None, 0, 0 varBindTable = [] - for errorIndication, \ - errorStatus, errorIndex, \ - varBinds \ - in sync.nextCmd(self.snmpEngine, authData, transportTarget, - ContextData(kwargs.get('contextEngineId'), - kwargs.get('contextName', null)), - *[(x, self._null) for x in varNames], - **kwargs): + for (errorIndication, + errorStatus, + errorIndex, + varBinds) in sync.nextCmd(self.snmpEngine, authData, transportTarget, + ContextData(kwargs.get('contextEngineId'), + kwargs.get('contextName', null)), + *[(x, self._null) for x in varNames], + **kwargs): if errorIndication or errorStatus: return errorIndication, errorStatus, errorIndex, varBinds @@ -234,16 +236,16 @@ kwargs['lexicographicMode'] = False errorIndication, errorStatus, errorIndex = None, 0, 0 varBindTable = [] - for errorIndication, \ - errorStatus, errorIndex, \ - varBinds \ - in sync.bulkCmd(self.snmpEngine, authData, - transportTarget, - ContextData(kwargs.get('contextEngineId'), - kwargs.get('contextName', null)), - nonRepeaters, maxRepetitions, - *[(x, self._null) for x in varNames], - **kwargs): + for (errorIndication, + errorStatus, + errorIndex, + varBinds) in sync.bulkCmd(self.snmpEngine, authData, + transportTarget, + ContextData(kwargs.get('contextEngineId'), + kwargs.get('contextName', null)), + nonRepeaters, maxRepetitions, + *[(x, self._null) for x in varNames], + **kwargs): if errorIndication or errorStatus: return errorIndication, errorStatus, errorIndex, varBinds diff -Nru python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/oneliner/ntforg.py python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/oneliner/ntforg.py --- python-pysnmp4-4.3.2/pysnmp/entity/rfc3413/oneliner/ntforg.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/entity/rfc3413/oneliner/ntforg.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # All code in this file belongs to obsolete, compatibility wrappers. # Never use interfaces below for new applications! @@ -21,7 +21,8 @@ MibVariable = ObjectIdentity -class ErrorIndicationReturn: + +class ErrorIndicationReturn(object): def __init__(self, *vars): self.__vars = vars @@ -29,7 +30,7 @@ return self.__vars[i] def __nonzero__(self): - return self.__vars[0] and 1 or 0 + return bool(self) def __bool__(self): return bool(self.__vars[0]) @@ -37,9 +38,11 @@ def __str__(self): return str(self.__vars[0]) -class AsynNotificationOriginator: + +class AsynNotificationOriginator(object): vbProcessor = NotificationOriginatorVarBinds() lcd = NotificationOriginatorLcdConfigurator() + def __init__(self, snmpEngine=None, snmpContext=None): if snmpEngine is None: self.snmpEngine = snmpEngine = SnmpEngine() @@ -133,8 +136,10 @@ asyncSendNotification = sendNotification -class NotificationOriginator: + +class NotificationOriginator(object): vbProcessor = NotificationOriginatorVarBinds() + def __init__(self, snmpEngine=None, snmpContext=None, asynNtfOrg=None): # compatibility attributes self.snmpEngine = snmpEngine or SnmpEngine() @@ -158,19 +163,17 @@ if not isinstance(notificationType, NotificationType): notificationType = NotificationType(notificationType) - errorIndication, errorStatus, errorIndex, rspVarBinds = None, 0, 0, [] - for errorIndication, \ - errorStatus, errorIndex, \ - rspVarBinds \ - in sync.sendNotification(self.snmpEngine, authData, - transportTarget, - ContextData( - kwargs.get('contextEngineId'), - kwargs.get('contextName', null) - ), - notifyType, - notificationType.addVarBinds(*varBinds), - **kwargs): + + for (errorIndication, + errorStatus, + errorIndex, + rspVarBinds) in sync.sendNotification(self.snmpEngine, authData, + transportTarget, + ContextData(kwargs.get('contextEngineId'), + kwargs.get('contextName', null)), + notifyType, + notificationType.addVarBinds(*varBinds), + **kwargs): if notifyType == 'inform': return errorIndication, errorStatus, errorIndex, rspVarBinds else: diff -Nru python-pysnmp4-4.3.2/pysnmp/error.py python-pysnmp4-4.4.3/pysnmp/error.py --- python-pysnmp4-4.3.2/pysnmp/error.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/error.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,10 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # + + class PySnmpError(Exception): pass diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncio/cmdgen.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncio/cmdgen.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncio/cmdgen.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncio/cmdgen.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # Copyright (C) 2014, Zebra Technologies # Authors: Matt Hooks @@ -38,6 +38,7 @@ from pysnmp.hlapi.varbinds import * from pysnmp.hlapi.asyncio.transport import * from pysnmp.entity.rfc3413 import cmdgen + try: import asyncio except ImportError: @@ -50,6 +51,7 @@ isEndOfMib = lambda x: not cmdgen.getNextVarBinds(x)[1] + @asyncio.coroutine def getCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): @@ -125,15 +127,22 @@ >>> """ + def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): lookupMib, future = cbCtx if future.cancelled(): return - future.set_result( - (errorIndication, errorStatus, errorIndex, vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib)) - ) + try: + varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds, + lookupMib) + except Exception as e: + future.set_exception(e) + else: + future.set_result( + (errorIndication, errorStatus, errorIndex, varBindsUnmade) + ) addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget) @@ -147,6 +156,7 @@ ) return future + @asyncio.coroutine def setCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): @@ -222,15 +232,22 @@ >>> """ + def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): lookupMib, future = cbCtx if future.cancelled(): return - future.set_result( - (errorIndication, errorStatus, errorIndex, vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib)) - ) + try: + varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds, + lookupMib) + except Exception as e: + future.set_exception(e) + else: + future.set_result( + (errorIndication, errorStatus, errorIndex, varBindsUnmade) + ) addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget) @@ -244,6 +261,7 @@ ) return future + @asyncio.coroutine def nextCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): @@ -323,15 +341,24 @@ >>> """ + def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): lookupMib, future = cbCtx if future.cancelled(): return - future.set_result( - (errorIndication, errorStatus, errorIndex, [vbProcessor.unmakeVarBinds(snmpEngine, varBindTableRow, lookupMib) for varBindTableRow in varBindTable]) - ) + try: + varBindsUnmade = [vbProcessor.unmakeVarBinds(snmpEngine, + varBindTableRow, + lookupMib) + for varBindTableRow in varBindTable] + except Exception as e: + future.set_exception(e) + else: + future.set_result( + (errorIndication, errorStatus, errorIndex, varBindsUnmade) + ) addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget) @@ -345,6 +372,7 @@ ) return future + @asyncio.coroutine def bulkCmd(snmpEngine, authData, transportTarget, contextData, nonRepeaters, maxRepetitions, *varBinds, **options): @@ -399,13 +427,31 @@ True value indicates SNMP PDU error. errorIndex : int Non-zero value refers to `varBinds[errorIndex-1]` - varBinds : tuple + varBindTable : tuple A sequence of sequences (e.g. 2-D array) of :py:class:`~pysnmp.smi.rfc1902.ObjectType` class instances - representing a table of MIB variables returned in SNMP response. - Inner sequences represent table rows and ordered exactly the same - as `varBinds` in request. Response to GETNEXT always contain - a single row. + representing a table of MIB variables returned in SNMP response, with + up to ``maxRepetitions`` rows, i.e. + ``len(varBindTable) <= maxRepetitions``. + + For ``0 <= i < len(varBindTable)`` and ``0 <= j < len(varBinds)``, + ``varBindTable[i][j]`` represents: + + - For non-repeaters (``j < nonRepeaters``), the first lexicographic + successor of ``varBinds[j]``, regardless the value of ``i``, or an + :py:class:`~pysnmp.smi.rfc1902.ObjectType` instance with the + :py:obj:`~pysnmp.proto.rfc1905.endOfMibView` value if no such + successor exists; + - For repeaters (``j >= nonRepeaters``), the ``i``-th lexicographic + successor of ``varBinds[j]``, or an + :py:class:`~pysnmp.smi.rfc1902.ObjectType` instance with the + :py:obj:`~pysnmp.proto.rfc1905.endOfMibView` value if no such + successor exists. + + See :rfc:`3416#section-4.2.3` for details on the underlying + ``GetBulkRequest-PDU`` and the associated ``GetResponse-PDU``, such as + specific conditions under which the server may truncate the response, + causing ``varBindTable`` to have less than ``maxRepetitions`` rows. Raises ------ @@ -420,7 +466,7 @@ >>> >>> @asyncio.coroutine ... def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = yield from nextCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = yield from bulkCmd( ... SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.snmplabs.com', 161)), @@ -431,19 +477,28 @@ ... print(errorIndication, errorStatus, errorIndex, varBinds) >>> >>> asyncio.get_event_loop().run_until_complete(run()) - (None, 0, 0, [[ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.1.0')), DisplayString('SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m')), ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.2.0')), ObjectIdentifier('1.3.6.1.4.1.424242.1.1')]]) + (None, 0, 0, [[ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.1.0')), DisplayString('SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m'))], [ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.2.0')), ObjectIdentifier('1.3.6.1.4.1.424242.1.1'))]]) >>> """ + def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): lookupMib, future = cbCtx if future.cancelled(): return - future.set_result( - (errorIndication, errorStatus, errorIndex, [vbProcessor.unmakeVarBinds(snmpEngine, varBindTableRow, lookupMib) for varBindTableRow in varBindTable]) - ) + try: + varBindsUnmade = [vbProcessor.unmakeVarBinds(snmpEngine, + varBindTableRow, + lookupMib) + for varBindTableRow in varBindTable] + except Exception as e: + future.set_exception(e) + else: + future.set_result( + (errorIndication, errorStatus, errorIndex, varBindsUnmade) + ) addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget) diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncio/__init__.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncio/__init__.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncio/__init__.py 2015-09-27 10:26:28.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncio/__init__.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,3 +1,9 @@ +# +# This file is part of pysnmp software. +# +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# from pysnmp.proto.rfc1902 import * from pysnmp.smi.rfc1902 import * from pysnmp.entity.engine import * diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncio/ntforg.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncio/ntforg.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncio/ntforg.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncio/ntforg.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # Copyright (C) 2014, Zebra Technologies # Authors: Matt Hooks @@ -15,6 +15,7 @@ from pysnmp.hlapi.varbinds import * from pysnmp.hlapi.asyncio.transport import * from pysnmp.entity.rfc3413 import ntforg + try: import asyncio except ImportError: @@ -25,6 +26,7 @@ vbProcessor = NotificationOriginatorVarBinds() lcd = NotificationOriginatorLcdConfigurator() + @asyncio.coroutine def sendNotification(snmpEngine, authData, transportTarget, contextData, notifyType, varBinds, **options): @@ -115,15 +117,22 @@ >>> """ + def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): lookupMib, future = cbCtx if future.cancelled(): return - future.set_result( - (errorIndication, errorStatus, errorIndex, vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib)) - ) + try: + varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds, + lookupMib) + except Exception as e: + future.set_exception(e) + else: + future.set_result( + (errorIndication, errorStatus, errorIndex, varBindsUnmade) + ) notifyName = lcd.configure( snmpEngine, authData, transportTarget, notifyType diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncio/transport.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncio/transport.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncio/transport.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncio/transport.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,16 +1,18 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -import socket, sys +import socket +import sys from pysnmp.carrier.asyncio.dgram import udp, udp6 from pysnmp.hlapi.transport import AbstractTransportTarget from pysnmp.error import PySnmpError __all__ = ['Udp6TransportTarget', 'UdpTransportTarget'] + class UdpTransportTarget(AbstractTransportTarget): """Creates UDP/IPv4 configuration entry and initialize socket API if needed. @@ -47,6 +49,7 @@ """ transportDomain = udp.domainName protoTransport = udp.UdpAsyncioTransport + def _resolveAddr(self, transportAddr): try: return socket.getaddrinfo(transportAddr[0], @@ -55,7 +58,9 @@ socket.SOCK_DGRAM, socket.IPPROTO_UDP)[0][4][:2] except socket.gaierror: - raise PySnmpError('Bad IPv4/UDP transport address %s: %s' % ('@'.join([str(x) for x in transportAddr]), sys.exc_info()[1])) + raise PySnmpError('Bad IPv4/UDP transport address %s: %s' % ( + '@'.join([str(x) for x in transportAddr]), sys.exc_info()[1])) + class Udp6TransportTarget(AbstractTransportTarget): """Creates UDP/IPv6 configuration entry and initialize socket API if needed. @@ -105,6 +110,7 @@ """ transportDomain = udp6.domainName protoTransport = udp6.Udp6AsyncioTransport + def _resolveAddr(self, transportAddr): try: return socket.getaddrinfo(transportAddr[0], @@ -113,4 +119,5 @@ socket.SOCK_DGRAM, socket.IPPROTO_UDP)[0][4][:2] except socket.gaierror: - raise PySnmpError('Bad IPv6/UDP transport address %s: %s' % ('@'.join([str(x) for x in transportAddr]), sys.exc_info()[1])) + raise PySnmpError('Bad IPv6/UDP transport address %s: %s' % ( + '@'.join([str(x) for x in transportAddr]), sys.exc_info()[1])) diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/cmdgen.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/cmdgen.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/cmdgen.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/cmdgen.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.entity.rfc3413 import cmdgen from pysnmp.smi.rfc1902 import * @@ -19,6 +19,7 @@ isEndOfMib = lambda x: not cmdgen.getNextVarBinds(x)[1] + def getCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): """Performs SNMP GET query. @@ -108,6 +109,7 @@ >>> """ + def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): @@ -129,6 +131,7 @@ options.get('cbFun'), options.get('cbCtx')) ) + def setCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): """Performs SNMP SET query. @@ -218,6 +221,7 @@ >>> """ + def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): @@ -237,6 +241,7 @@ options.get('cbFun'), options.get('cbCtx')) ) + def nextCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): """Performs SNMP GETNEXT query. @@ -328,12 +333,14 @@ >>> """ + def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): lookupMib, cbFun, cbCtx = cbCtx return cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, - [vbProcessor.unmakeVarBinds(snmpEngine, varBindTableRow, lookupMib) for varBindTableRow in varBindTable], + [vbProcessor.unmakeVarBinds(snmpEngine, varBindTableRow, lookupMib) for varBindTableRow in + varBindTable], cbCtx) addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget) @@ -345,6 +352,7 @@ options.get('cbFun'), options.get('cbCtx')) ) + def bulkCmd(snmpEngine, authData, transportTarget, contextData, nonRepeaters, maxRepetitions, *varBinds, **options): """Performs SNMP GETBULK query. @@ -408,12 +416,30 @@ * errorIndication (str): True value indicates SNMP engine error. * errorStatus (str): True value indicates SNMP PDU error. * errorIndex (int): Non-zero value refers to `varBinds[errorIndex-1]` - * varBinds (tuple): A sequence of sequences (e.g. 2-D array) of - :py:class:`~pysnmp.smi.rfc1902.ObjectType` class instances - representing a table of MIB variables returned in SNMP response. - Inner sequences represent table rows and ordered exactly the same - as `varBinds` in request. Number of rows might be less or equal - to `maxRepetitions` value in request. + * varBindTable (tuple): + A sequence of sequences (e.g. 2-D array) of + :py:class:`~pysnmp.smi.rfc1902.ObjectType` class instances representing a + table of MIB variables returned in SNMP response, with up to + ``maxRepetitions`` rows, i.e. ``len(varBindTable) <= maxRepetitions``. + + For ``0 <= i < len(varBindTable)`` and ``0 <= j < len(varBinds)``, + ``varBindTable[i][j]`` represents: + + - For non-repeaters (``j < nonRepeaters``), the first lexicographic + successor of ``varBinds[j]``, regardless the value of ``i``, or an + :py:class:`~pysnmp.smi.rfc1902.ObjectType` instance with the + :py:obj:`~pysnmp.proto.rfc1905.endOfMibView` value if no such successor + exists; + - For repeaters (``j >= nonRepeaters``), the ``i``-th lexicographic + successor of ``varBinds[j]``, or an + :py:class:`~pysnmp.smi.rfc1902.ObjectType` instance with the + :py:obj:`~pysnmp.proto.rfc1905.endOfMibView` value if no such successor + exists. + + See :rfc:`3416#section-4.2.3` for details on the underlying + ``GetBulkRequest-PDU`` and the associated ``GetResponse-PDU``, such as + specific conditions under which the server may truncate the response, + causing ``varBindTable`` to have less than ``maxRepetitions`` rows. * `cbCtx` : Original user-supplied object. Returns @@ -443,16 +469,19 @@ ... ObjectType(ObjectIdentity('SNMPv2-MIB', 'system')), ... cbFun=cbFun) >>> snmpEngine.transportDispatcher.runDispatcher() - (None, 0, 0, [ [ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.1.0')), DisplayString('SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m')), ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.2.0')), ObjectIdentifier('1.3.6.1.4.1.424242.1.1')] ]) + (None, 0, 0, [[ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.1.0')), DisplayString('SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m'))], [ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.2.0')), ObjectIdentifier('1.3.6.1.4.1.424242.1.1'))]]) >>> """ + def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): lookupMib, cbFun, cbCtx = cbCtx return cbFun(snmpEngine, sendRequestHandle, errorIndication, - errorStatus, errorIndex, [vbProcessor.unmakeVarBinds(snmpEngine, varBindTableRow, lookupMib) for varBindTableRow in varBindTable], cbCtx) + errorStatus, errorIndex, + [vbProcessor.unmakeVarBinds(snmpEngine, varBindTableRow, lookupMib) for varBindTableRow in + varBindTable], cbCtx) addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget) return cmdgen.BulkCommandGenerator().sendVarBinds( diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/__init__.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/__init__.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/__init__.py 2015-09-27 10:26:28.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/__init__.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,3 +1,9 @@ +# +# This file is part of pysnmp software. +# +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# from pysnmp.proto.rfc1902 import * from pysnmp.smi.rfc1902 import * from pysnmp.hlapi.auth import * diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/ntforg.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/ntforg.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/ntforg.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/ntforg.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.smi.rfc1902 import * from pysnmp.entity.rfc3413 import ntforg @@ -17,6 +17,7 @@ vbProcessor = NotificationOriginatorVarBinds() lcd = NotificationOriginatorLcdConfigurator() + def sendNotification(snmpEngine, authData, transportTarget, contextData, notifyType, varBinds, cbFun=None, cbCtx=None, lookupMib=False): @@ -46,7 +47,7 @@ Indicates type of notification to be sent. Recognized literal values are *trap* or *inform*. - varBinds: tuple + varBinds : tuple Single :py:class:`~pysnmp.smi.rfc1902.NotificationType` class instance representing a minimum sequence of MIB variables required for particular notification type. Alternatively, @@ -54,15 +55,6 @@ objects could be passed instead. In the latter case it is up to the user to ensure proper Notification PDU contents. - cbInfo : tuple - - * `cbFun` - user-supplied callable that is invoked to pass - SNMP response to *INFORM* notification or error to user at - a later point of time. The `cbFun` callable is never invoked - for *TRAP* notifications. - * `cbCtx` - user-supplied object passing additional parameters - to/from `cbFun`. Default is `None`. - Other Parameters ---------------- cbFun : callable @@ -125,6 +117,8 @@ >>> """ + + # noinspection PyShadowingNames def __cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): lookupMib, cbFun, cbCtx = cbCtx diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/sync/cmdgen.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/sync/cmdgen.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/sync/cmdgen.py 2016-02-13 20:18:36.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/sync/cmdgen.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from sys import version_info from pysnmp.hlapi.asyncore import cmdgen @@ -16,9 +16,11 @@ if version_info[:2] < (2, 6): __all__.append('next') + # noinspection PyShadowingBuiltins def next(iter): return iter.next() + def getCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): """Creates a generator to perform one or more SNMP GET queries. @@ -78,7 +80,7 @@ Examples -------- - >>> from pysnmp.hlapi.asyncore import * + >>> from pysnmp.hlapi import * >>> g = getCmd(SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.snmplabs.com', 161)), @@ -89,6 +91,8 @@ >>> """ + + # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): @@ -121,6 +125,7 @@ if not varBinds: break + def setCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): """Creates a generator to perform one or more SNMP SET queries. @@ -181,7 +186,7 @@ Examples -------- - >>> from pysnmp.hlapi.asyncore import * + >>> from pysnmp.hlapi import * >>> g = setCmd(SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.snmplabs.com', 161)), @@ -192,6 +197,8 @@ >>> """ + + # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): @@ -224,6 +231,7 @@ if not varBinds: break + def nextCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): """Creates a generator to perform one or more SNMP GETNEXT queries. @@ -258,12 +266,14 @@ * `lookupMib` - load MIB and resolve response MIB variables at the cost of slightly reduced performance. Default is `True`. Default is `True`. - * `lexicographicMode` - stop iteration when all response MIB + * `lexicographicMode` - walk SNMP agent's MIB till the end (if `True`), + otherwise (if `False`) stop iteration when all response MIB variables leave the scope of initial MIB variables in `varBinds`. Default is `True`. * `ignoreNonIncreasingOid` - continue iteration even if response MIB variables (OIDs) are not greater then request MIB variables. - Default is `False`. + Be aware that setting it to `True` may cause infinite loop between + SNMP management and agent applications. Default is `False`. * `maxRows` - stop iteration once this generator instance processed `maxRows` of SNMP conceptual table. Default is `0` (no limit). * `maxCalls` - stop iteration once this generator instance processed @@ -297,7 +307,8 @@ * SNMP :py:class:`~pysnmp.proto.rfc1905.EndOfMibView` values (also known as *SNMP exception values*) are reported for all MIB variables in `varBinds` - * *lexicographicMode* option is set to `False` and all + * *lexicographicMode* option is `True` and SNMP agent reports + end-of-mib or *lexicographicMode* is `False` and all response MIB variables leave the scope of `varBinds` At any moment a new sequence of `varBinds` could be send back into @@ -305,7 +316,7 @@ Examples -------- - >>> from pysnmp.hlapi.asyncore import * + >>> from pysnmp.hlapi import * >>> g = nextCmd(SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.snmplabs.com', 161)), @@ -316,6 +327,8 @@ >>> g.send( [ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets')) ] ) (None, 0, 0, [(ObjectName('1.3.6.1.2.1.2.2.1.10.1'), Counter32(284817787))]) """ + + # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): @@ -340,7 +353,7 @@ while True: if varBinds: cmdgen.nextCmd(snmpEngine, authData, transportTarget, contextData, - *[(x[0], Null()) for x in varBinds], + *[(x[0], Null('')) for x in varBinds], **dict(cbFun=cbFun, cbCtx=cbCtx, lookupMib=options.get('lookupMib', True))) @@ -350,12 +363,11 @@ errorStatus = cbCtx['errorStatus'] errorIndex = cbCtx['errorIndex'] - if ignoreNonIncreasingOid and errorIndication and \ - isinstance(errorIndication, errind.OidNotIncreasing): + if ignoreNonIncreasingOid and errorIndication and isinstance(errorIndication, errind.OidNotIncreasing): errorIndication = None if errorIndication: - yield errorIndication, errorStatus, errorIndex, varBinds + yield (errorIndication, errorStatus, errorIndex, varBinds) return elif errorStatus: if errorStatus == 2: @@ -363,7 +375,7 @@ # from SNMPv1 Agent through internal pysnmp proxy. errorStatus = errorStatus.clone(0) errorIndex = errorIndex.clone(0) - yield errorIndication, errorStatus, errorIndex, varBinds + yield (errorIndication, errorStatus, errorIndex, varBinds) return else: varBinds = cbCtx['varBindTable'] and cbCtx['varBindTable'][0] @@ -381,17 +393,19 @@ errorIndication = errorStatus = errorIndex = None varBinds = [] - initialVarBinds = (yield errorIndication, errorStatus,\ - errorIndex, varBinds) + initialVarBinds = (yield errorIndication, errorStatus, errorIndex, varBinds) if initialVarBinds: varBinds = initialVarBinds initialVars = [x[0] for x in vbProcessor.makeVarBinds(snmpEngine, varBinds)] - if maxRows and totalRows >= maxRows or \ - maxCalls and totalCalls >= maxCalls: + if maxRows and totalRows >= maxRows: + return + + if maxCalls and totalCalls >= maxCalls: return + def bulkCmd(snmpEngine, authData, transportTarget, contextData, nonRepeaters, maxRepetitions, *varBinds, **options): """Creates a generator to perform one or more SNMP GETBULK queries. @@ -436,12 +450,14 @@ * `lookupMib` - load MIB and resolve response MIB variables at the cost of slightly reduced performance. Default is `True`. Default is `True`. - * `lexicographicMode` - stop iteration when all response MIB + * `lexicographicMode` - walk SNMP agent's MIB till the end (if `True`), + otherwise (if `False`) stop iteration when all response MIB variables leave the scope of initial MIB variables in `varBinds`. Default is `True`. * `ignoreNonIncreasingOid` - continue iteration even if response MIB variables (OIDs) are not greater then request MIB variables. - Default is `False`. + Be aware that setting it to `True` may cause infinite loop between + SNMP management and agent applications. Default is `False`. * `maxRows` - stop iteration once this generator instance processed `maxRows` of SNMP conceptual table. Default is `0` (no limit). * `maxCalls` - stop iteration once this generator instance processed @@ -475,7 +491,8 @@ * SNMP :py:class:`~pysnmp.proto.rfc1905.EndOfMibView` values (also known as *SNMP exception values*) are reported for all MIB variables in `varBinds` - * *lexicographicMode* option is set to `False` and all + * *lexicographicMode* option is `True` and SNMP agent reports + end-of-mib or *lexicographicMode* is `False` and all response MIB variables leave the scope of `varBinds` At any moment a new sequence of `varBinds` could be send back into @@ -487,7 +504,7 @@ Examples -------- - >>> from pysnmp.hlapi.asyncore import * + >>> from pysnmp.hlapi import * >>> g = bulkCmd(SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.snmplabs.com', 161)), @@ -499,6 +516,8 @@ >>> g.send( [ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets')) ] ) (None, 0, 0, [(ObjectName('1.3.6.1.2.1.2.2.1.10.1'), Counter32(284817787))]) """ + + # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): @@ -524,11 +543,11 @@ while not stopFlag: if maxRows and totalRows < maxRows: - maxRepetitions = min(maxRepetitions, maxRows-totalRows) + maxRepetitions = min(maxRepetitions, maxRows - totalRows) cmdgen.bulkCmd(snmpEngine, authData, transportTarget, contextData, nonRepeaters, maxRepetitions, - *[(x[0], Null()) for x in varBinds], + *[(x[0], Null('')) for x in varBinds], **dict(cbFun=cbFun, cbCtx=cbCtx, lookupMib=options.get('lookupMib', True))) @@ -544,8 +563,8 @@ errorIndication = None if errorIndication: - yield errorIndication, errorStatus, errorIndex, \ - varBindTable and varBindTable[0] or [] + yield (errorIndication, errorStatus, errorIndex, + varBindTable and varBindTable[0] or []) if errorIndication != errind.requestTimedOut: return elif errorStatus: @@ -554,29 +573,27 @@ # from SNMPv1 Agent through internal pysnmp proxy. errorStatus = errorStatus.clone(0) errorIndex = errorIndex.clone(0) - yield errorIndication, errorStatus, errorIndex, \ - varBindTable and varBindTable[0] or [] + yield (errorIndication, errorStatus, errorIndex, varBindTable and varBindTable[0] or []) return else: - for i in range(len(varBindTable)): + for row in range(len(varBindTable)): stopFlag = True - if len(varBindTable[i]) != len(initialVars): - varBindTable = i and varBindTable[:i-1] or [] + if len(varBindTable[row]) != len(initialVars): + varBindTable = row and varBindTable[:row - 1] or [] break - for j in range(len(varBindTable[i])): - name, val = varBindTable[i][j] - if nullVarBinds[j]: - varBindTable[i][j] = name, endOfMibView + for col in range(len(varBindTable[row])): + name, val = varBindTable[row][col] + if nullVarBinds[col]: + varBindTable[row][col] = name, endOfMibView continue stopFlag = False if isinstance(val, Null): - nullVarBinds[j] = True - elif not lexicographicMode and \ - not initialVars[j].isPrefixOf(name): - varBindTable[i][j] = name, endOfMibView - nullVarBinds[j] = True + nullVarBinds[col] = True + elif not lexicographicMode and not initialVars[col].isPrefixOf(name): + varBindTable[row][col] = name, endOfMibView + nullVarBinds[col] = True if stopFlag: - varBindTable = i and varBindTable[:i-1] or [] + varBindTable = row and varBindTable[:row - 1] or [] break totalRows += len(varBindTable) @@ -584,15 +601,14 @@ if maxRows and totalRows >= maxRows: if totalRows > maxRows: - varBindTable = varBindTable[:-(totalRows-maxRows)] + varBindTable = varBindTable[:-(totalRows - maxRows)] stopFlag = True if maxCalls and totalCalls >= maxCalls: stopFlag = True for varBinds in varBindTable: - initialVarBinds = (yield errorIndication, errorStatus,\ - errorIndex, varBinds) + initialVarBinds = (yield errorIndication, errorStatus, errorIndex, varBinds) if initialVarBinds: varBinds = initialVarBinds diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/sync/compat/cmdgen.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/sync/compat/cmdgen.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/sync/compat/cmdgen.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/sync/compat/cmdgen.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # This is a Python 2.6- version of the same file at level up # @@ -14,12 +14,14 @@ __all__ = ['getCmd', 'nextCmd', 'setCmd', 'bulkCmd', 'next'] + +# noinspection PyShadowingBuiltins def next(iter): return iter.next() def getCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): - + # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): @@ -48,9 +50,10 @@ yield errorIndication, errorStatus, errorIndex, varBinds + def setCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): - + # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): @@ -69,16 +72,17 @@ snmpEngine.transportDispatcher.runDispatcher() - yield cbCtx['errorIndication'], \ - cbCtx['errorStatus'], cbCtx['errorIndex'], \ - cbCtx['varBinds'] + yield (cbCtx['errorIndication'], + cbCtx['errorStatus'], cbCtx['errorIndex'], + cbCtx['varBinds']) if cbCtx['errorIndication'] != errind.requestTimedOut: break + def nextCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): - + # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): @@ -102,7 +106,7 @@ while True: cmdgen.nextCmd(snmpEngine, authData, transportTarget, contextData, - *[(x[0], Null()) for x in varBinds], + *[(x[0], Null('')) for x in varBinds], **dict(cbFun=cbFun, cbCtx=cbCtx, lookupMib=options.get('lookupMib', True))) @@ -113,7 +117,7 @@ errorIndex = cbCtx['errorIndex'] if ignoreNonIncreasingOid and errorIndication and \ - isinstance(errorIndication, errind.OidNotIncreasing): + isinstance(errorIndication, errind.OidNotIncreasing): errorIndication = None if errorIndication: @@ -144,12 +148,13 @@ yield errorIndication, errorStatus, errorIndex, varBinds if maxRows and totalRows >= maxRows or \ - maxCalls and totalCalls >= maxCalls: + maxCalls and totalCalls >= maxCalls: return + def bulkCmd(snmpEngine, authData, transportTarget, contextData, nonRepeaters, maxRepetitions, *varBinds, **options): - + # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): @@ -175,11 +180,11 @@ while not stopFlag: if maxRows and totalRows < maxRows: - maxRepetitions = min(maxRepetitions, maxRows-totalRows) + maxRepetitions = min(maxRepetitions, maxRows - totalRows) cmdgen.bulkCmd(snmpEngine, authData, transportTarget, contextData, nonRepeaters, maxRepetitions, - *[(x[0], Null()) for x in varBinds], + *[(x[0], Null('')) for x in varBinds], **dict(cbFun=cbFun, cbCtx=cbCtx, lookupMib=options.get('lookupMib', True))) @@ -195,8 +200,8 @@ errorIndication = None if errorIndication: - yield errorIndication, errorStatus, errorIndex, \ - varBindTable and varBindTable[0] or [] + yield (errorIndication, errorStatus, errorIndex, + varBindTable and varBindTable[0] or []) if errorIndication != errind.requestTimedOut: return elif errorStatus: @@ -205,14 +210,14 @@ # from SNMPv1 Agent through internal pysnmp proxy. errorStatus = errorStatus.clone(0) errorIndex = errorIndex.clone(0) - yield errorIndication, errorStatus, errorIndex, \ - varBindTable and varBindTable[0] or [] + yield (errorIndication, errorStatus, errorIndex, + varBindTable and varBindTable[0] or []) return else: for i in range(len(varBindTable)): stopFlag = True if len(varBindTable[i]) != len(initialVars): - varBindTable = i and varBindTable[:i-1] or [] + varBindTable = i and varBindTable[:i - 1] or [] break for j in range(len(varBindTable[i])): name, val = varBindTable[i][j] @@ -223,11 +228,11 @@ if isinstance(val, Null): nullVarBinds[j] = True elif not lexicographicMode and \ - not initialVars[j].isPrefixOf(name): + not initialVars[j].isPrefixOf(name): varBindTable[i][j] = name, endOfMibView nullVarBinds[j] = True if stopFlag: - varBindTable = i and varBindTable[:i-1] or [] + varBindTable = i and varBindTable[:i - 1] or [] break totalRows += len(varBindTable) @@ -235,7 +240,7 @@ if maxRows and totalRows >= maxRows: if totalRows > maxRows: - varBindTable = varBindTable[:-(totalRows-maxRows)] + varBindTable = varBindTable[:-(totalRows - maxRows)] stopFlag = True if maxCalls and totalCalls >= maxCalls: diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/sync/compat/ntforg.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/sync/compat/ntforg.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/sync/compat/ntforg.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/sync/compat/ntforg.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # # This is a Python 2.6- version of the same file at level up # @@ -10,16 +10,19 @@ __all__ = ['sendNotification', 'next'] + +# noinspection PyShadowingBuiltins def next(iter): return iter.next() + # # Synchronous one-liner SNMP Notification Originator application # def sendNotification(snmpEngine, authData, transportTarget, contextData, notifyType, varBinds, **options): - + # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/sync/__init__.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/sync/__init__.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/sync/__init__.py 2015-09-27 11:32:11.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/sync/__init__.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,3 +1,9 @@ +# +# This file is part of pysnmp software. +# +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# from pysnmp.proto.rfc1902 import * from pysnmp.smi.rfc1902 import * from pysnmp.hlapi.auth import * diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/sync/ntforg.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/sync/ntforg.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/sync/ntforg.py 2016-02-13 20:19:27.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/sync/ntforg.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from sys import version_info from pysnmp.hlapi.asyncore import ntforg @@ -12,9 +12,11 @@ if version_info[:2] < (2, 6): __all__.append('next') + # noinspection PyShadowingBuiltins def next(iter): return iter.next() + def sendNotification(snmpEngine, authData, transportTarget, contextData, notifyType, varBinds, **options): """Creates a generator to send one or more SNMP notifications. @@ -84,7 +86,7 @@ Examples -------- - >>> from pysnmp.hlapi.asyncore import * + >>> from pysnmp.hlapi import * >>> g = sendNotification(SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.snmplabs.com', 162)), @@ -96,6 +98,8 @@ >>> """ + + # noinspection PyShadowingNames def cbFun(snmpEngine, sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx): diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/transport.py python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/transport.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/asyncore/transport.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/asyncore/transport.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,16 +1,18 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -import socket, sys +import socket +import sys from pysnmp.carrier.asyncore.dgram import udp, udp6, unix from pysnmp.hlapi.transport import AbstractTransportTarget from pysnmp import error __all__ = ['UnixTransportTarget', 'Udp6TransportTarget', 'UdpTransportTarget'] + class UdpTransportTarget(AbstractTransportTarget): """Creates UDP/IPv4 configuration entry and initialize socket API if needed. @@ -22,20 +24,21 @@ Parameters ---------- - transportAddr : tuple + transportAddr: :py:class:`tuple` Indicates remote address in Python :py:mod:`socket` module format which is a tuple of FQDN, port where FQDN is a string representing either hostname or IPv4 address in quad-dotted form, port is an integer. - timeout : int + timeout: :py:class:`int` Response timeout in seconds. - retries : int + retries: :py:class:`int` Maximum number of request retries, 0 retries means just a single request. - tagList : str - Arbitrary string that contains a list of tag values which are used - to select target addresses for a particular operation - (:RFC:`3413#section-4.1.4`). + tagList: :py:class:`str` + Arbitrary string that contains a list of space-separated tag + strings used to select target addresses and/or SNMP configuration + (see :RFC:`3413#section-4.1.1`, :RFC:`2576#section-5.3` and + :py:class:`~pysnmp.hlapi.CommunityData` object). Examples -------- @@ -47,6 +50,7 @@ """ transportDomain = udp.domainName protoTransport = udp.UdpSocketTransport + def _resolveAddr(self, transportAddr): try: return socket.getaddrinfo(transportAddr[0], @@ -55,7 +59,9 @@ socket.SOCK_DGRAM, socket.IPPROTO_UDP)[0][4][:2] except socket.gaierror: - raise error.PySnmpError('Bad IPv4/UDP transport address %s: %s' % ('@'.join([str(x) for x in transportAddr]), sys.exc_info()[1])) + raise error.PySnmpError('Bad IPv4/UDP transport address %s: %s' % ( + '@'.join([str(x) for x in transportAddr]), sys.exc_info()[1])) + class Udp6TransportTarget(AbstractTransportTarget): """Creates UDP/IPv6 configuration entry and initialize socket API if needed. @@ -102,6 +108,7 @@ """ transportDomain = udp6.domainName protoTransport = udp6.Udp6SocketTransport + def _resolveAddr(self, transportAddr): try: return socket.getaddrinfo(transportAddr[0], @@ -110,7 +117,9 @@ socket.SOCK_DGRAM, socket.IPPROTO_UDP)[0][4][:2] except socket.gaierror: - raise error.PySnmpError('Bad IPv6/UDP transport address %s: %s' % ('@'.join([str(x) for x in transportAddr]), sys.exc_info()[1])) + raise error.PySnmpError('Bad IPv6/UDP transport address %s: %s' % ( + '@'.join([str(x) for x in transportAddr]), sys.exc_info()[1])) + class UnixTransportTarget(AbstractTransportTarget): transportDomain = unix.domainName diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/auth.py python-pysnmp4-4.4.3/pysnmp/hlapi/auth.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/auth.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/auth.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.entity import config from pysnmp import error @@ -11,11 +11,15 @@ __all__ = ['CommunityData', 'UsmUserData', 'usm3DESEDEPrivProtocol', 'usmAesCfb128Protocol', 'usmAesCfb192Protocol', 'usmAesCfb256Protocol', + 'usmAesBlumenthalCfb192Protocol', 'usmAesBlumenthalCfb256Protocol', 'usmDESPrivProtocol', 'usmHMACMD5AuthProtocol', - 'usmHMACSHAAuthProtocol', 'usmNoAuthProtocol', + 'usmHMACSHAAuthProtocol', 'usmHMAC128SHA224AuthProtocol', + 'usmHMAC192SHA256AuthProtocol', 'usmHMAC256SHA384AuthProtocol', + 'usmHMAC384SHA512AuthProtocol', 'usmNoAuthProtocol', 'usmNoPrivProtocol'] -class CommunityData: + +class CommunityData(object): """Creates SNMP v1/v2c configuration entry. This object can be used by @@ -30,24 +34,51 @@ Parameters ---------- - communityIndex : str + communityIndex: py:class:`str` Unique index value of a row in snmpCommunityTable. If it is the - only positional parameter, it is taken as *communityName*. - communityName : str + only positional parameter, it is treated as a *communityName*. + communityName: py:class:`str` SNMP v1/v2c community string. - mpModel : int + mpModel: py:class:`int` SNMP version - 0 for SNMPv1 and 1 for SNMPv2c. - contextEngineId : str + contextEngineId: py:class:`str` Indicates the location of the context in which management information is accessed when using the community string specified by the above communityName. - contextName : str + contextName: py:class:`str` The context in which management information is accessed when using the above communityName. - tag : str + tag: py:class:`str` Arbitrary string that specifies a set of transport endpoints - to which a notification may be sent using communityName above - (see also :RFC:`3413#section-4.1.4`). + from which a command responder application will accept + management requests with given *communityName* or to which + notification originator application will send notifications + when targets are specified by a tag value(s). + + The other way to look at the *tag* feature is that it can make + specific *communityName* only valid for certain targets. + + The other use-case is when multiple distinct SNMP peers share + the same *communityName* -- binding each instance of + *communityName* to transport endpoint lets you distinguish + SNMP peers from each other (e.g. resolving *communityName* into + proper *securityName*). + + For more technical information on SNMP configuration tags please + refer to :RFC:`3413#section-4.1.1` and :RFC:`2576#section-5.3` + (e.g. the *snmpCommunityTransportTag* object). + + See also: :py:class:`~pysnmp.hlapi.UdpTransportTarget` + + Warnings + -------- + If the same *communityIndex* value is supplied repeatedly with + different *communityName* (or other parameters), the later call + supersedes all previous calls. + + Make sure not to configure duplicate *communityName* values unless + they have distinct *mpModel* and/or *tag* fields. This will make + *communityName* based database lookup ambiguous. Examples -------- @@ -59,11 +90,12 @@ >>> """ - mpModel = 1 # Default is SMIv2 + mpModel = 1 # Default is SMIv2 securityModel = mpModel + 1 securityLevel = 'noAuthNoPriv' contextName = null tag = null + def __init__(self, communityIndex, communityName=None, mpModel=None, contextEngineId=None, contextName=None, tag=None, securityName=None): @@ -119,12 +151,18 @@ securityName is None and self.securityName or securityName ) + #: No Authentication Protocol. usmNoAuthProtocol = config.usmNoAuthProtocol #: The HMAC-MD5-96 Digest Authentication Protocol (:RFC:`3414#section-6`) usmHMACMD5AuthProtocol = config.usmHMACMD5AuthProtocol #: The HMAC-SHA-96 Digest Authentication Protocol (:RFC:`3414#section-7`) usmHMACSHAAuthProtocol = config.usmHMACSHAAuthProtocol +#: The HMAC-SHA-2 Digest Authentication Protocols (:RFC:`7860`) +usmHMAC128SHA224AuthProtocol = config.usmHMAC128SHA224AuthProtocol +usmHMAC192SHA256AuthProtocol = config.usmHMAC192SHA256AuthProtocol +usmHMAC256SHA384AuthProtocol = config.usmHMAC256SHA384AuthProtocol +usmHMAC384SHA512AuthProtocol = config.usmHMAC384SHA512AuthProtocol #: No Privacy Protocol. usmNoPrivProtocol = config.usmNoPrivProtocol @@ -134,12 +172,17 @@ usm3DESEDEPrivProtocol = config.usm3DESEDEPrivProtocol #: The CFB128-AES-128 Symmetric Encryption Protocol (:RFC:`3826#section-3`) usmAesCfb128Protocol = config.usmAesCfb128Protocol -#: The CFB128-AES-192 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 `_) +#: The CFB128-AES-192 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 `_) with Reeder key localization usmAesCfb192Protocol = config.usmAesCfb192Protocol -#: The CFB128-AES-256 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 `_) +#: The CFB128-AES-256 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 `_) with Reeder key localization usmAesCfb256Protocol = config.usmAesCfb256Protocol +#: The CFB128-AES-192 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 `_) +usmAesBlumenthalCfb192Protocol = config.usmAesBlumenthalCfb192Protocol +#: The CFB128-AES-256 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 `_) +usmAesBlumenthalCfb256Protocol = config.usmAesBlumenthalCfb256Protocol -class UsmUserData: + +class UsmUserData(object): """Creates SNMP v3 User Security Model (USM) configuration entry. This object can be used by @@ -154,21 +197,21 @@ Parameters ---------- - userName : str + userName: py:class:`str` A human readable string representing the name of the SNMP USM user. - authKey : str + authKey: py:class:`str` Initial value of the secret authentication key. If not set, :py:class:`~pysnmp.hlapi.usmNoAuthProtocol` is implied. If set and no *authProtocol* is specified, :py:class:`~pysnmp.hlapi.usmHMACMD5AuthProtocol` takes effect. - privKey : str + privKey: py:class:`str` Initial value of the secret encryption key. If not set, :py:class:`~pysnmp.hlapi.usmNoPrivProtocol` is implied. If set and no *privProtocol* is specified, :py:class:`~pysnmp.hlapi.usmDESPrivProtocol` takes effect. - authProtocol : tuple + authProtocol: py:class:`tuple` An indication of whether messages sent on behalf of this USM user can be authenticated, and if so, the type of authentication protocol which is used. @@ -178,7 +221,11 @@ * :py:class:`~pysnmp.hlapi.usmNoAuthProtocol` (default is *authKey* not given) * :py:class:`~pysnmp.hlapi.usmHMACMD5AuthProtocol` (default if *authKey* is given) * :py:class:`~pysnmp.hlapi.usmHMACSHAAuthProtocol` - privProtocol : tuple + * :py:class:`~pysnmp.hlapi.usmHMAC128SHA224AuthProtocol` + * :py:class:`~pysnmp.hlapi.usmHMAC192SHA256AuthProtocol` + * :py:class:`~pysnmp.hlapi.usmHMAC256SHA384AuthProtocol` + * :py:class:`~pysnmp.hlapi.usmHMAC384SHA512AuthProtocol` + privProtocol: py:class:`tuple` An indication of whether messages sent on behalf of this USM user be encrypted, and if so, the type of encryption protocol which is used. @@ -208,16 +255,11 @@ securityModel = 3 mpModel = 3 contextName = null - # the contextEngineId/contextName values stored here should - # be used for USM configuration only, not for PDU contents + def __init__(self, userName, authKey=None, privKey=None, authProtocol=None, privProtocol=None, securityEngineId=None, - # deprecated parameters begin - contextName=None, - contextEngineId=None, - # deprecated parameters end securityName=None): self.userName = userName if securityName is None: @@ -244,20 +286,13 @@ else: self.privProtocol = privProtocol - # the contextEngineId parameter is actually a securityEngineId - if securityEngineId is None: - securityEngineId = contextEngineId - self.contextEngineId = self.securityEngineId = securityEngineId - - # the contextName parameter should never be used here - if contextName is not None: - self.contextName = contextName + self.securityEngineId = securityEngineId def __hash__(self): raise TypeError('%s is not hashable' % self.__class__.__name__) def __repr__(self): - return '%s(userName=%r, authKey=, privKey=, authProtocol=%r, privProtocol=%r, securityEngineId=%r, securityName=%r)'%( + return '%s(userName=%r, authKey=, privKey=, authProtocol=%r, privProtocol=%r, securityEngineId=%r, securityName=%r)' % ( self.__class__.__name__, self.userName, self.authProtocol, diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/context.py python-pysnmp4-4.4.3/pysnmp/hlapi/context.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/context.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/context.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,14 +1,15 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.compat.octets import null __all__ = ['ContextData'] -class ContextData: + +class ContextData(object): """Creates UDP/IPv6 configuration entry and initialize socket API if needed. This object can be used by @@ -44,6 +45,7 @@ ContextData(contextEngineId=None, contextName='mycontext') """ + def __init__(self, contextEngineId=None, contextName=null): self.contextEngineId = contextEngineId self.contextName = contextName diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/__init__.py python-pysnmp4-4.4.3/pysnmp/hlapi/__init__.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/__init__.py 2015-09-27 11:32:11.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/__init__.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,4 +1,11 @@ +# +# This file is part of pysnmp software. +# +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# from pysnmp.proto.rfc1902 import * +from pysnmp.proto.rfc1905 import NoSuchInstance, NoSuchObject, EndOfMibView from pysnmp.smi.rfc1902 import * from pysnmp.hlapi.auth import * from pysnmp.hlapi.context import * diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/lcd.py python-pysnmp4-4.4.3/pysnmp/hlapi/lcd.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/lcd.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/lcd.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.entity import config from pysnmp import nextid, error @@ -11,9 +11,11 @@ __all__ = ['CommandGeneratorLcdConfigurator', 'NotificationOriginatorLcdConfigurator'] -class AbstractLcdConfigurator: + +class AbstractLcdConfigurator(object): nextID = nextid.Integer(0xffffffff) cacheKeys = [] + def _getCache(self, snmpEngine): cacheId = self.__class__.__name__ cache = snmpEngine.getUserContext(cacheId) @@ -22,15 +24,17 @@ snmpEngine.setUserContext(**{cacheId: cache}) return cache - def configure(self, snmpEngine, authData, transportTarget): + def configure(self, snmpEngine, authData, transportTarget, *options): pass def unconfigure(self, snmpEngine, authData=None): pass + class CommandGeneratorLcdConfigurator(AbstractLcdConfigurator): cacheKeys = ['auth', 'parm', 'tran', 'addr'] - def configure(self, snmpEngine, authData, transportTarget): + + def configure(self, snmpEngine, authData, transportTarget, *options): cache = self._getCache(snmpEngine) if isinstance(authData, CommunityData): if authData.communityIndex not in cache['auth']: @@ -59,9 +63,9 @@ else: raise error.PySnmpError('Unsupported authentication object') - paramsKey = authData.securityName, \ - authData.securityLevel, \ - authData.mpModel + paramsKey = (authData.securityName, + authData.securityLevel, + authData.mpModel) if paramsKey in cache['parm']: paramsName, useCount = cache['parm'][paramsKey] cache['parm'][paramsKey] = paramsName, useCount + 1 @@ -145,9 +149,9 @@ else: raise error.PySnmpError('Unsupported authentication object') - paramsKey = authDataX.securityName, \ - authDataX.securityLevel, \ - authDataX.mpModel + paramsKey = (authDataX.securityName, + authDataX.securityLevel, + authDataX.mpModel) if paramsKey in cache['parm']: paramsName, useCount = cache['parm'][paramsKey] useCount -= 1 @@ -186,11 +190,15 @@ return addrNames, paramsNames + class NotificationOriginatorLcdConfigurator(AbstractLcdConfigurator): cacheKeys = ['auth', 'name'] _cmdGenLcdCfg = CommandGeneratorLcdConfigurator() - def configure(self, snmpEngine, authData, transportTarget, notifyType): + + def configure(self, snmpEngine, authData, transportTarget, *options): cache = self._getCache(snmpEngine) + notifyType = options and options[0] or 'trap' + notifyName = None # Create matching transport tags if not given by user. Not good! if not transportTarget.tagList: @@ -220,7 +228,7 @@ ) cache['name'][notifyNameKey] = notifyName, paramsName, 1 authDataKey = authData.securityName, authData.securityModel - if authDataKey in cache['auth']: + if authDataKey in cache['auth']: authDataX, subTree, useCount = cache['auth'][authDataKey] cache['auth'][authDataKey] = authDataX, subTree, useCount + 1 else: diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/transport.py python-pysnmp4-4.4.3/pysnmp/hlapi/transport.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/transport.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/transport.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.compat.octets import null from pysnmp.carrier.base import AbstractTransport @@ -10,15 +10,18 @@ __all__ = [] -class AbstractTransportTarget: + +class AbstractTransportTarget(object): transportDomain = None protoTransport = AbstractTransport + def __init__(self, transportAddr, timeout=1, retries=5, tagList=null): self.transportAddr = self._resolveAddr(transportAddr) self.timeout = timeout self.retries = retries self.tagList = tagList self.iface = None + self.transport = None def __repr__(self): return '%s(%r, timeout=%r, retries=%r, tagList=%r)' % ( @@ -30,6 +33,19 @@ return self.transportDomain, self.transportAddr def setLocalAddress(self, iface): + """Set source address. + + Parameters + ---------- + iface : tuple + Indicates network address of a local interface from which SNMP packets will be originated. + Format is the same as of `transportAddress`. + + Returns + ------- + self + + """ self.iface = iface return self @@ -39,7 +55,8 @@ def verifyDispatcherCompatibility(self, snmpEngine): if not self.protoTransport.isCompatibleWithDispatcher(snmpEngine.transportDispatcher): - raise error.PySnmpError('Transport %r is not compatible with dispatcher %r' % (self.protoTransport, snmpEngine.transportDispatcher)) + raise error.PySnmpError('Transport %r is not compatible with dispatcher %r' % ( + self.protoTransport, snmpEngine.transportDispatcher)) def _resolveAddr(self, transportAddr): raise NotImplementedError() diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/twisted/cmdgen.py python-pysnmp4-4.4.3/pysnmp/hlapi/twisted/cmdgen.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/twisted/cmdgen.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/twisted/cmdgen.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.smi.rfc1902 import * from pysnmp.hlapi.auth import * @@ -11,6 +11,7 @@ from pysnmp.hlapi.varbinds import * from pysnmp.hlapi.twisted.transport import * from pysnmp.entity.rfc3413 import cmdgen +from pysnmp.proto import errind from twisted.internet.defer import Deferred from twisted.python.failure import Failure @@ -88,7 +89,8 @@ >>> from twisted.internet.task import react >>> from pysnmp.hlapi.twisted import * >>> - >>> def success((errorStatus, errorIndex, varBinds)): + >>> def success(args): + ... (errorStatus, errorIndex, varBinds) = args ... print(errorStatus, errorIndex, varBind) ... >>> def failure(errorIndication): @@ -115,10 +117,14 @@ if errorIndication: deferred.errback(Failure(errorIndication)) else: - deferred.callback( - (errorStatus, errorIndex, - vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib)) - ) + try: + varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib) + + except Exception as e: + deferred.errback(Failure(e)) + + else: + deferred.callback((errorStatus, errorIndex, varBindsUnmade)) addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget) @@ -199,7 +205,8 @@ >>> from twisted.internet.task import react >>> from pysnmp.hlapi.twisted import * >>> - >>> def success((errorStatus, errorIndex, varBinds)): + >>> def success(args): + ... (errorStatus, errorIndex, varBinds) = args ... print(errorStatus, errorIndex, varBind) ... >>> def failure(errorIndication): @@ -226,10 +233,14 @@ if errorIndication: deferred.errback(Failure(errorIndication)) else: - deferred.callback( - (errorStatus, errorIndex, - vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib)) - ) + try: + varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib) + + except Exception as e: + deferred.errback(Failure(e)) + + else: + deferred.callback((errorStatus, errorIndex, varBindsUnmade)) addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget) @@ -276,6 +287,10 @@ * `lookupMib` - load MIB and resolve response MIB variables at the cost of slightly reduced performance. Default is `True`. + * `ignoreNonIncreasingOid` - continue iteration even if response + MIB variables (OIDs) are not greater then request MIB variables. + Be aware that setting it to `True` may cause infinite loop between + SNMP management and agent applications. Default is `False`. Returns ------- @@ -314,7 +329,8 @@ >>> from twisted.internet.task import react >>> from pysnmp.hlapi.twisted import * >>> - >>> def success((errorStatus, errorIndex, varBindTable)): + >>> def success(args): + ... (errorStatus, errorIndex, varBindTable) = args ... print(errorStatus, errorIndex, varBindTable) ... >>> def failure(errorIndication): @@ -338,13 +354,23 @@ errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): lookupMib, deferred = cbCtx + if (options.get('ignoreNonIncreasingOid', False) and + errorIndication and isinstance(errorIndication, errind.OidNotIncreasing)): + errorIndication = None if errorIndication: deferred.errback(Failure(errorIndication)) else: - deferred.callback( - (errorStatus, errorIndex, - [vbProcessor.unmakeVarBinds(snmpEngine, varBindTableRow, lookupMib) for varBindTableRow in varBindTable]) - ) + try: + varBindsUnmade = [vbProcessor.unmakeVarBinds(snmpEngine, + varBindTableRow, + lookupMib) + for varBindTableRow in varBindTable] + + except Exception as e: + deferred.errback(Failure(e)) + + else: + deferred.callback((errorStatus, errorIndex, varBindsUnmade)) addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget) @@ -401,6 +427,10 @@ * `lookupMib` - load MIB and resolve response MIB variables at the cost of slightly reduced performance. Default is `True`. + * `ignoreNonIncreasingOid` - continue iteration even if response + MIB variables (OIDs) are not greater then request MIB variables. + Be aware that setting it to `True` may cause infinite loop between + SNMP management and agent applications. Default is `False`. Returns ------- @@ -423,13 +453,30 @@ * errorStatus (str) : True value indicates SNMP PDU error. * errorIndex (int) : Non-zero value refers to `varBinds[errorIndex-1]` - * varBinds (tuple) : - A sequence of sequences (e.g. 2-D array) of - :py:class:`~pysnmp.smi.rfc1902.ObjectType` class instances - representing a table of MIB variables returned in SNMP response. - Inner sequences represent table rows and ordered exactly the same - as `varBinds` in request. Number of rows might be less or equal - to `maxRepetitions` value in request. + * varBindTable (tuple): + A sequence of sequences (e.g. 2-D array) of + :py:class:`~pysnmp.smi.rfc1902.ObjectType` class instances representing a + table of MIB variables returned in SNMP response, with up to + ``maxRepetitions`` rows, i.e. ``len(varBindTable) <= maxRepetitions``. + + For ``0 <= i < len(varBindTable)`` and ``0 <= j < len(varBinds)``, + ``varBindTable[i][j]`` represents: + + - For non-repeaters (``j < nonRepeaters``), the first lexicographic + successor of ``varBinds[j]``, regardless the value of ``i``, or an + :py:class:`~pysnmp.smi.rfc1902.ObjectType` instance with the + :py:obj:`~pysnmp.proto.rfc1905.endOfMibView` value if no such successor + exists; + - For repeaters (``j >= nonRepeaters``), the ``i``-th lexicographic + successor of ``varBinds[j]``, or an + :py:class:`~pysnmp.smi.rfc1902.ObjectType` instance with the + :py:obj:`~pysnmp.proto.rfc1905.endOfMibView` value if no such successor + exists. + + See :rfc:`3416#section-4.2.3` for details on the underlying + ``GetBulkRequest-PDU`` and the associated ``GetResponse-PDU``, such as + specific conditions under which the server may truncate the response, + causing ``varBindTable`` to have less than ``maxRepetitions`` rows. User `error` callback is called with `errorIndication` object wrapped in :class:`~twisted.python.failure.Failure` object. @@ -439,7 +486,8 @@ >>> from twisted.internet.task import react >>> from pysnmp.hlapi.twisted import * >>> - >>> def success((errorStatus, errorIndex, varBindTable)): + >>> def success(args): + ... (errorStatus, errorIndex, varBindTable) = args ... print(errorStatus, errorIndex, varBindTable) ... >>> def failure(errorIndication): @@ -456,7 +504,7 @@ ... return d ... >>> react(run) - (0, 0, [[ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.1.0')), DisplayString('SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m')), ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.2.0')), ObjectIdentifier('1.3.6.1.4.1.424242.1.1')]]) + (0, 0, [[ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.1.0')), DisplayString('SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m'))], [ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.2.0')), ObjectIdentifier('1.3.6.1.4.1.424242.1.1'))]]) >>> """ @@ -464,13 +512,23 @@ errorIndication, errorStatus, errorIndex, varBindTable, cbCtx): lookupMib, deferred = cbCtx + if options.get('ignoreNonIncreasingOid', False) and errorIndication and \ + isinstance(errorIndication, errind.OidNotIncreasing): + errorIndication = None if errorIndication: deferred.errback(Failure(errorIndication)) else: - deferred.callback( - (errorStatus, errorIndex, - [vbProcessor.unmakeVarBinds(snmpEngine, varBindTableRow, lookupMib) for varBindTableRow in varBindTable]) - ) + try: + varBindsUnmade = [vbProcessor.unmakeVarBinds(snmpEngine, + varBindTableRow, + lookupMib) + for varBindTableRow in varBindTable] + + except Exception as e: + deferred.errback(Failure(e)) + + else: + deferred.callback((errorStatus, errorIndex, varBindsUnmade)) addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget) diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/twisted/ntforg.py python-pysnmp4-4.4.3/pysnmp/hlapi/twisted/ntforg.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/twisted/ntforg.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/twisted/ntforg.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.smi.rfc1902 import * from pysnmp.hlapi.auth import * @@ -95,7 +95,8 @@ >>> from twisted.internet.task import react >>> from pysnmp.hlapi.twisted import * >>> - >>> def success((errorStatus, errorIndex, varBinds)): + >>> def success(args): + ... (errorStatus, errorIndex, varBinds) = args ... print(errorStatus, errorIndex, varBind) ... >>> def failure(errorIndication): @@ -120,13 +121,18 @@ errorIndication, errorStatus, errorIndex, varBinds, cbCtx): lookupMib, deferred = cbCtx + if errorIndication: deferred.errback(Failure(errorIndication)) else: - deferred.callback( - (errorStatus, errorIndex, - vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib)) - ) + try: + varBindsUnmade = vbProcessor.unmakeVarBinds(snmpEngine, varBinds, lookupMib) + + except Exception as e: + deferred.errback(Failure(e)) + + else: + deferred.callback((errorStatus, errorIndex, varBindsUnmade)) notifyName = lcd.configure( snmpEngine, authData, transportTarget, notifyType diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/twisted/transport.py python-pysnmp4-4.4.3/pysnmp/hlapi/twisted/transport.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/twisted/transport.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/twisted/transport.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import socket, sys from pysnmp.carrier.twisted.dgram import udp diff -Nru python-pysnmp4-4.3.2/pysnmp/hlapi/varbinds.py python-pysnmp4-4.4.3/pysnmp/hlapi/varbinds.py --- python-pysnmp4-4.3.2/pysnmp/hlapi/varbinds.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/hlapi/varbinds.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,16 +1,18 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.smi import view from pysnmp.smi.rfc1902 import * __all__ = ['CommandGeneratorVarBinds', 'NotificationOriginatorVarBinds'] -class AbstractVarBinds: - def getMibViewController(self, snmpEngine): + +class AbstractVarBinds(object): + @staticmethod + def getMibViewController(snmpEngine): mibViewController = snmpEngine.getUserContext('mibViewController') if not mibViewController: mibViewController = view.MibViewController( @@ -19,6 +21,7 @@ snmpEngine.setUserContext(mibViewController=mibViewController) return mibViewController + class CommandGeneratorVarBinds(AbstractVarBinds): def makeVarBinds(self, snmpEngine, varBinds): mibViewController = self.getMibViewController(snmpEngine) @@ -44,6 +47,7 @@ return varBinds + class NotificationOriginatorVarBinds(AbstractVarBinds): def makeVarBinds(self, snmpEngine, varBinds): mibViewController = self.getMibViewController(snmpEngine) @@ -65,4 +69,3 @@ mibViewController = self.getMibViewController(snmpEngine) varBinds = [ObjectType(ObjectIdentity(x[0]), x[1]).resolveWithMib(mibViewController) for x in varBinds] return varBinds - diff -Nru python-pysnmp4-4.3.2/pysnmp/__init__.py python-pysnmp4-4.4.3/pysnmp/__init__.py --- python-pysnmp4-4.3.2/pysnmp/__init__.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/__init__.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,5 +1,5 @@ # http://www.python.org/dev/peps/pep-0396/ -__version__ = '4.3.2' +__version__ = '4.4.3' # backward compatibility version = tuple([int(x) for x in __version__.split('.')]) majorVersionId = version[0] diff -Nru python-pysnmp4-4.3.2/pysnmp/nextid.py python-pysnmp4-4.4.3/pysnmp/nextid.py --- python-pysnmp4-4.3.2/pysnmp/nextid.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/nextid.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,30 +1,32 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import random random.seed() -class Integer: + +class Integer(object): """Return a next value in a reasonably MT-safe manner""" + def __init__(self, maximum, increment=256): self.__maximum = maximum if increment >= maximum: increment = maximum self.__increment = increment - self.__threshold = increment//2 + self.__threshold = increment // 2 e = random.randrange(self.__maximum - self.__increment) - self.__bank = list(range(e, e+self.__increment)) + self.__bank = list(range(e, e + self.__increment)) def __repr__(self): return '%s(%d, %d)' % ( self.__class__.__name__, self.__maximum, self.__increment - ) + ) def __call__(self): v = self.__bank.pop(0) @@ -33,8 +35,8 @@ else: # this is MT-safe unless too many (~ increment/2) threads # bump into this code simultaneously - e = self.__bank[-1]+1 + e = self.__bank[-1] + 1 if e > self.__maximum: e = 0 - self.__bank.extend(range(e, e+self.__threshold)) + self.__bank.extend(range(e, e + self.__threshold)) return v diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/acmod/rfc3415.py python-pysnmp4-4.4.3/pysnmp/proto/acmod/rfc3415.py --- python-pysnmp4-4.3.2/pysnmp/proto/acmod/rfc3415.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/acmod/rfc3415.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.smi.error import NoSuchInstanceError from pysnmp.proto import errind, error @@ -10,10 +10,12 @@ __powOfTwoSeq = [128, 64, 32, 16, 8, 4, 2, 1] + # 3.2 -class Vacm: +class Vacm(object): """View-based Access Control Model""" accessModelID = 3 + def isAccessAllowed(self, snmpEngine, securityModel, @@ -24,7 +26,9 @@ variableName): mibInstrumController = snmpEngine.msgAndPduDsp.mibInstrumController - debug.logger & debug.flagACL and debug.logger('isAccessAllowed: securityModel %s, securityName %s, securityLevel %s, viewType %s, contextName %s for variableName %s' % (securityModel, securityName, securityLevel, viewType, contextName, variableName)) + debug.logger & debug.flagACL and debug.logger( + 'isAccessAllowed: securityModel %s, securityName %s, securityLevel %s, viewType %s, contextName %s for variableName %s' % ( + securityModel, securityName, securityLevel, viewType, contextName, variableName)) # 3.2.1 vacmContextEntry, = mibInstrumController.mibBuilder.importSymbols('SNMP-VIEW-BASED-ACM-MIB', 'vacmContextEntry') @@ -37,7 +41,8 @@ raise error.StatusInformation(errorIndication=errind.noSuchContext) # 3.2.2 - vacmSecurityToGroupEntry, = mibInstrumController.mibBuilder.importSymbols('SNMP-VIEW-BASED-ACM-MIB', 'vacmSecurityToGroupEntry') + vacmSecurityToGroupEntry, = mibInstrumController.mibBuilder.importSymbols('SNMP-VIEW-BASED-ACM-MIB', + 'vacmSecurityToGroupEntry') tblIdx = vacmSecurityToGroupEntry.getInstIdFromIndices( securityModel, securityName ) @@ -77,7 +82,8 @@ # XXX split onto object & instance ? # 3.2.5a - vacmViewTreeFamilyEntry, = mibInstrumController.mibBuilder.importSymbols('SNMP-VIEW-BASED-ACM-MIB', 'vacmViewTreeFamilyEntry') + vacmViewTreeFamilyEntry, = mibInstrumController.mibBuilder.importSymbols('SNMP-VIEW-BASED-ACM-MIB', + 'vacmViewTreeFamilyEntry') tblIdx = vacmViewTreeFamilyEntry.getInstIdFromIndices(viewName) # Walk over entries @@ -101,18 +107,18 @@ if vacmViewTreeFamilyMask.syntax: mask = [] for c in vacmViewTreeFamilyMask.syntax.asNumbers(): - mask = mask + [b&c for b in __powOfTwoSeq] - m = len(mask)-1 - idx = l-1 + mask = mask + [b & c for b in __powOfTwoSeq] + m = len(mask) - 1 + idx = l - 1 while idx: if idx > m or mask[idx] and \ - vacmViewTreeFamilySubtree.syntax[idx] != variableName[idx]: + vacmViewTreeFamilySubtree.syntax[idx] != variableName[idx]: break - idx = idx - 1 + idx -= 1 if idx: - continue # no match - else: # no mask + continue # no match + else: # no mask if vacmViewTreeFamilySubtree.syntax != variableName[:l]: - continue # no match + continue # no match # 3.2.5c return error.StatusInformation(errorIndication=errind.accessAllowed) diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/acmod/void.py python-pysnmp4-4.4.3/pysnmp/proto/acmod/void.py --- python-pysnmp4-4.3.2/pysnmp/proto/acmod/void.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/acmod/void.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,16 +1,19 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto import errind, error from pysnmp import debug + # rfc3415 3.2 -class Vacm: +# noinspection PyUnusedLocal +class Vacm(object): """Void Access Control Model""" accessModelID = 0 + def isAccessAllowed(self, snmpEngine, securityModel, @@ -19,8 +22,9 @@ viewType, contextName, variableName): - - debug.logger & debug.flagACL and debug.logger('isAccessAllowed: viewType %s for variableName %s - OK' % (viewType, variableName)) + debug.logger & debug.flagACL and debug.logger( + 'isAccessAllowed: viewType %s for variableName %s - OK' % (viewType, variableName) + ) # rfc3415 3.2.5c return error.StatusInformation(errorIndication=errind.accessAllowed) diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/api/__init__.py python-pysnmp4-4.4.3/pysnmp/proto/api/__init__.py --- python-pysnmp4-4.3.2/pysnmp/proto/api/__init__.py 2015-10-17 20:07:37.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/api/__init__.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,3 +1,9 @@ +# +# This file is part of pysnmp software. +# +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# from pysnmp.proto.api import v1, v2c, verdec # Protocol versions diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/api/v1.py python-pysnmp4-4.4.3/pysnmp/proto/api/v1.py --- python-pysnmp4-4.3.2/pysnmp/proto/api/v1.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/api/v1.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.type import univ from pysnmp.proto import rfc1155, rfc1157, error @@ -31,50 +31,61 @@ TrapPDU = rfc1157.TrapPDU Message = rfc1157.Message -class VarBindAPI: - def setOIDVal(self, varBind, oidVal): - (oid, val) = oidVal + +class VarBindAPI(object): + @staticmethod + def setOIDVal(varBind, oidVal): + oid, val = oidVal[0], oidVal[1] varBind.setComponentByPosition(0, oid) if val is None: val = null - varBind.setComponentByPosition(1).getComponentByPosition(1).setComponentByType(val.getTagSet(), val, 1, verifyConstraints=False) + varBind.setComponentByPosition(1).getComponentByPosition(1).setComponentByType(val.getTagSet(), val, verifyConstraints=False, matchTags=False, matchConstraints=False, innerFlag=True) return varBind - def getOIDVal(self, varBind): + @staticmethod + def getOIDVal(varBind): return varBind[0], varBind[1].getComponent(1) + apiVarBind = VarBindAPI() getNextRequestID = nextid.Integer(0xffffff) -class PDUAPI: - _errorStatus = rfc1157._errorStatus.clone(0) + +class PDUAPI(object): + _errorStatus = rfc1157.errorStatus.clone(0) _errorIndex = Integer(0) + def setDefaults(self, pdu): pdu.setComponentByPosition( - 0, getNextRequestID(), verifyConstraints=False + 0, getNextRequestID(), verifyConstraints=False, matchTags=False, matchConstraints=False ) pdu.setComponentByPosition( - 1, self._errorStatus, verifyConstraints=False + 1, self._errorStatus, verifyConstraints=False, matchTags=False, matchConstraints=False ) pdu.setComponentByPosition( - 2, self._errorIndex, verifyConstraints=False + 2, self._errorIndex, verifyConstraints=False, matchTags=False, matchConstraints=False ) pdu.setComponentByPosition(3) - def getRequestID(self, pdu): + @staticmethod + def getRequestID(pdu): return pdu.getComponentByPosition(0) - def setRequestID(self, pdu, value): + @staticmethod + def setRequestID(pdu, value): pdu.setComponentByPosition(0, value) - def getErrorStatus(self, pdu): + @staticmethod + def getErrorStatus(pdu): return pdu.getComponentByPosition(1) - def setErrorStatus(self, pdu, value): + @staticmethod + def setErrorStatus(pdu, value): pdu.setComponentByPosition(1, value) - def getErrorIndex(self, pdu, muteErrors=False): + @staticmethod + def getErrorIndex(pdu, muteErrors=False): errorIndex = pdu.getComponentByPosition(2) if errorIndex > len(pdu[3]): if muteErrors: @@ -84,7 +95,8 @@ ) return errorIndex - def setErrorIndex(self, pdu, value): + @staticmethod + def setErrorIndex(pdu, value): pdu.setComponentByPosition(2, value) def setEndOfMibError(self, pdu, errorIndex): @@ -94,23 +106,23 @@ def setNoSuchInstanceError(self, pdu, errorIndex): self.setEndOfMibError(pdu, errorIndex) - def getVarBindList(self, pdu): + @staticmethod + def getVarBindList(pdu): return pdu.getComponentByPosition(3) - def setVarBindList(self, pdu, varBindList): - varBindList = pdu.setComponentByPosition(3, varBindList) - - def getVarBinds(self, pdu): - varBinds = [] - for varBind in pdu.getComponentByPosition(3): - varBinds.append(apiVarBind.getOIDVal(varBind)) - return varBinds + @staticmethod + def setVarBindList(pdu, varBindList): + pdu.setComponentByPosition(3, varBindList) + + @staticmethod + def getVarBinds(pdu): + return [apiVarBind.getOIDVal(varBind) for varBind in pdu.getComponentByPosition(3)] - def setVarBinds(self, pdu, varBinds): + @staticmethod + def setVarBinds(pdu, varBinds): varBindList = pdu.setComponentByPosition(3).getComponentByPosition(3) varBindList.clear() - idx = 0 - for varBind in varBinds: + for idx, varBind in enumerate(varBinds): if isinstance(varBind, VarBind): varBindList.setComponentByPosition(idx, varBind) else: @@ -118,7 +130,6 @@ apiVarBind.setOIDVal( varBindList.getComponentByPosition(idx), varBind ) - idx += 1 def getResponse(self, reqPDU): rspPDU = GetResponsePDU() @@ -135,72 +146,89 @@ else: return [apiPDU.getVarBinds(rspPDU)] + apiPDU = PDUAPI() -class TrapPDUAPI: + +class TrapPDUAPI(object): _networkAddress = None _entOid = ObjectIdentifier((1, 3, 6, 1, 4, 1, 20408)) - _genericTrap = rfc1157._genericTrap.clone('coldStart') + _genericTrap = rfc1157.genericTrap.clone('coldStart') _zeroInt = univ.Integer(0) _zeroTime = TimeTicks(0) + def setDefaults(self, pdu): if self._networkAddress is None: try: import socket agentAddress = IpAddress(socket.gethostbyname(socket.gethostname())) - except: + except Exception: agentAddress = IpAddress('0.0.0.0') - self._networkAddress = NetworkAddress().setComponentByPosition(0, agentAddress) - pdu.setComponentByPosition(0, self._entOid, verifyConstraints=False) - pdu.setComponentByPosition(1, self._networkAddress, verifyConstraints=False) - pdu.setComponentByPosition(2, self._genericTrap, verifyConstraints=False) - pdu.setComponentByPosition(3, self._zeroInt, verifyConstraints=False) - pdu.setComponentByPosition(4, self._zeroTime, verifyConstraints=False) + self._networkAddress = NetworkAddress().setComponentByPosition(0, agentAddress) + pdu.setComponentByPosition(0, self._entOid, verifyConstraints=False, matchTags=False, matchConstraints=False) + pdu.setComponentByPosition(1, self._networkAddress, verifyConstraints=False, matchTags=False, matchConstraints=False) + pdu.setComponentByPosition(2, self._genericTrap, verifyConstraints=False, matchTags=False, matchConstraints=False) + pdu.setComponentByPosition(3, self._zeroInt, verifyConstraints=False, matchTags=False, matchConstraints=False) + pdu.setComponentByPosition(4, self._zeroTime, verifyConstraints=False, matchTags=False, matchConstraints=False) pdu.setComponentByPosition(5) - def getEnterprise(self, pdu): + @staticmethod + def getEnterprise(pdu): return pdu.getComponentByPosition(0) - def setEnterprise(self, pdu, value): + @staticmethod + def setEnterprise(pdu, value): pdu.setComponentByPosition(0, value) - def getAgentAddr(self, pdu): + @staticmethod + def getAgentAddr(pdu): return pdu.getComponentByPosition(1).getComponentByPosition(0) - def setAgentAddr(self, pdu, value): + @staticmethod + def setAgentAddr(pdu, value): pdu.setComponentByPosition(1).getComponentByPosition(1).setComponentByPosition(0, value) - def getGenericTrap(self, pdu): + @staticmethod + def getGenericTrap(pdu): return pdu.getComponentByPosition(2) - def setGenericTrap(self, pdu, value): + @staticmethod + def setGenericTrap(pdu, value): pdu.setComponentByPosition(2, value) - def getSpecificTrap(self, pdu): + @staticmethod + def getSpecificTrap(pdu): return pdu.getComponentByPosition(3) - def setSpecificTrap(self, pdu, value): + @staticmethod + def setSpecificTrap(pdu, value): pdu.setComponentByPosition(3, value) - def getTimeStamp(self, pdu): + @staticmethod + def getTimeStamp(pdu): return pdu.getComponentByPosition(4) - def setTimeStamp(self, pdu, value): + @staticmethod + def setTimeStamp(pdu, value): pdu.setComponentByPosition(4, value) - def getVarBindList(self, pdu): + @staticmethod + def getVarBindList(pdu): return pdu.getComponentByPosition(5) - def setVarBindList(self, pdu, varBindList): - varBindList = pdu.setComponentByPosition(5, varBindList) + @staticmethod + def setVarBindList(pdu, varBindList): + pdu.setComponentByPosition(5, varBindList) - def getVarBinds(self, pdu): + @staticmethod + def getVarBinds(pdu): varBinds = [] for varBind in pdu.getComponentByPosition(5): varBinds.append(apiVarBind.getOIDVal(varBind)) return varBinds - def setVarBinds(self, pdu, varBinds): + @staticmethod + def setVarBinds(pdu, varBinds): varBindList = pdu.setComponentByPosition(5).getComponentByPosition(5) varBindList.clear() idx = 0 @@ -211,36 +239,45 @@ varBindList.setComponentByPosition(idx) apiVarBind.setOIDVal( varBindList.getComponentByPosition(idx), varBind - ) - idx = idx + 1 + ) + idx += 1 + apiTrapPDU = TrapPDUAPI() -class MessageAPI: - _version = rfc1157._version.clone(0) + +class MessageAPI(object): + _version = rfc1157.version.clone(0) _community = univ.OctetString('public') + def setDefaults(self, msg): - msg.setComponentByPosition(0, self._version, verifyConstraints=False) - msg.setComponentByPosition(1, self._community, verifyConstraints=False) + msg.setComponentByPosition(0, self._version, verifyConstraints=False, matchTags=False, matchConstraints=False) + msg.setComponentByPosition(1, self._community, verifyConstraints=False, matchTags=False, matchConstraints=False) return msg - def getVersion(self, msg): + @staticmethod + def getVersion(msg): return msg.getComponentByPosition(0) - def setVersion(self, msg, value): + @staticmethod + def setVersion(msg, value): msg.setComponentByPosition(0, value) - def getCommunity(self, msg): + @staticmethod + def getCommunity(msg): return msg.getComponentByPosition(1) - def setCommunity(self, msg, value): + @staticmethod + def setCommunity(msg, value): msg.setComponentByPosition(1, value) - def getPDU(self, msg): + @staticmethod + def getPDU(msg): return msg.getComponentByPosition(2).getComponent() - def setPDU(self, msg, value): - msg.setComponentByPosition(2).getComponentByPosition(2).setComponentByType(value.getTagSet(), value, 1, verifyConstraints=False) + @staticmethod + def setPDU(msg, value): + msg.setComponentByPosition(2).getComponentByPosition(2).setComponentByType(value.getTagSet(), value, verifyConstraints=False, matchTags=False, matchConstraints=False, innerFlag=True) def getResponse(self, reqMsg): rspMsg = Message() @@ -250,4 +287,5 @@ self.setPDU(rspMsg, apiPDU.getResponse(self.getPDU(reqMsg))) return rspMsg + apiMessage = MessageAPI() diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/api/v2c.py python-pysnmp4-4.4.3/pysnmp/proto/api/v2c.py --- python-pysnmp4-4.3.2/pysnmp/proto/api/v2c.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/api/v2c.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto import rfc1901, rfc1902, rfc1905 from pysnmp.proto.api import v1 @@ -46,8 +46,9 @@ apiVarBind = v1.apiVarBind + class PDUAPI(v1.PDUAPI): - _errorStatus = rfc1905._errorStatus.clone(0) + _errorStatus = rfc1905.errorStatus.clone(0) _errorIndex = univ.Integer(0).subtype(subtypeSpec=constraint.ValueRangeConstraint(0, rfc1905.max_bindings)) def getResponse(self, reqPDU): @@ -61,62 +62,68 @@ def setEndOfMibError(self, pdu, errorIndex): varBindList = self.getVarBindList(pdu) - varBindList[errorIndex-1].setComponentByPosition( - 1, rfc1905.endOfMibView, verifyConstraints=False + varBindList[errorIndex - 1].setComponentByPosition( + 1, rfc1905.endOfMibView, verifyConstraints=False, matchTags=False, matchConstraints=False ) def setNoSuchInstanceError(self, pdu, errorIndex): varBindList = self.getVarBindList(pdu) - varBindList[errorIndex-1].setComponentByPosition( - 1, rfc1905.noSuchInstance, verifyConstraints=False + varBindList[errorIndex - 1].setComponentByPosition( + 1, rfc1905.noSuchInstance, verifyConstraints=False, matchTags=False, matchConstraints=False ) + apiPDU = PDUAPI() + class BulkPDUAPI(PDUAPI): - _nonRepeaters = rfc1905._nonRepeaters.clone(0) - _maxRepetitions = rfc1905._maxRepetitions.clone(10) + _nonRepeaters = rfc1905.nonRepeaters.clone(0) + _maxRepetitions = rfc1905.maxRepetitions.clone(10) + def setDefaults(self, pdu): PDUAPI.setDefaults(self, pdu) pdu.setComponentByPosition( - 0, getNextRequestID(), verifyConstraints=False + 0, getNextRequestID(), verifyConstraints=False, matchTags=False, matchConstraints=False ) pdu.setComponentByPosition( - 1, self._nonRepeaters, verifyConstraints=False + 1, self._nonRepeaters, verifyConstraints=False, matchTags=False, matchConstraints=False ) pdu.setComponentByPosition( - 2, self._maxRepetitions, verifyConstraints=False + 2, self._maxRepetitions, verifyConstraints=False, matchTags=False, matchConstraints=False ) pdu.setComponentByPosition(3) - def getNonRepeaters(self, pdu): + @staticmethod + def getNonRepeaters(pdu): return pdu.getComponentByPosition(1) - def setNonRepeaters(self, pdu, value): + @staticmethod + def setNonRepeaters(pdu, value): pdu.setComponentByPosition(1, value) - def getMaxRepetitions(self, pdu): + @staticmethod + def getMaxRepetitions(pdu): return pdu.getComponentByPosition(2) - def setMaxRepetitions(self, pdu, value): + @staticmethod + def setMaxRepetitions(pdu, value): pdu.setComponentByPosition(2, value) def getVarBindTable(self, reqPDU, rspPDU): nonRepeaters = self.getNonRepeaters(reqPDU) - maxRepetitions = self.getMaxRepetitions(reqPDU) reqVarBinds = self.getVarBinds(reqPDU) N = min(int(nonRepeaters), len(reqVarBinds)) - R = max(len(reqVarBinds)-N, 0) + R = max(len(reqVarBinds) - N, 0) rspVarBinds = self.getVarBinds(rspPDU) varBindTable = [] if R: - for i in range(0, len(rspVarBinds)-N, R): - varBindRow = rspVarBinds[:N] + rspVarBinds[N+i:N+R+i] + for i in range(0, len(rspVarBinds) - N, R): + varBindRow = rspVarBinds[:N] + rspVarBinds[N + i:N + R + i] # ignore stray OIDs / non-rectangular table if len(varBindRow) == N + R: varBindTable.append(varBindRow) @@ -125,8 +132,10 @@ return varBindTable + apiBulkPDU = BulkPDUAPI() + class TrapPDUAPI(v1.PDUAPI): sysUpTime = (1, 3, 6, 1, 2, 1, 1, 3, 0) snmpTrapAddress = (1, 3, 6, 1, 6, 3, 18, 1, 3, 0) @@ -135,6 +144,7 @@ snmpTrapEnterprise = (1, 3, 6, 1, 6, 3, 1, 1, 4, 3, 0) _zeroTime = TimeTicks(0) _genTrap = ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1)) + def setDefaults(self, pdu): v1.PDUAPI.setDefaults(self, pdu) varBinds = [(self.sysUpTime, self._zeroTime), @@ -142,13 +152,16 @@ (self.snmpTrapOID, self._genTrap)] self.setVarBinds(pdu, varBinds) + apiTrapPDU = TrapPDUAPI() + class MessageAPI(v1.MessageAPI): - _version = rfc1901._version.clone(1) + _version = rfc1901.version.clone(1) + def setDefaults(self, msg): - msg.setComponentByPosition(0, self._version, verifyConstraints=False) - msg.setComponentByPosition(1, self._community, verifyConstraints=False) + msg.setComponentByPosition(0, self._version, verifyConstraints=False, matchTags=False, matchConstraints=False) + msg.setComponentByPosition(1, self._community, verifyConstraints=False, matchTags=False, matchConstraints=False) return msg def getResponse(self, reqMsg): @@ -159,4 +172,5 @@ self.setPDU(rspMsg, apiPDU.getResponse(self.getPDU(reqMsg))) return rspMsg + apiMessage = MessageAPI() diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/api/verdec.py python-pysnmp4-4.4.3/pysnmp/proto/api/verdec.py --- python-pysnmp4-4.3.2/pysnmp/proto/api/verdec.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/api/verdec.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,21 +1,24 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.type import univ from pyasn1.codec.ber import decoder, eoo from pyasn1.error import PyAsn1Error from pysnmp.proto.error import ProtocolError + def decodeMessageVersion(wholeMsg): try: seq, wholeMsg = decoder.decode( - wholeMsg, asn1Spec=univ.Sequence(), recursiveFlag=0 + wholeMsg, asn1Spec=univ.Sequence(), + recursiveFlag=False, substrateFun=lambda a, b, c: (a, b[:c]) ) ver, wholeMsg = decoder.decode( - wholeMsg, asn1Spec=univ.Integer(), recursiveFlag=0 + wholeMsg, asn1Spec=univ.Integer(), + recursiveFlag=False, substrateFun=lambda a, b, c: (a, b[:c]) ) if eoo.endOfOctets.isSameTypeWith(ver): raise ProtocolError('EOO at SNMP version component') diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/cache.py python-pysnmp4-4.4.3/pysnmp/proto/cache.py --- python-pysnmp4-4.3.2/pysnmp/proto/cache.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/cache.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,12 +1,13 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto import error -class Cache: + +class Cache(object): def __init__(self): self.__cacheRepository = {} @@ -26,7 +27,7 @@ if index not in self.__cacheRepository: raise error.ProtocolError( 'Cache miss on update for %s' % kwargs - ) + ) self.__cacheRepository[index].update(kwargs) def expire(self, cbFun, cbCtx): diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/errind.py python-pysnmp4-4.4.3/pysnmp/proto/errind.py --- python-pysnmp4-4.3.2/pysnmp/proto/errind.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/errind.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,11 +1,14 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -class ErrorIndication: + + +class ErrorIndication(Exception): """SNMPv3 error-indication values""" + def __init__(self, descr=None): self.__value = self.__descr = self.__class__.__name__[0].lower() + self.__class__.__name__[1:] if descr: @@ -32,6 +35,7 @@ def __str__(self): return self.__descr + # SNMP message processing errors class SerializationError(ErrorIndication): @@ -39,76 +43,91 @@ serializationError = SerializationError('SNMP message serialization error') + class DeserializationError(ErrorIndication): pass deserializationError = DeserializationError('SNMP message deserialization error') + class ParseError(DeserializationError): pass parseError = ParseError('SNMP message deserialization error') + class UnsupportedMsgProcessingModel(ErrorIndication): pass unsupportedMsgProcessingModel = UnsupportedMsgProcessingModel('Unknown SNMP message processing model ID encountered') + class UnknownPDUHandler(ErrorIndication): pass unknownPDUHandler = UnknownPDUHandler('Unhandled PDU type encountered') + class UnsupportedPDUtype(ErrorIndication): pass unsupportedPDUtype = UnsupportedPDUtype('Unsupported SNMP PDU type encountered') + class RequestTimedOut(ErrorIndication): pass requestTimedOut = RequestTimedOut('No SNMP response received before timeout') + class EmptyResponse(ErrorIndication): pass emptyResponse = EmptyResponse('Empty SNMP response message') + class NonReportable(ErrorIndication): pass nonReportable = NonReportable('Report PDU generation not attempted') + class DataMismatch(ErrorIndication): pass dataMismatch = DataMismatch('SNMP request/response parameters mismatched') + class EngineIDMismatch(ErrorIndication): pass engineIDMismatch = EngineIDMismatch('SNMP engine ID mismatch encountered') + class UnknownEngineID(ErrorIndication): pass unknownEngineID = UnknownEngineID('Unknown SNMP engine ID encountered') + class TooBig(ErrorIndication): pass tooBig = TooBig('SNMP message will be too big') + class LoopTerminated(ErrorIndication): pass loopTerminated = LoopTerminated('Infinite SNMP entities talk terminated') + class InvalidMsg(ErrorIndication): pass invalidMsg = InvalidMsg('Invalid SNMP message header parameters encountered') + # SNMP security modules errors class UnknownCommunityName(ErrorIndication): @@ -116,66 +135,100 @@ unknownCommunityName = UnknownCommunityName('Unknown SNMP community name encountered') + class NoEncryption(ErrorIndication): pass noEncryption = NoEncryption('No encryption services configured') + class EncryptionError(ErrorIndication): pass encryptionError = EncryptionError('Ciphering services not available') + class DecryptionError(ErrorIndication): pass decryptionError = DecryptionError('Ciphering services not available or ciphertext is broken') + class NoAuthentication(ErrorIndication): pass noAuthentication = NoAuthentication('No authentication services configured') + class AuthenticationError(ErrorIndication): pass authenticationError = AuthenticationError('Ciphering services not available or bad parameters') + class AuthenticationFailure(ErrorIndication): pass authenticationFailure = AuthenticationFailure('Authenticator mismatched') + class UnsupportedAuthProtocol(ErrorIndication): pass unsupportedAuthProtocol = UnsupportedAuthProtocol('Authentication protocol is not supprted') + class UnsupportedPrivProtocol(ErrorIndication): pass unsupportedPrivProtocol = UnsupportedPrivProtocol('Privacy protocol is not supprted') + class UnknownSecurityName(ErrorIndication): pass unknownSecurityName = UnknownSecurityName('Unknown SNMP security name encountered') + class UnsupportedSecurityModel(ErrorIndication): pass unsupportedSecurityModel = UnsupportedSecurityModel('Unsupported SNMP security model') + class UnsupportedSecurityLevel(ErrorIndication): pass +# backward compatibility plug +UnsupportedSecLevel = UnsupportedSecurityLevel + unsupportedSecurityLevel = UnsupportedSecurityLevel('Unsupported SNMP security level') + class NotInTimeWindow(ErrorIndication): pass notInTimeWindow = NotInTimeWindow('SNMP message timing parameters not in windows of trust') + +class UnknownUserName(ErrorIndication): + pass + +unknownUserName = UnknownUserName('Unknown USM user') + + +class WrongDigest(ErrorIndication): + pass + +wrongDigest = WrongDigest('Wrong SNMP PDU digest') + + +class ReportPduReceived(ErrorIndication): + pass + +reportPduReceived = ReportPduReceived('Remote SNMP engine reported error') + + # SNMP access-control errors class NoSuchView(ErrorIndication): @@ -183,39 +236,46 @@ noSuchView = NoSuchView('No such MIB view currently exists') + class NoAccessEntry(ErrorIndication): pass noAccessEntry = NoAccessEntry('Access to MIB node denined') + class NoGroupName(ErrorIndication): pass noGroupName = NoGroupName('No such VACM group configured') + class NoSuchContext(ErrorIndication): pass noSuchContext = NoSuchContext('SNMP context now found') + class NotInView(ErrorIndication): pass notInView = NotInView('Requested OID is out of MIB view') + class AccessAllowed(ErrorIndication): pass accessAllowed = AccessAllowed() + class OtherError(ErrorIndication): pass otherError = OtherError('Unspecified SNMP engine error occurred') + # SNMP Apps errors class OidNotIncreasing(ErrorIndication): pass -oidNotIncreasing = OidNotIncreasing('OIDs are not increasing') +oidNotIncreasing = OidNotIncreasing('OID not increasing') diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/error.py python-pysnmp4-4.4.3/pysnmp/proto/error.py --- python-pysnmp4-4.3.2/pysnmp/proto/error.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/error.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,26 +1,30 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.error import PyAsn1Error from pysnmp.error import PySnmpError from pysnmp import debug + class ProtocolError(PySnmpError, PyAsn1Error): pass + # SNMP v3 exceptions class SnmpV3Error(ProtocolError): pass + class StatusInformation(SnmpV3Error): def __init__(self, **kwargs): SnmpV3Error.__init__(self) self.__errorIndication = kwargs - debug.logger & (debug.flagDsp|debug.flagMP|debug.flagSM|debug.flagACL) and debug.logger('StatusInformation: %s' % kwargs) + debug.logger & (debug.flagDsp | debug.flagMP | debug.flagSM | debug.flagACL) and debug.logger( + 'StatusInformation: %s' % kwargs) def __str__(self): return str(self.__errorIndication) @@ -34,14 +38,18 @@ def get(self, key, defVal=None): return self.__errorIndication.get(key, defVal) + class CacheExpiredError(SnmpV3Error): pass + class InternalError(SnmpV3Error): pass + class MessageProcessingError(SnmpV3Error): pass + class RequestTimeout(SnmpV3Error): pass diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/mpmod/base.py python-pysnmp4-4.4.3/pysnmp/proto/mpmod/base.py --- python-pysnmp4-4.3.2/pysnmp/proto/mpmod/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/mpmod/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,14 +1,16 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto.mpmod import cache from pysnmp.proto import error -class AbstractMessageProcessingModel: + +class AbstractMessageProcessingModel(object): snmpMsgSpec = NotImplementedError + def __init__(self): self._snmpMsgSpec = self.snmpMsgSpec() # local copy self._cache = cache.Cache() @@ -35,7 +37,7 @@ try: self._cache.popBySendPduHandle(sendPduHandle) except error.ProtocolError: - pass # XXX maybe these should all follow some scheme? + pass # XXX maybe these should all follow some scheme? def receiveTimerTick(self, snmpEngine, timeNow): self._cache.expireCaches() diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/mpmod/cache.py python-pysnmp4-4.4.3/pysnmp/proto/mpmod/cache.py --- python-pysnmp4-4.3.2/pysnmp/proto/mpmod/cache.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/mpmod/cache.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,15 +1,17 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto import error from pysnmp import nextid -class Cache: + +class Cache(object): __stateReference = nextid.Integer(0xffffff) __msgID = nextid.Integer(0xffffff) + def __init__(self): self.__msgIdIndex = {} self.__stateReferenceIndex = {} @@ -26,7 +28,7 @@ def pushByStateRef(self, stateReference, **msgInfo): if stateReference in self.__stateReferenceIndex: raise error.ProtocolError('Cache dup for stateReference=%s at %s' % (stateReference, self)) - expireAt = self.__expirationTimer+600 + expireAt = self.__expirationTimer + 600 self.__stateReferenceIndex[stateReference] = msgInfo, expireAt # Schedule to expire @@ -56,7 +58,7 @@ raise error.ProtocolError( 'Cache dup for msgId=%s at %s' % (msgId, self) ) - expireAt = self.__expirationTimer+600 + expireAt = self.__expirationTimer + 600 self.__msgIdIndex[msgId] = msgInfo, expireAt self.__sendPduHandleIdx[msgInfo['sendPduHandle']] = msgId diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/mpmod/rfc2576.py python-pysnmp4-4.4.3/pysnmp/proto/mpmod/rfc2576.py --- python-pysnmp4-4.3.2/pysnmp/proto/mpmod/rfc2576.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/mpmod/rfc2576.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from pyasn1.codec.ber import decoder, eoo @@ -14,29 +14,33 @@ from pysnmp.proto.api import v1, v2c from pysnmp import debug + # Since I have not found a detailed reference to v1MP/v2cMP # inner workings, the following has been patterned from v3MP. Most # references here goes to RFC3412. class SnmpV1MessageProcessingModel(AbstractMessageProcessingModel): - messageProcessingModelID = univ.Integer(0) # SNMPv1 + messageProcessingModelID = univ.Integer(0) # SNMPv1 snmpMsgSpec = v1.Message + # rfc3412: 7.1 def prepareOutgoingMessage(self, snmpEngine, transportDomain, transportAddress, messageProcessingModel, securityModel, securityName, securityLevel, contextEngineId, contextName, pduVersion, pdu, expectResponse, sendPduHandle): - snmpEngineId, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + + snmpEngineId, = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') snmpEngineId = snmpEngineId.syntax # rfc3412: 7.1.1b if pdu.tagSet in rfc3411.confirmedClassPDUs: # serve unique PDU request-id - pdu.setComponentByPosition(1) msgID = self._cache.newMsgID() reqID = pdu.getComponentByPosition(0) - debug.logger & debug.flagMP and debug.logger('prepareOutgoingMessage: PDU request-id %s replaced with unique ID %s' % (reqID, msgID)) + debug.logger & debug.flagMP and debug.logger( + 'prepareOutgoingMessage: PDU request-id %s replaced with unique ID %s' % (reqID, msgID)) # rfc3412: 7.1.4 # Since there's no SNMP engine identification in v1/2c, @@ -48,7 +52,8 @@ if not contextName: contextName = null - debug.logger & debug.flagMP and debug.logger('prepareOutgoingMessage: using contextEngineId %r contextName %r' % (contextEngineId, contextName)) + debug.logger & debug.flagMP and debug.logger( + 'prepareOutgoingMessage: using contextEngineId %r contextName %r' % (contextEngineId, contextName)) # rfc3412: 7.1.6 scopedPDU = (contextEngineId, contextName, pdu) @@ -57,7 +62,7 @@ msg.setComponentByPosition(0, self.messageProcessingModelID) msg.setComponentByPosition(2) msg.getComponentByPosition(2).setComponentByType( - pdu.tagSet, pdu, verifyConstraints=False + pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False ) # rfc3412: 7.1.7 @@ -73,22 +78,25 @@ # rfc3412: 7.1.9.a & rfc2576: 5.2.1 --> no-op - snmpEngineMaxMessageSize, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') + snmpEngineMaxMessageSize, = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', + 'snmpEngineMaxMessageSize') # fix unique request-id right prior PDU serialization if pdu.tagSet in rfc3411.confirmedClassPDUs: + # noinspection PyUnboundLocalVariable pdu.setComponentByPosition(0, msgID) # rfc3412: 7.1.9.b (securityParameters, wholeMsg) = smHandler.generateRequestMsg( - snmpEngine, self.messageProcessingModelID, globalData, - snmpEngineMaxMessageSize.syntax, securityModel, - snmpEngineId, securityName, securityLevel, scopedPDU - ) + snmpEngine, self.messageProcessingModelID, globalData, + snmpEngineMaxMessageSize.syntax, securityModel, + snmpEngineId, securityName, securityLevel, scopedPDU + ) # return original request-id right after PDU serialization if pdu.tagSet in rfc3411.confirmedClassPDUs: + # noinspection PyUnboundLocalVariable pdu.setComponentByPosition(0, reqID) # rfc3412: 7.1.9.c @@ -131,7 +139,9 @@ contextEngineId, contextName, pduVersion, pdu, maxSizeResponseScopedPDU, stateReference, statusInformation): - snmpEngineId, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + + snmpEngineId, = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') snmpEngineId = snmpEngineId.syntax # rfc3412: 7.1.2.b @@ -151,7 +161,9 @@ transportDomain = cachedParams['transportDomain'] transportAddress = cachedParams['transportAddress'] - debug.logger & debug.flagMP and debug.logger('prepareResponseMessage: cache read msgID %s transportDomain %s transportAddress %s by stateReference %s' % (msgID, transportDomain, transportAddress, stateReference)) + debug.logger & debug.flagMP and debug.logger( + 'prepareResponseMessage: cache read msgID %s transportDomain %s transportAddress %s by stateReference %s' % ( + msgID, transportDomain, transportAddress, stateReference)) # rfc3412: 7.1.3 if statusInformation: @@ -173,13 +185,14 @@ # rfc3412: 7.1.6 scopedPDU = (contextEngineId, contextName, pdu) - debug.logger & debug.flagMP and debug.logger('prepareResponseMessage: using contextEngineId %r contextName %r' % (contextEngineId, contextName)) + debug.logger & debug.flagMP and debug.logger( + 'prepareResponseMessage: using contextEngineId %r contextName %r' % (contextEngineId, contextName)) msg = self._snmpMsgSpec msg.setComponentByPosition(0, messageProcessingModel) msg.setComponentByPosition(2) msg.getComponentByPosition(2).setComponentByType( - pdu.tagSet, pdu, verifyConstraints=False + pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False ) # att: msgId not set back to PDU as it's up to responder app @@ -231,15 +244,10 @@ def prepareDataElements(self, snmpEngine, transportDomain, transportAddress, wholeMsg): + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + # rfc3412: 7.2.2 - try: - msg, restOfwholeMsg = decoder.decode(wholeMsg, - asn1Spec=self._snmpMsgSpec) - except PyAsn1Error: - debug.logger & debug.flagMP and debug.logger('prepareDataElements: %s' % (sys.exc_info()[1],)) - snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') - snmpInASNParseErrs.syntax += 1 - raise error.StatusInformation(errorIndication=errind.parseError) + msg, restOfWholeMsg = decoder.decode(wholeMsg, asn1Spec=self._snmpMsgSpec) debug.logger & debug.flagMP and debug.logger('prepareDataElements: %s' % (msg.prettyPrint(),)) @@ -247,39 +255,62 @@ raise error.StatusInformation(errorIndication=errind.parseError) # rfc3412: 7.2.3 - msgVersion = messageProcessingModel = msg.getComponentByPosition(0) + msgVersion = msg.getComponentByPosition(0) # rfc2576: 5.2.1 - snmpEngineMaxMessageSize, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') + snmpEngineMaxMessageSize, = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') communityName = msg.getComponentByPosition(1) - # transportDomain identifies local enpoint - securityParameters = (communityName, - (transportDomain, transportAddress)) + # transportDomain identifies local endpoint + securityParameters = (communityName, (transportDomain, transportAddress)) messageProcessingModel = int(msg.getComponentByPosition(0)) securityModel = messageProcessingModel + 1 securityLevel = 1 - # rfc3412: 7.2.4 -- 7.2.5 -> noop + # rfc3412: 7.2.4 -- 7.2.5 -> no-op - k = int(securityModel) - if k in snmpEngine.securityModels: - smHandler = snmpEngine.securityModels[k] - else: - raise error.StatusInformation( - errorIndication=errind.unsupportedSecurityModel + try: + + try: + smHandler = snmpEngine.securityModels[int(securityModel)] + + except KeyError: + raise error.StatusInformation( + errorIndication=errind.unsupportedSecurityModel + ) + + # rfc3412: 7.2.6 + (securityEngineId, + securityName, + scopedPDU, + maxSizeResponseScopedPDU, + securityStateReference) = smHandler.processIncomingMsg( + snmpEngine, messageProcessingModel, + snmpEngineMaxMessageSize.syntax, securityParameters, + securityModel, securityLevel, wholeMsg, msg ) - # rfc3412: 7.2.6 - (securityEngineId, securityName, scopedPDU, maxSizeResponseScopedPDU, - securityStateReference) = smHandler.processIncomingMsg( - snmpEngine, messageProcessingModel, - snmpEngineMaxMessageSize.syntax, securityParameters, - securityModel, securityLevel, wholeMsg, msg - ) + debug.logger & debug.flagMP and debug.logger( + 'prepareDataElements: SM returned securityEngineId %r securityName %r' % (securityEngineId, securityName)) + + except error.StatusInformation: + statusInformation = sys.exc_info()[1] + + snmpEngine.observer.storeExecutionContext( + snmpEngine, 'rfc2576.prepareDataElements:sm-failure', + dict(transportDomain=transportDomain, + transportAddress=transportAddress, + securityModel=securityModel, + securityLevel=securityLevel, + securityParameters=securityParameters, + statusInformation=statusInformation) + ) + snmpEngine.observer.clearExecutionContext( + snmpEngine, 'rfc2576.prepareDataElements:sm-failure' + ) - debug.logger & debug.flagMP and debug.logger('prepareDataElements: SM returned securityEngineId %r securityName %r' % (securityEngineId, securityName)) + raise - # rfc3412: 7.2.6a --> noop + # rfc3412: 7.2.6a --> no-op # rfc3412: 7.2.7 contextEngineId, contextName, pdu = scopedPDU @@ -288,7 +319,7 @@ pduVersion = msgVersion pduType = pdu.tagSet - # rfc3412: 7.2.8, 7.2.9 -> noop + # rfc3412: 7.2.8, 7.2.9 -> no-op # rfc3412: 7.2.10 if pduType in rfc3411.responseClassPDUs: @@ -305,7 +336,9 @@ # recover original PDU request-id to return to app pdu.setComponentByPosition(0, cachedReqParams['reqID']) - debug.logger & debug.flagMP and debug.logger('prepareDataElements: unique PDU request-id %s replaced with original ID %s' % (msgID, cachedReqParams['reqID'])) + debug.logger & debug.flagMP and debug.logger( + 'prepareDataElements: unique PDU request-id %s replaced with original ID %s' % ( + msgID, cachedReqParams['reqID'])) # 7.2.10b sendPduHandle = cachedReqParams['sendPduHandle'] @@ -315,17 +348,18 @@ # no error by default statusInformation = None - # rfc3412: 7.2.11 -> noop + # rfc3412: 7.2.11 -> no-op # rfc3412: 7.2.12 if pduType in rfc3411.responseClassPDUs: - # rfc3412: 7.2.12a -> noop + # rfc3412: 7.2.12a -> no-op # rfc3412: 7.2.12b - if securityModel != cachedReqParams['securityModel'] or \ - securityName != cachedReqParams['securityName'] or \ - securityLevel != cachedReqParams['securityLevel'] or \ - contextEngineId != cachedReqParams['contextEngineId'] or \ - contextName != cachedReqParams['contextName']: + # noinspection PyUnboundLocalVariable + if (securityModel != cachedReqParams['securityModel'] or + securityName != cachedReqParams['securityName'] or + securityLevel != cachedReqParams['securityLevel'] or + contextEngineId != cachedReqParams['contextEngineId'] or + contextName != cachedReqParams['contextName']): smHandler.releaseStateInformation(securityStateReference) raise error.StatusInformation(errorIndication=errind.dataMismatch) @@ -364,10 +398,11 @@ reqID = pdu.getComponentByPosition(0) msgID = self._cache.newMsgID() pdu.setComponentByPosition(0, msgID) - debug.logger & debug.flagMP and debug.logger('prepareDataElements: received PDU request-id %s replaced with unique ID %s' % (reqID, msgID)) + debug.logger & debug.flagMP and debug.logger( + 'prepareDataElements: received PDU request-id %s replaced with unique ID %s' % (reqID, msgID)) # rfc3412: 7.2.13a - snmpEngineId, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + snmpEngineId, = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') if securityEngineId != snmpEngineId.syntax: smHandler.releaseStateInformation(securityStateReference) raise error.StatusInformation( @@ -405,7 +440,8 @@ snmpEngine, 'rfc2576.prepareDataElements:confirmed' ) - debug.logger & debug.flagMP and debug.logger('prepareDataElements: cached by new stateReference %s' % stateReference) + debug.logger & debug.flagMP and debug.logger( + 'prepareDataElements: cached by new stateReference %s' % stateReference) # rfc3412: 7.2.13c return (messageProcessingModel, securityModel, securityName, @@ -448,6 +484,7 @@ smHandler.releaseStateInformation(securityStateReference) raise error.StatusInformation(errorIndication=errind.unsupportedPDUtype) + class SnmpV2cMessageProcessingModel(SnmpV1MessageProcessingModel): - messageProcessingModelID = univ.Integer(1) # SNMPv2c + messageProcessingModelID = univ.Integer(1) # SNMPv2c snmpMsgSpec = v2c.Message diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/mpmod/rfc3412.py python-pysnmp4-4.4.3/pysnmp/proto/mpmod/rfc3412.py --- python-pysnmp4-4.3.2/pysnmp/proto/mpmod/rfc3412.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/mpmod/rfc3412.py 2017-12-22 11:53:40.000000000 +0000 @@ -2,7 +2,7 @@ # This file is part of pysnmp software. # # Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# License: http://snmplabs.com/pysnmp/license.html # import sys from pysnmp.proto.mpmod.base import AbstractMessageProcessingModel @@ -15,6 +15,7 @@ # API to rfc1905 protocol objects pMod = api.protoModules[api.protoVersion2c] + # SNMPv3 message format class ScopedPDU(univ.Sequence): @@ -24,38 +25,47 @@ namedtype.NamedType('data', rfc1905.PDUs()) ) + class ScopedPduData(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('plaintext', ScopedPDU()), namedtype.NamedType('encryptedPDU', univ.OctetString()), ) + class HeaderData(univ.Sequence): componentType = namedtype.NamedTypes( - namedtype.NamedType('msgID', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))), - namedtype.NamedType('msgMaxSize', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(484, 2147483647))), + namedtype.NamedType('msgID', + univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))), + namedtype.NamedType('msgMaxSize', + univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(484, 2147483647))), namedtype.NamedType('msgFlags', univ.OctetString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 1))), - namedtype.NamedType('msgSecurityModel', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, 2147483647))) + namedtype.NamedType('msgSecurityModel', + univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, 2147483647))) ) + class SNMPv3Message(univ.Sequence): componentType = namedtype.NamedTypes( - namedtype.NamedType('msgVersion', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))), + namedtype.NamedType('msgVersion', + univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))), namedtype.NamedType('msgGlobalData', HeaderData()), namedtype.NamedType('msgSecurityParameters', univ.OctetString()), namedtype.NamedType('msgData', ScopedPduData()) ) + # XXX move somewhere? -_snmpErrors = {(1, 3, 6, 1, 6, 3, 15, 1, 1, 1, 0): 'unsupportedSecLevel', - (1, 3, 6, 1, 6, 3, 15, 1, 1, 2, 0): 'notInTimeWindow', - (1, 3, 6, 1, 6, 3, 15, 1, 1, 3, 0): 'unknownUserName', - (1, 3, 6, 1, 6, 3, 15, 1, 1, 4, 0): 'unknownEngineID', - (1, 3, 6, 1, 6, 3, 15, 1, 1, 5, 0): 'wrongDigest', - (1, 3, 6, 1, 6, 3, 15, 1, 1, 6, 0): 'decryptionError'} +_snmpErrors = {(1, 3, 6, 1, 6, 3, 15, 1, 1, 1, 0): errind.unsupportedSecurityLevel, + (1, 3, 6, 1, 6, 3, 15, 1, 1, 2, 0): errind.notInTimeWindow, + (1, 3, 6, 1, 6, 3, 15, 1, 1, 3, 0): errind.unknownUserName, + (1, 3, 6, 1, 6, 3, 15, 1, 1, 4, 0): errind.unknownEngineID, + (1, 3, 6, 1, 6, 3, 15, 1, 1, 5, 0): errind.wrongDigest, + (1, 3, 6, 1, 6, 3, 15, 1, 1, 6, 0): errind.decryptionError} + class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel): - messageProcessingModelID = univ.Integer(3) # SNMPv3 + messageProcessingModelID = univ.Integer(3) # SNMPv3 snmpMsgSpec = SNMPv3Message _emptyStr = univ.OctetString('') _msgFlags = {0: univ.OctetString('\x00'), @@ -64,6 +74,7 @@ 4: univ.OctetString('\x04'), 5: univ.OctetString('\x05'), 7: univ.OctetString('\x07')} + def __init__(self): AbstractMessageProcessingModel.__init__(self) self.__scopedPDU = ScopedPDU() @@ -74,9 +85,9 @@ def getPeerEngineInfo(self, transportDomain, transportAddress): k = transportDomain, transportAddress if k in self.__engineIdCache: - return self.__engineIdCache[k]['securityEngineId'], \ - self.__engineIdCache[k]['contextEngineId'], \ - self.__engineIdCache[k]['contextName'] + return (self.__engineIdCache[k]['securityEngineId'], + self.__engineIdCache[k]['contextEngineId'], + self.__engineIdCache[k]['contextName']) else: return None, None, None @@ -86,7 +97,8 @@ securityModel, securityName, securityLevel, contextEngineId, contextName, pduVersion, pdu, expectResponse, sendPduHandle): - snmpEngineID, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + snmpEngineID, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', + 'snmpEngineID') snmpEngineID = snmpEngineID.syntax # 7.1.1b @@ -100,7 +112,9 @@ else: peerSnmpEngineData = None - debug.logger & debug.flagMP and debug.logger('prepareOutgoingMessage: peer SNMP engine data %s for transport %s, address %s' % (peerSnmpEngineData, transportDomain, transportAddress)) + debug.logger & debug.flagMP and debug.logger( + 'prepareOutgoingMessage: peer SNMP engine data %s for transport %s, address %s' % ( + peerSnmpEngineData, transportDomain, transportAddress)) # 7.1.4 if contextEngineId is None: @@ -117,7 +131,8 @@ if not contextName: contextName = self._emptyStr - debug.logger & debug.flagMP and debug.logger('prepareOutgoingMessage: using contextEngineId %r, contextName %r' % (contextEngineId, contextName)) + debug.logger & debug.flagMP and debug.logger( + 'prepareOutgoingMessage: using contextEngineId %r, contextName %r' % (contextEngineId, contextName)) # 7.1.6 scopedPDU = self.__scopedPDU @@ -125,7 +140,7 @@ scopedPDU.setComponentByPosition(1, contextName) scopedPDU.setComponentByPosition(2) scopedPDU.getComponentByPosition(2).setComponentByType( - pdu.tagSet, pdu, verifyConstraints=False + pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False ) # 7.1.7 @@ -133,19 +148,20 @@ # 7.1.7a msg.setComponentByPosition( - 0, self.messageProcessingModelID, verifyConstraints=False + 0, self.messageProcessingModelID, verifyConstraints=False, matchTags=False, matchConstraints=False ) headerData = msg.setComponentByPosition(1).getComponentByPosition(1) # 7.1.7b - headerData.setComponentByPosition(0, msgID, verifyConstraints=False) + headerData.setComponentByPosition(0, msgID, verifyConstraints=False, matchTags=False, matchConstraints=False) - snmpEngineMaxMessageSize, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') + snmpEngineMaxMessageSize, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + '__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') # 7.1.7c # XXX need to coerce MIB value as it has incompatible constraints set headerData.setComponentByPosition( - 1, snmpEngineMaxMessageSize.syntax, verifyConstraints=False + 1, snmpEngineMaxMessageSize.syntax, verifyConstraints=False, matchTags=False, matchConstraints=False ) # 7.1.7d @@ -153,19 +169,19 @@ if securityLevel == 1: pass elif securityLevel == 2: - msgFlags = msgFlags | 0x01 + msgFlags |= 0x01 elif securityLevel == 3: - msgFlags = msgFlags | 0x03 + msgFlags |= 0x03 else: raise error.ProtocolError( 'Unknown securityLevel %s' % securityLevel ) if pdu.tagSet in rfc3411.confirmedClassPDUs: - msgFlags = msgFlags | 0x04 + msgFlags |= 0x04 headerData.setComponentByPosition( - 2, self._msgFlags[msgFlags], verifyConstraints=False + 2, self._msgFlags[msgFlags], verifyConstraints=False, matchTags=False, matchConstraints=False ) # 7.1.7e @@ -191,12 +207,12 @@ securityLevel = 1 # Clear possible auth&priv flags headerData.setComponentByPosition( - 2, self._msgFlags[msgFlags & 0xfc], verifyConstraints=False + 2, self._msgFlags[msgFlags & 0xfc], verifyConstraints=False, matchTags=False, matchConstraints=False ) # XXX scopedPDU = self.__scopedPDU scopedPDU.setComponentByPosition( - 0, self._emptyStr, verifyConstraints=False + 0, self._emptyStr, verifyConstraints=False, matchTags=False, matchConstraints=False ) scopedPDU.setComponentByPosition(1, contextName) scopedPDU.setComponentByPosition(2) @@ -206,21 +222,23 @@ pMod.apiPDU.setDefaults(emptyPdu) scopedPDU.getComponentByPosition(2).setComponentByType( - emptyPdu.tagSet, emptyPdu, verifyConstraints=False + emptyPdu.tagSet, emptyPdu, verifyConstraints=False, matchTags=False, matchConstraints=False ) debug.logger & debug.flagMP and debug.logger('prepareOutgoingMessage: force engineID discovery') else: securityEngineId = peerSnmpEngineData['securityEngineId'] - debug.logger & debug.flagMP and debug.logger('prepareOutgoingMessage: securityModel %r, securityEngineId %r, securityName %r, securityLevel %r' % (securityModel, securityEngineId, securityName, securityLevel)) + debug.logger & debug.flagMP and debug.logger( + 'prepareOutgoingMessage: securityModel %r, securityEngineId %r, securityName %r, securityLevel %r' % ( + securityModel, securityEngineId, securityName, securityLevel)) # 7.1.9.b (securityParameters, wholeMsg) = smHandler.generateRequestMsg( - snmpEngine, self.messageProcessingModelID, msg, - snmpEngineMaxMessageSize.syntax, securityModel, - securityEngineId, securityName, securityLevel, scopedPDU - ) + snmpEngine, self.messageProcessingModelID, msg, + snmpEngineMaxMessageSize.syntax, securityModel, + securityEngineId, securityName, securityLevel, scopedPDU + ) # Message size constraint verification if len(wholeMsg) > snmpEngineMaxMessageSize.syntax: @@ -279,21 +297,21 @@ transportDomain = cachedParams['transportDomain'] transportAddress = cachedParams['transportAddress'] - debug.logger & debug.flagMP and debug.logger('prepareResponseMessage: stateReference %s' % (stateReference)) + debug.logger & debug.flagMP and debug.logger('prepareResponseMessage: stateReference %s' % stateReference) # 7.1.3 if statusInformation is not None and 'oid' in statusInformation: # 7.1.3a - if pdu is not None: + if pdu is None: + pduType = None + else: requestID = pdu.getComponentByPosition(0) pduType = pdu.tagSet - else: - pduType = None # 7.1.3b - if pdu is None and not reportableFlag or \ - pduType is not None and \ - pduType not in rfc3411.confirmedClassPDUs: + if (pdu is None and not reportableFlag or + pduType is not None and + pduType not in rfc3411.confirmedClassPDUs): raise error.StatusInformation( errorIndication=errind.loopTerminated ) @@ -306,6 +324,7 @@ if pdu is None: pMod.apiPDU.setRequestID(reportPDU, 0) else: + # noinspection PyUnboundLocalVariable pMod.apiPDU.setRequestID(reportPDU, requestID) # 7.1.3d.1 @@ -329,7 +348,8 @@ # 7.1.3e pdu = reportPDU - debug.logger & debug.flagMP and debug.logger('prepareResponseMessage: prepare report PDU for statusInformation %s' % statusInformation) + debug.logger & debug.flagMP and debug.logger( + 'prepareResponseMessage: prepare report PDU for statusInformation %s' % statusInformation) # 7.1.4 if not contextEngineId: contextEngineId = snmpEngineID # XXX impl-dep manner @@ -338,7 +358,8 @@ if not contextName: contextName = self._emptyStr - debug.logger & debug.flagMP and debug.logger('prepareResponseMessage: using contextEngineId %r, contextName %r' % (contextEngineId, contextName)) + debug.logger & debug.flagMP and debug.logger( + 'prepareResponseMessage: using contextEngineId %r, contextName %r' % (contextEngineId, contextName)) # 7.1.6 scopedPDU = self.__scopedPDU @@ -346,27 +367,29 @@ scopedPDU.setComponentByPosition(1, contextName) scopedPDU.setComponentByPosition(2) scopedPDU.getComponentByPosition(2).setComponentByType( - pdu.tagSet, pdu, verifyConstraints=False + pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False ) # 7.1.7 msg = self._snmpMsgSpec # 7.1.7a - msg.setComponentByPosition(0, self.messageProcessingModelID, - verifyConstraints=False) + msg.setComponentByPosition( + 0, self.messageProcessingModelID, verifyConstraints=False, matchTags=False, matchConstraints=False + ) headerData = msg.setComponentByPosition(1).getComponentByPosition(1) # 7.1.7b - headerData.setComponentByPosition(0, msgID, verifyConstraints=False) + headerData.setComponentByPosition(0, msgID, verifyConstraints=False, matchTags=False, matchConstraints=False) - snmpEngineMaxMessageSize, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') + snmpEngineMaxMessageSize, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + '__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') # 7.1.7c # XXX need to coerce MIB value as it has incompatible constraints set headerData.setComponentByPosition( - 1, snmpEngineMaxMessageSize.syntax, verifyConstraints=False + 1, snmpEngineMaxMessageSize.syntax, verifyConstraints=False, matchTags=False, matchConstraints=False ) # 7.1.7d @@ -374,22 +397,22 @@ if securityLevel == 1: pass elif securityLevel == 2: - msgFlags = msgFlags | 0x01 + msgFlags |= 0x01 elif securityLevel == 3: - msgFlags = msgFlags | 0x03 + msgFlags |= 0x03 else: raise error.ProtocolError('Unknown securityLevel %s' % securityLevel) if pdu.tagSet in rfc3411.confirmedClassPDUs: # XXX not needed? - msgFlags = msgFlags | 0x04 + msgFlags |= 0x04 headerData.setComponentByPosition( - 2, self._msgFlags[msgFlags], verifyConstraints=False + 2, self._msgFlags[msgFlags], verifyConstraints=False, matchTags=False, matchConstraints=False ) # 7.1.7e headerData.setComponentByPosition( - 3, securityModel, verifyConstraints=False + 3, securityModel, verifyConstraints=False, matchTags=False, matchConstraints=False ) debug.logger & debug.flagMP and debug.logger('prepareResponseMessage: %s' % (msg.prettyPrint(),)) @@ -399,17 +422,19 @@ else: raise error.StatusInformation(errorIndication=errind.unsupportedSecurityModel) - debug.logger & debug.flagMP and debug.logger('prepareResponseMessage: securityModel %r, securityEngineId %r, securityName %r, securityLevel %r' % (securityModel, snmpEngineID, securityName, securityLevel)) + debug.logger & debug.flagMP and debug.logger( + 'prepareResponseMessage: securityModel %r, securityEngineId %r, securityName %r, securityLevel %r' % ( + securityModel, snmpEngineID, securityName, securityLevel)) # 7.1.8a try: (securityParameters, wholeMsg) = smHandler.generateResponseMsg( - snmpEngine, self.messageProcessingModelID, msg, - snmpEngineMaxMessageSize.syntax, securityModel, - snmpEngineID, securityName, securityLevel, scopedPDU, - securityStateReference - ) + snmpEngine, self.messageProcessingModelID, msg, + snmpEngineMaxMessageSize.syntax, securityModel, + snmpEngineID, securityName, securityLevel, scopedPDU, + securityStateReference + ) except error.StatusInformation: # 7.1.8.b raise @@ -444,14 +469,7 @@ def prepareDataElements(self, snmpEngine, transportDomain, transportAddress, wholeMsg): # 7.2.2 - try: - msg, restOfwholeMsg = decoder.decode(wholeMsg, asn1Spec=self._snmpMsgSpec) - - except PyAsn1Error: - debug.logger & debug.flagMP and debug.logger('prepareDataElements: %s' % (sys.exc_info()[1],)) - snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') - snmpInASNParseErrs.syntax += 1 - raise error.StatusInformation(errorIndication=errind.parseError) + msg, restOfwholeMsg = decoder.decode(wholeMsg, asn1Spec=self._snmpMsgSpec) debug.logger & debug.flagMP and debug.logger('prepareDataElements: %s' % (msg.prettyPrint(),)) @@ -467,11 +485,14 @@ securityModel = headerData.getComponentByPosition(3) securityParameters = msg.getComponentByPosition(2) - debug.logger & debug.flagMP and debug.logger('prepareDataElements: msg data msgVersion %s msgID %s securityModel %s' % (msgVersion, msgID, securityModel)) + debug.logger & debug.flagMP and debug.logger( + 'prepareDataElements: msg data msgVersion %s msgID %s securityModel %s' % ( + msgVersion, msgID, securityModel)) # 7.2.4 if securityModel not in snmpEngine.securityModels: - snmpUnknownSecurityModels, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-MPD-MIB', 'snmpUnknownSecurityModels') + snmpUnknownSecurityModels, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + '__SNMP-MPD-MIB', 'snmpUnknownSecurityModels') snmpUnknownSecurityModels.syntax += 1 raise error.StatusInformation(errorIndication=errind.unsupportedSecurityModel) @@ -483,7 +504,7 @@ elif (msgFlags & 0x03) == 0x03: securityLevel = 3 else: - snmpInvalidMsgs = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-MPD-MIB', 'snmpInvalidMsgs') + snmpInvalidMsgs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-MPD-MIB', 'snmpInvalidMsgs') snmpInvalidMsgs.syntax += 1 raise error.StatusInformation(errorIndication=errind.invalidMsg) @@ -495,18 +516,36 @@ # 7.2.6 smHandler = snmpEngine.securityModels[securityModel] try: - (securityEngineId, securityName, - scopedPDU, maxSizeResponseScopedPDU, + (securityEngineId, + securityName, + scopedPDU, + maxSizeResponseScopedPDU, securityStateReference) = smHandler.processIncomingMsg( - snmpEngine, messageProcessingModel, maxMessageSize, - securityParameters, securityModel, securityLevel, - wholeMsg, msg - ) + snmpEngine, messageProcessingModel, maxMessageSize, + securityParameters, securityModel, securityLevel, + wholeMsg, msg + ) debug.logger & debug.flagMP and debug.logger('prepareDataElements: SM succeeded') except error.StatusInformation: statusInformation, origTraceback = sys.exc_info()[1:3] - debug.logger & debug.flagMP and debug.logger('prepareDataElements: SM failed, statusInformation %s' % statusInformation) + + debug.logger & debug.flagMP and debug.logger( + 'prepareDataElements: SM failed, statusInformation %s' % statusInformation) + + snmpEngine.observer.storeExecutionContext( + snmpEngine, 'rfc3412.prepareDataElements:sm-failure', + dict(transportDomain=transportDomain, + transportAddress=transportAddress, + securityModel=securityModel, + securityLevel=securityLevel, + securityParameters=securityParameters, + statusInformation=statusInformation) + ) + snmpEngine.observer.clearExecutionContext( + snmpEngine, 'rfc3412.prepareDataElements:sm-failure' + ) + if 'errorIndication' in statusInformation: # 7.2.6a if 'oid' in statusInformation: @@ -549,6 +588,7 @@ pass debug.logger & debug.flagMP and debug.logger('prepareDataElements: error reported') + # 7.2.6b if sys.version_info[0] <= 2: raise statusInformation @@ -563,7 +603,9 @@ # Sniff for engineIdCache k = (transportDomain, transportAddress) if k not in self.__engineIdCache: - contextEngineId, contextName, pdus = scopedPDU + contextEngineId = scopedPDU[0] + contextName = scopedPDU[1] + pdus = scopedPDU[2] pdu = pdus.getComponent() # Here we assume that authentic/default EngineIDs # come only in the course of engine-to-engine communication. @@ -579,14 +621,19 @@ self.__engineIdCacheExpQueue[expireAt] = [] self.__engineIdCacheExpQueue[expireAt].append(k) - debug.logger & debug.flagMP and debug.logger('prepareDataElements: cache securityEngineId %r for %r %r' % (securityEngineId, transportDomain, transportAddress)) + debug.logger & debug.flagMP and debug.logger( + 'prepareDataElements: cache securityEngineId %r for %r %r' % ( + securityEngineId, transportDomain, transportAddress)) snmpEngineID, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') snmpEngineID = snmpEngineID.syntax # 7.2.7 XXX PDU would be parsed here? - contextEngineId, contextName, pdu = scopedPDU - pdu = pdu.getComponent() # PDUs + contextEngineId = scopedPDU[0] + contextName = scopedPDU[1] + pdu = scopedPDU[2] + + pdu = pdu.getComponent() # PDUs # 7.2.8 pduVersion = api.protoVersion2c @@ -595,8 +642,8 @@ pduType = pdu.tagSet # 7.2.10 - if pduType in rfc3411.responseClassPDUs or \ - pduType in rfc3411.internalClassPDUs: + if (pduType in rfc3411.responseClassPDUs or + pduType in rfc3411.internalClassPDUs): # 7.2.10a try: cachedReqParams = self._cache.popByMsgId(msgID) @@ -610,7 +657,8 @@ else: sendPduHandle = None - debug.logger & debug.flagMP and debug.logger('prepareDataElements: using sendPduHandle %s for msgID %s' % (sendPduHandle, msgID)) + debug.logger & debug.flagMP and debug.logger( + 'prepareDataElements: using sendPduHandle %s for msgID %s' % (sendPduHandle, msgID)) # 7.2.11 if pduType in rfc3411.internalClassPDUs: @@ -618,11 +666,14 @@ varBinds = pMod.apiPDU.getVarBinds(pdu) if varBinds: statusInformation = error.StatusInformation( - errorIndication=_snmpErrors.get(varBinds[0][0], - 'errorReportReceived'), + errorIndication=_snmpErrors.get(varBinds[0][0], errind.ReportPduReceived(varBinds[0][0].prettyPrint())), oid=varBinds[0][0], val=varBinds[0][1], sendPduHandle=sendPduHandle ) + else: + statusInformation = error.StatusInformation( + sendPduHandle=sendPduHandle + ) # 7.2.11b (incomplete implementation) @@ -646,7 +697,7 @@ smHandler.releaseStateInformation(securityStateReference) # 7.2.11d - stateReference = None + # no-op # 7.2.11e XXX may need to pass Reports up to app in some cases... raise statusInformation @@ -655,14 +706,15 @@ # 7.2.12 if pduType in rfc3411.responseClassPDUs: - # 7.2.12a -> noop + # 7.2.12a -> no-op # 7.2.12b - if securityModel != cachedReqParams['securityModel'] or \ - securityName != cachedReqParams['securityName'] or \ - securityLevel != cachedReqParams['securityLevel'] or \ - contextEngineId != cachedReqParams['contextEngineId'] or \ - contextName != cachedReqParams['contextName']: + # noinspection PyUnboundLocalVariable + if (securityModel != cachedReqParams['securityModel'] or + securityName != cachedReqParams['securityName'] or + securityLevel != cachedReqParams['securityLevel'] or + contextEngineId != cachedReqParams['contextEngineId'] or + contextName != cachedReqParams['contextName']): smHandler.releaseStateInformation(securityStateReference) raise error.StatusInformation( errorIndication=errind.dataMismatch diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/proxy/rfc2576.py python-pysnmp4-4.4.3/pysnmp/proto/proxy/rfc2576.py --- python-pysnmp4-4.3.2/pysnmp/proto/proxy/rfc2576.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/proxy/rfc2576.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto import rfc1905, rfc3411, error from pysnmp.proto.api import v1, v2c @@ -22,7 +22,7 @@ v1.Opaque.tagSet: v2c.Opaque() } -__v2ToV1ValueMap = { # XXX do not re-create same-type items? +__v2ToV1ValueMap = { # XXX do not re-create same-type items? v2c.Integer32.tagSet: v1.Integer(), v2c.OctetString.tagSet: v1.OctetString(), v2c.Null.tagSet: v1.Null(), @@ -50,7 +50,7 @@ v2c.SetRequestPDU.tagSet: v1.SetRequestPDU(), v2c.ResponsePDU.tagSet: v1.GetResponsePDU(), v2c.SNMPv2TrapPDU.tagSet: v1.TrapPDU(), - v2c.GetBulkRequestPDU.tagSet: v1.GetNextRequestPDU() # 4.1.1 + v2c.GetBulkRequestPDU.tagSet: v1.GetNextRequestPDU() # 4.1.1 } # Trap map @@ -76,15 +76,15 @@ # 4.3 __v2ToV1ErrorMap = { - 0: 0, - 1: 1, - 5: 5, + 0: 0, + 1: 1, + 5: 5, 10: 3, - 9: 3, - 7: 3, - 8: 3, + 9: 3, + 7: 3, + 8: 3, 12: 3, - 6: 2, + 6: 2, 17: 2, 11: 2, 18: 2, @@ -96,7 +96,8 @@ __zeroInt = v1.Integer(0) -def v1ToV2(v1Pdu, origV2Pdu=None): + +def v1ToV2(v1Pdu, origV2Pdu=None, snmpTrapCommunity=''): pduType = v1Pdu.tagSet v2Pdu = __v1ToV2PduMap[pduType].clone() @@ -112,20 +113,19 @@ # 3.1.2 genericTrap = v1.apiTrapPDU.getGenericTrap(v1Pdu) if genericTrap == 6: - snmpTrapOIDParam = v1.apiTrapPDU.getEnterprise(v1Pdu) + (0,) + \ - (int(v1.apiTrapPDU.getSpecificTrap(v1Pdu)),) + snmpTrapOIDParam = v1.apiTrapPDU.getEnterprise(v1Pdu) + (0, int(v1.apiTrapPDU.getSpecificTrap(v1Pdu))) # 3.1.3 else: snmpTrapOIDParam = v2c.ObjectIdentifier(__v1ToV2TrapMap[genericTrap]) - # 3.1.4 (XXX snmpTrapCommunity.0 is missing here) + # 3.1.4 v2VarBinds.append((v2c.apiTrapPDU.sysUpTime, sysUpTime)) v2VarBinds.append((v2c.apiTrapPDU.snmpTrapOID, snmpTrapOIDParam)) v2VarBinds.append( (v2c.apiTrapPDU.snmpTrapAddress, v1.apiTrapPDU.getAgentAddr(v1Pdu)) ) - v2VarBinds.append((v2c.apiTrapPDU.snmpTrapCommunity, v2c.OctetString(""))) + v2VarBinds.append((v2c.apiTrapPDU.snmpTrapCommunity, v2c.OctetString(snmpTrapCommunity))) v2VarBinds.append((v2c.apiTrapPDU.snmpTrapEnterprise, v1.apiTrapPDU.getEnterprise(v1Pdu))) @@ -146,21 +146,15 @@ # 4.1.2.2.1&2 errorStatus = int(v1.apiPDU.getErrorStatus(v1Pdu)) errorIndex = int(v1.apiPDU.getErrorIndex(v1Pdu, muteErrors=True)) - if errorStatus == 2: # noSuchName + if errorStatus == 2: # noSuchName if origV2Pdu.tagSet == v2c.GetNextRequestPDU.tagSet: - v2VarBinds = [ - (o, rfc1905.endOfMibView) for o, v in v2VarBinds - ] + v2VarBinds = [(o, rfc1905.endOfMibView) for o, v in v2VarBinds] else: - v2VarBinds = [ - (o, rfc1905.noSuchObject) for o, v in v2VarBinds - ] - v2c.apiPDU.setErrorStatus(v2Pdu, 0) - v2c.apiPDU.setErrorIndex(v2Pdu, 0) - else: - # partial one-to-one mapping - 4.2.1 - v2c.apiPDU.setErrorStatus(v2Pdu, errorStatus) - v2c.apiPDU.setErrorIndex(v2Pdu, errorIndex) + v2VarBinds = [(o, rfc1905.noSuchObject) for o, v in v2VarBinds] + + # partial one-to-one mapping - 4.2.1 + v2c.apiPDU.setErrorStatus(v2Pdu, errorStatus) + v2c.apiPDU.setErrorIndex(v2Pdu, errorIndex) # 4.1.2.1 --> no-op @@ -177,6 +171,7 @@ return v2Pdu + def v2ToV1(v2Pdu, origV1Pdu=None): debug.logger & debug.flagPrx and debug.logger('v2ToV1: v2Pdu %s' % v2Pdu.prettyPrint()) @@ -215,7 +210,7 @@ for oid, val in v2VarBinds: # snmpTrapAddress if oid == v2c.apiTrapPDU.snmpTrapAddress: - v1.apiTrapPDU.setAgentAddr(v1Pdu, val) + v1.apiTrapPDU.setAgentAddr(v1Pdu, v1.IpAddress(val)) # v2c.OctetString is more constrained break else: v1.apiTrapPDU.setAgentAddr(v1Pdu, v1.IpAddress('0.0.0.0')) @@ -238,9 +233,9 @@ __v2VarBinds = [] for oid, val in v2VarBinds[2:]: if oid in __v2ToV1TrapMap or \ - oid in (v2c.apiTrapPDU.sysUpTime, - v2c.apiTrapPDU.snmpTrapAddress, - v2c.apiTrapPDU.snmpTrapEnterprise): + oid in (v2c.apiTrapPDU.sysUpTime, + v2c.apiTrapPDU.snmpTrapAddress, + v2c.apiTrapPDU.snmpTrapEnterprise): continue __v2VarBinds.append((oid, val)) v2VarBinds = __v2VarBinds @@ -252,14 +247,14 @@ v1.apiPDU.setErrorIndex(v1Pdu, __zeroInt) if pduType in rfc3411.responseClassPDUs: - idx = len(v2VarBinds)-1 + idx = len(v2VarBinds) - 1 while idx >= 0: # 4.1.2.1 oid, val = v2VarBinds[idx] if v2c.Counter64.tagSet == val.tagSet: if origV1Pdu.tagSet == v1.GetRequestPDU.tagSet: v1.apiPDU.setErrorStatus(v1Pdu, 2) - v1.apiPDU.setErrorIndex(v1Pdu, idx+1) + v1.apiPDU.setErrorIndex(v1Pdu, idx + 1) break elif origV1Pdu.tagSet == v1.GetNextRequestPDU.tagSet: raise error.StatusInformation(idx=idx, pdu=v2Pdu) @@ -271,7 +266,7 @@ v2c.NoSuchInstance.tagSet, v2c.EndOfMibView.tagSet): v1.apiPDU.setErrorStatus(v1Pdu, 2) - v1.apiPDU.setErrorIndex(v1Pdu, idx+1) + v1.apiPDU.setErrorIndex(v1Pdu, idx + 1) idx -= 1 @@ -280,7 +275,7 @@ if v2ErrorStatus: v1.apiPDU.setErrorStatus( v1Pdu, __v2ToV1ErrorMap.get(v2ErrorStatus, 5) - ) + ) v1.apiPDU.setErrorIndex(v1Pdu, v2c.apiPDU.getErrorIndex(v2Pdu, muteErrors=True)) elif pduType in rfc3411.confirmedClassPDUs: @@ -288,8 +283,8 @@ v1.apiPDU.setErrorIndex(v1Pdu, 0) # Translate Var-Binds - if pduType in rfc3411.responseClassPDUs and \ - v1.apiPDU.getErrorStatus(v1Pdu): + if (pduType in rfc3411.responseClassPDUs and + v1.apiPDU.getErrorStatus(v1Pdu)): v1VarBinds = v1.apiPDU.getVarBinds(origV1Pdu) else: for oid, v2Val in v2VarBinds: diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/rfc1155.py python-pysnmp4-4.4.3/pysnmp/proto/rfc1155.py --- python-pysnmp4-4.3.2/pysnmp/proto/rfc1155.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/rfc1155.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,21 +1,23 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.type import univ, tag, constraint, namedtype from pyasn1.error import PyAsn1Error +from pysnmp.smi.error import SmiError from pysnmp.proto import error __all__ = ['Opaque', 'NetworkAddress', 'ObjectName', 'TimeTicks', 'Counter', 'Gauge', 'IpAddress'] + class IpAddress(univ.OctetString): tagSet = univ.OctetString.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x00) ) - subtypeSpec = univ.OctetString.subtypeSpec+constraint.ValueSizeConstraint( + subtypeSpec = univ.OctetString.subtypeSpec + constraint.ValueSizeConstraint( 4, 4 ) @@ -24,7 +26,7 @@ try: value = [int(x) for x in value.split('.')] except: - raise error.ProtocolError('Bad IP address syntax %s' % value) + raise error.ProtocolError('Bad IP address syntax %s' % value) if len(value) != 4: raise error.ProtocolError('Bad IP address syntax') return univ.OctetString.prettyIn(self, value) @@ -35,44 +37,104 @@ else: return '' + class Counter(univ.Integer): tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x01) ) - subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint( + subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) + class NetworkAddress(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('internet', IpAddress()) ) + def clone(self, value=univ.noValue, **kwargs): + """Clone this instance. + + If *value* is specified, use its tag as the component type selector, + and itself as the component value. + + :param value: (Optional) the component value. + :type value: :py:obj:`pyasn1.type.base.Asn1ItemBase` + :return: the cloned instance. + :rtype: :py:obj:`pysnmp.proto.rfc1155.NetworkAddress` + :raise: :py:obj:`pysnmp.smi.error.SmiError`: + if the type of *value* is not allowed for this Choice instance. + """ + cloned = univ.Choice.clone(self, **kwargs) + if value is not univ.noValue: + if isinstance(value, NetworkAddress): + value = value.getComponent() + elif not isinstance(value, IpAddress): + # IpAddress is the only supported type, perhaps forever because + # this is SNMPv1. + value = IpAddress(value) + try: + tagSet = value.tagSet + except AttributeError: + raise PyAsn1Error('component value %r has no tag set' % (value,)) + cloned.setComponentByType(tagSet, value) + return cloned + + # RFC 1212, section 4.1.6: + # + # "(5) NetworkAddress-valued: `n+1' sub-identifiers, where `n' + # depends on the kind of address being encoded (the first + # sub-identifier indicates the kind of address, value 1 + # indicates an IpAddress);" + + def cloneFromName(self, value, impliedFlag, parentRow, parentIndices): + kind = value[0] + clone = self.clone() + if kind == 1: + clone['internet'] = tuple(value[1:5]) + return clone, value[5:] + else: + raise SmiError('unknown NetworkAddress type %r' % (kind,)) + + def cloneAsName(self, impliedFlag, parentRow, parentIndices): + kind = self.getName() + component = self.getComponent() + if kind == 'internet': + return (1,) + tuple(component.asNumbers()) + else: + raise SmiError('unknown NetworkAddress type %r' % (kind,)) + + + class Gauge(univ.Integer): tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x02) ) - subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint( + subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) + class TimeTicks(univ.Integer): tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x03) ) - subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint( + subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) + class Opaque(univ.OctetString): tagSet = univ.OctetString.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x04) ) + class ObjectName(univ.ObjectIdentifier): pass -class TypeCoercionHackMixIn: # XXX + +class TypeCoercionHackMixIn: # XXX keep this old-style class till pyasn1 types becomes new-style # Reduce ASN1 type check to simple tag check as SMIv2 objects may # not be constraints-compatible with those used in SNMP PDU. def _verifyComponent(self, idx, value, **kwargs): @@ -84,6 +146,7 @@ if not t.getTagSet().isSuperTagSetOf(value.getTagSet()): raise PyAsn1Error('Component type error %r vs %r' % (t, value)) + class SimpleSyntax(TypeCoercionHackMixIn, univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('number', univ.Integer()), @@ -92,6 +155,7 @@ namedtype.NamedType('empty', univ.Null()) ) + class ApplicationSyntax(TypeCoercionHackMixIn, univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('address', NetworkAddress()), @@ -101,6 +165,7 @@ namedtype.NamedType('arbitrary', Opaque()) ) + class ObjectSyntax(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('simple', SimpleSyntax()), diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/rfc1157.py python-pysnmp4-4.4.3/pysnmp/proto/rfc1157.py --- python-pysnmp4-4.3.2/pysnmp/proto/rfc1157.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/rfc1157.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.type import univ, tag, namedtype, namedval from pysnmp.proto import rfc1155 @@ -10,42 +10,60 @@ __all__ = ['GetNextRequestPDU', 'GetResponsePDU', 'SetRequestPDU', 'TrapPDU', 'GetRequestPDU'] + class VarBind(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('name', rfc1155.ObjectName()), namedtype.NamedType('value', rfc1155.ObjectSyntax()) ) + + class VarBindList(univ.SequenceOf): componentType = VarBind() -_errorStatus = univ.Integer(namedValues=namedval.NamedValues(('noError', 0), ('tooBig', 1), ('noSuchName', 2), ('badValue', 3), ('readOnly', 4), ('genErr', 5))) + +errorStatus = univ.Integer( + namedValues=namedval.NamedValues(('noError', 0), ('tooBig', 1), ('noSuchName', 2), + ('badValue', 3), ('readOnly', 4), ('genErr', 5))) + class _RequestBase(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('request-id', univ.Integer()), - namedtype.NamedType('error-status', _errorStatus), + namedtype.NamedType('error-status', errorStatus), namedtype.NamedType('error-index', univ.Integer()), namedtype.NamedType('variable-bindings', VarBindList()) ) + class GetRequestPDU(_RequestBase): tagSet = _RequestBase.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0) ) + + class GetNextRequestPDU(_RequestBase): tagSet = _RequestBase.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1) ) + + class GetResponsePDU(_RequestBase): tagSet = _RequestBase.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2) ) + + class SetRequestPDU(_RequestBase): tagSet = _RequestBase.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3) ) -_genericTrap = univ.Integer().clone(namedValues=namedval.NamedValues(('coldStart', 0), ('warmStart', 1), ('linkDown', 2), ('linkUp', 3), ('authenticationFailure', 4), ('egpNeighborLoss', 5), ('enterpriseSpecific', 6))) + +genericTrap = univ.Integer().clone( + namedValues=namedval.NamedValues(('coldStart', 0), ('warmStart', 1), ('linkDown', 2), ('linkUp', 3), + ('authenticationFailure', 4), ('egpNeighborLoss', 5), ('enterpriseSpecific', 6))) + class TrapPDU(univ.Sequence): tagSet = univ.Sequence.tagSet.tagImplicitly( @@ -54,12 +72,13 @@ componentType = namedtype.NamedTypes( namedtype.NamedType('enterprise', univ.ObjectIdentifier()), namedtype.NamedType('agent-addr', rfc1155.NetworkAddress()), - namedtype.NamedType('generic-trap', _genericTrap), + namedtype.NamedType('generic-trap', genericTrap), namedtype.NamedType('specific-trap', univ.Integer()), namedtype.NamedType('time-stamp', rfc1155.TimeTicks()), namedtype.NamedType('variable-bindings', VarBindList()) ) + class PDUs(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('get-request', GetRequestPDU()), @@ -69,11 +88,13 @@ namedtype.NamedType('trap', TrapPDU()) ) -_version = univ.Integer(namedValues=namedval.NamedValues(('version-1', 0))) + +version = univ.Integer(namedValues=namedval.NamedValues(('version-1', 0))) + class Message(univ.Sequence): componentType = namedtype.NamedTypes( - namedtype.NamedType('version', _version), + namedtype.NamedType('version', version), namedtype.NamedType('community', univ.OctetString()), namedtype.NamedType('data', PDUs()) ) diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/rfc1901.py python-pysnmp4-4.4.3/pysnmp/proto/rfc1901.py --- python-pysnmp4-4.3.2/pysnmp/proto/rfc1901.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/rfc1901.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,17 +1,18 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.type import univ, namedtype, namedval from pysnmp.proto import rfc1905 -_version = univ.Integer(namedValues=namedval.NamedValues(('version-2c', 1))) +version = univ.Integer(namedValues=namedval.NamedValues(('version-2c', 1))) + class Message(univ.Sequence): componentType = namedtype.NamedTypes( - namedtype.NamedType('version', _version), + namedtype.NamedType('version', version), namedtype.NamedType('community', univ.OctetString()), namedtype.NamedType('data', rfc1905.PDUs()) ) diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/rfc1902.py python-pysnmp4-4.4.3/pysnmp/proto/rfc1902.py --- python-pysnmp4-4.3.2/pysnmp/proto/rfc1902.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/rfc1902.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,18 +1,18 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from sys import version_info from pyasn1.type import univ, tag, constraint, namedtype, namedval -from pyasn1.compat import octets from pysnmp.proto import rfc1155, error __all__ = ['Opaque', 'TimeTicks', 'Bits', 'Integer', 'OctetString', 'IpAddress', 'Counter64', 'Unsigned32', 'Gauge32', 'Integer32', 'ObjectIdentifier', 'Counter32'] + class Integer32(univ.Integer): """Creates an instance of SNMP Integer32 class. @@ -55,7 +55,7 @@ >>> """ - subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint( + subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( -2147483648, 2147483647 ) @@ -63,8 +63,10 @@ def withValues(cls, *values): """Creates a subclass with discreet values constraint. """ + class X(cls): subtypeSpec = cls.subtypeSpec + constraint.SingleValueConstraint(*values) + X.__name__ = cls.__name__ return X @@ -72,11 +74,14 @@ def withRange(cls, minimum, maximum): """Creates a subclass with value range constraint. """ + class X(cls): subtypeSpec = cls.subtypeSpec + constraint.ValueRangeConstraint(minimum, maximum) + X.__name__ = cls.__name__ return X + class Integer(Integer32): """Creates an instance of SNMP INTEGER class. @@ -120,16 +125,20 @@ >>> """ + @classmethod def withNamedValues(cls, **values): """Creates a subclass with discreet named values constraint. """ + class X(cls): namedValues = cls.namedValues + namedval.NamedValues(*values.items()) subtypeSpec = cls.subtypeSpec + constraint.SingleValueConstraint(*values.values()) + X.__name__ = cls.__name__ return X + class OctetString(univ.OctetString): """Creates an instance of SNMP OCTET STRING class. @@ -169,7 +178,7 @@ >>> """ - subtypeSpec = univ.OctetString.subtypeSpec+constraint.ValueSizeConstraint( + subtypeSpec = univ.OctetString.subtypeSpec + constraint.ValueSizeConstraint( 0, 65535 ) @@ -189,38 +198,23 @@ def getFixedLength(self): return self.fixedLength - def clone(self, value=None, tagSet=None, subtypeSpec=None, - encoding=None, binValue=None, hexValue=None): - return univ.OctetString.clone( - self, value, tagSet, subtypeSpec, encoding, binValue, hexValue - ).setFixedLength(self.getFixedLength()) - - def subtype(self, value=None, implicitTag=None, explicitTag=None, - subtypeSpec=None): - return univ.OctetString.subtype( - self, value, implicitTag, explicitTag, subtypeSpec - ).setFixedLength(self.getFixedLength()) + def clone(self, *args, **kwargs): + return univ.OctetString.clone(self, *args, **kwargs).setFixedLength(self.getFixedLength()) + + def subtype(self, *args, **kwargs): + return univ.OctetString.subtype(self, *args, **kwargs).setFixedLength(self.getFixedLength()) @classmethod def withSize(cls, minimum, maximum): """Creates a subclass with value size constraint. """ + class X(cls): subtypeSpec = cls.subtypeSpec + constraint.ValueSizeConstraint(minimum, maximum) + X.__name__ = cls.__name__ return X - # modern pyasn1 does this all by itself - def prettyOut(self, value): - if version_info[0] <= 2: - numbers = tuple((ord(x) for x in value)) - else: - numbers = tuple(value) - for x in numbers: - if x < 32 or x > 126: - return '0x' + ''.join(('%.2x' % x for x in numbers)) - else: - return octets.octs2str(value) class ObjectIdentifier(univ.ObjectIdentifier): """Creates an instance of SNMP OBJECT IDENTIFIER class. @@ -256,6 +250,7 @@ """ + class IpAddress(OctetString): """Creates an instance of SNMP IpAddress class. @@ -289,7 +284,7 @@ tagSet = OctetString.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x00) ) - subtypeSpec = OctetString.subtypeSpec+constraint.ValueSizeConstraint( + subtypeSpec = OctetString.subtypeSpec + constraint.ValueSizeConstraint( 4, 4 ) fixedLength = 4 @@ -299,7 +294,7 @@ try: value = [int(x) for x in value.split('.')] except: - raise error.ProtocolError('Bad IP address syntax %s' % value) + raise error.ProtocolError('Bad IP address syntax %s' % value) value = OctetString.prettyIn(self, value) if len(value) != 4: raise error.ProtocolError('Bad IP address syntax') @@ -313,6 +308,7 @@ else: return '' + class Counter32(univ.Integer): """Creates an instance of SNMP Counter32 class. @@ -347,10 +343,11 @@ tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x01) ) - subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint( + subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) + class Gauge32(univ.Integer): """Creates an instance of SNMP Gauge32 class. @@ -385,10 +382,11 @@ tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x02) ) - subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint( + subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) + class Unsigned32(univ.Integer): """Creates an instance of SNMP Unsigned32 class. @@ -422,10 +420,11 @@ tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x02) ) - subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint( + subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) + class TimeTicks(univ.Integer): """Creates an instance of SNMP TimeTicks class. @@ -459,10 +458,11 @@ tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x03) ) - subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint( + subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) + class Opaque(univ.OctetString): """Creates an instance of SNMP Opaque class. @@ -507,6 +507,7 @@ tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x04) ) + class Counter64(univ.Integer): """Creates an instance of SNMP Counter64 class. @@ -541,10 +542,11 @@ tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x06) ) - subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint( + subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 18446744073709551615 ) + class Bits(OctetString): """Creates an instance of SNMP BITS class. @@ -595,94 +597,50 @@ """ namedValues = namedval.NamedValues() - def __init__(self, value=None, tagSet=None, subtypeSpec=None, - encoding=None, binValue=None, hexValue=None, - namedValues=None): - if namedValues is None: - self.__namedValues = self.namedValues - else: - self.__namedValues = namedValues - OctetString.__init__( - self, value, tagSet, subtypeSpec, encoding, binValue, hexValue - ) + + def __init__(self, value=univ.noValue, **kwargs): + if 'namedValues' not in kwargs: + kwargs['namedValues'] = self.namedValues + + OctetString.__init__(self, value, **kwargs) def prettyIn(self, bits): if not isinstance(bits, (tuple, list)): - return OctetString.prettyIn(self, bits) # raw bitstring + return OctetString.prettyIn(self, bits) # raw bitstring octets = [] - for bit in bits: # tuple of named bits - v = self.__namedValues.getValue(bit) + for bit in bits: # tuple of named bits + v = self.namedValues.getValue(bit) if v is None: - raise error.ProtocolError( - 'Unknown named bit %s' % bit - ) + raise error.ProtocolError('Unknown named bit %s' % bit) d, m = divmod(v, 8) if d >= len(octets): octets.extend([0] * (d - len(octets) + 1)) - octets[d] = octets[d] | 0x01 << (7-m) + octets[d] |= 0x01 << (7 - m) return OctetString.prettyIn(self, octets) def prettyOut(self, value): names = [] ints = self.__class__(value).asNumbers() - i = 0 - while i < len(ints): + for i, v in enumerate(ints): v = ints[i] j = 7 while j >= 0: - if v & (0x01< -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.type import univ, tag, constraint, namedtype, namedval from pysnmp.proto import rfc1902 @@ -19,7 +19,8 @@ # Take SNMP exception values out of BindValue structure for convenience UnSpecified = univ.Null -unSpecified = UnSpecified() +unSpecified = UnSpecified('') + class NoSuchObject(univ.Null): tagSet = univ.Null.tagSet.tagImplicitly( @@ -29,7 +30,9 @@ def prettyPrint(self, scope=0): return 'No Such Object currently exists at this OID' -noSuchObject = NoSuchObject() + +noSuchObject = NoSuchObject('') + class NoSuchInstance(univ.Null): tagSet = univ.Null.tagSet.tagImplicitly( @@ -38,7 +41,10 @@ def prettyPrint(self, scope=0): return 'No Such Instance currently exists at this OID' -noSuchInstance = NoSuchInstance() + + +noSuchInstance = NoSuchInstance('') + class EndOfMibView(univ.Null): tagSet = univ.Null.tagSet.tagImplicitly( @@ -48,7 +54,9 @@ def prettyPrint(self, scope=0): return 'No more variables left in this MIB View' -endOfMibView = EndOfMibView() + +endOfMibView = EndOfMibView('') + # Made a separate class for better readability class _BindValue(univ.Choice): @@ -60,81 +68,104 @@ namedtype.NamedType('endOfMibView', endOfMibView) ) + class VarBind(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('name', rfc1902.ObjectName()), namedtype.NamedType('', _BindValue()) ) + class VarBindList(univ.SequenceOf): componentType = VarBind() subtypeSpec = univ.SequenceOf.subtypeSpec + constraint.ValueSizeConstraint( 0, max_bindings ) -_errorStatus = univ.Integer(namedValues=namedval.NamedValues(('noError', 0), ('tooBig', 1), ('noSuchName', 2), ('badValue', 3), ('readOnly', 4), ('genErr', 5), ('noAccess', 6), ('wrongType', 7), ('wrongLength', 8), ('wrongEncoding', 9), ('wrongValue', 10), ('noCreation', 11), ('inconsistentValue', 12), ('resourceUnavailable', 13), ('commitFailed', 14), ('undoFailed', 15), ('authorizationError', 16), ('notWritable', 17), ('inconsistentName', 18))) + +errorStatus = univ.Integer( + namedValues=namedval.NamedValues(('noError', 0), ('tooBig', 1), ('noSuchName', 2), ('badValue', 3), ('readOnly', 4), + ('genErr', 5), ('noAccess', 6), ('wrongType', 7), ('wrongLength', 8), + ('wrongEncoding', 9), ('wrongValue', 10), ('noCreation', 11), + ('inconsistentValue', 12), ('resourceUnavailable', 13), ('commitFailed', 14), + ('undoFailed', 15), ('authorizationError', 16), ('notWritable', 17), + ('inconsistentName', 18)) + ) + # Base class for a non-bulk PDU class PDU(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('request-id', rfc1902.Integer32()), - namedtype.NamedType('error-status', _errorStatus), - namedtype.NamedType('error-index', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings))), + namedtype.NamedType('error-status', errorStatus), + namedtype.NamedType('error-index', + univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings))), namedtype.NamedType('variable-bindings', VarBindList()) ) -_nonRepeaters = univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings)) -_maxRepetitions = univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings)) + +nonRepeaters = univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings)) +maxRepetitions = univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, max_bindings)) + # Base class for bulk PDU class BulkPDU(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('request-id', rfc1902.Integer32()), - namedtype.NamedType('non-repeaters', _nonRepeaters), - namedtype.NamedType('max-repetitions', _maxRepetitions), + namedtype.NamedType('non-repeaters', nonRepeaters), + namedtype.NamedType('max-repetitions', maxRepetitions), namedtype.NamedType('variable-bindings', VarBindList()) ) + class GetRequestPDU(PDU): tagSet = PDU.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0) ) + class GetNextRequestPDU(PDU): tagSet = PDU.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1) ) + class ResponsePDU(PDU): tagSet = PDU.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2) ) + class SetRequestPDU(PDU): tagSet = PDU.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3) ) + class GetBulkRequestPDU(BulkPDU): tagSet = PDU.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5) ) + class InformRequestPDU(PDU): tagSet = PDU.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 6) ) + class SNMPv2TrapPDU(PDU): tagSet = PDU.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 7) ) + class ReportPDU(PDU): tagSet = PDU.tagSet.tagImplicitly( tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 8) ) + class PDUs(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('get-request', GetRequestPDU()), diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/rfc3411.py python-pysnmp4-4.4.3/pysnmp/proto/rfc3411.py --- python-pysnmp4-4.3.2/pysnmp/proto/rfc3411.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/rfc3411.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto import rfc1157, rfc1905 diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/rfc3412.py python-pysnmp4-4.4.3/pysnmp/proto/rfc3412.py --- python-pysnmp4-4.3.2/pysnmp/proto/rfc3412.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/rfc3412.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,21 +1,24 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from pyasn1.compat.octets import null +from pyasn1.error import PyAsn1Error from pysnmp.smi import builder, instrum from pysnmp.proto import errind, error, cache -from pysnmp.proto.api import verdec # XXX +from pysnmp.proto.api import verdec # XXX from pysnmp.error import PySnmpError from pysnmp import nextid, debug -class MsgAndPduDispatcher: + +class MsgAndPduDispatcher(object): """SNMP engine PDU & message dispatcher. Exchanges SNMP PDU's with applications and serialized messages with transport level. """ + def __init__(self, mibInstrumController=None): if mibInstrumController is None: self.mibInstrumController = instrum.MibInstrumController( @@ -55,7 +58,7 @@ # 4.3.1 def registerContextEngineId(self, contextEngineId, pduTypes, processPdu): """Register application with dispatcher""" - # 4.3.2 -> noop + # 4.3.2 -> no-op # 4.3.3 for pduType in pduTypes: @@ -68,7 +71,8 @@ # 4.3.4 self.__appsRegistration[k] = processPdu - debug.logger & debug.flagDsp and debug.logger('registerContextEngineId: contextEngineId %r pduTypes %s' % (contextEngineId, pduTypes)) + debug.logger & debug.flagDsp and debug.logger( + 'registerContextEngineId: contextEngineId %r pduTypes %s' % (contextEngineId, pduTypes)) # 4.4.1 def unregisterContextEngineId(self, contextEngineId, pduTypes): @@ -76,14 +80,16 @@ # 4.3.4 if contextEngineId is None: # Default to local snmpEngineId - contextEngineId, = self.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + contextEngineId, = self.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', + 'snmpEngineID') for pduType in pduTypes: k = (contextEngineId, pduType) if k in self.__appsRegistration: del self.__appsRegistration[k] - debug.logger & debug.flagDsp and debug.logger('unregisterContextEngineId: contextEngineId %r pduTypes %s' % (contextEngineId, pduTypes)) + debug.logger & debug.flagDsp and debug.logger( + 'unregisterContextEngineId: contextEngineId %r pduTypes %s' % (contextEngineId, pduTypes)) def getRegisteredApp(self, contextEngineId, pduType): k = (contextEngineId, pduType) @@ -91,7 +97,7 @@ return self.__appsRegistration[k] k = (null, pduType) if k in self.__appsRegistration: - return self.__appsRegistration[k] # wildcard + return self.__appsRegistration[k] # wildcard # Dispatcher <-> application API @@ -112,7 +118,8 @@ errorIndication=errind.unsupportedMsgProcessingModel ) - debug.logger & debug.flagDsp and debug.logger('sendPdu: securityName %s, PDU\n%s' % (securityName, PDU.prettyPrint())) + debug.logger & debug.flagDsp and debug.logger( + 'sendPdu: securityName %s, PDU\n%s' % (securityName, PDU.prettyPrint())) # 4.1.1.3 sendPduHandle = self.__sendPduHandle() @@ -121,14 +128,16 @@ sendPduHandle, messageProcessingModel=messageProcessingModel, sendPduHandle=sendPduHandle, - timeout=timeout+snmpEngine.transportDispatcher.getTimerTicks(), + timeout=timeout + snmpEngine.transportDispatcher.getTimerTicks(), cbFun=cbFun, cbCtx=cbCtx ) - debug.logger & debug.flagDsp and debug.logger('sendPdu: current time %d ticks, one tick is %s seconds' % (snmpEngine.transportDispatcher.getTimerTicks(), snmpEngine.transportDispatcher.getTimerResolution())) + debug.logger & debug.flagDsp and debug.logger('sendPdu: current time %d ticks, one tick is %s seconds' % ( + snmpEngine.transportDispatcher.getTimerTicks(), snmpEngine.transportDispatcher.getTimerResolution())) - debug.logger & debug.flagDsp and debug.logger('sendPdu: new sendPduHandle %s, timeout %s ticks, cbFun %s' % (sendPduHandle, timeout, cbFun)) + debug.logger & debug.flagDsp and debug.logger( + 'sendPdu: new sendPduHandle %s, timeout %s ticks, cbFun %s' % (sendPduHandle, timeout, cbFun)) origTransportDomain = transportDomain origTransportAddress = transportAddress @@ -138,11 +147,11 @@ (transportDomain, transportAddress, outgoingMessage) = mpHandler.prepareOutgoingMessage( - snmpEngine, origTransportDomain, origTransportAddress, - messageProcessingModel, securityModel, securityName, - securityLevel, contextEngineId, contextName, - pduVersion, PDU, expectResponse, sendPduHandle - ) + snmpEngine, origTransportDomain, origTransportAddress, + messageProcessingModel, securityModel, securityName, + securityLevel, contextEngineId, contextName, + pduVersion, PDU, expectResponse, sendPduHandle + ) debug.logger & debug.flagDsp and debug.logger('sendPdu: MP succeeded') except PySnmpError: @@ -213,18 +222,19 @@ errorIndication=errind.unsupportedMsgProcessingModel ) - debug.logger & debug.flagDsp and debug.logger('returnResponsePdu: PDU %s' % (PDU and PDU.prettyPrint() or "",)) + debug.logger & debug.flagDsp and debug.logger( + 'returnResponsePdu: PDU %s' % (PDU and PDU.prettyPrint() or "",)) # 4.1.2.2 try: (transportDomain, transportAddress, outgoingMessage) = mpHandler.prepareResponseMessage( - snmpEngine, messageProcessingModel, securityModel, - securityName, securityLevel, contextEngineId, contextName, - pduVersion, PDU, maxSizeResponseScopedPDU, stateReference, - statusInformation - ) + snmpEngine, messageProcessingModel, securityModel, + securityName, securityLevel, contextEngineId, contextName, + pduVersion, PDU, maxSizeResponseScopedPDU, stateReference, + statusInformation + ) debug.logger & debug.flagDsp and debug.logger('returnResponsePdu: MP suceeded') @@ -233,9 +243,10 @@ raise # Handle oversized messages XXX transport constrains? - snmpEngineMaxMessageSize, = self.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') - if snmpEngineMaxMessageSize.syntax and \ - len(outgoingMessage) > snmpEngineMaxMessageSize.syntax: + snmpEngineMaxMessageSize, = self.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', + 'snmpEngineMaxMessageSize') + if (snmpEngineMaxMessageSize.syntax and + len(outgoingMessage) > snmpEngineMaxMessageSize.syntax): snmpSilentDrops, = self.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpSilentDrops') snmpSilentDrops.syntax += 1 raise error.StatusInformation(errorIndication=errind.tooBig) @@ -271,15 +282,17 @@ # 4.2.1.1 snmpInPkts, = self.mibInstrumController.mibBuilder.importSymbols( '__SNMPv2-MIB', 'snmpInPkts' - ) + ) snmpInPkts.syntax += 1 # 4.2.1.2 try: - restOfWholeMsg = null # XXX fix decoder non-recursive return + restOfWholeMsg = null # XXX fix decoder non-recursive return msgVersion = verdec.decodeMessageVersion(wholeMsg) + except error.ProtocolError: - snmpInASNParseErrs, = self.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') + snmpInASNParseErrs, = self.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', + 'snmpInASNParseErrs') snmpInASNParseErrs.syntax += 1 return null # n.b the whole buffer gets dropped @@ -287,10 +300,10 @@ messageProcessingModel = msgVersion - k = int(messageProcessingModel) - if k in snmpEngine.messageProcessingSubsystems: - mpHandler = snmpEngine.messageProcessingSubsystems[k] - else: + try: + mpHandler = snmpEngine.messageProcessingSubsystems[int(messageProcessingModel)] + + except KeyError: snmpInBadVersions, = self.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInBadVersions') snmpInBadVersions.syntax += 1 return restOfWholeMsg @@ -299,13 +312,21 @@ # 4.2.1.4 try: - (messageProcessingModel, securityModel, securityName, - securityLevel, contextEngineId, contextName, - pduVersion, PDU, pduType, sendPduHandle, - maxSizeResponseScopedPDU, statusInformation, + (messageProcessingModel, + securityModel, + securityName, + securityLevel, + contextEngineId, + contextName, + pduVersion, + PDU, + pduType, + sendPduHandle, + maxSizeResponseScopedPDU, + statusInformation, stateReference) = mpHandler.prepareDataElements( - snmpEngine, transportDomain, transportAddress, wholeMsg - ) + snmpEngine, transportDomain, transportAddress, wholeMsg + ) debug.logger & debug.flagDsp and debug.logger('receiveMessage: MP succeded') @@ -314,7 +335,8 @@ if 'sendPduHandle' in statusInformation: # Dropped REPORT -- re-run pending reqs queue as some # of them may be waiting for this REPORT - debug.logger & debug.flagDsp and debug.logger('receiveMessage: MP failed, statusInformation %s, forcing a retry' % statusInformation) + debug.logger & debug.flagDsp and debug.logger( + 'receiveMessage: MP failed, statusInformation %s, forcing a retry' % statusInformation) self.__expireRequest( statusInformation['sendPduHandle'], self.__cache.pop(statusInformation['sendPduHandle']), @@ -323,6 +345,13 @@ ) return restOfWholeMsg + except PyAsn1Error: + debug.logger & debug.flagMP and debug.logger('receiveMessage: %s' % (sys.exc_info()[1],)) + snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') + snmpInASNParseErrs.syntax += 1 + + return restOfWholeMsg + debug.logger & debug.flagDsp and debug.logger('receiveMessage: PDU %s' % PDU.prettyPrint()) # 4.2.2 @@ -336,7 +365,8 @@ # 4.2.2.1.2 if processPdu is None: # 4.2.2.1.2.a - snmpUnknownPDUHandlers, = self.mibInstrumController.mibBuilder.importSymbols('__SNMP-MPD-MIB', 'snmpUnknownPDUHandlers') + snmpUnknownPDUHandlers, = self.mibInstrumController.mibBuilder.importSymbols('__SNMP-MPD-MIB', + 'snmpUnknownPDUHandlers') snmpUnknownPDUHandlers.syntax += 1 # 4.2.2.1.2.b @@ -348,37 +378,33 @@ debug.logger & debug.flagDsp and debug.logger('receiveMessage: unhandled PDU type') - # XXX fails on unknown PDU - + # 4.2.2.1.2.c try: (destTransportDomain, destTransportAddress, outgoingMessage) = mpHandler.prepareResponseMessage( - snmpEngine, messageProcessingModel, - securityModel, securityName, securityLevel, - contextEngineId, contextName, pduVersion, - PDU, maxSizeResponseScopedPDU, stateReference, - statusInformation - ) - - except error.StatusInformation: - debug.logger & debug.flagDsp and debug.logger('receiveMessage: report failed, statusInformation %s' % sys.exc_info()[1]) - return restOfWholeMsg + snmpEngine, messageProcessingModel, + securityModel, securityName, securityLevel, + contextEngineId, contextName, pduVersion, + PDU, maxSizeResponseScopedPDU, stateReference, + statusInformation + ) - # 4.2.2.1.2.c - try: snmpEngine.transportDispatcher.sendMessage( outgoingMessage, destTransportDomain, destTransportAddress ) - except PySnmpError: # XXX - pass + except PySnmpError: + debug.logger & debug.flagDsp and debug.logger( + 'receiveMessage: report failed, statusInformation %s' % sys.exc_info()[1]) - debug.logger & debug.flagDsp and debug.logger('receiveMessage: reporting succeeded') + else: + debug.logger & debug.flagDsp and debug.logger('receiveMessage: reporting succeeded') # 4.2.2.1.2.d return restOfWholeMsg + else: snmpEngine.observer.storeExecutionContext( snmpEngine, 'rfc3412.receiveMessage:request', @@ -424,11 +450,13 @@ # 4.2.2.2.2 if cachedParams is None: - snmpUnknownPDUHandlers, = self.mibInstrumController.mibBuilder.importSymbols('__SNMP-MPD-MIB', 'snmpUnknownPDUHandlers') + snmpUnknownPDUHandlers, = self.mibInstrumController.mibBuilder.importSymbols('__SNMP-MPD-MIB', + 'snmpUnknownPDUHandlers') snmpUnknownPDUHandlers.syntax += 1 return restOfWholeMsg - debug.logger & debug.flagDsp and debug.logger('receiveMessage: cache read by sendPduHandle %s' % sendPduHandle) + debug.logger & debug.flagDsp and debug.logger( + 'receiveMessage: cache read by sendPduHandle %s' % sendPduHandle) # 4.2.2.2.3 # no-op ? XXX @@ -476,6 +504,7 @@ # Cache expiration stuff + # noinspection PyUnusedLocal def __expireRequest(self, cacheKey, cachedParams, snmpEngine, statusInformation=None): timeNow = snmpEngine.transportDispatcher.getTimerTicks() @@ -504,5 +533,6 @@ cachedParams['cbCtx']) return True + # noinspection PyUnusedLocal def receiveTimerTick(self, snmpEngine, timeNow): self.__cache.expire(self.__expireRequest, snmpEngine) diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/base.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/base.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,14 +1,16 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto.secmod import cache from pysnmp.proto import error -class AbstractSecurityModel: + +class AbstractSecurityModel(object): securityModelID = None + def __init__(self): self._cache = cache.Cache() diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/cache.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/cache.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/cache.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/cache.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,14 +1,16 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp import nextid from pysnmp.proto import error -class Cache: + +class Cache(object): __stateReference = nextid.Integer(0xffffff) + def __init__(self): self.__cacheEntries = {} diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/eso/priv/aes192.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/eso/priv/aes192.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/eso/priv/aes192.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/eso/priv/aes192.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,15 +1,33 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto.secmod.eso.priv import aesbase -class Aes192(aesbase.AbstractAes): - """AES 192/256 bit encryption (Internet draft) + +class AesBlumenthal192(aesbase.AbstractAesBlumenthal): + """AES 192 bit encryption (Internet draft) + + Reeder AES encryption: http://tools.ietf.org/html/draft-blumenthal-aes-usm-04 """ serviceID = (1, 3, 6, 1, 4, 1, 9, 12, 6, 1, 1) # cusmAESCfb192PrivProtocol keySize = 24 + + +class Aes192(aesbase.AbstractAesReeder): + """AES 192 bit encryption (Internet draft) + + Reeder AES encryption with non-standard key localization algorithm + borrowed from Reeder 3DES draft: + + http://tools.ietf.org/html/draft-blumenthal-aes-usm-04 + https://tools.ietf.org/html/draft-reeder-snmpv3-usm-3desede-00 + + Known to be used by many vendors including Cisco and others. + """ + serviceID = (1, 3, 6, 1, 4, 1, 9, 12, 6, 1, 101) # cusmAESCfb192PrivProtocol (non-standard OID) + keySize = 24 diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/eso/priv/aes256.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/eso/priv/aes256.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/eso/priv/aes256.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/eso/priv/aes256.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,15 +1,31 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto.secmod.eso.priv import aesbase -class Aes256(aesbase.AbstractAes): - """AES 192/256 bit encryption (Internet draft) + +class AesBlumenthal256(aesbase.AbstractAesBlumenthal): + """AES 256 bit encryption (Internet draft) http://tools.ietf.org/html/draft-blumenthal-aes-usm-04 """ serviceID = (1, 3, 6, 1, 4, 1, 9, 12, 6, 1, 2) # cusmAESCfb256PrivProtocol keySize = 32 + + +class Aes256(aesbase.AbstractAesReeder): + """AES 256 bit encryption (Internet draft) + + Reeder AES encryption with non-standard key localization algorithm + borrowed from Reeder 3DES draft: + + http://tools.ietf.org/html/draft-blumenthal-aes-usm-04 + https://tools.ietf.org/html/draft-reeder-snmpv3-usm-3desede-00 + + Known to be used by many vendors including Cisco and others. + """ + serviceID = (1, 3, 6, 1, 4, 1, 9, 12, 6, 1, 102) # cusmAESCfb256PrivProtocol (non-standard OID) + keySize = 32 diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/eso/priv/aesbase.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/eso/priv/aesbase.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/eso/priv/aesbase.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/eso/priv/aesbase.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,37 +1,89 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto.secmod.rfc3826.priv import aes from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha +from pysnmp.proto.secmod.rfc7860.auth import hmacsha2 from pysnmp.proto.secmod.rfc3414 import localkey from pysnmp.proto import error from math import ceil + try: from hashlib import md5, sha1 except ImportError: - import md5, sha + import md5 + import sha + md5 = md5.new sha1 = sha.new -class AbstractAes(aes.Aes): + +class AbstractAesBlumenthal(aes.Aes): serviceID = () keySize = 0 # 3.1.2.1 def localizeKey(self, authProtocol, privKey, snmpEngineID): if authProtocol == hmacmd5.HmacMd5.serviceID: - localPrivKey = localkey.localizeKeyMD5(privKey, snmpEngineID) - while ceil(self.keySize//len(localPrivKey)): - localPrivKey = localPrivKey + md5(localPrivKey).digest() + hashAlgo = md5 + elif authProtocol == hmacsha.HmacSha.serviceID: + hashAlgo = sha1 + elif authProtocol in hmacsha2.HmacSha2.hashAlgorithms: + hashAlgo = hmacsha2.HmacSha2.hashAlgorithms[authProtocol] + else: + raise error.ProtocolError( + 'Unknown auth protocol %s' % (authProtocol,) + ) + + localPrivKey = localkey.localizeKey(privKey, snmpEngineID, hashAlgo) + + # now extend this key if too short by repeating steps that includes the hashPassphrase step + for count in range(1, int(ceil(self.keySize * 1.0 / len(localPrivKey)))): + localPrivKey += hashAlgo(localPrivKey).digest() + + return localPrivKey[:self.keySize] + + +class AbstractAesReeder(aes.Aes): + """AES encryption with non-standard key localization. + + Many vendors (including Cisco) do not use: + + https://tools.itef.org/pdf/draft_bluementhal-aes-usm-04.txt + + for key localization instead, they use the procedure for 3DES key localization + specified in: + + https://tools.itef.org/pdf/draft_reeder_snmpv3-usm-3desede-00.pdf + + The difference between the two is that the Reeder draft does key extension by repeating + the steps in the password to key algorithm (hash phrase, then localize with SNMPEngine ID). + """ + serviceID = () + keySize = 0 + + # 2.1 of https://tools.itef.org/pdf/draft_bluementhal-aes-usm-04.txt + def localizeKey(self, authProtocol, privKey, snmpEngineID): + if authProtocol == hmacmd5.HmacMd5.serviceID: + hashAlgo = md5 elif authProtocol == hmacsha.HmacSha.serviceID: - localPrivKey = localkey.localizeKeySHA(privKey, snmpEngineID) - while ceil(self.keySize//len(localPrivKey)): - localPrivKey = localPrivKey + sha1(localPrivKey).digest() + hashAlgo = sha1 + elif authProtocol in hmacsha2.HmacSha2.hashAlgorithms: + hashAlgo = hmacsha2.HmacSha2.hashAlgorithms[authProtocol] else: raise error.ProtocolError( 'Unknown auth protocol %s' % (authProtocol,) - ) + ) + + localPrivKey = localkey.localizeKey(privKey, snmpEngineID, hashAlgo) + + # now extend this key if too short by repeating steps that includes the hashPassphrase step + while len(localPrivKey) < self.keySize: + # this is the difference between reeder and bluementhal + newKey = localkey.hashPassphrase(localPrivKey, hashAlgo) + localPrivKey += localkey.localizeKey(newKey, snmpEngineID, hashAlgo) + return localPrivKey[:self.keySize] diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/eso/priv/des3.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/eso/priv/des3.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/eso/priv/des3.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/eso/priv/des3.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,13 +1,14 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import random from pysnmp.proto.secmod.rfc3414.priv import base from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha from pysnmp.proto.secmod.rfc3414 import localkey +from pysnmp.proto.secmod.rfc7860.auth import hmacsha2 from pysnmp.proto import errind, error from pyasn1.type import univ from pyasn1.compat.octets import null @@ -16,52 +17,58 @@ try: from hashlib import md5, sha1 except ImportError: - import md5, sha + import md5 + import sha + md5 = md5.new sha1 = sha.new try: - from Crypto.Cipher import DES3 + from Cryptodome.Cipher import DES3 except ImportError: DES3 = None random.seed() + # 5.1.1 class Des3(base.AbstractEncryptionService): """Reeder 3DES-EDE for USM (Internet draft). - http://www.snmp.com/eso/draft-reeder-snmpv3-usm-3desede-00.txt + https://tools.ietf.org/html/draft-reeder-snmpv3-usm-3desede-00 """ - serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 2, 3) # usm3DESEDEPrivProtocol + serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 2, 3) # usm3DESEDEPrivProtocol keySize = 32 _localInt = random.randrange(0, 0xffffffff) def hashPassphrase(self, authProtocol, privKey): if authProtocol == hmacmd5.HmacMd5.serviceID: - return localkey.hashPassphraseMD5(privKey) + hashAlgo = md5 elif authProtocol == hmacsha.HmacSha.serviceID: - return localkey.hashPassphraseSHA(privKey) + hashAlgo = sha1 + elif authProtocol in hmacsha2.HmacSha2.hashAlgorithms: + hashAlgo = hmacsha2.HmacSha2.hashAlgorithms[authProtocol] else: raise error.ProtocolError( 'Unknown auth protocol %s' % (authProtocol,) - ) + ) + return localkey.hashPassphrase(privKey, hashAlgo) + # 2.1 def localizeKey(self, authProtocol, privKey, snmpEngineID): if authProtocol == hmacmd5.HmacMd5.serviceID: - localPrivKey = localkey.localizeKeyMD5(privKey, snmpEngineID) - while ceil(self.keySize//len(localPrivKey)): - localPrivKey = localPrivKey + md5(localPrivKey).digest() + hashAlgo = md5 elif authProtocol == hmacsha.HmacSha.serviceID: - localPrivKey = localkey.localizeKeySHA(privKey, snmpEngineID) - while ceil(self.keySize//len(localPrivKey)): - localPrivKey = localPrivKey + sha1(localPrivKey).digest() + hashAlgo = sha1 + elif authProtocol in hmacsha2.HmacSha2.hashAlgorithms: + hashAlgo = hmacsha2.HmacSha2.hashAlgorithms[authProtocol] else: raise error.ProtocolError( 'Unknown auth protocol %s' % (authProtocol,) - ) - return localPrivKey[:self.keySize] # key+IV + ) + localPrivKey = localkey.localizeKey(privKey, snmpEngineID, hashAlgo) + return localPrivKey[:self.keySize] # 5.1.1.1 def __getEncryptionKey(self, privKey, snmpEngineBoots): @@ -72,56 +79,50 @@ securityEngineBoots = int(snmpEngineBoots) salt = [ - securityEngineBoots>>24&0xff, - securityEngineBoots>>16&0xff, - securityEngineBoots>>8&0xff, - securityEngineBoots&0xff, - self._localInt>>24&0xff, - self._localInt>>16&0xff, - self._localInt>>8&0xff, - self._localInt&0xff - ] + securityEngineBoots >> 24 & 0xff, + securityEngineBoots >> 16 & 0xff, + securityEngineBoots >> 8 & 0xff, + securityEngineBoots & 0xff, + self._localInt >> 24 & 0xff, + self._localInt >> 16 & 0xff, + self._localInt >> 8 & 0xff, + self._localInt & 0xff + ] if self._localInt == 0xffffffff: self._localInt = 0 else: - self._localInt = self._localInt + 1 + self._localInt += 1 # salt not yet hashed XXX - return des3Key.asOctets(), \ - univ.OctetString(salt).asOctets(), \ - univ.OctetString(map(lambda x, y: x^y, salt, preIV.asNumbers())).asOctets() - - def __getDecryptionKey(self, privKey, salt): - return privKey[:24].asOctets(), \ - univ.OctetString(map(lambda x, y: x^y, salt.asNumbers(), privKey[24:32].asNumbers())).asOctets() + return (des3Key.asOctets(), + univ.OctetString(salt).asOctets(), + univ.OctetString(map(lambda x, y: x ^ y, salt, preIV.asNumbers())).asOctets()) + + @staticmethod + def __getDecryptionKey(privKey, salt): + return (privKey[:24].asOctets(), + univ.OctetString(map(lambda x, y: x ^ y, salt.asNumbers(), privKey[24:32].asNumbers())).asOctets()) # 5.1.1.2 def encryptData(self, encryptKey, privParameters, dataToEncrypt): if DES3 is None: raise error.StatusInformation( errorIndication=errind.encryptionError - ) + ) snmpEngineBoots, snmpEngineTime, salt = privParameters des3Key, salt, iv = self.__getEncryptionKey( encryptKey, snmpEngineBoots - ) + ) des3Obj = DES3.new(des3Key, DES3.MODE_CBC, iv) privParameters = univ.OctetString(salt) plaintext = dataToEncrypt + univ.OctetString((0,) * (8 - len(dataToEncrypt) % 8)).asOctets() - cipherblock = iv - ciphertext = null - while plaintext: - cipherblock = des3Obj.encrypt( - univ.OctetString(map(lambda x, y: x^y, univ.OctetString(cipherblock).asNumbers(), univ.OctetString(plaintext[:8]).asNumbers())).asOctets() - ) - ciphertext = ciphertext + cipherblock - plaintext = plaintext[8:] + ciphertext = des3Obj.encrypt(plaintext) return univ.OctetString(ciphertext), privParameters @@ -130,29 +131,24 @@ if DES3 is None: raise error.StatusInformation( errorIndication=errind.decryptionError - ) + ) snmpEngineBoots, snmpEngineTime, salt = privParameters if len(salt) != 8: raise error.StatusInformation( errorIndication=errind.decryptionError - ) + ) des3Key, iv = self.__getDecryptionKey(decryptKey, salt) if len(encryptedData) % 8 != 0: raise error.StatusInformation( errorIndication=errind.decryptionError - ) + ) des3Obj = DES3.new(des3Key, DES3.MODE_CBC, iv) - plaintext = null ciphertext = encryptedData.asOctets() - cipherblock = iv - while ciphertext: - plaintext = plaintext + univ.OctetString(map(lambda x, y: x ^ y, univ.OctetString(cipherblock).asNumbers(), univ.OctetString(des3Obj.decrypt(ciphertext[:8])).asNumbers())).asOctets() - cipherblock = ciphertext[:8] - ciphertext = ciphertext[8:] + plaintext = des3Obj.decrypt(ciphertext) return plaintext diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc2576.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc2576.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc2576.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc2576.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from pyasn1.codec.ber import encoder @@ -13,8 +13,10 @@ from pysnmp.proto import errind, error from pysnmp import debug + class SnmpV1SecurityModel(base.AbstractSecurityModel): securityModelID = 1 + # According to rfc2576, community name <-> contextEngineId/contextName # mapping is up to MP module for notifications but belongs to secmod # responsibility for other PDU types. Since I do not yet understand @@ -26,9 +28,11 @@ base.AbstractSecurityModel.__init__(self) def _sec2com(self, snmpEngine, securityName, contextEngineId, contextName): - snmpTargetParamsSecurityName, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsSecurityName') + snmpTargetParamsSecurityName, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + 'SNMP-TARGET-MIB', 'snmpTargetParamsSecurityName') if self.__paramsBranchId != snmpTargetParamsSecurityName.branchVersionId: - snmpTargetParamsSecurityModel, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsSecurityModel') + snmpTargetParamsSecurityModel, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + 'SNMP-TARGET-MIB', 'snmpTargetParamsSecurityModel') self.__nameToModelMap = {} @@ -55,14 +59,15 @@ # invalidate next map as it include this one self.__securityBranchId = -1 - snmpCommunityName, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-COMMUNITY-MIB', 'snmpCommunityName') + snmpCommunityName, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-COMMUNITY-MIB', + 'snmpCommunityName') if self.__securityBranchId != snmpCommunityName.branchVersionId: (snmpCommunitySecurityName, snmpCommunityContextEngineId, snmpCommunityContextName) = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( - 'SNMP-COMMUNITY-MIB', 'snmpCommunitySecurityName', - 'snmpCommunityContextEngineID', 'snmpCommunityContextName' - ) + 'SNMP-COMMUNITY-MIB', 'snmpCommunitySecurityName', + 'snmpCommunityContextEngineID', 'snmpCommunityContextName' + ) self.__securityMap = {} @@ -78,7 +83,8 @@ _securityName = snmpCommunitySecurityName.getNode(snmpCommunitySecurityName.name + instId).syntax - _contextEngineId = snmpCommunityContextEngineId.getNode(snmpCommunityContextEngineId.name + instId).syntax + _contextEngineId = snmpCommunityContextEngineId.getNode( + snmpCommunityContextEngineId.name + instId).syntax _contextName = snmpCommunityContextName.getNode(snmpCommunityContextName.name + instId).syntax @@ -88,7 +94,9 @@ self.__securityBranchId = snmpCommunityName.branchVersionId - debug.logger & debug.flagSM and debug.logger('_sec2com: built securityName to communityName map, version %s: %s' % (self.__securityBranchId, self.__securityMap)) + debug.logger & debug.flagSM and debug.logger( + '_sec2com: built securityName to communityName map, version %s: %s' % ( + self.__securityBranchId, self.__securityMap)) try: return self.__securityMap[(securityName, @@ -101,13 +109,14 @@ ) def _com2sec(self, snmpEngine, communityName, transportInformation): - snmpTargetAddrTAddress, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetAddrTAddress') + snmpTargetAddrTAddress, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + 'SNMP-TARGET-MIB', 'snmpTargetAddrTAddress') if self.__transportBranchId != snmpTargetAddrTAddress.branchVersionId: (SnmpTagValue, snmpTargetAddrTDomain, snmpTargetAddrTagList) = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( - 'SNMP-TARGET-MIB', 'SnmpTagValue', 'snmpTargetAddrTDomain', - 'snmpTargetAddrTagList' - ) + 'SNMP-TARGET-MIB', 'SnmpTagValue', 'snmpTargetAddrTDomain', + 'snmpTargetAddrTagList' + ) self.__emptyTag = SnmpTagValue('') @@ -126,10 +135,12 @@ targetAddrTDomain = tuple(targetAddrTDomain) if targetAddrTDomain[:len(udp.snmpUDPDomain)] == udp.snmpUDPDomain: - SnmpUDPAddress, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMPv2-TM', 'SnmpUDPAddress') + SnmpUDPAddress, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMPv2-TM', + 'SnmpUDPAddress') targetAddrTAddress = tuple(SnmpUDPAddress(targetAddrTAddress)) elif targetAddrTDomain[:len(udp6.snmpUDP6Domain)] == udp6.snmpUDP6Domain: - TransportAddressIPv6, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('TRANSPORT-ADDRESS-MIB', 'TransportAddressIPv6') + TransportAddressIPv6, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + 'TRANSPORT-ADDRESS-MIB', 'TransportAddressIPv6') targetAddrTAddress = tuple(TransportAddressIPv6(targetAddrTAddress)) elif targetAddrTDomain[:len(unix.snmpLocalDomain)] == unix.snmpLocalDomain: targetAddrTAddress = str(targetAddrTAddress) @@ -147,11 +158,14 @@ self.__transportBranchId = snmpTargetAddrTAddress.branchVersionId - debug.logger & debug.flagSM and debug.logger('_com2sec: built transport-to-tag map version %s: %s' % (self.__transportBranchId, self.__transportToTagMap)) + debug.logger & debug.flagSM and debug.logger('_com2sec: built transport-to-tag map version %s: %s' % ( + self.__transportBranchId, self.__transportToTagMap)) - snmpTargetParamsSecurityName, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsSecurityName') + snmpTargetParamsSecurityName, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + 'SNMP-TARGET-MIB', 'snmpTargetParamsSecurityName') if self.__paramsBranchId != snmpTargetParamsSecurityName.branchVersionId: - snmpTargetParamsSecurityModel, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsSecurityModel') + snmpTargetParamsSecurityModel, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + 'SNMP-TARGET-MIB', 'snmpTargetParamsSecurityModel') self.__nameToModelMap = {} @@ -178,17 +192,20 @@ # invalidate next map as it include this one self.__communityBranchId = -1 - debug.logger & debug.flagSM and debug.logger('_com2sec: built securityName to securityModel map, version %s: %s' % (self.__paramsBranchId, self.__nameToModelMap)) + debug.logger & debug.flagSM and debug.logger( + '_com2sec: built securityName to securityModel map, version %s: %s' % ( + self.__paramsBranchId, self.__nameToModelMap)) - snmpCommunityName, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-COMMUNITY-MIB', 'snmpCommunityName') + snmpCommunityName, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-COMMUNITY-MIB', + 'snmpCommunityName') if self.__communityBranchId != snmpCommunityName.branchVersionId: (snmpCommunitySecurityName, snmpCommunityContextEngineId, snmpCommunityContextName, snmpCommunityTransportTag) = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( - 'SNMP-COMMUNITY-MIB', 'snmpCommunitySecurityName', - 'snmpCommunityContextEngineID', 'snmpCommunityContextName', - 'snmpCommunityTransportTag' - ) + 'SNMP-COMMUNITY-MIB', 'snmpCommunitySecurityName', + 'snmpCommunityContextEngineID', 'snmpCommunityContextName', + 'snmpCommunityTransportTag' + ) self.__communityToTagMap = {} self.__tagAndCommunityToSecurityMap = {} @@ -205,7 +222,8 @@ securityName = snmpCommunitySecurityName.getNode(snmpCommunitySecurityName.name + instId).syntax - contextEngineId = snmpCommunityContextEngineId.getNode(snmpCommunityContextEngineId.name + instId).syntax + contextEngineId = snmpCommunityContextEngineId.getNode( + snmpCommunityContextEngineId.name + instId).syntax contextName = snmpCommunityContextName.getNode(snmpCommunityContextName.name + instId).syntax @@ -227,13 +245,18 @@ self.__communityBranchId = snmpCommunityName.branchVersionId - debug.logger & debug.flagSM and debug.logger('_com2sec: built communityName to tag map (securityModel %s), version %s: %s' % (self.securityModelID, self.__communityBranchId, self.__communityToTagMap)) - - debug.logger & debug.flagSM and debug.logger('_com2sec: built tag & community to securityName map (securityModel %s), version %s: %s' % (self.securityModelID, self.__communityBranchId, self.__tagAndCommunityToSecurityMap)) + debug.logger & debug.flagSM and debug.logger( + '_com2sec: built communityName to tag map (securityModel %s), version %s: %s' % ( + self.securityModelID, self.__communityBranchId, self.__communityToTagMap)) + + debug.logger & debug.flagSM and debug.logger( + '_com2sec: built tag & community to securityName map (securityModel %s), version %s: %s' % ( + self.securityModelID, self.__communityBranchId, self.__tagAndCommunityToSecurityMap)) if communityName in self.__communityToTagMap: if transportInformation in self.__transportToTagMap: - tags = self.__transportToTagMap[transportInformation].intersection(self.__communityToTagMap[communityName]) + tags = self.__transportToTagMap[transportInformation].intersection( + self.__communityToTagMap[communityName]) elif self.__emptyTag in self.__communityToTagMap[communityName]: tags = [self.__emptyTag] else: @@ -247,9 +270,14 @@ # 5.2.1 (row selection in snmpCommunityTable) # Picks first match but favors entries already in targets table if candidateSecurityNames: - candidateSecurityNames.sort(key=lambda x, m=self.__nameToModelMap, v=self.securityModelID: (not int(x[0] in m and v in m[x[0]]), str(x[0]))) + candidateSecurityNames.sort( + key=lambda x, m=self.__nameToModelMap, v=self.securityModelID: ( + not int(x[0] in m and v in m[x[0]]), str(x[0])) + ) chosenSecurityName = candidateSecurityNames[0] # min() - debug.logger & debug.flagSM and debug.logger('_com2sec: securityName candidates for communityName \'%s\' are %s; choosing securityName \'%s\'' % (communityName, candidateSecurityNames, chosenSecurityName[0])) + debug.logger & debug.flagSM and debug.logger( + '_com2sec: securityName candidates for communityName \'%s\' are %s; choosing securityName \'%s\'' % ( + communityName, candidateSecurityNames, chosenSecurityName[0])) return chosenSecurityName raise error.StatusInformation(errorIndication=errind.unknownCommunityName) @@ -265,14 +293,16 @@ communityName = self._sec2com(snmpEngine, securityName, contextEngineId, contextName) - debug.logger & debug.flagSM and debug.logger('generateRequestMsg: using community %r for securityModel %r, securityName %r, contextEngineId %r contextName %r' % (communityName, securityModel, securityName, contextEngineId, contextName)) + debug.logger & debug.flagSM and debug.logger( + 'generateRequestMsg: using community %r for securityModel %r, securityName %r, contextEngineId %r contextName %r' % ( + communityName, securityModel, securityName, contextEngineId, contextName)) securityParameters = communityName msg.setComponentByPosition(1, securityParameters) msg.setComponentByPosition(2) msg.getComponentByPosition(2).setComponentByType( - pdu.tagSet, pdu, verifyConstraints=False + pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False ) debug.logger & debug.flagMP and debug.logger('generateRequestMsg: %s' % (msg.prettyPrint(),)) @@ -281,7 +311,8 @@ return securityParameters, encoder.encode(msg) except PyAsn1Error: - debug.logger & debug.flagMP and debug.logger('generateRequestMsg: serialization failure: %s' % sys.exc_info()[1]) + debug.logger & debug.flagMP and debug.logger( + 'generateRequestMsg: serialization failure: %s' % sys.exc_info()[1]) raise error.StatusInformation(errorIndication=errind.serializationError) def generateResponseMsg(self, snmpEngine, messageProcessingModel, @@ -294,12 +325,14 @@ cachedSecurityData = self._cache.pop(securityStateReference) communityName = cachedSecurityData['communityName'] - debug.logger & debug.flagSM and debug.logger('generateResponseMsg: recovered community %r by securityStateReference %s' % (communityName, securityStateReference)) + debug.logger & debug.flagSM and debug.logger( + 'generateResponseMsg: recovered community %r by securityStateReference %s' % ( + communityName, securityStateReference)) msg.setComponentByPosition(1, communityName) msg.setComponentByPosition(2) msg.getComponentByPosition(2).setComponentByType( - pdu.tagSet, pdu, verifyConstraints=False + pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False ) debug.logger & debug.flagMP and debug.logger('generateResponseMsg: %s' % (msg.prettyPrint(),)) @@ -308,7 +341,8 @@ return communityName, encoder.encode(msg) except PyAsn1Error: - debug.logger & debug.flagMP and debug.logger('generateResponseMsg: serialization failure: %s' % sys.exc_info()[1]) + debug.logger & debug.flagMP and debug.logger( + 'generateResponseMsg: serialization failure: %s' % sys.exc_info()[1]) raise error.StatusInformation(errorIndication=errind.serializationError) def processIncomingMsg(self, snmpEngine, messageProcessingModel, @@ -334,11 +368,16 @@ ) except error.StatusInformation: - snmpInBadCommunityNames, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInBadCommunityNames') + snmpInBadCommunityNames, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols( + '__SNMPv2-MIB', 'snmpInBadCommunityNames') snmpInBadCommunityNames.syntax += 1 - raise error.StatusInformation(errorIndication=errind.unknownCommunityName) + raise error.StatusInformation( + errorIndication=errind.unknownCommunityName, + communityName=communityName + ) - snmpEngineID, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + snmpEngineID, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', + 'snmpEngineID') securityEngineID = snmpEngineID.syntax @@ -355,7 +394,9 @@ snmpEngine, 'rfc2576.processIncomingMsg' ) - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: looked up securityName %r securityModel %r contextEngineId %r contextName %r by communityName %r AND transportInformation %r' % (securityName, self.securityModelID, contextEngineId, contextName, communityName, transportInformation)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: looked up securityName %r securityModel %r contextEngineId %r contextName %r by communityName %r AND transportInformation %r' % ( + securityName, self.securityModelID, contextEngineId, contextName, communityName, transportInformation)) stateReference = self._cache.push(communityName=communityName) @@ -364,11 +405,14 @@ maxSizeResponseScopedPDU = maxMessageSize - 128 securityStateReference = stateReference - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: generated maxSizeResponseScopedPDU %s securityStateReference %s' % (maxSizeResponseScopedPDU, securityStateReference)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: generated maxSizeResponseScopedPDU %s securityStateReference %s' % ( + maxSizeResponseScopedPDU, securityStateReference)) return (securityEngineID, securityName, scopedPDU, maxSizeResponseScopedPDU, securityStateReference) + class SnmpV2cSecurityModel(SnmpV1SecurityModel): securityModelID = 2 diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/auth/base.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/auth/base.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/auth/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/auth/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,12 +1,13 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto import errind, error -class AbstractAuthenticationService: + +class AbstractAuthenticationService(object): serviceID = None def hashPassphrase(self, authKey): @@ -15,6 +16,10 @@ def localizeKey(self, authKey, snmpEngineID): raise error.ProtocolError(errind.noAuthentication) + @property + def digestLength(self): + raise error.ProtocolError(errind.noAuthentication) + # 7.2.4.1 def authenticateOutgoingMsg(self, authKey, wholeMsg): raise error.ProtocolError(errind.noAuthentication) diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,28 +1,30 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # try: from hashlib import md5 except ImportError: import md5 + md5 = md5.new from pyasn1.type import univ from pysnmp.proto.secmod.rfc3414.auth import base from pysnmp.proto.secmod.rfc3414 import localkey from pysnmp.proto import errind, error -_twelveZeros = univ.OctetString((0,)*12).asOctets() -_fortyEightZeros = (0,)*48 +_twelveZeros = univ.OctetString((0,) * 12).asOctets() +_fortyEightZeros = (0,) * 48 + # rfc3414: 6.2.4 class HmacMd5(base.AbstractAuthenticationService): serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 1, 2) # usmHMACMD5AuthProtocol - __ipad = [0x36]*64 - __opad = [0x5C]*64 + __ipad = [0x36] * 64 + __opad = [0x5C] * 64 def hashPassphrase(self, authKey): return localkey.hashPassphraseMD5(authKey) @@ -30,6 +32,10 @@ def localizeKey(self, authKey, snmpEngineID): return localkey.localizeKeyMD5(authKey, snmpEngineID) + @property + def digestLength(self): + return 12 + # 6.3.1 def authenticateOutgoingMsg(self, authKey, wholeMsg): # Here we expect calling secmod to indicate where the digest @@ -40,32 +46,34 @@ if l == -1: raise error.ProtocolError('Cant locate digest placeholder') wholeHead = wholeMsg[:l] - wholeTail = wholeMsg[l+12:] + wholeTail = wholeMsg[l + 12:] # 6.3.1.1 # 6.3.1.2a extendedAuthKey = authKey.asNumbers() + _fortyEightZeros - # 6.3.1.2b --> noop + # 6.3.1.2b --> no-op # 6.3.1.2c k1 = univ.OctetString( - map(lambda x, y: x^y, extendedAuthKey, self.__ipad) + map(lambda x, y: x ^ y, extendedAuthKey, self.__ipad) ) - # 6.3.1.2d --> noop + # 6.3.1.2d --> no-op # 6.3.1.2e k2 = univ.OctetString( - map(lambda x, y: x^y, extendedAuthKey, self.__opad) + map(lambda x, y: x ^ y, extendedAuthKey, self.__opad) ) # 6.3.1.3 - d1 = md5(k1.asOctets()+wholeMsg).digest() + # noinspection PyDeprecation,PyCallingNonCallable + d1 = md5(k1.asOctets() + wholeMsg).digest() # 6.3.1.4 - d2 = md5(k2.asOctets()+d1).digest() + # noinspection PyDeprecation,PyCallingNonCallable + d2 = md5(k2.asOctets() + d1).digest() mac = d2[:12] # 6.3.1.5 & 6 @@ -84,31 +92,33 @@ if l == -1: raise error.ProtocolError('Cant locate digest in wholeMsg') wholeHead = wholeMsg[:l] - wholeTail = wholeMsg[l+12:] + wholeTail = wholeMsg[l + 12:] authenticatedWholeMsg = wholeHead + _twelveZeros + wholeTail # 6.3.2.4a extendedAuthKey = authKey.asNumbers() + _fortyEightZeros - # 6.3.2.4b --> noop + # 6.3.2.4b --> no-op # 6.3.2.4c k1 = univ.OctetString( - map(lambda x, y: x^y, extendedAuthKey, self.__ipad) + map(lambda x, y: x ^ y, extendedAuthKey, self.__ipad) ) - # 6.3.2.4d --> noop + # 6.3.2.4d --> no-op # 6.3.2.4e k2 = univ.OctetString( - map(lambda x, y: x^y, extendedAuthKey, self.__opad) + map(lambda x, y: x ^ y, extendedAuthKey, self.__opad) ) # 6.3.2.5a - d1 = md5(k1.asOctets()+authenticatedWholeMsg).digest() + # noinspection PyDeprecation,PyCallingNonCallable + d1 = md5(k1.asOctets() + authenticatedWholeMsg).digest() # 6.3.2.5b - d2 = md5(k2.asOctets()+d1).digest() + # noinspection PyDeprecation,PyCallingNonCallable + d2 = md5(k2.asOctets() + d1).digest() # 6.3.2.5c mac = d2[:12] diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/auth/hmacsha.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/auth/hmacsha.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/auth/hmacsha.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/auth/hmacsha.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,28 +1,30 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # try: from hashlib import sha1 except ImportError: import sha + sha1 = sha.new from pyasn1.type import univ from pysnmp.proto.secmod.rfc3414.auth import base from pysnmp.proto.secmod.rfc3414 import localkey from pysnmp.proto import errind, error -_twelveZeros = univ.OctetString((0,)*12).asOctets() -_fortyFourZeros = (0,)*44 +_twelveZeros = univ.OctetString((0,) * 12).asOctets() +_fortyFourZeros = (0,) * 44 + # 7.2.4 class HmacSha(base.AbstractAuthenticationService): serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 1, 3) # usmHMACSHAAuthProtocol - __ipad = [0x36]*64 - __opad = [0x5C]*64 + __ipad = [0x36] * 64 + __opad = [0x5C] * 64 def hashPassphrase(self, authKey): return localkey.hashPassphraseSHA(authKey) @@ -30,6 +32,10 @@ def localizeKey(self, authKey, snmpEngineID): return localkey.localizeKeySHA(authKey, snmpEngineID) + @property + def digestLength(self): + return 12 + # 7.3.1 def authenticateOutgoingMsg(self, authKey, wholeMsg): # 7.3.1.1 @@ -41,30 +47,30 @@ if l == -1: raise error.ProtocolError('Cant locate digest placeholder') wholeHead = wholeMsg[:l] - wholeTail = wholeMsg[l+12:] + wholeTail = wholeMsg[l + 12:] # 7.3.1.2a extendedAuthKey = authKey.asNumbers() + _fortyFourZeros - # 7.3.1.2b -- noop + # 7.3.1.2b -- no-op # 7.3.1.2c k1 = univ.OctetString( - map(lambda x, y: x^y, extendedAuthKey, self.__ipad) + map(lambda x, y: x ^ y, extendedAuthKey, self.__ipad) ) - # 7.3.1.2d -- noop + # 7.3.1.2d -- no-op # 7.3.1.2e k2 = univ.OctetString( - map(lambda x, y: x^y, extendedAuthKey, self.__opad) + map(lambda x, y: x ^ y, extendedAuthKey, self.__opad) ) # 7.3.1.3 - d1 = sha1(k1.asOctets()+wholeMsg).digest() + d1 = sha1(k1.asOctets() + wholeMsg).digest() # 7.3.1.4 - d2 = sha1(k2.asOctets()+d1).digest() + d2 = sha1(k2.asOctets() + d1).digest() mac = d2[:12] # 7.3.1.5 & 6 @@ -83,31 +89,31 @@ if l == -1: raise error.ProtocolError('Cant locate digest in wholeMsg') wholeHead = wholeMsg[:l] - wholeTail = wholeMsg[l+12:] + wholeTail = wholeMsg[l + 12:] authenticatedWholeMsg = wholeHead + _twelveZeros + wholeTail # 7.3.2.4a extendedAuthKey = authKey.asNumbers() + _fortyFourZeros - # 7.3.2.4b --> noop + # 7.3.2.4b --> no-op # 7.3.2.4c k1 = univ.OctetString( - map(lambda x, y: x^y, extendedAuthKey, self.__ipad) + map(lambda x, y: x ^ y, extendedAuthKey, self.__ipad) ) - # 7.3.2.4d --> noop + # 7.3.2.4d --> no-op # 7.3.2.4e k2 = univ.OctetString( - map(lambda x, y: x^y, extendedAuthKey, self.__opad) + map(lambda x, y: x ^ y, extendedAuthKey, self.__opad) ) # 7.3.2.5a - d1 = sha1(k1.asOctets()+authenticatedWholeMsg).digest() + d1 = sha1(k1.asOctets() + authenticatedWholeMsg).digest() # 7.3.2.5b - d2 = sha1(k2.asOctets()+d1).digest() + d2 = sha1(k2.asOctets() + d1).digest() # 7.3.2.5c mac = d2[:12] diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/auth/noauth.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/auth/noauth.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/auth/noauth.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/auth/noauth.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,12 +1,13 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto.secmod.rfc3414.auth import base from pysnmp.proto import errind, error + class NoAuth(base.AbstractAuthenticationService): serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 1, 1) # usmNoAuthProtocol diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/__init__.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/__init__.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/__init__.py 2005-06-14 10:49:57.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/__init__.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,3 +1,9 @@ +# +# This file is part of pysnmp software. +# +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# from pysnmp.proto.secmod.rfc3414 import service SnmpUSMSecurityModel = service.SnmpUSMSecurityModel diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/localkey.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/localkey.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/localkey.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/localkey.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,69 +1,76 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # try: from hashlib import md5, sha1 + except ImportError: - import md5, sha + import md5 + import sha + md5 = md5.new sha1 = sha.new + from pyasn1.type import univ -# RFC3414: A.2.1 -def hashPassphraseMD5(passphrase): + +def hashPassphrase(passphrase, hashFunc): passphrase = univ.OctetString(passphrase).asOctets() - md = md5() - ringBuffer = passphrase * (passphrase and (64//len(passphrase)+1) or 1) + # noinspection PyDeprecation,PyCallingNonCallable + hasher = hashFunc() + ringBuffer = passphrase * (64 // len(passphrase) + 1) + # noinspection PyTypeChecker ringBufferLen = len(ringBuffer) count = 0 mark = 0 while count < 16384: e = mark + 64 if e < ringBufferLen: - md.update(ringBuffer[mark:e]) + hasher.update(ringBuffer[mark:e]) mark = e else: - md.update( - ringBuffer[mark:ringBufferLen] + ringBuffer[0:e-ringBufferLen] + hasher.update( + ringBuffer[mark:ringBufferLen] + ringBuffer[0:e - ringBufferLen] ) - mark = e-ringBufferLen + mark = e - ringBufferLen count += 1 - return md.digest() + return hasher.digest() -def localizeKeyMD5(passKey, snmpEngineId): + +def passwordToKey(passphrase, snmpEngineId, hashFunc): + return localizeKey(hashPassphrase(passphrase, hashFunc), snmpEngineId, hashFunc) + + +def localizeKey(passKey, snmpEngineId, hashFunc): passKey = univ.OctetString(passKey).asOctets() - return md5(passKey + snmpEngineId.asOctets()+ passKey).digest() + # noinspection PyDeprecation,PyCallingNonCallable + return hashFunc(passKey + snmpEngineId.asOctets() + passKey).digest() + + +# RFC3414: A.2.1 +def hashPassphraseMD5(passphrase): + return hashPassphrase(passphrase, md5) -def passwordToKeyMD5(passphrase, snmpEngineId): - return localizeKeyMD5(hashPassphraseMD5(passphrase), snmpEngineId) # RFC3414: A.2.2 def hashPassphraseSHA(passphrase): - passphrase = univ.OctetString(passphrase).asOctets() - md = sha1() - ringBuffer = passphrase * (64//len(passphrase)+1) - ringBufferLen = len(ringBuffer) - count = 0 - mark = 0 - while count < 16384: - e = mark + 64 - if e < ringBufferLen: - md.update(ringBuffer[mark:e]) - mark = e - else: - md.update( - ringBuffer[mark:ringBufferLen] + ringBuffer[0:e-ringBufferLen] - ) - mark = e-ringBufferLen - count += 1 - return md.digest() + return hashPassphrase(passphrase, sha1) + + +def passwordToKeyMD5(passphrase, snmpEngineId): + return localizeKey(hashPassphraseMD5(passphrase), snmpEngineId, md5) -def localizeKeySHA(passKey, snmpEngineId): - passKey = univ.OctetString(passKey).asOctets() - return sha1(passKey + snmpEngineId.asOctets()+ passKey).digest() def passwordToKeySHA(passphrase, snmpEngineId): - return localizeKeySHA(hashPassphraseSHA(passphrase), snmpEngineId) + return localizeKey(hashPassphraseMD5(passphrase), snmpEngineId, sha1) + + +def localizeKeyMD5(passKey, snmpEngineId): + return localizeKey(passKey, snmpEngineId, md5) + + +def localizeKeySHA(passKey, snmpEngineId): + return localizeKey(passKey, snmpEngineId, sha1) diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/priv/base.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/priv/base.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/priv/base.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/priv/base.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,13 +1,15 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto import error -class AbstractEncryptionService: + +class AbstractEncryptionService(object): serviceID = None + keySize = 0 def hashPassphrase(self, authProtocol, privKey): raise error.ProtocolError('no encryption') diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/priv/des.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/priv/des.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/priv/des.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/priv/des.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,53 +1,71 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import random from pysnmp.proto.secmod.rfc3414.priv import base from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha from pysnmp.proto.secmod.rfc3414 import localkey +from pysnmp.proto.secmod.rfc7860.auth import hmacsha2 from pysnmp.proto import errind, error from pyasn1.type import univ from sys import version_info try: - from Crypto.Cipher import DES + from Cryptodome.Cipher import DES except ImportError: DES = None +try: + from hashlib import md5, sha1 +except ImportError: + import md5 + import sha + + md5 = md5.new + sha1 = sha.new random.seed() + # 8.2.4 class Des(base.AbstractEncryptionService): - serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 2, 2) # usmDESPrivProtocol + serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 2, 2) # usmDESPrivProtocol + keySize = 16 + if version_info < (2, 3): - _localInt = int(random.random()*0xffffffff) + _localInt = int(random.random() * 0xffffffff) else: _localInt = random.randrange(0, 0xffffffff) def hashPassphrase(self, authProtocol, privKey): if authProtocol == hmacmd5.HmacMd5.serviceID: - return localkey.hashPassphraseMD5(privKey) + hashAlgo = md5 elif authProtocol == hmacsha.HmacSha.serviceID: - return localkey.hashPassphraseSHA(privKey) + hashAlgo = sha1 + elif authProtocol in hmacsha2.HmacSha2.hashAlgorithms: + hashAlgo = hmacsha2.HmacSha2.hashAlgorithms[authProtocol] else: raise error.ProtocolError( 'Unknown auth protocol %s' % (authProtocol,) ) + return localkey.hashPassphrase(privKey, hashAlgo) def localizeKey(self, authProtocol, privKey, snmpEngineID): if authProtocol == hmacmd5.HmacMd5.serviceID: - localPrivKey = localkey.localizeKeyMD5(privKey, snmpEngineID) + hashAlgo = md5 elif authProtocol == hmacsha.HmacSha.serviceID: - localPrivKey = localkey.localizeKeySHA(privKey, snmpEngineID) + hashAlgo = sha1 + elif authProtocol in hmacsha2.HmacSha2.hashAlgorithms: + hashAlgo = hmacsha2.HmacSha2.hashAlgorithms[authProtocol] else: raise error.ProtocolError( 'Unknown auth protocol %s' % (authProtocol,) ) - return localPrivKey[:32] # key+IV + localPrivKey = localkey.localizeKey(privKey, snmpEngineID, hashAlgo) + return localPrivKey[:self.keySize] # 8.1.1.1 def __getEncryptionKey(self, privKey, snmpEngineBoots): @@ -56,14 +74,14 @@ securityEngineBoots = int(snmpEngineBoots) - salt = [securityEngineBoots>>24&0xff, - securityEngineBoots>>16&0xff, - securityEngineBoots>>8&0xff, - securityEngineBoots&0xff, - self._localInt>>24&0xff, - self._localInt>>16&0xff, - self._localInt>>8&0xff, - self._localInt&0xff] + salt = [securityEngineBoots >> 24 & 0xff, + securityEngineBoots >> 16 & 0xff, + securityEngineBoots >> 8 & 0xff, + securityEngineBoots & 0xff, + self._localInt >> 24 & 0xff, + self._localInt >> 16 & 0xff, + self._localInt >> 8 & 0xff, + self._localInt & 0xff] if self._localInt == 0xffffffff: self._localInt = 0 else: @@ -71,11 +89,12 @@ return (desKey.asOctets(), univ.OctetString(salt).asOctets(), - univ.OctetString(map(lambda x, y: x^y, salt, preIV.asNumbers())).asOctets()) + univ.OctetString(map(lambda x, y: x ^ y, salt, preIV.asNumbers())).asOctets()) - def __getDecryptionKey(self, privKey, salt): + @staticmethod + def __getDecryptionKey(privKey, salt): return (privKey[:8].asOctets(), - univ.OctetString(map(lambda x, y: x^y, salt.asNumbers(), privKey[8:16].asNumbers())).asOctets()) + univ.OctetString(map(lambda x, y: x ^ y, salt.asNumbers(), privKey[8:16].asNumbers())).asOctets()) # 8.2.4.1 def encryptData(self, encryptKey, privParameters, dataToEncrypt): @@ -117,7 +136,7 @@ errorIndication=errind.decryptionError ) - # 8.3.2.2 noop + # 8.3.2.2 no-op # 8.3.2.3 desKey, iv = self.__getDecryptionKey(decryptKey, salt) diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/priv/nopriv.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/priv/nopriv.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/priv/nopriv.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/priv/nopriv.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,14 +1,16 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto.secmod.rfc3414.priv import base from pysnmp.proto import errind, error + class NoPriv(base.AbstractEncryptionService): - serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 2, 1) # usmNoPrivProtocol + serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 2, 1) # usmNoPrivProtocol + def hashPassphrase(self, authProtocol, privKey): return diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/service.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/service.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3414/service.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3414/service.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,14 +1,16 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -import time, sys +import time +import sys from pysnmp.proto.secmod.base import AbstractSecurityModel from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha, noauth from pysnmp.proto.secmod.rfc3414.priv import des, nopriv from pysnmp.proto.secmod.rfc3826.priv import aes +from pysnmp.proto.secmod.rfc7860.auth import hmacsha2 from pysnmp.proto.secmod.eso.priv import des3, aes192, aes256 from pysnmp.smi.error import NoSuchInstanceError from pysnmp.proto import rfc1155, errind, error @@ -18,29 +20,42 @@ from pyasn1.error import PyAsn1Error from pyasn1.compat.octets import null + # USM security params class UsmSecurityParameters(rfc1155.TypeCoercionHackMixIn, univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('msgAuthoritativeEngineId', univ.OctetString()), - namedtype.NamedType('msgAuthoritativeEngineBoots', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))), - namedtype.NamedType('msgAuthoritativeEngineTime', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))), - namedtype.NamedType('msgUserName', univ.OctetString().subtype(subtypeSpec=constraint.ValueSizeConstraint(0, 32))), + namedtype.NamedType('msgAuthoritativeEngineBoots', + univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))), + namedtype.NamedType('msgAuthoritativeEngineTime', + univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, 2147483647))), + namedtype.NamedType('msgUserName', + univ.OctetString().subtype(subtypeSpec=constraint.ValueSizeConstraint(0, 32))), namedtype.NamedType('msgAuthenticationParameters', univ.OctetString()), namedtype.NamedType('msgPrivacyParameters', univ.OctetString()) ) + class SnmpUSMSecurityModel(AbstractSecurityModel): securityModelID = 3 authServices = {hmacmd5.HmacMd5.serviceID: hmacmd5.HmacMd5(), hmacsha.HmacSha.serviceID: hmacsha.HmacSha(), - noauth.NoAuth.serviceID: noauth.NoAuth()} + hmacsha2.HmacSha2.sha224ServiceID: hmacsha2.HmacSha2(hmacsha2.HmacSha2.sha224ServiceID), + hmacsha2.HmacSha2.sha256ServiceID: hmacsha2.HmacSha2(hmacsha2.HmacSha2.sha256ServiceID), + hmacsha2.HmacSha2.sha384ServiceID: hmacsha2.HmacSha2(hmacsha2.HmacSha2.sha384ServiceID), + hmacsha2.HmacSha2.sha512ServiceID: hmacsha2.HmacSha2(hmacsha2.HmacSha2.sha512ServiceID), + noauth.NoAuth.serviceID: noauth.NoAuth(), + } privServices = {des.Des.serviceID: des.Des(), des3.Des3.serviceID: des3.Des3(), aes.Aes.serviceID: aes.Aes(), - aes192.Aes192.serviceID: aes192.Aes192(), - aes256.Aes256.serviceID: aes256.Aes256(), + aes192.AesBlumenthal192.serviceID: aes192.AesBlumenthal192(), + aes256.AesBlumenthal256.serviceID: aes256.AesBlumenthal256(), + aes192.Aes192.serviceID: aes192.Aes192(), # non-standard + aes256.Aes256.serviceID: aes256.Aes256(), # non-standard nopriv.NoPriv.serviceID: nopriv.NoPriv()} + def __init__(self): AbstractSecurityModel.__init__(self) self.__securityParametersSpec = UsmSecurityParameters() @@ -50,9 +65,12 @@ self.__paramsBranchId = -1 def __sec2usr(self, snmpEngine, securityName, securityEngineID=None): - usmUserEngineID, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-USER-BASED-SM-MIB', 'usmUserEngineID') + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + usmUserEngineID, = mibBuilder.importSymbols('SNMP-USER-BASED-SM-MIB', + 'usmUserEngineID') if self.__paramsBranchId != usmUserEngineID.branchVersionId: - usmUserName, usmUserSecurityName = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-USER-BASED-SM-MIB', 'usmUserName', 'usmUserSecurityName') + usmUserName, usmUserSecurityName = mibBuilder.importSymbols( + 'SNMP-USER-BASED-SM-MIB', 'usmUserName', 'usmUserSecurityName') self.__securityToUserMap = {} @@ -64,7 +82,9 @@ except NoSuchInstanceError: self.__paramsBranchId = usmUserEngineID.branchVersionId - debug.logger & debug.flagSM and debug.logger('_sec2usr: built snmpEngineId + securityName to userName map, version %s: %r' % (self.__paramsBranchId, self.__securityToUserMap)) + debug.logger & debug.flagSM and debug.logger( + '_sec2usr: built snmpEngineId + securityName to userName map, version %s: %r' % ( + self.__paramsBranchId, self.__securityToUserMap)) break instId = nextMibNode.name[len(usmUserSecurityName.name):] @@ -80,20 +100,24 @@ self.__securityToUserMap[k] = __userName if securityEngineID is None: - snmpEngineID, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') + snmpEngineID, = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') securityEngineID = snmpEngineID.syntax try: userName = self.__securityToUserMap[(securityEngineID, securityName)] except KeyError: - debug.logger & debug.flagSM and debug.logger('_sec2usr: no entry exists for snmpEngineId %r, securityName %r' % (securityEngineID, securityName)) + debug.logger & debug.flagSM and debug.logger( + '_sec2usr: no entry exists for snmpEngineId %r, securityName %r' % (securityEngineID, securityName)) raise NoSuchInstanceError() # emulate MIB lookup - debug.logger & debug.flagSM and debug.logger('_sec2usr: using userName %r for snmpEngineId %r, securityName %r' % (userName, securityEngineID, securityName)) + debug.logger & debug.flagSM and debug.logger( + '_sec2usr: using userName %r for snmpEngineId %r, securityName %r' % ( + userName, securityEngineID, securityName)) return userName - def __getUserInfo(self, mibInstrumController, securityEngineID, userName): + @staticmethod + def __getUserInfo(mibInstrumController, securityEngineID, userName): usmUserEntry, = mibInstrumController.mibBuilder.importSymbols( 'SNMP-USER-BASED-SM-MIB', 'usmUserEntry' ) @@ -198,7 +222,9 @@ securityModel, securityEngineID, securityName, securityLevel, scopedPDU, securityStateReference): - snmpEngineID = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID')[0].syntax + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + snmpEngineID = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID')[0].syntax + # 3.1.1 if securityStateReference is not None: # 3.1.1a @@ -232,14 +258,14 @@ (usmUserName, usmUserSecurityName, usmUserAuthProtocol, usmUserAuthKeyLocalized, usmUserPrivProtocol, usmUserPrivKeyLocalized) = self.__getUserInfo( - snmpEngine.msgAndPduDsp.mibInstrumController, - securityEngineID, - self.__sec2usr(snmpEngine, securityName, securityEngineID) - ) + snmpEngine.msgAndPduDsp.mibInstrumController, + securityEngineID, + self.__sec2usr(snmpEngine, securityName, securityEngineID) + ) debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: read user info') except NoSuchInstanceError: - pysnmpUsmDiscovery, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__PYSNMP-USM-MIB', 'pysnmpUsmDiscovery') + pysnmpUsmDiscovery, = mibBuilder.importSymbols('__PYSNMP-USM-MIB', 'pysnmpUsmDiscovery') reportUnknownName = not pysnmpUsmDiscovery.syntax if not reportUnknownName: try: @@ -247,10 +273,10 @@ usmUserAuthProtocol, usmUserAuthKeyLocalized, usmUserPrivProtocol, usmUserPrivKeyLocalized) = self.__cloneUserInfo( - snmpEngine.msgAndPduDsp.mibInstrumController, - securityEngineID, - self.__sec2usr(snmpEngine, securityName) - ) + snmpEngine.msgAndPduDsp.mibInstrumController, + securityEngineID, + self.__sec2usr(snmpEngine, securityName) + ) except NoSuchInstanceError: reportUnknownName = True @@ -263,8 +289,9 @@ debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: clone user info') except PyAsn1Error: - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: %s' % (sys.exc_info()[1],)) - snmpInGenErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInGenErrs') + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: %s' % (sys.exc_info()[1],)) + snmpInGenErrs, = mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInGenErrs') snmpInGenErrs.syntax += 1 raise error.StatusInformation( errorIndication=errind.invalidMsg @@ -277,14 +304,17 @@ usmUserAuthKeyLocalized = usmUserPrivKeyLocalized = None debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: use empty USM data') - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: local usmUserName %r usmUserSecurityName %r usmUserAuthProtocol %s usmUserPrivProtocol %s securityEngineID %r securityName %r' % (usmUserName, usmUserSecurityName, usmUserAuthProtocol, usmUserPrivProtocol, securityEngineID, securityName)) + # noinspection PyUnboundLocalVariable + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: local usmUserName %r usmUserSecurityName %r usmUserAuthProtocol %s usmUserPrivProtocol %s securityEngineID %r securityName %r' % ( + usmUserName, usmUserSecurityName, usmUserAuthProtocol, usmUserPrivProtocol, securityEngineID, securityName)) msg = globalData # 3.1.2 if securityLevel == 3: - if usmUserAuthProtocol == noauth.NoAuth.serviceID or \ - usmUserPrivProtocol == nopriv.NoPriv.serviceID: + if (usmUserAuthProtocol == noauth.NoAuth.serviceID or + usmUserPrivProtocol == nopriv.NoPriv.serviceID): raise error.StatusInformation( errorIndication=errind.unsupportedSecurityLevel ) @@ -300,7 +330,7 @@ scopedPDUData = msg.setComponentByPosition(3).getComponentByPosition(3) scopedPDUData.setComponentByPosition( - 0, scopedPDU, verifyConstraints=False + 0, scopedPDU, verifyConstraints=False, matchTags=False, matchConstraints=False ) # 3.1.6a @@ -308,24 +338,30 @@ if securityEngineID in self.__timeline: (snmpEngineBoots, snmpEngineTime, latestReceivedEngineTime, latestUpdateTimestamp) = self.__timeline[securityEngineID] - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: read snmpEngineBoots, snmpEngineTime from timeline') + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: read snmpEngineBoots, snmpEngineTime from timeline') else: # 2.3 XXX is this correct? snmpEngineBoots = snmpEngineTime = 0 - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: no timeline for securityEngineID %r' % (securityEngineID,)) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: no timeline for securityEngineID %r' % (securityEngineID,)) # 3.1.6.b elif securityStateReference is not None: # XXX Report? (snmpEngineBoots, - snmpEngineTime) = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineBoots', 'snmpEngineTime') + snmpEngineTime) = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineBoots', 'snmpEngineTime') snmpEngineBoots = snmpEngineBoots.syntax snmpEngineTime = snmpEngineTime.syntax.clone() - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: read snmpEngineBoots, snmpEngineTime from LCD') + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: read snmpEngineBoots, snmpEngineTime from LCD') # 3.1.6.c else: snmpEngineBoots = snmpEngineTime = 0 - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: assuming zero snmpEngineBoots, snmpEngineTime') + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: assuming zero snmpEngineBoots, snmpEngineTime') - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: use snmpEngineBoots %s snmpEngineTime %s for securityEngineID %r' % (snmpEngineBoots, snmpEngineTime, securityEngineID)) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: use snmpEngineBoots %s snmpEngineTime %s for securityEngineID %r' % ( + snmpEngineBoots, snmpEngineTime, securityEngineID)) # 3.1.4a if securityLevel == 3: @@ -336,33 +372,38 @@ errorIndication=errind.encryptionError ) - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: scopedPDU %s' % scopedPDU.prettyPrint()) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: scopedPDU %s' % scopedPDU.prettyPrint()) try: dataToEncrypt = encoder.encode(scopedPDU) except PyAsn1Error: - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: scopedPDU serialization error: %s' % sys.exc_info()[1]) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: scopedPDU serialization error: %s' % sys.exc_info()[1]) raise error.StatusInformation( errorIndication=errind.serializationError ) - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: scopedPDU encoded into %s' % debug.hexdump(dataToEncrypt)) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: scopedPDU encoded into %s' % debug.hexdump(dataToEncrypt)) + # noinspection PyUnboundLocalVariable (encryptedData, privParameters) = privHandler.encryptData( - usmUserPrivKeyLocalized, - (snmpEngineBoots, snmpEngineTime, None), dataToEncrypt - ) + usmUserPrivKeyLocalized, + (snmpEngineBoots, snmpEngineTime, None), dataToEncrypt + ) securityParameters.setComponentByPosition( - 5, privParameters, verifyConstraints=False + 5, privParameters, verifyConstraints=False, matchTags=False, matchConstraints=False ) scopedPDUData.setComponentByPosition( - 1, encryptedData, verifyConstraints=False + 1, encryptedData, verifyConstraints=False, matchTags=False, matchConstraints=False ) - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: scopedPDU ciphered into %s' % debug.hexdump(encryptedData)) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: scopedPDU ciphered into %s' % debug.hexdump(encryptedData)) # 3.1.4b elif securityLevel == 1 or securityLevel == 2: @@ -372,18 +413,18 @@ # 3.1.5 securityParameters.setComponentByPosition( - 0, securityEngineID, verifyConstraints=False + 0, securityEngineID, verifyConstraints=False, matchTags=False, matchConstraints=False ) securityParameters.setComponentByPosition( - 1, snmpEngineBoots, verifyConstraints=False + 1, snmpEngineBoots, verifyConstraints=False, matchTags=False, matchConstraints=False ) securityParameters.setComponentByPosition( - 2, snmpEngineTime, verifyConstraints=False + 2, snmpEngineTime, verifyConstraints=False, matchTags=False, matchConstraints=False ) # 3.1.7 securityParameters.setComponentByPosition( - 3, usmUserName, verifyConstraints=False + 3, usmUserName, verifyConstraints=False, matchTags=False, matchConstraints=False ) # 3.1.8a @@ -397,31 +438,36 @@ # extra-wild hack to facilitate BER substrate in-place re-write securityParameters.setComponentByPosition( - 4, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + 4, '\x00' * authHandler.digestLength ) - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: %s' % (securityParameters.prettyPrint(),)) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: %s' % (securityParameters.prettyPrint(),)) try: msg.setComponentByPosition(2, encoder.encode(securityParameters), verifyConstraints=False) except PyAsn1Error: - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: securityParameters serialization error: %s' % sys.exc_info()[1]) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: securityParameters serialization error: %s' % sys.exc_info()[1]) raise error.StatusInformation( errorIndication=errind.serializationError ) - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: auth outgoing msg: %s' % msg.prettyPrint()) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: auth outgoing msg: %s' % msg.prettyPrint()) try: wholeMsg = encoder.encode(msg) except PyAsn1Error: - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: msg serialization error: %s' % sys.exc_info()[1]) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: msg serialization error: %s' % sys.exc_info()[1]) raise error.StatusInformation( errorIndication=errind.serializationError ) + # noinspection PyUnboundLocalVariable authenticatedWholeMsg = authHandler.authenticateOutgoingMsg( usmUserAuthKeyLocalized, wholeMsg ) @@ -429,34 +475,39 @@ # 3.1.8b else: securityParameters.setComponentByPosition( - 4, '', verifyConstraints=False + 4, '', verifyConstraints=False, matchTags=False, matchConstraints=False ) - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: %s' % (securityParameters.prettyPrint(),)) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: %s' % (securityParameters.prettyPrint(),)) try: - msg.setComponentByPosition(2, encoder.encode(securityParameters), verifyConstraints=False) + msg.setComponentByPosition(2, encoder.encode(securityParameters), verifyConstraints=False, matchTags=False, matchConstraints=False) except PyAsn1Error: - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: secutiryParameters serialization error: %s' % sys.exc_info()[1]) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: secutiryParameters serialization error: %s' % sys.exc_info()[1]) raise error.StatusInformation( errorIndication=errind.serializationError ) try: - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: plain outgoing msg: %s' % msg.prettyPrint()) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: plain outgoing msg: %s' % msg.prettyPrint()) authenticatedWholeMsg = encoder.encode(msg) except PyAsn1Error: - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: msg serialization error: %s' % sys.exc_info()[1]) + debug.logger & debug.flagSM and debug.logger( + '__generateRequestOrResponseMsg: msg serialization error: %s' % sys.exc_info()[1]) raise error.StatusInformation( errorIndication=errind.serializationError ) - debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: %s outgoing msg: %s' % (securityLevel > 1 and "authenticated" or "plain", debug.hexdump(authenticatedWholeMsg))) + debug.logger & debug.flagSM and debug.logger('__generateRequestOrResponseMsg: %s outgoing msg: %s' % ( + securityLevel > 1 and "authenticated" or "plain", debug.hexdump(authenticatedWholeMsg))) # 3.1.9 - return (msg.getComponentByPosition(2), authenticatedWholeMsg) + return msg.getComponentByPosition(2), authenticatedWholeMsg def generateRequestMsg(self, snmpEngine, messageProcessingModel, globalData, maxMessageSize, securityModel, @@ -487,24 +538,20 @@ def processIncomingMsg(self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg): + mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder + # 3.2.9 -- moved up here to be able to report # maxSizeResponseScopedPDU on error # (48 - maximum SNMPv3 header length) maxSizeResponseScopedPDU = int(maxMessageSize) - len(securityParameters) - 48 - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: securityParameters %s' % debug.hexdump(securityParameters)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: securityParameters %s' % debug.hexdump(securityParameters)) # 3.2.1 - try: - securityParameters, rest = decoder.decode( - securityParameters, asn1Spec=self.__securityParametersSpec - ) - - except PyAsn1Error: - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: %s' % (sys.exc_info()[1],)) - snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') - snmpInASNParseErrs.syntax += 1 - raise error.StatusInformation(errorIndication=errind.parseError) + securityParameters, rest = decoder.decode( + securityParameters, asn1Spec=self.__securityParametersSpec + ) debug.logger & debug.flagSM and debug.logger('processIncomingMsg: %s' % (securityParameters.prettyPrint(),)) @@ -517,36 +564,45 @@ msgUserName=securityParameters.getComponentByPosition(3) ) - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: cache write securityStateReference %s by msgUserName %s' % (securityStateReference, securityParameters.getComponentByPosition(3))) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: cache write securityStateReference %s by msgUserName %s' % ( + securityStateReference, securityParameters.getComponentByPosition(3))) scopedPduData = msg.getComponentByPosition(3) # Used for error reporting - contextEngineId = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID')[0].syntax + contextEngineId = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID')[0].syntax contextName = null - snmpEngineID = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID')[0].syntax + snmpEngineID = mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID')[0].syntax # 3.2.3 - if msgAuthoritativeEngineId != snmpEngineID and \ - msgAuthoritativeEngineId not in self.__timeline: - if msgAuthoritativeEngineId and \ - 4 < len(msgAuthoritativeEngineId) < 33: + if (msgAuthoritativeEngineId != snmpEngineID and + msgAuthoritativeEngineId not in self.__timeline): + if (msgAuthoritativeEngineId and + 4 < len(msgAuthoritativeEngineId) < 33): # 3.2.3a - cloned user when request was sent - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: unsynchronized securityEngineID %r' % (msgAuthoritativeEngineId,)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: non-synchronized securityEngineID %r' % (msgAuthoritativeEngineId,)) else: # 3.2.3b - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: peer requested snmpEngineID discovery') - usmStatsUnknownEngineIDs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-USER-BASED-SM-MIB', 'usmStatsUnknownEngineIDs') + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: peer requested snmpEngineID discovery') + usmStatsUnknownEngineIDs, = mibBuilder.importSymbols( + '__SNMP-USER-BASED-SM-MIB', 'usmStatsUnknownEngineIDs') usmStatsUnknownEngineIDs.syntax += 1 - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: null or malformed msgAuthoritativeEngineId') - pysnmpUsmDiscoverable, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__PYSNMP-USM-MIB', 'pysnmpUsmDiscoverable') + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: null or malformed msgAuthoritativeEngineId') + pysnmpUsmDiscoverable, = mibBuilder.importSymbols( + '__PYSNMP-USM-MIB', 'pysnmpUsmDiscoverable') if pysnmpUsmDiscoverable.syntax: - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: starting snmpEngineID discovery procedure') + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: starting snmpEngineID discovery procedure') # Report original contextName if scopedPduData.getName() != 'plaintext': - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: scopedPduData not plaintext %s' % scopedPduData.prettyPrint()) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: scopedPduData not plaintext %s' % scopedPduData.prettyPrint()) raise error.StatusInformation( errorIndication=errind.unknownEngineID ) @@ -576,23 +632,33 @@ msgUserName = securityParameters.getComponentByPosition(3) - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: read from securityParams msgAuthoritativeEngineId %r msgUserName %r' % (msgAuthoritativeEngineId, msgUserName)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: read from securityParams msgAuthoritativeEngineId %r msgUserName %r' % ( + msgAuthoritativeEngineId, msgUserName)) if msgUserName: # 3.2.4 try: - (usmUserName, usmUserSecurityName, usmUserAuthProtocol, - usmUserAuthKeyLocalized, usmUserPrivProtocol, + (usmUserName, + usmUserSecurityName, + usmUserAuthProtocol, + usmUserAuthKeyLocalized, + usmUserPrivProtocol, usmUserPrivKeyLocalized) = self.__getUserInfo( - snmpEngine.msgAndPduDsp.mibInstrumController, - msgAuthoritativeEngineId, msgUserName - ) + snmpEngine.msgAndPduDsp.mibInstrumController, + msgAuthoritativeEngineId, msgUserName + ) debug.logger & debug.flagSM and debug.logger('processIncomingMsg: read user info from LCD') except NoSuchInstanceError: - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: unknown securityEngineID %r msgUserName %r' % (msgAuthoritativeEngineId, msgUserName)) - usmStatsUnknownUserNames, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-USER-BASED-SM-MIB', 'usmStatsUnknownUserNames') + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: unknown securityEngineID %r msgUserName %r' % ( + msgAuthoritativeEngineId, msgUserName)) + + usmStatsUnknownUserNames, = mibBuilder.importSymbols( + '__SNMP-USER-BASED-SM-MIB', 'usmStatsUnknownUserNames') usmStatsUnknownUserNames.syntax += 1 + raise error.StatusInformation( errorIndication=errind.unknownSecurityName, oid=usmStatsUnknownUserNames.name, @@ -601,12 +667,13 @@ securityLevel=securityLevel, contextEngineId=contextEngineId, contextName=contextName, + msgUserName=msgUserName, maxSizeResponseScopedPDU=maxSizeResponseScopedPDU ) except PyAsn1Error: debug.logger & debug.flagSM and debug.logger('processIncomingMsg: %s' % (sys.exc_info()[1],)) - snmpInGenErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInGenErrs') + snmpInGenErrs, = mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInGenErrs') snmpInGenErrs.syntax += 1 raise error.StatusInformation(errorIndication=errind.invalidMsg) else: @@ -616,7 +683,9 @@ usmUserPrivProtocol = nopriv.NoPriv.serviceID usmUserAuthKeyLocalized = usmUserPrivKeyLocalized = None - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: now have usmUserName %r usmUserSecurityName %r usmUserAuthProtocol %r usmUserPrivProtocol %r for msgUserName %r' % (usmUserName, usmUserSecurityName, usmUserAuthProtocol, usmUserPrivProtocol, msgUserName)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: now have usmUserName %r usmUserSecurityName %r usmUserAuthProtocol %r usmUserPrivProtocol %r for msgUserName %r' % ( + usmUserName, usmUserSecurityName, usmUserAuthProtocol, usmUserPrivProtocol, msgUserName)) # 3.2.11 (moved up here to let Reports be authenticated & encrypted) self._cache.pop(securityStateReference) @@ -647,7 +716,7 @@ snmpEngine.observer.clearExecutionContext( snmpEngine, 'rfc3414.processIncomingMsg' ) - + # 3.2.5 if msgAuthoritativeEngineId == snmpEngineID: # Authoritative SNMP engine: make sure securityLevel is sufficient @@ -671,9 +740,12 @@ if usmUserPrivProtocol != nopriv.NoPriv.serviceID: badSecIndication = 'noAuthNoPriv wanted while priv expected' if badSecIndication: - usmStatsUnsupportedSecLevels, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-USER-BASED-SM-MIB', 'usmStatsUnsupportedSecLevels') + usmStatsUnsupportedSecLevels, = mibBuilder.importSymbols( + '__SNMP-USER-BASED-SM-MIB', 'usmStatsUnsupportedSecLevels') usmStatsUnsupportedSecLevels.syntax += 1 - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: reporting inappropriate security level for user %s: %s' % (msgUserName, badSecIndication)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: reporting inappropriate security level for user %s: %s' % ( + msgUserName, badSecIndication)) raise error.StatusInformation( errorIndication=errind.unsupportedSecurityLevel, oid=usmStatsUnsupportedSecLevels.name, @@ -682,6 +754,7 @@ securityLevel=securityLevel, contextEngineId=contextEngineId, contextName=contextName, + msgUserName=msgUserName, maxSizeResponseScopedPDU=maxSizeResponseScopedPDU ) @@ -695,14 +768,15 @@ ) try: - authenticatedWholeMsg = authHandler.authenticateIncomingMsg( + authHandler.authenticateIncomingMsg( usmUserAuthKeyLocalized, securityParameters.getComponentByPosition(4), wholeMsg ) except error.StatusInformation: - usmStatsWrongDigests, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-USER-BASED-SM-MIB', 'usmStatsWrongDigests') + usmStatsWrongDigests, = mibBuilder.importSymbols( + '__SNMP-USER-BASED-SM-MIB', 'usmStatsWrongDigests') usmStatsWrongDigests.syntax += 1 raise error.StatusInformation( errorIndication=errind.authenticationFailure, @@ -712,6 +786,7 @@ securityLevel=securityLevel, contextEngineId=contextEngineId, contextName=contextName, + msgUserName=msgUserName, maxSizeResponseScopedPDU=maxSizeResponseScopedPDU ) @@ -725,43 +800,51 @@ int(time.time()) ) - expireAt = int(self.__expirationTimer + 300 / snmpEngine.transportDispatcher.getTimerResolution()) + timerResolution = snmpEngine.transportDispatcher is None and 1.0 or snmpEngine.transportDispatcher.getTimerResolution() + expireAt = int(self.__expirationTimer + 300 / timerResolution) if expireAt not in self.__timelineExpQueue: self.__timelineExpQueue[expireAt] = [] self.__timelineExpQueue[expireAt].append(msgAuthoritativeEngineId) - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: store timeline for securityEngineID %r' % (msgAuthoritativeEngineId,)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: store timeline for securityEngineID %r' % (msgAuthoritativeEngineId,)) # 3.2.7 if securityLevel == 3 or securityLevel == 2: if msgAuthoritativeEngineId == snmpEngineID: # Authoritative SNMP engine: use local notion (SF bug #1649032) - (snmpEngineBoots, snmpEngineTime) = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineBoots', 'snmpEngineTime') + (snmpEngineBoots, + snmpEngineTime) = mibBuilder.importSymbols( + '__SNMP-FRAMEWORK-MIB', 'snmpEngineBoots', 'snmpEngineTime') snmpEngineBoots = snmpEngineBoots.syntax snmpEngineTime = snmpEngineTime.syntax.clone() idleTime = 0 - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: read snmpEngineBoots (%s), snmpEngineTime (%s) from LCD' % (snmpEngineBoots, snmpEngineTime)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: read snmpEngineBoots (%s), snmpEngineTime (%s) from LCD' % ( + snmpEngineBoots, snmpEngineTime)) else: # Non-authoritative SNMP engine: use cached estimates if msgAuthoritativeEngineId in self.__timeline: (snmpEngineBoots, snmpEngineTime, latestReceivedEngineTime, latestUpdateTimestamp) = self.__timeline[ - msgAuthoritativeEngineId - ] + msgAuthoritativeEngineId + ] # time passed since last talk with this SNMP engine - idleTime = int(time.time())-latestUpdateTimestamp - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: read timeline snmpEngineBoots %s snmpEngineTime %s for msgAuthoritativeEngineId %r, idle time %s secs' % (snmpEngineBoots, snmpEngineTime, msgAuthoritativeEngineId, idleTime)) + idleTime = int(time.time()) - latestUpdateTimestamp + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: read timeline snmpEngineBoots %s snmpEngineTime %s for msgAuthoritativeEngineId %r, idle time %s secs' % ( + snmpEngineBoots, snmpEngineTime, msgAuthoritativeEngineId, idleTime)) else: raise error.ProtocolError('Peer SNMP engine info missing') # 3.2.7a if msgAuthoritativeEngineId == snmpEngineID: - if snmpEngineBoots == 2147483647 or \ - snmpEngineBoots != msgAuthoritativeEngineBoots or \ - abs(idleTime + int(snmpEngineTime) - \ - int(msgAuthoritativeEngineTime)) > 150: - usmStatsNotInTimeWindows, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-USER-BASED-SM-MIB', 'usmStatsNotInTimeWindows') + if (snmpEngineBoots == 2147483647 or + snmpEngineBoots != msgAuthoritativeEngineBoots or + abs(idleTime + int(snmpEngineTime) - int(msgAuthoritativeEngineTime)) > 150): + usmStatsNotInTimeWindows, = mibBuilder.importSymbols( + '__SNMP-USER-BASED-SM-MIB', 'usmStatsNotInTimeWindows') usmStatsNotInTimeWindows.syntax += 1 raise error.StatusInformation( errorIndication=errind.notInTimeWindow, @@ -771,35 +854,41 @@ securityLevel=2, contextEngineId=contextEngineId, contextName=contextName, + msgUserName=msgUserName, maxSizeResponseScopedPDU=maxSizeResponseScopedPDU ) # 3.2.7b else: # 3.2.7b.1 - if msgAuthoritativeEngineBoots > snmpEngineBoots or \ - msgAuthoritativeEngineBoots == snmpEngineBoots and \ - msgAuthoritativeEngineTime > latestReceivedEngineTime: + # noinspection PyUnboundLocalVariable + if (msgAuthoritativeEngineBoots > snmpEngineBoots or + msgAuthoritativeEngineBoots == snmpEngineBoots and + msgAuthoritativeEngineTime > latestReceivedEngineTime): self.__timeline[msgAuthoritativeEngineId] = ( msgAuthoritativeEngineBoots, msgAuthoritativeEngineTime, msgAuthoritativeEngineTime, int(time.time()) ) - expireAt = int(self.__expirationTimer + 300 / snmpEngine.transportDispatcher.getTimerResolution()) + + timerResolution = snmpEngine.transportDispatcher is None and 1.0 or snmpEngine.transportDispatcher.getTimerResolution() + expireAt = int(self.__expirationTimer + 300 / timerResolution) if expireAt not in self.__timelineExpQueue: self.__timelineExpQueue[expireAt] = [] self.__timelineExpQueue[expireAt].append(msgAuthoritativeEngineId) - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: stored timeline msgAuthoritativeEngineBoots %s msgAuthoritativeEngineTime %s for msgAuthoritativeEngineId %r' % (msgAuthoritativeEngineBoots, msgAuthoritativeEngineTime, msgAuthoritativeEngineId)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: stored timeline msgAuthoritativeEngineBoots %s msgAuthoritativeEngineTime %s for msgAuthoritativeEngineId %r' % ( + msgAuthoritativeEngineBoots, msgAuthoritativeEngineTime, msgAuthoritativeEngineId)) # 3.2.7b.2 - if snmpEngineBoots == 2147483647 or \ - msgAuthoritativeEngineBoots < snmpEngineBoots or \ - msgAuthoritativeEngineBoots == snmpEngineBoots and \ - abs(idleTime + int(snmpEngineTime) - \ - int(msgAuthoritativeEngineTime)) > 150: + if (snmpEngineBoots == 2147483647 or + msgAuthoritativeEngineBoots < snmpEngineBoots or + msgAuthoritativeEngineBoots == snmpEngineBoots and + abs(idleTime + int(snmpEngineTime) - int(msgAuthoritativeEngineTime)) > 150): raise error.StatusInformation( - errorIndication=errind.notInTimeWindow + errorIndication=errind.notInTimeWindow, + msgUserName=msgUserName ) # 3.2.8a @@ -808,12 +897,14 @@ privHandler = self.privServices[usmUserPrivProtocol] else: raise error.StatusInformation( - errorIndication=errind.decryptionError + errorIndication=errind.decryptionError, + msgUserName=msgUserName ) encryptedPDU = scopedPduData.getComponentByPosition(1) - if encryptedPDU is None: # no ciphertext + if encryptedPDU is None: # no ciphertext raise error.StatusInformation( - errorIndication=errind.decryptionError + errorIndication=errind.decryptionError, + msgUserName=msgUserName ) try: @@ -824,10 +915,12 @@ securityParameters.getComponentByPosition(5)), encryptedPDU ) - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: PDU deciphered into %s' % debug.hexdump(decryptedData)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: PDU deciphered into %s' % debug.hexdump(decryptedData)) except error.StatusInformation: - usmStatsDecryptionErrors, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-USER-BASED-SM-MIB', 'usmStatsDecryptionErrors') + usmStatsDecryptionErrors, = mibBuilder.importSymbols( + '__SNMP-USER-BASED-SM-MIB', 'usmStatsDecryptionErrors') usmStatsDecryptionErrors.syntax += 1 raise error.StatusInformation( errorIndication=errind.decryptionError, @@ -837,41 +930,49 @@ securityLevel=securityLevel, contextEngineId=contextEngineId, contextName=contextName, + msgUserName=msgUserName, maxSizeResponseScopedPDU=maxSizeResponseScopedPDU ) scopedPduSpec = scopedPduData.setComponentByPosition(0).getComponentByPosition(0) try: - scopedPDU, rest = decoder.decode(decryptedData, - asn1Spec=scopedPduSpec) + scopedPDU, rest = decoder.decode(decryptedData, asn1Spec=scopedPduSpec) except PyAsn1Error: - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: scopedPDU decoder failed %s' % sys.exc_info()[0]) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: scopedPDU decoder failed %s' % sys.exc_info()[0]) raise error.StatusInformation( - errorIndication=errind.decryptionError + errorIndication=errind.decryptionError, + msgUserName=msgUserName ) if eoo.endOfOctets.isSameTypeWith(scopedPDU): raise error.StatusInformation( - errorIndication=errind.decryptionError + errorIndication=errind.decryptionError, + msgUserName=msgUserName ) else: # 3.2.8b scopedPDU = scopedPduData.getComponentByPosition(0) if scopedPDU is None: # no plaintext raise error.StatusInformation( - errorIndication=errind.decryptionError + errorIndication=errind.decryptionError, + msgUserName=msgUserName ) - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: scopedPDU decoded %s' % scopedPDU.prettyPrint()) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: scopedPDU decoded %s' % scopedPDU.prettyPrint()) # 3.2.10 securityName = usmUserSecurityName - debug.logger & debug.flagSM and debug.logger('processIncomingMsg: cached msgUserName %s info by securityStateReference %s' % (msgUserName, securityStateReference)) + debug.logger & debug.flagSM and debug.logger( + 'processIncomingMsg: cached msgUserName %s info by securityStateReference %s' % ( + msgUserName, securityStateReference)) # Delayed to include details if not msgUserName and not msgAuthoritativeEngineId: - usmStatsUnknownUserNames, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-USER-BASED-SM-MIB', 'usmStatsUnknownUserNames') + usmStatsUnknownUserNames, = mibBuilder.importSymbols( + '__SNMP-USER-BASED-SM-MIB', 'usmStatsUnknownUserNames') usmStatsUnknownUserNames.syntax += 1 raise error.StatusInformation( errorIndication=errind.unknownSecurityName, @@ -882,6 +983,7 @@ securityLevel=securityLevel, contextEngineId=contextEngineId, contextName=contextName, + msgUserName=msgUserName, maxSizeResponseScopedPDU=maxSizeResponseScopedPDU, PDU=scopedPDU ) diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3826/priv/aes.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3826/priv/aes.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc3826/priv/aes.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc3826/priv/aes.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,48 +1,60 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import random from pyasn1.type import univ from pysnmp.proto.secmod.rfc3414.priv import base from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha +from pysnmp.proto.secmod.rfc7860.auth import hmacsha2 from pysnmp.proto.secmod.rfc3414 import localkey from pysnmp.proto import errind, error try: - from Crypto.Cipher import AES + from Cryptodome.Cipher import AES except ImportError: AES = None +try: + from hashlib import md5, sha1 +except ImportError: + import md5 + import sha + + md5 = md5.new + sha1 = sha.new random.seed() + # RFC3826 # class Aes(base.AbstractEncryptionService): - serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 2, 4) # usmAesCfb128Protocol + serviceID = (1, 3, 6, 1, 6, 3, 10, 1, 2, 4) # usmAesCfb128Protocol keySize = 16 _localInt = random.randrange(0, 0xffffffffffffffff) + # 3.1.2.1 def __getEncryptionKey(self, privKey, snmpEngineBoots, snmpEngineTime): - salt = [self._localInt>>56&0xff, - self._localInt>>48&0xff, - self._localInt>>40&0xff, - self._localInt>>32&0xff, - self._localInt>>24&0xff, - self._localInt>>16&0xff, - self._localInt>>8&0xff, - self._localInt&0xff] + salt = [self._localInt >> 56 & 0xff, + self._localInt >> 48 & 0xff, + self._localInt >> 40 & 0xff, + self._localInt >> 32 & 0xff, + self._localInt >> 24 & 0xff, + self._localInt >> 16 & 0xff, + self._localInt >> 8 & 0xff, + self._localInt & 0xff] if self._localInt == 0xffffffffffffffff: self._localInt = 0 else: self._localInt += 1 - return self.__getDecryptionKey(privKey, snmpEngineBoots, snmpEngineTime, salt) + (univ.OctetString(salt).asOctets(),) + return self.__getDecryptionKey(privKey, snmpEngineBoots, snmpEngineTime, salt) + ( + univ.OctetString(salt).asOctets(),) def __getDecryptionKey(self, privKey, snmpEngineBoots, snmpEngineTime, salt): @@ -50,37 +62,43 @@ int(snmpEngineBoots), int(snmpEngineTime), salt ) - iv = [snmpEngineBoots>>24&0xff, - snmpEngineBoots>>16&0xff, - snmpEngineBoots>>8&0xff, - snmpEngineBoots&0xff, - snmpEngineTime>>24&0xff, - snmpEngineTime>>16&0xff, - snmpEngineTime>>8&0xff, - snmpEngineTime&0xff] + salt + iv = [snmpEngineBoots >> 24 & 0xff, + snmpEngineBoots >> 16 & 0xff, + snmpEngineBoots >> 8 & 0xff, + snmpEngineBoots & 0xff, + snmpEngineTime >> 24 & 0xff, + snmpEngineTime >> 16 & 0xff, + snmpEngineTime >> 8 & 0xff, + snmpEngineTime & 0xff] + salt return privKey[:self.keySize].asOctets(), univ.OctetString(iv).asOctets() def hashPassphrase(self, authProtocol, privKey): if authProtocol == hmacmd5.HmacMd5.serviceID: - return localkey.hashPassphraseMD5(privKey) + hashAlgo = md5 elif authProtocol == hmacsha.HmacSha.serviceID: - return localkey.hashPassphraseSHA(privKey) + hashAlgo = sha1 + elif authProtocol in hmacsha2.HmacSha2.hashAlgorithms: + hashAlgo = hmacsha2.HmacSha2.hashAlgorithms[authProtocol] else: raise error.ProtocolError( 'Unknown auth protocol %s' % (authProtocol,) ) + return localkey.hashPassphrase(privKey, hashAlgo) def localizeKey(self, authProtocol, privKey, snmpEngineID): if authProtocol == hmacmd5.HmacMd5.serviceID: - localPrivKey = localkey.localizeKeyMD5(privKey, snmpEngineID) + hashAlgo = md5 elif authProtocol == hmacsha.HmacSha.serviceID: - localPrivKey = localkey.localizeKeySHA(privKey, snmpEngineID) + hashAlgo = sha1 + elif authProtocol in hmacsha2.HmacSha2.hashAlgorithms: + hashAlgo = hmacsha2.HmacSha2.hashAlgorithms[authProtocol] else: raise error.ProtocolError( 'Unknown auth protocol %s' % (authProtocol,) ) - return localPrivKey[:16] + localPrivKey = localkey.localizeKey(privKey, snmpEngineID, hashAlgo) + return localPrivKey[:self.keySize] # 3.2.4.1 def encryptData(self, encryptKey, privParameters, dataToEncrypt): @@ -100,7 +118,7 @@ aesObj = AES.new(aesKey, AES.MODE_CFB, iv, segment_size=128) # PyCrypto seems to require padding - dataToEncrypt = dataToEncrypt + univ.OctetString((0,) * (16-len(dataToEncrypt)%16)).asOctets() + dataToEncrypt = dataToEncrypt + univ.OctetString((0,) * (16 - len(dataToEncrypt) % 16)).asOctets() ciphertext = aesObj.encrypt(dataToEncrypt) @@ -130,7 +148,7 @@ aesObj = AES.new(aesKey, AES.MODE_CFB, iv, segment_size=128) # PyCrypto seems to require padding - encryptedData = encryptedData + univ.OctetString((0,) * (16-len(encryptedData)%16)).asOctets() + encryptedData = encryptedData + univ.OctetString((0,) * (16 - len(encryptedData) % 16)).asOctets() # 3.3.2.4-6 return aesObj.decrypt(encryptedData.asOctets()) diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc7860/auth/hmacsha2.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc7860/auth/hmacsha2.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc7860/auth/hmacsha2.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc7860/auth/hmacsha2.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,126 @@ +# +# This file is part of pysnmp software. +# +# Copyright (c) 2005-2017, Olivier Verriest +# License: http://snmplabs.com/pysnmp/license.html +# +import sys +import hmac +try: + from hashlib import sha224, sha256, sha384, sha512 + +except ImportError: + + class NotAvailable(object): + def __call__(self, *args, **kwargs): + raise errind.authenticationError + + sha224 = sha256 = sha384 = sha512 = NotAvailable() + +from pyasn1.type import univ +from pysnmp.proto.secmod.rfc3414.auth import base +from pysnmp.proto.secmod.rfc3414 import localkey +from pysnmp.proto import errind, error + + +# 7.2.4 + +class HmacSha2(base.AbstractAuthenticationService): + sha224ServiceID = (1, 3, 6, 1, 6, 3, 10, 1, 1, 4) # usmHMAC128SHA224AuthProtocol + sha256ServiceID = (1, 3, 6, 1, 6, 3, 10, 1, 1, 5) # usmHMAC192SHA256AuthProtocol + sha384ServiceID = (1, 3, 6, 1, 6, 3, 10, 1, 1, 6) # usmHMAC256SHA384AuthProtocol + sha512ServiceID = (1, 3, 6, 1, 6, 3, 10, 1, 1, 7) # usmHMAC384SHA512AuthProtocol + keyLengths = { + sha224ServiceID: 28, + sha256ServiceID: 32, + sha384ServiceID: 48, + sha512ServiceID: 64 + } + digestLengths = { + sha224ServiceID: 16, + sha256ServiceID: 24, + sha384ServiceID: 32, + sha512ServiceID: 48 + } + hashAlgorithms = { + sha224ServiceID: sha224, + sha256ServiceID: sha256, + sha384ServiceID: sha384, + sha512ServiceID: sha512 + } + + __ipad = [0x36] * 64 + __opad = [0x5C] * 64 + + def __init__(self, oid): + if oid not in self.hashAlgorithms: + raise error.ProtocolError('No SHA-2 authentication algorithm %s available' % (oid,)) + self.__hashAlgo = self.hashAlgorithms[oid] + self.__digestLength = self.digestLengths[oid] + self.__placeHolder = univ.OctetString((0,) * self.__digestLength).asOctets() + + def hashPassphrase(self, authKey): + return localkey.hashPassphrase(authKey, self.__hashAlgo) + + def localizeKey(self, authKey, snmpEngineID): + return localkey.localizeKey(authKey, snmpEngineID, self.__hashAlgo) + + @property + def digestLength(self): + return self.__digestLength + + # 7.3.1 + def authenticateOutgoingMsg(self, authKey, wholeMsg): + # 7.3.1.1 + location = wholeMsg.find(self.__placeHolder) + if location == -1: + raise error.ProtocolError('Can\'t locate digest placeholder') + wholeHead = wholeMsg[:location] + wholeTail = wholeMsg[location + self.__digestLength:] + + # 7.3.1.2, 7.3.1.3 + try: + mac = hmac.new(authKey.asOctets(), wholeMsg, self.__hashAlgo) + + except errind.ErrorIndication: + raise error.StatusInformation(errorIndication=sys.exc_info()[1]) + + # 7.3.1.4 + mac = mac.digest()[:self.__digestLength] + + # 7.3.1.5 & 6 + return wholeHead + mac + wholeTail + + # 7.3.2 + def authenticateIncomingMsg(self, authKey, authParameters, wholeMsg): + # 7.3.2.1 & 2 + if len(authParameters) != self.__digestLength: + raise error.StatusInformation( + errorIndication=errind.authenticationError + ) + + # 7.3.2.3 + location = wholeMsg.find(authParameters.asOctets()) + if location == -1: + raise error.ProtocolError('Can\'t locate digest in wholeMsg') + wholeHead = wholeMsg[:location] + wholeTail = wholeMsg[location + self.__digestLength:] + authenticatedWholeMsg = wholeHead + self.__placeHolder + wholeTail + + # 7.3.2.4 + try: + mac = hmac.new(authKey.asOctets(), authenticatedWholeMsg, self.__hashAlgo) + + except errind.ErrorIndication: + raise error.StatusInformation(errorIndication=sys.exc_info()[1]) + + # 7.3.2.5 + mac = mac.digest()[:self.__digestLength] + + # 7.3.2.6 + if mac != authParameters: + raise error.StatusInformation( + errorIndication=errind.authenticationFailure + ) + + return authenticatedWholeMsg diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc7860/auth/__init__.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc7860/auth/__init__.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc7860/auth/__init__.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc7860/auth/__init__.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1 @@ +# This file is necessary to make this directory a package. diff -Nru python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc7860/__init__.py python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc7860/__init__.py --- python-pysnmp4-4.3.2/pysnmp/proto/secmod/rfc7860/__init__.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/proto/secmod/rfc7860/__init__.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1 @@ +# This file is necessary to make this directory a package. diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/builder.py python-pysnmp4-4.4.3/pysnmp/smi/builder.py --- python-pysnmp4-4.3.2/pysnmp/smi/builder.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/builder.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,24 +1,34 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -import os, sys, imp, struct, marshal, time, traceback +import os +import sys +import imp +import struct +import marshal +import time +import traceback + try: from errno import ENOENT except ImportError: ENOENT = -1 +from pysnmp import version as pysnmp_version from pysnmp.smi import error from pysnmp import debug if sys.version_info[0] <= 2: import types + classTypes = (types.ClassType, type) else: classTypes = (type,) -class __AbstractMibSource: + +class __AbstractMibSource(object): def __init__(self, srcName): self._srcName = srcName self.__magic = imp.get_magic() @@ -63,51 +73,56 @@ return self._listdir() def read(self, f): + pycTime = pyTime = -1 + for pycSfx, pycSfxLen, pycMode in self.__sfx[imp.PY_COMPILED]: try: pycData = self._getData(f + pycSfx, pycMode) except IOError: why = sys.exc_info()[1] - if why.errno == ENOENT or ENOENT == -1: - pycTime = -1 + if ENOENT == -1 or why.errno == ENOENT: + debug.logger & debug.flagBld and debug.logger( + 'file %s access error: %s' % (f + pycSfx, why) + ) else: - raise error.MibLoadError('MIB file %s access error: %s' % (f+pycSfx, why)) + raise error.MibLoadError('MIB file %s access error: %s' % (f + pycSfx, why)) else: if self.__magic == pycData[:4]: pycData = pycData[4:] pycTime = struct.unpack('= pyTime: + # noinspection PyUnboundLocalVariable return marshal.loads(pycData), pycSfx if pyTime != -1: - return self._getData(f+pySfx, pyMode), pySfx + # noinspection PyUnboundLocalVariable + return self._getData(f + pySfx, pyMode), pySfx raise IOError(ENOENT, 'No suitable module found', f) @@ -121,9 +136,10 @@ def _getTimestamp(self, f): raise NotImplementedError() - def _getData(self, f, mode=None): + def _getData(self, f, mode): NotImplementedError() + class ZipMibSource(__AbstractMibSource): def _init(self): try: @@ -142,20 +158,22 @@ # Dir relative to CWD return DirMibSource(self._srcName).init() - def _parseDosTime(self, dosdate, dostime): - t = (((dosdate >> 9) & 0x7f) + 1980, # year + @staticmethod + def _parseDosTime(dosdate, dostime): + t = (((dosdate >> 9) & 0x7f) + 1980, # year ((dosdate >> 5) & 0x0f), # month - dosdate & 0x1f, # mday - (dostime >> 11) & 0x1f, # hour - (dostime >> 5) & 0x3f, # min - (dostime & 0x1f) * 2, # sec - -1, # wday - -1, # yday - -1) # dst + dosdate & 0x1f, # mday + (dostime >> 11) & 0x1f, # hour + (dostime >> 5) & 0x3f, # min + (dostime & 0x1f) * 2, # sec + -1, # wday + -1, # yday + -1) # dst return time.mktime(t) def _listdir(self): l = [] + # noinspection PyProtectedMember for f in self.__loader._files.keys(): d, f = os.path.split(f) if d == self._srcName: @@ -164,7 +182,9 @@ def _getTimestamp(self, f): p = os.path.join(self._srcName, f) + # noinspection PyProtectedMember if p in self.__loader._files: + # noinspection PyProtectedMember return self._parseDosTime( self.__loader._files[p][6], self.__loader._files[p][5] ) @@ -178,6 +198,7 @@ except: # ZIP code seems to return all kinds of errors raise IOError(ENOENT, 'No such file in ZIP archive: %s' % sys.exc_info()[1], p) + class DirMibSource(__AbstractMibSource): def _init(self): self._srcName = os.path.normpath(self._srcName) @@ -187,7 +208,8 @@ try: return self._uniqNames(os.listdir(self._srcName)) except OSError: - debug.logger & debug.flagBld and debug.logger('listdir() failed for %s: %s' % (self._srcName, sys.exc_info()[1])) + debug.logger & debug.flagBld and debug.logger( + 'listdir() failed for %s: %s' % (self._srcName, sys.exc_info()[1])) return () def _getTimestamp(self, f): @@ -200,7 +222,7 @@ def _getData(self, f, mode): p = os.path.join(self._srcName, f) try: - if f in os.listdir(self._srcName): # make FS case-sensitive + if f in os.listdir(self._srcName): # make FS case-sensitive fp = open(p, mode) data = fp.read() fp.close() @@ -212,13 +234,20 @@ raise IOError(ENOENT, 'No such file: %s' % sys.exc_info()[1], p) -class MibBuilder: - loadTexts = 0 + +class MibBuilder(object): defaultCoreMibs = os.pathsep.join( ('pysnmp.smi.mibs.instances', 'pysnmp.smi.mibs') ) defaultMiscMibs = 'pysnmp_mibs' + moduleID = 'PYSNMP_MODULE_ID' + + loadTexts = False + + # MIB modules can use this to select the features they can use + version = pysnmp_version + def __init__(self): self.lastBuildId = self._autoName = 0 sources = [] @@ -232,6 +261,7 @@ for m in self.defaultCoreMibs.split(os.pathsep): sources.insert(0, ZipMibSource(m)) self.mibSymbols = {} + self.__mibSources = [] self.__modSeen = {} self.__modPathsSeen = {} self.__mibCompiler = None @@ -253,7 +283,6 @@ self.__mibSources.extend([s.init() for s in mibSources]) debug.logger & debug.flagBld and debug.logger('addMibSources: new MIB sources %s' % (self.__mibSources,)) - def setMibSources(self, *mibSources): self.__mibSources = [s.init() for s in mibSources] debug.logger & debug.flagBld and debug.logger('setMibSources: new MIB sources %s' % (self.__mibSources,)) @@ -282,7 +311,8 @@ try: modData, sfx = mibSource.read(modName) except IOError: - debug.logger & debug.flagBld and debug.logger('loadModule: read %s from %s failed: %s' % (modName, mibSource, sys.exc_info()[1])) + debug.logger & debug.flagBld and debug.logger( + 'loadModule: read %s from %s failed: %s' % (modName, mibSource, sys.exc_info()[1])) continue modPath = mibSource.fullPath(modName, sfx) @@ -298,7 +328,7 @@ g = {'mibBuilder': self, 'userCtx': userCtx} try: - exec(modData, g) + exec (modData, g) except Exception: del self.__modPathsSeen[modPath] @@ -314,7 +344,8 @@ if modName not in self.__modSeen: raise error.MibNotFoundError( - 'MIB file \"%s\" not found in search path (%s)' % (modName and modName + ".py[co]", ', '.join([str(x) for x in self.__mibSources])) + 'MIB file \"%s\" not found in search path (%s)' % ( + modName and modName + ".py[co]", ', '.join([str(x) for x in self.__mibSources])) ) return self @@ -339,7 +370,8 @@ if self.__mibCompiler: debug.logger & debug.flagBld and debug.logger('loadModules: calling MIB compiler for %s' % modName) status = self.__mibCompiler.compile(modName, genTexts=self.loadTexts) - errs = '; '.join([hasattr(x, 'error') and str(x.error) or x for x in status.values() if x in ('failed', 'missing')]) + errs = '; '.join([hasattr(x, 'error') and str(x.error) or x for x in status.values() if + x in ('failed', 'missing')]) if errs: raise error.MibNotFoundError('%s compilation error(s): %s' % (modName, errs)) # compilation suceeded, MIB might load now @@ -359,7 +391,7 @@ del self.__modPathsSeen[self.__modSeen[modName]] del self.__modSeen[modName] - debug.logger & debug.flagBld and debug.logger('unloadModules: ' % (modName)) + debug.logger & debug.flagBld and debug.logger('unloadModules: %s' % modName) return self @@ -389,7 +421,8 @@ mibSymbols = self.mibSymbols[modName] for symObj in anonymousSyms: - debug.logger & debug.flagBld and debug.logger('exportSymbols: anonymous symbol %s::__pysnmp_%ld' % (modName, self._autoName)) + debug.logger & debug.flagBld and debug.logger( + 'exportSymbols: anonymous symbol %s::__pysnmp_%ld' % (modName, self._autoName)) mibSymbols['__pysnmp_%ld' % self._autoName] = symObj self._autoName += 1 for symName, symObj in namedSyms.items(): @@ -399,7 +432,7 @@ ) if symName != self.moduleID and \ - not isinstance(symObj, classTypes): + not isinstance(symObj, classTypes): label = symObj.getLabel() if label: symName = label diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/compiler.py python-pysnmp4-4.4.3/pysnmp/smi/compiler.py --- python-pysnmp4-4.3.2/pysnmp/smi/compiler.py 2016-02-13 19:53:47.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/compiler.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import os import sys @@ -31,12 +31,15 @@ except ImportError: from pysnmp.smi import error + def addMibCompilerDecorator(errorMsg): def addMibCompiler(mibBuilder, **kwargs): if not kwargs.get('ifAvailable'): raise error.SmiError('MIB compiler not available: %s' % errorMsg) + return addMibCompiler + addMibCompiler = addMibCompilerDecorator(sys.exc_info()[1]) else: @@ -53,7 +56,9 @@ compiler.addSearchers(StubSearcher(*baseMibs)) compiler.addSearchers(*[PyPackageSearcher(x.fullPath()) for x in mibBuilder.getMibSources()]) - compiler.addBorrowers(*[PyFileBorrower(x, genTexts=mibBuilder.loadTexts) for x in getReadersFromUrls(*kwargs.get('borrowers') or defaultBorrowers, **dict(lowcaseMatching=False))]) + compiler.addBorrowers(*[PyFileBorrower(x, genTexts=mibBuilder.loadTexts) for x in + getReadersFromUrls(*kwargs.get('borrowers') or defaultBorrowers, + **dict(lowcaseMatching=False))]) mibBuilder.setMibCompiler( compiler, kwargs.get('destination') or defaultDest diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/error.py python-pysnmp4-4.4.3/pysnmp/smi/error.py --- python-pysnmp4-4.3.2/pysnmp/smi/error.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/error.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,21 +1,25 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.error import PyAsn1Error from pysnmp.error import PySnmpError + class SmiError(PySnmpError, PyAsn1Error): pass + class MibLoadError(SmiError): pass + class MibNotFoundError(MibLoadError): pass + class MibOperationError(SmiError): def __init__(self, **kwargs): self.__outArgs = kwargs @@ -38,65 +42,85 @@ def update(self, d): self.__outArgs.update(d) + # Aligned with SNMPv2 PDU error-status class GenError(MibOperationError): pass + class NoAccessError(MibOperationError): pass + class WrongTypeError(MibOperationError): pass + class WrongLengthError(MibOperationError): pass + class WrongEncodingError(MibOperationError): pass + class WrongValueError(MibOperationError): pass + class NoCreationError(MibOperationError): pass + class InconsistentValueError(MibOperationError): pass + class ResourceUnavailableError(MibOperationError): pass + class CommitFailedError(MibOperationError): pass + class UndoFailedError(MibOperationError): pass + class AuthorizationError(MibOperationError): pass + class NotWritableError(MibOperationError): pass + class InconsistentNameError(MibOperationError): pass + # Aligned with SNMPv2 Var-Bind exceptions class NoSuchObjectError(MibOperationError): pass + class NoSuchInstanceError(MibOperationError): pass + class EndOfMibViewError(MibOperationError): pass + # Row management class TableRowManagement(MibOperationError): pass + class RowCreationWanted(TableRowManagement): pass + class RowDestructionWanted(TableRowManagement): pass diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/exval.py python-pysnmp4-4.4.3/pysnmp/smi/exval.py --- python-pysnmp4-4.3.2/pysnmp/smi/exval.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/exval.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,12 +1,11 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pysnmp.proto import rfc1905 noSuchObject = rfc1905.noSuchObject noSuchInstance = rfc1905.noSuchInstance endOfMibView = endOfMib = rfc1905.endOfMibView - diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/indices.py python-pysnmp4-4.4.3/pysnmp/smi/indices.py --- python-pysnmp4-4.3.2/pysnmp/smi/indices.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/indices.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,13 +1,15 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from bisect import bisect + class OrderedDict(dict): """Ordered dictionary used for indices""" + def __init__(self, **kwargs): self.__keys = [] self.__dirty = True @@ -91,8 +93,10 @@ self.__order() return self.__keysLens + class OidOrderedDict(OrderedDict): """OID-ordered dictionary used for indices""" + def __init__(self, **kwargs): self.__keysCache = {} OrderedDict.__init__(self, **kwargs) @@ -109,6 +113,7 @@ if key in self.__keysCache: del self.__keysCache[key] OrderedDict.__delitem__(self, key) + __delattr__ = __delitem__ def sortingFun(self, keys): diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/instrum.py python-pysnmp4-4.4.3/pysnmp/smi/instrum.py --- python-pysnmp4-4.3.2/pysnmp/smi/instrum.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/instrum.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys import traceback @@ -11,16 +11,18 @@ __all__ = ['AbstractMibInstrumController', 'MibInstrumController'] -class AbstractMibInstrumController: - def readVars(self, vars, acInfo=(None, None)): + +class AbstractMibInstrumController(object): + def readVars(self, varBinds, acInfo=(None, None)): raise error.NoSuchInstanceError(idx=0) - def readNextVars(self, vars, acInfo=(None, None)): + def readNextVars(self, varBinds, acInfo=(None, None)): raise error.EndOfMibViewError(idx=0) - def writeVars(self, vars, acInfo=(None, None)): + def writeVars(self, varBinds, acInfo=(None, None)): raise error.NoSuchObjectError(idx=0) + class MibInstrumController(AbstractMibInstrumController): fsmReadVar = { # ( state, status ) -> newState @@ -72,9 +74,9 @@ (MibScalarInstance, MibScalar, MibTableColumn, MibTableRow, MibTable) = self.mibBuilder.importSymbols( - 'SNMPv2-SMI', 'MibScalarInstance', 'MibScalar', - 'MibTableColumn', 'MibTableRow', 'MibTable' - ) + 'SNMPv2-SMI', 'MibScalarInstance', 'MibScalar', + 'MibTableColumn', 'MibTableRow', 'MibTable' + ) mibTree, = self.mibBuilder.importSymbols('SNMPv2-SMI', 'iso') @@ -144,18 +146,18 @@ else: raise error.SmiError( 'Orphan MIB scalar instance %r at %r' % (inst, self) - ) + ) lastBuildSyms[inst.name] = inst.typeName # Attach Table Columns to Table Rows for col in cols.values(): - rowName = col.name[:-1] # XXX + rowName = col.name[:-1] # XXX if rowName in rows: rows[rowName].registerSubtrees(col) else: raise error.SmiError( 'Orphan MIB table column %r at %r' % (col, self) - ) + ) lastBuildSyms[col.name] = rowName # Attach Table Rows to MIB tree @@ -181,14 +183,14 @@ # MIB instrumentation - def flipFlopFsm(self, fsmTable, inputNameVals, acInfo): + def flipFlopFsm(self, fsmTable, inputVarBinds, acInfo): self.__indexMib() - debug.logger & debug.flagIns and debug.logger('flipFlopFsm: inputNameVals %r' % (inputNameVals,)) + debug.logger & debug.flagIns and debug.logger('flipFlopFsm: input var-binds %r' % (inputVarBinds,)) mibTree, = self.mibBuilder.importSymbols('SNMPv2-SMI', 'iso') - outputNameVals = [] + outputVarBinds = [] state, status = 'start', 'ok' origExc = None - while 1: + while True: k = (state, status) if k in fsmTable: fsmState = fsmTable[k] @@ -199,35 +201,39 @@ else: raise error.SmiError( 'Unresolved FSM state %s, %s' % (state, status) - ) - debug.logger & debug.flagIns and debug.logger('flipFlopFsm: state %s status %s -> fsmState %s' % (state, status, fsmState)) + ) + debug.logger & debug.flagIns and debug.logger( + 'flipFlopFsm: state %s status %s -> fsmState %s' % (state, status, fsmState)) state = fsmState status = 'ok' if state == 'stop': break idx = 0 - for name, val in inputNameVals: + for name, val in inputVarBinds: f = getattr(mibTree, state, None) if f is None: raise error.SmiError( 'Unsupported state handler %s at %s' % (state, self) - ) + ) try: # Convert to tuple to avoid ObjectName instantiation # on subscription rval = f(tuple(name), val, idx, acInfo) except error.SmiError: exc_t, exc_v, exc_tb = sys.exc_info() - debug.logger & debug.flagIns and debug.logger('flipFlopFsm: fun %s exception %s for %s=%r with traceback: %s' % (f, exc_t, name, val, traceback.format_exception(exc_t, exc_v, exc_tb))) + debug.logger & debug.flagIns and debug.logger( + 'flipFlopFsm: fun %s exception %s for %s=%r with traceback: %s' % ( + f, exc_t, name, val, traceback.format_exception(exc_t, exc_v, exc_tb))) if origExc is None: # Take the first exception origExc, origTraceback = exc_v, exc_tb status = 'err' break else: - debug.logger & debug.flagIns and debug.logger('flipFlopFsm: fun %s suceeded for %s=%r' % (f, name, val)) + debug.logger & debug.flagIns and debug.logger( + 'flipFlopFsm: fun %s suceeded for %s=%r' % (f, name, val)) if rval is not None: - outputNameVals.append((rval[0], rval[1])) - idx = idx + 1 + outputVarBinds.append((rval[0], rval[1])) + idx += 1 if origExc: if sys.version_info[0] <= 2: raise origExc @@ -238,13 +244,13 @@ # Break cycle between locals and traceback object # (seems to be irrelevant on Py3 but just in case) del origTraceback - return outputNameVals + return outputVarBinds - def readVars(self, vars, acInfo=(None, None)): - return self.flipFlopFsm(self.fsmReadVar, vars, acInfo) + def readVars(self, varBinds, acInfo=(None, None)): + return self.flipFlopFsm(self.fsmReadVar, varBinds, acInfo) - def readNextVars(self, vars, acInfo=(None, None)): - return self.flipFlopFsm(self.fsmReadNextVar, vars, acInfo) + def readNextVars(self, varBinds, acInfo=(None, None)): + return self.flipFlopFsm(self.fsmReadNextVar, varBinds, acInfo) - def writeVars(self, vars, acInfo=(None, None)): - return self.flipFlopFsm(self.fsmWriteVar, vars, acInfo) + def writeVars(self, varBinds, acInfo=(None, None)): + return self.flipFlopFsm(self.fsmWriteVar, varBinds, acInfo) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/ASN1-ENUMERATION.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/ASN1-ENUMERATION.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/ASN1-ENUMERATION.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/ASN1-ENUMERATION.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.type import namedval diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/ASN1.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/ASN1.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/ASN1.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/ASN1.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.type import univ from pysnmp.proto import rfc1902 diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/ASN1-REFINEMENT.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/ASN1-REFINEMENT.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/ASN1-REFINEMENT.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/ASN1-REFINEMENT.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from pyasn1.type import constraint diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/INET-ADDRESS-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/INET-ADDRESS-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/INET-ADDRESS-MIB.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/INET-ADDRESS-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,138 @@ +# +# This file is part of pysnmp software. +# +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# +# PySNMP MIB module INET-ADDRESS-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/INET-ADDRESS-MIB +# Produced by pysmi-0.1.2 at Sat Apr 15 23:36:33 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) +# +from pysnmp.smi import error + +ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint") +NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") +Gauge32, iso, Bits, Integer32, MibIdentifier, TimeTicks, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, Counter32, mib_2, Counter64, IpAddress, Unsigned32, ObjectIdentity, ModuleIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "Gauge32", "iso", "Bits", "Integer32", "MibIdentifier", "TimeTicks", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "Counter32", "mib-2", "Counter64", "IpAddress", "Unsigned32", "ObjectIdentity", "ModuleIdentity") +TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") +inetAddressMIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 76)) +if mibBuilder.loadTexts: inetAddressMIB.setRevisions(('2005-02-04 00:00', '2002-05-09 00:00', '2000-06-08 00:00',)) +if mibBuilder.loadTexts: inetAddressMIB.setLastUpdated('200502040000Z') +if mibBuilder.loadTexts: inetAddressMIB.setOrganization('IETF Operations and Management Area') +if mibBuilder.loadTexts: inetAddressMIB.setContactInfo('Juergen Schoenwaelder (Editor) International University Bremen P.O. Box 750 561 28725 Bremen, Germany Phone: +49 421 200-3587 EMail: j.schoenwaelder@iu-bremen.de Send comments to .') +if mibBuilder.loadTexts: inetAddressMIB.setDescription('This MIB module defines textual conventions for representing Internet addresses. An Internet address can be an IPv4 address, an IPv6 address, or a DNS domain name. This module also defines textual conventions for Internet port numbers, autonomous system numbers, and the length of an Internet address prefix. Copyright (C) The Internet Society (2005). This version of this MIB module is part of RFC 4001, see the RFC itself for full legal notices.') +class InetAddressType(TextualConvention, Integer32): + description = 'A value that represents a type of Internet address. unknown(0) An unknown address type. This value MUST be used if the value of the corresponding InetAddress object is a zero-length string. It may also be used to indicate an IP address that is not in one of the formats defined below. ipv4(1) An IPv4 address as defined by the InetAddressIPv4 textual convention. ipv6(2) An IPv6 address as defined by the InetAddressIPv6 textual convention. ipv4z(3) A non-global IPv4 address including a zone index as defined by the InetAddressIPv4z textual convention. ipv6z(4) A non-global IPv6 address including a zone index as defined by the InetAddressIPv6z textual convention. dns(16) A DNS domain name as defined by the InetAddressDNS textual convention. Each definition of a concrete InetAddressType value must be accompanied by a definition of a textual convention for use with that InetAddressType. To support future extensions, the InetAddressType textual convention SHOULD NOT be sub-typed in object type definitions. It MAY be sub-typed in compliance statements in order to require only a subset of these address types for a compliant implementation. Implementations must ensure that InetAddressType objects and any dependent objects (e.g., InetAddress objects) are consistent. An inconsistentValue error must be generated if an attempt to change an InetAddressType object would, for example, lead to an undefined InetAddress value. In particular, InetAddressType/InetAddress pairs must be changed together if the address type changes (e.g., from ipv6(2) to ipv4(1)).' + status = 'current' + subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 16)) + namedValues = NamedValues(("unknown", 0), ("ipv4", 1), ("ipv6", 2), ("ipv4z", 3), ("ipv6z", 4), ("dns", 16)) + +class InetAddressIPv4(TextualConvention, OctetString): + description = 'Represents an IPv4 network address: Octets Contents Encoding 1-4 IPv4 address network-byte order The corresponding InetAddressType value is ipv4(1). This textual convention SHOULD NOT be used directly in object definitions, as it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with InetAddressType, as a pair.' + status = 'current' + displayHint = '1d.1d.1d.1d' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(4, 4) + +class InetAddressIPv6(TextualConvention, OctetString): + description = 'Represents an IPv6 network address: Octets Contents Encoding 1-16 IPv6 address network-byte order The corresponding InetAddressType value is ipv6(2). This textual convention SHOULD NOT be used directly in object definitions, as it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with InetAddressType, as a pair.' + status = 'current' + displayHint = '2x:2x:2x:2x:2x:2x:2x:2x' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(16, 16) + +class InetAddressIPv4z(TextualConvention, OctetString): + description = 'Represents a non-global IPv4 network address, together with its zone index: Octets Contents Encoding 1-4 IPv4 address network-byte order 5-8 zone index network-byte order The corresponding InetAddressType value is ipv4z(3). The zone index (bytes 5-8) is used to disambiguate identical address values on nodes that have interfaces attached to different zones of the same scope. The zone index may contain the special value 0, which refers to the default zone for each scope. This textual convention SHOULD NOT be used directly in object definitions, as it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with InetAddressType, as a pair.' + status = 'current' + displayHint = '1d.1d.1d.1d%4d' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(8, 8) + +class InetAddressIPv6z(TextualConvention, OctetString): + description = 'Represents a non-global IPv6 network address, together with its zone index: Octets Contents Encoding 1-16 IPv6 address network-byte order 17-20 zone index network-byte order The corresponding InetAddressType value is ipv6z(4). The zone index (bytes 17-20) is used to disambiguate identical address values on nodes that have interfaces attached to different zones of the same scope. The zone index may contain the special value 0, which refers to the default zone for each scope. This textual convention SHOULD NOT be used directly in object definitions, as it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with InetAddressType, as a pair.' + status = 'current' + displayHint = '2x:2x:2x:2x:2x:2x:2x:2x%4d' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(20, 20) + +class InetAddressDNS(TextualConvention, OctetString): + description = 'Represents a DNS domain name. The name SHOULD be fully qualified whenever possible. The corresponding InetAddressType is dns(16). The DESCRIPTION clause of InetAddress objects that may have InetAddressDNS values MUST fully describe how (and when) these names are to be resolved to IP addresses. The resolution of an InetAddressDNS value may require to query multiple DNS records (e.g., A for IPv4 and AAAA for IPv6). The order of the resolution process and which DNS record takes precedence depends on the configuration of the resolver. This textual convention SHOULD NOT be used directly in object definitions, as it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with InetAddressType, as a pair.' + status = 'current' + displayHint = '255a' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(1, 255) + +# https://tools.ietf.org/html/rfc4001#section-4.1 + +class InetAddress(TextualConvention, OctetString): + description = "Denotes a generic Internet address. An InetAddress value is always interpreted within the context of an InetAddressType value. Every usage of the InetAddress textual convention is required to specify the InetAddressType object that provides the context. It is suggested that the InetAddressType object be logically registered before the object(s) that use the InetAddress textual convention, if they appear in the same logical row. The value of an InetAddress object must always be consistent with the value of the associated InetAddressType object. Attempts to set an InetAddress object to a value inconsistent with the associated InetAddressType must fail with an inconsistentValue error. When this textual convention is used as the syntax of an index object, there may be issues with the limit of 128 sub-identifiers specified in SMIv2, STD 58. In this case, the object definition MUST include a 'SIZE' clause to limit the number of potential instance sub-identifiers; otherwise the applicable constraints MUST be stated in the appropriate conceptual row DESCRIPTION clauses, or in the surrounding documentation if there is no single DESCRIPTION clause that is appropriate." + status = 'current' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(0, 255) + + typeMap = { + InetAddressType.namedValues.getValue("ipv4"): InetAddressIPv4(), + InetAddressType.namedValues.getValue("ipv6"): InetAddressIPv6(), + InetAddressType.namedValues.getValue("ipv4z"): InetAddressIPv4z(), + InetAddressType.namedValues.getValue("ipv6z"): InetAddressIPv6z(), + InetAddressType.namedValues.getValue("dns"): InetAddressDNS() + } + + @classmethod + def cloneFromName(cls, value, impliedFlag, parentRow, parentIndices): + for parentIndex in reversed(parentIndices): + if isinstance(parentIndex, InetAddressType): + try: + return parentRow.setFromName(cls.typeMap[parentIndex], value, impliedFlag, parentIndices) + except KeyError: + pass + + raise error.SmiError('%s object encountered without preceding InetAddressType-like index: %r' % (cls.__name__, value)) + + def cloneAsName(self, impliedFlag, parentRow, parentIndices): + for parentIndex in reversed(parentIndices): + if isinstance(parentIndex, InetAddressType): + try: + return parentRow.getAsName(self.typeMap[parentIndex].clone(self.asOctets()), impliedFlag, parentIndices) + except KeyError: + pass + + raise error.SmiError('%s object encountered without preceding InetAddressType-like index: %r' % (self.__class__.__name__, self)) + +class InetAddressPrefixLength(TextualConvention, Unsigned32): + description = "Denotes the length of a generic Internet network address prefix. A value of n corresponds to an IP address mask that has n contiguous 1-bits from the most significant bit (MSB), with all other bits set to 0. An InetAddressPrefixLength value is always interpreted within the context of an InetAddressType value. Every usage of the InetAddressPrefixLength textual convention is required to specify the InetAddressType object that provides the context. It is suggested that the InetAddressType object be logically registered before the object(s) that use the InetAddressPrefixLength textual convention, if they appear in the same logical row. InetAddressPrefixLength values larger than the maximum length of an IP address for a specific InetAddressType are treated as the maximum significant value applicable for the InetAddressType. The maximum significant value is 32 for the InetAddressType 'ipv4(1)' and 'ipv4z(3)' and 128 for the InetAddressType 'ipv6(2)' and 'ipv6z(4)'. The maximum significant value for the InetAddressType 'dns(16)' is 0. The value zero is object-specific and must be defined as part of the description of any object that uses this syntax. Examples of the usage of zero might include situations where the Internet network address prefix is unknown or does not apply. The upper bound of the prefix length has been chosen to be consistent with the maximum size of an InetAddress." + status = 'current' + displayHint = 'd' + subtypeSpec = Unsigned32.subtypeSpec + ValueRangeConstraint(0, 2040) + +class InetPortNumber(TextualConvention, Unsigned32): + reference = 'STD 6 (RFC 768), STD 7 (RFC 793) and RFC 2960' + description = 'Represents a 16 bit port number of an Internet transport layer protocol. Port numbers are assigned by IANA. A current list of all assignments is available from . The value zero is object-specific and must be defined as part of the description of any object that uses this syntax. Examples of the usage of zero might include situations where a port number is unknown, or when the value zero is used as a wildcard in a filter.' + status = 'current' + displayHint = 'd' + subtypeSpec = Unsigned32.subtypeSpec + ValueRangeConstraint(0, 65535) + +class InetAutonomousSystemNumber(TextualConvention, Unsigned32): + reference = 'RFC 1771, RFC 1930' + description = "Represents an autonomous system number that identifies an Autonomous System (AS). An AS is a set of routers under a single technical administration, using an interior gateway protocol and common metrics to route packets within the AS, and using an exterior gateway protocol to route packets to other ASes'. IANA maintains the AS number space and has delegated large parts to the regional registries. Autonomous system numbers are currently limited to 16 bits (0..65535). There is, however, work in progress to enlarge the autonomous system number space to 32 bits. Therefore, this textual convention uses an Unsigned32 value without a range restriction in order to support a larger autonomous system number space." + status = 'current' + displayHint = 'd' + +class InetScopeType(TextualConvention, Integer32): + reference = 'RFC 3513' + description = 'Represents a scope type. This textual convention can be used in cases where a MIB has to represent different scope types and there is no context information, such as an InetAddress object, that implicitly defines the scope type. Note that not all possible values have been assigned yet, but they may be assigned in future revisions of this specification. Applications should therefore be able to deal with values not yet assigned.' + status = 'current' + subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 8, 14)) + namedValues = NamedValues(("interfaceLocal", 1), ("linkLocal", 2), ("subnetLocal", 3), ("adminLocal", 4), ("siteLocal", 5), ("organizationLocal", 8), ("global", 14)) + +class InetZoneIndex(TextualConvention, Unsigned32): + reference = 'RFC4007' + description = 'A zone index identifies an instance of a zone of a specific scope. The zone index MUST disambiguate identical address values. For link-local addresses, the zone index will typically be the interface index (ifIndex as defined in the IF-MIB) of the interface on which the address is configured. The zone index may contain the special value 0, which refers to the default zone. The default zone may be used in cases where the valid zone index is not known (e.g., when a management application has to write a link-local IPv6 address without knowing the interface index value). The default zone SHOULD NOT be used as an easy way out in cases where the zone index for a non-global IPv6 address is known.' + status = 'current' + displayHint = 'd' + +class InetVersion(TextualConvention, Integer32): + reference = 'RFC 791, RFC 2460' + description = 'A value representing a version of the IP protocol. unknown(0) An unknown or unspecified version of the IP protocol. ipv4(1) The IPv4 protocol as defined in RFC 791 (STD 5). ipv6(2) The IPv6 protocol as defined in RFC 2460. Note that this textual convention SHOULD NOT be used to distinguish different address types associated with IP protocols. The InetAddressType has been designed for this purpose.' + status = 'current' + subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2)) + namedValues = NamedValues(("unknown", 0), ("ipv4", 1), ("ipv6", 2)) + +mibBuilder.exportSymbols("INET-ADDRESS-MIB", inetAddressMIB=inetAddressMIB, InetVersion=InetVersion, InetAddressIPv4=InetAddressIPv4, InetAddressIPv6z=InetAddressIPv6z, InetScopeType=InetScopeType, InetAddressType=InetAddressType, InetPortNumber=InetPortNumber, InetAddressIPv6=InetAddressIPv6, InetAddress=InetAddress, PYSNMP_MODULE_ID=inetAddressMIB, InetAddressDNS=InetAddressDNS, InetAutonomousSystemNumber=InetAutonomousSystemNumber, InetZoneIndex=InetZoneIndex, InetAddressPrefixLength=InetAddressPrefixLength, InetAddressIPv4z=InetAddressIPv4z) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__PYSNMP-USM-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__PYSNMP-USM-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__PYSNMP-USM-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__PYSNMP-USM-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,13 +1,13 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # MibScalarInstance, = mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalarInstance') (pysnmpUsmDiscoverable, - pysnmpUsmDiscovery ) = mibBuilder.importSymbols( + pysnmpUsmDiscovery) = mibBuilder.importSymbols( 'PYSNMP-USM-MIB', 'pysnmpUsmDiscoverable', 'pysnmpUsmDiscovery' @@ -18,6 +18,6 @@ mibBuilder.exportSymbols( "__PYSNMP-USM-MIB", - pysnmpUsmDiscoverable = __pysnmpUsmDiscoverable, - pysnmpUsmDiscovery = __pysnmpUsmDiscovery + pysnmpUsmDiscoverable=__pysnmpUsmDiscoverable, + pysnmpUsmDiscovery=__pysnmpUsmDiscovery ) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMP-FRAMEWORK-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMP-FRAMEWORK-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMP-FRAMEWORK-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMP-FRAMEWORK-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import time @@ -11,7 +11,7 @@ (snmpEngineID, snmpEngineBoots, snmpEngineTime, - snmpEngineMaxMessageSize ) = mibBuilder.importSymbols( + snmpEngineMaxMessageSize) = mibBuilder.importSymbols( 'SNMP-FRAMEWORK-MIB', 'snmpEngineID', 'snmpEngineBoots', @@ -22,12 +22,13 @@ __snmpEngineID = MibScalarInstance(snmpEngineID.name, (0,), snmpEngineID.syntax) __snmpEngineBoots = MibScalarInstance(snmpEngineBoots.name, (0,), snmpEngineBoots.syntax.clone(1)) __snmpEngineTime = MibScalarInstance(snmpEngineTime.name, (0,), snmpEngineTime.syntax.clone(int(time.time()))) -__snmpEngineMaxMessageSize = MibScalarInstance(snmpEngineMaxMessageSize.name, (0,), snmpEngineMaxMessageSize.syntax.clone(4096)) +__snmpEngineMaxMessageSize = MibScalarInstance(snmpEngineMaxMessageSize.name, (0,), + snmpEngineMaxMessageSize.syntax.clone(4096)) mibBuilder.exportSymbols( '__SNMP-FRAMEWORK-MIB', - snmpEngineID = __snmpEngineID, - snmpEngineBoots = __snmpEngineBoots, - snmpEngineTime = __snmpEngineTime, - snmpEngineMaxMessageSize = __snmpEngineMaxMessageSize + snmpEngineID=__snmpEngineID, + snmpEngineBoots=__snmpEngineBoots, + snmpEngineTime=__snmpEngineTime, + snmpEngineMaxMessageSize=__snmpEngineMaxMessageSize ) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMP-MPD-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMP-MPD-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMP-MPD-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMP-MPD-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,27 +1,28 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # MibScalarInstance, = mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalarInstance') (snmpUnknownSecurityModels, snmpInvalidMsgs, - snmpUnknownPDUHandlers ) = mibBuilder.importSymbols( + snmpUnknownPDUHandlers) = mibBuilder.importSymbols( 'SNMP-MPD-MIB', 'snmpUnknownSecurityModels', 'snmpInvalidMsgs', 'snmpUnknownPDUHandlers', ) -__snmpUnknownSecurityModels = MibScalarInstance(snmpUnknownSecurityModels.name, (0,), snmpUnknownSecurityModels.syntax.clone(0)) +__snmpUnknownSecurityModels = MibScalarInstance(snmpUnknownSecurityModels.name, (0,), + snmpUnknownSecurityModels.syntax.clone(0)) __snmpInvalidMsgs = MibScalarInstance(snmpInvalidMsgs.name, (0,), snmpInvalidMsgs.syntax.clone(0)) __snmpUnknownPDUHandlers = MibScalarInstance(snmpUnknownPDUHandlers.name, (0,), snmpUnknownPDUHandlers.syntax.clone(0)) mibBuilder.exportSymbols( '__SNMP-MPD-MIB', - snmpUnknownSecurityModels = __snmpUnknownSecurityModels, - snmpInvalidMsgs = __snmpInvalidMsgs, - snmpUnknownPDUHandlers = __snmpUnknownPDUHandlers + snmpUnknownSecurityModels=__snmpUnknownSecurityModels, + snmpInvalidMsgs=__snmpInvalidMsgs, + snmpUnknownPDUHandlers=__snmpUnknownPDUHandlers ) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMP-TARGET-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMP-TARGET-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMP-TARGET-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMP-TARGET-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # MibScalarInstance, = mibBuilder.importSymbols( 'SNMPv2-SMI', @@ -19,7 +19,8 @@ ) __snmpTargetSpinLock = MibScalarInstance(snmpTargetSpinLock.name, (0,), snmpTargetSpinLock.syntax.clone(0)) -__snmpUnavailableContexts = MibScalarInstance(snmpUnavailableContexts.name, (0,), snmpUnavailableContexts.syntax.clone(0)) +__snmpUnavailableContexts = MibScalarInstance(snmpUnavailableContexts.name, (0,), + snmpUnavailableContexts.syntax.clone(0)) __snmpUnknownContexts = MibScalarInstance(snmpUnknownContexts.name, (0,), snmpUnknownContexts.syntax.clone(0)) mibBuilder.exportSymbols( @@ -28,4 +29,3 @@ snmpUnavailableContexts=__snmpUnavailableContexts, snmpUnknownContexts=__snmpUnknownContexts ) - diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMP-USER-BASED-SM-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMP-USER-BASED-SM-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMP-USER-BASED-SM-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMP-USER-BASED-SM-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # MibScalarInstance, = mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalarInstance') @@ -23,21 +23,26 @@ 'usmUserSpinLock' ) -__usmStatsUnsupportedSecLevels = MibScalarInstance(usmStatsUnsupportedSecLevels.name, (0,), usmStatsUnsupportedSecLevels.syntax.clone(0)) -__usmStatsNotInTimeWindows = MibScalarInstance(usmStatsNotInTimeWindows.name, (0,), usmStatsNotInTimeWindows.syntax.clone(0)) -__usmStatsUnknownUserNames = MibScalarInstance(usmStatsUnknownUserNames.name, (0,), usmStatsUnknownUserNames.syntax.clone(0)) -__usmStatsUnknownEngineIDs = MibScalarInstance(usmStatsUnknownEngineIDs.name, (0,), usmStatsUnknownEngineIDs.syntax.clone(0)) +__usmStatsUnsupportedSecLevels = MibScalarInstance(usmStatsUnsupportedSecLevels.name, (0,), + usmStatsUnsupportedSecLevels.syntax.clone(0)) +__usmStatsNotInTimeWindows = MibScalarInstance(usmStatsNotInTimeWindows.name, (0,), + usmStatsNotInTimeWindows.syntax.clone(0)) +__usmStatsUnknownUserNames = MibScalarInstance(usmStatsUnknownUserNames.name, (0,), + usmStatsUnknownUserNames.syntax.clone(0)) +__usmStatsUnknownEngineIDs = MibScalarInstance(usmStatsUnknownEngineIDs.name, (0,), + usmStatsUnknownEngineIDs.syntax.clone(0)) __usmStatsWrongDigests = MibScalarInstance(usmStatsWrongDigests.name, (0,), usmStatsWrongDigests.syntax.clone(0)) -__usmStatsDecryptionErrors = MibScalarInstance(usmStatsDecryptionErrors.name, (0,), usmStatsDecryptionErrors.syntax.clone(0)) +__usmStatsDecryptionErrors = MibScalarInstance(usmStatsDecryptionErrors.name, (0,), + usmStatsDecryptionErrors.syntax.clone(0)) __usmUserSpinLock = MibScalarInstance(usmUserSpinLock.name, (0,), usmUserSpinLock.syntax.clone(0)) mibBuilder.exportSymbols( '__SNMP-USER-BASED-SM-MIB', - usmStatsUnsupportedSecLevels = __usmStatsUnsupportedSecLevels, - usmStatsNotInTimeWindows = __usmStatsNotInTimeWindows, - usmStatsUnknownUserNames = __usmStatsUnknownUserNames, - usmStatsUnknownEngineIDs = __usmStatsUnknownEngineIDs, - usmStatsWrongDigests = __usmStatsWrongDigests, - usmStatsDecryptionErrors = __usmStatsDecryptionErrors, - usmUserSpinLock = __usmUserSpinLock + usmStatsUnsupportedSecLevels=__usmStatsUnsupportedSecLevels, + usmStatsNotInTimeWindows=__usmStatsNotInTimeWindows, + usmStatsUnknownUserNames=__usmStatsUnknownUserNames, + usmStatsUnknownEngineIDs=__usmStatsUnknownEngineIDs, + usmStatsWrongDigests=__usmStatsWrongDigests, + usmStatsDecryptionErrors=__usmStatsDecryptionErrors, + usmUserSpinLock=__usmUserSpinLock ) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMPv2-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMPv2-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMPv2-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMPv2-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # from sys import version from time import time @@ -96,16 +96,20 @@ 'snmpSetSerialNo' ) -__sysDescr = MibScalarInstance(sysDescr.name, (0,), sysDescr.syntax.clone("PySNMP engine version %s, Python %s" % (__version__, version.replace('\n', ' ').replace('\r', ' ')))) -__sysObjectID = MibScalarInstance(sysObjectID.name, (0,), sysObjectID.syntax.clone((1,3,6,1,4,1,20408))) +__sysDescr = MibScalarInstance(sysDescr.name, (0,), sysDescr.syntax.clone( + "PySNMP engine version %s, Python %s" % (__version__, version.replace('\n', ' ').replace('\r', ' ')))) +__sysObjectID = MibScalarInstance(sysObjectID.name, (0,), sysObjectID.syntax.clone((1, 3, 6, 1, 4, 1, 20408))) + class SysUpTime(TimeTicks): createdAt = time() + def clone(self, **kwargs): if 'value' not in kwargs: - kwargs['value'] = int((time()-self.createdAt)*100) + kwargs['value'] = int((time() - self.createdAt) * 100) return TimeTicks.clone(self, **kwargs) + __sysUpTime = MibScalarInstance(sysUpTime.name, (0,), SysUpTime(0)) __sysContact = MibScalarInstance(sysContact.name, (0,), sysContact.syntax.clone('')) __sysName = MibScalarInstance(sysName.name, (0,), sysName.syntax.clone('')) @@ -115,7 +119,8 @@ __snmpInPkts = MibScalarInstance(snmpInPkts.name, (0,), snmpInPkts.syntax.clone(0)) __snmpOutPkts = MibScalarInstance(snmpOutPkts.name, (0,), snmpOutPkts.syntax.clone(0)) __snmpInBadVersions = MibScalarInstance(snmpInBadVersions.name, (0,), snmpInBadVersions.syntax.clone(0)) -__snmpInBadCommunityNames = MibScalarInstance(snmpInBadCommunityNames.name, (0,), snmpInBadCommunityNames.syntax.clone(0)) +__snmpInBadCommunityNames = MibScalarInstance(snmpInBadCommunityNames.name, (0,), + snmpInBadCommunityNames.syntax.clone(0)) __snmpInBadCommunityUses = MibScalarInstance(snmpInBadCommunityUses.name, (0,), snmpInBadCommunityUses.syntax.clone(0)) __snmpInASNParseErrs = MibScalarInstance(snmpInASNParseErrs.name, (0,), snmpInASNParseErrs.syntax.clone(0)) __snmpInTooBigs = MibScalarInstance(snmpInTooBigs.name, (0,), snmpInTooBigs.syntax.clone(0)) @@ -145,42 +150,42 @@ mibBuilder.exportSymbols( "__SNMPv2-MIB", - sysDescr = __sysDescr, - sysObjectID = __sysObjectID, - sysUpTime = __sysUpTime, - sysContact = __sysContact, - sysName = __sysName, - sysLocation = __sysLocation, - sysServices = __sysServices, - sysORLastChange = __sysORLastChange, - snmpInPkts = __snmpInPkts, - snmpOutPkts = __snmpOutPkts, - snmpInBadVersions = __snmpInBadVersions, - snmpInBadCommunityNames = __snmpInBadCommunityNames, - snmpInBadCommunityUses = __snmpInBadCommunityUses, - snmpInASNParseErrs = __snmpInASNParseErrs, - snmpInTooBigs = __snmpInTooBigs, - snmpInNoSuchNames = __snmpInNoSuchNames, - snmpInBadValues = __snmpInBadValues, - snmpInReadOnlys = __snmpInReadOnlys, - snmpInGenErrs = __snmpInGenErrs, - snmpInTotalReqVars = __snmpInTotalReqVars, - snmpInTotalSetVars = __snmpInTotalSetVars, - snmpInGetRequests = __snmpInGetRequests, - snmpInGetNexts = __snmpInGetNexts, - snmpInSetRequests = __snmpInSetRequests, - snmpInGetResponses = __snmpInGetResponses, - snmpInTraps = __snmpInTraps, - snmpOutTooBigs = __snmpOutTooBigs, - snmpOutNoSuchNames = __snmpOutNoSuchNames, - snmpOutBadValues = __snmpOutBadValues, - snmpOutGenErrs = __snmpOutGenErrs, - snmpOutSetRequests = __snmpOutSetRequests, - snmpOutGetResponses = __snmpOutGetResponses, - snmpOutTraps = __snmpOutTraps, - snmpEnableAuthenTraps = __snmpEnableAuthenTraps, - snmpSilentDrops = __snmpSilentDrops, - snmpProxyDrops = __snmpProxyDrops, - snmpTrapOID = __snmpTrapOID, - snmpSetSerialNo = __snmpSetSerialNo + sysDescr=__sysDescr, + sysObjectID=__sysObjectID, + sysUpTime=__sysUpTime, + sysContact=__sysContact, + sysName=__sysName, + sysLocation=__sysLocation, + sysServices=__sysServices, + sysORLastChange=__sysORLastChange, + snmpInPkts=__snmpInPkts, + snmpOutPkts=__snmpOutPkts, + snmpInBadVersions=__snmpInBadVersions, + snmpInBadCommunityNames=__snmpInBadCommunityNames, + snmpInBadCommunityUses=__snmpInBadCommunityUses, + snmpInASNParseErrs=__snmpInASNParseErrs, + snmpInTooBigs=__snmpInTooBigs, + snmpInNoSuchNames=__snmpInNoSuchNames, + snmpInBadValues=__snmpInBadValues, + snmpInReadOnlys=__snmpInReadOnlys, + snmpInGenErrs=__snmpInGenErrs, + snmpInTotalReqVars=__snmpInTotalReqVars, + snmpInTotalSetVars=__snmpInTotalSetVars, + snmpInGetRequests=__snmpInGetRequests, + snmpInGetNexts=__snmpInGetNexts, + snmpInSetRequests=__snmpInSetRequests, + snmpInGetResponses=__snmpInGetResponses, + snmpInTraps=__snmpInTraps, + snmpOutTooBigs=__snmpOutTooBigs, + snmpOutNoSuchNames=__snmpOutNoSuchNames, + snmpOutBadValues=__snmpOutBadValues, + snmpOutGenErrs=__snmpOutGenErrs, + snmpOutSetRequests=__snmpOutSetRequests, + snmpOutGetResponses=__snmpOutGetResponses, + snmpOutTraps=__snmpOutTraps, + snmpEnableAuthenTraps=__snmpEnableAuthenTraps, + snmpSilentDrops=__snmpSilentDrops, + snmpProxyDrops=__snmpProxyDrops, + snmpTrapOID=__snmpTrapOID, + snmpSetSerialNo=__snmpSetSerialNo ) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMP-VIEW-BASED-ACM-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMP-VIEW-BASED-ACM-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/instances/__SNMP-VIEW-BASED-ACM-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/instances/__SNMP-VIEW-BASED-ACM-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # MibScalarInstance, = mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalarInstance') @@ -12,5 +12,5 @@ mibBuilder.exportSymbols( "__SNMP-VIEW-BASED-ACM-MIB", - vacmViewSpinLock = __vacmViewSpinLock + vacmViewSpinLock=__vacmViewSpinLock ) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/PYSNMP-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/PYSNMP-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/PYSNMP-MIB.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/PYSNMP-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,26 +1,27 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module PYSNMP-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///Users/ilya/src/py/pysnmp/docs/mibs/PYSNMP-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 16:21:43 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module PYSNMP-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/PYSNMP-MIB +# Produced by pysmi-0.1.3 at Mon Apr 17 11:46:02 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( NotificationGroup, ModuleCompliance, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, enterprises, iso, Gauge32, ModuleIdentity, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "enterprises", "iso", "Gauge32", "ModuleIdentity", "ObjectIdentity", "Bits", "Counter32") -( DisplayString, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") -pysnmp = ModuleIdentity((1, 3, 6, 1, 4, 1, 20408)).setRevisions(("2005-05-14 00:00",)) -if mibBuilder.loadTexts: pysnmp.setLastUpdated('200505140000Z') -if mibBuilder.loadTexts: pysnmp.setOrganization('pysnmp.sf.net') -if mibBuilder.loadTexts: pysnmp.setContactInfo('email: ilya@glas.net') -if mibBuilder.loadTexts: pysnmp.setDescription('Top-level infrastructure of the PySNMP project enterprise MIB tree') +Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +SingleValueConstraint, ValueRangeConstraint, ConstraintsIntersection, ValueSizeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ConstraintsUnion") +NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") +ModuleIdentity, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, NotificationType, IpAddress, MibIdentifier, Unsigned32, Counter32, ObjectIdentity, Counter64, Bits, Integer32, enterprises, TimeTicks = mibBuilder.importSymbols("SNMPv2-SMI", "ModuleIdentity", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "NotificationType", "IpAddress", "MibIdentifier", "Unsigned32", "Counter32", "ObjectIdentity", "Counter64", "Bits", "Integer32", "enterprises", "TimeTicks") +TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") +pysnmp = ModuleIdentity((1, 3, 6, 1, 4, 1, 20408)) +if mibBuilder.loadTexts: pysnmp.setRevisions(('2017-04-14 00:00', '2005-05-14 00:00',)) +if mibBuilder.loadTexts: pysnmp.setLastUpdated('201704140000Z') +if mibBuilder.loadTexts: pysnmp.setOrganization('The PySNMP Project') +if mibBuilder.loadTexts: pysnmp.setContactInfo('E-mail: Ilya Etingof GitHub: https://github.com/etingof/pysnmp') +if mibBuilder.loadTexts: pysnmp.setDescription('PySNMP top-level MIB tree infrastructure') pysnmpObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 1)) pysnmpExamples = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 2)) pysnmpEnumerations = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3)) @@ -34,4 +35,4 @@ pysnmpConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 5)) pysnmpCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 5, 1)) pysnmpGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 5, 2)) -mibBuilder.exportSymbols("PYSNMP-MIB", pysnmpAgentOIDs=pysnmpAgentOIDs, pysnmpNotificationPrefix=pysnmpNotificationPrefix, pysnmpModuleIDs=pysnmpModuleIDs, pysnmpGroups=pysnmpGroups, pysnmpCompliances=pysnmpCompliances, pysnmp=pysnmp, PYSNMP_MODULE_ID=pysnmp, pysnmpNotificationObjects=pysnmpNotificationObjects, pysnmpExamples=pysnmpExamples, pysnmpConformance=pysnmpConformance, pysnmpObjects=pysnmpObjects, pysnmpEnumerations=pysnmpEnumerations, pysnmpDomains=pysnmpDomains, pysnmpExperimental=pysnmpExperimental, pysnmpNotifications=pysnmpNotifications) +mibBuilder.exportSymbols("PYSNMP-MIB", pysnmpCompliances=pysnmpCompliances, pysnmpObjects=pysnmpObjects, pysnmpNotificationPrefix=pysnmpNotificationPrefix, pysnmpModuleIDs=pysnmpModuleIDs, pysnmpGroups=pysnmpGroups, pysnmpNotificationObjects=pysnmpNotificationObjects, pysnmp=pysnmp, pysnmpExperimental=pysnmpExperimental, pysnmpNotifications=pysnmpNotifications, PYSNMP_MODULE_ID=pysnmp, pysnmpEnumerations=pysnmpEnumerations, pysnmpDomains=pysnmpDomains, pysnmpAgentOIDs=pysnmpAgentOIDs, pysnmpConformance=pysnmpConformance, pysnmpExamples=pysnmpExamples) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/PYSNMP-SOURCE-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/PYSNMP-SOURCE-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/PYSNMP-SOURCE-MIB.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/PYSNMP-SOURCE-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,38 +1,42 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module PYSNMP-SOURCE-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///Users/ilya/src/py/pysnmp/docs/mibs/PYSNMP-SOURCE-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 16:25:01 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module PYSNMP-SOURCE-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/PYSNMP-SOURCE-MIB +# Produced by pysmi-0.1.3 at Mon Apr 17 11:46:02 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( pysnmpModuleIDs, ) = mibBuilder.importSymbols("PYSNMP-MIB", "pysnmpModuleIDs") -( snmpTargetAddrEntry, ) = mibBuilder.importSymbols("SNMP-TARGET-MIB", "snmpTargetAddrEntry") -( NotificationGroup, ModuleCompliance, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, iso, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "iso", "ObjectIdentity", "Bits", "Counter32") -( DisplayString, TAddress, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TAddress", "TextualConvention") -pysnmpSourceMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 20408, 3, 1, 8)).setRevisions(("2015-01-16 00:00",)) -if mibBuilder.loadTexts: pysnmpSourceMIB.setLastUpdated('201501160000Z') -if mibBuilder.loadTexts: pysnmpSourceMIB.setOrganization('SNMP Laboratories') -if mibBuilder.loadTexts: pysnmpSourceMIB.setContactInfo('E-mail: info@snmplabs.com\n Subscribe: pysnmp-users-request@lists.sourceforge.net') -if mibBuilder.loadTexts: pysnmpSourceMIB.setDescription('This MIB module defines implementation specific objects\n\t that provide variable source transport endpoints feature to\n SNMP Engine and Applications.') +Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +SingleValueConstraint, ValueRangeConstraint, ConstraintsIntersection, ValueSizeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ConstraintsUnion") +pysnmpModuleIDs, = mibBuilder.importSymbols("PYSNMP-MIB", "pysnmpModuleIDs") +snmpTargetAddrEntry, = mibBuilder.importSymbols("SNMP-TARGET-MIB", "snmpTargetAddrEntry") +NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") +ModuleIdentity, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, NotificationType, IpAddress, MibIdentifier, Unsigned32, Counter32, ObjectIdentity, Counter64, Bits, Integer32, TimeTicks = mibBuilder.importSymbols("SNMPv2-SMI", "ModuleIdentity", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "NotificationType", "IpAddress", "MibIdentifier", "Unsigned32", "Counter32", "ObjectIdentity", "Counter64", "Bits", "Integer32", "TimeTicks") +TextualConvention, DisplayString, TAddress = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString", "TAddress") +pysnmpSourceMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 20408, 3, 1, 8)) +if mibBuilder.loadTexts: pysnmpSourceMIB.setRevisions(('2017-04-14 00:00', '2015-01-16 00:00',)) +if mibBuilder.loadTexts: pysnmpSourceMIB.setLastUpdated('201704140000Z') +if mibBuilder.loadTexts: pysnmpSourceMIB.setOrganization('The PySNMP Project') +if mibBuilder.loadTexts: pysnmpSourceMIB.setContactInfo('E-mail: Ilya Etingof GitHub: https://github.com/etingof/pysnmp') +if mibBuilder.loadTexts: pysnmpSourceMIB.setDescription('This MIB module defines implementation specific objects that provide variable source transport endpoints feature to SNMP Engine and Standard SNMP Applications.') pysnmpSourceMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1, 8, 1)) pysnmpSourceMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1, 8, 2)) snmpSourceAddrTable = MibTable((1, 3, 6, 1, 4, 1, 20408, 3, 1, 8, 1, 1), ) -if mibBuilder.loadTexts: snmpSourceAddrTable.setDescription('A table of transport addresses to be used as a source in the\n generation of SNMP messages. This table contains additional\n objects for the SNMP-TRANSPORT-ADDRESS::snmpSourceAddressTable.') +if mibBuilder.loadTexts: snmpSourceAddrTable.setStatus('current') +if mibBuilder.loadTexts: snmpSourceAddrTable.setDescription('A table of transport addresses to be used as a source in the generation of SNMP messages. This table contains additional objects for the SNMP-TRANSPORT-ADDRESS::snmpSourceAddressTable.') snmpSourceAddrEntry = MibTableRow((1, 3, 6, 1, 4, 1, 20408, 3, 1, 8, 1, 1, 1), ) snmpTargetAddrEntry.registerAugmentions(("PYSNMP-SOURCE-MIB", "snmpSourceAddrEntry")) snmpSourceAddrEntry.setIndexNames(*snmpTargetAddrEntry.getIndexNames()) -if mibBuilder.loadTexts: snmpSourceAddrEntry.setDescription('A transport address to be used as a source in the generation\n of SNMP operations.\n\n An entry containing additional management information\n applicable to a particular target.') +if mibBuilder.loadTexts: snmpSourceAddrEntry.setStatus('current') +if mibBuilder.loadTexts: snmpSourceAddrEntry.setDescription('A transport address to be used as a source in the generation of SNMP operations. An entry containing additional management information applicable to a particular target.') snmpSourceAddrTAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 8, 1, 1, 1, 1), TAddress()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpSourceAddrTAddress.setDescription('This object contains a transport address. The format of\n this address depends on the value of the\n snmpSourceAddrTDomain object.') +if mibBuilder.loadTexts: snmpSourceAddrTAddress.setStatus('current') +if mibBuilder.loadTexts: snmpSourceAddrTAddress.setDescription('This object contains a transport address. The format of this address depends on the value of the snmpSourceAddrTDomain object.') pysnmpSourceMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1, 8, 2, 1)) pysnmpSourceMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1, 8, 2, 2)) -mibBuilder.exportSymbols("PYSNMP-SOURCE-MIB", snmpSourceAddrTAddress=snmpSourceAddrTAddress, pysnmpSourceMIBGroups=pysnmpSourceMIBGroups, pysnmpSourceMIB=pysnmpSourceMIB, pysnmpSourceMIBConformance=pysnmpSourceMIBConformance, snmpSourceAddrTable=snmpSourceAddrTable, pysnmpSourceMIBCompliances=pysnmpSourceMIBCompliances, PYSNMP_MODULE_ID=pysnmpSourceMIB, pysnmpSourceMIBObjects=pysnmpSourceMIBObjects, snmpSourceAddrEntry=snmpSourceAddrEntry) +mibBuilder.exportSymbols("PYSNMP-SOURCE-MIB", pysnmpSourceMIBConformance=pysnmpSourceMIBConformance, pysnmpSourceMIB=pysnmpSourceMIB, snmpSourceAddrTable=snmpSourceAddrTable, snmpSourceAddrEntry=snmpSourceAddrEntry, pysnmpSourceMIBGroups=pysnmpSourceMIBGroups, PYSNMP_MODULE_ID=pysnmpSourceMIB, snmpSourceAddrTAddress=snmpSourceAddrTAddress, pysnmpSourceMIBObjects=pysnmpSourceMIBObjects, pysnmpSourceMIBCompliances=pysnmpSourceMIBCompliances) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/PYSNMP-USM-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/PYSNMP-USM-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/PYSNMP-USM-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/PYSNMP-USM-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,63 +1,78 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module PYSNMP-USM-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///Users/ilya/src/py/pysnmp/docs/mibs/PYSNMP-USM-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 16:26:08 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module PYSNMP-USM-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/PYSNMP-USM-MIB +# Produced by pysmi-0.1.3 at Mon Apr 17 11:46:02 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( pysnmpModuleIDs, ) = mibBuilder.importSymbols("PYSNMP-MIB", "pysnmpModuleIDs") -( SnmpAdminString, ) = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") -( usmUserEntry, ) = mibBuilder.importSymbols("SNMP-USER-BASED-SM-MIB", "usmUserEntry") -( NotificationGroup, ModuleCompliance, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, iso, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "iso", "ObjectIdentity", "Bits", "Counter32") -( DisplayString, RowStatus, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "RowStatus", "TextualConvention") -pysnmpUsmMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1)).setRevisions(("2005-05-14 00:00",)) -if mibBuilder.loadTexts: pysnmpUsmMIB.setLastUpdated('200505140000Z') -if mibBuilder.loadTexts: pysnmpUsmMIB.setOrganization('The PySNMP project') -if mibBuilder.loadTexts: pysnmpUsmMIB.setContactInfo('E-mail: ilya@glas.net\n Subscribe: pysnmp-users-request@lists.sourceforge.net') -if mibBuilder.loadTexts: pysnmpUsmMIB.setDescription('This MIB module defines objects specific to User\n Security Model (USM) implementation at PySNMP.') +Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +SingleValueConstraint, ValueRangeConstraint, ConstraintsIntersection, ValueSizeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ConstraintsUnion") +pysnmpModuleIDs, = mibBuilder.importSymbols("PYSNMP-MIB", "pysnmpModuleIDs") +SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") +usmUserEntry, = mibBuilder.importSymbols("SNMP-USER-BASED-SM-MIB", "usmUserEntry") +NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") +ModuleIdentity, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, NotificationType, IpAddress, MibIdentifier, Unsigned32, Counter32, ObjectIdentity, Counter64, Bits, Integer32, TimeTicks = mibBuilder.importSymbols("SNMPv2-SMI", "ModuleIdentity", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "NotificationType", "IpAddress", "MibIdentifier", "Unsigned32", "Counter32", "ObjectIdentity", "Counter64", "Bits", "Integer32", "TimeTicks") +RowStatus, DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "DisplayString", "TextualConvention") +pysnmpUsmMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1)) +if mibBuilder.loadTexts: pysnmpUsmMIB.setRevisions(('2017-04-14 00:00', '2005-05-14 00:00',)) +if mibBuilder.loadTexts: pysnmpUsmMIB.setLastUpdated('201704140000Z') +if mibBuilder.loadTexts: pysnmpUsmMIB.setOrganization('The PySNMP Project') +if mibBuilder.loadTexts: pysnmpUsmMIB.setContactInfo('E-mail: Ilya Etingof GitHub: https://github.com/etingof/pysnmp') +if mibBuilder.loadTexts: pysnmpUsmMIB.setDescription('This MIB module defines objects specific to User Security Model (USM) implementation at PySNMP.') pysnmpUsmMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1)) pysnmpUsmMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 2)) pysnmpUsmCfg = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 1)) -pysnmpUsmDiscoverable = MibScalar((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=SingleValueConstraint(0, 1,)).clone(namedValues=NamedValues(("notDiscoverable", 0), ("discoverable", 1),)).clone('discoverable')).setMaxAccess("readwrite") -if mibBuilder.loadTexts: pysnmpUsmDiscoverable.setDescription('Whether SNMP engine would support its discovery by\n responding to unknown clients.') -pysnmpUsmDiscovery = MibScalar((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=SingleValueConstraint(0, 1,)).clone(namedValues=NamedValues(("doNotDiscover", 0), ("doDiscover", 1),)).clone('doDiscover')).setMaxAccess("readwrite") -if mibBuilder.loadTexts: pysnmpUsmDiscovery.setDescription('Whether SNMP engine would try to figure out the EngineIDs\n of its peers by sending discover requests.') +pysnmpUsmDiscoverable = MibScalar((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("notDiscoverable", 0), ("discoverable", 1))).clone('discoverable')).setMaxAccess("readwrite") +if mibBuilder.loadTexts: pysnmpUsmDiscoverable.setStatus('current') +if mibBuilder.loadTexts: pysnmpUsmDiscoverable.setDescription('Whether SNMP engine would support its discovery by responding to unknown clients.') +pysnmpUsmDiscovery = MibScalar((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("doNotDiscover", 0), ("doDiscover", 1))).clone('doDiscover')).setMaxAccess("readwrite") +if mibBuilder.loadTexts: pysnmpUsmDiscovery.setStatus('current') +if mibBuilder.loadTexts: pysnmpUsmDiscovery.setDescription('Whether SNMP engine would try to figure out the EngineIDs of its peers by sending discover requests.') pysnmpUsmUser = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3)) pysnmpUsmSecretTable = MibTable((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 2), ) -if mibBuilder.loadTexts: pysnmpUsmSecretTable.setDescription("The table of USM users passphrases configured in the SNMP \n engine's Local Configuration Datastore (LCD).") +if mibBuilder.loadTexts: pysnmpUsmSecretTable.setStatus('current') +if mibBuilder.loadTexts: pysnmpUsmSecretTable.setDescription("The table of USM users passphrases configured in the SNMP engine's Local Configuration Datastore (LCD).") pysnmpUsmSecretEntry = MibTableRow((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 2, 1), ).setIndexNames((1, "PYSNMP-USM-MIB", "pysnmpUsmSecretUserName")) +if mibBuilder.loadTexts: pysnmpUsmSecretEntry.setStatus('current') if mibBuilder.loadTexts: pysnmpUsmSecretEntry.setDescription('Information about a particular USM user credentials.') -pysnmpUsmSecretUserName = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 2, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))) -if mibBuilder.loadTexts: pysnmpUsmSecretUserName.setDescription('The username string for which a row in this table\n represents a configuration.') -pysnmpUsmSecretAuthKey = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 2, 1, 2), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8,65535))) +pysnmpUsmSecretUserName = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 2, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) +if mibBuilder.loadTexts: pysnmpUsmSecretUserName.setStatus('current') +if mibBuilder.loadTexts: pysnmpUsmSecretUserName.setDescription('The username string for which a row in this table represents a configuration.') +pysnmpUsmSecretAuthKey = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 2, 1, 2), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8, 65535))) +if mibBuilder.loadTexts: pysnmpUsmSecretAuthKey.setStatus('current') if mibBuilder.loadTexts: pysnmpUsmSecretAuthKey.setDescription("User's authentication passphrase used for localized key generation.") -pysnmpUsmSecretPrivKey = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 2, 1, 3), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8,65535))) +pysnmpUsmSecretPrivKey = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 2, 1, 3), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8, 65535))) +if mibBuilder.loadTexts: pysnmpUsmSecretPrivKey.setStatus('current') if mibBuilder.loadTexts: pysnmpUsmSecretPrivKey.setDescription("User's encryption passphrase used for localized key generation.") pysnmpUsmSecretStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 2, 1, 4), RowStatus()).setMaxAccess("readcreate") +if mibBuilder.loadTexts: pysnmpUsmSecretStatus.setStatus('current') if mibBuilder.loadTexts: pysnmpUsmSecretStatus.setDescription('Table status') pysnmpUsmKeyTable = MibTable((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3), ) -if mibBuilder.loadTexts: pysnmpUsmKeyTable.setDescription("The table of USM users localized keys configured in the \n SNMP engine's Local Configuration Datastore (LCD).") +if mibBuilder.loadTexts: pysnmpUsmKeyTable.setStatus('current') +if mibBuilder.loadTexts: pysnmpUsmKeyTable.setDescription("The table of USM users localized keys configured in the SNMP engine's Local Configuration Datastore (LCD).") pysnmpUsmKeyEntry = MibTableRow((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3, 1), ) usmUserEntry.registerAugmentions(("PYSNMP-USM-MIB", "pysnmpUsmKeyEntry")) pysnmpUsmKeyEntry.setIndexNames(*usmUserEntry.getIndexNames()) +if mibBuilder.loadTexts: pysnmpUsmKeyEntry.setStatus('current') if mibBuilder.loadTexts: pysnmpUsmKeyEntry.setDescription('Information about a particular USM user credentials.') -pysnmpUsmKeyAuthLocalized = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3, 1, 1), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8,32))) +pysnmpUsmKeyAuthLocalized = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3, 1, 1), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8, 64))) +if mibBuilder.loadTexts: pysnmpUsmKeyAuthLocalized.setStatus('current') if mibBuilder.loadTexts: pysnmpUsmKeyAuthLocalized.setDescription("User's localized key used for authentication.") -pysnmpUsmKeyPrivLocalized = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3, 1, 2), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8,32))) +pysnmpUsmKeyPrivLocalized = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3, 1, 2), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8, 64))) +if mibBuilder.loadTexts: pysnmpUsmKeyPrivLocalized.setStatus('current') if mibBuilder.loadTexts: pysnmpUsmKeyPrivLocalized.setDescription("User's localized key used for encryption.") -pysnmpUsmKeyAuth = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3, 1, 3), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8,32))) +pysnmpUsmKeyAuth = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3, 1, 3), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8, 64))) +if mibBuilder.loadTexts: pysnmpUsmKeyAuth.setStatus('current') if mibBuilder.loadTexts: pysnmpUsmKeyAuth.setDescription("User's non-localized key used for authentication.") -pysnmpUsmKeyPriv = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3, 1, 4), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8,32))) +pysnmpUsmKeyPriv = MibTableColumn((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 1, 3, 1, 4), OctetString('\x00\x00\x00\x00\x00\x00\x00\x00').subtype(subtypeSpec=ValueSizeConstraint(8, 64))) +if mibBuilder.loadTexts: pysnmpUsmKeyPriv.setStatus('current') if mibBuilder.loadTexts: pysnmpUsmKeyPriv.setDescription("User's non-localized key used for encryption.") pysnmpUsmMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 2, 1)) pysnmpUsmMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1, 1, 2, 2)) -mibBuilder.exportSymbols("PYSNMP-USM-MIB", pysnmpUsmCfg=pysnmpUsmCfg, PYSNMP_MODULE_ID=pysnmpUsmMIB, pysnmpUsmKeyAuthLocalized=pysnmpUsmKeyAuthLocalized, pysnmpUsmKeyTable=pysnmpUsmKeyTable, pysnmpUsmDiscovery=pysnmpUsmDiscovery, pysnmpUsmMIBCompliances=pysnmpUsmMIBCompliances, pysnmpUsmSecretAuthKey=pysnmpUsmSecretAuthKey, pysnmpUsmSecretStatus=pysnmpUsmSecretStatus, pysnmpUsmKeyPrivLocalized=pysnmpUsmKeyPrivLocalized, pysnmpUsmKeyEntry=pysnmpUsmKeyEntry, pysnmpUsmKeyPriv=pysnmpUsmKeyPriv, pysnmpUsmSecretTable=pysnmpUsmSecretTable, pysnmpUsmUser=pysnmpUsmUser, pysnmpUsmMIBGroups=pysnmpUsmMIBGroups, pysnmpUsmMIB=pysnmpUsmMIB, pysnmpUsmSecretEntry=pysnmpUsmSecretEntry, pysnmpUsmDiscoverable=pysnmpUsmDiscoverable, pysnmpUsmMIBObjects=pysnmpUsmMIBObjects, pysnmpUsmSecretUserName=pysnmpUsmSecretUserName, pysnmpUsmSecretPrivKey=pysnmpUsmSecretPrivKey, pysnmpUsmKeyAuth=pysnmpUsmKeyAuth, pysnmpUsmMIBConformance=pysnmpUsmMIBConformance) +mibBuilder.exportSymbols("PYSNMP-USM-MIB", pysnmpUsmCfg=pysnmpUsmCfg, pysnmpUsmDiscoverable=pysnmpUsmDiscoverable, pysnmpUsmKeyEntry=pysnmpUsmKeyEntry, pysnmpUsmKeyTable=pysnmpUsmKeyTable, pysnmpUsmKeyPrivLocalized=pysnmpUsmKeyPrivLocalized, pysnmpUsmMIBCompliances=pysnmpUsmMIBCompliances, pysnmpUsmMIBObjects=pysnmpUsmMIBObjects, pysnmpUsmSecretTable=pysnmpUsmSecretTable, PYSNMP_MODULE_ID=pysnmpUsmMIB, pysnmpUsmSecretEntry=pysnmpUsmSecretEntry, pysnmpUsmMIBConformance=pysnmpUsmMIBConformance, pysnmpUsmUser=pysnmpUsmUser, pysnmpUsmKeyAuth=pysnmpUsmKeyAuth, pysnmpUsmSecretPrivKey=pysnmpUsmSecretPrivKey, pysnmpUsmKeyAuthLocalized=pysnmpUsmKeyAuthLocalized, pysnmpUsmMIB=pysnmpUsmMIB, pysnmpUsmDiscovery=pysnmpUsmDiscovery, pysnmpUsmSecretUserName=pysnmpUsmSecretUserName, pysnmpUsmKeyPriv=pysnmpUsmKeyPriv, pysnmpUsmSecretAuthKey=pysnmpUsmSecretAuthKey, pysnmpUsmSecretStatus=pysnmpUsmSecretStatus, pysnmpUsmMIBGroups=pysnmpUsmMIBGroups) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/RFC1158-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/RFC1158-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/RFC1158-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/RFC1158-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,14 +1,21 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# +# PySNMP MIB module RFC1158-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/RFC1158-MIB +# Produced by pysmi-0.1.3 at Mon Apr 17 12:12:07 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -# PySNMP MIB module RFC1158-MIB (http://pysnmp.sf.net) # It is a stripped version of MIB that contains only symbols that is # unique to SMIv1 and have no analogues in SMIv2 # -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, iso, Gauge32, MibIdentifier, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "iso", "Gauge32", "MibIdentifier", "Bits", "Counter32") +Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, iso, Gauge32, MibIdentifier, Bits, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "iso", "Gauge32", "MibIdentifier", "Bits","Counter32") snmpInBadTypes = MibScalar((1, 3, 6, 1, 2, 1, 11, 7), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: snmpInBadTypes.setStatus('mandatory') snmpOutReadOnlys = MibScalar((1, 3, 6, 1, 2, 1, 11, 23), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: snmpInReadOnlys.setStatus('mandatory') mibBuilder.exportSymbols("RFC1158-MIB", snmpOutReadOnlys=snmpOutReadOnlys, snmpInBadTypes=snmpInBadTypes) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/RFC1213-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/RFC1213-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/RFC1213-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/RFC1213-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,62 +1,417 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# +# PySNMP MIB module RFC1213-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/RFC1213-MIB +# Produced by pysmi-0.1.3 at Mon Apr 17 12:12:07 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -# PySNMP MIB module RFC1158-MIB (http://pysnmp.sf.net) # It is a stripped version of MIB that contains only symbols that is # unique to SMIv1 and have no analogues in SMIv2 # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, mib_2, IpAddress, TimeTicks, iso, Gauge32, MibIdentifier, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "mib-2", "IpAddress", "TimeTicks", "iso", "Gauge32", "MibIdentifier", "Bits", "Counter32") -( DisplayString, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString") +OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ConstraintsUnion, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ConstraintsUnion", "ValueRangeConstraint") +ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") +IpAddress, TimeTicks, NotificationType, ModuleIdentity, Integer32, Counter32, MibIdentifier, ObjectIdentity, Gauge32, Unsigned32, mgmt, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits, iso, Counter64, mib_2 = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "TimeTicks", "NotificationType", "ModuleIdentity", "Integer32", "Counter32", "MibIdentifier", "ObjectIdentity", "Gauge32", "Unsigned32", "mgmt", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits", "iso", "Counter64","mib-2") +DisplayString, PhysAddress = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "PhysAddress") +from pysnmp.proto.rfc1155 import NetworkAddress + at = MibIdentifier((1, 3, 6, 1, 2, 1, 3)) ip = MibIdentifier((1, 3, 6, 1, 2, 1, 4)) egp = MibIdentifier((1, 3, 6, 1, 2, 1, 8)) -atTable = MibTable((1, 3, 6, 1, 2, 1, 3, 1)).setMaxAccess("readwrite") -atEntry = MibTableRow((1, 3, 6, 1, 2, 1, 3, 1, 1)).setMaxAccess("readwrite") +atTable = MibTable((1, 3, 6, 1, 2, 1, 3, 1), ) +if mibBuilder.loadTexts: atTable.setStatus('deprecated') +if mibBuilder.loadTexts: atTable.setDescription("The Address Translation tables contain the NetworkAddress to `physical' address equivalences. Some interfaces do not use translation tables for determining address equivalences (e.g., DDN-X.25 has an algorithmic method); if all interfaces are of this type, then the Address Translation table is empty, i.e., has zero entries.") +atEntry = MibTableRow((1, 3, 6, 1, 2, 1, 3, 1, 1), ).setIndexNames((0, "RFC1213-MIB", "atIfIndex"), (0, "RFC1213-MIB", "atNetAddress")) +if mibBuilder.loadTexts: atEntry.setStatus('deprecated') +if mibBuilder.loadTexts: atEntry.setDescription("Each entry contains one NetworkAddress to `physical' address equivalence.") atIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 3, 1, 1, 1), Integer32()).setMaxAccess("readwrite") -atPhysAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 3, 1, 1, 2), OctetString()).setMaxAccess("readwrite") -atNetAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 3, 1, 1, 3), IpAddress()).setMaxAccess("readwrite") -ipRouteTable = MibTable((1, 3, 6, 1, 2, 1, 4, 21)) -ipRouteEntry = MibTableRow((1, 3, 6, 1, 2, 1, 4, 21, 1)).setIndexNames((0, "RFC1213-MIB", "ipRouteDest")) +if mibBuilder.loadTexts: atIfIndex.setStatus('deprecated') +if mibBuilder.loadTexts: atIfIndex.setDescription("The interface on which this entry's equivalence is effective. The interface identified by a particular value of this index is the same interface as identified by the same value of ifIndex.") +atPhysAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 3, 1, 1, 2), PhysAddress()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: atPhysAddress.setStatus('deprecated') +if mibBuilder.loadTexts: atPhysAddress.setDescription("The media-dependent `physical' address. Setting this object to a null string (one of zero length) has the effect of invaliding the corresponding entry in the atTable object. That is, it effectively dissasociates the interface identified with said entry from the mapping identified with said entry. It is an implementation-specific matter as to whether the agent removes an invalidated entry from the table. Accordingly, management stations must be prepared to receive tabular information from agents that corresponds to entries not currently in use. Proper interpretation of such entries requires examination of the relevant atPhysAddress object.") +atNetAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 3, 1, 1, 3), NetworkAddress()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: atNetAddress.setStatus('deprecated') +if mibBuilder.loadTexts: atNetAddress.setDescription("The NetworkAddress (e.g., the IP address) corresponding to the media-dependent `physical' address.") +ipForwarding = MibScalar((1, 3, 6, 1, 2, 1, 4, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("forwarding", 1), ("not-forwarding", 2)))).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipForwarding.setStatus('mandatory') +if mibBuilder.loadTexts: ipForwarding.setDescription("The indication of whether this entity is acting as an IP gateway in respect to the forwarding of datagrams received by, but not addressed to, this entity. IP gateways forward datagrams. IP hosts do not (except those source-routed via the host). Note that for some managed nodes, this object may take on only a subset of the values possible. Accordingly, it is appropriate for an agent to return a `badValue' response if a management station attempts to change this object to an inappropriate value.") +ipDefaultTTL = MibScalar((1, 3, 6, 1, 2, 1, 4, 2), Integer32()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipDefaultTTL.setStatus('mandatory') +if mibBuilder.loadTexts: ipDefaultTTL.setDescription('The default value inserted into the Time-To-Live field of the IP header of datagrams originated at this entity, whenever a TTL value is not supplied by the transport layer protocol.') +ipInReceives = MibScalar((1, 3, 6, 1, 2, 1, 4, 3), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipInReceives.setStatus('mandatory') +if mibBuilder.loadTexts: ipInReceives.setDescription('The total number of input datagrams received from interfaces, including those received in error.') +ipInHdrErrors = MibScalar((1, 3, 6, 1, 2, 1, 4, 4), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipInHdrErrors.setStatus('mandatory') +if mibBuilder.loadTexts: ipInHdrErrors.setDescription('The number of input datagrams discarded due to errors in their IP headers, including bad checksums, version number mismatch, other format errors, time-to-live exceeded, errors discovered in processing their IP options, etc.') +ipInAddrErrors = MibScalar((1, 3, 6, 1, 2, 1, 4, 5), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipInAddrErrors.setStatus('mandatory') +if mibBuilder.loadTexts: ipInAddrErrors.setDescription("The number of input datagrams discarded because the IP address in their IP header's destination field was not a valid address to be received at this entity. This count includes invalid addresses (e.g., 0.0.0.0) and addresses of unsupported Classes (e.g., Class E). For entities which are not IP Gateways and therefore do not forward datagrams, this counter includes datagrams discarded because the destination address was not a local address.") +ipForwDatagrams = MibScalar((1, 3, 6, 1, 2, 1, 4, 6), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipForwDatagrams.setStatus('mandatory') +if mibBuilder.loadTexts: ipForwDatagrams.setDescription('The number of input datagrams for which this entity was not their final IP destination, as a result of which an attempt was made to find a route to forward them to that final destination. In entities which do not act as IP Gateways, this counter will include only those packets which were Source-Routed via this entity, and the Source- Route option processing was successful.') +ipInUnknownProtos = MibScalar((1, 3, 6, 1, 2, 1, 4, 7), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipInUnknownProtos.setStatus('mandatory') +if mibBuilder.loadTexts: ipInUnknownProtos.setDescription('The number of locally-addressed datagrams received successfully but discarded because of an unknown or unsupported protocol.') +ipInDiscards = MibScalar((1, 3, 6, 1, 2, 1, 4, 8), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipInDiscards.setStatus('mandatory') +if mibBuilder.loadTexts: ipInDiscards.setDescription('The number of input IP datagrams for which no problems were encountered to prevent their continued processing, but which were discarded (e.g., for lack of buffer space). Note that this counter does not include any datagrams discarded while awaiting re-assembly.') +ipInDelivers = MibScalar((1, 3, 6, 1, 2, 1, 4, 9), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipInDelivers.setStatus('mandatory') +if mibBuilder.loadTexts: ipInDelivers.setDescription('The total number of input datagrams successfully delivered to IP user-protocols (including ICMP).') +ipOutRequests = MibScalar((1, 3, 6, 1, 2, 1, 4, 10), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipOutRequests.setStatus('mandatory') +if mibBuilder.loadTexts: ipOutRequests.setDescription('The total number of IP datagrams which local IP user-protocols (including ICMP) supplied to IP in requests for transmission. Note that this counter does not include any datagrams counted in ipForwDatagrams.') +ipOutDiscards = MibScalar((1, 3, 6, 1, 2, 1, 4, 11), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipOutDiscards.setStatus('mandatory') +if mibBuilder.loadTexts: ipOutDiscards.setDescription('The number of output IP datagrams for which no problem was encountered to prevent their transmission to their destination, but which were discarded (e.g., for lack of buffer space). Note that this counter would include datagrams counted in ipForwDatagrams if any such packets met this (discretionary) discard criterion.') +ipOutNoRoutes = MibScalar((1, 3, 6, 1, 2, 1, 4, 12), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipOutNoRoutes.setStatus('mandatory') +if mibBuilder.loadTexts: ipOutNoRoutes.setDescription("The number of IP datagrams discarded because no route could be found to transmit them to their destination. Note that this counter includes any packets counted in ipForwDatagrams which meet this `no-route' criterion. Note that this includes any datagarms which a host cannot route because all of its default gateways are down.") +ipReasmTimeout = MibScalar((1, 3, 6, 1, 2, 1, 4, 13), Integer32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipReasmTimeout.setStatus('mandatory') +if mibBuilder.loadTexts: ipReasmTimeout.setDescription('The maximum number of seconds which received fragments are held while they are awaiting reassembly at this entity.') +ipReasmReqds = MibScalar((1, 3, 6, 1, 2, 1, 4, 14), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipReasmReqds.setStatus('mandatory') +if mibBuilder.loadTexts: ipReasmReqds.setDescription('The number of IP fragments received which needed to be reassembled at this entity.') +ipReasmOKs = MibScalar((1, 3, 6, 1, 2, 1, 4, 15), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipReasmOKs.setStatus('mandatory') +if mibBuilder.loadTexts: ipReasmOKs.setDescription('The number of IP datagrams successfully re- assembled.') +ipReasmFails = MibScalar((1, 3, 6, 1, 2, 1, 4, 16), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipReasmFails.setStatus('mandatory') +if mibBuilder.loadTexts: ipReasmFails.setDescription('The number of failures detected by the IP re- assembly algorithm (for whatever reason: timed out, errors, etc). Note that this is not necessarily a count of discarded IP fragments since some algorithms (notably the algorithm in RFC 815) can lose track of the number of fragments by combining them as they are received.') +ipFragOKs = MibScalar((1, 3, 6, 1, 2, 1, 4, 17), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipFragOKs.setStatus('mandatory') +if mibBuilder.loadTexts: ipFragOKs.setDescription('The number of IP datagrams that have been successfully fragmented at this entity.') +ipFragFails = MibScalar((1, 3, 6, 1, 2, 1, 4, 18), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipFragFails.setStatus('mandatory') +if mibBuilder.loadTexts: ipFragFails.setDescription("The number of IP datagrams that have been discarded because they needed to be fragmented at this entity but could not be, e.g., because their Don't Fragment flag was set.") +ipFragCreates = MibScalar((1, 3, 6, 1, 2, 1, 4, 19), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipFragCreates.setStatus('mandatory') +if mibBuilder.loadTexts: ipFragCreates.setDescription('The number of IP datagram fragments that have been generated as a result of fragmentation at this entity.') +ipAddrTable = MibTable((1, 3, 6, 1, 2, 1, 4, 20), ) +if mibBuilder.loadTexts: ipAddrTable.setStatus('mandatory') +if mibBuilder.loadTexts: ipAddrTable.setDescription("The table of addressing information relevant to this entity's IP addresses.") +ipAddrEntry = MibTableRow((1, 3, 6, 1, 2, 1, 4, 20, 1), ).setIndexNames((0, "RFC1213-MIB", "ipAdEntAddr")) +if mibBuilder.loadTexts: ipAddrEntry.setStatus('mandatory') +if mibBuilder.loadTexts: ipAddrEntry.setDescription("The addressing information for one of this entity's IP addresses.") +ipAdEntAddr = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 20, 1, 1), IpAddress()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipAdEntAddr.setStatus('mandatory') +if mibBuilder.loadTexts: ipAdEntAddr.setDescription("The IP address to which this entry's addressing information pertains.") +ipAdEntIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 20, 1, 2), Integer32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipAdEntIfIndex.setStatus('mandatory') +if mibBuilder.loadTexts: ipAdEntIfIndex.setDescription('The index value which uniquely identifies the interface to which this entry is applicable. The interface identified by a particular value of this index is the same interface as identified by the same value of ifIndex.') +ipAdEntNetMask = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 20, 1, 3), IpAddress()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipAdEntNetMask.setStatus('mandatory') +if mibBuilder.loadTexts: ipAdEntNetMask.setDescription('The subnet mask associated with the IP address of this entry. The value of the mask is an IP address with all the network bits set to 1 and all the hosts bits set to 0.') +ipAdEntBcastAddr = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 20, 1, 4), Integer32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipAdEntBcastAddr.setStatus('mandatory') +if mibBuilder.loadTexts: ipAdEntBcastAddr.setDescription('The value of the least-significant bit in the IP broadcast address used for sending datagrams on the (logical) interface associated with the IP address of this entry. For example, when the Internet standard all-ones broadcast address is used, the value will be 1. This value applies to both the subnet and network broadcasts addresses used by the entity on this (logical) interface.') +ipAdEntReasmMaxSize = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 20, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipAdEntReasmMaxSize.setStatus('mandatory') +if mibBuilder.loadTexts: ipAdEntReasmMaxSize.setDescription('The size of the largest IP datagram which this entity can re-assemble from incoming IP fragmented datagrams received on this interface.') +ipRouteTable = MibTable((1, 3, 6, 1, 2, 1, 4, 21), ) +if mibBuilder.loadTexts: ipRouteTable.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteTable.setDescription("This entity's IP Routing table.") +ipRouteEntry = MibTableRow((1, 3, 6, 1, 2, 1, 4, 21, 1), ).setIndexNames((0, "RFC1213-MIB", "ipRouteDest")) +if mibBuilder.loadTexts: ipRouteEntry.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteEntry.setDescription('A route to a particular destination.') ipRouteDest = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 1), IpAddress()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipRouteDest.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteDest.setDescription('The destination IP address of this route. An entry with a value of 0.0.0.0 is considered a default route. Multiple routes to a single destination can appear in the table, but access to such multiple entries is dependent on the table- access mechanisms defined by the network management protocol in use.') ipRouteIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 2), Integer32()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipRouteIfIndex.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteIfIndex.setDescription('The index value which uniquely identifies the local interface through which the next hop of this route should be reached. The interface identified by a particular value of this index is the same interface as identified by the same value of ifIndex.') ipRouteMetric1 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 3), Integer32()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipRouteMetric1.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteMetric1.setDescription("The primary routing metric for this route. The semantics of this metric are determined by the routing-protocol specified in the route's ipRouteProto value. If this metric is not used, its value should be set to -1.") ipRouteMetric2 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 4), Integer32()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipRouteMetric2.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteMetric2.setDescription("An alternate routing metric for this route. The semantics of this metric are determined by the routing-protocol specified in the route's ipRouteProto value. If this metric is not used, its value should be set to -1.") ipRouteMetric3 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 5), Integer32()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipRouteMetric3.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteMetric3.setDescription("An alternate routing metric for this route. The semantics of this metric are determined by the routing-protocol specified in the route's ipRouteProto value. If this metric is not used, its value should be set to -1.") ipRouteMetric4 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 6), Integer32()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipRouteMetric4.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteMetric4.setDescription("An alternate routing metric for this route. The semantics of this metric are determined by the routing-protocol specified in the route's ipRouteProto value. If this metric is not used, its value should be set to -1.") ipRouteNextHop = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 7), IpAddress()).setMaxAccess("readwrite") -ipRouteType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 8), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2, 3, 4,)).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("direct", 3), ("indirect", 4),))).setMaxAccess("readwrite") -ipRouteProto = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 9), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,)).clone(namedValues=NamedValues(("other", 1), ("local", 2), ("netmgmt", 3), ("icmp", 4), ("egp", 5), ("ggp", 6), ("hello", 7), ("rip", 8), ("is-is", 9), ("es-is", 10), ("ciscoIgrp", 11), ("bbnSpfIgp", 12), ("ospf", 13), ("bgp", 14),))).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipRouteNextHop.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteNextHop.setDescription("The IP address of the next hop of this route. (In the case of a route bound to an interface which is realized via a broadcast media, the value of this field is the agent's IP address on that interface.)") +ipRouteType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("direct", 3), ("indirect", 4)))).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipRouteType.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteType.setDescription('The type of route. Note that the values direct(3) and indirect(4) refer to the notion of direct and indirect routing in the IP architecture. Setting this object to the value invalid(2) has the effect of invalidating the corresponding entry in the ipRouteTable object. That is, it effectively dissasociates the destination identified with said entry from the route identified with said entry. It is an implementation-specific matter as to whether the agent removes an invalidated entry from the table. Accordingly, management stations must be prepared to receive tabular information from agents that corresponds to entries not currently in use. Proper interpretation of such entries requires examination of the relevant ipRouteType object.') +ipRouteProto = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14))).clone(namedValues=NamedValues(("other", 1), ("local", 2), ("netmgmt", 3), ("icmp", 4), ("egp", 5), ("ggp", 6), ("hello", 7), ("rip", 8), ("is-is", 9), ("es-is", 10), ("ciscoIgrp", 11), ("bbnSpfIgp", 12), ("ospf", 13), ("bgp", 14)))).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipRouteProto.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteProto.setDescription('The routing mechanism via which this route was learned. Inclusion of values for gateway routing protocols is not intended to imply that hosts should support those protocols.') ipRouteAge = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 10), Integer32()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipRouteAge.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteAge.setDescription("The number of seconds since this route was last updated or otherwise determined to be correct. Note that no semantics of `too old' can be implied except through knowledge of the routing protocol by which the route was learned.") ipRouteMask = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 11), IpAddress()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipRouteMask.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteMask.setDescription('Indicate the mask to be logical-ANDed with the destination address before being compared to the value in the ipRouteDest field. For those systems that do not support arbitrary subnet masks, an agent constructs the value of the ipRouteMask by determining whether the value of the correspondent ipRouteDest field belong to a class-A, B, or C network, and then using one of: mask network 255.0.0.0 class-A 255.255.0.0 class-B 255.255.255.0 class-C If the value of the ipRouteDest is 0.0.0.0 (a default route), then the mask value is also 0.0.0.0. It should be noted that all IP routing subsystems implicitly use this mechanism.') ipRouteMetric5 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 12), Integer32()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipRouteMetric5.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteMetric5.setDescription("An alternate routing metric for this route. The semantics of this metric are determined by the routing-protocol specified in the route's ipRouteProto value. If this metric is not used, its value should be set to -1.") ipRouteInfo = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 21, 1, 13), ObjectIdentifier()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipRouteInfo.setStatus('mandatory') +if mibBuilder.loadTexts: ipRouteInfo.setDescription("A reference to MIB definitions specific to the particular routing protocol which is responsible for this route, as determined by the value specified in the route's ipRouteProto value. If this information is not present, its value should be set to the OBJECT IDENTIFIER { 0 0 }, which is a syntatically valid object identifier, and any conformant implementation of ASN.1 and BER must be able to generate and recognize this value.") +ipNetToMediaTable = MibTable((1, 3, 6, 1, 2, 1, 4, 22), ) +if mibBuilder.loadTexts: ipNetToMediaTable.setStatus('mandatory') +if mibBuilder.loadTexts: ipNetToMediaTable.setDescription('The IP Address Translation table used for mapping from IP addresses to physical addresses.') +ipNetToMediaEntry = MibTableRow((1, 3, 6, 1, 2, 1, 4, 22, 1), ).setIndexNames((0, "RFC1213-MIB", "ipNetToMediaIfIndex"), (0, "RFC1213-MIB", "ipNetToMediaNetAddress")) +if mibBuilder.loadTexts: ipNetToMediaEntry.setStatus('mandatory') +if mibBuilder.loadTexts: ipNetToMediaEntry.setDescription("Each entry contains one IpAddress to `physical' address equivalence.") +ipNetToMediaIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 22, 1, 1), Integer32()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipNetToMediaIfIndex.setStatus('mandatory') +if mibBuilder.loadTexts: ipNetToMediaIfIndex.setDescription("The interface on which this entry's equivalence is effective. The interface identified by a particular value of this index is the same interface as identified by the same value of ifIndex.") +ipNetToMediaPhysAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 22, 1, 2), PhysAddress()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipNetToMediaPhysAddress.setStatus('mandatory') +if mibBuilder.loadTexts: ipNetToMediaPhysAddress.setDescription("The media-dependent `physical' address.") +ipNetToMediaNetAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 22, 1, 3), IpAddress()).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipNetToMediaNetAddress.setStatus('mandatory') +if mibBuilder.loadTexts: ipNetToMediaNetAddress.setDescription("The IpAddress corresponding to the media- dependent `physical' address.") +ipNetToMediaType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 22, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("dynamic", 3), ("static", 4)))).setMaxAccess("readwrite") +if mibBuilder.loadTexts: ipNetToMediaType.setStatus('mandatory') +if mibBuilder.loadTexts: ipNetToMediaType.setDescription('The type of mapping. Setting this object to the value invalid(2) has the effect of invalidating the corresponding entry in the ipNetToMediaTable. That is, it effectively dissasociates the interface identified with said entry from the mapping identified with said entry. It is an implementation-specific matter as to whether the agent removes an invalidated entry from the table. Accordingly, management stations must be prepared to receive tabular information from agents that corresponds to entries not currently in use. Proper interpretation of such entries requires examination of the relevant ipNetToMediaType object.') ipRoutingDiscards = MibScalar((1, 3, 6, 1, 2, 1, 4, 23), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: ipRoutingDiscards.setStatus('mandatory') +if mibBuilder.loadTexts: ipRoutingDiscards.setDescription('The number of routing entries which were chosen to be discarded even though they are valid. One possible reason for discarding such an entry could be to free-up buffer space for other routing entries.') +icmpInMsgs = MibScalar((1, 3, 6, 1, 2, 1, 5, 1), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInMsgs.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInMsgs.setDescription('The total number of ICMP messages which the entity received. Note that this counter includes all those counted by icmpInErrors.') +icmpInErrors = MibScalar((1, 3, 6, 1, 2, 1, 5, 2), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInErrors.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInErrors.setDescription('The number of ICMP messages which the entity received but determined as having ICMP-specific errors (bad ICMP checksums, bad length, etc.).') +icmpInDestUnreachs = MibScalar((1, 3, 6, 1, 2, 1, 5, 3), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInDestUnreachs.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInDestUnreachs.setDescription('The number of ICMP Destination Unreachable messages received.') +icmpInTimeExcds = MibScalar((1, 3, 6, 1, 2, 1, 5, 4), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInTimeExcds.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInTimeExcds.setDescription('The number of ICMP Time Exceeded messages received.') +icmpInParmProbs = MibScalar((1, 3, 6, 1, 2, 1, 5, 5), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInParmProbs.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInParmProbs.setDescription('The number of ICMP Parameter Problem messages received.') +icmpInSrcQuenchs = MibScalar((1, 3, 6, 1, 2, 1, 5, 6), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInSrcQuenchs.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInSrcQuenchs.setDescription('The number of ICMP Source Quench messages received.') +icmpInRedirects = MibScalar((1, 3, 6, 1, 2, 1, 5, 7), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInRedirects.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInRedirects.setDescription('The number of ICMP Redirect messages received.') +icmpInEchos = MibScalar((1, 3, 6, 1, 2, 1, 5, 8), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInEchos.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInEchos.setDescription('The number of ICMP Echo (request) messages received.') +icmpInEchoReps = MibScalar((1, 3, 6, 1, 2, 1, 5, 9), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInEchoReps.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInEchoReps.setDescription('The number of ICMP Echo Reply messages received.') +icmpInTimestamps = MibScalar((1, 3, 6, 1, 2, 1, 5, 10), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInTimestamps.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInTimestamps.setDescription('The number of ICMP Timestamp (request) messages received.') +icmpInTimestampReps = MibScalar((1, 3, 6, 1, 2, 1, 5, 11), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInTimestampReps.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInTimestampReps.setDescription('The number of ICMP Timestamp Reply messages received.') +icmpInAddrMasks = MibScalar((1, 3, 6, 1, 2, 1, 5, 12), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInAddrMasks.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInAddrMasks.setDescription('The number of ICMP Address Mask Request messages received.') +icmpInAddrMaskReps = MibScalar((1, 3, 6, 1, 2, 1, 5, 13), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpInAddrMaskReps.setStatus('mandatory') +if mibBuilder.loadTexts: icmpInAddrMaskReps.setDescription('The number of ICMP Address Mask Reply messages received.') +icmpOutMsgs = MibScalar((1, 3, 6, 1, 2, 1, 5, 14), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutMsgs.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutMsgs.setDescription('The total number of ICMP messages which this entity attempted to send. Note that this counter includes all those counted by icmpOutErrors.') +icmpOutErrors = MibScalar((1, 3, 6, 1, 2, 1, 5, 15), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutErrors.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutErrors.setDescription("The number of ICMP messages which this entity did not send due to problems discovered within ICMP such as a lack of buffers. This value should not include errors discovered outside the ICMP layer such as the inability of IP to route the resultant datagram. In some implementations there may be no types of error which contribute to this counter's value.") +icmpOutDestUnreachs = MibScalar((1, 3, 6, 1, 2, 1, 5, 16), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutDestUnreachs.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutDestUnreachs.setDescription('The number of ICMP Destination Unreachable messages sent.') +icmpOutTimeExcds = MibScalar((1, 3, 6, 1, 2, 1, 5, 17), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutTimeExcds.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutTimeExcds.setDescription('The number of ICMP Time Exceeded messages sent.') +icmpOutParmProbs = MibScalar((1, 3, 6, 1, 2, 1, 5, 18), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutParmProbs.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutParmProbs.setDescription('The number of ICMP Parameter Problem messages sent.') +icmpOutSrcQuenchs = MibScalar((1, 3, 6, 1, 2, 1, 5, 19), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutSrcQuenchs.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutSrcQuenchs.setDescription('The number of ICMP Source Quench messages sent.') +icmpOutRedirects = MibScalar((1, 3, 6, 1, 2, 1, 5, 20), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutRedirects.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutRedirects.setDescription('The number of ICMP Redirect messages sent. For a host, this object will always be zero, since hosts do not send redirects.') +icmpOutEchos = MibScalar((1, 3, 6, 1, 2, 1, 5, 21), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutEchos.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutEchos.setDescription('The number of ICMP Echo (request) messages sent.') +icmpOutEchoReps = MibScalar((1, 3, 6, 1, 2, 1, 5, 22), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutEchoReps.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutEchoReps.setDescription('The number of ICMP Echo Reply messages sent.') +icmpOutTimestamps = MibScalar((1, 3, 6, 1, 2, 1, 5, 23), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutTimestamps.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutTimestamps.setDescription('The number of ICMP Timestamp (request) messages sent.') +icmpOutTimestampReps = MibScalar((1, 3, 6, 1, 2, 1, 5, 24), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutTimestampReps.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutTimestampReps.setDescription('The number of ICMP Timestamp Reply messages sent.') +icmpOutAddrMasks = MibScalar((1, 3, 6, 1, 2, 1, 5, 25), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutAddrMasks.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutAddrMasks.setDescription('The number of ICMP Address Mask Request messages sent.') +icmpOutAddrMaskReps = MibScalar((1, 3, 6, 1, 2, 1, 5, 26), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: icmpOutAddrMaskReps.setStatus('mandatory') +if mibBuilder.loadTexts: icmpOutAddrMaskReps.setDescription('The number of ICMP Address Mask Reply messages sent.') +tcpRtoAlgorithm = MibScalar((1, 3, 6, 1, 2, 1, 6, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("constant", 2), ("rsre", 3), ("vanj", 4)))).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpRtoAlgorithm.setStatus('mandatory') +if mibBuilder.loadTexts: tcpRtoAlgorithm.setDescription('The algorithm used to determine the timeout value used for retransmitting unacknowledged octets.') +tcpRtoMin = MibScalar((1, 3, 6, 1, 2, 1, 6, 2), Integer32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpRtoMin.setStatus('mandatory') +if mibBuilder.loadTexts: tcpRtoMin.setDescription('The minimum value permitted by a TCP implementation for the retransmission timeout, measured in milliseconds. More refined semantics for objects of this type depend upon the algorithm used to determine the retransmission timeout. In particular, when the timeout algorithm is rsre(3), an object of this type has the semantics of the LBOUND quantity described in RFC 793.') +tcpRtoMax = MibScalar((1, 3, 6, 1, 2, 1, 6, 3), Integer32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpRtoMax.setStatus('mandatory') +if mibBuilder.loadTexts: tcpRtoMax.setDescription('The maximum value permitted by a TCP implementation for the retransmission timeout, measured in milliseconds. More refined semantics for objects of this type depend upon the algorithm used to determine the retransmission timeout. In particular, when the timeout algorithm is rsre(3), an object of this type has the semantics of the UBOUND quantity described in RFC 793.') +tcpMaxConn = MibScalar((1, 3, 6, 1, 2, 1, 6, 4), Integer32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpMaxConn.setStatus('mandatory') +if mibBuilder.loadTexts: tcpMaxConn.setDescription('The limit on the total number of TCP connections the entity can support. In entities where the maximum number of connections is dynamic, this object should contain the value -1.') +tcpActiveOpens = MibScalar((1, 3, 6, 1, 2, 1, 6, 5), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpActiveOpens.setStatus('mandatory') +if mibBuilder.loadTexts: tcpActiveOpens.setDescription('The number of times TCP connections have made a direct transition to the SYN-SENT state from the CLOSED state.') +tcpPassiveOpens = MibScalar((1, 3, 6, 1, 2, 1, 6, 6), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpPassiveOpens.setStatus('mandatory') +if mibBuilder.loadTexts: tcpPassiveOpens.setDescription('The number of times TCP connections have made a direct transition to the SYN-RCVD state from the LISTEN state.') +tcpAttemptFails = MibScalar((1, 3, 6, 1, 2, 1, 6, 7), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpAttemptFails.setStatus('mandatory') +if mibBuilder.loadTexts: tcpAttemptFails.setDescription('The number of times TCP connections have made a direct transition to the CLOSED state from either the SYN-SENT state or the SYN-RCVD state, plus the number of times TCP connections have made a direct transition to the LISTEN state from the SYN-RCVD state.') +tcpEstabResets = MibScalar((1, 3, 6, 1, 2, 1, 6, 8), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpEstabResets.setStatus('mandatory') +if mibBuilder.loadTexts: tcpEstabResets.setDescription('The number of times TCP connections have made a direct transition to the CLOSED state from either the ESTABLISHED state or the CLOSE-WAIT state.') +tcpCurrEstab = MibScalar((1, 3, 6, 1, 2, 1, 6, 9), Gauge32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpCurrEstab.setStatus('mandatory') +if mibBuilder.loadTexts: tcpCurrEstab.setDescription('The number of TCP connections for which the current state is either ESTABLISHED or CLOSE- WAIT.') +tcpInSegs = MibScalar((1, 3, 6, 1, 2, 1, 6, 10), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpInSegs.setStatus('mandatory') +if mibBuilder.loadTexts: tcpInSegs.setDescription('The total number of segments received, including those received in error. This count includes segments received on currently established connections.') +tcpOutSegs = MibScalar((1, 3, 6, 1, 2, 1, 6, 11), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpOutSegs.setStatus('mandatory') +if mibBuilder.loadTexts: tcpOutSegs.setDescription('The total number of segments sent, including those on current connections but excluding those containing only retransmitted octets.') +tcpRetransSegs = MibScalar((1, 3, 6, 1, 2, 1, 6, 12), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpRetransSegs.setStatus('mandatory') +if mibBuilder.loadTexts: tcpRetransSegs.setDescription('The total number of segments retransmitted - that is, the number of TCP segments transmitted containing one or more previously transmitted octets.') +tcpConnTable = MibTable((1, 3, 6, 1, 2, 1, 6, 13), ) +if mibBuilder.loadTexts: tcpConnTable.setStatus('mandatory') +if mibBuilder.loadTexts: tcpConnTable.setDescription('A table containing TCP connection-specific information.') +tcpConnEntry = MibTableRow((1, 3, 6, 1, 2, 1, 6, 13, 1), ).setIndexNames((0, "RFC1213-MIB", "tcpConnLocalAddress"), (0, "RFC1213-MIB", "tcpConnLocalPort"), (0, "RFC1213-MIB", "tcpConnRemAddress"), (0, "RFC1213-MIB", "tcpConnRemPort")) +if mibBuilder.loadTexts: tcpConnEntry.setStatus('mandatory') +if mibBuilder.loadTexts: tcpConnEntry.setDescription('Information about a particular current TCP connection. An object of this type is transient, in that it ceases to exist when (or soon after) the connection makes the transition to the CLOSED state.') +tcpConnState = MibTableColumn((1, 3, 6, 1, 2, 1, 6, 13, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))).clone(namedValues=NamedValues(("closed", 1), ("listen", 2), ("synSent", 3), ("synReceived", 4), ("established", 5), ("finWait1", 6), ("finWait2", 7), ("closeWait", 8), ("lastAck", 9), ("closing", 10), ("timeWait", 11), ("deleteTCB", 12)))).setMaxAccess("readwrite") +if mibBuilder.loadTexts: tcpConnState.setStatus('mandatory') +if mibBuilder.loadTexts: tcpConnState.setDescription("The state of this TCP connection. The only value which may be set by a management station is deleteTCB(12). Accordingly, it is appropriate for an agent to return a `badValue' response if a management station attempts to set this object to any other value. If a management station sets this object to the value deleteTCB(12), then this has the effect of deleting the TCB (as defined in RFC 793) of the corresponding connection on the managed node, resulting in immediate termination of the connection. As an implementation-specific option, a RST segment may be sent from the managed node to the other TCP endpoint (note however that RST segments are not sent reliably).") +tcpConnLocalAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 6, 13, 1, 2), IpAddress()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpConnLocalAddress.setStatus('mandatory') +if mibBuilder.loadTexts: tcpConnLocalAddress.setDescription('The local IP address for this TCP connection. In the case of a connection in the listen state which is willing to accept connections for any IP interface associated with the node, the value 0.0.0.0 is used.') +tcpConnLocalPort = MibTableColumn((1, 3, 6, 1, 2, 1, 6, 13, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpConnLocalPort.setStatus('mandatory') +if mibBuilder.loadTexts: tcpConnLocalPort.setDescription('The local port number for this TCP connection.') +tcpConnRemAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 6, 13, 1, 4), IpAddress()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpConnRemAddress.setStatus('mandatory') +if mibBuilder.loadTexts: tcpConnRemAddress.setDescription('The remote IP address for this TCP connection.') +tcpConnRemPort = MibTableColumn((1, 3, 6, 1, 2, 1, 6, 13, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpConnRemPort.setStatus('mandatory') +if mibBuilder.loadTexts: tcpConnRemPort.setDescription('The remote port number for this TCP connection.') +tcpInErrs = MibScalar((1, 3, 6, 1, 2, 1, 6, 14), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpInErrs.setStatus('mandatory') +if mibBuilder.loadTexts: tcpInErrs.setDescription('The total number of segments received in error (e.g., bad TCP checksums).') +tcpOutRsts = MibScalar((1, 3, 6, 1, 2, 1, 6, 15), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: tcpOutRsts.setStatus('mandatory') +if mibBuilder.loadTexts: tcpOutRsts.setDescription('The number of TCP segments sent containing the RST flag.') +udpInDatagrams = MibScalar((1, 3, 6, 1, 2, 1, 7, 1), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: udpInDatagrams.setStatus('mandatory') +if mibBuilder.loadTexts: udpInDatagrams.setDescription('The total number of UDP datagrams delivered to UDP users.') +udpNoPorts = MibScalar((1, 3, 6, 1, 2, 1, 7, 2), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: udpNoPorts.setStatus('mandatory') +if mibBuilder.loadTexts: udpNoPorts.setDescription('The total number of received UDP datagrams for which there was no application at the destination port.') +udpInErrors = MibScalar((1, 3, 6, 1, 2, 1, 7, 3), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: udpInErrors.setStatus('mandatory') +if mibBuilder.loadTexts: udpInErrors.setDescription('The number of received UDP datagrams that could not be delivered for reasons other than the lack of an application at the destination port.') +udpOutDatagrams = MibScalar((1, 3, 6, 1, 2, 1, 7, 4), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: udpOutDatagrams.setStatus('mandatory') +if mibBuilder.loadTexts: udpOutDatagrams.setDescription('The total number of UDP datagrams sent from this entity.') +udpTable = MibTable((1, 3, 6, 1, 2, 1, 7, 5), ) +if mibBuilder.loadTexts: udpTable.setStatus('mandatory') +if mibBuilder.loadTexts: udpTable.setDescription('A table containing UDP listener information.') +udpEntry = MibTableRow((1, 3, 6, 1, 2, 1, 7, 5, 1), ).setIndexNames((0, "RFC1213-MIB", "udpLocalAddress"), (0, "RFC1213-MIB", "udpLocalPort")) +if mibBuilder.loadTexts: udpEntry.setStatus('mandatory') +if mibBuilder.loadTexts: udpEntry.setDescription('Information about a particular current UDP listener.') +udpLocalAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 7, 5, 1, 1), IpAddress()).setMaxAccess("readonly") +if mibBuilder.loadTexts: udpLocalAddress.setStatus('mandatory') +if mibBuilder.loadTexts: udpLocalAddress.setDescription('The local IP address for this UDP listener. In the case of a UDP listener which is willing to accept datagrams for any IP interface associated with the node, the value 0.0.0.0 is used.') +udpLocalPort = MibTableColumn((1, 3, 6, 1, 2, 1, 7, 5, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") +if mibBuilder.loadTexts: udpLocalPort.setStatus('mandatory') +if mibBuilder.loadTexts: udpLocalPort.setDescription('The local port number for this UDP listener.') egpInMsgs = MibScalar((1, 3, 6, 1, 2, 1, 8, 1), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpInMsgs.setStatus('mandatory') +if mibBuilder.loadTexts: egpInMsgs.setDescription('The number of EGP messages received without error.') egpInErrors = MibScalar((1, 3, 6, 1, 2, 1, 8, 2), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpInErrors.setStatus('mandatory') +if mibBuilder.loadTexts: egpInErrors.setDescription('The number of EGP messages received that proved to be in error.') egpOutMsgs = MibScalar((1, 3, 6, 1, 2, 1, 8, 3), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpOutMsgs.setStatus('mandatory') +if mibBuilder.loadTexts: egpOutMsgs.setDescription('The total number of locally generated EGP messages.') egpOutErrors = MibScalar((1, 3, 6, 1, 2, 1, 8, 4), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpOutErrors.setStatus('mandatory') +if mibBuilder.loadTexts: egpOutErrors.setDescription('The number of locally generated EGP messages not sent due to resource limitations within an EGP entity.') egpNeighTable = MibTable((1, 3, 6, 1, 2, 1, 8, 5), ) +if mibBuilder.loadTexts: egpNeighTable.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighTable.setDescription('The EGP neighbor table.') egpNeighEntry = MibTableRow((1, 3, 6, 1, 2, 1, 8, 5, 1), ).setIndexNames((0, "RFC1213-MIB", "egpNeighAddr")) -egpNeighState = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 1), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2, 3, 4, 5,)).clone(namedValues=NamedValues(("idle", 1), ("acquisition", 2), ("down", 3), ("up", 4), ("cease", 5),))).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighEntry.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighEntry.setDescription("Information about this entity's relationship with a particular EGP neighbor.") +egpNeighState = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("idle", 1), ("acquisition", 2), ("down", 3), ("up", 4), ("cease", 5)))).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighState.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighState.setDescription("The EGP state of the local system with respect to this entry's EGP neighbor. Each EGP state is represented by a value that is one greater than the numerical value associated with said state in RFC 904.") egpNeighAddr = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 2), IpAddress()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighAddr.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighAddr.setDescription("The IP address of this entry's EGP neighbor.") egpNeighAs = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 3), Integer32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighAs.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighAs.setDescription('The autonomous system of this EGP peer. Zero should be specified if the autonomous system number of the neighbor is not yet known.') egpNeighInMsgs = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 4), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighInMsgs.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighInMsgs.setDescription('The number of EGP messages received without error from this EGP peer.') egpNeighInErrs = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 5), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighInErrs.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighInErrs.setDescription('The number of EGP messages received from this EGP peer that proved to be in error (e.g., bad EGP checksum).') egpNeighOutMsgs = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 6), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighOutMsgs.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighOutMsgs.setDescription('The number of locally generated EGP messages to this EGP peer.') egpNeighOutErrs = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 7), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighOutErrs.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighOutErrs.setDescription('The number of locally generated EGP messages not sent to this EGP peer due to resource limitations within an EGP entity.') egpNeighInErrMsgs = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 8), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighInErrMsgs.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighInErrMsgs.setDescription('The number of EGP-defined error messages received from this EGP peer.') egpNeighOutErrMsgs = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 9), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighOutErrMsgs.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighOutErrMsgs.setDescription('The number of EGP-defined error messages sent to this EGP peer.') egpNeighStateUps = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 10), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighStateUps.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighStateUps.setDescription('The number of EGP state transitions to the UP state with this EGP peer.') egpNeighStateDowns = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 11), Counter32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighStateDowns.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighStateDowns.setDescription('The number of EGP state transitions from the UP state to any other state with this EGP peer.') egpNeighIntervalHello = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 12), Integer32()).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighIntervalHello.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighIntervalHello.setDescription('The interval between EGP Hello command retransmissions (in hundredths of a second). This represents the t1 timer as defined in RFC 904.') egpNeighIntervalPoll = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 13), Integer32()).setMaxAccess("readonly") -egpNeighMode = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 14), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2,)).clone(namedValues=NamedValues(("active", 1), ("passive", 2),))).setMaxAccess("readonly") -egpNeighEventTrigger = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 15), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2,)).clone(namedValues=NamedValues(("start", 1), ("stop", 2),))).setMaxAccess("readwrite") +if mibBuilder.loadTexts: egpNeighIntervalPoll.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighIntervalPoll.setDescription('The interval between EGP poll command retransmissions (in hundredths of a second). This represents the t3 timer as defined in RFC 904.') +egpNeighMode = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("passive", 2)))).setMaxAccess("readonly") +if mibBuilder.loadTexts: egpNeighMode.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighMode.setDescription('The polling mode of this EGP entity, either passive or active.') +egpNeighEventTrigger = MibTableColumn((1, 3, 6, 1, 2, 1, 8, 5, 1, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("start", 1), ("stop", 2)))).setMaxAccess("readwrite") +if mibBuilder.loadTexts: egpNeighEventTrigger.setStatus('mandatory') +if mibBuilder.loadTexts: egpNeighEventTrigger.setDescription("A control variable used to trigger operator- initiated Start and Stop events. When read, this variable always returns the most recent value that egpNeighEventTrigger was set to. If it has not been set since the last initialization of the network management subsystem on the node, it returns a value of `stop'. When set, this variable causes a Start or Stop event on the specified neighbor, as specified on pages 8-10 of RFC 904. Briefly, a Start event causes an Idle peer to begin neighbor acquisition and a non-Idle peer to reinitiate neighbor acquisition. A stop event causes a non-Idle peer to return to the Idle state until a Start event occurs, either via egpNeighEventTrigger or otherwise.") egpAs = MibScalar((1, 3, 6, 1, 2, 1, 8, 6), Integer32()).setMaxAccess("readonly") -mibBuilder.exportSymbols("RFC1213-MIB", atPhysAddress=atPhysAddress, egpNeighMode=egpNeighMode, egpOutMsgs=egpOutMsgs, ipRouteAge=ipRouteAge, ipRouteEntry=ipRouteEntry, egpNeighStateUps=egpNeighStateUps, ipRouteInfo=ipRouteInfo, ipRoutingDiscards=ipRoutingDiscards, egpInErrors=egpInErrors, egpOutErrors=egpOutErrors, ipRouteTable=ipRouteTable, egpNeighEventTrigger=egpNeighEventTrigger, egpNeighTable=egpNeighTable, ipRouteProto=ipRouteProto, egpNeighStateDowns=egpNeighStateDowns, ipRouteNextHop=ipRouteNextHop, ipRouteMetric3=ipRouteMetric3, ipRouteMetric4=ipRouteMetric4, ipRouteDest=ipRouteDest, ipRouteMetric2=ipRouteMetric2, egpNeighState=egpNeighState, atNetAddress=atNetAddress, egpNeighOutErrs=egpNeighOutErrs, ipRouteIfIndex=ipRouteIfIndex, atIfIndex=atIfIndex, ipRouteMask=ipRouteMask, ipRouteMetric5=ipRouteMetric5, ipRouteType=ipRouteType, egpNeighIntervalPoll=egpNeighIntervalPoll, egpNeighIntervalHello=egpNeighIntervalHello, atTable=atTable, ipRouteMetric1=ipRouteMetric1, egpNeighInErrMsgs=egpNeighInErrMsgs, egpNeighInErrs=egpNeighInErrs, egpAs=egpAs, egpNeighAddr=egpNeighAddr, egpNeighEntry=egpNeighEntry, egpNeighOutErrMsgs=egpNeighOutErrMsgs, at=at, atEntry=atEntry, egpNeighOutMsgs=egpNeighOutMsgs, egpNeighInMsgs=egpNeighInMsgs, egpInMsgs=egpInMsgs, egpNeighAs=egpNeighAs, egp=egp) +if mibBuilder.loadTexts: egpAs.setStatus('mandatory') +if mibBuilder.loadTexts: egpAs.setDescription('The autonomous system number of this EGP entity.') +mibBuilder.exportSymbols("RFC1213-MIB", ipAdEntReasmMaxSize=ipAdEntReasmMaxSize, icmpOutAddrMasks=icmpOutAddrMasks, ipRouteNextHop=ipRouteNextHop, tcpRtoMax=tcpRtoMax, ipOutRequests=ipOutRequests, udpNoPorts=udpNoPorts, ipNetToMediaIfIndex=ipNetToMediaIfIndex, ipNetToMediaTable=ipNetToMediaTable, udpTable=udpTable, tcpRetransSegs=tcpRetransSegs, icmpOutAddrMaskReps=icmpOutAddrMaskReps, icmpInEchoReps=icmpInEchoReps, ipRouteMetric5=ipRouteMetric5, ipNetToMediaNetAddress=ipNetToMediaNetAddress, ipAddrTable=ipAddrTable, tcpAttemptFails=tcpAttemptFails, icmpInDestUnreachs=icmpInDestUnreachs, ipAdEntIfIndex=ipAdEntIfIndex, egpInErrors=egpInErrors, TtcpInSegs=tcpInSegs, icmpInAddrMaskReps=icmpInAddrMaskReps, egp=egp, icmpInSrcQuenchs=icmpInSrcQuenchs, icmpInTimestamps=icmpInTimestamps, ipOutNoRoutes=ipOutNoRoutes, icmpOutTimestampReps=icmpOutTimestampReps, udpLocalPort=udpLocalPort, ipRouteType=ipRouteType, atIfIndex=atIfIndex, tcpEstabResets=tcpEstabResets, icmpOutTimestamps=icmpOutTimestamps, ipAdEntBcastAddr=ipAdEntBcastAddr, PhysAddress=PhysAddress, mib_2=mib_2, atPhysAddress=atPhysAddress, icmpInAddrMasks=icmpInAddrMasks, ipRouteMask=ipRouteMask, ipInHdrErrors=ipInHdrErrors, egpNeighInMsgs=egpNeighInMsgs, egpNeighAs=egpNeighAs, icmpOutErrors=icmpOutErrors, icmpOutTimeExcds=icmpOutTimeExcds, icmpOutEchoReps=icmpOutEchoReps, icmpOutDestUnreachs=icmpOutDestUnreachs, ipReasmFails=ipReasmFails, egpNeighOutErrMsgs=egpNeighOutErrMsgs, egpNeighEntry=egpNeighEntry, egpNeighTable=egpNeighTable, DisplayString=DisplayString, ipRouteIfIndex=ipRouteIfIndex, tcpRtoMin=tcpRtoMin, icmpInParmProbs=icmpInParmProbs, tcpCurrEstab=tcpCurrEstab, tcpConnLocalPort=tcpConnLocalPort, tcpOutRsts=tcpOutRsts, icmpOutEchos=icmpOutEchos, ipAdEntAddr=ipAdEntAddr, ipRouteInfo=ipRouteInfo, tcpConnRemAddress=tcpConnRemAddress, ipNetToMediaPhysAddress=ipNetToMediaPhysAddress, ipDefaultTTL=ipDefaultTTL, ipInUnknownProtos=ipInUnknownProtos, ipOutDiscards=ipOutDiscards, ipRouteEntry=ipRouteEntry, egpInMsgs=egpInMsgs, egpNeighIntervalHello=egpNeighIntervalHello, ipRouteProto=ipRouteProto, icmpOutMsgs=icmpOutMsgs, egpNeighStateDowns=egpNeighStateDowns, ipRouteAge=ipRouteAge, icmpInErrors=icmpInErrors, tcpConnTable=tcpConnTable, egpNeighInErrMsgs=egpNeighInErrMsgs, ipInAddrErrors=ipInAddrErrors, tcpOutSegs=tcpOutSegs, icmpInTimestampReps=icmpInTimestampReps, tcpConnLocalAddress=tcpConnLocalAddress, udpOutDatagrams=udpOutDatagrams, tcpRtoAlgorithm=tcpRtoAlgorithm, ipFragCreates=ipFragCreates, tcpPassiveOpens=tcpPassiveOpens, ipNetToMediaEntry=ipNetToMediaEntry, ipInReceives=ipInReceives, ipForwDatagrams=ipForwDatagrams, tcpActiveOpens=tcpActiveOpens, ipFragOKs=ipFragOKs, ipAddrEntry=ipAddrEntry, ipRouteDest=ipRouteDest, udpInDatagrams=udpInDatagrams, egpOutErrors=egpOutErrors, ipRouteMetric1=ipRouteMetric1, ipAdEntNetMask=ipAdEntNetMask, tcpConnEntry=tcpConnEntry, tcpConnRemPort=tcpConnRemPort, ipReasmTimeout=ipReasmTimeout, udpInErrors=udpInErrors, udpEntry=udpEntry, egpNeighState=egpNeighState, ipReasmReqds=ipReasmReqds, egpNeighInErrs=egpNeighInErrs, tcpInErrs=tcpInErrs, egpNeighAddr=egpNeighAddr, ipInDelivers=ipInDelivers, udpLocalAddress=udpLocalAddress, icmpOutRedirects=icmpOutRedirects, icmpInRedirects=icmpInRedirects, ipReasmOKs=ipReasmOKs, egpAs=egpAs, egpOutMsgs=egpOutMsgs, ipRouteMetric3=ipRouteMetric3, icmpInMsgs=icmpInMsgs, icmpOutParmProbs=icmpOutParmProbs, ipRouteMetric2=ipRouteMetric2, atTable=atTable, egpNeighEventTrigger=egpNeighEventTrigger, ipNetToMediaType=ipNetToMediaType, icmpOutSrcQuenchs=icmpOutSrcQuenchs, icmpInTimeExcds=icmpInTimeExcds, icmpInEchos=icmpInEchos, egpNeighStateUps=egpNeighStateUps, atNetAddress=atNetAddress, egpNeighOutMsgs=egpNeighOutMsgs, ipRouteTable=ipRouteTable, tcpConnState=tcpConnState, tcpMaxConn=tcpMaxConn, ipForwarding=ipForwarding, atEntry=atEntry, ipRoutingDiscards=ipRoutingDiscards, ipRouteMetric4=ipRouteMetric4, egpNeighIntervalPoll=egpNeighIntervalPoll, ipFragFails=ipFragFails, egpNeighOutErrs=egpNeighOutErrs, at=at, ipInDiscards=ipInDiscards, egpNeighMode=egpNeighMode) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-COMMUNITY-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-COMMUNITY-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-COMMUNITY-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-COMMUNITY-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,72 +1,91 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMP-COMMUNITY-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/SNMP-COMMUNITY-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 16:28:11 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module SNMP-COMMUNITY-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-COMMUNITY-MIB +# Produced by pysmi-0.1.3 at Mon Apr 17 13:47:39 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( SnmpAdminString, SnmpEngineID, ) = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString", "SnmpEngineID") -( snmpTargetAddrEntry, SnmpTagValue, ) = mibBuilder.importSymbols("SNMP-TARGET-MIB", "snmpTargetAddrEntry", "SnmpTagValue") -( NotificationGroup, ModuleCompliance, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, Bits, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, snmpModules, iso, ObjectIdentity, IpAddress, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "Bits", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "snmpModules", "iso", "ObjectIdentity", "IpAddress", "Counter32") -( StorageType, DisplayString, RowStatus, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "StorageType", "DisplayString", "RowStatus", "TextualConvention") -snmpCommunityMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 18)).setRevisions(("2000-03-06 00:00", "1999-05-13 00:00",)) -if mibBuilder.loadTexts: snmpCommunityMIB.setLastUpdated('200003060000Z') +OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ConstraintsUnion, ConstraintsIntersection, ValueRangeConstraint, ValueSizeConstraint, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ConstraintsIntersection", "ValueRangeConstraint", "ValueSizeConstraint", "SingleValueConstraint") +SnmpAdminString, SnmpEngineID = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString", "SnmpEngineID") +snmpTargetAddrEntry, SnmpTagValue = mibBuilder.importSymbols("SNMP-TARGET-MIB", "snmpTargetAddrEntry", "SnmpTagValue") +NotificationGroup, ObjectGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ObjectGroup", "ModuleCompliance") +Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, Bits, ModuleIdentity, TimeTicks, Counter32, Gauge32, Integer32, Counter64, MibIdentifier, IpAddress, snmpModules, iso, ObjectIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "Bits", "ModuleIdentity", "TimeTicks", "Counter32", "Gauge32", "Integer32", "Counter64", "MibIdentifier", "IpAddress", "snmpModules", "iso", "ObjectIdentity") +DisplayString, RowStatus, StorageType, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "RowStatus", "StorageType", "TextualConvention") +snmpCommunityMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 18)) +if mibBuilder.loadTexts: snmpCommunityMIB.setRevisions(('2003-08-06 00:00', '2000-03-06 00:00',)) +if mibBuilder.loadTexts: snmpCommunityMIB.setLastUpdated('200308060000Z') if mibBuilder.loadTexts: snmpCommunityMIB.setOrganization('SNMPv3 Working Group') -if mibBuilder.loadTexts: snmpCommunityMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com\n Subscribe: majordomo@lists.tislabs.com\n In msg body: subscribe snmpv3\n\n Chair: Russ Mundy\n TIS Labs at Network Associates\n Postal: 3060 Washington Rd\n Glenwood MD 21738\n USA\n Email: mundy@tislabs.com\n Phone: +1-301-854-6889\n\n Co-editor: Rob Frye\n CoSine Communications\n Postal: 1200 Bridge Parkway\n Redwood City, CA 94065\n USA\n E-mail: rfrye@cosinecom.com\n Phone: +1 703 725 1130\n\n Co-editor: David B. Levi\n Nortel Networks\n Postal: 3505 Kesterwood Drive\n Knoxville, TN 37918\n E-mail: dlevi@nortelnetworks.com\n Phone: +1 423 686 0432\n\n Co-editor: Shawn A. Routhier\n Integrated Systems Inc.\n Postal: 333 North Ave 4th Floor\n Wakefield, MA 01880\n E-mail: sar@epilogue.com\n Phone: +1 781 245 0804\n\n Co-editor: Bert Wijnen\n Lucent Technologies\n Postal: Schagen 33\n 3461 GL Linschoten\n Netherlands\n Email: bwijnen@lucent.com\n Phone: +31-348-407-775\n ') -if mibBuilder.loadTexts: snmpCommunityMIB.setDescription('This MIB module defines objects to help support coexistence\n between SNMPv1, SNMPv2c, and SNMPv3.') +if mibBuilder.loadTexts: snmpCommunityMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com Subscribe: majordomo@lists.tislabs.com In msg body: subscribe snmpv3 Co-Chair: Russ Mundy SPARTA, Inc Postal: 7075 Samuel Morse Drive Columbia, MD 21045 USA EMail: mundy@tislabs.com Phone: +1 410-872-1515 Co-Chair: David Harrington Enterasys Networks Postal: 35 Industrial Way P. O. Box 5005 Rochester, New Hampshire 03866-5005 USA EMail: dbh@enterasys.com Phone: +1 603-337-2614 Co-editor: Rob Frye Vibrant Solutions Postal: 2711 Prosperity Ave Fairfax, Virginia 22031 USA E-mail: rfrye@vibrant-1.com Phone: +1-703-270-2000 Co-editor: David B. Levi Nortel Networks Postal: 3505 Kesterwood Drive Knoxville, Tennessee 37918 E-mail: dlevi@nortelnetworks.com Phone: +1 865 686 0432 Co-editor: Shawn A. Routhier Wind River Systems, Inc. Postal: 500 Wind River Way Alameda, CA 94501 E-mail: sar@epilogue.com Phone: +1 510 749 2095 Co-editor: Bert Wijnen Lucent Technologies Postal: Schagen 33 3461 GL Linschoten Netherlands Email: bwijnen@lucent.com Phone: +31-348-407-775 ') +if mibBuilder.loadTexts: snmpCommunityMIB.setDescription('This MIB module defines objects to help support coexistence between SNMPv1, SNMPv2c, and SNMPv3. Copyright (C) The Internet Society (2003) This version of this MIB module is part of RFC 3584; see the RFC itself for full legal notices.') snmpCommunityMIBObjects = MibIdentifier((1, 3, 6, 1, 6, 3, 18, 1)) snmpCommunityMIBConformance = MibIdentifier((1, 3, 6, 1, 6, 3, 18, 2)) snmpCommunityTable = MibTable((1, 3, 6, 1, 6, 3, 18, 1, 1), ) -if mibBuilder.loadTexts: snmpCommunityTable.setDescription("The table of community strings configured in the SNMP\n engine's Local Configuration Datastore (LCD).") +if mibBuilder.loadTexts: snmpCommunityTable.setStatus('current') +if mibBuilder.loadTexts: snmpCommunityTable.setDescription("The table of community strings configured in the SNMP engine's Local Configuration Datastore (LCD).") snmpCommunityEntry = MibTableRow((1, 3, 6, 1, 6, 3, 18, 1, 1, 1), ).setIndexNames((1, "SNMP-COMMUNITY-MIB", "snmpCommunityIndex")) +if mibBuilder.loadTexts: snmpCommunityEntry.setStatus('current') if mibBuilder.loadTexts: snmpCommunityEntry.setDescription('Information about a particular community string.') -snmpCommunityIndex = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))) +snmpCommunityIndex = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) +if mibBuilder.loadTexts: snmpCommunityIndex.setStatus('current') if mibBuilder.loadTexts: snmpCommunityIndex.setDescription('The unique index value of a row in this table.') snmpCommunityName = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 2), OctetString()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpCommunityName.setDescription('The community string for which a row in this table\n represents a configuration.') -snmpCommunitySecurityName = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 3), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpCommunitySecurityName.setDescription('A human readable string representing the corresponding\n value of snmpCommunityName in a Security Model\n independent format.') +if mibBuilder.loadTexts: snmpCommunityName.setStatus('current') +if mibBuilder.loadTexts: snmpCommunityName.setDescription('The community string for which a row in this table represents a configuration. There is no SIZE constraint specified for this object because RFC 1157 does not impose any explicit limitation on the length of community strings (their size is constrained indirectly by the SNMP message size).') +snmpCommunitySecurityName = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 3), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpCommunitySecurityName.setStatus('current') +if mibBuilder.loadTexts: snmpCommunitySecurityName.setDescription('A human readable string representing the corresponding value of snmpCommunityName in a Security Model independent format.') snmpCommunityContextEngineID = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 4), SnmpEngineID()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpCommunityContextEngineID.setDescription('The contextEngineID indicating the location of the\n context in which management information is accessed\n when using the community string specified by the\n corresponding instance of snmpCommunityName.\n\n The default value is the snmpEngineID of the entity in\n which this object is instantiated.') -snmpCommunityContextName = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 5), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0,32)).clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpCommunityContextName.setDescription('The context in which management information is accessed\n when using the community string specified by the corresponding\n instance of snmpCommunityName.') +if mibBuilder.loadTexts: snmpCommunityContextEngineID.setStatus('current') +if mibBuilder.loadTexts: snmpCommunityContextEngineID.setDescription('The contextEngineID indicating the location of the context in which management information is accessed when using the community string specified by the corresponding instance of snmpCommunityName. The default value is the snmpEngineID of the entity in which this object is instantiated.') +snmpCommunityContextName = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 5), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 32)).clone(hexValue="")).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpCommunityContextName.setStatus('current') +if mibBuilder.loadTexts: snmpCommunityContextName.setDescription('The context in which management information is accessed when using the community string specified by the corresponding instance of snmpCommunityName.') snmpCommunityTransportTag = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 6), SnmpTagValue().clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpCommunityTransportTag.setDescription('This object specifies a set of transport endpoints\n from which a command responder application will accept\n management requests. If a management request containing\n this community is received on a transport endpoint other\n than the transport endpoints identified by this object,\n the request is deemed unauthentic.\n\n The transports identified by this object are specified\n\n in the snmpTargetAddrTable. Entries in that table\n whose snmpTargetAddrTagList contains this tag value\n are identified.\n\n If the value of this object has zero-length, transport\n endpoints are not checked when authenticating messages\n containing this community string.') +if mibBuilder.loadTexts: snmpCommunityTransportTag.setStatus('current') +if mibBuilder.loadTexts: snmpCommunityTransportTag.setDescription('This object specifies a set of transport endpoints which are used in two ways: - to specify the transport endpoints from which an SNMP entity will accept management requests, and - to specify the transport endpoints to which a notification may be sent using the community string matching the corresponding instance of snmpCommunityName. In either case, if the value of this object has zero-length, transport endpoints are not checked when either authenticating messages containing this community string, nor when generating notifications. The transports identified by this object are specified in the snmpTargetAddrTable. Entries in that table whose snmpTargetAddrTagList contains this tag value are identified. If a management request containing a community string that matches the corresponding instance of snmpCommunityName is received on a transport endpoint other than the transport endpoints identified by this object the request is deemed unauthentic. When a notification is to be sent using an entry in this table, if the destination transport endpoint of the notification does not match one of the transport endpoints selected by this object, the notification is not sent.') snmpCommunityStorageType = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 7), StorageType()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpCommunityStorageType.setDescription("The storage type for this conceptual row in the\n snmpCommunityTable. Conceptual rows having the value\n 'permanent' need not allow write-access to any\n columnar object in the row.") +if mibBuilder.loadTexts: snmpCommunityStorageType.setStatus('current') +if mibBuilder.loadTexts: snmpCommunityStorageType.setDescription("The storage type for this conceptual row in the snmpCommunityTable. Conceptual rows having the value 'permanent' need not allow write-access to any columnar object in the row.") snmpCommunityStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 1, 1, 8), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpCommunityStatus.setDescription('The status of this conceptual row in the snmpCommunityTable.\n\n An entry in this table is not qualified for activation\n until instances of all corresponding columns have been\n initialized, either through default values, or through\n Set operations. The snmpCommunityName and\n snmpCommunitySecurityName objects must be explicitly set.\n\n There is no restriction on setting columns in this table\n when the value of snmpCommunityStatus is active(1).') +if mibBuilder.loadTexts: snmpCommunityStatus.setStatus('current') +if mibBuilder.loadTexts: snmpCommunityStatus.setDescription('The status of this conceptual row in the snmpCommunityTable. An entry in this table is not qualified for activation until instances of all corresponding columns have been initialized, either through default values, or through Set operations. The snmpCommunityName and snmpCommunitySecurityName objects must be explicitly set. There is no restriction on setting columns in this table when the value of snmpCommunityStatus is active(1).') snmpTargetAddrExtTable = MibTable((1, 3, 6, 1, 6, 3, 18, 1, 2), ) -if mibBuilder.loadTexts: snmpTargetAddrExtTable.setDescription('The table of mask and mms values associated with the\n\n snmpTargetAddrTable.\n\n The snmpTargetAddrExtTable augments the\n snmpTargetAddrTable with a transport address mask value\n and a maximum message size value. The transport address\n mask allows entries in the snmpTargetAddrTable to define\n a set of addresses instead of just a single address.\n The maximum message size value allows the maximum\n message size of another SNMP entity to be configured for\n use in SNMPv1 (and SNMPv2c) transactions, where the\n message format does not specify a maximum message size.') +if mibBuilder.loadTexts: snmpTargetAddrExtTable.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrExtTable.setDescription('The table of mask and maximum message size (mms) values associated with the snmpTargetAddrTable. The snmpTargetAddrExtTable augments the snmpTargetAddrTable with a transport address mask value and a maximum message size value. The transport address mask allows entries in the snmpTargetAddrTable to define a set of addresses instead of just a single address. The maximum message size value allows the maximum message size of another SNMP entity to be configured for use in SNMPv1 (and SNMPv2c) transactions, where the message format does not specify a maximum message size.') snmpTargetAddrExtEntry = MibTableRow((1, 3, 6, 1, 6, 3, 18, 1, 2, 1), ) snmpTargetAddrEntry.registerAugmentions(("SNMP-COMMUNITY-MIB", "snmpTargetAddrExtEntry")) snmpTargetAddrExtEntry.setIndexNames(*snmpTargetAddrEntry.getIndexNames()) +if mibBuilder.loadTexts: snmpTargetAddrExtEntry.setStatus('current') if mibBuilder.loadTexts: snmpTargetAddrExtEntry.setDescription('Information about a particular mask and mms value.') -snmpTargetAddrTMask = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 2, 1, 1), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0,255)).clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetAddrTMask.setDescription('The mask value associated with an entry in the\n snmpTargetAddrTable. The value of this object must\n have the same length as the corresponding instance of\n snmpTargetAddrTAddress, or must have length 0. An\n attempt to set it to any other value will result in\n an inconsistentValue error.\n\n The value of this object allows an entry in the\n snmpTargetAddrTable to specify multiple addresses.\n The mask value is used to select which bits of\n a transport address must match bits of the corresponding\n instance of snmpTargetAddrTAddress, in order for the\n transport address to match a particular entry in the\n snmpTargetAddrTable. Bits which are 1 in the mask\n value indicate bits in the transport address which\n must match bits in the snmpTargetAddrTAddress value.\n\n Bits which are 0 in the mask indicate bits in the\n transport address which need not match. If the\n length of the mask is 0, the mask should be treated\n as if all its bits were 1 and its length were equal\n to the length of the corresponding value of\n snmpTargetAddrTable.\n\n This object may not be modified while the value of the\n corresponding instance of snmpTargetAddrRowStatus is\n active(1). An attempt to set this object in this case\n will result in an inconsistentValue error.') -snmpTargetAddrMMS = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(0,0),ValueRangeConstraint(484,2147483647),)).clone(484)).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetAddrMMS.setDescription('The maximum message size value associated with an entry\n in the snmpTargetAddrTable.') +snmpTargetAddrTMask = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 2, 1, 1), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 255)).clone(hexValue="")).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpTargetAddrTMask.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrTMask.setDescription('The mask value associated with an entry in the snmpTargetAddrTable. The value of this object must have the same length as the corresponding instance of snmpTargetAddrTAddress, or must have length 0. An attempt to set it to any other value will result in an inconsistentValue error. The value of this object allows an entry in the snmpTargetAddrTable to specify multiple addresses. The mask value is used to select which bits of a transport address must match bits of the corresponding instance of snmpTargetAddrTAddress, in order for the transport address to match a particular entry in the snmpTargetAddrTable. Bits which are 1 in the mask value indicate bits in the transport address which must match bits in the snmpTargetAddrTAddress value. Bits which are 0 in the mask indicate bits in the transport address which need not match. If the length of the mask is 0, the mask should be treated as if all its bits were 1 and its length were equal to the length of the corresponding value of snmpTargetAddrTable. This object may not be modified while the value of the corresponding instance of snmpTargetAddrRowStatus is active(1). An attempt to set this object in this case will result in an inconsistentValue error.') +snmpTargetAddrMMS = MibTableColumn((1, 3, 6, 1, 6, 3, 18, 1, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(0, 0), ValueRangeConstraint(484, 2147483647), )).clone(484)).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpTargetAddrMMS.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrMMS.setDescription('The maximum message size value associated with an entry in the snmpTargetAddrTable. Note that a value of 0 means that the maximum message size is unknown.') snmpTrapAddress = MibScalar((1, 3, 6, 1, 6, 3, 18, 1, 3), IpAddress()).setMaxAccess("accessiblefornotify") -if mibBuilder.loadTexts: snmpTrapAddress.setDescription('The value of the agent-addr field of a Trap PDU which\n is forwarded by a proxy forwarder application using\n an SNMP version other than SNMPv1. The value of this\n object SHOULD contain the value of the agent-addr field\n from the original Trap PDU as generated by an SNMPv1\n agent.') +if mibBuilder.loadTexts: snmpTrapAddress.setStatus('current') +if mibBuilder.loadTexts: snmpTrapAddress.setDescription('The value of the agent-addr field of a Trap PDU which is forwarded by a proxy forwarder application using an SNMP version other than SNMPv1. The value of this object SHOULD contain the value of the agent-addr field from the original Trap PDU as generated by an SNMPv1 agent.') snmpTrapCommunity = MibScalar((1, 3, 6, 1, 6, 3, 18, 1, 4), OctetString()).setMaxAccess("accessiblefornotify") -if mibBuilder.loadTexts: snmpTrapCommunity.setDescription('The value of the community string field of an SNMPv1\n message containing a Trap PDU which is forwarded by a\n a proxy forwarder application using an SNMP version\n other than SNMPv1. The value of this object SHOULD\n contain the value of the community string field from\n the original SNMPv1 message containing a Trap PDU as\n generated by an SNMPv1 agent.') +if mibBuilder.loadTexts: snmpTrapCommunity.setStatus('current') +if mibBuilder.loadTexts: snmpTrapCommunity.setDescription('The value of the community string field of an SNMPv1 message containing a Trap PDU which is forwarded by a a proxy forwarder application using an SNMP version other than SNMPv1. The value of this object SHOULD contain the value of the community string field from the original SNMPv1 message containing a Trap PDU as generated by an SNMPv1 agent. There is no SIZE constraint specified for this object because RFC 1157 does not impose any explicit limitation on the length of community strings (their size is constrained indirectly by the SNMP message size).') snmpCommunityMIBCompliances = MibIdentifier((1, 3, 6, 1, 6, 3, 18, 2, 1)) snmpCommunityMIBGroups = MibIdentifier((1, 3, 6, 1, 6, 3, 18, 2, 2)) -snmpCommunityMIBCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 18, 2, 1, 1)).setObjects(*(("SNMP-COMMUNITY-MIB", "snmpCommunityGroup"),)) -if mibBuilder.loadTexts: snmpCommunityMIBCompliance.setDescription('The compliance statement for SNMP engines which\n implement the SNMP-COMMUNITY-MIB.') -snmpProxyTrapForwardCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 18, 2, 1, 2)).setObjects(*(("SNMP-COMMUNITY-MIB", "snmpProxyTrapForwardGroup"),)) -if mibBuilder.loadTexts: snmpProxyTrapForwardCompliance.setDescription('The compliance statement for SNMP engines which\n contain a proxy forwarding application which is\n capable of forwarding SNMPv1 traps using SNMPv2c\n or SNMPv3.') -snmpCommunityGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 18, 2, 2, 1)).setObjects(*(("SNMP-COMMUNITY-MIB", "snmpCommunityName"), ("SNMP-COMMUNITY-MIB", "snmpCommunitySecurityName"), ("SNMP-COMMUNITY-MIB", "snmpCommunityContextEngineID"), ("SNMP-COMMUNITY-MIB", "snmpCommunityContextName"), ("SNMP-COMMUNITY-MIB", "snmpCommunityTransportTag"), ("SNMP-COMMUNITY-MIB", "snmpCommunityStorageType"), ("SNMP-COMMUNITY-MIB", "snmpCommunityStatus"), ("SNMP-COMMUNITY-MIB", "snmpTargetAddrTMask"), ("SNMP-COMMUNITY-MIB", "snmpTargetAddrMMS"),)) -if mibBuilder.loadTexts: snmpCommunityGroup.setDescription('A collection of objects providing for configuration\n of community strings for SNMPv1 (and SNMPv2c) usage.') -snmpProxyTrapForwardGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 18, 2, 2, 3)).setObjects(*(("SNMP-COMMUNITY-MIB", "snmpTrapAddress"), ("SNMP-COMMUNITY-MIB", "snmpTrapCommunity"),)) -if mibBuilder.loadTexts: snmpProxyTrapForwardGroup.setDescription('Objects which are used by proxy forwarding applications\n when translating traps between SNMP versions. These are\n used to preserve SNMPv1-specific information when\n\n translating to SNMPv2c or SNMPv3.') -mibBuilder.exportSymbols("SNMP-COMMUNITY-MIB", snmpCommunityContextName=snmpCommunityContextName, snmpCommunityMIBConformance=snmpCommunityMIBConformance, snmpCommunityName=snmpCommunityName, PYSNMP_MODULE_ID=snmpCommunityMIB, snmpCommunityMIBCompliance=snmpCommunityMIBCompliance, snmpCommunityContextEngineID=snmpCommunityContextEngineID, snmpCommunityEntry=snmpCommunityEntry, snmpCommunityMIBGroups=snmpCommunityMIBGroups, snmpCommunityMIB=snmpCommunityMIB, snmpCommunitySecurityName=snmpCommunitySecurityName, snmpProxyTrapForwardCompliance=snmpProxyTrapForwardCompliance, snmpCommunityTransportTag=snmpCommunityTransportTag, snmpTargetAddrExtTable=snmpTargetAddrExtTable, snmpCommunityMIBObjects=snmpCommunityMIBObjects, snmpTrapAddress=snmpTrapAddress, snmpCommunityMIBCompliances=snmpCommunityMIBCompliances, snmpCommunityIndex=snmpCommunityIndex, snmpCommunityGroup=snmpCommunityGroup, snmpTrapCommunity=snmpTrapCommunity, snmpCommunityStorageType=snmpCommunityStorageType, snmpTargetAddrTMask=snmpTargetAddrTMask, snmpCommunityTable=snmpCommunityTable, snmpTargetAddrExtEntry=snmpTargetAddrExtEntry, snmpCommunityStatus=snmpCommunityStatus, snmpProxyTrapForwardGroup=snmpProxyTrapForwardGroup, snmpTargetAddrMMS=snmpTargetAddrMMS) +snmpCommunityMIBCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 18, 2, 1, 1)).setObjects(("SNMP-COMMUNITY-MIB", "snmpCommunityTableGroup")) +if mibBuilder.loadTexts: snmpCommunityMIBCompliance.setDescription('The compliance statement for SNMP engines which implement the SNMP-COMMUNITY-MIB.') +snmpProxyTrapForwardCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 18, 2, 1, 2)).setObjects(("SNMP-COMMUNITY-MIB", "snmpProxyTrapForwardGroup")) +if mibBuilder.loadTexts: snmpProxyTrapForwardCompliance.setDescription('The compliance statement for SNMP engines which contain a proxy forwarding application which is capable of forwarding SNMPv1 traps using SNMPv2c or SNMPv3.') +snmpCommunityMIBFullCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 18, 2, 1, 3)).setObjects(("SNMP-COMMUNITY-MIB", "snmpCommunityTableGroup")) +if mibBuilder.loadTexts: snmpCommunityMIBFullCompliance.setDescription('The compliance statement for SNMP engines which implement the SNMP-COMMUNITY-MIB with full read-create access.') +snmpCommunityTableGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 18, 2, 2, 1)).setObjects(("SNMP-COMMUNITY-MIB", "snmpCommunityName"), ("SNMP-COMMUNITY-MIB", "snmpCommunitySecurityName"), ("SNMP-COMMUNITY-MIB", "snmpCommunityContextEngineID"), ("SNMP-COMMUNITY-MIB", "snmpCommunityContextName"), ("SNMP-COMMUNITY-MIB", "snmpCommunityTransportTag"), ("SNMP-COMMUNITY-MIB", "snmpCommunityStorageType"), ("SNMP-COMMUNITY-MIB", "snmpCommunityStatus"), ("SNMP-COMMUNITY-MIB", "snmpTargetAddrTMask"), ("SNMP-COMMUNITY-MIB", "snmpTargetAddrMMS")) +if mibBuilder.loadTexts: snmpCommunityTableGroup.setDescription('A collection of objects providing for configuration of community strings for SNMPv1 (and SNMPv2c) usage.') +snmpProxyTrapForwardGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 18, 2, 2, 3)).setObjects(("SNMP-COMMUNITY-MIB", "snmpTrapAddress"), ("SNMP-COMMUNITY-MIB", "snmpTrapCommunity")) +if mibBuilder.loadTexts: snmpProxyTrapForwardGroup.setDescription('Objects which are used by proxy forwarding applications when translating traps between SNMP versions. These are used to preserve SNMPv1-specific information when translating to SNMPv2c or SNMPv3.') +mibBuilder.exportSymbols("SNMP-COMMUNITY-MIB", PYSNMP_MODULE_ID=snmpCommunityMIB, snmpCommunityMIBFullCompliance=snmpCommunityMIBFullCompliance, snmpTargetAddrTMask=snmpTargetAddrTMask, snmpTargetAddrExtEntry=snmpTargetAddrExtEntry, snmpCommunityContextName=snmpCommunityContextName, snmpCommunityMIBConformance=snmpCommunityMIBConformance, snmpCommunityTableGroup=snmpCommunityTableGroup, snmpCommunityIndex=snmpCommunityIndex, snmpTrapCommunity=snmpTrapCommunity, snmpCommunityContextEngineID=snmpCommunityContextEngineID, snmpTrapAddress=snmpTrapAddress, snmpCommunityMIBObjects=snmpCommunityMIBObjects, snmpCommunityMIBCompliances=snmpCommunityMIBCompliances, snmpCommunityStorageType=snmpCommunityStorageType, snmpCommunitySecurityName=snmpCommunitySecurityName, snmpCommunityTable=snmpCommunityTable, snmpCommunityMIBGroups=snmpCommunityMIBGroups, snmpCommunityEntry=snmpCommunityEntry, snmpTargetAddrExtTable=snmpTargetAddrExtTable, snmpCommunityName=snmpCommunityName, snmpCommunityMIBCompliance=snmpCommunityMIBCompliance, snmpCommunityMIB=snmpCommunityMIB, snmpCommunityStatus=snmpCommunityStatus, snmpProxyTrapForwardCompliance=snmpProxyTrapForwardCompliance, snmpProxyTrapForwardGroup=snmpProxyTrapForwardGroup, snmpTargetAddrMMS=snmpTargetAddrMMS, snmpCommunityTransportTag=snmpCommunityTransportTag) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,99 +1,120 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMP-FRAMEWORK-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/SNMP-FRAMEWORK-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 19:37:28 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) -# -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( NotificationGroup, ModuleCompliance, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, snmpModules, iso, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "snmpModules", "iso", "ObjectIdentity", "Bits", "Counter32") -( DisplayString, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") - +# PySNMP MIB module SNMP-FRAMEWORK-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-FRAMEWORK-MIB +# Produced by pysmi-0.1.3 at Mon Apr 17 13:59:41 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) +# +import time try: import os except ImportError: pass -import time -snmpFrameworkMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 10)).setRevisions(("2002-10-14 00:00", "1999-01-19 00:00", "1997-11-20 00:00",)) +OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ValueSizeConstraint, SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion", "ConstraintsIntersection") +ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance") +Gauge32, Unsigned32, MibIdentifier, ObjectIdentity, iso, Counter64, IpAddress, Counter32, ModuleIdentity, Bits, snmpModules, Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "Gauge32", "Unsigned32", "MibIdentifier", "ObjectIdentity", "iso", "Counter64", "IpAddress", "Counter32", "ModuleIdentity", "Bits", "snmpModules", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "NotificationType") +DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") +snmpFrameworkMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 10)) +if mibBuilder.loadTexts: snmpFrameworkMIB.setRevisions(('2002-10-14 00:00', '1999-01-19 00:00', '1997-11-20 00:00',)) if mibBuilder.loadTexts: snmpFrameworkMIB.setLastUpdated('200210140000Z') if mibBuilder.loadTexts: snmpFrameworkMIB.setOrganization('SNMPv3 Working Group') -if mibBuilder.loadTexts: snmpFrameworkMIB.setContactInfo('WG-EMail: snmpv3@lists.tislabs.com\n Subscribe: snmpv3-request@lists.tislabs.com\n\n Co-Chair: Russ Mundy\n Network Associates Laboratories\n postal: 15204 Omega Drive, Suite 300\n Rockville, MD 20850-4601\n USA\n EMail: mundy@tislabs.com\n phone: +1 301-947-7107\n\n Co-Chair &\n Co-editor: David Harrington\n Enterasys Networks\n postal: 35 Industrial Way\n P. O. Box 5005\n Rochester, New Hampshire 03866-5005\n USA\n EMail: dbh@enterasys.com\n phone: +1 603-337-2614\n\n Co-editor: Randy Presuhn\n BMC Software, Inc.\n postal: 2141 North First Street\n San Jose, California 95131\n USA\n EMail: randy_presuhn@bmc.com\n phone: +1 408-546-1006\n\n Co-editor: Bert Wijnen\n Lucent Technologies\n postal: Schagen 33\n 3461 GL Linschoten\n Netherlands\n\n EMail: bwijnen@lucent.com\n phone: +31 348-680-485\n ') -if mibBuilder.loadTexts: snmpFrameworkMIB.setDescription('The SNMP Management Architecture MIB\n\n Copyright (C) The Internet Society (2002). This\n version of this MIB module is part of RFC 3411;\n see the RFC itself for full legal notices.\n ') +if mibBuilder.loadTexts: snmpFrameworkMIB.setContactInfo('WG-EMail: snmpv3@lists.tislabs.com Subscribe: snmpv3-request@lists.tislabs.com Co-Chair: Russ Mundy Network Associates Laboratories postal: 15204 Omega Drive, Suite 300 Rockville, MD 20850-4601 USA EMail: mundy@tislabs.com phone: +1 301-947-7107 Co-Chair & Co-editor: David Harrington Enterasys Networks postal: 35 Industrial Way P. O. Box 5005 Rochester, New Hampshire 03866-5005 USA EMail: dbh@enterasys.com phone: +1 603-337-2614 Co-editor: Randy Presuhn BMC Software, Inc. postal: 2141 North First Street San Jose, California 95131 USA EMail: randy_presuhn@bmc.com phone: +1 408-546-1006 Co-editor: Bert Wijnen Lucent Technologies postal: Schagen 33 3461 GL Linschoten Netherlands EMail: bwijnen@lucent.com phone: +31 348-680-485 ') +if mibBuilder.loadTexts: snmpFrameworkMIB.setDescription('The SNMP Management Architecture MIB Copyright (C) The Internet Society (2002). This version of this MIB module is part of RFC 3411; see the RFC itself for full legal notices. ') # # WARNING: some of the classes below are manually implemented # class SnmpAdminString(TextualConvention, OctetString): + description = 'An octet string containing administrative information, preferably in human-readable form. To facilitate internationalization, this information is represented using the ISO/IEC IS 10646-1 character set, encoded as an octet string using the UTF-8 transformation format described in [RFC2279]. Since additional code points are added by amendments to the 10646 standard from time to time, implementations must be prepared to encounter any code point from 0x00000000 to 0x7fffffff. Byte sequences that do not correspond to the valid UTF-8 encoding of a code point or are outside this range are prohibited. The use of control codes should be avoided. When it is necessary to represent a newline, the control code sequence CR LF should be used. The use of leading or trailing white space should be avoided. For code points not directly supported by user interface hardware or software, an alternative means of entry and display, such as hexadecimal, may be provided. For information encoded in 7-bit US-ASCII, the UTF-8 encoding is identical to the US-ASCII encoding. UTF-8 may require multiple bytes to represent a single character / code point; thus the length of this object in octets may be different from the number of characters encoded. Similarly, size constraints refer to the number of encoded octets, not the number of characters represented by an encoding. Note that when this TC is used for an object that is used or envisioned to be used as an index, then a SIZE restriction MUST be specified so that the number of sub-identifiers for any object instance does not exceed the limit of 128, as defined by [RFC3416]. Note that the size of an SnmpAdminString object is measured in octets, not characters. ' + status = 'current' displayHint = "255t" - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(0,255) + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(0, 255) encoding = 'utf-8' - + + class SnmpEngineID(TextualConvention, OctetString): - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(5,32) + description = "An SNMP engine's administratively-unique identifier. Objects of this type are for identification, not for addressing, even though it is possible that an address may have been used in the generation of a specific value. The value for this object may not be all zeros or all 'ff'H or the empty (zero length) string. The initial value for this object may be configured via an operator console entry or via an algorithmic function. In the latter case, the following example algorithm is recommended. In cases where there are multiple engines on the same system, the use of this algorithm is NOT appropriate, as it would result in all of those engines ending up with the same ID value. 1) The very first bit is used to indicate how the rest of the data is composed. 0 - as defined by enterprise using former methods that existed before SNMPv3. See item 2 below. 1 - as defined by this architecture, see item 3 below. Note that this allows existing uses of the engineID (also known as AgentID [RFC1910]) to co-exist with any new uses. 2) The snmpEngineID has a length of 12 octets. The first four octets are set to the binary equivalent of the agent's SNMP management private enterprise number as assigned by the Internet Assigned Numbers Authority (IANA). For example, if Acme Networks has been assigned { enterprises 696 }, the first four octets would be assigned '000002b8'H. The remaining eight octets are determined via one or more enterprise-specific methods. Such methods must be designed so as to maximize the possibility that the value of this object will be unique in the agent's administrative domain. For example, it may be the IP address of the SNMP entity, or the MAC address of one of the interfaces, with each address suitably padded with random octets. If multiple methods are defined, then it is recommended that the first octet indicate the method being used and the remaining octets be a function of the method. 3) The length of the octet string varies. The first four octets are set to the binary equivalent of the agent's SNMP management private enterprise number as assigned by the Internet Assigned Numbers Authority (IANA). For example, if Acme Networks has been assigned { enterprises 696 }, the first four octets would be assigned '000002b8'H. The very first bit is set to 1. For example, the above value for Acme Networks now changes to be '800002b8'H. The fifth octet indicates how the rest (6th and following octets) are formatted. The values for the fifth octet are: 0 - reserved, unused. 1 - IPv4 address (4 octets) lowest non-special IP address 2 - IPv6 address (16 octets) lowest non-special IP address 3 - MAC address (6 octets) lowest IEEE MAC address, canonical order 4 - Text, administratively assigned Maximum remaining length 27 5 - Octets, administratively assigned Maximum remaining length 27 6-127 - reserved, unused 128-255 - as defined by the enterprise Maximum remaining length 27 " + status = 'current' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(5, 32) defaultValue = [128, 0, 79, 184, 5] try: # Attempt to base engine ID on local system name and properties - defaultValue += [ ord(x) for x in os.uname()[1][:16] ] - except: + defaultValue += [ord(x) for x in os.uname()[1][:16]] + except Exception: pass try: # Attempt to base engine ID on PID - defaultValue += [ os.getpid() >> 8 & 0xff, os.getpid() & 0xff ] - except: + defaultValue += [os.getpid() >> 8 & 0xff, os.getpid() & 0xff] + except Exception: pass # add pseudo-random text ID - defaultValue += [ id(defaultValue) >> 8 & 0xff, id(defaultValue) & 0xff ] + defaultValue += [id(defaultValue) >> 8 & 0xff, id(defaultValue) & 0xff] defaultValue = OctetString(defaultValue).asOctets() + class SnmpEngineTime(Integer32): - def clone(self, value=None, tagSet=None, subtypeSpec=None): - if value is None: + def clone(self, *args, **kwargs): + if not args: try: - value = time.time() - self - except: + args = (time.time() - self,) + except Exception: pass - return Integer32.clone(self, value, tagSet, subtypeSpec) + return Integer32.clone(self, *args, **kwargs) + class SnmpSecurityModel(Integer32, TextualConvention): - subtypeSpec = Integer32.subtypeSpec+ValueRangeConstraint(0,2147483647) + description = "An identifier that uniquely identifies a Security Model of the Security Subsystem within this SNMP Management Architecture. The values for securityModel are allocated as follows: - The zero value does not identify any particular security model. - Values between 1 and 255, inclusive, are reserved for standards-track Security Models and are managed by the Internet Assigned Numbers Authority (IANA). - Values greater than 255 are allocated to enterprise-specific Security Models. An enterprise-specific securityModel value is defined to be: enterpriseID * 256 + security model within enterprise For example, the fourth Security Model defined by the enterprise whose enterpriseID is 1 would be 259. This scheme for allocation of securityModel values allows for a maximum of 255 standards- based Security Models, and for a maximum of 256 Security Models per enterprise. It is believed that the assignment of new securityModel values will be rare in practice because the larger the number of simultaneously utilized Security Models, the larger the chance that interoperability will suffer. Consequently, it is believed that such a range will be sufficient. In the unlikely event that the standards committee finds this number to be insufficient over time, an enterprise number can be allocated to obtain an additional 256 possible values. Note that the most significant bit must be zero; hence, there are 23 bits allocated for various organizations to design and define non-standard securityModels. This limits the ability to define new proprietary implementations of Security Models to the first 8,388,608 enterprises. It is worthwhile to note that, in its encoded form, the securityModel value will normally require only a single byte since, in practice, the leftmost bits will be zero for most messages and sign extension is suppressed by the encoding rules. As of this writing, there are several values of securityModel defined for use with SNMP or reserved for use with supporting MIB objects. They are as follows: 0 reserved for 'any' 1 reserved for SNMPv1 2 reserved for SNMPv2c 3 User-Based Security Model (USM) " + status = 'current' + subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 2147483647) + class SnmpMessageProcessingModel(Integer32, TextualConvention): - subtypeSpec = Integer32.subtypeSpec+ValueRangeConstraint(0,2147483647) + description = 'An identifier that uniquely identifies a Message Processing Model of the Message Processing Subsystem within this SNMP Management Architecture. The values for messageProcessingModel are allocated as follows: - Values between 0 and 255, inclusive, are reserved for standards-track Message Processing Models and are managed by the Internet Assigned Numbers Authority (IANA). - Values greater than 255 are allocated to enterprise-specific Message Processing Models. An enterprise messageProcessingModel value is defined to be: enterpriseID * 256 + messageProcessingModel within enterprise For example, the fourth Message Processing Model defined by the enterprise whose enterpriseID is 1 would be 259. This scheme for allocating messageProcessingModel values allows for a maximum of 255 standards- based Message Processing Models, and for a maximum of 256 Message Processing Models per enterprise. It is believed that the assignment of new messageProcessingModel values will be rare in practice because the larger the number of simultaneously utilized Message Processing Models, the larger the chance that interoperability will suffer. It is believed that such a range will be sufficient. In the unlikely event that the standards committee finds this number to be insufficient over time, an enterprise number can be allocated to obtain an additional 256 possible values. Note that the most significant bit must be zero; hence, there are 23 bits allocated for various organizations to design and define non-standard messageProcessingModels. This limits the ability to define new proprietary implementations of Message Processing Models to the first 8,388,608 enterprises. It is worthwhile to note that, in its encoded form, the messageProcessingModel value will normally require only a single byte since, in practice, the leftmost bits will be zero for most messages and sign extension is suppressed by the encoding rules. As of this writing, there are several values of messageProcessingModel defined for use with SNMP. They are as follows: 0 reserved for SNMPv1 1 reserved for SNMPv2c 2 reserved for SNMPv2u and SNMPv2* 3 reserved for SNMPv3 ' + status = 'current' + subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 2147483647) + class SnmpSecurityLevel(Integer32, TextualConvention): - subtypeSpec = Integer32.subtypeSpec+SingleValueConstraint(1, 2, 3,) - namedValues = NamedValues(("noAuthNoPriv", 1), ("authNoPriv", 2), ("authPriv", 3),) + description = 'A Level of Security at which SNMP messages can be sent or with which operations are being processed; in particular, one of: noAuthNoPriv - without authentication and without privacy, authNoPriv - with authentication but without privacy, authPriv - with authentication and with privacy. These three values are ordered such that noAuthNoPriv is less than authNoPriv and authNoPriv is less than authPriv. ' + status = 'current' + subtypeSpec = Integer32.subtypeSpec + SingleValueConstraint(1, 2, 3, ) + namedValues = NamedValues(("noAuthNoPriv", 1), ("authNoPriv", 2), ("authPriv", 3), ) snmpFrameworkAdmin = MibIdentifier((1, 3, 6, 1, 6, 3, 10, 1)) snmpFrameworkMIBObjects = MibIdentifier((1, 3, 6, 1, 6, 3, 10, 2)) snmpFrameworkMIBConformance = MibIdentifier((1, 3, 6, 1, 6, 3, 10, 3)) snmpEngine = MibIdentifier((1, 3, 6, 1, 6, 3, 10, 2, 1)) snmpEngineID = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 1), SnmpEngineID()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpEngineID.setDescription("An SNMP engine's administratively-unique identifier.\n\n This information SHOULD be stored in non-volatile\n storage so that it remains constant across\n re-initializations of the SNMP engine.\n ") -snmpEngineBoots = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1,2147483647))).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpEngineBoots.setDescription('The number of times that the SNMP engine has\n (re-)initialized itself since snmpEngineID\n was last configured.\n ') -snmpEngineTime = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 3), SnmpEngineTime().subtype(subtypeSpec=ValueRangeConstraint(0,2147483647))).setUnits('seconds').setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpEngineTime.setDescription("The number of seconds since the value of\n the snmpEngineBoots object last changed.\n When incrementing this object's value would\n cause it to exceed its maximum,\n snmpEngineBoots is incremented as if a\n re-initialization had occurred, and this\n object's value consequently reverts to zero.\n ") -snmpEngineMaxMessageSize = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(484,2147483647))).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpEngineMaxMessageSize.setDescription('The maximum length in octets of an SNMP message\n which this SNMP engine can send or receive and\n process, determined as the minimum of the maximum\n message size values supported among all of the\n transports available to and supported by the engine.\n ') +if mibBuilder.loadTexts: snmpEngineID.setStatus('current') +if mibBuilder.loadTexts: snmpEngineID.setDescription("An SNMP engine's administratively-unique identifier. This information SHOULD be stored in non-volatile storage so that it remains constant across re-initializations of the SNMP engine. ") +snmpEngineBoots = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readonly") +if mibBuilder.loadTexts: snmpEngineBoots.setStatus('current') +if mibBuilder.loadTexts: snmpEngineBoots.setDescription('The number of times that the SNMP engine has (re-)initialized itself since snmpEngineID was last configured. ') +snmpEngineTime = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 3), SnmpEngineTime().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setUnits('seconds').setMaxAccess("readonly") +if mibBuilder.loadTexts: snmpEngineTime.setStatus('current') +if mibBuilder.loadTexts: snmpEngineTime.setDescription("The number of seconds since the value of the snmpEngineBoots object last changed. When incrementing this object's value would cause it to exceed its maximum, snmpEngineBoots is incremented as if a re-initialization had occurred, and this object's value consequently reverts to zero. ") +snmpEngineMaxMessageSize = MibScalar((1, 3, 6, 1, 6, 3, 10, 2, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(484, 2147483647))).setMaxAccess("readonly") +if mibBuilder.loadTexts: snmpEngineMaxMessageSize.setStatus('current') +if mibBuilder.loadTexts: snmpEngineMaxMessageSize.setDescription('The maximum length in octets of an SNMP message which this SNMP engine can send or receive and process, determined as the minimum of the maximum message size values supported among all of the transports available to and supported by the engine. ') snmpAuthProtocols = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 1)) -if mibBuilder.loadTexts: snmpAuthProtocols.setDescription('Registration point for standards-track\n authentication protocols used in SNMP Management\n Frameworks.\n ') +if mibBuilder.loadTexts: snmpAuthProtocols.setStatus('current') +if mibBuilder.loadTexts: snmpAuthProtocols.setDescription('Registration point for standards-track authentication protocols used in SNMP Management Frameworks. ') snmpPrivProtocols = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 2)) -if mibBuilder.loadTexts: snmpPrivProtocols.setDescription('Registration point for standards-track privacy\n protocols used in SNMP Management Frameworks.\n ') +if mibBuilder.loadTexts: snmpPrivProtocols.setStatus('current') +if mibBuilder.loadTexts: snmpPrivProtocols.setDescription('Registration point for standards-track privacy protocols used in SNMP Management Frameworks. ') snmpFrameworkMIBCompliances = MibIdentifier((1, 3, 6, 1, 6, 3, 10, 3, 1)) snmpFrameworkMIBGroups = MibIdentifier((1, 3, 6, 1, 6, 3, 10, 3, 2)) -snmpFrameworkMIBCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 10, 3, 1, 1)).setObjects(*(("SNMP-FRAMEWORK-MIB", "snmpEngineGroup"),)) -if mibBuilder.loadTexts: snmpFrameworkMIBCompliance.setDescription('The compliance statement for SNMP engines which\n implement the SNMP Management Framework MIB.\n ') -snmpEngineGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 10, 3, 2, 1)).setObjects(*(("SNMP-FRAMEWORK-MIB", "snmpEngineID"), ("SNMP-FRAMEWORK-MIB", "snmpEngineBoots"), ("SNMP-FRAMEWORK-MIB", "snmpEngineTime"), ("SNMP-FRAMEWORK-MIB", "snmpEngineMaxMessageSize"),)) -if mibBuilder.loadTexts: snmpEngineGroup.setDescription('A collection of objects for identifying and\n determining the configuration and current timeliness\n\n values of an SNMP engine.\n ') -mibBuilder.exportSymbols("SNMP-FRAMEWORK-MIB", snmpPrivProtocols=snmpPrivProtocols, snmpEngine=snmpEngine, snmpEngineMaxMessageSize=snmpEngineMaxMessageSize, snmpAuthProtocols=snmpAuthProtocols, PYSNMP_MODULE_ID=snmpFrameworkMIB, snmpFrameworkMIBConformance=snmpFrameworkMIBConformance, snmpEngineGroup=snmpEngineGroup, SnmpAdminString=SnmpAdminString, snmpEngineID=snmpEngineID, snmpFrameworkAdmin=snmpFrameworkAdmin, snmpFrameworkMIBObjects=snmpFrameworkMIBObjects, SnmpSecurityLevel=SnmpSecurityLevel, snmpFrameworkMIBCompliance=snmpFrameworkMIBCompliance, snmpFrameworkMIBGroups=snmpFrameworkMIBGroups, snmpFrameworkMIB=snmpFrameworkMIB, snmpFrameworkMIBCompliances=snmpFrameworkMIBCompliances, SnmpEngineID=SnmpEngineID, snmpEngineBoots=snmpEngineBoots, SnmpSecurityModel=SnmpSecurityModel, SnmpMessageProcessingModel=SnmpMessageProcessingModel, snmpEngineTime=snmpEngineTime) +snmpFrameworkMIBCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 10, 3, 1, 1)).setObjects(("SNMP-FRAMEWORK-MIB", "snmpEngineGroup")) +if mibBuilder.loadTexts: snmpFrameworkMIBCompliance.setDescription('The compliance statement for SNMP engines which implement the SNMP Management Framework MIB. ') +snmpEngineGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 10, 3, 2, 1)).setObjects(("SNMP-FRAMEWORK-MIB", "snmpEngineID"), ("SNMP-FRAMEWORK-MIB", "snmpEngineBoots"), ("SNMP-FRAMEWORK-MIB", "snmpEngineTime"), ("SNMP-FRAMEWORK-MIB", "snmpEngineMaxMessageSize")) +if mibBuilder.loadTexts: snmpEngineGroup.setDescription('A collection of objects for identifying and determining the configuration and current timeliness values of an SNMP engine. ') +mibBuilder.exportSymbols("SNMP-FRAMEWORK-MIB", snmpFrameworkMIBConformance=snmpFrameworkMIBConformance, snmpFrameworkMIB=snmpFrameworkMIB, snmpFrameworkMIBGroups=snmpFrameworkMIBGroups, SnmpEngineID=SnmpEngineID, SnmpSecurityLevel=SnmpSecurityLevel, snmpEngineMaxMessageSize=snmpEngineMaxMessageSize, snmpFrameworkAdmin=snmpFrameworkAdmin, PYSNMP_MODULE_ID=snmpFrameworkMIB, snmpFrameworkMIBObjects=snmpFrameworkMIBObjects, snmpFrameworkMIBCompliances=snmpFrameworkMIBCompliances, snmpAuthProtocols=snmpAuthProtocols, snmpFrameworkMIBCompliance=snmpFrameworkMIBCompliance, snmpEngineTime=snmpEngineTime, snmpPrivProtocols=snmpPrivProtocols, SnmpMessageProcessingModel=SnmpMessageProcessingModel, snmpEngine=snmpEngine, SnmpSecurityModel=SnmpSecurityModel, snmpEngineGroup=snmpEngineGroup, snmpEngineBoots=snmpEngineBoots, SnmpAdminString=SnmpAdminString, snmpEngineID=snmpEngineID) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-MPD-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-MPD-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-MPD-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-MPD-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,40 +1,45 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMP-MPD-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/SNMP-MPD-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 16:31:46 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( NotificationGroup, ModuleCompliance, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, snmpModules, iso, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "snmpModules", "iso", "ObjectIdentity", "Bits", "Counter32") -( DisplayString, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") -snmpMPDMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 11)).setRevisions(("2002-10-14 00:00", "1999-05-04 16:36", "1997-09-30 00:00",)) -if mibBuilder.loadTexts: snmpMPDMIB.setLastUpdated('200210140000Z') +# PySNMP MIB module SNMP-MPD-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-MPD-MIB +# Produced by pysmi-0.1.3 at Tue Apr 18 00:17:00 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) +# +OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +SingleValueConstraint, ConstraintsUnion, ValueSizeConstraint, ValueRangeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsUnion", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsIntersection") +NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") +iso, Counter32, Unsigned32, Gauge32, MibIdentifier, TimeTicks, NotificationType, ObjectIdentity, Bits, ModuleIdentity, MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32, Counter64, IpAddress, snmpModules = mibBuilder.importSymbols("SNMPv2-SMI", "iso", "Counter32", "Unsigned32", "Gauge32", "MibIdentifier", "TimeTicks", "NotificationType", "ObjectIdentity", "Bits", "ModuleIdentity", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32", "Counter64", "IpAddress", "snmpModules") +DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") +snmpMPDMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 11)) +if mibBuilder.loadTexts: snmpMPDMIB.setRevisions(('1999-05-04 16:36', '1997-09-30 00:00',)) +if mibBuilder.loadTexts: snmpMPDMIB.setLastUpdated('9905041636Z') if mibBuilder.loadTexts: snmpMPDMIB.setOrganization('SNMPv3 Working Group') -if mibBuilder.loadTexts: snmpMPDMIB.setContactInfo('WG-EMail: snmpv3@lists.tislabs.com\n Subscribe: snmpv3-request@lists.tislabs.com\n\n Co-Chair: Russ Mundy\n Network Associates Laboratories\n postal: 15204 Omega Drive, Suite 300\n Rockville, MD 20850-4601\n USA\n\n EMail: mundy@tislabs.com\n phone: +1 301-947-7107\n\n Co-Chair &\n Co-editor: David Harrington\n Enterasys Networks\n postal: 35 Industrial Way\n P. O. Box 5005\n Rochester NH 03866-5005\n USA\n EMail: dbh@enterasys.com\n phone: +1 603-337-2614\n\n Co-editor: Jeffrey Case\n SNMP Research, Inc.\n postal: 3001 Kimberlin Heights Road\n Knoxville, TN 37920-9716\n USA\n EMail: case@snmp.com\n phone: +1 423-573-1434\n\n Co-editor: Randy Presuhn\n BMC Software, Inc.\n postal: 2141 North First Street\n San Jose, CA 95131\n USA\n EMail: randy_presuhn@bmc.com\n phone: +1 408-546-1006\n\n Co-editor: Bert Wijnen\n Lucent Technologies\n postal: Schagen 33\n 3461 GL Linschoten\n Netherlands\n EMail: bwijnen@lucent.com\n phone: +31 348-680-485\n ') -if mibBuilder.loadTexts: snmpMPDMIB.setDescription('The MIB for Message Processing and Dispatching\n\n Copyright (C) The Internet Society (2002). This\n version of this MIB module is part of RFC 3412;\n see the RFC itself for full legal notices.\n ') +if mibBuilder.loadTexts: snmpMPDMIB.setContactInfo('WG-EMail: snmpv3@lists.tislabs.com Subscribe: majordomo@lists.tislabs.com In message body: subscribe snmpv3 Chair: Russ Mundy TIS Labs at Network Associates postal: 3060 Washington Road Glenwood, MD 21738 USA EMail: mundy@tislabs.com phone: +1 301-854-6889 Co-editor: Jeffrey Case SNMP Research, Inc. postal: 3001 Kimberlin Heights Road Knoxville, TN 37920-9716 USA EMail: case@snmp.com phone: +1 423-573-1434 Co-editor Dave Harrington Cabletron Systems, Inc. postal: Post Office Box 5005 MailStop: Durham 35 Industrial Way Rochester, NH 03867-5005 USA EMail: dbh@ctron.com phone: +1 603-337-7357 Co-editor: Randy Presuhn BMC Software, Inc. postal: 965 Stewart Drive Sunnyvale, CA 94086 USA EMail: randy_presuhn@bmc.com phone: +1 408-616-3100 Co-editor: Bert Wijnen IBM T. J. Watson Research postal: Schagen 33 3461 GL Linschoten Netherlands EMail: wijnen@vnet.ibm.com phone: +31 348-432-794 ') +if mibBuilder.loadTexts: snmpMPDMIB.setDescription('The MIB for Message Processing and Dispatching') snmpMPDAdmin = MibIdentifier((1, 3, 6, 1, 6, 3, 11, 1)) snmpMPDMIBObjects = MibIdentifier((1, 3, 6, 1, 6, 3, 11, 2)) snmpMPDMIBConformance = MibIdentifier((1, 3, 6, 1, 6, 3, 11, 3)) snmpMPDStats = MibIdentifier((1, 3, 6, 1, 6, 3, 11, 2, 1)) snmpUnknownSecurityModels = MibScalar((1, 3, 6, 1, 6, 3, 11, 2, 1, 1), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpUnknownSecurityModels.setDescription('The total number of packets received by the SNMP\n engine which were dropped because they referenced a\n securityModel that was not known to or supported by\n the SNMP engine.\n ') +if mibBuilder.loadTexts: snmpUnknownSecurityModels.setStatus('current') +if mibBuilder.loadTexts: snmpUnknownSecurityModels.setDescription('The total number of packets received by the SNMP engine which were dropped because they referenced a securityModel that was not known to or supported by the SNMP engine. ') snmpInvalidMsgs = MibScalar((1, 3, 6, 1, 6, 3, 11, 2, 1, 2), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInvalidMsgs.setDescription('The total number of packets received by the SNMP\n engine which were dropped because there were invalid\n or inconsistent components in the SNMP message.\n ') +if mibBuilder.loadTexts: snmpInvalidMsgs.setStatus('current') +if mibBuilder.loadTexts: snmpInvalidMsgs.setDescription('The total number of packets received by the SNMP engine which were dropped because there were invalid or inconsistent components in the SNMP message. ') snmpUnknownPDUHandlers = MibScalar((1, 3, 6, 1, 6, 3, 11, 2, 1, 3), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpUnknownPDUHandlers.setDescription('The total number of packets received by the SNMP\n engine which were dropped because the PDU contained\n in the packet could not be passed to an application\n responsible for handling the pduType, e.g. no SNMP\n application had registered for the proper\n combination of the contextEngineID and the pduType.\n ') +if mibBuilder.loadTexts: snmpUnknownPDUHandlers.setStatus('current') +if mibBuilder.loadTexts: snmpUnknownPDUHandlers.setDescription('The total number of packets received by the SNMP engine which were dropped because the PDU contained in the packet could not be passed to an application responsible for handling the pduType, e.g. no SNMP application had registered for the proper combination of the contextEngineID and the pduType. ') snmpMPDMIBCompliances = MibIdentifier((1, 3, 6, 1, 6, 3, 11, 3, 1)) snmpMPDMIBGroups = MibIdentifier((1, 3, 6, 1, 6, 3, 11, 3, 2)) -snmpMPDCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 11, 3, 1, 1)).setObjects(*(("SNMP-MPD-MIB", "snmpMPDGroup"),)) -if mibBuilder.loadTexts: snmpMPDCompliance.setDescription('The compliance statement for SNMP entities which\n implement the SNMP-MPD-MIB.\n ') -snmpMPDGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 11, 3, 2, 1)).setObjects(*(("SNMP-MPD-MIB", "snmpUnknownSecurityModels"), ("SNMP-MPD-MIB", "snmpInvalidMsgs"), ("SNMP-MPD-MIB", "snmpUnknownPDUHandlers"),)) -if mibBuilder.loadTexts: snmpMPDGroup.setDescription('A collection of objects providing for remote\n monitoring of the SNMP Message Processing and\n Dispatching process.\n ') -mibBuilder.exportSymbols("SNMP-MPD-MIB", snmpMPDMIBObjects=snmpMPDMIBObjects, snmpMPDMIBCompliances=snmpMPDMIBCompliances, snmpMPDCompliance=snmpMPDCompliance, snmpMPDMIBGroups=snmpMPDMIBGroups, snmpMPDMIB=snmpMPDMIB, snmpMPDAdmin=snmpMPDAdmin, snmpInvalidMsgs=snmpInvalidMsgs, PYSNMP_MODULE_ID=snmpMPDMIB, snmpMPDStats=snmpMPDStats, snmpMPDMIBConformance=snmpMPDMIBConformance, snmpUnknownSecurityModels=snmpUnknownSecurityModels, snmpMPDGroup=snmpMPDGroup, snmpUnknownPDUHandlers=snmpUnknownPDUHandlers) +snmpMPDCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 11, 3, 1, 1)).setObjects(("SNMP-MPD-MIB", "snmpMPDGroup")) +if mibBuilder.loadTexts: snmpMPDCompliance.setDescription('The compliance statement for SNMP entities which implement the SNMP-MPD-MIB. ') +snmpMPDGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 11, 3, 2, 1)).setObjects(("SNMP-MPD-MIB", "snmpUnknownSecurityModels"), ("SNMP-MPD-MIB", "snmpInvalidMsgs"), ("SNMP-MPD-MIB", "snmpUnknownPDUHandlers")) +if mibBuilder.loadTexts: snmpMPDGroup.setDescription('A collection of objects providing for remote monitoring of the SNMP Message Processing and Dispatching process. ') +mibBuilder.exportSymbols("SNMP-MPD-MIB", snmpMPDMIBGroups=snmpMPDMIBGroups, PYSNMP_MODULE_ID=snmpMPDMIB, snmpMPDMIBConformance=snmpMPDMIBConformance, snmpMPDMIBCompliances=snmpMPDMIBCompliances, snmpUnknownPDUHandlers=snmpUnknownPDUHandlers, snmpMPDGroup=snmpMPDGroup, snmpMPDMIB=snmpMPDMIB, snmpInvalidMsgs=snmpInvalidMsgs, snmpMPDCompliance=snmpMPDCompliance, snmpMPDMIBObjects=snmpMPDMIBObjects, snmpMPDAdmin=snmpMPDAdmin, snmpMPDStats=snmpMPDStats, snmpUnknownSecurityModels=snmpUnknownSecurityModels) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-NOTIFICATION-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-NOTIFICATION-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-NOTIFICATION-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-NOTIFICATION-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,78 +1,98 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMP-NOTIFICATION-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/SNMP-NOTIFICATION-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 23:00:18 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module SNMP-NOTIFICATION-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-NOTIFICATION-MIB +# Produced by pysmi-0.1.3 at Tue Apr 18 00:41:37 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( SnmpAdminString, ) = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") -( snmpTargetParamsName, SnmpTagValue, ) = mibBuilder.importSymbols("SNMP-TARGET-MIB", "snmpTargetParamsName", "SnmpTagValue") -( NotificationGroup, ModuleCompliance, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, snmpModules, iso, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "snmpModules", "iso", "ObjectIdentity", "Bits", "Counter32") -( StorageType, DisplayString, RowStatus, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "StorageType", "DisplayString", "RowStatus", "TextualConvention") -snmpNotificationMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 13)).setRevisions(("2002-10-14 00:00", "1998-08-04 00:00", "1997-07-14 00:00",)) +OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ValueRangeConstraint, ConstraintsIntersection, SingleValueConstraint, ValueSizeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsUnion") +SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") +snmpTargetParamsName, SnmpTagValue = mibBuilder.importSymbols("SNMP-TARGET-MIB", "snmpTargetParamsName", "SnmpTagValue") +NotificationGroup, ObjectGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ObjectGroup", "ModuleCompliance") +TimeTicks, IpAddress, Integer32, snmpModules, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits, Counter32, Gauge32, Unsigned32, MibIdentifier, iso, ModuleIdentity, ObjectIdentity, NotificationType, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "IpAddress", "Integer32", "snmpModules", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits", "Counter32", "Gauge32", "Unsigned32", "MibIdentifier", "iso", "ModuleIdentity", "ObjectIdentity", "NotificationType", "Counter64") +DisplayString, TextualConvention, RowStatus, StorageType = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention", "RowStatus", "StorageType") +snmpNotificationMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 13)) +if mibBuilder.loadTexts: snmpNotificationMIB.setRevisions(('2002-10-14 00:00', '1998-08-04 00:00', '1997-07-14 00:00',)) if mibBuilder.loadTexts: snmpNotificationMIB.setLastUpdated('200210140000Z') if mibBuilder.loadTexts: snmpNotificationMIB.setOrganization('IETF SNMPv3 Working Group') -if mibBuilder.loadTexts: snmpNotificationMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com\n Subscribe: majordomo@lists.tislabs.com\n In message body: subscribe snmpv3\n\n Co-Chair: Russ Mundy\n Network Associates Laboratories\n Postal: 15204 Omega Drive, Suite 300\n Rockville, MD 20850-4601\n USA\n EMail: mundy@tislabs.com\n Phone: +1 301-947-7107\n\n Co-Chair: David Harrington\n Enterasys Networks\n Postal: 35 Industrial Way\n P. O. Box 5004\n Rochester, New Hampshire 03866-5005\n USA\n EMail: dbh@enterasys.com\n Phone: +1 603-337-2614\n\n Co-editor: David B. Levi\n Nortel Networks\n Postal: 3505 Kesterwood Drive\n Knoxville, Tennessee 37918\n EMail: dlevi@nortelnetworks.com\n Phone: +1 865 686 0432\n\n Co-editor: Paul Meyer\n Secure Computing Corporation\n Postal: 2675 Long Lake Road\n Roseville, Minnesota 55113\n EMail: paul_meyer@securecomputing.com\n Phone: +1 651 628 1592\n\n Co-editor: Bob Stewart\n Retired') -if mibBuilder.loadTexts: snmpNotificationMIB.setDescription('This MIB module defines MIB objects which provide\n mechanisms to remotely configure the parameters\n used by an SNMP entity for the generation of\n notifications.\n\n Copyright (C) The Internet Society (2002). This\n version of this MIB module is part of RFC 3413;\n see the RFC itself for full legal notices.\n ') +if mibBuilder.loadTexts: snmpNotificationMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com Subscribe: majordomo@lists.tislabs.com In message body: subscribe snmpv3 Co-Chair: Russ Mundy Network Associates Laboratories Postal: 15204 Omega Drive, Suite 300 Rockville, MD 20850-4601 USA EMail: mundy@tislabs.com Phone: +1 301-947-7107 Co-Chair: David Harrington Enterasys Networks Postal: 35 Industrial Way P. O. Box 5004 Rochester, New Hampshire 03866-5005 USA EMail: dbh@enterasys.com Phone: +1 603-337-2614 Co-editor: David B. Levi Nortel Networks Postal: 3505 Kesterwood Drive Knoxville, Tennessee 37918 EMail: dlevi@nortelnetworks.com Phone: +1 865 686 0432 Co-editor: Paul Meyer Secure Computing Corporation Postal: 2675 Long Lake Road Roseville, Minnesota 55113 EMail: paul_meyer@securecomputing.com Phone: +1 651 628 1592 Co-editor: Bob Stewart Retired') +if mibBuilder.loadTexts: snmpNotificationMIB.setDescription('This MIB module defines MIB objects which provide mechanisms to remotely configure the parameters used by an SNMP entity for the generation of notifications. Copyright (C) The Internet Society (2002). This version of this MIB module is part of RFC 3413; see the RFC itself for full legal notices. ') snmpNotifyObjects = MibIdentifier((1, 3, 6, 1, 6, 3, 13, 1)) snmpNotifyConformance = MibIdentifier((1, 3, 6, 1, 6, 3, 13, 3)) snmpNotifyTable = MibTable((1, 3, 6, 1, 6, 3, 13, 1, 1), ) -if mibBuilder.loadTexts: snmpNotifyTable.setDescription('This table is used to select management targets which should\n receive notifications, as well as the type of notification\n which should be sent to each selected management target.') +if mibBuilder.loadTexts: snmpNotifyTable.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyTable.setDescription('This table is used to select management targets which should receive notifications, as well as the type of notification which should be sent to each selected management target.') snmpNotifyEntry = MibTableRow((1, 3, 6, 1, 6, 3, 13, 1, 1, 1), ).setIndexNames((1, "SNMP-NOTIFICATION-MIB", "snmpNotifyName")) -if mibBuilder.loadTexts: snmpNotifyEntry.setDescription('An entry in this table selects a set of management targets\n which should receive notifications, as well as the type of\n\n notification which should be sent to each selected\n management target.\n\n Entries in the snmpNotifyTable are created and\n deleted using the snmpNotifyRowStatus object.') -snmpNotifyName = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 1, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))) -if mibBuilder.loadTexts: snmpNotifyName.setDescription('The locally arbitrary, but unique identifier associated\n with this snmpNotifyEntry.') +if mibBuilder.loadTexts: snmpNotifyEntry.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyEntry.setDescription('An entry in this table selects a set of management targets which should receive notifications, as well as the type of notification which should be sent to each selected management target. Entries in the snmpNotifyTable are created and deleted using the snmpNotifyRowStatus object.') +snmpNotifyName = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 1, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) +if mibBuilder.loadTexts: snmpNotifyName.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyName.setDescription('The locally arbitrary, but unique identifier associated with this snmpNotifyEntry.') snmpNotifyTag = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 1, 1, 2), SnmpTagValue()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyTag.setDescription('This object contains a single tag value which is used\n to select entries in the snmpTargetAddrTable. Any entry\n in the snmpTargetAddrTable which contains a tag value\n which is equal to the value of an instance of this\n object is selected. If this object contains a value\n of zero length, no entries are selected.') -snmpNotifyType = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2,)).clone(namedValues=NamedValues(("trap", 1), ("inform", 2),)).clone('trap')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyType.setDescription('This object determines the type of notification to\n\n be generated for entries in the snmpTargetAddrTable\n selected by the corresponding instance of\n snmpNotifyTag. This value is only used when\n generating notifications, and is ignored when\n using the snmpTargetAddrTable for other purposes.\n\n If the value of this object is trap(1), then any\n messages generated for selected rows will contain\n Unconfirmed-Class PDUs.\n\n If the value of this object is inform(2), then any\n messages generated for selected rows will contain\n Confirmed-Class PDUs.\n\n Note that if an SNMP entity only supports\n generation of Unconfirmed-Class PDUs (and not\n Confirmed-Class PDUs), then this object may be\n read-only.') +if mibBuilder.loadTexts: snmpNotifyTag.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyTag.setDescription('This object contains a single tag value which is used to select entries in the snmpTargetAddrTable. Any entry in the snmpTargetAddrTable which contains a tag value which is equal to the value of an instance of this object is selected. If this object contains a value of zero length, no entries are selected.') +snmpNotifyType = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("trap", 1), ("inform", 2))).clone('trap')).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpNotifyType.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyType.setDescription('This object determines the type of notification to be generated for entries in the snmpTargetAddrTable selected by the corresponding instance of snmpNotifyTag. This value is only used when generating notifications, and is ignored when using the snmpTargetAddrTable for other purposes. If the value of this object is trap(1), then any messages generated for selected rows will contain Unconfirmed-Class PDUs. If the value of this object is inform(2), then any messages generated for selected rows will contain Confirmed-Class PDUs. Note that if an SNMP entity only supports generation of Unconfirmed-Class PDUs (and not Confirmed-Class PDUs), then this object may be read-only.') snmpNotifyStorageType = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 1, 1, 4), StorageType().clone('nonVolatile')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyStorageType.setDescription("The storage type for this conceptual row.\n Conceptual rows having the value 'permanent' need not\n allow write-access to any columnar objects in the row.") +if mibBuilder.loadTexts: snmpNotifyStorageType.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyStorageType.setDescription("The storage type for this conceptual row. Conceptual rows having the value 'permanent' need not allow write-access to any columnar objects in the row.") snmpNotifyRowStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 1, 1, 5), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyRowStatus.setDescription('The status of this conceptual row.\n\n To create a row in this table, a manager must\n set this object to either createAndGo(4) or\n createAndWait(5).') +if mibBuilder.loadTexts: snmpNotifyRowStatus.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyRowStatus.setDescription('The status of this conceptual row. To create a row in this table, a manager must set this object to either createAndGo(4) or createAndWait(5).') snmpNotifyFilterProfileTable = MibTable((1, 3, 6, 1, 6, 3, 13, 1, 2), ) -if mibBuilder.loadTexts: snmpNotifyFilterProfileTable.setDescription('This table is used to associate a notification filter\n profile with a particular set of target parameters.') +if mibBuilder.loadTexts: snmpNotifyFilterProfileTable.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterProfileTable.setDescription('This table is used to associate a notification filter profile with a particular set of target parameters.') snmpNotifyFilterProfileEntry = MibTableRow((1, 3, 6, 1, 6, 3, 13, 1, 2, 1), ).setIndexNames((1, "SNMP-TARGET-MIB", "snmpTargetParamsName")) -if mibBuilder.loadTexts: snmpNotifyFilterProfileEntry.setDescription('An entry in this table indicates the name of the filter\n profile to be used when generating notifications using\n the corresponding entry in the snmpTargetParamsTable.\n\n Entries in the snmpNotifyFilterProfileTable are created\n and deleted using the snmpNotifyFilterProfileRowStatus\n object.') -snmpNotifyFilterProfileName = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 2, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyFilterProfileName.setDescription('The name of the filter profile to be used when generating\n notifications using the corresponding entry in the\n snmpTargetAddrTable.') +if mibBuilder.loadTexts: snmpNotifyFilterProfileEntry.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterProfileEntry.setDescription('An entry in this table indicates the name of the filter profile to be used when generating notifications using the corresponding entry in the snmpTargetParamsTable. Entries in the snmpNotifyFilterProfileTable are created and deleted using the snmpNotifyFilterProfileRowStatus object.') +snmpNotifyFilterProfileName = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 2, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpNotifyFilterProfileName.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterProfileName.setDescription('The name of the filter profile to be used when generating notifications using the corresponding entry in the snmpTargetAddrTable.') snmpNotifyFilterProfileStorType = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 2, 1, 2), StorageType().clone('nonVolatile')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyFilterProfileStorType.setDescription("The storage type for this conceptual row.\n Conceptual rows having the value 'permanent' need not\n allow write-access to any columnar objects in the row.") +if mibBuilder.loadTexts: snmpNotifyFilterProfileStorType.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterProfileStorType.setDescription("The storage type for this conceptual row. Conceptual rows having the value 'permanent' need not allow write-access to any columnar objects in the row.") snmpNotifyFilterProfileRowStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 2, 1, 3), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyFilterProfileRowStatus.setDescription("The status of this conceptual row.\n\n To create a row in this table, a manager must\n set this object to either createAndGo(4) or\n createAndWait(5).\n\n Until instances of all corresponding columns are\n appropriately configured, the value of the\n corresponding instance of the\n snmpNotifyFilterProfileRowStatus column is 'notReady'.\n\n In particular, a newly created row cannot be made\n active until the corresponding instance of\n snmpNotifyFilterProfileName has been set.") +if mibBuilder.loadTexts: snmpNotifyFilterProfileRowStatus.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterProfileRowStatus.setDescription("The status of this conceptual row. To create a row in this table, a manager must set this object to either createAndGo(4) or createAndWait(5). Until instances of all corresponding columns are appropriately configured, the value of the corresponding instance of the snmpNotifyFilterProfileRowStatus column is 'notReady'. In particular, a newly created row cannot be made active until the corresponding instance of snmpNotifyFilterProfileName has been set.") snmpNotifyFilterTable = MibTable((1, 3, 6, 1, 6, 3, 13, 1, 3), ) -if mibBuilder.loadTexts: snmpNotifyFilterTable.setDescription('The table of filter profiles. Filter profiles are used\n to determine whether particular management targets should\n receive particular notifications.\n\n When a notification is generated, it must be compared\n with the filters associated with each management target\n which is configured to receive notifications, in order to\n determine whether it may be sent to each such management\n target.\n\n A more complete discussion of notification filtering\n can be found in section 6. of [SNMP-APPL].') +if mibBuilder.loadTexts: snmpNotifyFilterTable.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterTable.setDescription('The table of filter profiles. Filter profiles are used to determine whether particular management targets should receive particular notifications. When a notification is generated, it must be compared with the filters associated with each management target which is configured to receive notifications, in order to determine whether it may be sent to each such management target. A more complete discussion of notification filtering can be found in section 6. of [SNMP-APPL].') snmpNotifyFilterEntry = MibTableRow((1, 3, 6, 1, 6, 3, 13, 1, 3, 1), ).setIndexNames((0, "SNMP-NOTIFICATION-MIB", "snmpNotifyFilterProfileName"), (1, "SNMP-NOTIFICATION-MIB", "snmpNotifyFilterSubtree")) -if mibBuilder.loadTexts: snmpNotifyFilterEntry.setDescription('An element of a filter profile.\n\n Entries in the snmpNotifyFilterTable are created and\n deleted using the snmpNotifyFilterRowStatus object.') +if mibBuilder.loadTexts: snmpNotifyFilterEntry.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterEntry.setDescription('An element of a filter profile. Entries in the snmpNotifyFilterTable are created and deleted using the snmpNotifyFilterRowStatus object.') snmpNotifyFilterSubtree = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 3, 1, 1), ObjectIdentifier()) -if mibBuilder.loadTexts: snmpNotifyFilterSubtree.setDescription('The MIB subtree which, when combined with the corresponding\n instance of snmpNotifyFilterMask, defines a family of\n subtrees which are included in or excluded from the\n filter profile.') -snmpNotifyFilterMask = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 3, 1, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0,16)).clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyFilterMask.setDescription("The bit mask which, in combination with the corresponding\n instance of snmpNotifyFilterSubtree, defines a family of\n subtrees which are included in or excluded from the\n filter profile.\n\n Each bit of this bit mask corresponds to a\n sub-identifier of snmpNotifyFilterSubtree, with the\n most significant bit of the i-th octet of this octet\n string value (extended if necessary, see below)\n corresponding to the (8*i - 7)-th sub-identifier, and\n the least significant bit of the i-th octet of this\n octet string corresponding to the (8*i)-th\n sub-identifier, where i is in the range 1 through 16.\n\n Each bit of this bit mask specifies whether or not\n the corresponding sub-identifiers must match when\n determining if an OBJECT IDENTIFIER matches this\n family of filter subtrees; a '1' indicates that an\n exact match must occur; a '0' indicates 'wild card',\n i.e., any sub-identifier value matches.\n\n Thus, the OBJECT IDENTIFIER X of an object instance\n is contained in a family of filter subtrees if, for\n each sub-identifier of the value of\n snmpNotifyFilterSubtree, either:\n\n the i-th bit of snmpNotifyFilterMask is 0, or\n\n the i-th sub-identifier of X is equal to the i-th\n sub-identifier of the value of\n snmpNotifyFilterSubtree.\n\n If the value of this bit mask is M bits long and\n there are more than M sub-identifiers in the\n corresponding instance of snmpNotifyFilterSubtree,\n then the bit mask is extended with 1's to be the\n required length.\n\n Note that when the value of this object is the\n zero-length string, this extension rule results in\n a mask of all-1's being used (i.e., no 'wild card'),\n and the family of filter subtrees is the one\n subtree uniquely identified by the corresponding\n instance of snmpNotifyFilterSubtree.") -snmpNotifyFilterType = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 3, 1, 3), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2,)).clone(namedValues=NamedValues(("included", 1), ("excluded", 2),)).clone('included')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyFilterType.setDescription('This object indicates whether the family of filter subtrees\n defined by this entry are included in or excluded from a\n filter. A more detailed discussion of the use of this\n object can be found in section 6. of [SNMP-APPL].') +if mibBuilder.loadTexts: snmpNotifyFilterSubtree.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterSubtree.setDescription('The MIB subtree which, when combined with the corresponding instance of snmpNotifyFilterMask, defines a family of subtrees which are included in or excluded from the filter profile.') +snmpNotifyFilterMask = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 3, 1, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 16)).clone(hexValue="")).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpNotifyFilterMask.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterMask.setDescription("The bit mask which, in combination with the corresponding instance of snmpNotifyFilterSubtree, defines a family of subtrees which are included in or excluded from the filter profile. Each bit of this bit mask corresponds to a sub-identifier of snmpNotifyFilterSubtree, with the most significant bit of the i-th octet of this octet string value (extended if necessary, see below) corresponding to the (8*i - 7)-th sub-identifier, and the least significant bit of the i-th octet of this octet string corresponding to the (8*i)-th sub-identifier, where i is in the range 1 through 16. Each bit of this bit mask specifies whether or not the corresponding sub-identifiers must match when determining if an OBJECT IDENTIFIER matches this family of filter subtrees; a '1' indicates that an exact match must occur; a '0' indicates 'wild card', i.e., any sub-identifier value matches. Thus, the OBJECT IDENTIFIER X of an object instance is contained in a family of filter subtrees if, for each sub-identifier of the value of snmpNotifyFilterSubtree, either: the i-th bit of snmpNotifyFilterMask is 0, or the i-th sub-identifier of X is equal to the i-th sub-identifier of the value of snmpNotifyFilterSubtree. If the value of this bit mask is M bits long and there are more than M sub-identifiers in the corresponding instance of snmpNotifyFilterSubtree, then the bit mask is extended with 1's to be the required length. Note that when the value of this object is the zero-length string, this extension rule results in a mask of all-1's being used (i.e., no 'wild card'), and the family of filter subtrees is the one subtree uniquely identified by the corresponding instance of snmpNotifyFilterSubtree.") +snmpNotifyFilterType = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 3, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("included", 1), ("excluded", 2))).clone('included')).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpNotifyFilterType.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterType.setDescription('This object indicates whether the family of filter subtrees defined by this entry are included in or excluded from a filter. A more detailed discussion of the use of this object can be found in section 6. of [SNMP-APPL].') snmpNotifyFilterStorageType = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 3, 1, 4), StorageType().clone('nonVolatile')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyFilterStorageType.setDescription("The storage type for this conceptual row.\n Conceptual rows having the value 'permanent' need not\n\n allow write-access to any columnar objects in the row.") +if mibBuilder.loadTexts: snmpNotifyFilterStorageType.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterStorageType.setDescription("The storage type for this conceptual row. Conceptual rows having the value 'permanent' need not allow write-access to any columnar objects in the row.") snmpNotifyFilterRowStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 13, 1, 3, 1, 5), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpNotifyFilterRowStatus.setDescription('The status of this conceptual row.\n\n To create a row in this table, a manager must\n set this object to either createAndGo(4) or\n createAndWait(5).') +if mibBuilder.loadTexts: snmpNotifyFilterRowStatus.setStatus('current') +if mibBuilder.loadTexts: snmpNotifyFilterRowStatus.setDescription('The status of this conceptual row. To create a row in this table, a manager must set this object to either createAndGo(4) or createAndWait(5).') snmpNotifyCompliances = MibIdentifier((1, 3, 6, 1, 6, 3, 13, 3, 1)) snmpNotifyGroups = MibIdentifier((1, 3, 6, 1, 6, 3, 13, 3, 2)) -snmpNotifyBasicCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 13, 3, 1, 1)).setObjects(*(("SNMP-TARGET-MIB", "snmpTargetBasicGroup"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyGroup"),)) -if mibBuilder.loadTexts: snmpNotifyBasicCompliance.setDescription('The compliance statement for minimal SNMP entities which\n implement only SNMP Unconfirmed-Class notifications and\n read-create operations on only the snmpTargetAddrTable.') -snmpNotifyBasicFiltersCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 13, 3, 1, 2)).setObjects(*(("SNMP-TARGET-MIB", "snmpTargetBasicGroup"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyGroup"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterGroup"),)) -if mibBuilder.loadTexts: snmpNotifyBasicFiltersCompliance.setDescription('The compliance statement for SNMP entities which implement\n SNMP Unconfirmed-Class notifications with filtering, and\n read-create operations on all related tables.') -snmpNotifyFullCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 13, 3, 1, 3)).setObjects(*(("SNMP-TARGET-MIB", "snmpTargetBasicGroup"), ("SNMP-TARGET-MIB", "snmpTargetResponseGroup"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyGroup"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterGroup"),)) -if mibBuilder.loadTexts: snmpNotifyFullCompliance.setDescription('The compliance statement for SNMP entities which either\n implement only SNMP Confirmed-Class notifications, or both\n SNMP Unconfirmed-Class and Confirmed-Class notifications,\n plus filtering and read-create operations on all related\n tables.') -snmpNotifyGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 13, 3, 2, 1)).setObjects(*(("SNMP-NOTIFICATION-MIB", "snmpNotifyTag"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyType"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyStorageType"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyRowStatus"),)) -if mibBuilder.loadTexts: snmpNotifyGroup.setDescription('A collection of objects for selecting which management\n targets are used for generating notifications, and the\n type of notification to be generated for each selected\n management target.') -snmpNotifyFilterGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 13, 3, 2, 2)).setObjects(*(("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterProfileName"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterProfileStorType"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterProfileRowStatus"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterMask"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterType"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterStorageType"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterRowStatus"),)) -if mibBuilder.loadTexts: snmpNotifyFilterGroup.setDescription('A collection of objects providing remote configuration\n of notification filters.') -mibBuilder.exportSymbols("SNMP-NOTIFICATION-MIB", snmpNotifyBasicCompliance=snmpNotifyBasicCompliance, snmpNotifyEntry=snmpNotifyEntry, snmpNotifyFilterType=snmpNotifyFilterType, snmpNotifyConformance=snmpNotifyConformance, snmpNotifyFilterGroup=snmpNotifyFilterGroup, snmpNotifyFilterTable=snmpNotifyFilterTable, PYSNMP_MODULE_ID=snmpNotificationMIB, snmpNotifyFilterMask=snmpNotifyFilterMask, snmpNotifyFullCompliance=snmpNotifyFullCompliance, snmpNotifyFilterProfileEntry=snmpNotifyFilterProfileEntry, snmpNotifyFilterProfileRowStatus=snmpNotifyFilterProfileRowStatus, snmpNotifyFilterProfileStorType=snmpNotifyFilterProfileStorType, snmpNotifyFilterRowStatus=snmpNotifyFilterRowStatus, snmpNotifyBasicFiltersCompliance=snmpNotifyBasicFiltersCompliance, snmpNotifyFilterProfileTable=snmpNotifyFilterProfileTable, snmpNotifyType=snmpNotifyType, snmpNotifyTag=snmpNotifyTag, snmpNotifyName=snmpNotifyName, snmpNotifyObjects=snmpNotifyObjects, snmpNotifyGroup=snmpNotifyGroup, snmpNotifyGroups=snmpNotifyGroups, snmpNotifyRowStatus=snmpNotifyRowStatus, snmpNotifyFilterProfileName=snmpNotifyFilterProfileName, snmpNotificationMIB=snmpNotificationMIB, snmpNotifyFilterSubtree=snmpNotifyFilterSubtree, snmpNotifyStorageType=snmpNotifyStorageType, snmpNotifyCompliances=snmpNotifyCompliances, snmpNotifyFilterStorageType=snmpNotifyFilterStorageType, snmpNotifyFilterEntry=snmpNotifyFilterEntry, snmpNotifyTable=snmpNotifyTable) +snmpNotifyBasicCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 13, 3, 1, 1)).setObjects(("SNMP-TARGET-MIB", "snmpTargetBasicGroup"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyGroup")) +if mibBuilder.loadTexts: snmpNotifyBasicCompliance.setDescription('The compliance statement for minimal SNMP entities which implement only SNMP Unconfirmed-Class notifications and read-create operations on only the snmpTargetAddrTable.') +snmpNotifyBasicFiltersCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 13, 3, 1, 2)).setObjects(("SNMP-TARGET-MIB", "snmpTargetBasicGroup"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyGroup"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterGroup")) +if mibBuilder.loadTexts: snmpNotifyBasicFiltersCompliance.setDescription('The compliance statement for SNMP entities which implement SNMP Unconfirmed-Class notifications with filtering, and read-create operations on all related tables.') +snmpNotifyFullCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 13, 3, 1, 3)).setObjects(("SNMP-TARGET-MIB", "snmpTargetBasicGroup"), ("SNMP-TARGET-MIB", "snmpTargetResponseGroup"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyGroup"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterGroup")) +if mibBuilder.loadTexts: snmpNotifyFullCompliance.setDescription('The compliance statement for SNMP entities which either implement only SNMP Confirmed-Class notifications, or both SNMP Unconfirmed-Class and Confirmed-Class notifications, plus filtering and read-create operations on all related tables.') +snmpNotifyGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 13, 3, 2, 1)).setObjects(("SNMP-NOTIFICATION-MIB", "snmpNotifyTag"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyType"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyStorageType"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyRowStatus")) +if mibBuilder.loadTexts: snmpNotifyGroup.setDescription('A collection of objects for selecting which management targets are used for generating notifications, and the type of notification to be generated for each selected management target.') +snmpNotifyFilterGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 13, 3, 2, 2)).setObjects(("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterProfileName"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterProfileStorType"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterProfileRowStatus"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterMask"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterType"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterStorageType"), ("SNMP-NOTIFICATION-MIB", "snmpNotifyFilterRowStatus")) +if mibBuilder.loadTexts: snmpNotifyFilterGroup.setDescription('A collection of objects providing remote configuration of notification filters.') +mibBuilder.exportSymbols("SNMP-NOTIFICATION-MIB", PYSNMP_MODULE_ID=snmpNotificationMIB, snmpNotifyFilterProfileTable=snmpNotifyFilterProfileTable, snmpNotifyTag=snmpNotifyTag, snmpNotifyGroup=snmpNotifyGroup, snmpNotifyFilterProfileRowStatus=snmpNotifyFilterProfileRowStatus, snmpNotifyRowStatus=snmpNotifyRowStatus, snmpNotifyCompliances=snmpNotifyCompliances, snmpNotifyTable=snmpNotifyTable, snmpNotifyType=snmpNotifyType, snmpNotifyStorageType=snmpNotifyStorageType, snmpNotifyConformance=snmpNotifyConformance, snmpNotifyFilterMask=snmpNotifyFilterMask, snmpNotifyFilterProfileName=snmpNotifyFilterProfileName, snmpNotifyEntry=snmpNotifyEntry, snmpNotifyFullCompliance=snmpNotifyFullCompliance, snmpNotifyObjects=snmpNotifyObjects, snmpNotifyFilterEntry=snmpNotifyFilterEntry, snmpNotificationMIB=snmpNotificationMIB, snmpNotifyFilterRowStatus=snmpNotifyFilterRowStatus, snmpNotifyBasicFiltersCompliance=snmpNotifyBasicFiltersCompliance, snmpNotifyFilterGroup=snmpNotifyFilterGroup, snmpNotifyFilterProfileEntry=snmpNotifyFilterProfileEntry, snmpNotifyFilterTable=snmpNotifyFilterTable, snmpNotifyFilterSubtree=snmpNotifyFilterSubtree, snmpNotifyBasicCompliance=snmpNotifyBasicCompliance, snmpNotifyFilterStorageType=snmpNotifyFilterStorageType, snmpNotifyGroups=snmpNotifyGroups, snmpNotifyName=snmpNotifyName, snmpNotifyFilterProfileStorType=snmpNotifyFilterProfileStorType, snmpNotifyFilterType=snmpNotifyFilterType) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-PROXY-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-PROXY-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-PROXY-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-PROXY-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,56 +1,68 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMP-PROXY-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/SNMP-PROXY-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 23:02:14 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module SNMP-PROXY-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-PROXY-MIB +# Produced by pysmi-0.1.3 at Tue Apr 18 00:43:17 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( SnmpEngineID, SnmpAdminString, ) = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpEngineID", "SnmpAdminString") -( SnmpTagValue, ) = mibBuilder.importSymbols("SNMP-TARGET-MIB", "SnmpTagValue") -( NotificationGroup, ModuleCompliance, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, snmpModules, iso, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "snmpModules", "iso", "ObjectIdentity", "Bits", "Counter32") -( StorageType, DisplayString, RowStatus, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "StorageType", "DisplayString", "RowStatus", "TextualConvention") -snmpProxyMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 14)).setRevisions(("2002-10-14 00:00", "1998-08-04 00:00", "1997-07-14 00:00",)) -if mibBuilder.loadTexts: snmpProxyMIB.setLastUpdated('200210140000Z') +ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +SingleValueConstraint, ValueSizeConstraint, ConstraintsUnion, ValueRangeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsUnion", "ValueRangeConstraint", "ConstraintsIntersection") +SnmpAdminString, SnmpEngineID = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString", "SnmpEngineID") +SnmpTagValue, = mibBuilder.importSymbols("SNMP-TARGET-MIB", "SnmpTagValue") +ModuleCompliance, NotificationGroup, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup", "ObjectGroup") +ModuleIdentity, Counter64, Gauge32, Integer32, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn, MibIdentifier, NotificationType, iso, Counter32, ObjectIdentity, IpAddress, TimeTicks, Unsigned32, snmpModules = mibBuilder.importSymbols("SNMPv2-SMI", "ModuleIdentity", "Counter64", "Gauge32", "Integer32", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "MibIdentifier", "NotificationType", "iso", "Counter32", "ObjectIdentity", "IpAddress", "TimeTicks", "Unsigned32", "snmpModules") +TextualConvention, RowStatus, DisplayString, StorageType = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "RowStatus", "DisplayString", "StorageType") +snmpProxyMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 14)) +if mibBuilder.loadTexts: snmpProxyMIB.setRevisions(('1998-08-04 00:00', '1997-07-14 00:00',)) +if mibBuilder.loadTexts: snmpProxyMIB.setLastUpdated('9808040000Z') if mibBuilder.loadTexts: snmpProxyMIB.setOrganization('IETF SNMPv3 Working Group') -if mibBuilder.loadTexts: snmpProxyMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com\n Subscribe: majordomo@lists.tislabs.com\n In message body: subscribe snmpv3\n\n Co-Chair: Russ Mundy\n Network Associates Laboratories\n Postal: 15204 Omega Drive, Suite 300\n Rockville, MD 20850-4601\n USA\n EMail: mundy@tislabs.com\n Phone: +1 301-947-7107\n\n Co-Chair: David Harrington\n Enterasys Networks\n Postal: 35 Industrial Way\n P. O. Box 5004\n Rochester, New Hampshire 03866-5005\n USA\n EMail: dbh@enterasys.com\n Phone: +1 603-337-2614\n\n Co-editor: David B. Levi\n Nortel Networks\n Postal: 3505 Kesterwood Drive\n Knoxville, Tennessee 37918\n EMail: dlevi@nortelnetworks.com\n Phone: +1 865 686 0432\n\n Co-editor: Paul Meyer\n Secure Computing Corporation\n Postal: 2675 Long Lake Road\n Roseville, Minnesota 55113\n EMail: paul_meyer@securecomputing.com\n Phone: +1 651 628 1592\n\n Co-editor: Bob Stewart\n Retired') -if mibBuilder.loadTexts: snmpProxyMIB.setDescription('This MIB module defines MIB objects which provide\n mechanisms to remotely configure the parameters\n used by a proxy forwarding application.\n\n Copyright (C) The Internet Society (2002). This\n version of this MIB module is part of RFC 3413;\n see the RFC itself for full legal notices.\n ') +if mibBuilder.loadTexts: snmpProxyMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com Subscribe: majordomo@lists.tislabs.com In message body: subscribe snmpv3 Chair: Russ Mundy Trusted Information Systems Postal: 3060 Washington Rd Glenwood MD 21738 USA EMail: mundy@tislabs.com Phone: +1-301-854-6889 Co-editor: David B. Levi SNMP Research, Inc. Postal: 3001 Kimberlin Heights Road Knoxville, TN 37920-9716 EMail: levi@snmp.com Phone: +1 423 573 1434 Co-editor: Paul Meyer Secure Computing Corporation Postal: 2675 Long Lake Road Roseville, MN 55113 EMail: paul_meyer@securecomputing.com Phone: +1 651 628 1592 Co-editor: Bob Stewart Cisco Systems, Inc. Postal: 170 West Tasman Drive San Jose, CA 95134-1706 EMail: bstewart@cisco.com Phone: +1 603 654 2686') +if mibBuilder.loadTexts: snmpProxyMIB.setDescription('This MIB module defines MIB objects which provide mechanisms to remotely configure the parameters used by a proxy forwarding application.') snmpProxyObjects = MibIdentifier((1, 3, 6, 1, 6, 3, 14, 1)) snmpProxyConformance = MibIdentifier((1, 3, 6, 1, 6, 3, 14, 3)) snmpProxyTable = MibTable((1, 3, 6, 1, 6, 3, 14, 1, 2), ) -if mibBuilder.loadTexts: snmpProxyTable.setDescription('The table of translation parameters used by proxy forwarder\n applications for forwarding SNMP messages.') +if mibBuilder.loadTexts: snmpProxyTable.setStatus('current') +if mibBuilder.loadTexts: snmpProxyTable.setDescription('The table of translation parameters used by proxy forwarder applications for forwarding SNMP messages.') snmpProxyEntry = MibTableRow((1, 3, 6, 1, 6, 3, 14, 1, 2, 1), ).setIndexNames((1, "SNMP-PROXY-MIB", "snmpProxyName")) -if mibBuilder.loadTexts: snmpProxyEntry.setDescription('A set of translation parameters used by a proxy forwarder\n application for forwarding SNMP messages.\n\n Entries in the snmpProxyTable are created and deleted\n using the snmpProxyRowStatus object.') -snmpProxyName = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))) -if mibBuilder.loadTexts: snmpProxyName.setDescription('The locally arbitrary, but unique identifier associated\n with this snmpProxyEntry.') -snmpProxyType = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 2), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2, 3, 4,)).clone(namedValues=NamedValues(("read", 1), ("write", 2), ("trap", 3), ("inform", 4),))).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpProxyType.setDescription('The type of message that may be forwarded using\n the translation parameters defined by this entry.') +if mibBuilder.loadTexts: snmpProxyEntry.setStatus('current') +if mibBuilder.loadTexts: snmpProxyEntry.setDescription('A set of translation parameters used by a proxy forwarder application for forwarding SNMP messages. Entries in the snmpProxyTable are created and deleted using the snmpProxyRowStatus object.') +snmpProxyName = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) +if mibBuilder.loadTexts: snmpProxyName.setStatus('current') +if mibBuilder.loadTexts: snmpProxyName.setDescription('The locally arbitrary, but unique identifier associated with this snmpProxyEntry.') +snmpProxyType = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("read", 1), ("write", 2), ("trap", 3), ("inform", 4)))).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpProxyType.setStatus('current') +if mibBuilder.loadTexts: snmpProxyType.setDescription('The type of message that may be forwarded using the translation parameters defined by this entry.') snmpProxyContextEngineID = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 3), SnmpEngineID()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpProxyContextEngineID.setDescription('The contextEngineID contained in messages that\n may be forwarded using the translation parameters\n defined by this entry.') +if mibBuilder.loadTexts: snmpProxyContextEngineID.setStatus('current') +if mibBuilder.loadTexts: snmpProxyContextEngineID.setDescription('The contextEngineID contained in messages that may be forwarded using the translation parameters defined by this entry.') snmpProxyContextName = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 4), SnmpAdminString()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpProxyContextName.setDescription('The contextName contained in messages that may be\n forwarded using the translation parameters defined\n by this entry.\n\n This object is optional, and if not supported, the\n contextName contained in a message is ignored when\n selecting an entry in the snmpProxyTable.') +if mibBuilder.loadTexts: snmpProxyContextName.setStatus('current') +if mibBuilder.loadTexts: snmpProxyContextName.setDescription('The contextName contained in messages that may be forwarded using the translation parameters defined by this entry. This object is optional, and if not supported, the contextName contained in a message is ignored when selecting an entry in the snmpProxyTable.') snmpProxyTargetParamsIn = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 5), SnmpAdminString()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpProxyTargetParamsIn.setDescription('This object selects an entry in the snmpTargetParamsTable.\n The selected entry is used to determine which row of the\n snmpProxyTable to use for forwarding received messages.') +if mibBuilder.loadTexts: snmpProxyTargetParamsIn.setStatus('current') +if mibBuilder.loadTexts: snmpProxyTargetParamsIn.setDescription('This object selects an entry in the snmpTargetParamsTable. The selected entry is used to determine which row of the snmpProxyTable to use for forwarding received messages.') snmpProxySingleTargetOut = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 6), SnmpAdminString()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpProxySingleTargetOut.setDescription('This object selects a management target defined in the\n snmpTargetAddrTable (in the SNMP-TARGET-MIB). The\n selected target is defined by an entry in the\n snmpTargetAddrTable whose index value (snmpTargetAddrName)\n is equal to this object.\n\n This object is only used when selection of a single\n target is required (i.e. when forwarding an incoming\n read or write request).') +if mibBuilder.loadTexts: snmpProxySingleTargetOut.setStatus('current') +if mibBuilder.loadTexts: snmpProxySingleTargetOut.setDescription('This object selects a management target defined in the snmpTargetAddrTable (in the SNMP-TARGET-MIB). The selected target is defined by an entry in the snmpTargetAddrTable whose index value (snmpTargetAddrName) is equal to this object. This object is only used when selection of a single target is required (i.e. when forwarding an incoming read or write request).') snmpProxyMultipleTargetOut = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 7), SnmpTagValue()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpProxyMultipleTargetOut.setDescription('This object selects a set of management targets defined\n in the snmpTargetAddrTable (in the SNMP-TARGET-MIB).\n\n This object is only used when selection of multiple\n targets is required (i.e. when forwarding an incoming\n notification).') +if mibBuilder.loadTexts: snmpProxyMultipleTargetOut.setStatus('current') +if mibBuilder.loadTexts: snmpProxyMultipleTargetOut.setDescription('This object selects a set of management targets defined in the snmpTargetAddrTable (in the SNMP-TARGET-MIB). This object is only used when selection of multiple targets is required (i.e. when forwarding an incoming notification).') snmpProxyStorageType = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 8), StorageType().clone('nonVolatile')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpProxyStorageType.setDescription("The storage type of this conceptual row.\n Conceptual rows having the value 'permanent' need not\n allow write-access to any columnar objects in the row.") +if mibBuilder.loadTexts: snmpProxyStorageType.setStatus('current') +if mibBuilder.loadTexts: snmpProxyStorageType.setDescription('The storage type of this conceptual row.') snmpProxyRowStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 14, 1, 2, 1, 9), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpProxyRowStatus.setDescription('The status of this conceptual row.\n\n To create a row in this table, a manager must\n\n set this object to either createAndGo(4) or\n createAndWait(5).\n\n The following objects may not be modified while the\n value of this object is active(1):\n - snmpProxyType\n - snmpProxyContextEngineID\n - snmpProxyContextName\n - snmpProxyTargetParamsIn\n - snmpProxySingleTargetOut\n - snmpProxyMultipleTargetOut') +if mibBuilder.loadTexts: snmpProxyRowStatus.setStatus('current') +if mibBuilder.loadTexts: snmpProxyRowStatus.setDescription('The status of this conceptual row. To create a row in this table, a manager must set this object to either createAndGo(4) or createAndWait(5). The following objects may not be modified while the value of this object is active(1): - snmpProxyType - snmpProxyContextEngineID - snmpProxyContextName - snmpProxyTargetParamsIn - snmpProxySingleTargetOut - snmpProxyMultipleTargetOut') snmpProxyCompliances = MibIdentifier((1, 3, 6, 1, 6, 3, 14, 3, 1)) snmpProxyGroups = MibIdentifier((1, 3, 6, 1, 6, 3, 14, 3, 2)) -snmpProxyCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 14, 3, 1, 1)).setObjects(*(("SNMP-TARGET-MIB", "snmpTargetBasicGroup"), ("SNMP-TARGET-MIB", "snmpTargetResponseGroup"), ("SNMP-PROXY-MIB", "snmpProxyGroup"),)) -if mibBuilder.loadTexts: snmpProxyCompliance.setDescription('The compliance statement for SNMP entities which include\n a proxy forwarding application.') -snmpProxyGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 14, 3, 2, 3)).setObjects(*(("SNMP-PROXY-MIB", "snmpProxyType"), ("SNMP-PROXY-MIB", "snmpProxyContextEngineID"), ("SNMP-PROXY-MIB", "snmpProxyContextName"), ("SNMP-PROXY-MIB", "snmpProxyTargetParamsIn"), ("SNMP-PROXY-MIB", "snmpProxySingleTargetOut"), ("SNMP-PROXY-MIB", "snmpProxyMultipleTargetOut"), ("SNMP-PROXY-MIB", "snmpProxyStorageType"), ("SNMP-PROXY-MIB", "snmpProxyRowStatus"),)) -if mibBuilder.loadTexts: snmpProxyGroup.setDescription('A collection of objects providing remote configuration of\n management target translation parameters for use by\n proxy forwarder applications.') -mibBuilder.exportSymbols("SNMP-PROXY-MIB", snmpProxyMIB=snmpProxyMIB, snmpProxyEntry=snmpProxyEntry, snmpProxyContextEngineID=snmpProxyContextEngineID, snmpProxyStorageType=snmpProxyStorageType, snmpProxyCompliance=snmpProxyCompliance, PYSNMP_MODULE_ID=snmpProxyMIB, snmpProxyMultipleTargetOut=snmpProxyMultipleTargetOut, snmpProxyTargetParamsIn=snmpProxyTargetParamsIn, snmpProxyTable=snmpProxyTable, snmpProxyObjects=snmpProxyObjects, snmpProxyType=snmpProxyType, snmpProxyCompliances=snmpProxyCompliances, snmpProxyContextName=snmpProxyContextName, snmpProxyGroups=snmpProxyGroups, snmpProxyConformance=snmpProxyConformance, snmpProxyRowStatus=snmpProxyRowStatus, snmpProxyGroup=snmpProxyGroup, snmpProxyName=snmpProxyName, snmpProxySingleTargetOut=snmpProxySingleTargetOut) +snmpProxyCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 14, 3, 1, 1)).setObjects(("SNMP-TARGET-MIB", "snmpTargetBasicGroup"), ("SNMP-TARGET-MIB", "snmpTargetResponseGroup"), ("SNMP-PROXY-MIB", "snmpProxyGroup")) +if mibBuilder.loadTexts: snmpProxyCompliance.setDescription('The compliance statement for SNMP entities which include a proxy forwarding application.') +snmpProxyGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 14, 3, 2, 3)).setObjects(("SNMP-PROXY-MIB", "snmpProxyType"), ("SNMP-PROXY-MIB", "snmpProxyContextEngineID"), ("SNMP-PROXY-MIB", "snmpProxyContextName"), ("SNMP-PROXY-MIB", "snmpProxyTargetParamsIn"), ("SNMP-PROXY-MIB", "snmpProxySingleTargetOut"), ("SNMP-PROXY-MIB", "snmpProxyMultipleTargetOut"), ("SNMP-PROXY-MIB", "snmpProxyStorageType"), ("SNMP-PROXY-MIB", "snmpProxyRowStatus")) +if mibBuilder.loadTexts: snmpProxyGroup.setDescription('A collection of objects providing remote configuration of management target translation parameters for use by proxy forwarder applications.') +mibBuilder.exportSymbols("SNMP-PROXY-MIB", snmpProxyObjects=snmpProxyObjects, snmpProxyType=snmpProxyType, snmpProxyRowStatus=snmpProxyRowStatus, snmpProxyName=snmpProxyName, snmpProxyGroups=snmpProxyGroups, snmpProxySingleTargetOut=snmpProxySingleTargetOut, snmpProxyGroup=snmpProxyGroup, snmpProxyConformance=snmpProxyConformance, snmpProxyCompliance=snmpProxyCompliance, PYSNMP_MODULE_ID=snmpProxyMIB, snmpProxyContextEngineID=snmpProxyContextEngineID, snmpProxyCompliances=snmpProxyCompliances, snmpProxyStorageType=snmpProxyStorageType, snmpProxyEntry=snmpProxyEntry, snmpProxyTargetParamsIn=snmpProxyTargetParamsIn, snmpProxyContextName=snmpProxyContextName, snmpProxyMultipleTargetOut=snmpProxyMultipleTargetOut, snmpProxyTable=snmpProxyTable, snmpProxyMIB=snmpProxyMIB) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-TARGET-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-TARGET-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-TARGET-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-TARGET-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,32 +1,43 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMP-TARGET-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/SNMP-TARGET-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 23:04:28 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) -# -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( SnmpSecurityModel, SnmpMessageProcessingModel, SnmpSecurityLevel, SnmpAdminString, ) = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpSecurityModel", "SnmpMessageProcessingModel", "SnmpSecurityLevel", "SnmpAdminString") -( NotificationGroup, ModuleCompliance, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, iso, Gauge32, snmpModules, ModuleIdentity, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "iso", "Gauge32", "snmpModules", "ModuleIdentity", "ObjectIdentity", "Bits", "Counter32") -( TimeInterval, TextualConvention, StorageType, TestAndIncr, RowStatus, DisplayString, TAddress, TDomain, ) = mibBuilder.importSymbols("SNMPv2-TC", "TimeInterval", "TextualConvention", "StorageType", "TestAndIncr", "RowStatus", "DisplayString", "TAddress", "TDomain") +# PySNMP MIB module SNMP-TARGET-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-TARGET-MIB +# Produced by pysmi-0.1.3 at Tue Apr 18 00:44:13 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) +# +ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ConstraintsIntersection, ValueSizeConstraint, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint") +SnmpAdminString, SnmpSecurityLevel, SnmpMessageProcessingModel, SnmpSecurityModel = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString", "SnmpSecurityLevel", "SnmpMessageProcessingModel", "SnmpSecurityModel") +ModuleCompliance, ObjectGroup, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "ObjectGroup", "NotificationGroup") +MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, iso, Counter32, ObjectIdentity, Bits, NotificationType, Unsigned32, IpAddress, Integer32, ModuleIdentity, snmpModules, TimeTicks, Gauge32, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "Counter32", "ObjectIdentity", "Bits", "NotificationType", "Unsigned32", "IpAddress", "Integer32", "ModuleIdentity", "snmpModules", "TimeTicks", "Gauge32", "Counter64") +TimeInterval, RowStatus, TextualConvention, TestAndIncr, TAddress, StorageType, TDomain, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TimeInterval", "RowStatus", "TextualConvention", "TestAndIncr", "TAddress", "StorageType", "TDomain", "DisplayString") +snmpTargetMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 12)) +if mibBuilder.loadTexts: snmpTargetMIB.setRevisions(('2002-10-14 00:00', '1998-08-04 00:00', '1997-07-14 00:00',)) +if mibBuilder.loadTexts: snmpTargetMIB.setLastUpdated('200210140000Z') +if mibBuilder.loadTexts: snmpTargetMIB.setOrganization('IETF SNMPv3 Working Group') +if mibBuilder.loadTexts: snmpTargetMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com Subscribe: majordomo@lists.tislabs.com In message body: subscribe snmpv3 Co-Chair: Russ Mundy Network Associates Laboratories Postal: 15204 Omega Drive, Suite 300 Rockville, MD 20850-4601 USA EMail: mundy@tislabs.com Phone: +1 301-947-7107 Co-Chair: David Harrington Enterasys Networks Postal: 35 Industrial Way P. O. Box 5004 Rochester, New Hampshire 03866-5005 USA EMail: dbh@enterasys.com Phone: +1 603-337-2614 Co-editor: David B. Levi Nortel Networks Postal: 3505 Kesterwood Drive Knoxville, Tennessee 37918 EMail: dlevi@nortelnetworks.com Phone: +1 865 686 0432 Co-editor: Paul Meyer Secure Computing Corporation Postal: 2675 Long Lake Road Roseville, Minnesota 55113 EMail: paul_meyer@securecomputing.com Phone: +1 651 628 1592 Co-editor: Bob Stewart Retired') +if mibBuilder.loadTexts: snmpTargetMIB.setDescription('This MIB module defines MIB objects which provide mechanisms to remotely configure the parameters used by an SNMP entity for the generation of SNMP messages. Copyright (C) The Internet Society (2002). This version of this MIB module is part of RFC 3413; see the RFC itself for full legal notices. ') +snmpTargetObjects = MibIdentifier((1, 3, 6, 1, 6, 3, 12, 1)) +snmpTargetConformance = MibIdentifier((1, 3, 6, 1, 6, 3, 12, 3)) # # WARNING: some of the classes below are manually implemented # class SnmpTagList(TextualConvention, OctetString): + description = "An octet string containing a list of tag values. Tag values are preferably in human-readable form. To facilitate internationalization, this information is represented using the ISO/IEC IS 10646-1 character set, encoded as an octet string using the UTF-8 character encoding scheme described in RFC 2279. Since additional code points are added by amendments to the 10646 standard from time to time, implementations must be prepared to encounter any code point from 0x00000000 to 0x7fffffff. The use of control codes should be avoided, except as described below. For code points not directly supported by user interface hardware or software, an alternative means of entry and display, such as hexadecimal, may be provided. For information encoded in 7-bit US-ASCII, the UTF-8 representation is identical to the US-ASCII encoding. An object of this type contains a list of tag values which are used to select a set of entries in a table. A tag value is an arbitrary string of octets, but may not contain a delimiter character. Delimiter characters are defined to be one of the following: - An ASCII space character (0x20). - An ASCII TAB character (0x09). - An ASCII carriage return (CR) character (0x0D). - An ASCII line feed (LF) character (0x0A). Delimiter characters are used to separate tag values in a tag list. Only a single delimiter character may occur between two tag values. A tag value may not have a zero length. These constraints imply certain restrictions on the contents of this object: - There cannot be a leading or trailing delimiter character. - There cannot be multiple adjacent delimiter characters. Some examples of valid tag lists are: - '' -- an empty list - 'acme' -- list of one tag - 'host router bridge' -- list of several tags Note that although a tag value may not have a length of zero, an empty string is still valid. This indicates an empty list (i.e. there are no tag values in the list). The use of the tag list to select table entries is application and MIB specific. Typically, an application will provide one or more tag values, and any entry which contains some combination of these tag values will be selected." + status = 'current' displayHint = "255t" - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(0,255) + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(0, 255) encoding = 'utf-8' _delimiters = (' ', '\n', '\t', '\t') + def prettyIn(self, value): inDelim = True for v in str(value): @@ -39,80 +50,99 @@ if value and inDelim: raise error.SmiError('Dangling delimiter not allowed in tag list %r' % value) return OctetString.prettyIn(self, value) - + + class SnmpTagValue(TextualConvention, OctetString): + description = "An octet string containing a tag value. Tag values are preferably in human-readable form. To facilitate internationalization, this information is represented using the ISO/IEC IS 10646-1 character set, encoded as an octet string using the UTF-8 character encoding scheme described in RFC 2279. Since additional code points are added by amendments to the 10646 standard from time to time, implementations must be prepared to encounter any code point from 0x00000000 to 0x7fffffff. The use of control codes should be avoided, and certain control codes are not allowed as described below. For code points not directly supported by user interface hardware or software, an alternative means of entry and display, such as hexadecimal, may be provided. For information encoded in 7-bit US-ASCII, the UTF-8 representation is identical to the US-ASCII encoding. Note that when this TC is used for an object that is used or envisioned to be used as an index, then a SIZE restriction must be specified so that the number of sub-identifiers for any object instance does not exceed the limit of 128, as defined by [RFC1905]. An object of this type contains a single tag value which is used to select a set of entries in a table. A tag value is an arbitrary string of octets, but may not contain a delimiter character. Delimiter characters are defined to be one of the following: - An ASCII space character (0x20). - An ASCII TAB character (0x09). - An ASCII carriage return (CR) character (0x0D). - An ASCII line feed (LF) character (0x0A). Delimiter characters are used to separate tag values in a tag list. An object of this type may only contain a single tag value, and so delimiter characters are not allowed in a value of this type. Note that a tag value of 0 length means that no tag is defined. In other words, a tag value of 0 length would never match anything in a tag list, and would never select any table entries. Some examples of valid tag values are: - 'acme' - 'router' - 'host' The use of a tag value to select table entries is application and MIB specific." + status = 'current' displayHint = "255t" - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(0,255) + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(0, 255) encoding = 'utf-8' _delimiters = (' ', '\n', '\t', '\t') + def prettyIn(self, value): for v in str(value): if v in self._delimiters: raise error.SmiError('Delimiters not allowed in tag value') return OctetString.prettyIn(self, value) - -snmpTargetMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 12)).setRevisions(("2002-10-14 00:00", "1998-08-04 00:00", "1997-07-14 00:00",)) -if mibBuilder.loadTexts: snmpTargetMIB.setLastUpdated('200210140000Z') -if mibBuilder.loadTexts: snmpTargetMIB.setOrganization('IETF SNMPv3 Working Group') -if mibBuilder.loadTexts: snmpTargetMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com\n Subscribe: majordomo@lists.tislabs.com\n In message body: subscribe snmpv3\n\n Co-Chair: Russ Mundy\n Network Associates Laboratories\n Postal: 15204 Omega Drive, Suite 300\n Rockville, MD 20850-4601\n USA\n EMail: mundy@tislabs.com\n Phone: +1 301-947-7107\n\n Co-Chair: David Harrington\n Enterasys Networks\n Postal: 35 Industrial Way\n P. O. Box 5004\n Rochester, New Hampshire 03866-5005\n USA\n EMail: dbh@enterasys.com\n Phone: +1 603-337-2614\n\n Co-editor: David B. Levi\n Nortel Networks\n Postal: 3505 Kesterwood Drive\n Knoxville, Tennessee 37918\n EMail: dlevi@nortelnetworks.com\n Phone: +1 865 686 0432\n\n Co-editor: Paul Meyer\n Secure Computing Corporation\n Postal: 2675 Long Lake Road\n\n Roseville, Minnesota 55113\n EMail: paul_meyer@securecomputing.com\n Phone: +1 651 628 1592\n\n Co-editor: Bob Stewart\n Retired') -if mibBuilder.loadTexts: snmpTargetMIB.setDescription('This MIB module defines MIB objects which provide\n mechanisms to remotely configure the parameters used\n by an SNMP entity for the generation of SNMP messages.\n\n Copyright (C) The Internet Society (2002). This\n version of this MIB module is part of RFC 3413;\n see the RFC itself for full legal notices.\n ') -snmpTargetObjects = MibIdentifier((1, 3, 6, 1, 6, 3, 12, 1)) -snmpTargetConformance = MibIdentifier((1, 3, 6, 1, 6, 3, 12, 3)) snmpTargetSpinLock = MibScalar((1, 3, 6, 1, 6, 3, 12, 1, 1), TestAndIncr()).setMaxAccess("readwrite") -if mibBuilder.loadTexts: snmpTargetSpinLock.setDescription('This object is used to facilitate modification of table\n entries in the SNMP-TARGET-MIB module by multiple\n managers. In particular, it is useful when modifying\n the value of the snmpTargetAddrTagList object.\n\n The procedure for modifying the snmpTargetAddrTagList\n object is as follows:\n\n 1. Retrieve the value of snmpTargetSpinLock and\n of snmpTargetAddrTagList.\n\n 2. Generate a new value for snmpTargetAddrTagList.\n\n 3. Set the value of snmpTargetSpinLock to the\n retrieved value, and the value of\n snmpTargetAddrTagList to the new value. If\n the set fails for the snmpTargetSpinLock\n object, go back to step 1.') +if mibBuilder.loadTexts: snmpTargetSpinLock.setStatus('current') +if mibBuilder.loadTexts: snmpTargetSpinLock.setDescription('This object is used to facilitate modification of table entries in the SNMP-TARGET-MIB module by multiple managers. In particular, it is useful when modifying the value of the snmpTargetAddrTagList object. The procedure for modifying the snmpTargetAddrTagList object is as follows: 1. Retrieve the value of snmpTargetSpinLock and of snmpTargetAddrTagList. 2. Generate a new value for snmpTargetAddrTagList. 3. Set the value of snmpTargetSpinLock to the retrieved value, and the value of snmpTargetAddrTagList to the new value. If the set fails for the snmpTargetSpinLock object, go back to step 1.') snmpTargetAddrTable = MibTable((1, 3, 6, 1, 6, 3, 12, 1, 2), ) -if mibBuilder.loadTexts: snmpTargetAddrTable.setDescription('A table of transport addresses to be used in the generation\n of SNMP messages.') +if mibBuilder.loadTexts: snmpTargetAddrTable.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrTable.setDescription('A table of transport addresses to be used in the generation of SNMP messages.') snmpTargetAddrEntry = MibTableRow((1, 3, 6, 1, 6, 3, 12, 1, 2, 1), ).setIndexNames((1, "SNMP-TARGET-MIB", "snmpTargetAddrName")) -if mibBuilder.loadTexts: snmpTargetAddrEntry.setDescription('A transport address to be used in the generation\n of SNMP operations.\n\n Entries in the snmpTargetAddrTable are created and\n deleted using the snmpTargetAddrRowStatus object.') -snmpTargetAddrName = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))) -if mibBuilder.loadTexts: snmpTargetAddrName.setDescription('The locally arbitrary, but unique identifier associated\n with this snmpTargetAddrEntry.') +if mibBuilder.loadTexts: snmpTargetAddrEntry.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrEntry.setDescription('A transport address to be used in the generation of SNMP operations. Entries in the snmpTargetAddrTable are created and deleted using the snmpTargetAddrRowStatus object.') +snmpTargetAddrName = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) +if mibBuilder.loadTexts: snmpTargetAddrName.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrName.setDescription('The locally arbitrary, but unique identifier associated with this snmpTargetAddrEntry.') snmpTargetAddrTDomain = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 2), TDomain()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetAddrTDomain.setDescription('This object indicates the transport type of the address\n contained in the snmpTargetAddrTAddress object.') +if mibBuilder.loadTexts: snmpTargetAddrTDomain.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrTDomain.setDescription('This object indicates the transport type of the address contained in the snmpTargetAddrTAddress object.') snmpTargetAddrTAddress = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 3), TAddress()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetAddrTAddress.setDescription('This object contains a transport address. The format of\n this address depends on the value of the\n snmpTargetAddrTDomain object.') +if mibBuilder.loadTexts: snmpTargetAddrTAddress.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrTAddress.setDescription('This object contains a transport address. The format of this address depends on the value of the snmpTargetAddrTDomain object.') snmpTargetAddrTimeout = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 4), TimeInterval().clone(1500)).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetAddrTimeout.setDescription('This object should reflect the expected maximum round\n trip time for communicating with the transport address\n defined by this row. When a message is sent to this\n address, and a response (if one is expected) is not\n received within this time period, an implementation\n may assume that the response will not be delivered.\n\n Note that the time interval that an application waits\n for a response may actually be derived from the value\n of this object. The method for deriving the actual time\n interval is implementation dependent. One such method\n is to derive the expected round trip time based on a\n particular retransmission algorithm and on the number\n of timeouts which have occurred. The type of message may\n also be considered when deriving expected round trip\n times for retransmissions. For example, if a message is\n being sent with a securityLevel that indicates both\n\n authentication and privacy, the derived value may be\n increased to compensate for extra processing time spent\n during authentication and encryption processing.') -snmpTargetAddrRetryCount = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0,255)).clone(3)).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetAddrRetryCount.setDescription('This object specifies a default number of retries to be\n attempted when a response is not received for a generated\n message. An application may provide its own retry count,\n in which case the value of this object is ignored.') +if mibBuilder.loadTexts: snmpTargetAddrTimeout.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrTimeout.setDescription('This object should reflect the expected maximum round trip time for communicating with the transport address defined by this row. When a message is sent to this address, and a response (if one is expected) is not received within this time period, an implementation may assume that the response will not be delivered. Note that the time interval that an application waits for a response may actually be derived from the value of this object. The method for deriving the actual time interval is implementation dependent. One such method is to derive the expected round trip time based on a particular retransmission algorithm and on the number of timeouts which have occurred. The type of message may also be considered when deriving expected round trip times for retransmissions. For example, if a message is being sent with a securityLevel that indicates both authentication and privacy, the derived value may be increased to compensate for extra processing time spent during authentication and encryption processing.') +snmpTargetAddrRetryCount = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255)).clone(3)).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpTargetAddrRetryCount.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrRetryCount.setDescription('This object specifies a default number of retries to be attempted when a response is not received for a generated message. An application may provide its own retry count, in which case the value of this object is ignored.') snmpTargetAddrTagList = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 6), SnmpTagList()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetAddrTagList.setDescription('This object contains a list of tag values which are\n used to select target addresses for a particular\n operation.') -snmpTargetAddrParams = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 7), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetAddrParams.setDescription('The value of this object identifies an entry in the\n snmpTargetParamsTable. The identified entry\n contains SNMP parameters to be used when generating\n messages to be sent to this transport address.') +if mibBuilder.loadTexts: snmpTargetAddrTagList.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrTagList.setDescription('This object contains a list of tag values which are used to select target addresses for a particular operation.') +snmpTargetAddrParams = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 7), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpTargetAddrParams.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrParams.setDescription('The value of this object identifies an entry in the snmpTargetParamsTable. The identified entry contains SNMP parameters to be used when generating messages to be sent to this transport address.') snmpTargetAddrStorageType = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 8), StorageType().clone('nonVolatile')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetAddrStorageType.setDescription("The storage type for this conceptual row.\n Conceptual rows having the value 'permanent' need not\n allow write-access to any columnar objects in the row.") +if mibBuilder.loadTexts: snmpTargetAddrStorageType.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrStorageType.setDescription("The storage type for this conceptual row. Conceptual rows having the value 'permanent' need not allow write-access to any columnar objects in the row.") snmpTargetAddrRowStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 2, 1, 9), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetAddrRowStatus.setDescription("The status of this conceptual row.\n\n To create a row in this table, a manager must\n set this object to either createAndGo(4) or\n createAndWait(5).\n\n Until instances of all corresponding columns are\n appropriately configured, the value of the\n corresponding instance of the snmpTargetAddrRowStatus\n column is 'notReady'.\n\n In particular, a newly created row cannot be made\n active until the corresponding instances of\n snmpTargetAddrTDomain, snmpTargetAddrTAddress, and\n snmpTargetAddrParams have all been set.\n\n The following objects may not be modified while the\n value of this object is active(1):\n - snmpTargetAddrTDomain\n - snmpTargetAddrTAddress\n An attempt to set these objects while the value of\n snmpTargetAddrRowStatus is active(1) will result in\n an inconsistentValue error.") +if mibBuilder.loadTexts: snmpTargetAddrRowStatus.setStatus('current') +if mibBuilder.loadTexts: snmpTargetAddrRowStatus.setDescription("The status of this conceptual row. To create a row in this table, a manager must set this object to either createAndGo(4) or createAndWait(5). Until instances of all corresponding columns are appropriately configured, the value of the corresponding instance of the snmpTargetAddrRowStatus column is 'notReady'. In particular, a newly created row cannot be made active until the corresponding instances of snmpTargetAddrTDomain, snmpTargetAddrTAddress, and snmpTargetAddrParams have all been set. The following objects may not be modified while the value of this object is active(1): - snmpTargetAddrTDomain - snmpTargetAddrTAddress An attempt to set these objects while the value of snmpTargetAddrRowStatus is active(1) will result in an inconsistentValue error.") snmpTargetParamsTable = MibTable((1, 3, 6, 1, 6, 3, 12, 1, 3), ) -if mibBuilder.loadTexts: snmpTargetParamsTable.setDescription('A table of SNMP target information to be used\n in the generation of SNMP messages.') +if mibBuilder.loadTexts: snmpTargetParamsTable.setStatus('current') +if mibBuilder.loadTexts: snmpTargetParamsTable.setDescription('A table of SNMP target information to be used in the generation of SNMP messages.') snmpTargetParamsEntry = MibTableRow((1, 3, 6, 1, 6, 3, 12, 1, 3, 1), ).setIndexNames((1, "SNMP-TARGET-MIB", "snmpTargetParamsName")) -if mibBuilder.loadTexts: snmpTargetParamsEntry.setDescription('A set of SNMP target information.\n\n Entries in the snmpTargetParamsTable are created and\n deleted using the snmpTargetParamsRowStatus object.') -snmpTargetParamsName = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 3, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))) -if mibBuilder.loadTexts: snmpTargetParamsName.setDescription('The locally arbitrary, but unique identifier associated\n with this snmpTargetParamsEntry.') +if mibBuilder.loadTexts: snmpTargetParamsEntry.setStatus('current') +if mibBuilder.loadTexts: snmpTargetParamsEntry.setDescription('A set of SNMP target information. Entries in the snmpTargetParamsTable are created and deleted using the snmpTargetParamsRowStatus object.') +snmpTargetParamsName = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 3, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) +if mibBuilder.loadTexts: snmpTargetParamsName.setStatus('current') +if mibBuilder.loadTexts: snmpTargetParamsName.setDescription('The locally arbitrary, but unique identifier associated with this snmpTargetParamsEntry.') snmpTargetParamsMPModel = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 3, 1, 2), SnmpMessageProcessingModel()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetParamsMPModel.setDescription('The Message Processing Model to be used when generating\n SNMP messages using this entry.') -snmpTargetParamsSecurityModel = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 3, 1, 3), SnmpSecurityModel().subtype(subtypeSpec=ValueRangeConstraint(1,2147483647))).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetParamsSecurityModel.setDescription('The Security Model to be used when generating SNMP\n messages using this entry. An implementation may\n choose to return an inconsistentValue error if an\n attempt is made to set this variable to a value\n for a security model which the implementation does\n not support.') +if mibBuilder.loadTexts: snmpTargetParamsMPModel.setStatus('current') +if mibBuilder.loadTexts: snmpTargetParamsMPModel.setDescription('The Message Processing Model to be used when generating SNMP messages using this entry.') +snmpTargetParamsSecurityModel = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 3, 1, 3), SnmpSecurityModel().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readcreate") +if mibBuilder.loadTexts: snmpTargetParamsSecurityModel.setStatus('current') +if mibBuilder.loadTexts: snmpTargetParamsSecurityModel.setDescription('The Security Model to be used when generating SNMP messages using this entry. An implementation may choose to return an inconsistentValue error if an attempt is made to set this variable to a value for a security model which the implementation does not support.') snmpTargetParamsSecurityName = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 3, 1, 4), SnmpAdminString()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetParamsSecurityName.setDescription('The securityName which identifies the Principal on\n whose behalf SNMP messages will be generated using\n this entry.') +if mibBuilder.loadTexts: snmpTargetParamsSecurityName.setStatus('current') +if mibBuilder.loadTexts: snmpTargetParamsSecurityName.setDescription('The securityName which identifies the Principal on whose behalf SNMP messages will be generated using this entry.') snmpTargetParamsSecurityLevel = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 3, 1, 5), SnmpSecurityLevel()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetParamsSecurityLevel.setDescription('The Level of Security to be used when generating\n SNMP messages using this entry.') +if mibBuilder.loadTexts: snmpTargetParamsSecurityLevel.setStatus('current') +if mibBuilder.loadTexts: snmpTargetParamsSecurityLevel.setDescription('The Level of Security to be used when generating SNMP messages using this entry.') snmpTargetParamsStorageType = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 3, 1, 6), StorageType().clone('nonVolatile')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetParamsStorageType.setDescription("The storage type for this conceptual row.\n Conceptual rows having the value 'permanent' need not\n allow write-access to any columnar objects in the row.") +if mibBuilder.loadTexts: snmpTargetParamsStorageType.setStatus('current') +if mibBuilder.loadTexts: snmpTargetParamsStorageType.setDescription("The storage type for this conceptual row. Conceptual rows having the value 'permanent' need not allow write-access to any columnar objects in the row.") snmpTargetParamsRowStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 12, 1, 3, 1, 7), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: snmpTargetParamsRowStatus.setDescription("The status of this conceptual row.\n\n To create a row in this table, a manager must\n set this object to either createAndGo(4) or\n createAndWait(5).\n\n Until instances of all corresponding columns are\n appropriately configured, the value of the\n corresponding instance of the snmpTargetParamsRowStatus\n column is 'notReady'.\n\n In particular, a newly created row cannot be made\n active until the corresponding\n snmpTargetParamsMPModel,\n snmpTargetParamsSecurityModel,\n snmpTargetParamsSecurityName,\n and snmpTargetParamsSecurityLevel have all been set.\n\n The following objects may not be modified while the\n value of this object is active(1):\n - snmpTargetParamsMPModel\n - snmpTargetParamsSecurityModel\n - snmpTargetParamsSecurityName\n - snmpTargetParamsSecurityLevel\n An attempt to set these objects while the value of\n snmpTargetParamsRowStatus is active(1) will result in\n an inconsistentValue error.") +if mibBuilder.loadTexts: snmpTargetParamsRowStatus.setStatus('current') +if mibBuilder.loadTexts: snmpTargetParamsRowStatus.setDescription("The status of this conceptual row. To create a row in this table, a manager must set this object to either createAndGo(4) or createAndWait(5). Until instances of all corresponding columns are appropriately configured, the value of the corresponding instance of the snmpTargetParamsRowStatus column is 'notReady'. In particular, a newly created row cannot be made active until the corresponding snmpTargetParamsMPModel, snmpTargetParamsSecurityModel, snmpTargetParamsSecurityName, and snmpTargetParamsSecurityLevel have all been set. The following objects may not be modified while the value of this object is active(1): - snmpTargetParamsMPModel - snmpTargetParamsSecurityModel - snmpTargetParamsSecurityName - snmpTargetParamsSecurityLevel An attempt to set these objects while the value of snmpTargetParamsRowStatus is active(1) will result in an inconsistentValue error.") snmpUnavailableContexts = MibScalar((1, 3, 6, 1, 6, 3, 12, 1, 4), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpUnavailableContexts.setDescription('The total number of packets received by the SNMP\n engine which were dropped because the context\n contained in the message was unavailable.') +if mibBuilder.loadTexts: snmpUnavailableContexts.setStatus('current') +if mibBuilder.loadTexts: snmpUnavailableContexts.setDescription('The total number of packets received by the SNMP engine which were dropped because the context contained in the message was unavailable.') snmpUnknownContexts = MibScalar((1, 3, 6, 1, 6, 3, 12, 1, 5), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpUnknownContexts.setDescription('The total number of packets received by the SNMP\n engine which were dropped because the context\n contained in the message was unknown.') +if mibBuilder.loadTexts: snmpUnknownContexts.setStatus('current') +if mibBuilder.loadTexts: snmpUnknownContexts.setDescription('The total number of packets received by the SNMP engine which were dropped because the context contained in the message was unknown.') snmpTargetCompliances = MibIdentifier((1, 3, 6, 1, 6, 3, 12, 3, 1)) snmpTargetGroups = MibIdentifier((1, 3, 6, 1, 6, 3, 12, 3, 2)) -snmpTargetCommandResponderCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 12, 3, 1, 1)).setObjects(*(("SNMP-TARGET-MIB", "snmpTargetCommandResponderGroup"),)) -if mibBuilder.loadTexts: snmpTargetCommandResponderCompliance.setDescription('The compliance statement for SNMP entities which include\n a command responder application.') -snmpTargetBasicGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 12, 3, 2, 1)).setObjects(*(("SNMP-TARGET-MIB", "snmpTargetSpinLock"), ("SNMP-TARGET-MIB", "snmpTargetAddrTDomain"), ("SNMP-TARGET-MIB", "snmpTargetAddrTAddress"), ("SNMP-TARGET-MIB", "snmpTargetAddrTagList"), ("SNMP-TARGET-MIB", "snmpTargetAddrParams"), ("SNMP-TARGET-MIB", "snmpTargetAddrStorageType"), ("SNMP-TARGET-MIB", "snmpTargetAddrRowStatus"), ("SNMP-TARGET-MIB", "snmpTargetParamsMPModel"), ("SNMP-TARGET-MIB", "snmpTargetParamsSecurityModel"), ("SNMP-TARGET-MIB", "snmpTargetParamsSecurityName"), ("SNMP-TARGET-MIB", "snmpTargetParamsSecurityLevel"), ("SNMP-TARGET-MIB", "snmpTargetParamsStorageType"), ("SNMP-TARGET-MIB", "snmpTargetParamsRowStatus"),)) -if mibBuilder.loadTexts: snmpTargetBasicGroup.setDescription('A collection of objects providing basic remote\n configuration of management targets.') -snmpTargetResponseGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 12, 3, 2, 2)).setObjects(*(("SNMP-TARGET-MIB", "snmpTargetAddrTimeout"), ("SNMP-TARGET-MIB", "snmpTargetAddrRetryCount"),)) -if mibBuilder.loadTexts: snmpTargetResponseGroup.setDescription('A collection of objects providing remote configuration\n of management targets for applications which generate\n SNMP messages for which a response message would be\n expected.') -snmpTargetCommandResponderGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 12, 3, 2, 3)).setObjects(*(("SNMP-TARGET-MIB", "snmpUnavailableContexts"), ("SNMP-TARGET-MIB", "snmpUnknownContexts"),)) -if mibBuilder.loadTexts: snmpTargetCommandResponderGroup.setDescription('A collection of objects required for command responder\n applications, used for counting error conditions.') -mibBuilder.exportSymbols("SNMP-TARGET-MIB", snmpTargetAddrTAddress=snmpTargetAddrTAddress, snmpTargetAddrStorageType=snmpTargetAddrStorageType, snmpTargetParamsName=snmpTargetParamsName, snmpTargetParamsRowStatus=snmpTargetParamsRowStatus, snmpTargetCommandResponderCompliance=snmpTargetCommandResponderCompliance, snmpTargetAddrTagList=snmpTargetAddrTagList, snmpTargetObjects=snmpTargetObjects, snmpTargetAddrTable=snmpTargetAddrTable, PYSNMP_MODULE_ID=snmpTargetMIB, snmpTargetGroups=snmpTargetGroups, snmpTargetAddrTDomain=snmpTargetAddrTDomain, snmpUnavailableContexts=snmpUnavailableContexts, snmpTargetParamsStorageType=snmpTargetParamsStorageType, snmpTargetParamsSecurityModel=snmpTargetParamsSecurityModel, snmpTargetMIB=snmpTargetMIB, snmpTargetAddrRowStatus=snmpTargetAddrRowStatus, snmpTargetCompliances=snmpTargetCompliances, snmpTargetParamsSecurityLevel=snmpTargetParamsSecurityLevel, snmpTargetResponseGroup=snmpTargetResponseGroup, snmpTargetCommandResponderGroup=snmpTargetCommandResponderGroup, snmpTargetAddrTimeout=snmpTargetAddrTimeout, snmpTargetAddrEntry=snmpTargetAddrEntry, snmpTargetParamsEntry=snmpTargetParamsEntry, snmpTargetAddrName=snmpTargetAddrName, snmpTargetAddrParams=snmpTargetAddrParams, snmpUnknownContexts=snmpUnknownContexts, snmpTargetParamsSecurityName=snmpTargetParamsSecurityName, snmpTargetConformance=snmpTargetConformance, SnmpTagList=SnmpTagList, snmpTargetSpinLock=snmpTargetSpinLock, SnmpTagValue=SnmpTagValue, snmpTargetParamsMPModel=snmpTargetParamsMPModel, snmpTargetParamsTable=snmpTargetParamsTable, snmpTargetBasicGroup=snmpTargetBasicGroup, snmpTargetAddrRetryCount=snmpTargetAddrRetryCount) +snmpTargetCommandResponderCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 12, 3, 1, 1)).setObjects(("SNMP-TARGET-MIB", "snmpTargetCommandResponderGroup")) +if mibBuilder.loadTexts: snmpTargetCommandResponderCompliance.setDescription('The compliance statement for SNMP entities which include a command responder application.') +snmpTargetBasicGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 12, 3, 2, 1)).setObjects(("SNMP-TARGET-MIB", "snmpTargetSpinLock"), ("SNMP-TARGET-MIB", "snmpTargetAddrTDomain"), ("SNMP-TARGET-MIB", "snmpTargetAddrTAddress"), ("SNMP-TARGET-MIB", "snmpTargetAddrTagList"), ("SNMP-TARGET-MIB", "snmpTargetAddrParams"), ("SNMP-TARGET-MIB", "snmpTargetAddrStorageType"), ("SNMP-TARGET-MIB", "snmpTargetAddrRowStatus"), ("SNMP-TARGET-MIB", "snmpTargetParamsMPModel"), ("SNMP-TARGET-MIB", "snmpTargetParamsSecurityModel"), ("SNMP-TARGET-MIB", "snmpTargetParamsSecurityName"), ("SNMP-TARGET-MIB", "snmpTargetParamsSecurityLevel"), ("SNMP-TARGET-MIB", "snmpTargetParamsStorageType"), ("SNMP-TARGET-MIB", "snmpTargetParamsRowStatus")) +if mibBuilder.loadTexts: snmpTargetBasicGroup.setDescription('A collection of objects providing basic remote configuration of management targets.') +snmpTargetResponseGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 12, 3, 2, 2)).setObjects(("SNMP-TARGET-MIB", "snmpTargetAddrTimeout"), ("SNMP-TARGET-MIB", "snmpTargetAddrRetryCount")) +if mibBuilder.loadTexts: snmpTargetResponseGroup.setDescription('A collection of objects providing remote configuration of management targets for applications which generate SNMP messages for which a response message would be expected.') +snmpTargetCommandResponderGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 12, 3, 2, 3)).setObjects(("SNMP-TARGET-MIB", "snmpUnavailableContexts"), ("SNMP-TARGET-MIB", "snmpUnknownContexts")) +if mibBuilder.loadTexts: snmpTargetCommandResponderGroup.setDescription('A collection of objects required for command responder applications, used for counting error conditions.') +mibBuilder.exportSymbols("SNMP-TARGET-MIB", snmpTargetAddrTimeout=snmpTargetAddrTimeout, SnmpTagValue=SnmpTagValue, snmpTargetParamsSecurityModel=snmpTargetParamsSecurityModel, snmpTargetParamsSecurityLevel=snmpTargetParamsSecurityLevel, snmpTargetParamsTable=snmpTargetParamsTable, snmpTargetAddrEntry=snmpTargetAddrEntry, snmpTargetAddrParams=snmpTargetAddrParams, snmpTargetParamsSecurityName=snmpTargetParamsSecurityName, snmpTargetParamsMPModel=snmpTargetParamsMPModel, snmpTargetSpinLock=snmpTargetSpinLock, snmpTargetAddrTAddress=snmpTargetAddrTAddress, snmpTargetResponseGroup=snmpTargetResponseGroup, snmpTargetCompliances=snmpTargetCompliances, snmpTargetMIB=snmpTargetMIB, snmpUnavailableContexts=snmpUnavailableContexts, snmpTargetCommandResponderCompliance=snmpTargetCommandResponderCompliance, snmpTargetParamsEntry=snmpTargetParamsEntry, snmpUnknownContexts=snmpUnknownContexts, snmpTargetParamsName=snmpTargetParamsName, snmpTargetAddrTDomain=snmpTargetAddrTDomain, snmpTargetAddrTable=snmpTargetAddrTable, snmpTargetObjects=snmpTargetObjects, snmpTargetBasicGroup=snmpTargetBasicGroup, snmpTargetAddrRetryCount=snmpTargetAddrRetryCount, snmpTargetAddrTagList=snmpTargetAddrTagList, snmpTargetAddrRowStatus=snmpTargetAddrRowStatus, SnmpTagList=SnmpTagList, snmpTargetParamsStorageType=snmpTargetParamsStorageType, snmpTargetCommandResponderGroup=snmpTargetCommandResponderGroup, snmpTargetConformance=snmpTargetConformance, snmpTargetParamsRowStatus=snmpTargetParamsRowStatus, snmpTargetGroups=snmpTargetGroups, PYSNMP_MODULE_ID=snmpTargetMIB, snmpTargetAddrName=snmpTargetAddrName, snmpTargetAddrStorageType=snmpTargetAddrStorageType) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-USER-BASED-SM-3DES-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-USER-BASED-SM-3DES-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-USER-BASED-SM-3DES-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-USER-BASED-SM-3DES-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,27 +1,30 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMP-USER-BASED-SM-3DES-MIB (http://pysnmp.sf.net) +# PySNMP MIB module SNMP-USER-BASED-SM-3DES-MIB (http://snmplabs.com/pysnmp) # ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-USER-BASED-SM-3DES-MIB -# Produced by pysmi-0.0.5 at Sat Sep 19 23:09:40 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# Produced by pysmi-0.1.3 at Tue Apr 18 00:47:21 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( snmpPrivProtocols, ) = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "snmpPrivProtocols") -( NotificationGroup, ModuleCompliance, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, iso, Gauge32, snmpModules, ModuleIdentity, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "iso", "Gauge32", "snmpModules", "ModuleIdentity", "ObjectIdentity", "Bits", "Counter32") -( DisplayString, TextualConvention, AutonomousType, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention", "AutonomousType") -snmpUsmMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 15)).setRevisions(("1999-10-06 00:00",)) +Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ValueRangeConstraint, ConstraintsUnion, ValueSizeConstraint, SingleValueConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ConstraintsUnion", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsIntersection") +snmpPrivProtocols, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "snmpPrivProtocols") +ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") +Bits, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, IpAddress, TimeTicks, Integer32, Counter64, NotificationType, MibIdentifier, Unsigned32, ObjectIdentity, snmpModules, ModuleIdentity, iso, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "IpAddress", "TimeTicks", "Integer32", "Counter64", "NotificationType", "MibIdentifier", "Unsigned32", "ObjectIdentity", "snmpModules", "ModuleIdentity", "iso", "Counter32") +TextualConvention, AutonomousType, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "AutonomousType", "DisplayString") +snmpUsmMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 15)) +if mibBuilder.loadTexts: snmpUsmMIB.setRevisions(('1999-10-06 00:00',)) if mibBuilder.loadTexts: snmpUsmMIB.setLastUpdated('9910060000Z') if mibBuilder.loadTexts: snmpUsmMIB.setOrganization('SNMPv3 Working Group') -if mibBuilder.loadTexts: snmpUsmMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com\n Subscribe: majordomo@lists.tislabs.com\n In msg body: subscribe snmpv3\n\n Chair: Russ Mundy\n NAI Labs\n postal: 3060 Washington Rd\n Glenwood MD 21738\n USA\n email: mundy@tislabs.com\n phone: +1-443-259-2307\n\n Co-editor: David Reeder\n NAI Labs\n postal: 3060 Washington Road (Route 97)\n Glenwood, MD 21738\n USA\n email: dreeder@tislabs.com\n phone: +1-443-259-2348\n\n Co-editor: Olafur Gudmundsson\n NAI Labs\n postal: 3060 Washington Road (Route 97)\n Glenwood, MD 21738\n USA\n email: ogud@tislabs.com\n phone: +1-443-259-2389\n ') -if mibBuilder.loadTexts: snmpUsmMIB.setDescription("Extension to the SNMP User-based Security Model\n to support Triple-DES EDE in 'Outside' CBC\n (cipher-block chaining) Mode.\n ") +if mibBuilder.loadTexts: snmpUsmMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com Subscribe: majordomo@lists.tislabs.com In msg body: subscribe snmpv3 Chair: Russ Mundy NAI Labs postal: 3060 Washington Rd Glenwood MD 21738 USA email: mundy@tislabs.com phone: +1-443-259-2307 Co-editor: David Reeder NAI Labs postal: 3060 Washington Road (Route 97) Glenwood, MD 21738 USA email: dreeder@tislabs.com phone: +1-443-259-2348 Co-editor: Olafur Gudmundsson NAI Labs postal: 3060 Washington Road (Route 97) Glenwood, MD 21738 USA email: ogud@tislabs.com phone: +1-443-259-2389 ') +if mibBuilder.loadTexts: snmpUsmMIB.setDescription("Extension to the SNMP User-based Security Model to support Triple-DES EDE in 'Outside' CBC (cipher-block chaining) Mode. ") usm3DESEDEPrivProtocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 2, 3)) +if mibBuilder.loadTexts: usm3DESEDEPrivProtocol.setStatus('current') if mibBuilder.loadTexts: usm3DESEDEPrivProtocol.setDescription('The 3DES-EDE Symmetric Encryption Protocol.') -mibBuilder.exportSymbols("SNMP-USER-BASED-SM-3DES-MIB", snmpUsmMIB=snmpUsmMIB, usm3DESEDEPrivProtocol=usm3DESEDEPrivProtocol, PYSNMP_MODULE_ID=snmpUsmMIB) +if mibBuilder.loadTexts: usm3DESEDEPrivProtocol.setReference('- Data Encryption Standard, National Institute of Standards and Technology. Federal Information Processing Standard (FIPS) Publication 46-3, (1999, pending approval). Will supersede FIPS Publication 46-2. - Data Encryption Algorithm, American National Standards Institute. ANSI X3.92-1981, (December, 1980). - DES Modes of Operation, National Institute of Standards and Technology. Federal Information Processing Standard (FIPS) Publication 81, (December, 1980). - Data Encryption Algorithm - Modes of Operation, American National Standards Institute. ANSI X3.106-1983, (May 1983). ') +mibBuilder.exportSymbols("SNMP-USER-BASED-SM-3DES-MIB", snmpUsmMIB=snmpUsmMIB, PYSNMP_MODULE_ID=snmpUsmMIB, usm3DESEDEPrivProtocol=usm3DESEDEPrivProtocol) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-USER-BASED-SM-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-USER-BASED-SM-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-USER-BASED-SM-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-USER-BASED-SM-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,92 +1,124 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMP-USER-BASED-SM-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/SNMP-USER-BASED-SM-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 23:10:57 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module SNMP-USER-BASED-SM-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-USER-BASED-SM-MIB +# Produced by pysmi-0.1.3 at Tue Apr 18 00:48:12 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( SnmpAdminString, snmpPrivProtocols, snmpAuthProtocols, SnmpEngineID, ) = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString", "snmpPrivProtocols", "snmpAuthProtocols", "SnmpEngineID") -( NotificationGroup, ModuleCompliance, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, snmpModules, iso, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "snmpModules", "iso", "ObjectIdentity", "Bits", "Counter32") -( TextualConvention, AutonomousType, StorageType, TestAndIncr, RowStatus, DisplayString, RowPointer, ) = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "AutonomousType", "StorageType", "TestAndIncr", "RowStatus", "DisplayString", "RowPointer") -snmpUsmMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 15)).setRevisions(("2002-10-16 00:00", "1999-01-20 00:00", "1997-11-20 00:00",)) +OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ValueRangeConstraint, SingleValueConstraint, ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion") +SnmpAdminString, snmpAuthProtocols, snmpPrivProtocols, SnmpEngineID = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString", "snmpAuthProtocols", "snmpPrivProtocols", "SnmpEngineID") +ObjectGroup, ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "ModuleCompliance", "NotificationGroup") +MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, Gauge32, iso, Counter32, NotificationType, Bits, Unsigned32, MibIdentifier, Integer32, TimeTicks, IpAddress, ModuleIdentity, snmpModules, ObjectIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "Gauge32", "iso", "Counter32", "NotificationType", "Bits", "Unsigned32", "MibIdentifier", "Integer32", "TimeTicks", "IpAddress", "ModuleIdentity", "snmpModules", "ObjectIdentity") +DisplayString, AutonomousType, RowStatus, StorageType, TextualConvention, RowPointer, TestAndIncr = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "AutonomousType", "RowStatus", "StorageType", "TextualConvention", "RowPointer", "TestAndIncr") +snmpUsmMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 15)) +if mibBuilder.loadTexts: snmpUsmMIB.setRevisions(('2002-10-16 00:00', '1999-01-20 00:00', '1997-11-20 00:00',)) if mibBuilder.loadTexts: snmpUsmMIB.setLastUpdated('200210160000Z') if mibBuilder.loadTexts: snmpUsmMIB.setOrganization('SNMPv3 Working Group') -if mibBuilder.loadTexts: snmpUsmMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com\n Subscribe: majordomo@lists.tislabs.com\n In msg body: subscribe snmpv3\n\n Chair: Russ Mundy\n Network Associates Laboratories\n postal: 15204 Omega Drive, Suite 300\n Rockville, MD 20850-4601\n USA\n email: mundy@tislabs.com\n\n phone: +1 301-947-7107\n\n Co-Chair: David Harrington\n Enterasys Networks\n Postal: 35 Industrial Way\n P. O. Box 5004\n Rochester, New Hampshire 03866-5005\n USA\n EMail: dbh@enterasys.com\n Phone: +1 603-337-2614\n\n Co-editor Uri Blumenthal\n Lucent Technologies\n postal: 67 Whippany Rd.\n Whippany, NJ 07981\n USA\n email: uri@lucent.com\n phone: +1-973-386-2163\n\n Co-editor: Bert Wijnen\n Lucent Technologies\n postal: Schagen 33\n 3461 GL Linschoten\n Netherlands\n email: bwijnen@lucent.com\n phone: +31-348-480-685\n ') -if mibBuilder.loadTexts: snmpUsmMIB.setDescription('The management information definitions for the\n SNMP User-based Security Model.\n\n Copyright (C) The Internet Society (2002). This\n version of this MIB module is part of RFC 3414;\n see the RFC itself for full legal notices.\n ') +if mibBuilder.loadTexts: snmpUsmMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com Subscribe: majordomo@lists.tislabs.com In msg body: subscribe snmpv3 Chair: Russ Mundy Network Associates Laboratories postal: 15204 Omega Drive, Suite 300 Rockville, MD 20850-4601 USA email: mundy@tislabs.com phone: +1 301-947-7107 Co-Chair: David Harrington Enterasys Networks Postal: 35 Industrial Way P. O. Box 5004 Rochester, New Hampshire 03866-5005 USA EMail: dbh@enterasys.com Phone: +1 603-337-2614 Co-editor Uri Blumenthal Lucent Technologies postal: 67 Whippany Rd. Whippany, NJ 07981 USA email: uri@lucent.com phone: +1-973-386-2163 Co-editor: Bert Wijnen Lucent Technologies postal: Schagen 33 3461 GL Linschoten Netherlands email: bwijnen@lucent.com phone: +31-348-480-685 ') +if mibBuilder.loadTexts: snmpUsmMIB.setDescription('The management information definitions for the SNMP User-based Security Model. Copyright (C) The Internet Society (2002). This version of this MIB module is part of RFC 3414; see the RFC itself for full legal notices. ') usmMIBObjects = MibIdentifier((1, 3, 6, 1, 6, 3, 15, 1)) usmMIBConformance = MibIdentifier((1, 3, 6, 1, 6, 3, 15, 2)) usmNoAuthProtocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 1, 1)) +if mibBuilder.loadTexts: usmNoAuthProtocol.setStatus('current') if mibBuilder.loadTexts: usmNoAuthProtocol.setDescription('No Authentication Protocol.') usmHMACMD5AuthProtocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 1, 2)) +if mibBuilder.loadTexts: usmHMACMD5AuthProtocol.setStatus('current') if mibBuilder.loadTexts: usmHMACMD5AuthProtocol.setDescription('The HMAC-MD5-96 Digest Authentication Protocol.') +if mibBuilder.loadTexts: usmHMACMD5AuthProtocol.setReference('- H. Krawczyk, M. Bellare, R. Canetti HMAC: Keyed-Hashing for Message Authentication, RFC2104, Feb 1997. - Rivest, R., Message Digest Algorithm MD5, RFC1321. ') usmHMACSHAAuthProtocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 1, 3)) +if mibBuilder.loadTexts: usmHMACSHAAuthProtocol.setStatus('current') if mibBuilder.loadTexts: usmHMACSHAAuthProtocol.setDescription('The HMAC-SHA-96 Digest Authentication Protocol.') +if mibBuilder.loadTexts: usmHMACSHAAuthProtocol.setReference('- H. Krawczyk, M. Bellare, R. Canetti, HMAC: Keyed-Hashing for Message Authentication, RFC2104, Feb 1997. - Secure Hash Algorithm. NIST FIPS 180-1. ') usmNoPrivProtocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 2, 1)) +if mibBuilder.loadTexts: usmNoPrivProtocol.setStatus('current') if mibBuilder.loadTexts: usmNoPrivProtocol.setDescription('No Privacy Protocol.') usmDESPrivProtocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 2, 2)) +if mibBuilder.loadTexts: usmDESPrivProtocol.setStatus('current') if mibBuilder.loadTexts: usmDESPrivProtocol.setDescription('The CBC-DES Symmetric Encryption Protocol.') -class KeyChange(OctetString, TextualConvention): - pass +if mibBuilder.loadTexts: usmDESPrivProtocol.setReference('- Data Encryption Standard, National Institute of Standards and Technology. Federal Information Processing Standard (FIPS) Publication 46-1. Supersedes FIPS Publication 46, (January, 1977; reaffirmed January, 1988). - Data Encryption Algorithm, American National Standards Institute. ANSI X3.92-1981, (December, 1980). - DES Modes of Operation, National Institute of Standards and Technology. Federal Information Processing Standard (FIPS) Publication 81, (December, 1980). - Data Encryption Algorithm - Modes of Operation, American National Standards Institute. ANSI X3.106-1983, (May 1983). ') +class KeyChange(TextualConvention, OctetString): + description = "Every definition of an object with this syntax must identify a protocol P, a secret key K, and a hash algorithm H that produces output of L octets. The object's value is a manager-generated, partially-random value which, when modified, causes the value of the secret key K, to be modified via a one-way function. The value of an instance of this object is the concatenation of two components: first a 'random' component and then a 'delta' component. The lengths of the random and delta components are given by the corresponding value of the protocol P; if P requires K to be a fixed length, the length of both the random and delta components is that fixed length; if P allows the length of K to be variable up to a particular maximum length, the length of the random component is that maximum length and the length of the delta component is any length less than or equal to that maximum length. For example, usmHMACMD5AuthProtocol requires K to be a fixed length of 16 octets and L - of 16 octets. usmHMACSHAAuthProtocol requires K to be a fixed length of 20 octets and L - of 20 octets. Other protocols may define other sizes, as deemed appropriate. When a requester wants to change the old key K to a new key keyNew on a remote entity, the 'random' component is obtained from either a true random generator, or from a pseudorandom generator, and the 'delta' component is computed as follows: - a temporary variable is initialized to the existing value of K; - if the length of the keyNew is greater than L octets, then: - the random component is appended to the value of the temporary variable, and the result is input to the the hash algorithm H to produce a digest value, and the temporary variable is set to this digest value; - the value of the temporary variable is XOR-ed with the first (next) L-octets (16 octets in case of MD5) of the keyNew to produce the first (next) L-octets (16 octets in case of MD5) of the 'delta' component. - the above two steps are repeated until the unused portion of the keyNew component is L octets or less, - the random component is appended to the value of the temporary variable, and the result is input to the hash algorithm H to produce a digest value; - this digest value, truncated if necessary to be the same length as the unused portion of the keyNew, is XOR-ed with the unused portion of the keyNew to produce the (final portion of the) 'delta' component. For example, using MD5 as the hash algorithm H: iterations = (lenOfDelta - 1)/16; /* integer division */ temp = keyOld; for (i = 0; i < iterations; i++) { temp = MD5 (temp || random); delta[i*16 .. (i*16)+15] = temp XOR keyNew[i*16 .. (i*16)+15]; } temp = MD5 (temp || random); delta[i*16 .. lenOfDelta-1] = temp XOR keyNew[i*16 .. lenOfDelta-1]; The 'random' and 'delta' components are then concatenated as described above, and the resulting octet string is sent to the recipient as the new value of an instance of this object. At the receiver side, when an instance of this object is set to a new value, then a new value of K is computed as follows: - a temporary variable is initialized to the existing value of K; - if the length of the delta component is greater than L octets, then: - the random component is appended to the value of the temporary variable, and the result is input to the hash algorithm H to produce a digest value, and the temporary variable is set to this digest value; - the value of the temporary variable is XOR-ed with the first (next) L-octets (16 octets in case of MD5) of the delta component to produce the first (next) L-octets (16 octets in case of MD5) of the new value of K. - the above two steps are repeated until the unused portion of the delta component is L octets or less, - the random component is appended to the value of the temporary variable, and the result is input to the hash algorithm H to produce a digest value; - this digest value, truncated if necessary to be the same length as the unused portion of the delta component, is XOR-ed with the unused portion of the delta component to produce the (final portion of the) new value of K. For example, using MD5 as the hash algorithm H: iterations = (lenOfDelta - 1)/16; /* integer division */ temp = keyOld; for (i = 0; i < iterations; i++) { temp = MD5 (temp || random); keyNew[i*16 .. (i*16)+15] = temp XOR delta[i*16 .. (i*16)+15]; } temp = MD5 (temp || random); keyNew[i*16 .. lenOfDelta-1] = temp XOR delta[i*16 .. lenOfDelta-1]; The value of an object with this syntax, whenever it is retrieved by the management protocol, is always the zero length string. Note that the keyOld and keyNew are the localized keys. Note that it is probably wise that when an SNMP entity sends a SetRequest to change a key, that it keeps a copy of the old key until it has confirmed that the key change actually succeeded. " + status = 'current' usmStats = MibIdentifier((1, 3, 6, 1, 6, 3, 15, 1, 1)) usmStatsUnsupportedSecLevels = MibScalar((1, 3, 6, 1, 6, 3, 15, 1, 1, 1), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: usmStatsUnsupportedSecLevels.setDescription('The total number of packets received by the SNMP\n engine which were dropped because they requested a\n securityLevel that was unknown to the SNMP engine\n or otherwise unavailable.\n ') +if mibBuilder.loadTexts: usmStatsUnsupportedSecLevels.setStatus('current') +if mibBuilder.loadTexts: usmStatsUnsupportedSecLevels.setDescription('The total number of packets received by the SNMP engine which were dropped because they requested a securityLevel that was unknown to the SNMP engine or otherwise unavailable. ') usmStatsNotInTimeWindows = MibScalar((1, 3, 6, 1, 6, 3, 15, 1, 1, 2), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: usmStatsNotInTimeWindows.setDescription("The total number of packets received by the SNMP\n engine which were dropped because they appeared\n outside of the authoritative SNMP engine's window.\n ") +if mibBuilder.loadTexts: usmStatsNotInTimeWindows.setStatus('current') +if mibBuilder.loadTexts: usmStatsNotInTimeWindows.setDescription("The total number of packets received by the SNMP engine which were dropped because they appeared outside of the authoritative SNMP engine's window. ") usmStatsUnknownUserNames = MibScalar((1, 3, 6, 1, 6, 3, 15, 1, 1, 3), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: usmStatsUnknownUserNames.setDescription('The total number of packets received by the SNMP\n engine which were dropped because they referenced a\n user that was not known to the SNMP engine.\n ') +if mibBuilder.loadTexts: usmStatsUnknownUserNames.setStatus('current') +if mibBuilder.loadTexts: usmStatsUnknownUserNames.setDescription('The total number of packets received by the SNMP engine which were dropped because they referenced a user that was not known to the SNMP engine. ') usmStatsUnknownEngineIDs = MibScalar((1, 3, 6, 1, 6, 3, 15, 1, 1, 4), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: usmStatsUnknownEngineIDs.setDescription('The total number of packets received by the SNMP\n engine which were dropped because they referenced an\n snmpEngineID that was not known to the SNMP engine.\n ') +if mibBuilder.loadTexts: usmStatsUnknownEngineIDs.setStatus('current') +if mibBuilder.loadTexts: usmStatsUnknownEngineIDs.setDescription('The total number of packets received by the SNMP engine which were dropped because they referenced an snmpEngineID that was not known to the SNMP engine. ') usmStatsWrongDigests = MibScalar((1, 3, 6, 1, 6, 3, 15, 1, 1, 5), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: usmStatsWrongDigests.setDescription("The total number of packets received by the SNMP\n engine which were dropped because they didn't\n contain the expected digest value.\n ") +if mibBuilder.loadTexts: usmStatsWrongDigests.setStatus('current') +if mibBuilder.loadTexts: usmStatsWrongDigests.setDescription("The total number of packets received by the SNMP engine which were dropped because they didn't contain the expected digest value. ") usmStatsDecryptionErrors = MibScalar((1, 3, 6, 1, 6, 3, 15, 1, 1, 6), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: usmStatsDecryptionErrors.setDescription('The total number of packets received by the SNMP\n engine which were dropped because they could not be\n decrypted.\n ') +if mibBuilder.loadTexts: usmStatsDecryptionErrors.setStatus('current') +if mibBuilder.loadTexts: usmStatsDecryptionErrors.setDescription('The total number of packets received by the SNMP engine which were dropped because they could not be decrypted. ') usmUser = MibIdentifier((1, 3, 6, 1, 6, 3, 15, 1, 2)) usmUserSpinLock = MibScalar((1, 3, 6, 1, 6, 3, 15, 1, 2, 1), TestAndIncr()).setMaxAccess("readwrite") -if mibBuilder.loadTexts: usmUserSpinLock.setDescription('An advisory lock used to allow several cooperating\n Command Generator Applications to coordinate their\n use of facilities to alter secrets in the\n usmUserTable.\n ') +if mibBuilder.loadTexts: usmUserSpinLock.setStatus('current') +if mibBuilder.loadTexts: usmUserSpinLock.setDescription('An advisory lock used to allow several cooperating Command Generator Applications to coordinate their use of facilities to alter secrets in the usmUserTable. ') usmUserTable = MibTable((1, 3, 6, 1, 6, 3, 15, 1, 2, 2), ) -if mibBuilder.loadTexts: usmUserTable.setDescription("The table of users configured in the SNMP engine's\n Local Configuration Datastore (LCD).\n\n To create a new user (i.e., to instantiate a new\n conceptual row in this table), it is recommended to\n follow this procedure:\n\n 1) GET(usmUserSpinLock.0) and save in sValue.\n\n 2) SET(usmUserSpinLock.0=sValue,\n usmUserCloneFrom=templateUser,\n usmUserStatus=createAndWait)\n You should use a template user to clone from\n which has the proper auth/priv protocol defined.\n\n If the new user is to use privacy:\n\n 3) generate the keyChange value based on the secret\n privKey of the clone-from user and the secret key\n to be used for the new user. Let us call this\n pkcValue.\n 4) GET(usmUserSpinLock.0) and save in sValue.\n 5) SET(usmUserSpinLock.0=sValue,\n usmUserPrivKeyChange=pkcValue\n usmUserPublic=randomValue1)\n 6) GET(usmUserPulic) and check it has randomValue1.\n If not, repeat steps 4-6.\n\n If the new user will never use privacy:\n\n 7) SET(usmUserPrivProtocol=usmNoPrivProtocol)\n\n If the new user is to use authentication:\n\n 8) generate the keyChange value based on the secret\n authKey of the clone-from user and the secret key\n to be used for the new user. Let us call this\n akcValue.\n 9) GET(usmUserSpinLock.0) and save in sValue.\n 10) SET(usmUserSpinLock.0=sValue,\n usmUserAuthKeyChange=akcValue\n usmUserPublic=randomValue2)\n 11) GET(usmUserPulic) and check it has randomValue2.\n If not, repeat steps 9-11.\n\n If the new user will never use authentication:\n\n 12) SET(usmUserAuthProtocol=usmNoAuthProtocol)\n\n Finally, activate the new user:\n\n 13) SET(usmUserStatus=active)\n\n The new user should now be available and ready to be\n used for SNMPv3 communication. Note however that access\n to MIB data must be provided via configuration of the\n SNMP-VIEW-BASED-ACM-MIB.\n\n The use of usmUserSpinlock is to avoid conflicts with\n another SNMP command generator application which may\n also be acting on the usmUserTable.\n ") +if mibBuilder.loadTexts: usmUserTable.setStatus('current') +if mibBuilder.loadTexts: usmUserTable.setDescription("The table of users configured in the SNMP engine's Local Configuration Datastore (LCD). To create a new user (i.e., to instantiate a new conceptual row in this table), it is recommended to follow this procedure: 1) GET(usmUserSpinLock.0) and save in sValue. 2) SET(usmUserSpinLock.0=sValue, usmUserCloneFrom=templateUser, usmUserStatus=createAndWait) You should use a template user to clone from which has the proper auth/priv protocol defined. If the new user is to use privacy: 3) generate the keyChange value based on the secret privKey of the clone-from user and the secret key to be used for the new user. Let us call this pkcValue. 4) GET(usmUserSpinLock.0) and save in sValue. 5) SET(usmUserSpinLock.0=sValue, usmUserPrivKeyChange=pkcValue usmUserPublic=randomValue1) 6) GET(usmUserPulic) and check it has randomValue1. If not, repeat steps 4-6. If the new user will never use privacy: 7) SET(usmUserPrivProtocol=usmNoPrivProtocol) If the new user is to use authentication: 8) generate the keyChange value based on the secret authKey of the clone-from user and the secret key to be used for the new user. Let us call this akcValue. 9) GET(usmUserSpinLock.0) and save in sValue. 10) SET(usmUserSpinLock.0=sValue, usmUserAuthKeyChange=akcValue usmUserPublic=randomValue2) 11) GET(usmUserPulic) and check it has randomValue2. If not, repeat steps 9-11. If the new user will never use authentication: 12) SET(usmUserAuthProtocol=usmNoAuthProtocol) Finally, activate the new user: 13) SET(usmUserStatus=active) The new user should now be available and ready to be used for SNMPv3 communication. Note however that access to MIB data must be provided via configuration of the SNMP-VIEW-BASED-ACM-MIB. The use of usmUserSpinlock is to avoid conflicts with another SNMP command generator application which may also be acting on the usmUserTable. ") usmUserEntry = MibTableRow((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1), ).setIndexNames((0, "SNMP-USER-BASED-SM-MIB", "usmUserEngineID"), (0, "SNMP-USER-BASED-SM-MIB", "usmUserName")) -if mibBuilder.loadTexts: usmUserEntry.setDescription("A user configured in the SNMP engine's Local\n Configuration Datastore (LCD) for the User-based\n Security Model.\n ") +if mibBuilder.loadTexts: usmUserEntry.setStatus('current') +if mibBuilder.loadTexts: usmUserEntry.setDescription("A user configured in the SNMP engine's Local Configuration Datastore (LCD) for the User-based Security Model. ") usmUserEngineID = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 1), SnmpEngineID()) -if mibBuilder.loadTexts: usmUserEngineID.setDescription("An SNMP engine's administratively-unique identifier.\n\n In a simple agent, this value is always that agent's\n own snmpEngineID value.\n\n The value can also take the value of the snmpEngineID\n of a remote SNMP engine with which this user can\n communicate.\n ") -usmUserName = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 2), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))) -if mibBuilder.loadTexts: usmUserName.setDescription('A human readable string representing the name of\n the user.\n\n This is the (User-based Security) Model dependent\n security ID.\n ') +if mibBuilder.loadTexts: usmUserEngineID.setStatus('current') +if mibBuilder.loadTexts: usmUserEngineID.setDescription("An SNMP engine's administratively-unique identifier. In a simple agent, this value is always that agent's own snmpEngineID value. The value can also take the value of the snmpEngineID of a remote SNMP engine with which this user can communicate. ") +usmUserName = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 2), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) +if mibBuilder.loadTexts: usmUserName.setStatus('current') +if mibBuilder.loadTexts: usmUserName.setDescription('A human readable string representing the name of the user. This is the (User-based Security) Model dependent security ID. ') usmUserSecurityName = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 3), SnmpAdminString()).setMaxAccess("readonly") -if mibBuilder.loadTexts: usmUserSecurityName.setDescription('A human readable string representing the user in\n Security Model independent format.\n\n The default transformation of the User-based Security\n Model dependent security ID to the securityName and\n vice versa is the identity function so that the\n securityName is the same as the userName.\n ') +if mibBuilder.loadTexts: usmUserSecurityName.setStatus('current') +if mibBuilder.loadTexts: usmUserSecurityName.setDescription('A human readable string representing the user in Security Model independent format. The default transformation of the User-based Security Model dependent security ID to the securityName and vice versa is the identity function so that the securityName is the same as the userName. ') usmUserCloneFrom = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 4), RowPointer()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: usmUserCloneFrom.setDescription("A pointer to another conceptual row in this\n usmUserTable. The user in this other conceptual\n row is called the clone-from user.\n\n When a new user is created (i.e., a new conceptual\n row is instantiated in this table), the privacy and\n authentication parameters of the new user must be\n cloned from its clone-from user. These parameters are:\n - authentication protocol (usmUserAuthProtocol)\n - privacy protocol (usmUserPrivProtocol)\n They will be copied regardless of what the current\n value is.\n\n Cloning also causes the initial values of the secret\n authentication key (authKey) and the secret encryption\n\n key (privKey) of the new user to be set to the same\n values as the corresponding secrets of the clone-from\n user to allow the KeyChange process to occur as\n required during user creation.\n\n The first time an instance of this object is set by\n a management operation (either at or after its\n instantiation), the cloning process is invoked.\n Subsequent writes are successful but invoke no\n action to be taken by the receiver.\n The cloning process fails with an 'inconsistentName'\n error if the conceptual row representing the\n clone-from user does not exist or is not in an active\n state when the cloning process is invoked.\n\n When this object is read, the ZeroDotZero OID\n is returned.\n ") +if mibBuilder.loadTexts: usmUserCloneFrom.setStatus('current') +if mibBuilder.loadTexts: usmUserCloneFrom.setDescription("A pointer to another conceptual row in this usmUserTable. The user in this other conceptual row is called the clone-from user. When a new user is created (i.e., a new conceptual row is instantiated in this table), the privacy and authentication parameters of the new user must be cloned from its clone-from user. These parameters are: - authentication protocol (usmUserAuthProtocol) - privacy protocol (usmUserPrivProtocol) They will be copied regardless of what the current value is. Cloning also causes the initial values of the secret authentication key (authKey) and the secret encryption key (privKey) of the new user to be set to the same values as the corresponding secrets of the clone-from user to allow the KeyChange process to occur as required during user creation. The first time an instance of this object is set by a management operation (either at or after its instantiation), the cloning process is invoked. Subsequent writes are successful but invoke no action to be taken by the receiver. The cloning process fails with an 'inconsistentName' error if the conceptual row representing the clone-from user does not exist or is not in an active state when the cloning process is invoked. When this object is read, the ZeroDotZero OID is returned. ") usmUserAuthProtocol = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 5), AutonomousType().clone((1, 3, 6, 1, 6, 3, 10, 1, 1, 1))).setMaxAccess("readcreate") -if mibBuilder.loadTexts: usmUserAuthProtocol.setDescription("An indication of whether messages sent on behalf of\n this user to/from the SNMP engine identified by\n usmUserEngineID, can be authenticated, and if so,\n the type of authentication protocol which is used.\n\n An instance of this object is created concurrently\n with the creation of any other object instance for\n the same user (i.e., as part of the processing of\n the set operation which creates the first object\n instance in the same conceptual row).\n\n If an initial set operation (i.e. at row creation time)\n tries to set a value for an unknown or unsupported\n protocol, then a 'wrongValue' error must be returned.\n\n The value will be overwritten/set when a set operation\n is performed on the corresponding instance of\n usmUserCloneFrom.\n\n Once instantiated, the value of such an instance of\n this object can only be changed via a set operation to\n the value of the usmNoAuthProtocol.\n\n If a set operation tries to change the value of an\n\n existing instance of this object to any value other\n than usmNoAuthProtocol, then an 'inconsistentValue'\n error must be returned.\n\n If a set operation tries to set the value to the\n usmNoAuthProtocol while the usmUserPrivProtocol value\n in the same row is not equal to usmNoPrivProtocol,\n then an 'inconsistentValue' error must be returned.\n That means that an SNMP command generator application\n must first ensure that the usmUserPrivProtocol is set\n to the usmNoPrivProtocol value before it can set\n the usmUserAuthProtocol value to usmNoAuthProtocol.\n ") +if mibBuilder.loadTexts: usmUserAuthProtocol.setStatus('current') +if mibBuilder.loadTexts: usmUserAuthProtocol.setDescription("An indication of whether messages sent on behalf of this user to/from the SNMP engine identified by usmUserEngineID, can be authenticated, and if so, the type of authentication protocol which is used. An instance of this object is created concurrently with the creation of any other object instance for the same user (i.e., as part of the processing of the set operation which creates the first object instance in the same conceptual row). If an initial set operation (i.e. at row creation time) tries to set a value for an unknown or unsupported protocol, then a 'wrongValue' error must be returned. The value will be overwritten/set when a set operation is performed on the corresponding instance of usmUserCloneFrom. Once instantiated, the value of such an instance of this object can only be changed via a set operation to the value of the usmNoAuthProtocol. If a set operation tries to change the value of an existing instance of this object to any value other than usmNoAuthProtocol, then an 'inconsistentValue' error must be returned. If a set operation tries to set the value to the usmNoAuthProtocol while the usmUserPrivProtocol value in the same row is not equal to usmNoPrivProtocol, then an 'inconsistentValue' error must be returned. That means that an SNMP command generator application must first ensure that the usmUserPrivProtocol is set to the usmNoPrivProtocol value before it can set the usmUserAuthProtocol value to usmNoAuthProtocol. ") usmUserAuthKeyChange = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 6), KeyChange().clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: usmUserAuthKeyChange.setDescription("An object, which when modified, causes the secret\n authentication key used for messages sent on behalf\n of this user to/from the SNMP engine identified by\n usmUserEngineID, to be modified via a one-way\n function.\n\n The associated protocol is the usmUserAuthProtocol.\n The associated secret key is the user's secret\n authentication key (authKey). The associated hash\n algorithm is the algorithm used by the user's\n usmUserAuthProtocol.\n\n When creating a new user, it is an 'inconsistentName'\n error for a set operation to refer to this object\n unless it is previously or concurrently initialized\n through a set operation on the corresponding instance\n of usmUserCloneFrom.\n\n When the value of the corresponding usmUserAuthProtocol\n is usmNoAuthProtocol, then a set is successful, but\n effectively is a no-op.\n\n When this object is read, the zero-length (empty)\n string is returned.\n\n The recommended way to do a key change is as follows:\n\n 1) GET(usmUserSpinLock.0) and save in sValue.\n 2) generate the keyChange value based on the old\n (existing) secret key and the new secret key,\n let us call this kcValue.\n\n If you do the key change on behalf of another user:\n\n 3) SET(usmUserSpinLock.0=sValue,\n usmUserAuthKeyChange=kcValue\n usmUserPublic=randomValue)\n\n If you do the key change for yourself:\n\n 4) SET(usmUserSpinLock.0=sValue,\n usmUserOwnAuthKeyChange=kcValue\n usmUserPublic=randomValue)\n\n If you get a response with error-status of noError,\n then the SET succeeded and the new key is active.\n If you do not get a response, then you can issue a\n GET(usmUserPublic) and check if the value is equal\n to the randomValue you did send in the SET. If so, then\n the key change succeeded and the new key is active\n (probably the response got lost). If not, then the SET\n request probably never reached the target and so you\n can start over with the procedure above.\n ") +if mibBuilder.loadTexts: usmUserAuthKeyChange.setStatus('current') +if mibBuilder.loadTexts: usmUserAuthKeyChange.setDescription("An object, which when modified, causes the secret authentication key used for messages sent on behalf of this user to/from the SNMP engine identified by usmUserEngineID, to be modified via a one-way function. The associated protocol is the usmUserAuthProtocol. The associated secret key is the user's secret authentication key (authKey). The associated hash algorithm is the algorithm used by the user's usmUserAuthProtocol. When creating a new user, it is an 'inconsistentName' error for a set operation to refer to this object unless it is previously or concurrently initialized through a set operation on the corresponding instance of usmUserCloneFrom. When the value of the corresponding usmUserAuthProtocol is usmNoAuthProtocol, then a set is successful, but effectively is a no-op. When this object is read, the zero-length (empty) string is returned. The recommended way to do a key change is as follows: 1) GET(usmUserSpinLock.0) and save in sValue. 2) generate the keyChange value based on the old (existing) secret key and the new secret key, let us call this kcValue. If you do the key change on behalf of another user: 3) SET(usmUserSpinLock.0=sValue, usmUserAuthKeyChange=kcValue usmUserPublic=randomValue) If you do the key change for yourself: 4) SET(usmUserSpinLock.0=sValue, usmUserOwnAuthKeyChange=kcValue usmUserPublic=randomValue) If you get a response with error-status of noError, then the SET succeeded and the new key is active. If you do not get a response, then you can issue a GET(usmUserPublic) and check if the value is equal to the randomValue you did send in the SET. If so, then the key change succeeded and the new key is active (probably the response got lost). If not, then the SET request probably never reached the target and so you can start over with the procedure above. ") usmUserOwnAuthKeyChange = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 7), KeyChange().clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: usmUserOwnAuthKeyChange.setDescription("Behaves exactly as usmUserAuthKeyChange, with one\n notable difference: in order for the set operation\n to succeed, the usmUserName of the operation\n requester must match the usmUserName that\n indexes the row which is targeted by this\n operation.\n In addition, the USM security model must be\n used for this operation.\n\n The idea here is that access to this column can be\n public, since it will only allow a user to change\n his own secret authentication key (authKey).\n Note that this can only be done once the row is active.\n\n When a set is received and the usmUserName of the\n requester is not the same as the umsUserName that\n indexes the row which is targeted by this operation,\n then a 'noAccess' error must be returned.\n\n When a set is received and the security model in use\n is not USM, then a 'noAccess' error must be returned.\n ") +if mibBuilder.loadTexts: usmUserOwnAuthKeyChange.setStatus('current') +if mibBuilder.loadTexts: usmUserOwnAuthKeyChange.setDescription("Behaves exactly as usmUserAuthKeyChange, with one notable difference: in order for the set operation to succeed, the usmUserName of the operation requester must match the usmUserName that indexes the row which is targeted by this operation. In addition, the USM security model must be used for this operation. The idea here is that access to this column can be public, since it will only allow a user to change his own secret authentication key (authKey). Note that this can only be done once the row is active. When a set is received and the usmUserName of the requester is not the same as the umsUserName that indexes the row which is targeted by this operation, then a 'noAccess' error must be returned. When a set is received and the security model in use is not USM, then a 'noAccess' error must be returned. ") usmUserPrivProtocol = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 8), AutonomousType().clone((1, 3, 6, 1, 6, 3, 10, 1, 2, 1))).setMaxAccess("readcreate") -if mibBuilder.loadTexts: usmUserPrivProtocol.setDescription("An indication of whether messages sent on behalf of\n this user to/from the SNMP engine identified by\n usmUserEngineID, can be protected from disclosure,\n and if so, the type of privacy protocol which is used.\n\n An instance of this object is created concurrently\n with the creation of any other object instance for\n the same user (i.e., as part of the processing of\n the set operation which creates the first object\n instance in the same conceptual row).\n\n If an initial set operation (i.e. at row creation time)\n tries to set a value for an unknown or unsupported\n protocol, then a 'wrongValue' error must be returned.\n\n The value will be overwritten/set when a set operation\n is performed on the corresponding instance of\n usmUserCloneFrom.\n\n Once instantiated, the value of such an instance of\n this object can only be changed via a set operation to\n the value of the usmNoPrivProtocol.\n\n If a set operation tries to change the value of an\n existing instance of this object to any value other\n than usmNoPrivProtocol, then an 'inconsistentValue'\n error must be returned.\n\n Note that if any privacy protocol is used, then you\n must also use an authentication protocol. In other\n words, if usmUserPrivProtocol is set to anything else\n than usmNoPrivProtocol, then the corresponding instance\n of usmUserAuthProtocol cannot have a value of\n\n usmNoAuthProtocol. If it does, then an\n 'inconsistentValue' error must be returned.\n ") +if mibBuilder.loadTexts: usmUserPrivProtocol.setStatus('current') +if mibBuilder.loadTexts: usmUserPrivProtocol.setDescription("An indication of whether messages sent on behalf of this user to/from the SNMP engine identified by usmUserEngineID, can be protected from disclosure, and if so, the type of privacy protocol which is used. An instance of this object is created concurrently with the creation of any other object instance for the same user (i.e., as part of the processing of the set operation which creates the first object instance in the same conceptual row). If an initial set operation (i.e. at row creation time) tries to set a value for an unknown or unsupported protocol, then a 'wrongValue' error must be returned. The value will be overwritten/set when a set operation is performed on the corresponding instance of usmUserCloneFrom. Once instantiated, the value of such an instance of this object can only be changed via a set operation to the value of the usmNoPrivProtocol. If a set operation tries to change the value of an existing instance of this object to any value other than usmNoPrivProtocol, then an 'inconsistentValue' error must be returned. Note that if any privacy protocol is used, then you must also use an authentication protocol. In other words, if usmUserPrivProtocol is set to anything else than usmNoPrivProtocol, then the corresponding instance of usmUserAuthProtocol cannot have a value of usmNoAuthProtocol. If it does, then an 'inconsistentValue' error must be returned. ") usmUserPrivKeyChange = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 9), KeyChange().clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: usmUserPrivKeyChange.setDescription("An object, which when modified, causes the secret\n encryption key used for messages sent on behalf\n of this user to/from the SNMP engine identified by\n usmUserEngineID, to be modified via a one-way\n function.\n\n The associated protocol is the usmUserPrivProtocol.\n The associated secret key is the user's secret\n privacy key (privKey). The associated hash\n algorithm is the algorithm used by the user's\n usmUserAuthProtocol.\n\n When creating a new user, it is an 'inconsistentName'\n error for a set operation to refer to this object\n unless it is previously or concurrently initialized\n through a set operation on the corresponding instance\n of usmUserCloneFrom.\n\n When the value of the corresponding usmUserPrivProtocol\n is usmNoPrivProtocol, then a set is successful, but\n effectively is a no-op.\n\n When this object is read, the zero-length (empty)\n string is returned.\n See the description clause of usmUserAuthKeyChange for\n a recommended procedure to do a key change.\n ") +if mibBuilder.loadTexts: usmUserPrivKeyChange.setStatus('current') +if mibBuilder.loadTexts: usmUserPrivKeyChange.setDescription("An object, which when modified, causes the secret encryption key used for messages sent on behalf of this user to/from the SNMP engine identified by usmUserEngineID, to be modified via a one-way function. The associated protocol is the usmUserPrivProtocol. The associated secret key is the user's secret privacy key (privKey). The associated hash algorithm is the algorithm used by the user's usmUserAuthProtocol. When creating a new user, it is an 'inconsistentName' error for a set operation to refer to this object unless it is previously or concurrently initialized through a set operation on the corresponding instance of usmUserCloneFrom. When the value of the corresponding usmUserPrivProtocol is usmNoPrivProtocol, then a set is successful, but effectively is a no-op. When this object is read, the zero-length (empty) string is returned. See the description clause of usmUserAuthKeyChange for a recommended procedure to do a key change. ") usmUserOwnPrivKeyChange = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 10), KeyChange().clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: usmUserOwnPrivKeyChange.setDescription("Behaves exactly as usmUserPrivKeyChange, with one\n notable difference: in order for the Set operation\n to succeed, the usmUserName of the operation\n requester must match the usmUserName that indexes\n\n the row which is targeted by this operation.\n In addition, the USM security model must be\n used for this operation.\n\n The idea here is that access to this column can be\n public, since it will only allow a user to change\n his own secret privacy key (privKey).\n Note that this can only be done once the row is active.\n\n When a set is received and the usmUserName of the\n requester is not the same as the umsUserName that\n indexes the row which is targeted by this operation,\n then a 'noAccess' error must be returned.\n\n When a set is received and the security model in use\n is not USM, then a 'noAccess' error must be returned.\n ") -usmUserPublic = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 11), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0,32)).clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: usmUserPublic.setDescription("A publicly-readable value which can be written as part\n of the procedure for changing a user's secret\n authentication and/or privacy key, and later read to\n determine whether the change of the secret was\n effected.\n ") +if mibBuilder.loadTexts: usmUserOwnPrivKeyChange.setStatus('current') +if mibBuilder.loadTexts: usmUserOwnPrivKeyChange.setDescription("Behaves exactly as usmUserPrivKeyChange, with one notable difference: in order for the Set operation to succeed, the usmUserName of the operation requester must match the usmUserName that indexes the row which is targeted by this operation. In addition, the USM security model must be used for this operation. The idea here is that access to this column can be public, since it will only allow a user to change his own secret privacy key (privKey). Note that this can only be done once the row is active. When a set is received and the usmUserName of the requester is not the same as the umsUserName that indexes the row which is targeted by this operation, then a 'noAccess' error must be returned. When a set is received and the security model in use is not USM, then a 'noAccess' error must be returned. ") +usmUserPublic = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 11), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 32)).clone(hexValue="")).setMaxAccess("readcreate") +if mibBuilder.loadTexts: usmUserPublic.setStatus('current') +if mibBuilder.loadTexts: usmUserPublic.setDescription("A publicly-readable value which can be written as part of the procedure for changing a user's secret authentication and/or privacy key, and later read to determine whether the change of the secret was effected. ") usmUserStorageType = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 12), StorageType().clone('nonVolatile')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: usmUserStorageType.setDescription("The storage type for this conceptual row.\n\n Conceptual rows having the value 'permanent' must\n allow write-access at a minimum to:\n\n - usmUserAuthKeyChange, usmUserOwnAuthKeyChange\n and usmUserPublic for a user who employs\n authentication, and\n - usmUserPrivKeyChange, usmUserOwnPrivKeyChange\n and usmUserPublic for a user who employs\n privacy.\n\n Note that any user who employs authentication or\n privacy must allow its secret(s) to be updated and\n thus cannot be 'readOnly'.\n\n If an initial set operation tries to set the value to\n 'readOnly' for a user who employs authentication or\n privacy, then an 'inconsistentValue' error must be\n returned. Note that if the value has been previously\n set (implicit or explicit) to any value, then the rules\n as defined in the StorageType Textual Convention apply.\n\n It is an implementation issue to decide if a SET for\n a readOnly or permanent row is accepted at all. In some\n contexts this may make sense, in others it may not. If\n a SET for a readOnly or permanent row is not accepted\n at all, then a 'wrongValue' error must be returned.\n ") +if mibBuilder.loadTexts: usmUserStorageType.setStatus('current') +if mibBuilder.loadTexts: usmUserStorageType.setDescription("The storage type for this conceptual row. Conceptual rows having the value 'permanent' must allow write-access at a minimum to: - usmUserAuthKeyChange, usmUserOwnAuthKeyChange and usmUserPublic for a user who employs authentication, and - usmUserPrivKeyChange, usmUserOwnPrivKeyChange and usmUserPublic for a user who employs privacy. Note that any user who employs authentication or privacy must allow its secret(s) to be updated and thus cannot be 'readOnly'. If an initial set operation tries to set the value to 'readOnly' for a user who employs authentication or privacy, then an 'inconsistentValue' error must be returned. Note that if the value has been previously set (implicit or explicit) to any value, then the rules as defined in the StorageType Textual Convention apply. It is an implementation issue to decide if a SET for a readOnly or permanent row is accepted at all. In some contexts this may make sense, in others it may not. If a SET for a readOnly or permanent row is not accepted at all, then a 'wrongValue' error must be returned. ") usmUserStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 13), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: usmUserStatus.setDescription("The status of this conceptual row.\n\n Until instances of all corresponding columns are\n appropriately configured, the value of the\n corresponding instance of the usmUserStatus column\n is 'notReady'.\n\n In particular, a newly created row for a user who\n employs authentication, cannot be made active until the\n corresponding usmUserCloneFrom and usmUserAuthKeyChange\n have been set.\n\n Further, a newly created row for a user who also\n employs privacy, cannot be made active until the\n usmUserPrivKeyChange has been set.\n\n The RowStatus TC [RFC2579] requires that this\n DESCRIPTION clause states under which circumstances\n other objects in this row can be modified:\n\n The value of this object has no effect on whether\n other objects in this conceptual row can be modified,\n except for usmUserOwnAuthKeyChange and\n usmUserOwnPrivKeyChange. For these 2 objects, the\n\n value of usmUserStatus MUST be active.\n ") +if mibBuilder.loadTexts: usmUserStatus.setStatus('current') +if mibBuilder.loadTexts: usmUserStatus.setDescription("The status of this conceptual row. Until instances of all corresponding columns are appropriately configured, the value of the corresponding instance of the usmUserStatus column is 'notReady'. In particular, a newly created row for a user who employs authentication, cannot be made active until the corresponding usmUserCloneFrom and usmUserAuthKeyChange have been set. Further, a newly created row for a user who also employs privacy, cannot be made active until the usmUserPrivKeyChange has been set. The RowStatus TC [RFC2579] requires that this DESCRIPTION clause states under which circumstances other objects in this row can be modified: The value of this object has no effect on whether other objects in this conceptual row can be modified, except for usmUserOwnAuthKeyChange and usmUserOwnPrivKeyChange. For these 2 objects, the value of usmUserStatus MUST be active. ") usmMIBCompliances = MibIdentifier((1, 3, 6, 1, 6, 3, 15, 2, 1)) usmMIBGroups = MibIdentifier((1, 3, 6, 1, 6, 3, 15, 2, 2)) -usmMIBCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 15, 2, 1, 1)).setObjects(*(("SNMP-USER-BASED-SM-MIB", "usmMIBBasicGroup"),)) -if mibBuilder.loadTexts: usmMIBCompliance.setDescription('The compliance statement for SNMP engines which\n implement the SNMP-USER-BASED-SM-MIB.\n ') -usmMIBBasicGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 15, 2, 2, 1)).setObjects(*(("SNMP-USER-BASED-SM-MIB", "usmStatsUnsupportedSecLevels"), ("SNMP-USER-BASED-SM-MIB", "usmStatsNotInTimeWindows"), ("SNMP-USER-BASED-SM-MIB", "usmStatsUnknownUserNames"), ("SNMP-USER-BASED-SM-MIB", "usmStatsUnknownEngineIDs"), ("SNMP-USER-BASED-SM-MIB", "usmStatsWrongDigests"), ("SNMP-USER-BASED-SM-MIB", "usmStatsDecryptionErrors"), ("SNMP-USER-BASED-SM-MIB", "usmUserSpinLock"), ("SNMP-USER-BASED-SM-MIB", "usmUserSecurityName"), ("SNMP-USER-BASED-SM-MIB", "usmUserCloneFrom"), ("SNMP-USER-BASED-SM-MIB", "usmUserAuthProtocol"), ("SNMP-USER-BASED-SM-MIB", "usmUserAuthKeyChange"), ("SNMP-USER-BASED-SM-MIB", "usmUserOwnAuthKeyChange"), ("SNMP-USER-BASED-SM-MIB", "usmUserPrivProtocol"), ("SNMP-USER-BASED-SM-MIB", "usmUserPrivKeyChange"), ("SNMP-USER-BASED-SM-MIB", "usmUserOwnPrivKeyChange"), ("SNMP-USER-BASED-SM-MIB", "usmUserPublic"), ("SNMP-USER-BASED-SM-MIB", "usmUserStorageType"), ("SNMP-USER-BASED-SM-MIB", "usmUserStatus"),)) -if mibBuilder.loadTexts: usmMIBBasicGroup.setDescription('A collection of objects providing for configuration\n of an SNMP engine which implements the SNMP\n User-based Security Model.\n ') -mibBuilder.exportSymbols("SNMP-USER-BASED-SM-MIB", usmUserOwnPrivKeyChange=usmUserOwnPrivKeyChange, usmUser=usmUser, usmStatsUnsupportedSecLevels=usmStatsUnsupportedSecLevels, usmHMACSHAAuthProtocol=usmHMACSHAAuthProtocol, snmpUsmMIB=snmpUsmMIB, usmMIBConformance=usmMIBConformance, usmUserCloneFrom=usmUserCloneFrom, usmUserSecurityName=usmUserSecurityName, usmUserTable=usmUserTable, usmNoAuthProtocol=usmNoAuthProtocol, usmNoPrivProtocol=usmNoPrivProtocol, usmUserEntry=usmUserEntry, usmUserAuthProtocol=usmUserAuthProtocol, usmUserStatus=usmUserStatus, usmUserEngineID=usmUserEngineID, usmUserAuthKeyChange=usmUserAuthKeyChange, usmDESPrivProtocol=usmDESPrivProtocol, usmUserPrivProtocol=usmUserPrivProtocol, usmUserStorageType=usmUserStorageType, usmUserPublic=usmUserPublic, usmStatsWrongDigests=usmStatsWrongDigests, usmMIBGroups=usmMIBGroups, usmStats=usmStats, usmStatsNotInTimeWindows=usmStatsNotInTimeWindows, PYSNMP_MODULE_ID=snmpUsmMIB, usmMIBCompliance=usmMIBCompliance, usmStatsUnknownUserNames=usmStatsUnknownUserNames, usmStatsUnknownEngineIDs=usmStatsUnknownEngineIDs, usmMIBCompliances=usmMIBCompliances, KeyChange=KeyChange, usmMIBObjects=usmMIBObjects, usmUserName=usmUserName, usmUserOwnAuthKeyChange=usmUserOwnAuthKeyChange, usmHMACMD5AuthProtocol=usmHMACMD5AuthProtocol, usmMIBBasicGroup=usmMIBBasicGroup, usmStatsDecryptionErrors=usmStatsDecryptionErrors, usmUserSpinLock=usmUserSpinLock, usmUserPrivKeyChange=usmUserPrivKeyChange) +usmMIBCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 15, 2, 1, 1)).setObjects(("SNMP-USER-BASED-SM-MIB", "usmMIBBasicGroup")) +if mibBuilder.loadTexts: usmMIBCompliance.setDescription('The compliance statement for SNMP engines which implement the SNMP-USER-BASED-SM-MIB. ') +usmMIBBasicGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 15, 2, 2, 1)).setObjects(("SNMP-USER-BASED-SM-MIB", "usmStatsUnsupportedSecLevels"), ("SNMP-USER-BASED-SM-MIB", "usmStatsNotInTimeWindows"), ("SNMP-USER-BASED-SM-MIB", "usmStatsUnknownUserNames"), ("SNMP-USER-BASED-SM-MIB", "usmStatsUnknownEngineIDs"), ("SNMP-USER-BASED-SM-MIB", "usmStatsWrongDigests"), ("SNMP-USER-BASED-SM-MIB", "usmStatsDecryptionErrors"), ("SNMP-USER-BASED-SM-MIB", "usmUserSpinLock"), ("SNMP-USER-BASED-SM-MIB", "usmUserSecurityName"), ("SNMP-USER-BASED-SM-MIB", "usmUserCloneFrom"), ("SNMP-USER-BASED-SM-MIB", "usmUserAuthProtocol"), ("SNMP-USER-BASED-SM-MIB", "usmUserAuthKeyChange"), ("SNMP-USER-BASED-SM-MIB", "usmUserOwnAuthKeyChange"), ("SNMP-USER-BASED-SM-MIB", "usmUserPrivProtocol"), ("SNMP-USER-BASED-SM-MIB", "usmUserPrivKeyChange"), ("SNMP-USER-BASED-SM-MIB", "usmUserOwnPrivKeyChange"), ("SNMP-USER-BASED-SM-MIB", "usmUserPublic"), ("SNMP-USER-BASED-SM-MIB", "usmUserStorageType"), ("SNMP-USER-BASED-SM-MIB", "usmUserStatus")) +if mibBuilder.loadTexts: usmMIBBasicGroup.setDescription('A collection of objects providing for configuration of an SNMP engine which implements the SNMP User-based Security Model. ') +mibBuilder.exportSymbols("SNMP-USER-BASED-SM-MIB", usmUserStorageType=usmUserStorageType, PYSNMP_MODULE_ID=snmpUsmMIB, usmUserTable=usmUserTable, KeyChange=KeyChange, usmUserStatus=usmUserStatus, usmStatsNotInTimeWindows=usmStatsNotInTimeWindows, usmMIBGroups=usmMIBGroups, usmHMACSHAAuthProtocol=usmHMACSHAAuthProtocol, usmUserPrivKeyChange=usmUserPrivKeyChange, usmUserPublic=usmUserPublic, usmUserAuthProtocol=usmUserAuthProtocol, snmpUsmMIB=snmpUsmMIB, usmNoAuthProtocol=usmNoAuthProtocol, usmUserAuthKeyChange=usmUserAuthKeyChange, usmUserOwnAuthKeyChange=usmUserOwnAuthKeyChange, usmUserPrivProtocol=usmUserPrivProtocol, usmStatsUnknownUserNames=usmStatsUnknownUserNames, usmUserEngineID=usmUserEngineID, usmMIBConformance=usmMIBConformance, usmDESPrivProtocol=usmDESPrivProtocol, usmUser=usmUser, usmMIBCompliance=usmMIBCompliance, usmUserCloneFrom=usmUserCloneFrom, usmUserEntry=usmUserEntry, usmMIBBasicGroup=usmMIBBasicGroup, usmStatsUnsupportedSecLevels=usmStatsUnsupportedSecLevels, usmMIBObjects=usmMIBObjects, usmNoPrivProtocol=usmNoPrivProtocol, usmStatsWrongDigests=usmStatsWrongDigests, usmUserOwnPrivKeyChange=usmUserOwnPrivKeyChange, usmHMACMD5AuthProtocol=usmHMACMD5AuthProtocol, usmUserSecurityName=usmUserSecurityName, usmStatsUnknownEngineIDs=usmStatsUnknownEngineIDs, usmUserSpinLock=usmUserSpinLock, usmStats=usmStats, usmUserName=usmUserName, usmMIBCompliances=usmMIBCompliances, usmStatsDecryptionErrors=usmStatsDecryptionErrors) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-USM-AES-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-USM-AES-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-USM-AES-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-USM-AES-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,27 +1,30 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMP-USM-AES-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/SNMP-USM-AES-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 23:11:55 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module SNMP-USM-AES-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-USM-AES-MIB +# Produced by pysmi-0.1.3 at Tue Apr 18 00:49:58 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( snmpPrivProtocols, ) = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "snmpPrivProtocols") -( NotificationGroup, ModuleCompliance, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, iso, Gauge32, snmpModules, ModuleIdentity, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "iso", "Gauge32", "snmpModules", "ModuleIdentity", "ObjectIdentity", "Bits", "Counter32") -( DisplayString, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") -snmpUsmAesMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 20)).setRevisions(("2004-06-14 00:00",)) +OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ValueSizeConstraint, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsIntersection") +snmpPrivProtocols, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "snmpPrivProtocols") +NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") +Counter32, iso, ModuleIdentity, IpAddress, MibIdentifier, Integer32, TimeTicks, snmpModules, Bits, Gauge32, NotificationType, ObjectIdentity, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "iso", "ModuleIdentity", "IpAddress", "MibIdentifier", "Integer32", "TimeTicks", "snmpModules", "Bits", "Gauge32", "NotificationType", "ObjectIdentity", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64") +DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") +snmpUsmAesMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 20)) +if mibBuilder.loadTexts: snmpUsmAesMIB.setRevisions(('2004-06-14 00:00',)) if mibBuilder.loadTexts: snmpUsmAesMIB.setLastUpdated('200406140000Z') if mibBuilder.loadTexts: snmpUsmAesMIB.setOrganization('IETF') -if mibBuilder.loadTexts: snmpUsmAesMIB.setContactInfo('Uri Blumenthal\n Lucent Technologies / Bell Labs\n 67 Whippany Rd.\n 14D-318\n Whippany, NJ 07981, USA\n 973-386-2163\n uri@bell-labs.com\n\n Fabio Maino\n Andiamo Systems, Inc.\n 375 East Tasman Drive\n San Jose, CA 95134, USA\n 408-853-7530\n fmaino@andiamo.com\n\n Keith McCloghrie\n Cisco Systems, Inc.\n 170 West Tasman Drive\n San Jose, CA 95134-1706, USA\n\n 408-526-5260\n kzm@cisco.com') -if mibBuilder.loadTexts: snmpUsmAesMIB.setDescription("Definitions of Object Identities needed for\n the use of AES by SNMP's User-based Security\n Model.\n\n Copyright (C) The Internet Society (2004).\n\n This version of this MIB module is part of RFC 3826;\n see the RFC itself for full legal notices.\n Supplementary information may be available on\n http://www.ietf.org/copyrights/ianamib.html.") +if mibBuilder.loadTexts: snmpUsmAesMIB.setContactInfo('Uri Blumenthal Lucent Technologies / Bell Labs 67 Whippany Rd. 14D-318 Whippany, NJ 07981, USA 973-386-2163 uri@bell-labs.com Fabio Maino Andiamo Systems, Inc. 375 East Tasman Drive San Jose, CA 95134, USA 408-853-7530 fmaino@andiamo.com Keith McCloghrie Cisco Systems, Inc. 170 West Tasman Drive San Jose, CA 95134-1706, USA 408-526-5260 kzm@cisco.com') +if mibBuilder.loadTexts: snmpUsmAesMIB.setDescription("Definitions of Object Identities needed for the use of AES by SNMP's User-based Security Model. Copyright (C) The Internet Society (2004). This version of this MIB module is part of RFC 3826; see the RFC itself for full legal notices. Supplementary information may be available on http://www.ietf.org/copyrights/ianamib.html.") usmAesCfb128Protocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 2, 4)) +if mibBuilder.loadTexts: usmAesCfb128Protocol.setStatus('current') if mibBuilder.loadTexts: usmAesCfb128Protocol.setDescription('The CFB128-AES-128 Privacy Protocol.') +if mibBuilder.loadTexts: usmAesCfb128Protocol.setReference('- Specification for the ADVANCED ENCRYPTION STANDARD. Federal Information Processing Standard (FIPS) Publication 197. (November 2001). - Dworkin, M., NIST Recommendation for Block Cipher Modes of Operation, Methods and Techniques. NIST Special Publication 800-38A (December 2001). ') mibBuilder.exportSymbols("SNMP-USM-AES-MIB", usmAesCfb128Protocol=usmAesCfb128Protocol, snmpUsmAesMIB=snmpUsmAesMIB, PYSNMP_MODULE_ID=snmpUsmAesMIB) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-USM-HMAC-SHA2-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-USM-HMAC-SHA2-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-USM-HMAC-SHA2-MIB.py 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-USM-HMAC-SHA2-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,37 @@ +# +# PySNMP MIB module SNMP-USM-HMAC-SHA2-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-USM-HMAC-SHA2-MIB +# Produced by pysmi-0.1.4 at Thu Aug 3 02:14:32 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) +# +OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ValueSizeConstraint, SingleValueConstraint, ConstraintsUnion, ConstraintsIntersection, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ConstraintsIntersection", "ValueRangeConstraint") +snmpAuthProtocols, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "snmpAuthProtocols") +NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") +Counter32, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, ObjectIdentity, TimeTicks, Gauge32, Unsigned32, MibIdentifier, mib_2, iso, ModuleIdentity, NotificationType, IpAddress, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "ObjectIdentity", "TimeTicks", "Gauge32", "Unsigned32", "MibIdentifier", "mib-2", "iso", "ModuleIdentity", "NotificationType", "IpAddress", "Integer32") +TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") +snmpUsmHmacSha2MIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 235)) +if mibBuilder.loadTexts: snmpUsmHmacSha2MIB.setRevisions(('2016-04-18 00:00', '2015-10-14 00:00',)) +if mibBuilder.loadTexts: snmpUsmHmacSha2MIB.setLastUpdated('201604180000Z') +if mibBuilder.loadTexts: snmpUsmHmacSha2MIB.setOrganization('SNMPv3 Working Group') +if mibBuilder.loadTexts: snmpUsmHmacSha2MIB.setContactInfo('WG email: OPSAWG@ietf.org Subscribe: https://www.ietf.org/mailman/listinfo/opsawg Editor: Johannes Merkle secunet Security Networks Postal: Mergenthaler Allee 77 D-65760 Eschborn Germany Phone: +49 20154543091 Email: johannes.merkle@secunet.com Co-Editor: Manfred Lochter Bundesamt fuer Sicherheit in der Informationstechnik (BSI) Postal: Postfach 200363 D-53133 Bonn Germany Phone: +49 228 9582 5643 Email: manfred.lochter@bsi.bund.de') +if mibBuilder.loadTexts: snmpUsmHmacSha2MIB.setDescription("Definitions of Object Identities needed for the use of HMAC-SHA2 Authentication Protocols by SNMP's User-based Security Model. Copyright (c) 2016 IETF Trust and the persons identified as authors of the code. All rights reserved. Redistribution and use in source and binary forms, with or without modification, is permitted pursuant to, and subject to the license terms contained in, the Simplified BSD License set forth in Section 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info).") +usmHMAC128SHA224AuthProtocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 1, 4)) +if mibBuilder.loadTexts: usmHMAC128SHA224AuthProtocol.setStatus('current') +if mibBuilder.loadTexts: usmHMAC128SHA224AuthProtocol.setDescription('The Authentication Protocol usmHMAC128SHA224AuthProtocol uses HMAC-SHA-224 and truncates output to 128 bits.') +if mibBuilder.loadTexts: usmHMAC128SHA224AuthProtocol.setReference('- Krawczyk, H., Bellare, M., and R. Canetti, HMAC: Keyed-Hashing for Message Authentication, RFC 2104. - National Institute of Standards and Technology, Secure Hash Standard (SHS), FIPS PUB 180-4, 2012.') +usmHMAC192SHA256AuthProtocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 1, 5)) +if mibBuilder.loadTexts: usmHMAC192SHA256AuthProtocol.setStatus('current') +if mibBuilder.loadTexts: usmHMAC192SHA256AuthProtocol.setDescription('The Authentication Protocol usmHMAC192SHA256AuthProtocol uses HMAC-SHA-256 and truncates output to 192 bits.') +if mibBuilder.loadTexts: usmHMAC192SHA256AuthProtocol.setReference('- Krawczyk, H., Bellare, M., and R. Canetti, HMAC: Keyed-Hashing for Message Authentication, RFC 2104. - National Institute of Standards and Technology, Secure Hash Standard (SHS), FIPS PUB 180-4, 2012.') +usmHMAC256SHA384AuthProtocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 1, 6)) +if mibBuilder.loadTexts: usmHMAC256SHA384AuthProtocol.setStatus('current') +if mibBuilder.loadTexts: usmHMAC256SHA384AuthProtocol.setDescription('The Authentication Protocol usmHMAC256SHA384AuthProtocol uses HMAC-SHA-384 and truncates output to 256 bits.') +if mibBuilder.loadTexts: usmHMAC256SHA384AuthProtocol.setReference('- Krawczyk, H., Bellare, M., and R. Canetti, HMAC: Keyed-Hashing for Message Authentication, RFC 2104. - National Institute of Standards and Technology, Secure Hash Standard (SHS), FIPS PUB 180-4, 2012.') +usmHMAC384SHA512AuthProtocol = ObjectIdentity((1, 3, 6, 1, 6, 3, 10, 1, 1, 7)) +if mibBuilder.loadTexts: usmHMAC384SHA512AuthProtocol.setStatus('current') +if mibBuilder.loadTexts: usmHMAC384SHA512AuthProtocol.setDescription('The Authentication Protocol usmHMAC384SHA512AuthProtocol uses HMAC-SHA-512 and truncates output to 384 bits.') +if mibBuilder.loadTexts: usmHMAC384SHA512AuthProtocol.setReference('- Krawczyk, H., Bellare, M., and R. Canetti, HMAC: Keyed-Hashing for Message Authentication, RFC 2104. - National Institute of Standards and Technology, Secure Hash Standard (SHS), FIPS PUB 180-4, 2012.') +mibBuilder.exportSymbols("SNMP-USM-HMAC-SHA2-MIB", usmHMAC256SHA384AuthProtocol=usmHMAC256SHA384AuthProtocol, usmHMAC192SHA256AuthProtocol=usmHMAC192SHA256AuthProtocol, usmHMAC384SHA512AuthProtocol=usmHMAC384SHA512AuthProtocol, PYSNMP_MODULE_ID=snmpUsmHmacSha2MIB, snmpUsmHmacSha2MIB=snmpUsmHmacSha2MIB, usmHMAC128SHA224AuthProtocol=usmHMAC128SHA224AuthProtocol) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMPv2-CONF.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMPv2-CONF.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMPv2-CONF.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMPv2-CONF.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,17 +1,38 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# +# PySNMP MIB module SNMPv2-CONF (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMPv2-CONF +# Produced by pysmi-0.1.3 at Tue Apr 18 00:51:39 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # MibNode, = mibBuilder.importSymbols('SNMPv2-SMI', 'MibNode') + class ObjectGroup(MibNode): + status = 'current' + objects = () + description = '' + + def getStatus(self): + return self.status + + def setStatus(self, v): + self.status = v + return self + def getObjects(self): return getattr(self, 'objects', ()) - def setObjects(self, *args): - self.objects = args + def setObjects(self, *args, **kwargs): + if kwargs.get('append'): + self.objects += args + else: + self.objects = args return self def getDescription(self): @@ -22,18 +43,33 @@ return self def asn1Print(self): - return '\ -OBJECT-GROUP\n\ - OBJECTS { %s }\n\ - DESCRIPTION \"%s\"\ -' % (', '.join([ x for x in self.getObjects() ]), self.getDescription()) + return """\ +OBJECT-GROUP + OBJECTS { %s } + DESCRIPTION "%s" +""" % (', '.join([x for x in self.getObjects()]), self.getDescription()) + class NotificationGroup(MibNode): + status = 'current' + objects = () + description = '' + + def getStatus(self): + return self.status + + def setStatus(self, v): + self.status = v + return self + def getObjects(self): return getattr(self, 'objects', ()) - def setObjects(self, *args): - self.objects = args + def setObjects(self, *args, **kwargs): + if kwargs.get('append'): + self.objects += args + else: + self.objects = args return self def getDescription(self): @@ -44,18 +80,33 @@ return self def asn1Print(self): - return '\ -NOTIFICATION-GROUP\n\ - NOTIFICATIONS { %s }\n\ - DESCRIPTION \"%s\"\ -' % (', '.join([ x for x in self.getObjects() ]), self.getDescription()) + return """\ +NOTIFICATION-GROUP + NOTIFICATIONS { %s } + DESCRIPTION "%s" +""" % (', '.join([x for x in self.getObjects()]), self.getDescription()) + class ModuleCompliance(MibNode): + status = 'current' + objects = () + description = '' + + def getStatus(self): + return self.status + + def setStatus(self, v): + self.status = v + return self + def getObjects(self): return getattr(self, 'objects', ()) - def setObjects(self, *args): - self.objects = args + def setObjects(self, *args, **kwargs): + if kwargs.get('append'): + self.objects += args + else: + self.objects = args return self def getDescription(self): @@ -66,13 +117,26 @@ return self def asn1Print(self): - return '\ -MODULE-COMPLIANCE\n\ - OBJECT { %s } \n\ - DESCRIPTION \"%s\"\n\ -' % (', '.join([ x for x in self.getObjects() ]), self.getDescription()) + return """\ +MODULE-COMPLIANCE + OBJECT { %s } + DESCRIPTION "%s" +""" % (', '.join([x for x in self.getObjects()]), self.getDescription()) + class AgentCapabilities(MibNode): + status = 'current' + description = '' + reference = '' + productRelease = '' + + def getStatus(self): + return self.status + + def setStatus(self, v): + self.status = v + return self + def getDescription(self): return getattr(self, 'description', '') @@ -80,10 +144,29 @@ self.description = v return self + def getReference(self): + return self.reference + + def setReference(self, v): + self.reference = v + return self + + def getProductRelease(self): + return self.productRelease + + def setProductRelease(self, v): + self.productRelease = v + return self + + # TODO: implement the rest of properties + def asn1Print(self): - return '\ -AGENT-CAPABILITIES\n\ - DESCRIPTION \"%s\"\n\ -' % self.getDescription() + return """\ +AGENT-CAPABILITIES + STATUS "%s" + PRODUCT-RELEASE "%s" + DESCRIPTION "%s" +""" % (self.getStatus(), self.getProductRelease(), self.getDescription()) + mibBuilder.exportSymbols('SNMPv2-CONF', ObjectGroup=ObjectGroup, NotificationGroup=NotificationGroup, ModuleCompliance=ModuleCompliance, AgentCapabilities=AgentCapabilities) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMPv2-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMPv2-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMPv2-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMPv2-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,153 +1,204 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMPv2-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/SNMPv2-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 23:15:24 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module SNMPv2-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMPv2-MIB +# Produced by pysmi-0.1.3 at Tue Apr 18 00:52:45 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( NotificationGroup, ModuleCompliance, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, mib_2, IpAddress, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, snmpModules, iso, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "mib-2", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "snmpModules", "iso", "ObjectIdentity", "Bits", "Counter32") -( DisplayString, TimeStamp, TextualConvention, TestAndIncr, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TimeStamp", "TextualConvention", "TestAndIncr") -snmpMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 1)).setRevisions(("2002-10-16 00:00", "1995-11-09 00:00", "1993-04-01 00:00",)) -if mibBuilder.loadTexts: snmpMIB.setLastUpdated('200210160000Z') +OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +SingleValueConstraint, ValueSizeConstraint, ConstraintsIntersection, ValueRangeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ValueRangeConstraint", "ConstraintsUnion") +ObjectGroup, ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "ModuleCompliance", "NotificationGroup") +mib_2, snmpModules, ModuleIdentity, Counter64, ObjectIdentity, Integer32, NotificationType, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, Bits, IpAddress, Gauge32, Unsigned32, TimeTicks, MibIdentifier = mibBuilder.importSymbols("SNMPv2-SMI", "mib-2", "snmpModules", "ModuleIdentity", "Counter64", "ObjectIdentity", "Integer32", "NotificationType", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "Bits", "IpAddress", "Gauge32", "Unsigned32", "TimeTicks", "MibIdentifier") +TextualConvention, TestAndIncr, TimeStamp, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "TestAndIncr", "TimeStamp", "DisplayString") +snmpMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 1)) +if mibBuilder.loadTexts: snmpMIB.setRevisions(('2000-08-09 20:17', '1995-11-09 00:00', '1993-04-01 00:00',)) +if mibBuilder.loadTexts: snmpMIB.setLastUpdated('200008092017Z') if mibBuilder.loadTexts: snmpMIB.setOrganization('IETF SNMPv3 Working Group') -if mibBuilder.loadTexts: snmpMIB.setContactInfo('WG-EMail: snmpv3@lists.tislabs.com\n Subscribe: snmpv3-request@lists.tislabs.com\n\n Co-Chair: Russ Mundy\n Network Associates Laboratories\n postal: 15204 Omega Drive, Suite 300\n Rockville, MD 20850-4601\n USA\n EMail: mundy@tislabs.com\n phone: +1 301 947-7107\n\n Co-Chair: David Harrington\n Enterasys Networks\n postal: 35 Industrial Way\n P. O. Box 5005\n Rochester, NH 03866-5005\n USA\n EMail: dbh@enterasys.com\n phone: +1 603 337-2614\n\n Editor: Randy Presuhn\n BMC Software, Inc.\n postal: 2141 North First Street\n San Jose, CA 95131\n USA\n EMail: randy_presuhn@bmc.com\n phone: +1 408 546-1006') -if mibBuilder.loadTexts: snmpMIB.setDescription('The MIB module for SNMP entities.\n\n Copyright (C) The Internet Society (2002). This\n version of this MIB module is part of RFC 3418;\n see the RFC itself for full legal notices.\n ') +if mibBuilder.loadTexts: snmpMIB.setContactInfo('WG-EMail: snmpv3@tis.com Subscribe: majordomo@tis.com In message body: subscribe snmpv3 Chair: Russ Mundy TIS Labs at Network Associates postal: 3060 Washington Rd Glenwood MD 21738 USA EMail: mundy@tislabs.com phone: +1 301 854-6889 Editor: Randy Presuhn BMC Software, Inc. postal: 2141 North First Street San Jose, CA 95131 USA EMail: randy_presuhn@bmc.com phone: +1 408 546-1006') +if mibBuilder.loadTexts: snmpMIB.setDescription('The MIB module for SNMP entities.') snmpMIBObjects = MibIdentifier((1, 3, 6, 1, 6, 3, 1, 1)) system = MibIdentifier((1, 3, 6, 1, 2, 1, 1)) -sysDescr = MibScalar((1, 3, 6, 1, 2, 1, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0,255))).setMaxAccess("readonly") -if mibBuilder.loadTexts: sysDescr.setDescription("A textual description of the entity. This value should\n include the full name and version identification of\n the system's hardware type, software operating-system,\n and networking software.") +sysDescr = MibScalar((1, 3, 6, 1, 2, 1, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") +if mibBuilder.loadTexts: sysDescr.setStatus('current') +if mibBuilder.loadTexts: sysDescr.setDescription("A textual description of the entity. This value should include the full name and version identification of the system's hardware type, software operating-system, and networking software.") sysObjectID = MibScalar((1, 3, 6, 1, 2, 1, 1, 2), ObjectIdentifier()).setMaxAccess("readonly") -if mibBuilder.loadTexts: sysObjectID.setDescription("The vendor's authoritative identification of the\n network management subsystem contained in the entity.\n This value is allocated within the SMI enterprises\n subtree (1.3.6.1.4.1) and provides an easy and\n unambiguous means for determining `what kind of box' is\n being managed. For example, if vendor `Flintstones,\n Inc.' was assigned the subtree 1.3.6.1.4.1.424242,\n it could assign the identifier 1.3.6.1.4.1.424242.1.1\n to its `Fred Router'.") +if mibBuilder.loadTexts: sysObjectID.setStatus('current') +if mibBuilder.loadTexts: sysObjectID.setDescription("The vendor's authoritative identification of the network management subsystem contained in the entity. This value is allocated within the SMI enterprises subtree (1.3.6.1.4.1) and provides an easy and unambiguous means for determining `what kind of box' is being managed. For example, if vendor `Flintstones, Inc.' was assigned the subtree 1.3.6.1.4.1.424242, it could assign the identifier 1.3.6.1.4.1.424242.1.1 to its `Fred Router'.") sysUpTime = MibScalar((1, 3, 6, 1, 2, 1, 1, 3), TimeTicks()).setMaxAccess("readonly") -if mibBuilder.loadTexts: sysUpTime.setDescription('The time (in hundredths of a second) since the\n network management portion of the system was last\n re-initialized.') -sysContact = MibScalar((1, 3, 6, 1, 2, 1, 1, 4), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0,255))).setMaxAccess("readwrite") -if mibBuilder.loadTexts: sysContact.setDescription('The textual identification of the contact person for\n this managed node, together with information on how\n to contact this person. If no contact information is\n known, the value is the zero-length string.') -sysName = MibScalar((1, 3, 6, 1, 2, 1, 1, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0,255))).setMaxAccess("readwrite") -if mibBuilder.loadTexts: sysName.setDescription("An administratively-assigned name for this managed\n node. By convention, this is the node's fully-qualified\n domain name. If the name is unknown, the value is\n the zero-length string.") -sysLocation = MibScalar((1, 3, 6, 1, 2, 1, 1, 6), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0,255))).setMaxAccess("readwrite") -if mibBuilder.loadTexts: sysLocation.setDescription("The physical location of this node (e.g., 'telephone\n closet, 3rd floor'). If the location is unknown, the\n value is the zero-length string.") -sysServices = MibScalar((1, 3, 6, 1, 2, 1, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0,127))).setMaxAccess("readonly") -if mibBuilder.loadTexts: sysServices.setDescription('A value which indicates the set of services that this\n entity may potentially offer. The value is a sum.\n\n This sum initially takes the value zero. Then, for\n each layer, L, in the range 1 through 7, that this node\n performs transactions for, 2 raised to (L - 1) is added\n to the sum. For example, a node which performs only\n routing functions would have a value of 4 (2^(3-1)).\n In contrast, a node which is a host offering application\n services would have a value of 72 (2^(4-1) + 2^(7-1)).\n Note that in the context of the Internet suite of\n protocols, values should be calculated accordingly:\n\n layer functionality\n 1 physical (e.g., repeaters)\n 2 datalink/subnetwork (e.g., bridges)\n 3 internet (e.g., supports the IP)\n 4 end-to-end (e.g., supports the TCP)\n 7 applications (e.g., supports the SMTP)\n\n For systems including OSI protocols, layers 5 and 6\n may also be counted.') +if mibBuilder.loadTexts: sysUpTime.setStatus('current') +if mibBuilder.loadTexts: sysUpTime.setDescription('The time (in hundredths of a second) since the network management portion of the system was last re-initialized.') +sysContact = MibScalar((1, 3, 6, 1, 2, 1, 1, 4), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readwrite") +if mibBuilder.loadTexts: sysContact.setStatus('current') +if mibBuilder.loadTexts: sysContact.setDescription('The textual identification of the contact person for this managed node, together with information on how to contact this person. If no contact information is known, the value is the zero-length string.') +sysName = MibScalar((1, 3, 6, 1, 2, 1, 1, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readwrite") +if mibBuilder.loadTexts: sysName.setStatus('current') +if mibBuilder.loadTexts: sysName.setDescription("An administratively-assigned name for this managed node. By convention, this is the node's fully-qualified domain name. If the name is unknown, the value is the zero-length string.") +sysLocation = MibScalar((1, 3, 6, 1, 2, 1, 1, 6), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readwrite") +if mibBuilder.loadTexts: sysLocation.setStatus('current') +if mibBuilder.loadTexts: sysLocation.setDescription("The physical location of this node (e.g., 'telephone closet, 3rd floor'). If the location is unknown, the value is the zero-length string.") +sysServices = MibScalar((1, 3, 6, 1, 2, 1, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 127))).setMaxAccess("readonly") +if mibBuilder.loadTexts: sysServices.setStatus('current') +if mibBuilder.loadTexts: sysServices.setDescription('A value which indicates the set of services that this entity may potentially offer. The value is a sum. This sum initially takes the value zero. Then, for each layer, L, in the range 1 through 7, that this node performs transactions for, 2 raised to (L - 1) is added to the sum. For example, a node which performs only routing functions would have a value of 4 (2^(3-1)). In contrast, a node which is a host offering application services would have a value of 72 (2^(4-1) + 2^(7-1)). Note that in the context of the Internet suite of protocols, values should be calculated accordingly: layer functionality 1 physical (e.g., repeaters) 2 datalink/subnetwork (e.g., bridges) 3 internet (e.g., supports the IP) 4 end-to-end (e.g., supports the TCP) 7 applications (e.g., supports the SMTP) For systems including OSI protocols, layers 5 and 6 may also be counted.') sysORLastChange = MibScalar((1, 3, 6, 1, 2, 1, 1, 8), TimeStamp()).setMaxAccess("readonly") -if mibBuilder.loadTexts: sysORLastChange.setDescription('The value of sysUpTime at the time of the most recent\n change in state or value of any instance of sysORID.') +if mibBuilder.loadTexts: sysORLastChange.setStatus('current') +if mibBuilder.loadTexts: sysORLastChange.setDescription('The value of sysUpTime at the time of the most recent change in state or value of any instance of sysORID.') sysORTable = MibTable((1, 3, 6, 1, 2, 1, 1, 9), ) -if mibBuilder.loadTexts: sysORTable.setDescription('The (conceptual) table listing the capabilities of\n the local SNMP application acting as a command\n responder with respect to various MIB modules.\n SNMP entities having dynamically-configurable support\n of MIB modules will have a dynamically-varying number\n of conceptual rows.') +if mibBuilder.loadTexts: sysORTable.setStatus('current') +if mibBuilder.loadTexts: sysORTable.setDescription('The (conceptual) table listing the capabilities of the local SNMP application acting as a command responder with respect to various MIB modules. SNMP entities having dynamically-configurable support of MIB modules will have a dynamically-varying number of conceptual rows.') sysOREntry = MibTableRow((1, 3, 6, 1, 2, 1, 1, 9, 1), ).setIndexNames((0, "SNMPv2-MIB", "sysORIndex")) +if mibBuilder.loadTexts: sysOREntry.setStatus('current') if mibBuilder.loadTexts: sysOREntry.setDescription('An entry (conceptual row) in the sysORTable.') -sysORIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 1, 9, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1,2147483647))) -if mibBuilder.loadTexts: sysORIndex.setDescription('The auxiliary variable used for identifying instances\n of the columnar objects in the sysORTable.') +sysORIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 1, 9, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))) +if mibBuilder.loadTexts: sysORIndex.setStatus('current') +if mibBuilder.loadTexts: sysORIndex.setDescription('The auxiliary variable used for identifying instances of the columnar objects in the sysORTable.') sysORID = MibTableColumn((1, 3, 6, 1, 2, 1, 1, 9, 1, 2), ObjectIdentifier()).setMaxAccess("readonly") -if mibBuilder.loadTexts: sysORID.setDescription('An authoritative identification of a capabilities\n statement with respect to various MIB modules supported\n by the local SNMP application acting as a command\n responder.') +if mibBuilder.loadTexts: sysORID.setStatus('current') +if mibBuilder.loadTexts: sysORID.setDescription('An authoritative identification of a capabilities statement with respect to various MIB modules supported by the local SNMP application acting as a command responder.') sysORDescr = MibTableColumn((1, 3, 6, 1, 2, 1, 1, 9, 1, 3), DisplayString()).setMaxAccess("readonly") -if mibBuilder.loadTexts: sysORDescr.setDescription('A textual description of the capabilities identified\n by the corresponding instance of sysORID.') +if mibBuilder.loadTexts: sysORDescr.setStatus('current') +if mibBuilder.loadTexts: sysORDescr.setDescription('A textual description of the capabilities identified by the corresponding instance of sysORID.') sysORUpTime = MibTableColumn((1, 3, 6, 1, 2, 1, 1, 9, 1, 4), TimeStamp()).setMaxAccess("readonly") -if mibBuilder.loadTexts: sysORUpTime.setDescription('The value of sysUpTime at the time this conceptual\n row was last instantiated.') +if mibBuilder.loadTexts: sysORUpTime.setStatus('current') +if mibBuilder.loadTexts: sysORUpTime.setDescription('The value of sysUpTime at the time this conceptual row was last instantiated.') snmp = MibIdentifier((1, 3, 6, 1, 2, 1, 11)) snmpInPkts = MibScalar((1, 3, 6, 1, 2, 1, 11, 1), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInPkts.setDescription('The total number of messages delivered to the SNMP\n entity from the transport service.') +if mibBuilder.loadTexts: snmpInPkts.setStatus('current') +if mibBuilder.loadTexts: snmpInPkts.setDescription('The total number of messages delivered to the SNMP entity from the transport service.') snmpInBadVersions = MibScalar((1, 3, 6, 1, 2, 1, 11, 3), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInBadVersions.setDescription('The total number of SNMP messages which were delivered\n to the SNMP entity and were for an unsupported SNMP\n version.') +if mibBuilder.loadTexts: snmpInBadVersions.setStatus('current') +if mibBuilder.loadTexts: snmpInBadVersions.setDescription('The total number of SNMP messages which were delivered to the SNMP entity and were for an unsupported SNMP version.') snmpInBadCommunityNames = MibScalar((1, 3, 6, 1, 2, 1, 11, 4), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInBadCommunityNames.setDescription('The total number of community-based SNMP messages (for\n example, SNMPv1) delivered to the SNMP entity which\n used an SNMP community name not known to said entity.\n Also, implementations which authenticate community-based\n SNMP messages using check(s) in addition to matching\n the community name (for example, by also checking\n whether the message originated from a transport address\n allowed to use a specified community name) MAY include\n in this value the number of messages which failed the\n additional check(s). It is strongly RECOMMENDED that\n\n the documentation for any security model which is used\n to authenticate community-based SNMP messages specify\n the precise conditions that contribute to this value.') +if mibBuilder.loadTexts: snmpInBadCommunityNames.setStatus('current') +if mibBuilder.loadTexts: snmpInBadCommunityNames.setDescription('The total number of community-based SNMP messages (for example, SNMPv1) delivered to the SNMP entity which used an SNMP community name not known to said entity. Also, implementations which authenticate community-based SNMP messages using check(s) in addition to matching the community name (for example, by also checking whether the message originated from a transport address allowed to use a specified community name) MAY include in this value the number of messages which failed the additional check(s). It is strongly RECOMMENDED that the documentation for any security model which is used to authenticate community-based SNMP messages specify the precise conditions that contribute to this value.') snmpInBadCommunityUses = MibScalar((1, 3, 6, 1, 2, 1, 11, 5), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInBadCommunityUses.setDescription('The total number of community-based SNMP messages (for\n example, SNMPv1) delivered to the SNMP entity which\n represented an SNMP operation that was not allowed for\n the SNMP community named in the message. The precise\n conditions under which this counter is incremented\n (if at all) depend on how the SNMP entity implements\n its access control mechanism and how its applications\n interact with that access control mechanism. It is\n strongly RECOMMENDED that the documentation for any\n access control mechanism which is used to control access\n to and visibility of MIB instrumentation specify the\n precise conditions that contribute to this value.') +if mibBuilder.loadTexts: snmpInBadCommunityUses.setStatus('current') +if mibBuilder.loadTexts: snmpInBadCommunityUses.setDescription('The total number of community-based SNMP messages (for example, SNMPv1) delivered to the SNMP entity which represented an SNMP operation that was not allowed for the SNMP community named in the message. The precise conditions under which this counter is incremented (if at all) depend on how the SNMP entity implements its access control mechanism and how its applications interact with that access control mechanism. It is strongly RECOMMENDED that the documentation for any access control mechanism which is used to control access to and visibility of MIB instrumentation specify the precise conditions that contribute to this value.') snmpInASNParseErrs = MibScalar((1, 3, 6, 1, 2, 1, 11, 6), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInASNParseErrs.setDescription('The total number of ASN.1 or BER errors encountered by\n the SNMP entity when decoding received SNMP messages.') -snmpEnableAuthenTraps = MibScalar((1, 3, 6, 1, 2, 1, 11, 30), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2,)).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2),))).setMaxAccess("readwrite") -if mibBuilder.loadTexts: snmpEnableAuthenTraps.setDescription('Indicates whether the SNMP entity is permitted to\n generate authenticationFailure traps. The value of this\n object overrides any configuration information; as such,\n it provides a means whereby all authenticationFailure\n traps may be disabled.\n\n Note that it is strongly recommended that this object\n be stored in non-volatile memory so that it remains\n constant across re-initializations of the network\n management system.') +if mibBuilder.loadTexts: snmpInASNParseErrs.setStatus('current') +if mibBuilder.loadTexts: snmpInASNParseErrs.setDescription('The total number of ASN.1 or BER errors encountered by the SNMP entity when decoding received SNMP messages.') +snmpEnableAuthenTraps = MibScalar((1, 3, 6, 1, 2, 1, 11, 30), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") +if mibBuilder.loadTexts: snmpEnableAuthenTraps.setStatus('current') +if mibBuilder.loadTexts: snmpEnableAuthenTraps.setDescription('Indicates whether the SNMP entity is permitted to generate authenticationFailure traps. The value of this object overrides any configuration information; as such, it provides a means whereby all authenticationFailure traps may be disabled. Note that it is strongly recommended that this object be stored in non-volatile memory so that it remains constant across re-initializations of the network management system.') snmpSilentDrops = MibScalar((1, 3, 6, 1, 2, 1, 11, 31), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpSilentDrops.setDescription('The total number of Confirmed Class PDUs (such as\n GetRequest-PDUs, GetNextRequest-PDUs,\n GetBulkRequest-PDUs, SetRequest-PDUs, and\n InformRequest-PDUs) delivered to the SNMP entity which\n were silently dropped because the size of a reply\n containing an alternate Response Class PDU (such as a\n Response-PDU) with an empty variable-bindings field\n was greater than either a local constraint or the\n maximum message size associated with the originator of\n the request.') +if mibBuilder.loadTexts: snmpSilentDrops.setStatus('current') +if mibBuilder.loadTexts: snmpSilentDrops.setDescription('The total number of Confirmed Class PDUs (such as GetRequest-PDUs, GetNextRequest-PDUs, GetBulkRequest-PDUs, SetRequest-PDUs, and InformRequest-PDUs) delivered to the SNMP entity which were silently dropped because the size of a reply containing an alternate Response Class PDU (such as a Response-PDU) with an empty variable-bindings field was greater than either a local constraint or the maximum message size associated with the originator of the request.') snmpProxyDrops = MibScalar((1, 3, 6, 1, 2, 1, 11, 32), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpProxyDrops.setDescription('The total number of Confirmed Class PDUs\n (such as GetRequest-PDUs, GetNextRequest-PDUs,\n GetBulkRequest-PDUs, SetRequest-PDUs, and\n InformRequest-PDUs) delivered to the SNMP entity which\n were silently dropped because the transmission of\n the (possibly translated) message to a proxy target\n failed in a manner (other than a time-out) such that\n no Response Class PDU (such as a Response-PDU) could\n be returned.') +if mibBuilder.loadTexts: snmpProxyDrops.setStatus('current') +if mibBuilder.loadTexts: snmpProxyDrops.setDescription('The total number of Confirmed Class PDUs (such as GetRequest-PDUs, GetNextRequest-PDUs, GetBulkRequest-PDUs, SetRequest-PDUs, and InformRequest-PDUs) delivered to the SNMP entity which were silently dropped because the transmission of the (possibly translated) message to a proxy target failed in a manner (other than a time-out) such that no Response Class PDU (such as a Response-PDU) could be returned.') snmpTrap = MibIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 4)) snmpTrapOID = MibScalar((1, 3, 6, 1, 6, 3, 1, 1, 4, 1), ObjectIdentifier()).setMaxAccess("accessiblefornotify") -if mibBuilder.loadTexts: snmpTrapOID.setDescription('The authoritative identification of the notification\n currently being sent. This variable occurs as\n the second varbind in every SNMPv2-Trap-PDU and\n InformRequest-PDU.') +if mibBuilder.loadTexts: snmpTrapOID.setStatus('current') +if mibBuilder.loadTexts: snmpTrapOID.setDescription('The authoritative identification of the notification currently being sent. This variable occurs as the second varbind in every SNMPv2-Trap-PDU and InformRequest-PDU.') snmpTrapEnterprise = MibScalar((1, 3, 6, 1, 6, 3, 1, 1, 4, 3), ObjectIdentifier()).setMaxAccess("accessiblefornotify") -if mibBuilder.loadTexts: snmpTrapEnterprise.setDescription('The authoritative identification of the enterprise\n associated with the trap currently being sent. When an\n SNMP proxy agent is mapping an RFC1157 Trap-PDU\n into a SNMPv2-Trap-PDU, this variable occurs as the\n last varbind.') +if mibBuilder.loadTexts: snmpTrapEnterprise.setStatus('current') +if mibBuilder.loadTexts: snmpTrapEnterprise.setDescription('The authoritative identification of the enterprise associated with the trap currently being sent. When an SNMP proxy agent is mapping an RFC1157 Trap-PDU into a SNMPv2-Trap-PDU, this variable occurs as the last varbind.') snmpTraps = MibIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5)) -coldStart = NotificationType((1, 3, 6, 1, 6, 3, 1, 1, 5, 1)).setObjects(*()) -if mibBuilder.loadTexts: coldStart.setDescription('A coldStart trap signifies that the SNMP entity,\n supporting a notification originator application, is\n reinitializing itself and that its configuration may\n have been altered.') -warmStart = NotificationType((1, 3, 6, 1, 6, 3, 1, 1, 5, 2)).setObjects(*()) -if mibBuilder.loadTexts: warmStart.setDescription('A warmStart trap signifies that the SNMP entity,\n supporting a notification originator application,\n is reinitializing itself such that its configuration\n is unaltered.') -authenticationFailure = NotificationType((1, 3, 6, 1, 6, 3, 1, 1, 5, 5)).setObjects(*()) -if mibBuilder.loadTexts: authenticationFailure.setDescription('An authenticationFailure trap signifies that the SNMP\n entity has received a protocol message that is not\n properly authenticated. While all implementations\n of SNMP entities MAY be capable of generating this\n trap, the snmpEnableAuthenTraps object indicates\n whether this trap will be generated.') +coldStart = NotificationType((1, 3, 6, 1, 6, 3, 1, 1, 5, 1)).setObjects() +if mibBuilder.loadTexts: coldStart.setStatus('current') +if mibBuilder.loadTexts: coldStart.setDescription('A coldStart trap signifies that the SNMP entity, supporting a notification originator application, is reinitializing itself and that its configuration may have been altered.') +warmStart = NotificationType((1, 3, 6, 1, 6, 3, 1, 1, 5, 2)).setObjects() +if mibBuilder.loadTexts: warmStart.setStatus('current') +if mibBuilder.loadTexts: warmStart.setDescription('A warmStart trap signifies that the SNMP entity, supporting a notification originator application, is reinitializing itself such that its configuration is unaltered.') +authenticationFailure = NotificationType((1, 3, 6, 1, 6, 3, 1, 1, 5, 5)).setObjects() +if mibBuilder.loadTexts: authenticationFailure.setStatus('current') +if mibBuilder.loadTexts: authenticationFailure.setDescription('An authenticationFailure trap signifies that the SNMP entity has received a protocol message that is not properly authenticated. While all implementations of SNMP entities MAY be capable of generating this trap, the snmpEnableAuthenTraps object indicates whether this trap will be generated.') snmpSet = MibIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 6)) snmpSetSerialNo = MibScalar((1, 3, 6, 1, 6, 3, 1, 1, 6, 1), TestAndIncr()).setMaxAccess("readwrite") -if mibBuilder.loadTexts: snmpSetSerialNo.setDescription('An advisory lock used to allow several cooperating\n command generator applications to coordinate their\n use of the SNMP set operation.\n\n This object is used for coarse-grain coordination.\n To achieve fine-grain coordination, one or more similar\n objects might be defined within each MIB group, as\n appropriate.') +if mibBuilder.loadTexts: snmpSetSerialNo.setStatus('current') +if mibBuilder.loadTexts: snmpSetSerialNo.setDescription('An advisory lock used to allow several cooperating command generator applications to coordinate their use of the SNMP set operation. This object is used for coarse-grain coordination. To achieve fine-grain coordination, one or more similar objects might be defined within each MIB group, as appropriate.') snmpMIBConformance = MibIdentifier((1, 3, 6, 1, 6, 3, 1, 2)) snmpMIBCompliances = MibIdentifier((1, 3, 6, 1, 6, 3, 1, 2, 1)) snmpMIBGroups = MibIdentifier((1, 3, 6, 1, 6, 3, 1, 2, 2)) -snmpBasicCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 1, 2, 1, 2)).setObjects(*(("SNMPv2-MIB", "snmpGroup"), ("SNMPv2-MIB", "snmpSetGroup"), ("SNMPv2-MIB", "systemGroup"), ("SNMPv2-MIB", "snmpBasicNotificationsGroup"), ("SNMPv2-MIB", "snmpCommunityGroup"),)) -if mibBuilder.loadTexts: snmpBasicCompliance.setDescription('The compliance statement for SNMPv2 entities which\n implement the SNMPv2 MIB.\n\n This compliance statement is replaced by\n snmpBasicComplianceRev2.') -snmpBasicComplianceRev2 = ModuleCompliance((1, 3, 6, 1, 6, 3, 1, 2, 1, 3)).setObjects(*(("SNMPv2-MIB", "snmpGroup"), ("SNMPv2-MIB", "snmpSetGroup"), ("SNMPv2-MIB", "systemGroup"), ("SNMPv2-MIB", "snmpBasicNotificationsGroup"), ("SNMPv2-MIB", "snmpCommunityGroup"), ("SNMPv2-MIB", "snmpWarmStartNotificationGroup"),)) -if mibBuilder.loadTexts: snmpBasicComplianceRev2.setDescription('The compliance statement for SNMP entities which\n implement this MIB module.') -snmpGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 8)).setObjects(*(("SNMPv2-MIB", "snmpInPkts"), ("SNMPv2-MIB", "snmpInBadVersions"), ("SNMPv2-MIB", "snmpInASNParseErrs"), ("SNMPv2-MIB", "snmpSilentDrops"), ("SNMPv2-MIB", "snmpProxyDrops"), ("SNMPv2-MIB", "snmpEnableAuthenTraps"),)) -if mibBuilder.loadTexts: snmpGroup.setDescription('A collection of objects providing basic instrumentation\n and control of an SNMP entity.') -snmpCommunityGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 9)).setObjects(*(("SNMPv2-MIB", "snmpInBadCommunityNames"), ("SNMPv2-MIB", "snmpInBadCommunityUses"),)) -if mibBuilder.loadTexts: snmpCommunityGroup.setDescription('A collection of objects providing basic instrumentation\n of a SNMP entity which supports community-based\n authentication.') -snmpSetGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 5)).setObjects(*(("SNMPv2-MIB", "snmpSetSerialNo"),)) -if mibBuilder.loadTexts: snmpSetGroup.setDescription('A collection of objects which allow several cooperating\n command generator applications to coordinate their\n use of the set operation.') -systemGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 6)).setObjects(*(("SNMPv2-MIB", "sysDescr"), ("SNMPv2-MIB", "sysObjectID"), ("SNMPv2-MIB", "sysUpTime"), ("SNMPv2-MIB", "sysContact"), ("SNMPv2-MIB", "sysName"), ("SNMPv2-MIB", "sysLocation"), ("SNMPv2-MIB", "sysServices"), ("SNMPv2-MIB", "sysORLastChange"), ("SNMPv2-MIB", "sysORID"), ("SNMPv2-MIB", "sysORUpTime"), ("SNMPv2-MIB", "sysORDescr"),)) -if mibBuilder.loadTexts: systemGroup.setDescription('The system group defines objects which are common to all\n managed systems.') -snmpBasicNotificationsGroup = NotificationGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 7)).setObjects(*(("SNMPv2-MIB", "coldStart"), ("SNMPv2-MIB", "authenticationFailure"),)) -if mibBuilder.loadTexts: snmpBasicNotificationsGroup.setDescription('The basic notifications implemented by an SNMP entity\n supporting command responder applications.') -snmpWarmStartNotificationGroup = NotificationGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 11)).setObjects(*(("SNMPv2-MIB", "warmStart"),)) -if mibBuilder.loadTexts: snmpWarmStartNotificationGroup.setDescription('An additional notification for an SNMP entity supporting\n command responder applications, if it is able to reinitialize\n itself such that its configuration is unaltered.') -snmpNotificationGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 12)).setObjects(*(("SNMPv2-MIB", "snmpTrapOID"), ("SNMPv2-MIB", "snmpTrapEnterprise"),)) -if mibBuilder.loadTexts: snmpNotificationGroup.setDescription('These objects are required for entities\n which support notification originator applications.') +snmpBasicCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 1, 2, 1, 2)).setObjects(("SNMPv2-MIB", "snmpGroup"), ("SNMPv2-MIB", "snmpSetGroup"), ("SNMPv2-MIB", "systemGroup"), ("SNMPv2-MIB", "snmpBasicNotificationsGroup"), ("SNMPv2-MIB", "snmpCommunityGroup")) +if mibBuilder.loadTexts: snmpBasicCompliance.setDescription('The compliance statement for SNMPv2 entities which implement the SNMPv2 MIB. This compliance statement is replaced by snmpBasicComplianceRev2.') +snmpBasicComplianceRev2 = ModuleCompliance((1, 3, 6, 1, 6, 3, 1, 2, 1, 3)).setObjects(("SNMPv2-MIB", "snmpGroup"), ("SNMPv2-MIB", "snmpSetGroup"), ("SNMPv2-MIB", "systemGroup"), ("SNMPv2-MIB", "snmpBasicNotificationsGroup"), ("SNMPv2-MIB", "snmpCommunityGroup"), ("SNMPv2-MIB", "snmpWarmStartNotificationGroup")) +if mibBuilder.loadTexts: snmpBasicComplianceRev2.setDescription('The compliance statement for SNMP entities which implement this MIB module.') +snmpGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 8)).setObjects(("SNMPv2-MIB", "snmpInPkts"), ("SNMPv2-MIB", "snmpInBadVersions"), ("SNMPv2-MIB", "snmpInASNParseErrs"), ("SNMPv2-MIB", "snmpSilentDrops"), ("SNMPv2-MIB", "snmpProxyDrops"), ("SNMPv2-MIB", "snmpEnableAuthenTraps")) +if mibBuilder.loadTexts: snmpGroup.setDescription('A collection of objects providing basic instrumentation and control of an SNMP entity.') +snmpCommunityGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 9)).setObjects(("SNMPv2-MIB", "snmpInBadCommunityNames"), ("SNMPv2-MIB", "snmpInBadCommunityUses")) +if mibBuilder.loadTexts: snmpCommunityGroup.setDescription('A collection of objects providing basic instrumentation of a SNMP entity which supports community-based authentication.') +snmpSetGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 5)).setObjects(("SNMPv2-MIB", "snmpSetSerialNo")) +if mibBuilder.loadTexts: snmpSetGroup.setDescription('A collection of objects which allow several cooperating command generator applications to coordinate their use of the set operation.') +systemGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 6)).setObjects(("SNMPv2-MIB", "sysDescr"), ("SNMPv2-MIB", "sysObjectID"), ("SNMPv2-MIB", "sysUpTime"), ("SNMPv2-MIB", "sysContact"), ("SNMPv2-MIB", "sysName"), ("SNMPv2-MIB", "sysLocation"), ("SNMPv2-MIB", "sysServices"), ("SNMPv2-MIB", "sysORLastChange"), ("SNMPv2-MIB", "sysORID"), ("SNMPv2-MIB", "sysORUpTime"), ("SNMPv2-MIB", "sysORDescr")) +if mibBuilder.loadTexts: systemGroup.setDescription('The system group defines objects which are common to all managed systems.') +snmpBasicNotificationsGroup = NotificationGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 7)).setObjects(("SNMPv2-MIB", "coldStart"), ("SNMPv2-MIB", "authenticationFailure")) +if mibBuilder.loadTexts: snmpBasicNotificationsGroup.setDescription('The basic notifications implemented by an SNMP entity supporting command responder applications.') +snmpWarmStartNotificationGroup = NotificationGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 11)).setObjects(("SNMPv2-MIB", "warmStart")) +if mibBuilder.loadTexts: snmpWarmStartNotificationGroup.setDescription('An additional notification for an SNMP entity supporting command responder applications, if it is able to reinitialize itself such that its configuration is unaltered.') +snmpNotificationGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 12)).setObjects(("SNMPv2-MIB", "snmpTrapOID"), ("SNMPv2-MIB", "snmpTrapEnterprise")) +if mibBuilder.loadTexts: snmpNotificationGroup.setDescription('These objects are required for entities which support notification originator applications.') snmpOutPkts = MibScalar((1, 3, 6, 1, 2, 1, 11, 2), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpOutPkts.setDescription('The total number of SNMP Messages which were\n passed from the SNMP protocol entity to the\n transport service.') +if mibBuilder.loadTexts: snmpOutPkts.setStatus('obsolete') +if mibBuilder.loadTexts: snmpOutPkts.setDescription('The total number of SNMP Messages which were passed from the SNMP protocol entity to the transport service.') snmpInTooBigs = MibScalar((1, 3, 6, 1, 2, 1, 11, 8), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInTooBigs.setDescription("The total number of SNMP PDUs which were\n delivered to the SNMP protocol entity and for\n which the value of the error-status field was\n `tooBig'.") +if mibBuilder.loadTexts: snmpInTooBigs.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInTooBigs.setDescription("The total number of SNMP PDUs which were delivered to the SNMP protocol entity and for which the value of the error-status field was `tooBig'.") snmpInNoSuchNames = MibScalar((1, 3, 6, 1, 2, 1, 11, 9), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInNoSuchNames.setDescription("The total number of SNMP PDUs which were\n delivered to the SNMP protocol entity and for\n which the value of the error-status field was\n `noSuchName'.") +if mibBuilder.loadTexts: snmpInNoSuchNames.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInNoSuchNames.setDescription("The total number of SNMP PDUs which were delivered to the SNMP protocol entity and for which the value of the error-status field was `noSuchName'.") snmpInBadValues = MibScalar((1, 3, 6, 1, 2, 1, 11, 10), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInBadValues.setDescription("The total number of SNMP PDUs which were\n delivered to the SNMP protocol entity and for\n which the value of the error-status field was\n `badValue'.") +if mibBuilder.loadTexts: snmpInBadValues.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInBadValues.setDescription("The total number of SNMP PDUs which were delivered to the SNMP protocol entity and for which the value of the error-status field was `badValue'.") snmpInReadOnlys = MibScalar((1, 3, 6, 1, 2, 1, 11, 11), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInReadOnlys.setDescription("The total number valid SNMP PDUs which were delivered\n to the SNMP protocol entity and for which the value\n of the error-status field was `readOnly'. It should\n be noted that it is a protocol error to generate an\n SNMP PDU which contains the value `readOnly' in the\n error-status field, as such this object is provided\n as a means of detecting incorrect implementations of\n the SNMP.") +if mibBuilder.loadTexts: snmpInReadOnlys.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInReadOnlys.setDescription("The total number valid SNMP PDUs which were delivered to the SNMP protocol entity and for which the value of the error-status field was `readOnly'. It should be noted that it is a protocol error to generate an SNMP PDU which contains the value `readOnly' in the error-status field, as such this object is provided as a means of detecting incorrect implementations of the SNMP.") snmpInGenErrs = MibScalar((1, 3, 6, 1, 2, 1, 11, 12), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInGenErrs.setDescription("The total number of SNMP PDUs which were delivered\n to the SNMP protocol entity and for which the value\n of the error-status field was `genErr'.") +if mibBuilder.loadTexts: snmpInGenErrs.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInGenErrs.setDescription("The total number of SNMP PDUs which were delivered to the SNMP protocol entity and for which the value of the error-status field was `genErr'.") snmpInTotalReqVars = MibScalar((1, 3, 6, 1, 2, 1, 11, 13), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInTotalReqVars.setDescription('The total number of MIB objects which have been\n retrieved successfully by the SNMP protocol entity\n as the result of receiving valid SNMP Get-Request\n and Get-Next PDUs.') +if mibBuilder.loadTexts: snmpInTotalReqVars.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInTotalReqVars.setDescription('The total number of MIB objects which have been retrieved successfully by the SNMP protocol entity as the result of receiving valid SNMP Get-Request and Get-Next PDUs.') snmpInTotalSetVars = MibScalar((1, 3, 6, 1, 2, 1, 11, 14), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInTotalSetVars.setDescription('The total number of MIB objects which have been\n altered successfully by the SNMP protocol entity as\n the result of receiving valid SNMP Set-Request PDUs.') +if mibBuilder.loadTexts: snmpInTotalSetVars.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInTotalSetVars.setDescription('The total number of MIB objects which have been altered successfully by the SNMP protocol entity as the result of receiving valid SNMP Set-Request PDUs.') snmpInGetRequests = MibScalar((1, 3, 6, 1, 2, 1, 11, 15), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInGetRequests.setDescription('The total number of SNMP Get-Request PDUs which\n have been accepted and processed by the SNMP\n protocol entity.') +if mibBuilder.loadTexts: snmpInGetRequests.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInGetRequests.setDescription('The total number of SNMP Get-Request PDUs which have been accepted and processed by the SNMP protocol entity.') snmpInGetNexts = MibScalar((1, 3, 6, 1, 2, 1, 11, 16), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInGetNexts.setDescription('The total number of SNMP Get-Next PDUs which have been\n accepted and processed by the SNMP protocol entity.') +if mibBuilder.loadTexts: snmpInGetNexts.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInGetNexts.setDescription('The total number of SNMP Get-Next PDUs which have been accepted and processed by the SNMP protocol entity.') snmpInSetRequests = MibScalar((1, 3, 6, 1, 2, 1, 11, 17), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInSetRequests.setDescription('The total number of SNMP Set-Request PDUs which\n have been accepted and processed by the SNMP protocol\n entity.') +if mibBuilder.loadTexts: snmpInSetRequests.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInSetRequests.setDescription('The total number of SNMP Set-Request PDUs which have been accepted and processed by the SNMP protocol entity.') snmpInGetResponses = MibScalar((1, 3, 6, 1, 2, 1, 11, 18), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInGetResponses.setDescription('The total number of SNMP Get-Response PDUs which\n have been accepted and processed by the SNMP protocol\n entity.') +if mibBuilder.loadTexts: snmpInGetResponses.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInGetResponses.setDescription('The total number of SNMP Get-Response PDUs which have been accepted and processed by the SNMP protocol entity.') snmpInTraps = MibScalar((1, 3, 6, 1, 2, 1, 11, 19), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpInTraps.setDescription('The total number of SNMP Trap PDUs which have been\n accepted and processed by the SNMP protocol entity.') +if mibBuilder.loadTexts: snmpInTraps.setStatus('obsolete') +if mibBuilder.loadTexts: snmpInTraps.setDescription('The total number of SNMP Trap PDUs which have been accepted and processed by the SNMP protocol entity.') snmpOutTooBigs = MibScalar((1, 3, 6, 1, 2, 1, 11, 20), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpOutTooBigs.setDescription("The total number of SNMP PDUs which were generated\n by the SNMP protocol entity and for which the value\n of the error-status field was `tooBig.'") +if mibBuilder.loadTexts: snmpOutTooBigs.setStatus('obsolete') +if mibBuilder.loadTexts: snmpOutTooBigs.setDescription("The total number of SNMP PDUs which were generated by the SNMP protocol entity and for which the value of the error-status field was `tooBig.'") snmpOutNoSuchNames = MibScalar((1, 3, 6, 1, 2, 1, 11, 21), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpOutNoSuchNames.setDescription("The total number of SNMP PDUs which were generated\n by the SNMP protocol entity and for which the value\n of the error-status was `noSuchName'.") +if mibBuilder.loadTexts: snmpOutNoSuchNames.setStatus('obsolete') +if mibBuilder.loadTexts: snmpOutNoSuchNames.setDescription("The total number of SNMP PDUs which were generated by the SNMP protocol entity and for which the value of the error-status was `noSuchName'.") snmpOutBadValues = MibScalar((1, 3, 6, 1, 2, 1, 11, 22), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpOutBadValues.setDescription("The total number of SNMP PDUs which were generated\n by the SNMP protocol entity and for which the value\n of the error-status field was `badValue'.") +if mibBuilder.loadTexts: snmpOutBadValues.setStatus('obsolete') +if mibBuilder.loadTexts: snmpOutBadValues.setDescription("The total number of SNMP PDUs which were generated by the SNMP protocol entity and for which the value of the error-status field was `badValue'.") snmpOutGenErrs = MibScalar((1, 3, 6, 1, 2, 1, 11, 24), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpOutGenErrs.setDescription("The total number of SNMP PDUs which were generated\n by the SNMP protocol entity and for which the value\n of the error-status field was `genErr'.") +if mibBuilder.loadTexts: snmpOutGenErrs.setStatus('obsolete') +if mibBuilder.loadTexts: snmpOutGenErrs.setDescription("The total number of SNMP PDUs which were generated by the SNMP protocol entity and for which the value of the error-status field was `genErr'.") snmpOutGetRequests = MibScalar((1, 3, 6, 1, 2, 1, 11, 25), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpOutGetRequests.setDescription('The total number of SNMP Get-Request PDUs which\n have been generated by the SNMP protocol entity.') +if mibBuilder.loadTexts: snmpOutGetRequests.setStatus('obsolete') +if mibBuilder.loadTexts: snmpOutGetRequests.setDescription('The total number of SNMP Get-Request PDUs which have been generated by the SNMP protocol entity.') snmpOutGetNexts = MibScalar((1, 3, 6, 1, 2, 1, 11, 26), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpOutGetNexts.setDescription('The total number of SNMP Get-Next PDUs which have\n been generated by the SNMP protocol entity.') +if mibBuilder.loadTexts: snmpOutGetNexts.setStatus('obsolete') +if mibBuilder.loadTexts: snmpOutGetNexts.setDescription('The total number of SNMP Get-Next PDUs which have been generated by the SNMP protocol entity.') snmpOutSetRequests = MibScalar((1, 3, 6, 1, 2, 1, 11, 27), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpOutSetRequests.setDescription('The total number of SNMP Set-Request PDUs which\n have been generated by the SNMP protocol entity.') +if mibBuilder.loadTexts: snmpOutSetRequests.setStatus('obsolete') +if mibBuilder.loadTexts: snmpOutSetRequests.setDescription('The total number of SNMP Set-Request PDUs which have been generated by the SNMP protocol entity.') snmpOutGetResponses = MibScalar((1, 3, 6, 1, 2, 1, 11, 28), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpOutGetResponses.setDescription('The total number of SNMP Get-Response PDUs which\n have been generated by the SNMP protocol entity.') +if mibBuilder.loadTexts: snmpOutGetResponses.setStatus('obsolete') +if mibBuilder.loadTexts: snmpOutGetResponses.setDescription('The total number of SNMP Get-Response PDUs which have been generated by the SNMP protocol entity.') snmpOutTraps = MibScalar((1, 3, 6, 1, 2, 1, 11, 29), Counter32()).setMaxAccess("readonly") -if mibBuilder.loadTexts: snmpOutTraps.setDescription('The total number of SNMP Trap PDUs which have\n been generated by the SNMP protocol entity.') -snmpObsoleteGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 10)).setObjects(*(("SNMPv2-MIB", "snmpOutPkts"), ("SNMPv2-MIB", "snmpInTooBigs"), ("SNMPv2-MIB", "snmpInNoSuchNames"), ("SNMPv2-MIB", "snmpInBadValues"), ("SNMPv2-MIB", "snmpInReadOnlys"), ("SNMPv2-MIB", "snmpInGenErrs"), ("SNMPv2-MIB", "snmpInTotalReqVars"), ("SNMPv2-MIB", "snmpInTotalSetVars"), ("SNMPv2-MIB", "snmpInGetRequests"), ("SNMPv2-MIB", "snmpInGetNexts"), ("SNMPv2-MIB", "snmpInSetRequests"), ("SNMPv2-MIB", "snmpInGetResponses"), ("SNMPv2-MIB", "snmpInTraps"), ("SNMPv2-MIB", "snmpOutTooBigs"), ("SNMPv2-MIB", "snmpOutNoSuchNames"), ("SNMPv2-MIB", "snmpOutBadValues"), ("SNMPv2-MIB", "snmpOutGenErrs"), ("SNMPv2-MIB", "snmpOutGetRequests"), ("SNMPv2-MIB", "snmpOutGetNexts"), ("SNMPv2-MIB", "snmpOutSetRequests"), ("SNMPv2-MIB", "snmpOutGetResponses"), ("SNMPv2-MIB", "snmpOutTraps"),)) -if mibBuilder.loadTexts: snmpObsoleteGroup.setDescription('A collection of objects from RFC 1213 made obsolete\n by this MIB module.') -mibBuilder.exportSymbols("SNMPv2-MIB", snmpMIBGroups=snmpMIBGroups, snmpSetGroup=snmpSetGroup, snmpInTraps=snmpInTraps, sysOREntry=sysOREntry, snmpOutPkts=snmpOutPkts, snmpInTotalSetVars=snmpInTotalSetVars, snmpInGetNexts=snmpInGetNexts, sysLocation=sysLocation, snmpBasicNotificationsGroup=snmpBasicNotificationsGroup, snmpOutTooBigs=snmpOutTooBigs, systemGroup=systemGroup, snmpMIB=snmpMIB, snmpInSetRequests=snmpInSetRequests, snmpInBadVersions=snmpInBadVersions, snmpTrapEnterprise=snmpTrapEnterprise, sysName=sysName, snmpTrapOID=snmpTrapOID, snmpOutNoSuchNames=snmpOutNoSuchNames, snmpInReadOnlys=snmpInReadOnlys, snmpOutGetResponses=snmpOutGetResponses, snmpWarmStartNotificationGroup=snmpWarmStartNotificationGroup, warmStart=warmStart, sysUpTime=sysUpTime, snmpCommunityGroup=snmpCommunityGroup, snmpInTotalReqVars=snmpInTotalReqVars, sysORLastChange=sysORLastChange, snmpOutGetNexts=snmpOutGetNexts, snmpOutGetRequests=snmpOutGetRequests, snmpInBadCommunityUses=snmpInBadCommunityUses, snmpMIBCompliances=snmpMIBCompliances, snmpTrap=snmpTrap, PYSNMP_MODULE_ID=snmpMIB, coldStart=coldStart, authenticationFailure=authenticationFailure, snmpInGenErrs=snmpInGenErrs, snmpInGetRequests=snmpInGetRequests, snmpOutTraps=snmpOutTraps, snmpOutGenErrs=snmpOutGenErrs, snmpProxyDrops=snmpProxyDrops, snmpSet=snmpSet, snmpMIBObjects=snmpMIBObjects, sysContact=sysContact, snmpOutBadValues=snmpOutBadValues, sysServices=sysServices, snmpTraps=snmpTraps, sysObjectID=sysObjectID, snmpOutSetRequests=snmpOutSetRequests, snmpInNoSuchNames=snmpInNoSuchNames, snmpObsoleteGroup=snmpObsoleteGroup, sysDescr=sysDescr, snmpMIBConformance=snmpMIBConformance, snmpInPkts=snmpInPkts, snmpGroup=snmpGroup, snmpBasicCompliance=snmpBasicCompliance, snmpInBadCommunityNames=snmpInBadCommunityNames, system=system, sysORUpTime=sysORUpTime, snmpBasicComplianceRev2=snmpBasicComplianceRev2, sysORTable=sysORTable, snmpInBadValues=snmpInBadValues, sysORDescr=sysORDescr, sysORIndex=sysORIndex, snmpSetSerialNo=snmpSetSerialNo, sysORID=sysORID, snmpInGetResponses=snmpInGetResponses, snmp=snmp, snmpInTooBigs=snmpInTooBigs, snmpInASNParseErrs=snmpInASNParseErrs, snmpEnableAuthenTraps=snmpEnableAuthenTraps, snmpNotificationGroup=snmpNotificationGroup, snmpSilentDrops=snmpSilentDrops) +if mibBuilder.loadTexts: snmpOutTraps.setStatus('obsolete') +if mibBuilder.loadTexts: snmpOutTraps.setDescription('The total number of SNMP Trap PDUs which have been generated by the SNMP protocol entity.') +snmpObsoleteGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 1, 2, 2, 10)).setObjects(("SNMPv2-MIB", "snmpOutPkts"), ("SNMPv2-MIB", "snmpInTooBigs"), ("SNMPv2-MIB", "snmpInNoSuchNames"), ("SNMPv2-MIB", "snmpInBadValues"), ("SNMPv2-MIB", "snmpInReadOnlys"), ("SNMPv2-MIB", "snmpInGenErrs"), ("SNMPv2-MIB", "snmpInTotalReqVars"), ("SNMPv2-MIB", "snmpInTotalSetVars"), ("SNMPv2-MIB", "snmpInGetRequests"), ("SNMPv2-MIB", "snmpInGetNexts"), ("SNMPv2-MIB", "snmpInSetRequests"), ("SNMPv2-MIB", "snmpInGetResponses"), ("SNMPv2-MIB", "snmpInTraps"), ("SNMPv2-MIB", "snmpOutTooBigs"), ("SNMPv2-MIB", "snmpOutNoSuchNames"), ("SNMPv2-MIB", "snmpOutBadValues"), ("SNMPv2-MIB", "snmpOutGenErrs"), ("SNMPv2-MIB", "snmpOutGetRequests"), ("SNMPv2-MIB", "snmpOutGetNexts"), ("SNMPv2-MIB", "snmpOutSetRequests"), ("SNMPv2-MIB", "snmpOutGetResponses"), ("SNMPv2-MIB", "snmpOutTraps")) +if mibBuilder.loadTexts: snmpObsoleteGroup.setDescription('A collection of objects from RFC 1213 made obsolete by this MIB module.') +mibBuilder.exportSymbols("SNMPv2-MIB", snmpOutBadValues=snmpOutBadValues, coldStart=coldStart, snmpOutPkts=snmpOutPkts, snmpSilentDrops=snmpSilentDrops, snmpCommunityGroup=snmpCommunityGroup, sysORLastChange=sysORLastChange, sysName=sysName, snmpBasicNotificationsGroup=snmpBasicNotificationsGroup, systemGroup=systemGroup, snmpInNoSuchNames=snmpInNoSuchNames, snmpInTotalSetVars=snmpInTotalSetVars, snmpOutTooBigs=snmpOutTooBigs, snmpInBadCommunityNames=snmpInBadCommunityNames, snmpInASNParseErrs=snmpInASNParseErrs, snmpProxyDrops=snmpProxyDrops, snmpInPkts=snmpInPkts, snmpInSetRequests=snmpInSetRequests, snmpInTraps=snmpInTraps, sysORIndex=sysORIndex, snmpOutGetRequests=snmpOutGetRequests, PYSNMP_MODULE_ID=snmpMIB, snmpMIB=snmpMIB, snmpTrap=snmpTrap, sysOREntry=sysOREntry, snmp=snmp, snmpSet=snmpSet, warmStart=warmStart, snmpOutGetNexts=snmpOutGetNexts, snmpOutGetResponses=snmpOutGetResponses, snmpGroup=snmpGroup, sysLocation=sysLocation, snmpOutSetRequests=snmpOutSetRequests, snmpMIBGroups=snmpMIBGroups, snmpTrapOID=snmpTrapOID, system=system, snmpWarmStartNotificationGroup=snmpWarmStartNotificationGroup, snmpInBadCommunityUses=snmpInBadCommunityUses, snmpBasicComplianceRev2=snmpBasicComplianceRev2, sysContact=sysContact, snmpInGetNexts=snmpInGetNexts, sysORUpTime=sysORUpTime, snmpInGetResponses=snmpInGetResponses, snmpTraps=snmpTraps, snmpInGenErrs=snmpInGenErrs, snmpInReadOnlys=snmpInReadOnlys, snmpMIBCompliances=snmpMIBCompliances, snmpMIBObjects=snmpMIBObjects, snmpOutTraps=snmpOutTraps, snmpEnableAuthenTraps=snmpEnableAuthenTraps, snmpSetSerialNo=snmpSetSerialNo, snmpInTotalReqVars=snmpInTotalReqVars, snmpInBadVersions=snmpInBadVersions, snmpMIBConformance=snmpMIBConformance, sysORTable=sysORTable, sysORID=sysORID, snmpInTooBigs=snmpInTooBigs, sysORDescr=sysORDescr, sysUpTime=sysUpTime, sysDescr=sysDescr, snmpBasicCompliance=snmpBasicCompliance, snmpInGetRequests=snmpInGetRequests, snmpInBadValues=snmpInBadValues, snmpSetGroup=snmpSetGroup, sysServices=sysServices, snmpOutNoSuchNames=snmpOutNoSuchNames, sysObjectID=sysObjectID, authenticationFailure=authenticationFailure, snmpObsoleteGroup=snmpObsoleteGroup, snmpOutGenErrs=snmpOutGenErrs, snmpTrapEnterprise=snmpTrapEnterprise, snmpNotificationGroup=snmpNotificationGroup) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMPv2-SMI.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMPv2-SMI.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMPv2-SMI.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMPv2-SMI.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys import traceback @@ -10,6 +10,7 @@ from pysnmp.smi import exval, error from pysnmp.proto import rfc1902 from pysnmp import cache, debug +from pyasn1.type import univ from pyasn1.error import PyAsn1Error Integer, ObjectIdentifier = mibBuilder.importSymbols( @@ -18,9 +19,9 @@ (ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint) = mibBuilder.importSymbols( - "ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", - "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint" - ) + "ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", + "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint" +) # syntax of objects @@ -35,13 +36,16 @@ Opaque = rfc1902.Opaque Counter64 = rfc1902.Counter64 + class ExtUTCTime(OctetString): - subtypeSpec = OctetString.subtypeSpec+ConstraintsUnion(ValueSizeConstraint(11, 11), ValueSizeConstraint(13, 13)) + subtypeSpec = OctetString.subtypeSpec + ConstraintsUnion(ValueSizeConstraint(11, 11), ValueSizeConstraint(13, 13)) + # MIB tree foundation class -class MibNode: +class MibNode(object): label = '' + def __init__(self, name): self.name = name @@ -66,139 +70,194 @@ myClone.label = self.label return myClone + # definitions for information modules class ModuleIdentity(MibNode): + status = 'current' + lastUpdated = '' + organization = '' + contactInfo = '' + description = '' + revisions = () + revisionsDescriptions = () + + def getStatus(self): + return self.status + + def setStatus(self, v): + self.status = v + return self + def getLastUpdated(self): - return getattr(self, 'lastUpdated', '') + return self.lastUpdated def setLastUpdated(self, v): self.lastUpdated = v return self def getOrganization(self): - return getattr(self, 'organization', '') + return self.organization def setOrganization(self, v): self.organization = v return self def getContactInfo(self): - return getattr(self, 'contactInfo', '') + return self.contactInfo def setContactInfo(self, v): self.contactInfo = v return self def getDescription(self): - return getattr(self, 'description', '') + return self.description def setDescription(self, v): self.description = v return self def getRevisions(self): - return getattr(self, 'revisions', ()) + return self.revisions def setRevisions(self, args): self.revisions = args return self + def getRevisionsDescriptions(self): + return self.revisionsDescriptions + + def setRevisionsDescriptions(self, args): + self.revisionsDescriptions = args + return self + def asn1Print(self): - return '\ -MODULE-IDENTITY\n\ - LAST-UPDATED %s\n\ - ORGANIZATION \"%s\"\n\ - CONTACT-INFO \"%s\"\n\ - DESCRIPTION \"%s\"\n\ - %s\ -' % (self.getLastUpdated(), - self.getOrganization(), - self.getContactInfo(), - self.getDescription(), - ''.join(["REVISION \"%s\"\n" % x for x in self.getRevisions()])) + return """\ +MODULE-IDENTITY + LAST-UPDATED %s + ORGANIZATION "%s" + CONTACT-INFO "%s" + DESCRIPTION "%s" + %s""" % (self.getLastUpdated(), + self.getOrganization(), + self.getContactInfo(), + self.getDescription(), + ''.join(['REVISION "%s"\n' % x for x in self.getRevisions()])) + class ObjectIdentity(MibNode): + status = 'current' + description = '' + reference = '' + def getStatus(self): - return getattr(self, 'status', 'current') + return self.status def setStatus(self, v): self.status = v return self def getDescription(self): - return getattr(self, 'description', '') + return self.description def setDescription(self, v): self.description = v return self def getReference(self): - return getattr(self, 'reference', '') + return self.reference def setReference(self, v): self.reference = v return self def asn1Print(self): - return '\ -OBJECT-IDENTITY\n\ - STATUS %s\n\ - DESCRIPTION \"%s\"\n\ - REFERENCE \"%s\"\ -' % (self.getStatus(), - self.getDescription(), - self.getReference()) + return """\ +OBJECT-IDENTITY + STATUS %s + DESCRIPTION "%s" + REFERENCE "%s" +""" % (self.getStatus(), + self.getDescription(), + self.getReference()) + # definition for objects class NotificationType(MibNode): + objects = () + status = 'current' + description = '' + reference = '' + # retained for compatibility + revisions = () + def getObjects(self): - return getattr(self, 'objects', ()) + return self.objects - def setObjects(self, *args): - self.objects = args + def setObjects(self, *args, **kwargs): + if kwargs.get('append'): + self.objects += args + else: + self.objects = args return self def getStatus(self): - return getattr(self, 'status', 'current') + return self.status def setStatus(self, v): self.status = v return self def getDescription(self): - return getattr(self, 'description', '') + return self.description def setDescription(self, v): self.description = v return self + def getReference(self): + return self.reference + + def setReference(self, v): + self.reference = v + return self + + # This should not be here. Retained for compatibility. + def getRevisions(self): - return getattr(self, 'revisions', ()) + return self.revisions - def setRevisions(self, args): - self.revisions = args + def setRevisions(self, v): + self.revisions = v return self def asn1Print(self): - return '\ -NOTIFICATION-TYPE\n\ - OBJECTS { %s }\n\ - STATUS %s\n\ - DESCRIPTION \"%s\"\n\ - %s\ -' % (', '.join([x for x in self.getObjects()]), - self.getStatus(), - self.getDescription(), - ''.join(["REVISION \"%s\"\n" % x for x in self.getRevisions()])) + return """\ +NOTIFICATION-TYPE + OBJECTS { %s } + STATUS %s + DESCRIPTION "%s" + REFERENCE "%s" +""" % (', '.join([x for x in self.getObjects()]), + self.getStatus(), + self.getDescription(), + self.getReference()) + class MibIdentifier(MibNode): - def asn1Print(self): + @staticmethod + def asn1Print(): return 'OBJECT IDENTIFIER' + class ObjectType(MibNode): - maxAccess = None + units = '' + maxAccess = 'not-accessible' + status = 'current' + description = '' + reference = '' + def __init__(self, name, syntax=None): MibNode.__init__(self, name) self.syntax = syntax @@ -235,59 +294,60 @@ return self def getUnits(self): - return getattr(self, 'units', '') + return self.units def setUnits(self, v): self.units = v return self def getMaxAccess(self): - return getattr(self, 'maxAccess', 'not-accessible') + return self.maxAccess def setMaxAccess(self, v): self.maxAccess = v return self def getStatus(self): - return getattr(self, 'status', 'current') + return self.status def setStatus(self, v): self.status = v return self def getDescription(self): - return getattr(self, 'description', '') + return self.description def setDescription(self, v): self.description = v return self def getReference(self): - return getattr(self, 'reference', '') + return self.reference def setReference(self, v): self.reference = v return self def asn1Print(self): - return '\ -OBJECT-TYPE\n\ - SYNTAX %s\n\ - UNITS \"%s\"\n\ - MAX-ACCESS %s\n\ - STATUS %s\n\ - DESCRIPTION \"%s\"\n\ - REFERENCE \"%s\"\ -' % (self.getSyntax().__class__.__name__, - self.getUnits(), - self.getMaxAccess(), - self.getStatus(), - self.getDescription(), - self.getReference()) + return """ +OBJECT-TYPE + SYNTAX %s + UNITS "%s" + MAX-ACCESS %s + STATUS %s + DESCRIPTION "%s" + REFERENCE "%s" """ % (self.getSyntax().__class__.__name__, + self.getUnits(), + self.getMaxAccess(), + self.getStatus(), + self.getDescription(), + self.getReference()) + class MibTree(ObjectType): - branchVersionId = 0 # cnanges on tree structure change + branchVersionId = 0 # cnanges on tree structure change maxAccess = 'not-accessible' + def __init__(self, name, syntax=None): ObjectType.__init__(self, name, syntax) self._vars = OidOrderedDict() @@ -299,8 +359,8 @@ for subTree in subTrees: if subTree.name in self._vars: raise error.SmiError( - 'MIB subtree %s already registered at %s' % (subTree.name, self) - ) + 'MIB subtree %s already registered at %s' % (subTree.name, self) + ) self._vars[subTree.name] = subTree def unregisterSubtrees(self, *names): @@ -309,9 +369,9 @@ # This may fail if you fill a table by exporting MibScalarInstances # but later drop them through SNMP. if name not in self._vars: - raise error.SmiError( - 'MIB subtree %s not registered at %s' % (name, self) - ) + raise error.SmiError( + 'MIB subtree %s not registered at %s' % (name, self) + ) del self._vars[name] # @@ -335,6 +395,8 @@ # Start from the beginning if self._vars: first = list(self._vars.keys())[0] + else: + first = () if self._vars and name < first: return self._vars[first] else: @@ -375,13 +437,13 @@ if acFun: if self.maxAccess not in ('readonly', 'readwrite', 'readcreate') or \ - acFun(name, self.syntax, idx, 'read', acCtx): + acFun(name, self.syntax, idx, 'read', acCtx): raise error.NoAccessError(idx=idx, name=name) else: try: node = self.getBranch(name, idx) except (error.NoSuchInstanceError, error.NoSuchObjectError): - return # missing object is not an error here + return # missing object is not an error here else: node.readTest(name, val, idx, acInfo) @@ -463,7 +525,7 @@ # Make sure variable is writable if acFun: if self.maxAccess not in ('readwrite', 'readcreate') or \ - acFun(name, self.syntax, idx, 'write', acCtx): + acFun(name, self.syntax, idx, 'write', acCtx): raise error.NotWritableError(idx=idx, name=name) else: node = self.getBranch(name, idx) @@ -479,6 +541,7 @@ def writeUndo(self, name, val, idx, acInfo): self.getBranch(name, idx).writeUndo(name, val, idx, acInfo) + class MibScalar(MibTree): """Scalar MIB variable. Implements access control checking.""" maxAccess = 'readonly' @@ -547,7 +610,7 @@ def readGetNext(self, name, val, idx, acInfo, oName=None): (acFun, acCtx) = acInfo - # have to dublicate AC here as *Next code above treats + # have to duplicate AC here as *Next code above treats # noAccess as a noSuchObject at the Test stage, goes on # to Reading if acFun: @@ -565,12 +628,14 @@ raise error.NoAccessError(idx=idx, name=name) if acFun: if self.maxAccess not in ('readwrite', 'readcreate') or \ - acFun(name, self.syntax, idx, 'write', acCtx): + acFun(name, self.syntax, idx, 'write', acCtx): raise error.NotWritableError(idx=idx, name=name) MibTree.writeTest(self, name, val, idx, acInfo) + class MibScalarInstance(MibTree): """Scalar MIB variable instance. Implements read/write operations.""" + def __init__(self, typeName, instId, syntax): MibTree.__init__(self, typeName + instId, syntax) self.typeName = typeName @@ -581,11 +646,14 @@ # Managed object value access methods # + # noinspection PyUnusedLocal def getValue(self, name, idx): debug.logger & debug.flagIns and debug.logger('getValue: returning %r for %s' % (self.syntax, self.name)) return self.syntax.clone() def setValue(self, value, name, idx): + if value is None: + value = univ.noValue try: if hasattr(self.syntax, 'setValue'): return self.syntax.setValue(value) @@ -593,7 +661,8 @@ return self.syntax.clone(value) except PyAsn1Error: exc_t, exc_v, exc_tb = sys.exc_info() - debug.logger & debug.flagIns and debug.logger('setValue: %s=%r failed with traceback %s' % (self.name, value, traceback.format_exception(exc_t, exc_v, exc_tb))) + debug.logger & debug.flagIns and debug.logger('setValue: %s=%r failed with traceback %s' % ( + self.name, value, traceback.format_exception(exc_t, exc_v, exc_tb))) if isinstance(exc_v, error.TableRowManagement): raise exc_v else: @@ -655,6 +724,7 @@ # Write operation: two-phase commit + # noinspection PyAttributeOutsideInit def writeTest(self, name, val, idx, acInfo): # Make sure write's allowed if name == self.name: @@ -678,12 +748,14 @@ # Commit new value self.syntax = self.__newSyntax + # noinspection PyAttributeOutsideInit def writeCleanup(self, name, val, idx, acInfo): self.branchVersionId += 1 debug.logger & debug.flagIns and debug.logger('writeCleanup: %s=%r' % (name, val)) # Drop previous value self.__newSyntax = self.__oldSyntax = None + # noinspection PyAttributeOutsideInit def writeUndo(self, name, val, idx, acInfo): # Revive previous value self.syntax = self.__oldSyntax @@ -693,6 +765,7 @@ # Create operation + # noinspection PyUnusedLocal,PyAttributeOutsideInit def createTest(self, name, val, idx, acInfo): if name == self.name: try: @@ -723,6 +796,7 @@ # Destroy operation + # noinspection PyUnusedLocal,PyAttributeOutsideInit def destroyTest(self, name, val, idx, acInfo): if name == self.name: try: @@ -734,20 +808,24 @@ self.__newSyntax = why['syntax'] else: raise error.NoSuchInstanceError(idx=idx, name=name) + def destroyCommit(self, name, val, idx, acInfo): pass + # noinspection PyUnusedLocal def destroyCleanup(self, name, val, idx, acInfo): self.branchVersionId += 1 def destroyUndo(self, name, val, idx, acInfo): pass + # Conceptual table classes class MibTableColumn(MibScalar): """MIB table column. Manages a set of column instance variables""" protoInstance = MibScalarInstance + def __init__(self, name, syntax): MibScalar.__init__(self, name, syntax) self.__createdInstances = {} @@ -780,8 +858,9 @@ raise error.NoAccessError(idx=idx, name=name) if acFun: if val is not None and self.maxAccess != 'readcreate' or \ - acFun(name, self.syntax, idx, 'write', acCtx): - debug.logger & debug.flagACL and debug.logger('createTest: %s=%r %s at %s' % (name, val, self.maxAccess, self.name)) + acFun(name, self.syntax, idx, 'write', acCtx): + debug.logger & debug.flagACL and debug.logger( + 'createTest: %s=%r %s at %s' % (name, val, self.maxAccess, self.name)) raise error.NoCreationError(idx=idx, name=name) # Create instances if either it does not yet exist (row creation) # or a value is passed (multiple OIDs in SET PDU) @@ -794,14 +873,14 @@ def createCommit(self, name, val, idx, acInfo): # Commit new instance value - if name in self._vars: # XXX + if name in self._vars: # XXX if name in self.__createdInstances: self._vars[name].createCommit(name, val, idx, acInfo) return self.__createdInstances[name].createCommit(name, val, idx, acInfo) # ...commit new column instance self._vars[name], self.__createdInstances[name] = \ - self.__createdInstances[name], self._vars.get(name) + self.__createdInstances[name], self._vars.get(name) def createCleanup(self, name, val, idx, acInfo): # Drop previous column instance @@ -842,7 +921,7 @@ return if acFun: if val is not None and self.maxAccess != 'readcreate' or \ - acFun(name, self.syntax, idx, 'write', acCtx): + acFun(name, self.syntax, idx, 'write', acCtx): raise error.NoAccessError(idx=idx, name=name) self._vars[name].destroyTest(name, val, idx, acInfo) @@ -888,17 +967,18 @@ self.__rowOpWanted[name] = error.RowDestructionWanted() self.destroyTest(name, val, idx, acInfo) if name in self.__rowOpWanted: - debug.logger & debug.flagIns and debug.logger('%s flagged by %s=%r, exception %s' % (self.__rowOpWanted[name], name, val, sys.exc_info()[1])) + debug.logger & debug.flagIns and debug.logger( + '%s flagged by %s=%r, exception %s' % (self.__rowOpWanted[name], name, val, sys.exc_info()[1])) raise self.__rowOpWanted[name] def __delegateWrite(self, subAction, name, val, idx, acInfo): if name not in self.__rowOpWanted: - getattr(MibScalar, 'write'+subAction)(self, name, val, idx, acInfo) + getattr(MibScalar, 'write' + subAction)(self, name, val, idx, acInfo) return if isinstance(self.__rowOpWanted[name], error.RowCreationWanted): - getattr(self, 'create'+subAction)(name, val, idx, acInfo) + getattr(self, 'create' + subAction)(name, val, idx, acInfo) if isinstance(self.__rowOpWanted[name], error.RowDestructionWanted): - getattr(self, 'destroy'+subAction)(name, val, idx, acInfo) + getattr(self, 'destroy' + subAction)(name, val, idx, acInfo) def writeCommit(self, name, val, idx, acInfo): self.__delegateWrite('Commit', name, val, idx, acInfo) @@ -924,10 +1004,12 @@ debug.logger & debug.flagIns and debug.logger('%s dropped by %s=%r' % (e, name, val)) raise e + class MibTableRow(MibTree): """MIB table row (SMI 'Entry'). Manages a set of table columns. Implements row creation/destruction. """ + def __init__(self, name): MibTree.__init__(self, name) self.__idToIdxCache = cache.Cache() @@ -946,10 +1028,11 @@ __ipaddrTagSet = IpAddress.tagSet __bitsBaseTag = Bits.tagSet.getBaseTag() - def setFromName(self, obj, value, impliedFlag=None): + def setFromName(self, obj, value, impliedFlag=None, parentIndices=None): if not value: raise error.SmiError('Short OID for index %r' % (obj,)) - value = tuple(value) # possible ObjectIdentifiers + if hasattr(obj, 'cloneFromName'): + return obj.cloneFromName(value, impliedFlag, parentRow=self, parentIndices=parentIndices) baseTag = obj.getTagSet().getBaseTag() if baseTag == self.__intBaseTag: return obj.clone(value[0]), value[1:] @@ -958,26 +1041,29 @@ elif baseTag == self.__strBaseTag: # rfc1902, 7.7 if impliedFlag: - return obj.clone(value), () + return obj.clone(tuple(value)), () elif obj.isFixedLength(): l = obj.getFixedLength() - return obj.clone(value[:l]), value[l:] + return obj.clone(tuple(value[:l])), value[l:] else: - return obj.clone(value[1:value[0]+1]), value[value[0]+1:] + return obj.clone(tuple(value[1:value[0] + 1])), value[value[0] + 1:] elif baseTag == self.__oidBaseTag: if impliedFlag: return obj.clone(value), () else: - return obj.clone(value[1:value[0]+1]), value[value[0]+1:] + return obj.clone(value[1:value[0] + 1]), value[value[0] + 1:] # rfc2578, 7.1 elif baseTag == self.__bitsBaseTag: - return obj.clone(value[1:value[0]+1]), value[value[0]+1:] + return obj.clone(tuple(value[1:value[0] + 1])), value[value[0] + 1:] else: raise error.SmiError('Unknown value type for index %r' % (obj,)) - def getAsName(self, obj, impliedFlag=None): + def getAsName(self, obj, impliedFlag=None, parentIndices=None): + if hasattr(obj, 'cloneAsName'): + return obj.cloneAsName(impliedFlag, parentRow=self, parentIndices=parentIndices) baseTag = obj.getTagSet().getBaseTag() if baseTag == self.__intBaseTag: + # noinspection PyRedundantParentheses return (int(obj),) elif self.__ipaddrTagSet.isSuperTagSetOf(obj.getTagSet()): return obj.asNumbers() @@ -991,10 +1077,10 @@ if impliedFlag: return tuple(obj) else: - return (len(self.name),) + tuple(obj) + return (len(obj),) + tuple(obj) # rfc2578, 7.1 elif baseTag == self.__bitsBaseTag: - return (len(obj),) + obj.asNumbers() + return (len(obj),) + obj.asNumbers() else: raise error.SmiError('Unknown value type for index %r' % (obj,)) @@ -1002,16 +1088,19 @@ def announceManagementEvent(self, action, name, val, idx, acInfo): # Convert OID suffix into index vals - instId = name[len(self.name)+1:] + instId = name[len(self.name) + 1:] baseIndices = [] + indices = [] for impliedFlag, modName, symName in self.indexNames: mibObj, = mibBuilder.importSymbols(modName, symName) syntax, instId = self.setFromName(mibObj.syntax, instId, - impliedFlag) + impliedFlag, indices) if self.name == mibObj.name[:-1]: baseIndices.append((mibObj.name, syntax)) + indices.append(syntax) + if instId: raise error.SmiError('Excessive instance identifier sub-OIDs left at %s: %s' % (self, instId)) @@ -1031,27 +1120,29 @@ # Resolve indices intersection for impliedFlag, modName, symName in self.indexNames: mibObj, = mibBuilder.importSymbols(modName, symName) + parentIndices = [] for name, syntax in baseIndices: if name == mibObj.name: - newSuffix = newSuffix + self.getAsName(syntax, impliedFlag) + newSuffix += self.getAsName(syntax, impliedFlag, parentIndices) + parentIndices.append(syntax) if newSuffix: - debug.logger & debug.flagIns and debug.logger('receiveManagementEvent %s for suffix %s' % (action, newSuffix)) + debug.logger & debug.flagIns and debug.logger( + 'receiveManagementEvent %s for suffix %s' % (action, newSuffix)) self.__manageColumns(action, (), newSuffix, val, idx, acInfo) def registerAugmentions(self, *names): for modName, symName in names: if (modName, symName) in self.augmentingRows: raise error.SmiError( - 'Row %s already augmented by %s::%s' % \ - (self.name, modName, symName) + 'Row %s already augmented by %s::%s' % (self.name, modName, symName) ) self.augmentingRows[(modName, symName)] = 1 return self def setIndexNames(self, *names): for name in names: - self.indexNames = self.indexNames + (name,) + self.indexNames += (name,) return self def getIndexNames(self): @@ -1062,11 +1153,13 @@ # Build a map of index names and values for automatic initialization indexVals = {} instId = nameSuffix + indices = [] for impliedFlag, modName, symName in self.indexNames: mibObj, = mibBuilder.importSymbols(modName, symName) syntax, instId = self.setFromName(mibObj.syntax, instId, - impliedFlag) + impliedFlag, indices) indexVals[mibObj.name] = syntax + indices.append(syntax) for name, var in self._vars.items(): if name == excludeName: @@ -1078,24 +1171,25 @@ else: getattr(var, action)(name + nameSuffix, val, idx, acInfo) - debug.logger & debug.flagIns and debug.logger('__manageColumns: action %s name %s suffix %s %svalue %r' % (action, name, nameSuffix, name in indexVals and "index " or "", indexVals.get(name, val))) + debug.logger & debug.flagIns and debug.logger('__manageColumns: action %s name %s suffix %s %svalue %r' % ( + action, name, nameSuffix, name in indexVals and "index " or "", indexVals.get(name, val))) def __delegate(self, subAction, name, val, idx, acInfo): # Relay operation request to column, expect row operation request. rowIsActive = False try: - getattr(self.getBranch(name, idx), 'write'+subAction)( + getattr(self.getBranch(name, idx), 'write' + subAction)( name, val, idx, acInfo ) except error.RowCreationWanted: self.__manageColumns( - 'create'+subAction, name[:len(self.name)+1], - name[len(self.name)+1:], None, idx, acInfo + 'create' + subAction, name[:len(self.name) + 1], + name[len(self.name) + 1:], None, idx, acInfo ) self.announceManagementEvent( - 'create'+subAction, name, None, idx, acInfo + 'create' + subAction, name, None, idx, acInfo ) # watch for RowStatus == 'stActive' @@ -1103,12 +1197,12 @@ except error.RowDestructionWanted: self.__manageColumns( - 'destroy'+subAction, name[:len(self.name)+1], - name[len(self.name)+1:], None, idx, acInfo + 'destroy' + subAction, name[:len(self.name) + 1], + name[len(self.name) + 1:], None, idx, acInfo ) self.announceManagementEvent( - 'destroy'+subAction, name, None, idx, acInfo + 'destroy' + subAction, name, None, idx, acInfo ) return rowIsActive @@ -1120,7 +1214,7 @@ rowIsActive = self.__delegate('Commit', name, val, idx, acInfo) if rowIsActive: for mibNode in self._vars.values(): - colNode = mibNode.getNode(mibNode.name + name[len(self.name)+1:]) + colNode = mibNode.getNode(mibNode.name + name[len(self.name) + 1:]) if not colNode.syntax.hasValue(): raise error.InconsistentValueError(msg='Row consistency check failed for %r' % colNode) @@ -1144,37 +1238,52 @@ """Return index values for instance identification""" if instId in self.__idToIdxCache: return self.__idToIdxCache[instId] + indices = [] for impliedFlag, modName, symName in self.indexNames: mibObj, = mibBuilder.importSymbols(modName, symName) - syntax, instId = self.setFromName(mibObj.syntax, instId, impliedFlag) - indices.append(syntax) # to avoid cyclic refs + try: + syntax, instId = self.setFromName(mibObj.syntax, instId, impliedFlag, indices) + except PyAsn1Error: + debug.logger & debug.flagIns and debug.logger('error resolving table indices at %s, %s: %s' % (self.__class__.__name__, instId, sys.exc_info()[1])) + indices = [instId] + instId = () + break + + indices.append(syntax) # to avoid cyclic refs + if instId: raise error.SmiError( 'Excessive instance identifier sub-OIDs left at %s: %s' % (self, instId) ) + indices = tuple(indices) self.__idToIdxCache[instId] = indices + return indices def getInstIdFromIndices(self, *indices): """Return column instance identification from indices""" - if indices in self.__idxToIdCache: + try: return self.__idxToIdCache[indices] + except TypeError: + cacheable = False + except KeyError: + cacheable = True idx = 0 - idxLen = len(indices) instId = () + parentIndices = [] for impliedFlag, modName, symName in self.indexNames: - mibObj, = mibBuilder.importSymbols(modName, symName) - if idx < idxLen: - instId = instId + self.getAsName( - mibObj.syntax.clone(indices[idx]), impliedFlag - ) - else: + if idx >= len(indices): break - idx = idx + 1 - self.__idxToIdCache[indices] = instId + mibObj, = mibBuilder.importSymbols(modName, symName) + syntax = mibObj.syntax.clone(indices[idx]) + instId += self.getAsName(syntax, impliedFlag, parentIndices) + parentIndices.append(syntax) + idx += 1 + if cacheable: + self.__idxToIdCache[indices] = instId return instId # Table access by index @@ -1193,11 +1302,14 @@ return tuple(instNames) + class MibTable(MibTree): """MIB table. Manages a set of TableRow's""" + def __init__(self, name): MibTree.__init__(self, name) + zeroDotZero = ObjectIdentity((0, 0)) # OID tree @@ -1218,8 +1330,8 @@ snmpV2 = MibIdentifier(internet.name + (6,)) snmpDomains = MibIdentifier(snmpV2.name + (1,)) -snmpProxys = MibIdentifier(snmpV2.name +(2,)) -snmpModules = MibIdentifier(snmpV2.name +(3,)) +snmpProxys = MibIdentifier(snmpV2.name + (2,)) +snmpModules = MibIdentifier(snmpV2.name + (3,)) mibBuilder.exportSymbols( 'SNMPv2-SMI', MibNode=MibNode, diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMPv2-TC.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMPv2-TC.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMPv2-TC.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMPv2-TC.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,43 +1,35 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys +import inspect +import string from pysnmp.smi.error import * from pysnmp import debug +from pyasn1.type import univ from pyasn1.compat import octets +from pyasn1.type.base import Asn1Item -OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols( - 'ASN1', 'OctetString', 'Integer', 'ObjectIdentifier' -) - +OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint") +Counter32, Unsigned32, TimeTicks, Counter64 = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter32', 'Unsigned32', 'TimeTicks', 'Counter64') -(ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, - ValueRangeConstraint, ValueSizeConstraint) = mibBuilder.importSymbols( - "ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", - "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint" - ) - -Counter32, Unsigned32, TimeTicks, Counter64 = mibBuilder.importSymbols( - 'SNMPv2-SMI', 'Counter32', 'Unsigned32', 'TimeTicks', 'Counter64' -) -class TextualConvention: +class TextualConvention(object): displayHint = '' status = 'current' description = '' reference = '' bits = () __integer = Integer() - __counter32 = Counter32() __unsigned32 = Unsigned32() __timeticks = TimeTicks() - __counter64 = Counter64() __octetString = OctetString() - __objectIdentifier = ObjectIdentifier() + def getDisplayHint(self): return self.displayHint @@ -54,201 +46,409 @@ return self.clone() def setValue(self, value): + if value is None: + value = univ.noValue return self.clone(value) def prettyOut(self, value): # override asn1 type method """Implements DISPLAY-HINT evaluation""" - if self.displayHint and (self.__integer.isSuperTypeOf(self) or - self.__unsigned32.isSuperTypeOf(self) or - self.__timeticks.isSuperTypeOf(self) or - self.__counter32.isSuperTypeOf(self) or - self.__counter64.isSuperTypeOf(self)): + if self.displayHint and (self.__integer.isSuperTypeOf(self, matchConstraints=False) and not self.getNamedValues() or + self.__unsigned32.isSuperTypeOf(self, matchConstraints=False) or + self.__timeticks.isSuperTypeOf(self, matchConstraints=False)): _ = lambda t, f=0: (t, f) - t, f = _(*self.displayHint.split('-')) - if t == 'x': + displayHintType, decimalPrecision = _(*self.displayHint.split('-')) + if displayHintType == 'x': return '0x%x' % value - elif t == 'd': + elif displayHintType == 'd': try: - return '%.*f' % (int(f), float(value)/pow(10, int(f))) + return '%.*f' % (int(decimalPrecision), float(value) / pow(10, int(decimalPrecision))) except Exception: raise SmiError( - 'float num evaluation error: %s' % sys.exc_info()[1] + 'float evaluation error: %s' % sys.exc_info()[1] ) - elif t == 'o': + elif displayHintType == 'o': return '0%o' % value - elif t == 'b': - v = value - r = ['B'] - while v: - r.insert(0, '%d' % (v&0x01)) - v = v>>1 - return ''.join(r) + elif displayHintType == 'b': + runningValue = value + outputValue = ['B'] + while runningValue: + outputValue.insert(0, '%d' % (runningValue & 0x01)) + runningValue >>= 1 + return ''.join(outputValue) else: raise SmiError( - 'Unsupported numeric type spec: %s' % t - ) - elif self.displayHint and self.__octetString.isSuperTypeOf(self): - r = '' - v = self.__class__(value).asOctets() - d = self.displayHint - while v and d: + 'Unsupported numeric type spec "%s" at %s' % (displayHintType, self.__class__.__name__) + ) + elif self.displayHint and self.__octetString.isSuperTypeOf(self, matchConstraints=False): + outputValue = '' + runningValue = OctetString(value).asOctets() + displayHint = self.displayHint + while runningValue and displayHint: # 1 - if d[0] == '*': - repeatIndicator = repeatCount = octets.oct2int(v[0]) - d = d[1:] - v = v[1:] + if displayHint[0] == '*': + repeatIndicator = repeatCount = octets.oct2int(runningValue[0]) + displayHint = displayHint[1:] + runningValue = runningValue[1:] else: repeatCount = 1 repeatIndicator = None # 2 octetLength = '' - while d and d[0] in '0123456789': - octetLength += d[0] - d = d[1:] + while displayHint and displayHint[0] in string.digits: + octetLength += displayHint[0] + displayHint = displayHint[1:] + + # length is manatory, but people ignore that + if not octetLength: + octetLength = len(runningValue) + try: octetLength = int(octetLength) except Exception: raise SmiError( 'Bad octet length: %s' % octetLength ) - if not d: + + if not displayHint: raise SmiError( 'Short octet length: %s' % self.displayHint ) + # 3 - displayFormat = d[0] - d = d[1:] + displayFormat = displayHint[0] + displayHint = displayHint[1:] # 4 - if d and d[0] not in '0123456789' and d[0] != '*': - displaySep = d[0] - d = d[1:] + if displayHint and displayHint[0] not in string.digits and displayHint[0] != '*': + displaySep = displayHint[0] + displayHint = displayHint[1:] else: displaySep = '' # 5 - if d and displaySep and repeatIndicator is not None: - repeatTerminator = d[0] + if displayHint and displaySep and repeatIndicator is not None: + repeatTerminator = displayHint[0] displaySep = '' - d = d[1:] + displayHint = displayHint[1:] else: repeatTerminator = None while repeatCount: repeatCount -= 1 if displayFormat == 'a': - r += v[:octetLength].decode('ascii', 'ignore') + outputValue += runningValue[:octetLength].decode('ascii', 'ignore') elif displayFormat == 't': - r += v[:octetLength].decode('utf-8', 'ignore') + outputValue += runningValue[:octetLength].decode('utf-8', 'ignore') elif displayFormat in ('x', 'd', 'o'): - n = 0 - vv = v[:octetLength] - while vv: - n = n << 8 + number = 0 + numberString = runningValue[:octetLength] + while numberString: + number <<= 8 try: - n |= octets.oct2int(vv[0]) - vv = vv[1:] + number |= octets.oct2int(numberString[0]) + numberString = numberString[1:] except Exception: raise SmiError( 'Display format eval failure: %s: %s' - % (vv, sys.exc_info()[1]) + % (numberString, sys.exc_info()[1]) ) if displayFormat == 'x': - r += '%02x' % n + outputValue += '%02x' % number elif displayFormat == 'o': - r += '%03o' % n + outputValue += '%03o' % number else: - r += '%d' % n + outputValue += '%d' % number else: raise SmiError( - 'Unsupported display format char: %s' % \ + 'Unsupported display format char: %s' % displayFormat ) - if v and repeatTerminator: - r += repeatTerminator - v = v[octetLength:] - if v and displaySep: - r += displaySep - if not d: - d = self.displayHint -# if d: -# raise SmiError( -# 'Unparsed display hint left: %s' % d -# ) - return r - elif self.__objectIdentifier.isSuperTypeOf(self): - return self.__objectIdentifier.prettyOut(value) - elif self.__octetString.isSuperTypeOf(self): - return self.__octetString.prettyOut(value) + if runningValue and repeatTerminator: + outputValue += repeatTerminator + runningValue = runningValue[octetLength:] + if runningValue and displaySep: + outputValue += displaySep + if not displayHint: + displayHint = self.displayHint + + return outputValue + + for base in inspect.getmro(self.__class__): + if not issubclass(base, TextualConvention) and issubclass(base, Asn1Item): + return base.prettyOut(self, value) + + raise SmiError('TEXTUAL-CONVENTION has no underlying SNMP base type') + + def prettyIn(self, value): # override asn1 type method + """Implements DISPLAY-HINT parsing into base SNMP value + + Proper parsing seems impossible due to ambiguities. + Here we are truing to do our best, but be prepared + for failures on complicated DISPLAY-HINTs. + + Keep in mind that this parser only works with "text" + input meaning `unicode` (Py2) or `str` (Py3). + """ + for base in inspect.getmro(self.__class__): + if not issubclass(base, TextualConvention) and issubclass(base, Asn1Item): + break + else: + raise SmiError('TEXTUAL-CONVENTION has no underlying SNMP base type') + + if self.displayHint and (self.__integer.isSuperTypeOf(self, matchConstraints=False) and + self.getNamedValues() or + self.__unsigned32.isSuperTypeOf(self, matchConstraints=False) or + self.__timeticks.isSuperTypeOf(self, matchConstraints=False)): + value = str(value) + + _ = lambda t, f=0: (t, f) + displayHintType, decimalPrecision = _(*self.displayHint.split('-')) + if displayHintType == 'x' and (value.startswith('0x') or value.startswith('-0x')): + try: + if value.startswith('-'): + return base.prettyIn(self, -int(value[3:], 16)) + else: + return base.prettyIn(self, int(value[2:], 16)) + except Exception: + raise SmiError( + 'integer evaluation error: %s' % sys.exc_info()[1] + ) + elif displayHintType == 'd': + try: + return base.prettyIn(self, int(float(value) * 10**int(decimalPrecision))) + except Exception: + raise SmiError( + 'float evaluation error: %s' % sys.exc_info()[1] + ) + elif displayHintType == 'o' and (value.startswith('0') or value.startswith('-0')): + try: + return base.prettyIn(self, int(value, 8)) + except Exception: + raise SmiError( + 'octal evaluation error: %s' % sys.exc_info()[1] + ) + elif displayHintType == 'b' and (value.startswith('B') or value.startswith('-B')): + negative = value.startswith('-') + if negative: + value = value[2:] + else: + value = value[1:] + value = [x != '0' and 1 or 0 for x in value] + binValue = 0 + while value: + binValue <<= value[0] + del value[0] + return base.prettyIn(self, binValue) + else: + raise SmiError( + 'Unsupported numeric type spec "%s" at %s' % (displayHintType, self.__class__.__name__) + ) + + elif self.displayHint and self.__octetString.isSuperTypeOf(self, matchConstraints=False): + numBase = { + 'x': 16, + 'd': 10, + 'o': 8 + } + numDigits = { + 'x': octets.str2octs(string.hexdigits), + 'o': octets.str2octs(string.octdigits), + 'd': octets.str2octs(string.digits) + } + + # how do we know if object is initialized with display-hint + # formatted text? based on "text" input maybe? + if octets.isStringType(value) and not octets.isOctetsType(value): + value = base.prettyIn(self, value) + else: + return base.prettyIn(self, value) + + outputValue = octets.str2octs('') + runningValue = value + displayHint = self.displayHint + while runningValue and displayHint: + # 1 this information is totally lost, just fail explicitly + if displayHint[0] == '*': + raise SmiError( + 'Can\'t parse "*" in DISPLAY-HINT (%s)' % self.__class__.__name__ + ) + + # 2 this becomes ambiguous when it comes to rendered value + octetLength = '' + while displayHint and displayHint[0] in string.digits: + octetLength += displayHint[0] + displayHint = displayHint[1:] + + # length is mandatory but people ignore that + if not octetLength: + octetLength = len(runningValue) + + try: + octetLength = int(octetLength) + except Exception: + raise SmiError( + 'Bad octet length: %s' % octetLength + ) + + if not displayHint: + raise SmiError( + 'Short octet length: %s' % self.displayHint + ) + + # 3 + displayFormat = displayHint[0] + displayHint = displayHint[1:] + + # 4 this is the lifesaver -- we could use it as an anchor + if displayHint and displayHint[0] not in string.digits and displayHint[0] != '*': + displaySep = displayHint[0] + displayHint = displayHint[1:] + else: + displaySep = '' + + # 5 is probably impossible to support + + if displayFormat in ('a', 't'): + outputValue += runningValue[:octetLength] + elif displayFormat in numBase: + if displaySep: + guessedOctetLength = runningValue.find(octets.str2octs(displaySep)) + if guessedOctetLength == -1: + guessedOctetLength = len(runningValue) + else: + for idx in range(len(runningValue)): + if runningValue[idx] not in numDigits[displayFormat]: + guessedOctetLength = idx + break + else: + guessedOctetLength = len(runningValue) + + try: + num = int(octets.octs2str(runningValue[:guessedOctetLength]), numBase[displayFormat]) + except Exception: + raise SmiError( + 'Display format eval failure: %s: %s' + % (runningValue[:guessedOctetLength], sys.exc_info()[1]) + ) + + num_as_bytes = [] + if num: + while num: + num_as_bytes.append(num & 0xFF) + num >>= 8 + else: + num_as_bytes = [0] + + while len(num_as_bytes) < octetLength: + num_as_bytes.append(0) + + num_as_bytes.reverse() + + outputValue += octets.ints2octs(num_as_bytes) + + if displaySep: + guessedOctetLength += 1 + + octetLength = guessedOctetLength + else: + raise SmiError( + 'Unsupported display format char: %s' % + displayFormat + ) + + runningValue = runningValue[octetLength:] + + if not displayHint: + displayHint = self.displayHint + + return base.prettyIn(self, outputValue) + else: - return str(value) + return base.prettyIn(self, value) -# elif self.bits: -# try: -# return self.bits[value] -# except Exception: -# raise SmiError( -# 'Enumeratin resolution failure for %s: %s' % (self, sys.exc_info()[1]) -# ) - -# XXX -# def prettyIn(self, value): -# # XXX parse TC syntax -# return str(value) class DisplayString(TextualConvention, OctetString): - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(0,255) + description = "Represents textual information taken from the NVT ASCII character set, as defined in pages 4, 10-11 of RFC 854. To summarize RFC 854, the NVT ASCII repertoire specifies: - the use of character codes 0-127 (decimal) - the graphics characters (32-126) are interpreted as US ASCII - NUL, LF, CR, BEL, BS, HT, VT and FF have the special meanings specified in RFC 854 - the other 25 codes have no standard interpretation - the sequence 'CR LF' means newline - the sequence 'CR NUL' means carriage-return - an 'LF' not preceded by a 'CR' means moving to the same column on the next line. - the sequence 'CR x' for any x other than LF or NUL is illegal. (Note that this also means that a string may end with either 'CR LF' or 'CR NUL', but not with CR.) Any object defined using this syntax may not exceed 255 characters in length." + status = 'current' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(0, 255) displayHint = "255a" + class PhysAddress(TextualConvention, OctetString): + description = "Represents textual information taken from the NVT ASCII character set, as defined in pages 4, 10-11 of RFC 854. To summarize RFC 854, the NVT ASCII repertoire specifies: - the use of character codes 0-127 (decimal) - the graphics characters (32-126) are interpreted as US ASCII - NUL, LF, CR, BEL, BS, HT, VT and FF have the special meanings specified in RFC 854 - the other 25 codes have no standard interpretation - the sequence 'CR LF' means newline - the sequence 'CR NUL' means carriage-return - an 'LF' not preceded by a 'CR' means moving to the same column on the next line. - the sequence 'CR x' for any x other than LF or NUL is illegal. (Note that this also means that a string may end with either 'CR LF' or 'CR NUL', but not with CR.) Any object defined using this syntax may not exceed 255 characters in length." + status = 'current' displayHint = "1x:" + class MacAddress(TextualConvention, OctetString): - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(6,6) + description = "Represents an 802 MAC address represented in the `canonical' order defined by IEEE 802.1a, i.e., as if it were transmitted least significant bit first, even though 802.5 (in contrast to other 802.x protocols) requires MAC addresses to be transmitted most significant bit first." + status = 'current' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(6, 6) displayHint = "1x:" fixedLength = 6 -class TruthValue(Integer, TextualConvention): - subtypeSpec = Integer.subtypeSpec+SingleValueConstraint(1, 2) + +class TruthValue(TextualConvention, Integer): + description = 'Represents a boolean value.' + status = 'current' + subtypeSpec = Integer.subtypeSpec + SingleValueConstraint(1, 2) namedValues = NamedValues(('true', 1), ('false', 2)) -class TestAndIncr(Integer, TextualConvention): - subtypeSpec = Integer.subtypeSpec+ValueRangeConstraint(0, 2147483647) + +class TestAndIncr(TextualConvention, Integer): + description = "Represents integer-valued information used for atomic operations. When the management protocol is used to specify that an object instance having this syntax is to be modified, the new value supplied via the management protocol must precisely match the value presently held by the instance. If not, the management protocol set operation fails with an error of `inconsistentValue'. Otherwise, if the current value is the maximum value of 2^31-1 (2147483647 decimal), then the value held by the instance is wrapped to zero; otherwise, the value held by the instance is incremented by one. (Note that regardless of whether the management protocol set operation succeeds, the variable- binding in the request and response PDUs are identical.) The value of the ACCESS clause for objects having this syntax is either `read-write' or `read-create'. When an instance of a columnar object having this syntax is created, any value may be supplied via the management protocol. When the network management portion of the system is re- initialized, the value of every object instance having this syntax must either be incremented from its value prior to the re-initialization, or (if the value prior to the re- initialization is unknown) be set to a pseudo-randomly generated value." + status = 'current' + subtypeSpec = Integer.subtypeSpec + ValueRangeConstraint(0, 2147483647) defaultValue = 0 + def setValue(self, value): if value is not None: if value != self: raise InconsistentValueError() - value = value + 1 + value += 1 if value > 2147483646: value = 0 - return self.clone(self, value) + if value is None: + value = univ.noValue + return self.clone(value) + + +class AutonomousType(TextualConvention, ObjectIdentifier): + description = 'Represents an independently extensible type identification value. It may, for example, indicate a particular sub-tree with further MIB definitions, or define a particular type of protocol or hardware.' + status = 'current' -class AutonomousType(ObjectIdentifier, TextualConvention): - pass -class InstancePointer(ObjectIdentifier, TextualConvention): +class InstancePointer(TextualConvention, ObjectIdentifier): + description = 'A pointer to either a specific instance of a MIB object or a conceptual row of a MIB table in the managed device. In the latter case, by convention, it is the name of the particular instance of the first accessible columnar object in the conceptual row. The two uses of this textual convention are replaced by VariablePointer and RowPointer, respectively.' status = 'obsolete' -class VariablePointer(ObjectIdentifier, TextualConvention): - pass -class RowPointer(ObjectIdentifier, TextualConvention): - pass +class VariablePointer(TextualConvention, ObjectIdentifier): + description = 'A pointer to a specific object instance. For example, sysContact.0 or ifInOctets.3.' + status = 'current' + -class RowStatus(Integer, TextualConvention): +class RowPointer(TextualConvention, ObjectIdentifier): + description = 'Represents a pointer to a conceptual row. The value is the name of the instance of the first accessible columnar object in the conceptual row. For example, ifIndex.3 would point to the 3rd row in the ifTable (note that if ifIndex were not-accessible, then ifDescr.3 would be used instead).' + status = 'current' + +class RowStatus(TextualConvention, Integer): """A special kind of scalar MIB variable responsible for MIB table row creation/destruction. """ - subtypeSpec = Integer.subtypeSpec+SingleValueConstraint(0, 1, 2, 3, 4, 5, 6) + description = "The RowStatus textual convention is used to manage the creation and deletion of conceptual rows, and is used as the value of the SYNTAX clause for the status column of a conceptual row (as described in Section 7.7.1 of [2].)..." + status = 'current' + subtypeSpec = Integer.subtypeSpec + SingleValueConstraint(0, 1, 2, 3, 4, 5, 6) namedValues = NamedValues( ('notExists', 0), ('active', 1), ('notInService', 2), ('notReady', 3), ('createAndGo', 4), ('createAndWait', 5), ('destroy', 6) ) # Known row states - stNotExists, stActive, stNotInService, stNotReady, \ - stCreateAndGo, stCreateAndWait, stDestroy = list(range(7)) + (stNotExists, stActive, stNotInService, + stNotReady, stCreateAndGo, stCreateAndWait, + stDestroy) = list(range(7)) + # States transition matrix (see RFC-1903) stateMatrix = { # (new-state, current-state) -> (error, new-state) @@ -281,6 +481,9 @@ } def setValue(self, value): + if value is None: + value = univ.noValue + value = self.clone(value) # Run through states transition matrix, @@ -290,40 +493,66 @@ self.hasValue() and self or self.stNotExists), (MibOperationError, None) ) + + if newState is None: + newState = univ.noValue + newState = self.clone(newState) - debug.logger & debug.flagIns and debug.logger('RowStatus state change from %r to %r produced new state %r, error indication %r' % (self, value, newState, excValue)) + debug.logger & debug.flagIns and debug.logger( + 'RowStatus state change from %r to %r produced new state %r, error indication %r' % ( + self, value, newState, excValue)) if excValue is not None: excValue = excValue( - msg='Exception at row state transition from %r to %r yields state %r and exception' % (self, value, newState), syntax=newState + msg='Exception at row state transition from %r to %r yields state %r and exception' % ( + self, value, newState), syntax=newState ) raise excValue return newState -class TimeStamp(TimeTicks, TextualConvention): - pass -class TimeInterval(Integer, TextualConvention): - subtypeSpec = Integer.subtypeSpec+ValueRangeConstraint(0, 2147483647) +class TimeStamp(TextualConvention, TimeTicks): + description = 'The value of the sysUpTime object at which a specific occurrence happened. The specific occurrence must be defined in the description of any object defined using this type. If sysUpTime is reset to zero as a result of a re- initialization of the network management (sub)system, then the values of all TimeStamp objects are also reset. However, after approximately 497 days without a re- initialization, the sysUpTime object will reach 2^^32-1 and then increment around to zero; in this case, existing values of TimeStamp objects do not change. This can lead to ambiguities in the value of TimeStamp objects.' + status = 'current' + + +class TimeInterval(TextualConvention, Integer): + description = 'A period of time, measured in units of 0.01 seconds.' + status = 'current' + subtypeSpec = Integer.subtypeSpec + ValueRangeConstraint(0, 2147483647) + class DateAndTime(TextualConvention, OctetString): - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(8, 11) + description = "A date-time specification. field octets contents range ----- ------ -------- ----- 1 1-2 year* 0..65536 2 3 month 1..12 3 4 day 1..31 4 5 hour 0..23 5 6 minutes 0..59 6 7 seconds 0..60 (use 60 for leap-second) 7 8 deci-seconds 0..9 8 9 direction from UTC '+' / '-' 9 10 hours from UTC* 0..13 10 11 minutes from UTC 0..59 * Notes: - the value of year is in network-byte order - daylight saving time in New Zealand is +13 For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be displayed as: 1992-5-26,13:30:15.0,-4:0 Note that if only local time is known, then timezone information (fields 8-10) is not present." + status = 'current' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(8, 11) displayHint = "2d-1d-1d,1d:1d:1d.1d,1a1d:1d" -class StorageType(Integer, TextualConvention): - subtypeSpec = Integer.subtypeSpec+SingleValueConstraint(1, 2, 3, 4, 5) + +class StorageType(TextualConvention, Integer): + description = "Describes the memory realization of a conceptual row. A row which is volatile(2) is lost upon reboot. A row which is either nonVolatile(3), permanent(4) or readOnly(5), is backed up by stable storage. A row which is permanent(4) can be changed but not deleted. A row which is readOnly(5) cannot be changed nor deleted. If the value of an object with this syntax is either permanent(4) or readOnly(5), it cannot be written. Conversely, if the value is either other(1), volatile(2) or nonVolatile(3), it cannot be modified to be permanent(4) or readOnly(5). (All illegal modifications result in a 'wrongValue' error.) Every usage of this textual convention is required to specify the columnar objects which a permanent(4) row must at a minimum allow to be writable." + status = 'current' + subtypeSpec = Integer.subtypeSpec + SingleValueConstraint(1, 2, 3, 4, 5) namedValues = NamedValues( ('other', 1), ('volatile', 2), ('nonVolatile', 3), ('permanent', 4), ('readOnly', 5) ) -class TDomain(ObjectIdentifier, TextualConvention): - pass -class TAddress(OctetString, TextualConvention): - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(1, 255) +class TDomain(TextualConvention, ObjectIdentifier): + reference = 'The SNMPv2-TM MIB module is defined in RFC 1906.' + description = 'Denotes a kind of transport service. Some possible values, such as snmpUDPDomain, are defined in the SNMPv2-TM MIB module. Other possible values are defined in other MIB modules.' + status = 'current' + + +class TAddress(TextualConvention, OctetString): + reference = 'The SNMPv2-TM MIB module is defined in RFC 1906.' + description = 'Denotes a transport service address. A TAddress value is always interpreted within the context of a TDomain value. Thus, each definition of a TDomain value must be accompanied by a definition of a textual convention for use with that TDomain. Some possible textual conventions, such as SnmpUDPAddress for snmpUDPDomain, are defined in the SNMPv2-TM MIB module. Other possible textual conventions are defined in other MIB modules.' + status = 'current' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(1, 255) + mibBuilder.exportSymbols( 'SNMPv2-TC', TextualConvention=TextualConvention, diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMPv2-TM.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMPv2-TM.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMPv2-TM.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMPv2-TM.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,79 +1,108 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html +# +# PySNMP MIB module SNMPv2-TM (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMPv2-TM +# Produced by pysmi-0.1.3 at Tue Apr 18 01:01:19 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # try: from socket import inet_ntop, inet_pton, AF_INET except ImportError: from socket import inet_ntoa, inet_aton, AF_INET + inet_ntop = lambda x, y: inet_ntoa(y) inet_pton = lambda x, y: inet_aton(y) from pyasn1.compat.octets import int2oct, oct2int -(OctetString,) = mibBuilder.importSymbols('ASN1', 'OctetString') -(ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint") -(ModuleIdentity, MibIdentifier, ObjectIdentity, snmpModules, snmpDomains, snmpProxys) = mibBuilder.importSymbols('SNMPv2-SMI', 'ModuleIdentity', 'MibIdentifier', 'ObjectIdentity', 'snmpModules', 'snmpDomains', 'snmpProxys') -(TextualConvention,) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention') - -snmpv2tm = ModuleIdentity(snmpModules.name + (19,)).setRevisions(("2002-10-16 00:00",)) +OctetString, = mibBuilder.importSymbols('ASN1', 'OctetString') +ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint") +ModuleIdentity, MibIdentifier, ObjectIdentity, snmpModules, snmpDomains, snmpProxys = mibBuilder.importSymbols('SNMPv2-SMI', 'ModuleIdentity', 'MibIdentifier', 'ObjectIdentity', 'snmpModules', 'snmpDomains', 'snmpProxys') +TextualConvention, = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention') + +snmpv2tm = ModuleIdentity((1, 3, 6, 1, 6, 3, 19)) +if mibBuilder.loadTexts: snmpv2tm.setRevisions(('2000-08-09 19:58', '1996-01-01 00:00', '1993-04-01 00:00',)) +if mibBuilder.loadTexts: snmpv2tm.setLastUpdated('200008091958Z') +if mibBuilder.loadTexts: snmpv2tm.setOrganization('IETF SNMPv3 Working Group') +if mibBuilder.loadTexts: snmpv2tm.setContactInfo('WG-EMail: snmpv3@tis.com Subscribe: majordomo@tis.com In message body: subscribe snmpv3 Chair: Russ Mundy TIS Labs at Network Associates postal: 3060 Washington Rd Glenwood MD 21738 USA EMail: mundy@tislabs.com phone: +1 301 854-6889 Editor: Randy Presuhn BMC Software, Inc. postal: 2141 North First Street San Jose, CA 95131 USA EMail: randy-presuhn@bmc.com phone: +1 408 546-1006') +if mibBuilder.loadTexts: snmpv2tm.setDescription('The MIB module for SNMP transport mappings.') +snmpUDPDomain = ObjectIdentity((1, 3, 6, 1, 6, 1, 1)) +if mibBuilder.loadTexts: snmpUDPDomain.setStatus('current') +if mibBuilder.loadTexts: snmpUDPDomain.setDescription('The SNMP over UDP over IPv4 transport domain. The corresponding transport address is of type SnmpUDPAddress.') -snmpUDPDomain = ObjectIdentity(snmpDomains.name + (1,)) class SnmpUDPAddress(TextualConvention, OctetString): + description = 'Represents a UDP over IPv4 address: octets contents encoding 1-4 IP-address network-byte order 5-6 UDP-port network-byte order ' + status = 'current' subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(6, 6) displayHint = "1d.1d.1d.1d/2d" + fixedLength = 6 def prettyIn(self, value): if isinstance(value, tuple): # Wild hack -- need to implement TextualConvention.prettyIn - value = inet_pton(AF_INET, value[0]) + \ - int2oct((value[1] >> 8) & 0xff) + \ - int2oct(value[1] & 0xff) + value = inet_pton(AF_INET, value[0]) + int2oct((value[1] >> 8) & 0xff) + int2oct(value[1] & 0xff) return OctetString.prettyIn(self, value) # Socket address syntax coercion - def __getitem__(self, i): + def __asSocketAddress(self): if not hasattr(self, '__tuple_value'): v = self.asOctets() self.__tuple_value = ( inet_ntop(AF_INET, v[:4]), oct2int(v[4]) << 8 | oct2int(v[5]) ) - return self.__tuple_value[i] - -snmpCLNSDomain = ObjectIdentity(snmpDomains.name + (2,)) -snmpCONSDomain = ObjectIdentity(snmpDomains.name + (3,)) + return self.__tuple_value + + def __iter__(self): + return iter(self.__asSocketAddress()) + + def __getitem__(self, item): + return self.__asSocketAddress()[item] + + +snmpCLNSDomain = ObjectIdentity((1, 3, 6, 1, 6, 1, 2)) +if mibBuilder.loadTexts: snmpCLNSDomain.setStatus('current') +if mibBuilder.loadTexts: snmpCLNSDomain.setDescription('The SNMP over CLNS transport domain. The corresponding transport address is of type SnmpOSIAddress.') +snmpCONSDomain = ObjectIdentity((1, 3, 6, 1, 6, 1, 3)) +if mibBuilder.loadTexts: snmpCONSDomain.setStatus('current') +if mibBuilder.loadTexts: snmpCONSDomain.setDescription('The SNMP over CONS transport domain. The corresponding transport address is of type SnmpOSIAddress.') + class SnmpOSIAddress(TextualConvention, OctetString): + description = "Represents an OSI transport-address: octets contents encoding 1 length of NSAP 'n' as an unsigned-integer (either 0 or from 3 to 20) 2..(n+1) NSAP concrete binary representation (n+2)..m TSEL string of (up to 64) octets " + status = 'current' subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(1, 85) displayHint = "*1x:/1x:" - -snmpDDPDomain = ObjectIdentity(snmpDomains.name + (4,)) + +snmpDDPDomain = ObjectIdentity((1, 3, 6, 1, 6, 1, 4)) +if mibBuilder.loadTexts: snmpDDPDomain.setStatus('current') +if mibBuilder.loadTexts: snmpDDPDomain.setDescription('The SNMP over DDP transport domain. The corresponding transport address is of type SnmpNBPAddress.') + class SnmpNBPAddress(OctetString, TextualConvention): + description = "Represents an NBP name: octets contents encoding 1 length of object 'n' as an unsigned integer 2..(n+1) object string of (up to 32) octets n+2 length of type 'p' as an unsigned integer (n+3)..(n+2+p) type string of (up to 32) octets n+3+p length of zone 'q' as an unsigned integer (n+4+p)..(n+3+p+q) zone string of (up to 32) octets For comparison purposes, strings are case-insensitive. All strings may contain any octet other than 255 (hex ff)." + status = 'current' subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(3, 99) - -snmpIPXDomain = ObjectIdentity(snmpDomains.name + (5,)) +snmpIPXDomain = ObjectIdentity((1, 3, 6, 1, 6, 1, 5)) +if mibBuilder.loadTexts: snmpIPXDomain.setStatus('current') +if mibBuilder.loadTexts: snmpIPXDomain.setDescription('The SNMP over IPX transport domain. The corresponding transport address is of type SnmpIPXAddress.') class SnmpIPXAddress(TextualConvention, OctetString): + description = 'Represents an IPX address: octets contents encoding 1-4 network-number network-byte order 5-10 physical-address network-byte order 11-12 socket-number network-byte order ' + status = 'current' subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(12, 12) displayHint = "4x.1x:1x:1x:1x:1x:1x.2d" + fixedLength = 12 -rfc1157Proxy = MibIdentifier(snmpProxys.name + (1,)) -rfc1157Domain = MibIdentifier(rfc1157Proxy.name + (1,)) - -# Module identity -mibBuilder.exportSymbols("SNMPv2-TM", PYSNMP_MODULE_ID=snmpv2tm) +rfc1157Proxy = MibIdentifier((1, 3, 6, 1, 6, 2, 1)) +rfc1157Domain = ObjectIdentity((1, 3, 6, 1, 6, 2, 1, 1)) +if mibBuilder.loadTexts: rfc1157Domain.setStatus('deprecated') +if mibBuilder.loadTexts: rfc1157Domain.setDescription('The transport domain for SNMPv1 over UDP over IPv4. The corresponding transport address is of type SnmpUDPAddress.') -mibBuilder.exportSymbols( - 'SNMPv2-TM', snmpv2tm=snmpv2tm, snmpUDPDomain=snmpUDPDomain, - SnmpUDPAddress=SnmpUDPAddress, - snmpCLNSDomain=snmpCLNSDomain, snmpCONSDomain=snmpCONSDomain, - SnmpOSIAddress=SnmpOSIAddress, snmpDDPDomain=snmpDDPDomain, - SnmpNBPAddress=SnmpNBPAddress, snmpIPXDomain=snmpIPXDomain, - SnmpIPXAddress=SnmpIPXAddress, rfc1157Proxy=rfc1157Proxy, - rfc1157Domain=rfc1157Domain - ) +mibBuilder.exportSymbols("SNMPv2-TM", SnmpNBPAddress=SnmpNBPAddress, rfc1157Domain=rfc1157Domain, SnmpIPXAddress=SnmpIPXAddress, snmpUDPDomain=snmpUDPDomain, snmpCLNSDomain=snmpCLNSDomain, SnmpOSIAddress=SnmpOSIAddress, rfc1157Proxy=rfc1157Proxy, PYSNMP_MODULE_ID=snmpv2tm, snmpIPXDomain=snmpIPXDomain, snmpCONSDomain=snmpCONSDomain, snmpDDPDomain=snmpDDPDomain, SnmpUDPAddress=SnmpUDPAddress, snmpv2tm=snmpv2tm) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-VIEW-BASED-ACM-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-VIEW-BASED-ACM-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/SNMP-VIEW-BASED-ACM-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/SNMP-VIEW-BASED-ACM-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,94 +1,125 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module SNMP-VIEW-BASED-ACM-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/SNMP-VIEW-BASED-ACM-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 23:12:54 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module SNMP-VIEW-BASED-ACM-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/SNMP-VIEW-BASED-ACM-MIB +# Produced by pysmi-0.1.3 at Tue Apr 18 00:50:37 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( SnmpSecurityModel, SnmpAdminString, SnmpSecurityLevel, ) = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpSecurityModel", "SnmpAdminString", "SnmpSecurityLevel") -( NotificationGroup, ModuleCompliance, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, snmpModules, iso, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "snmpModules", "iso", "ObjectIdentity", "Bits", "Counter32") -( StorageType, DisplayString, RowStatus, TextualConvention, TestAndIncr, ) = mibBuilder.importSymbols("SNMPv2-TC", "StorageType", "DisplayString", "RowStatus", "TextualConvention", "TestAndIncr") -snmpVacmMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 16)).setRevisions(("2002-10-16 00:00", "1999-01-20 00:00", "1997-11-20 00:00",)) +OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint") +SnmpAdminString, SnmpSecurityLevel, SnmpSecurityModel = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString", "SnmpSecurityLevel", "SnmpSecurityModel") +NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") +TimeTicks, Gauge32, Bits, snmpModules, IpAddress, Counter64, MibScalar, MibTable, MibTableRow, MibTableColumn, Unsigned32, Integer32, ModuleIdentity, NotificationType, MibIdentifier, ObjectIdentity, iso, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "Gauge32", "Bits", "snmpModules", "IpAddress", "Counter64", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Unsigned32", "Integer32", "ModuleIdentity", "NotificationType", "MibIdentifier", "ObjectIdentity", "iso", "Counter32") +TestAndIncr, RowStatus, TextualConvention, DisplayString, StorageType = mibBuilder.importSymbols("SNMPv2-TC", "TestAndIncr", "RowStatus", "TextualConvention", "DisplayString", "StorageType") +snmpVacmMIB = ModuleIdentity((1, 3, 6, 1, 6, 3, 16)) +if mibBuilder.loadTexts: snmpVacmMIB.setRevisions(('2002-10-16 00:00', '1999-01-20 00:00', '1997-11-20 00:00',)) if mibBuilder.loadTexts: snmpVacmMIB.setLastUpdated('200210160000Z') if mibBuilder.loadTexts: snmpVacmMIB.setOrganization('SNMPv3 Working Group') -if mibBuilder.loadTexts: snmpVacmMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com\n Subscribe: majordomo@lists.tislabs.com\n In message body: subscribe snmpv3\n\n Co-Chair: Russ Mundy\n Network Associates Laboratories\n postal: 15204 Omega Drive, Suite 300\n Rockville, MD 20850-4601\n USA\n email: mundy@tislabs.com\n phone: +1 301-947-7107\n\n Co-Chair: David Harrington\n Enterasys Networks\n Postal: 35 Industrial Way\n P. O. Box 5004\n Rochester, New Hampshire 03866-5005\n USA\n EMail: dbh@enterasys.com\n Phone: +1 603-337-2614\n\n Co-editor: Bert Wijnen\n Lucent Technologies\n postal: Schagen 33\n 3461 GL Linschoten\n Netherlands\n email: bwijnen@lucent.com\n phone: +31-348-480-685\n\n Co-editor: Randy Presuhn\n BMC Software, Inc.\n\n postal: 2141 North First Street\n San Jose, CA 95131\n USA\n email: randy_presuhn@bmc.com\n phone: +1 408-546-1006\n\n Co-editor: Keith McCloghrie\n Cisco Systems, Inc.\n postal: 170 West Tasman Drive\n San Jose, CA 95134-1706\n USA\n email: kzm@cisco.com\n phone: +1-408-526-5260\n ') -if mibBuilder.loadTexts: snmpVacmMIB.setDescription('The management information definitions for the\n View-based Access Control Model for SNMP.\n\n Copyright (C) The Internet Society (2002). This\n version of this MIB module is part of RFC 3415;\n see the RFC itself for full legal notices.\n ') +if mibBuilder.loadTexts: snmpVacmMIB.setContactInfo('WG-email: snmpv3@lists.tislabs.com Subscribe: majordomo@lists.tislabs.com In message body: subscribe snmpv3 Co-Chair: Russ Mundy Network Associates Laboratories postal: 15204 Omega Drive, Suite 300 Rockville, MD 20850-4601 USA email: mundy@tislabs.com phone: +1 301-947-7107 Co-Chair: David Harrington Enterasys Networks Postal: 35 Industrial Way P. O. Box 5004 Rochester, New Hampshire 03866-5005 USA EMail: dbh@enterasys.com Phone: +1 603-337-2614 Co-editor: Bert Wijnen Lucent Technologies postal: Schagen 33 3461 GL Linschoten Netherlands email: bwijnen@lucent.com phone: +31-348-480-685 Co-editor: Randy Presuhn BMC Software, Inc. postal: 2141 North First Street San Jose, CA 95131 USA email: randy_presuhn@bmc.com phone: +1 408-546-1006 Co-editor: Keith McCloghrie Cisco Systems, Inc. postal: 170 West Tasman Drive San Jose, CA 95134-1706 USA email: kzm@cisco.com phone: +1-408-526-5260 ') +if mibBuilder.loadTexts: snmpVacmMIB.setDescription('The management information definitions for the View-based Access Control Model for SNMP. Copyright (C) The Internet Society (2002). This version of this MIB module is part of RFC 3415; see the RFC itself for full legal notices. ') vacmMIBObjects = MibIdentifier((1, 3, 6, 1, 6, 3, 16, 1)) vacmMIBConformance = MibIdentifier((1, 3, 6, 1, 6, 3, 16, 2)) vacmContextTable = MibTable((1, 3, 6, 1, 6, 3, 16, 1, 1), ) -if mibBuilder.loadTexts: vacmContextTable.setDescription('The table of locally available contexts.\n\n This table provides information to SNMP Command\n\n Generator applications so that they can properly\n configure the vacmAccessTable to control access to\n all contexts at the SNMP entity.\n\n This table may change dynamically if the SNMP entity\n allows that contexts are added/deleted dynamically\n (for instance when its configuration changes). Such\n changes would happen only if the management\n instrumentation at that SNMP entity recognizes more\n (or fewer) contexts.\n\n The presence of entries in this table and of entries\n in the vacmAccessTable are independent. That is, a\n context identified by an entry in this table is not\n necessarily referenced by any entries in the\n vacmAccessTable; and the context(s) referenced by an\n entry in the vacmAccessTable does not necessarily\n currently exist and thus need not be identified by an\n entry in this table.\n\n This table must be made accessible via the default\n context so that Command Responder applications have\n a standard way of retrieving the information.\n\n This table is read-only. It cannot be configured via\n SNMP.\n ') +if mibBuilder.loadTexts: vacmContextTable.setStatus('current') +if mibBuilder.loadTexts: vacmContextTable.setDescription('The table of locally available contexts. This table provides information to SNMP Command Generator applications so that they can properly configure the vacmAccessTable to control access to all contexts at the SNMP entity. This table may change dynamically if the SNMP entity allows that contexts are added/deleted dynamically (for instance when its configuration changes). Such changes would happen only if the management instrumentation at that SNMP entity recognizes more (or fewer) contexts. The presence of entries in this table and of entries in the vacmAccessTable are independent. That is, a context identified by an entry in this table is not necessarily referenced by any entries in the vacmAccessTable; and the context(s) referenced by an entry in the vacmAccessTable does not necessarily currently exist and thus need not be identified by an entry in this table. This table must be made accessible via the default context so that Command Responder applications have a standard way of retrieving the information. This table is read-only. It cannot be configured via SNMP. ') vacmContextEntry = MibTableRow((1, 3, 6, 1, 6, 3, 16, 1, 1, 1), ).setIndexNames((0, "SNMP-VIEW-BASED-ACM-MIB", "vacmContextName")) +if mibBuilder.loadTexts: vacmContextEntry.setStatus('current') if mibBuilder.loadTexts: vacmContextEntry.setDescription('Information about a particular context.') -vacmContextName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 1, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0,32))).setMaxAccess("readonly") -if mibBuilder.loadTexts: vacmContextName.setDescription('A human readable name identifying a particular\n context at a particular SNMP entity.\n\n The empty contextName (zero length) represents the\n default context.\n ') +vacmContextName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 1, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 32))).setMaxAccess("readonly") +if mibBuilder.loadTexts: vacmContextName.setStatus('current') +if mibBuilder.loadTexts: vacmContextName.setDescription('A human readable name identifying a particular context at a particular SNMP entity. The empty contextName (zero length) represents the default context. ') vacmSecurityToGroupTable = MibTable((1, 3, 6, 1, 6, 3, 16, 1, 2), ) -if mibBuilder.loadTexts: vacmSecurityToGroupTable.setDescription('This table maps a combination of securityModel and\n securityName into a groupName which is used to define\n an access control policy for a group of principals.\n ') +if mibBuilder.loadTexts: vacmSecurityToGroupTable.setStatus('current') +if mibBuilder.loadTexts: vacmSecurityToGroupTable.setDescription('This table maps a combination of securityModel and securityName into a groupName which is used to define an access control policy for a group of principals. ') vacmSecurityToGroupEntry = MibTableRow((1, 3, 6, 1, 6, 3, 16, 1, 2, 1), ).setIndexNames((0, "SNMP-VIEW-BASED-ACM-MIB", "vacmSecurityModel"), (0, "SNMP-VIEW-BASED-ACM-MIB", "vacmSecurityName")) -if mibBuilder.loadTexts: vacmSecurityToGroupEntry.setDescription('An entry in this table maps the combination of a\n securityModel and securityName into a groupName.\n ') -vacmSecurityModel = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 2, 1, 1), SnmpSecurityModel().subtype(subtypeSpec=ValueRangeConstraint(1,2147483647))) -if mibBuilder.loadTexts: vacmSecurityModel.setDescription("The Security Model, by which the vacmSecurityName\n referenced by this entry is provided.\n\n Note, this object may not take the 'any' (0) value.\n ") -vacmSecurityName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 2, 1, 2), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))) -if mibBuilder.loadTexts: vacmSecurityName.setDescription('The securityName for the principal, represented in a\n Security Model independent format, which is mapped by\n this entry to a groupName.\n ') -vacmGroupName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 2, 1, 3), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmGroupName.setDescription('The name of the group to which this entry (e.g., the\n combination of securityModel and securityName)\n belongs.\n\n This groupName is used as index into the\n vacmAccessTable to select an access control policy.\n However, a value in this table does not imply that an\n instance with the value exists in table vacmAccesTable.\n ') +if mibBuilder.loadTexts: vacmSecurityToGroupEntry.setStatus('current') +if mibBuilder.loadTexts: vacmSecurityToGroupEntry.setDescription('An entry in this table maps the combination of a securityModel and securityName into a groupName. ') +vacmSecurityModel = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 2, 1, 1), SnmpSecurityModel().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))) +if mibBuilder.loadTexts: vacmSecurityModel.setStatus('current') +if mibBuilder.loadTexts: vacmSecurityModel.setDescription("The Security Model, by which the vacmSecurityName referenced by this entry is provided. Note, this object may not take the 'any' (0) value. ") +vacmSecurityName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 2, 1, 2), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) +if mibBuilder.loadTexts: vacmSecurityName.setStatus('current') +if mibBuilder.loadTexts: vacmSecurityName.setDescription('The securityName for the principal, represented in a Security Model independent format, which is mapped by this entry to a groupName. ') +vacmGroupName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 2, 1, 3), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))).setMaxAccess("readcreate") +if mibBuilder.loadTexts: vacmGroupName.setStatus('current') +if mibBuilder.loadTexts: vacmGroupName.setDescription('The name of the group to which this entry (e.g., the combination of securityModel and securityName) belongs. This groupName is used as index into the vacmAccessTable to select an access control policy. However, a value in this table does not imply that an instance with the value exists in table vacmAccesTable. ') vacmSecurityToGroupStorageType = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 2, 1, 4), StorageType().clone('nonVolatile')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmSecurityToGroupStorageType.setDescription("The storage type for this conceptual row.\n Conceptual rows having the value 'permanent' need not\n allow write-access to any columnar objects in the row.\n ") +if mibBuilder.loadTexts: vacmSecurityToGroupStorageType.setStatus('current') +if mibBuilder.loadTexts: vacmSecurityToGroupStorageType.setDescription("The storage type for this conceptual row. Conceptual rows having the value 'permanent' need not allow write-access to any columnar objects in the row. ") vacmSecurityToGroupStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 2, 1, 5), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmSecurityToGroupStatus.setDescription("The status of this conceptual row.\n\n Until instances of all corresponding columns are\n appropriately configured, the value of the\n\n corresponding instance of the vacmSecurityToGroupStatus\n column is 'notReady'.\n\n In particular, a newly created row cannot be made\n active until a value has been set for vacmGroupName.\n\n The RowStatus TC [RFC2579] requires that this\n DESCRIPTION clause states under which circumstances\n other objects in this row can be modified:\n\n The value of this object has no effect on whether\n other objects in this conceptual row can be modified.\n ") +if mibBuilder.loadTexts: vacmSecurityToGroupStatus.setStatus('current') +if mibBuilder.loadTexts: vacmSecurityToGroupStatus.setDescription("The status of this conceptual row. Until instances of all corresponding columns are appropriately configured, the value of the corresponding instance of the vacmSecurityToGroupStatus column is 'notReady'. In particular, a newly created row cannot be made active until a value has been set for vacmGroupName. The RowStatus TC [RFC2579] requires that this DESCRIPTION clause states under which circumstances other objects in this row can be modified: The value of this object has no effect on whether other objects in this conceptual row can be modified. ") vacmAccessTable = MibTable((1, 3, 6, 1, 6, 3, 16, 1, 4), ) -if mibBuilder.loadTexts: vacmAccessTable.setDescription("The table of access rights for groups.\n\n Each entry is indexed by a groupName, a contextPrefix,\n a securityModel and a securityLevel. To determine\n whether access is allowed, one entry from this table\n needs to be selected and the proper viewName from that\n entry must be used for access control checking.\n\n To select the proper entry, follow these steps:\n\n 1) the set of possible matches is formed by the\n intersection of the following sets of entries:\n\n the set of entries with identical vacmGroupName\n the union of these two sets:\n - the set with identical vacmAccessContextPrefix\n - the set of entries with vacmAccessContextMatch\n value of 'prefix' and matching\n vacmAccessContextPrefix\n intersected with the union of these two sets:\n - the set of entries with identical\n vacmSecurityModel\n - the set of entries with vacmSecurityModel\n value of 'any'\n intersected with the set of entries with\n vacmAccessSecurityLevel value less than or equal\n to the requested securityLevel\n\n 2) if this set has only one member, we're done\n otherwise, it comes down to deciding how to weight\n the preferences between ContextPrefixes,\n SecurityModels, and SecurityLevels as follows:\n a) if the subset of entries with securityModel\n matching the securityModel in the message is\n not empty, then discard the rest.\n b) if the subset of entries with\n vacmAccessContextPrefix matching the contextName\n in the message is not empty,\n then discard the rest\n c) discard all entries with ContextPrefixes shorter\n than the longest one remaining in the set\n d) select the entry with the highest securityLevel\n\n Please note that for securityLevel noAuthNoPriv, all\n groups are really equivalent since the assumption that\n the securityName has been authenticated does not hold.\n ") +if mibBuilder.loadTexts: vacmAccessTable.setStatus('current') +if mibBuilder.loadTexts: vacmAccessTable.setDescription("The table of access rights for groups. Each entry is indexed by a groupName, a contextPrefix, a securityModel and a securityLevel. To determine whether access is allowed, one entry from this table needs to be selected and the proper viewName from that entry must be used for access control checking. To select the proper entry, follow these steps: 1) the set of possible matches is formed by the intersection of the following sets of entries: the set of entries with identical vacmGroupName the union of these two sets: - the set with identical vacmAccessContextPrefix - the set of entries with vacmAccessContextMatch value of 'prefix' and matching vacmAccessContextPrefix intersected with the union of these two sets: - the set of entries with identical vacmSecurityModel - the set of entries with vacmSecurityModel value of 'any' intersected with the set of entries with vacmAccessSecurityLevel value less than or equal to the requested securityLevel 2) if this set has only one member, we're done otherwise, it comes down to deciding how to weight the preferences between ContextPrefixes, SecurityModels, and SecurityLevels as follows: a) if the subset of entries with securityModel matching the securityModel in the message is not empty, then discard the rest. b) if the subset of entries with vacmAccessContextPrefix matching the contextName in the message is not empty, then discard the rest c) discard all entries with ContextPrefixes shorter than the longest one remaining in the set d) select the entry with the highest securityLevel Please note that for securityLevel noAuthNoPriv, all groups are really equivalent since the assumption that the securityName has been authenticated does not hold. ") vacmAccessEntry = MibTableRow((1, 3, 6, 1, 6, 3, 16, 1, 4, 1), ).setIndexNames((0, "SNMP-VIEW-BASED-ACM-MIB", "vacmGroupName"), (0, "SNMP-VIEW-BASED-ACM-MIB", "vacmAccessContextPrefix"), (0, "SNMP-VIEW-BASED-ACM-MIB", "vacmAccessSecurityModel"), (0, "SNMP-VIEW-BASED-ACM-MIB", "vacmAccessSecurityLevel")) -if mibBuilder.loadTexts: vacmAccessEntry.setDescription('An access right configured in the Local Configuration\n Datastore (LCD) authorizing access to an SNMP context.\n\n Entries in this table can use an instance value for\n object vacmGroupName even if no entry in table\n vacmAccessSecurityToGroupTable has a corresponding\n value for object vacmGroupName.\n ') -vacmAccessContextPrefix = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0,32))) -if mibBuilder.loadTexts: vacmAccessContextPrefix.setDescription("In order to gain the access rights allowed by this\n conceptual row, a contextName must match exactly\n (if the value of vacmAccessContextMatch is 'exact')\n or partially (if the value of vacmAccessContextMatch\n is 'prefix') to the value of the instance of this\n object.\n ") +if mibBuilder.loadTexts: vacmAccessEntry.setStatus('current') +if mibBuilder.loadTexts: vacmAccessEntry.setDescription('An access right configured in the Local Configuration Datastore (LCD) authorizing access to an SNMP context. Entries in this table can use an instance value for object vacmGroupName even if no entry in table vacmAccessSecurityToGroupTable has a corresponding value for object vacmGroupName. ') +vacmAccessContextPrefix = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 32))) +if mibBuilder.loadTexts: vacmAccessContextPrefix.setStatus('current') +if mibBuilder.loadTexts: vacmAccessContextPrefix.setDescription("In order to gain the access rights allowed by this conceptual row, a contextName must match exactly (if the value of vacmAccessContextMatch is 'exact') or partially (if the value of vacmAccessContextMatch is 'prefix') to the value of the instance of this object. ") vacmAccessSecurityModel = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 2), SnmpSecurityModel()) -if mibBuilder.loadTexts: vacmAccessSecurityModel.setDescription('In order to gain the access rights allowed by this\n conceptual row, this securityModel must be in use.\n ') +if mibBuilder.loadTexts: vacmAccessSecurityModel.setStatus('current') +if mibBuilder.loadTexts: vacmAccessSecurityModel.setDescription('In order to gain the access rights allowed by this conceptual row, this securityModel must be in use. ') vacmAccessSecurityLevel = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 3), SnmpSecurityLevel()) -if mibBuilder.loadTexts: vacmAccessSecurityLevel.setDescription('The minimum level of security required in order to\n gain the access rights allowed by this conceptual\n row. A securityLevel of noAuthNoPriv is less than\n authNoPriv which in turn is less than authPriv.\n\n If multiple entries are equally indexed except for\n this vacmAccessSecurityLevel index, then the entry\n which has the highest value for\n vacmAccessSecurityLevel is selected.\n ') -vacmAccessContextMatch = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 4), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2,)).clone(namedValues=NamedValues(("exact", 1), ("prefix", 2),)).clone('exact')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmAccessContextMatch.setDescription('If the value of this object is exact(1), then all\n rows where the contextName exactly matches\n vacmAccessContextPrefix are selected.\n\n If the value of this object is prefix(2), then all\n rows where the contextName whose starting octets\n exactly match vacmAccessContextPrefix are selected.\n This allows for a simple form of wildcarding.\n ') -vacmAccessReadViewName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 5), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0,32)).clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmAccessReadViewName.setDescription('The value of an instance of this object identifies\n the MIB view of the SNMP context to which this\n conceptual row authorizes read access.\n\n The identified MIB view is that one for which the\n vacmViewTreeFamilyViewName has the same value as the\n instance of this object; if the value is the empty\n string or if there is no active MIB view having this\n value of vacmViewTreeFamilyViewName, then no access\n is granted.\n ') -vacmAccessWriteViewName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 6), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0,32)).clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmAccessWriteViewName.setDescription('The value of an instance of this object identifies\n the MIB view of the SNMP context to which this\n conceptual row authorizes write access.\n\n The identified MIB view is that one for which the\n vacmViewTreeFamilyViewName has the same value as the\n instance of this object; if the value is the empty\n string or if there is no active MIB view having this\n value of vacmViewTreeFamilyViewName, then no access\n is granted.\n ') -vacmAccessNotifyViewName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 7), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0,32)).clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmAccessNotifyViewName.setDescription('The value of an instance of this object identifies\n the MIB view of the SNMP context to which this\n conceptual row authorizes access for notifications.\n\n The identified MIB view is that one for which the\n vacmViewTreeFamilyViewName has the same value as the\n instance of this object; if the value is the empty\n string or if there is no active MIB view having this\n value of vacmViewTreeFamilyViewName, then no access\n is granted.\n ') +if mibBuilder.loadTexts: vacmAccessSecurityLevel.setStatus('current') +if mibBuilder.loadTexts: vacmAccessSecurityLevel.setDescription('The minimum level of security required in order to gain the access rights allowed by this conceptual row. A securityLevel of noAuthNoPriv is less than authNoPriv which in turn is less than authPriv. If multiple entries are equally indexed except for this vacmAccessSecurityLevel index, then the entry which has the highest value for vacmAccessSecurityLevel is selected. ') +vacmAccessContextMatch = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("exact", 1), ("prefix", 2))).clone('exact')).setMaxAccess("readcreate") +if mibBuilder.loadTexts: vacmAccessContextMatch.setStatus('current') +if mibBuilder.loadTexts: vacmAccessContextMatch.setDescription('If the value of this object is exact(1), then all rows where the contextName exactly matches vacmAccessContextPrefix are selected. If the value of this object is prefix(2), then all rows where the contextName whose starting octets exactly match vacmAccessContextPrefix are selected. This allows for a simple form of wildcarding. ') +vacmAccessReadViewName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 5), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 32)).clone(hexValue="")).setMaxAccess("readcreate") +if mibBuilder.loadTexts: vacmAccessReadViewName.setStatus('current') +if mibBuilder.loadTexts: vacmAccessReadViewName.setDescription('The value of an instance of this object identifies the MIB view of the SNMP context to which this conceptual row authorizes read access. The identified MIB view is that one for which the vacmViewTreeFamilyViewName has the same value as the instance of this object; if the value is the empty string or if there is no active MIB view having this value of vacmViewTreeFamilyViewName, then no access is granted. ') +vacmAccessWriteViewName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 6), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 32)).clone(hexValue="")).setMaxAccess("readcreate") +if mibBuilder.loadTexts: vacmAccessWriteViewName.setStatus('current') +if mibBuilder.loadTexts: vacmAccessWriteViewName.setDescription('The value of an instance of this object identifies the MIB view of the SNMP context to which this conceptual row authorizes write access. The identified MIB view is that one for which the vacmViewTreeFamilyViewName has the same value as the instance of this object; if the value is the empty string or if there is no active MIB view having this value of vacmViewTreeFamilyViewName, then no access is granted. ') +vacmAccessNotifyViewName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 7), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 32)).clone(hexValue="")).setMaxAccess("readcreate") +if mibBuilder.loadTexts: vacmAccessNotifyViewName.setStatus('current') +if mibBuilder.loadTexts: vacmAccessNotifyViewName.setDescription('The value of an instance of this object identifies the MIB view of the SNMP context to which this conceptual row authorizes access for notifications. The identified MIB view is that one for which the vacmViewTreeFamilyViewName has the same value as the instance of this object; if the value is the empty string or if there is no active MIB view having this value of vacmViewTreeFamilyViewName, then no access is granted. ') vacmAccessStorageType = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 8), StorageType().clone('nonVolatile')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmAccessStorageType.setDescription("The storage type for this conceptual row.\n\n Conceptual rows having the value 'permanent' need not\n allow write-access to any columnar objects in the row.\n ") +if mibBuilder.loadTexts: vacmAccessStorageType.setStatus('current') +if mibBuilder.loadTexts: vacmAccessStorageType.setDescription("The storage type for this conceptual row. Conceptual rows having the value 'permanent' need not allow write-access to any columnar objects in the row. ") vacmAccessStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 4, 1, 9), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmAccessStatus.setDescription('The status of this conceptual row.\n\n The RowStatus TC [RFC2579] requires that this\n DESCRIPTION clause states under which circumstances\n other objects in this row can be modified:\n\n The value of this object has no effect on whether\n other objects in this conceptual row can be modified.\n ') +if mibBuilder.loadTexts: vacmAccessStatus.setStatus('current') +if mibBuilder.loadTexts: vacmAccessStatus.setDescription('The status of this conceptual row. The RowStatus TC [RFC2579] requires that this DESCRIPTION clause states under which circumstances other objects in this row can be modified: The value of this object has no effect on whether other objects in this conceptual row can be modified. ') vacmMIBViews = MibIdentifier((1, 3, 6, 1, 6, 3, 16, 1, 5)) vacmViewSpinLock = MibScalar((1, 3, 6, 1, 6, 3, 16, 1, 5, 1), TestAndIncr()).setMaxAccess("readwrite") -if mibBuilder.loadTexts: vacmViewSpinLock.setDescription("An advisory lock used to allow cooperating SNMP\n Command Generator applications to coordinate their\n use of the Set operation in creating or modifying\n views.\n\n When creating a new view or altering an existing\n view, it is important to understand the potential\n interactions with other uses of the view. The\n vacmViewSpinLock should be retrieved. The name of\n the view to be created should be determined to be\n unique by the SNMP Command Generator application by\n consulting the vacmViewTreeFamilyTable. Finally,\n the named view may be created (Set), including the\n advisory lock.\n If another SNMP Command Generator application has\n altered the views in the meantime, then the spin\n lock's value will have changed, and so this creation\n will fail because it will specify the wrong value for\n the spin lock.\n\n Since this is an advisory lock, the use of this lock\n is not enforced.\n ") +if mibBuilder.loadTexts: vacmViewSpinLock.setStatus('current') +if mibBuilder.loadTexts: vacmViewSpinLock.setDescription("An advisory lock used to allow cooperating SNMP Command Generator applications to coordinate their use of the Set operation in creating or modifying views. When creating a new view or altering an existing view, it is important to understand the potential interactions with other uses of the view. The vacmViewSpinLock should be retrieved. The name of the view to be created should be determined to be unique by the SNMP Command Generator application by consulting the vacmViewTreeFamilyTable. Finally, the named view may be created (Set), including the advisory lock. If another SNMP Command Generator application has altered the views in the meantime, then the spin lock's value will have changed, and so this creation will fail because it will specify the wrong value for the spin lock. Since this is an advisory lock, the use of this lock is not enforced. ") vacmViewTreeFamilyTable = MibTable((1, 3, 6, 1, 6, 3, 16, 1, 5, 2), ) -if mibBuilder.loadTexts: vacmViewTreeFamilyTable.setDescription("Locally held information about families of subtrees\n within MIB views.\n\n Each MIB view is defined by two sets of view subtrees:\n - the included view subtrees, and\n - the excluded view subtrees.\n Every such view subtree, both the included and the\n\n excluded ones, is defined in this table.\n\n To determine if a particular object instance is in\n a particular MIB view, compare the object instance's\n OBJECT IDENTIFIER with each of the MIB view's active\n entries in this table. If none match, then the\n object instance is not in the MIB view. If one or\n more match, then the object instance is included in,\n or excluded from, the MIB view according to the\n value of vacmViewTreeFamilyType in the entry whose\n value of vacmViewTreeFamilySubtree has the most\n sub-identifiers. If multiple entries match and have\n the same number of sub-identifiers (when wildcarding\n is specified with the value of vacmViewTreeFamilyMask),\n then the lexicographically greatest instance of\n vacmViewTreeFamilyType determines the inclusion or\n exclusion.\n\n An object instance's OBJECT IDENTIFIER X matches an\n active entry in this table when the number of\n sub-identifiers in X is at least as many as in the\n value of vacmViewTreeFamilySubtree for the entry,\n and each sub-identifier in the value of\n vacmViewTreeFamilySubtree matches its corresponding\n sub-identifier in X. Two sub-identifiers match\n either if the corresponding bit of the value of\n vacmViewTreeFamilyMask for the entry is zero (the\n 'wild card' value), or if they are equal.\n\n A 'family' of subtrees is the set of subtrees defined\n by a particular combination of values of\n vacmViewTreeFamilySubtree and vacmViewTreeFamilyMask.\n\n In the case where no 'wild card' is defined in the\n vacmViewTreeFamilyMask, the family of subtrees reduces\n to a single subtree.\n\n When creating or changing MIB views, an SNMP Command\n Generator application should utilize the\n vacmViewSpinLock to try to avoid collisions. See\n DESCRIPTION clause of vacmViewSpinLock.\n\n When creating MIB views, it is strongly advised that\n first the 'excluded' vacmViewTreeFamilyEntries are\n created and then the 'included' entries.\n\n When deleting MIB views, it is strongly advised that\n first the 'included' vacmViewTreeFamilyEntries are\n\n deleted and then the 'excluded' entries.\n\n If a create for an entry for instance-level access\n control is received and the implementation does not\n support instance-level granularity, then an\n inconsistentName error must be returned.\n ") +if mibBuilder.loadTexts: vacmViewTreeFamilyTable.setStatus('current') +if mibBuilder.loadTexts: vacmViewTreeFamilyTable.setDescription("Locally held information about families of subtrees within MIB views. Each MIB view is defined by two sets of view subtrees: - the included view subtrees, and - the excluded view subtrees. Every such view subtree, both the included and the excluded ones, is defined in this table. To determine if a particular object instance is in a particular MIB view, compare the object instance's OBJECT IDENTIFIER with each of the MIB view's active entries in this table. If none match, then the object instance is not in the MIB view. If one or more match, then the object instance is included in, or excluded from, the MIB view according to the value of vacmViewTreeFamilyType in the entry whose value of vacmViewTreeFamilySubtree has the most sub-identifiers. If multiple entries match and have the same number of sub-identifiers (when wildcarding is specified with the value of vacmViewTreeFamilyMask), then the lexicographically greatest instance of vacmViewTreeFamilyType determines the inclusion or exclusion. An object instance's OBJECT IDENTIFIER X matches an active entry in this table when the number of sub-identifiers in X is at least as many as in the value of vacmViewTreeFamilySubtree for the entry, and each sub-identifier in the value of vacmViewTreeFamilySubtree matches its corresponding sub-identifier in X. Two sub-identifiers match either if the corresponding bit of the value of vacmViewTreeFamilyMask for the entry is zero (the 'wild card' value), or if they are equal. A 'family' of subtrees is the set of subtrees defined by a particular combination of values of vacmViewTreeFamilySubtree and vacmViewTreeFamilyMask. In the case where no 'wild card' is defined in the vacmViewTreeFamilyMask, the family of subtrees reduces to a single subtree. When creating or changing MIB views, an SNMP Command Generator application should utilize the vacmViewSpinLock to try to avoid collisions. See DESCRIPTION clause of vacmViewSpinLock. When creating MIB views, it is strongly advised that first the 'excluded' vacmViewTreeFamilyEntries are created and then the 'included' entries. When deleting MIB views, it is strongly advised that first the 'included' vacmViewTreeFamilyEntries are deleted and then the 'excluded' entries. If a create for an entry for instance-level access control is received and the implementation does not support instance-level granularity, then an inconsistentName error must be returned. ") vacmViewTreeFamilyEntry = MibTableRow((1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1), ).setIndexNames((0, "SNMP-VIEW-BASED-ACM-MIB", "vacmViewTreeFamilyViewName"), (0, "SNMP-VIEW-BASED-ACM-MIB", "vacmViewTreeFamilySubtree")) -if mibBuilder.loadTexts: vacmViewTreeFamilyEntry.setDescription("Information on a particular family of view subtrees\n included in or excluded from a particular SNMP\n context's MIB view.\n\n Implementations must not restrict the number of\n families of view subtrees for a given MIB view,\n except as dictated by resource constraints on the\n overall number of entries in the\n vacmViewTreeFamilyTable.\n\n If no conceptual rows exist in this table for a given\n MIB view (viewName), that view may be thought of as\n consisting of the empty set of view subtrees.\n ") -vacmViewTreeFamilyViewName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1,32))) -if mibBuilder.loadTexts: vacmViewTreeFamilyViewName.setDescription('The human readable name for a family of view subtrees.\n ') +if mibBuilder.loadTexts: vacmViewTreeFamilyEntry.setStatus('current') +if mibBuilder.loadTexts: vacmViewTreeFamilyEntry.setDescription("Information on a particular family of view subtrees included in or excluded from a particular SNMP context's MIB view. Implementations must not restrict the number of families of view subtrees for a given MIB view, except as dictated by resource constraints on the overall number of entries in the vacmViewTreeFamilyTable. If no conceptual rows exist in this table for a given MIB view (viewName), that view may be thought of as consisting of the empty set of view subtrees. ") +vacmViewTreeFamilyViewName = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) +if mibBuilder.loadTexts: vacmViewTreeFamilyViewName.setStatus('current') +if mibBuilder.loadTexts: vacmViewTreeFamilyViewName.setDescription('The human readable name for a family of view subtrees. ') vacmViewTreeFamilySubtree = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1, 2), ObjectIdentifier()) -if mibBuilder.loadTexts: vacmViewTreeFamilySubtree.setDescription('The MIB subtree which when combined with the\n corresponding instance of vacmViewTreeFamilyMask\n defines a family of view subtrees.\n ') -vacmViewTreeFamilyMask = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1, 3), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0,16)).clone(hexValue="")).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmViewTreeFamilyMask.setDescription("The bit mask which, in combination with the\n corresponding instance of vacmViewTreeFamilySubtree,\n defines a family of view subtrees.\n\n Each bit of this bit mask corresponds to a\n sub-identifier of vacmViewTreeFamilySubtree, with the\n most significant bit of the i-th octet of this octet\n string value (extended if necessary, see below)\n corresponding to the (8*i - 7)-th sub-identifier, and\n the least significant bit of the i-th octet of this\n octet string corresponding to the (8*i)-th\n sub-identifier, where i is in the range 1 through 16.\n\n Each bit of this bit mask specifies whether or not\n the corresponding sub-identifiers must match when\n determining if an OBJECT IDENTIFIER is in this\n family of view subtrees; a '1' indicates that an\n exact match must occur; a '0' indicates 'wild card',\n i.e., any sub-identifier value matches.\n\n Thus, the OBJECT IDENTIFIER X of an object instance\n is contained in a family of view subtrees if, for\n each sub-identifier of the value of\n vacmViewTreeFamilySubtree, either:\n\n the i-th bit of vacmViewTreeFamilyMask is 0, or\n\n the i-th sub-identifier of X is equal to the i-th\n sub-identifier of the value of\n vacmViewTreeFamilySubtree.\n\n If the value of this bit mask is M bits long and\n\n there are more than M sub-identifiers in the\n corresponding instance of vacmViewTreeFamilySubtree,\n then the bit mask is extended with 1's to be the\n required length.\n\n Note that when the value of this object is the\n zero-length string, this extension rule results in\n a mask of all-1's being used (i.e., no 'wild card'),\n and the family of view subtrees is the one view\n subtree uniquely identified by the corresponding\n instance of vacmViewTreeFamilySubtree.\n\n Note that masks of length greater than zero length\n do not need to be supported. In this case this\n object is made read-only.\n ") -vacmViewTreeFamilyType = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1, 4), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2,)).clone(namedValues=NamedValues(("included", 1), ("excluded", 2),)).clone('included')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmViewTreeFamilyType.setDescription('Indicates whether the corresponding instances of\n vacmViewTreeFamilySubtree and vacmViewTreeFamilyMask\n define a family of view subtrees which is included in\n or excluded from the MIB view.\n ') +if mibBuilder.loadTexts: vacmViewTreeFamilySubtree.setStatus('current') +if mibBuilder.loadTexts: vacmViewTreeFamilySubtree.setDescription('The MIB subtree which when combined with the corresponding instance of vacmViewTreeFamilyMask defines a family of view subtrees. ') +vacmViewTreeFamilyMask = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1, 3), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 16)).clone(hexValue="")).setMaxAccess("readcreate") +if mibBuilder.loadTexts: vacmViewTreeFamilyMask.setStatus('current') +if mibBuilder.loadTexts: vacmViewTreeFamilyMask.setDescription("The bit mask which, in combination with the corresponding instance of vacmViewTreeFamilySubtree, defines a family of view subtrees. Each bit of this bit mask corresponds to a sub-identifier of vacmViewTreeFamilySubtree, with the most significant bit of the i-th octet of this octet string value (extended if necessary, see below) corresponding to the (8*i - 7)-th sub-identifier, and the least significant bit of the i-th octet of this octet string corresponding to the (8*i)-th sub-identifier, where i is in the range 1 through 16. Each bit of this bit mask specifies whether or not the corresponding sub-identifiers must match when determining if an OBJECT IDENTIFIER is in this family of view subtrees; a '1' indicates that an exact match must occur; a '0' indicates 'wild card', i.e., any sub-identifier value matches. Thus, the OBJECT IDENTIFIER X of an object instance is contained in a family of view subtrees if, for each sub-identifier of the value of vacmViewTreeFamilySubtree, either: the i-th bit of vacmViewTreeFamilyMask is 0, or the i-th sub-identifier of X is equal to the i-th sub-identifier of the value of vacmViewTreeFamilySubtree. If the value of this bit mask is M bits long and there are more than M sub-identifiers in the corresponding instance of vacmViewTreeFamilySubtree, then the bit mask is extended with 1's to be the required length. Note that when the value of this object is the zero-length string, this extension rule results in a mask of all-1's being used (i.e., no 'wild card'), and the family of view subtrees is the one view subtree uniquely identified by the corresponding instance of vacmViewTreeFamilySubtree. Note that masks of length greater than zero length do not need to be supported. In this case this object is made read-only. ") +vacmViewTreeFamilyType = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("included", 1), ("excluded", 2))).clone('included')).setMaxAccess("readcreate") +if mibBuilder.loadTexts: vacmViewTreeFamilyType.setStatus('current') +if mibBuilder.loadTexts: vacmViewTreeFamilyType.setDescription('Indicates whether the corresponding instances of vacmViewTreeFamilySubtree and vacmViewTreeFamilyMask define a family of view subtrees which is included in or excluded from the MIB view. ') vacmViewTreeFamilyStorageType = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1, 5), StorageType().clone('nonVolatile')).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmViewTreeFamilyStorageType.setDescription("The storage type for this conceptual row.\n\n Conceptual rows having the value 'permanent' need not\n allow write-access to any columnar objects in the row.\n ") +if mibBuilder.loadTexts: vacmViewTreeFamilyStorageType.setStatus('current') +if mibBuilder.loadTexts: vacmViewTreeFamilyStorageType.setDescription("The storage type for this conceptual row. Conceptual rows having the value 'permanent' need not allow write-access to any columnar objects in the row. ") vacmViewTreeFamilyStatus = MibTableColumn((1, 3, 6, 1, 6, 3, 16, 1, 5, 2, 1, 6), RowStatus()).setMaxAccess("readcreate") -if mibBuilder.loadTexts: vacmViewTreeFamilyStatus.setDescription('The status of this conceptual row.\n\n The RowStatus TC [RFC2579] requires that this\n DESCRIPTION clause states under which circumstances\n other objects in this row can be modified:\n\n The value of this object has no effect on whether\n other objects in this conceptual row can be modified.\n ') +if mibBuilder.loadTexts: vacmViewTreeFamilyStatus.setStatus('current') +if mibBuilder.loadTexts: vacmViewTreeFamilyStatus.setDescription('The status of this conceptual row. The RowStatus TC [RFC2579] requires that this DESCRIPTION clause states under which circumstances other objects in this row can be modified: The value of this object has no effect on whether other objects in this conceptual row can be modified. ') vacmMIBCompliances = MibIdentifier((1, 3, 6, 1, 6, 3, 16, 2, 1)) vacmMIBGroups = MibIdentifier((1, 3, 6, 1, 6, 3, 16, 2, 2)) -vacmMIBCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 16, 2, 1, 1)).setObjects(*(("SNMP-VIEW-BASED-ACM-MIB", "vacmBasicGroup"),)) -if mibBuilder.loadTexts: vacmMIBCompliance.setDescription('The compliance statement for SNMP engines which\n implement the SNMP View-based Access Control Model\n configuration MIB.\n ') -vacmBasicGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 16, 2, 2, 1)).setObjects(*(("SNMP-VIEW-BASED-ACM-MIB", "vacmContextName"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmGroupName"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmSecurityToGroupStorageType"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmSecurityToGroupStatus"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessContextMatch"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessReadViewName"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessWriteViewName"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessNotifyViewName"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessStorageType"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessStatus"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmViewSpinLock"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmViewTreeFamilyMask"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmViewTreeFamilyType"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmViewTreeFamilyStorageType"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmViewTreeFamilyStatus"),)) -if mibBuilder.loadTexts: vacmBasicGroup.setDescription('A collection of objects providing for remote\n configuration of an SNMP engine which implements\n\n the SNMP View-based Access Control Model.\n ') -mibBuilder.exportSymbols("SNMP-VIEW-BASED-ACM-MIB", vacmMIBObjects=vacmMIBObjects, vacmSecurityName=vacmSecurityName, vacmViewTreeFamilyMask=vacmViewTreeFamilyMask, vacmSecurityToGroupStorageType=vacmSecurityToGroupStorageType, vacmAccessContextMatch=vacmAccessContextMatch, vacmContextEntry=vacmContextEntry, vacmSecurityModel=vacmSecurityModel, vacmAccessReadViewName=vacmAccessReadViewName, snmpVacmMIB=snmpVacmMIB, vacmViewTreeFamilyEntry=vacmViewTreeFamilyEntry, vacmSecurityToGroupStatus=vacmSecurityToGroupStatus, vacmMIBCompliances=vacmMIBCompliances, vacmContextName=vacmContextName, vacmAccessTable=vacmAccessTable, vacmViewTreeFamilyTable=vacmViewTreeFamilyTable, vacmSecurityToGroupEntry=vacmSecurityToGroupEntry, vacmContextTable=vacmContextTable, vacmMIBGroups=vacmMIBGroups, vacmViewSpinLock=vacmViewSpinLock, vacmViewTreeFamilySubtree=vacmViewTreeFamilySubtree, vacmMIBCompliance=vacmMIBCompliance, vacmGroupName=vacmGroupName, vacmAccessWriteViewName=vacmAccessWriteViewName, vacmBasicGroup=vacmBasicGroup, vacmAccessStorageType=vacmAccessStorageType, vacmSecurityToGroupTable=vacmSecurityToGroupTable, vacmAccessContextPrefix=vacmAccessContextPrefix, vacmAccessSecurityModel=vacmAccessSecurityModel, vacmAccessEntry=vacmAccessEntry, vacmAccessSecurityLevel=vacmAccessSecurityLevel, vacmAccessNotifyViewName=vacmAccessNotifyViewName, PYSNMP_MODULE_ID=snmpVacmMIB, vacmMIBViews=vacmMIBViews, vacmViewTreeFamilyStorageType=vacmViewTreeFamilyStorageType, vacmAccessStatus=vacmAccessStatus, vacmViewTreeFamilyType=vacmViewTreeFamilyType, vacmViewTreeFamilyViewName=vacmViewTreeFamilyViewName, vacmMIBConformance=vacmMIBConformance, vacmViewTreeFamilyStatus=vacmViewTreeFamilyStatus) +vacmMIBCompliance = ModuleCompliance((1, 3, 6, 1, 6, 3, 16, 2, 1, 1)).setObjects(("SNMP-VIEW-BASED-ACM-MIB", "vacmBasicGroup")) +if mibBuilder.loadTexts: vacmMIBCompliance.setDescription('The compliance statement for SNMP engines which implement the SNMP View-based Access Control Model configuration MIB. ') +vacmBasicGroup = ObjectGroup((1, 3, 6, 1, 6, 3, 16, 2, 2, 1)).setObjects(("SNMP-VIEW-BASED-ACM-MIB", "vacmContextName"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmGroupName"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmSecurityToGroupStorageType"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmSecurityToGroupStatus"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessContextMatch"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessReadViewName"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessWriteViewName"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessNotifyViewName"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessStorageType"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmAccessStatus"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmViewSpinLock"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmViewTreeFamilyMask"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmViewTreeFamilyType"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmViewTreeFamilyStorageType"), ("SNMP-VIEW-BASED-ACM-MIB", "vacmViewTreeFamilyStatus")) +if mibBuilder.loadTexts: vacmBasicGroup.setDescription('A collection of objects providing for remote configuration of an SNMP engine which implements the SNMP View-based Access Control Model. ') +mibBuilder.exportSymbols("SNMP-VIEW-BASED-ACM-MIB", vacmSecurityModel=vacmSecurityModel, vacmSecurityToGroupEntry=vacmSecurityToGroupEntry, vacmMIBConformance=vacmMIBConformance, vacmAccessReadViewName=vacmAccessReadViewName, vacmViewTreeFamilyMask=vacmViewTreeFamilyMask, snmpVacmMIB=snmpVacmMIB, vacmViewTreeFamilyType=vacmViewTreeFamilyType, vacmMIBGroups=vacmMIBGroups, vacmAccessContextMatch=vacmAccessContextMatch, vacmAccessNotifyViewName=vacmAccessNotifyViewName, vacmViewSpinLock=vacmViewSpinLock, vacmAccessWriteViewName=vacmAccessWriteViewName, vacmContextTable=vacmContextTable, PYSNMP_MODULE_ID=snmpVacmMIB, vacmViewTreeFamilyViewName=vacmViewTreeFamilyViewName, vacmMIBObjects=vacmMIBObjects, vacmViewTreeFamilyStatus=vacmViewTreeFamilyStatus, vacmSecurityName=vacmSecurityName, vacmGroupName=vacmGroupName, vacmAccessSecurityLevel=vacmAccessSecurityLevel, vacmBasicGroup=vacmBasicGroup, vacmContextName=vacmContextName, vacmSecurityToGroupStatus=vacmSecurityToGroupStatus, vacmAccessEntry=vacmAccessEntry, vacmMIBViews=vacmMIBViews, vacmAccessStorageType=vacmAccessStorageType, vacmMIBCompliances=vacmMIBCompliances, vacmViewTreeFamilyEntry=vacmViewTreeFamilyEntry, vacmViewTreeFamilyTable=vacmViewTreeFamilyTable, vacmSecurityToGroupStorageType=vacmSecurityToGroupStorageType, vacmAccessTable=vacmAccessTable, vacmAccessContextPrefix=vacmAccessContextPrefix, vacmViewTreeFamilyStorageType=vacmViewTreeFamilyStorageType, vacmMIBCompliance=vacmMIBCompliance, vacmAccessSecurityModel=vacmAccessSecurityModel, vacmAccessStatus=vacmAccessStatus, vacmContextEntry=vacmContextEntry, vacmSecurityToGroupTable=vacmSecurityToGroupTable, vacmViewTreeFamilySubtree=vacmViewTreeFamilySubtree) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/mibs/TRANSPORT-ADDRESS-MIB.py python-pysnmp4-4.4.3/pysnmp/smi/mibs/TRANSPORT-ADDRESS-MIB.py --- python-pysnmp4-4.3.2/pysnmp/smi/mibs/TRANSPORT-ADDRESS-MIB.py 2016-02-13 19:38:15.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/mibs/TRANSPORT-ADDRESS-MIB.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,25 +1,16 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # -# PySNMP MIB module TRANSPORT-ADDRESS-MIB (http://pysnmp.sf.net) -# ASN.1 source file:///usr/share/snmp/mibs/TRANSPORT-ADDRESS-MIB.txt -# Produced by pysmi-0.0.5 at Sat Sep 19 23:19:08 2015 -# On host grommit.local platform Darwin version 14.4.0 by user ilya -# Using Python version 2.7.6 (default, Sep 9 2014, 15:04:36) +# PySNMP MIB module TRANSPORT-ADDRESS-MIB (http://snmplabs.com/pysnmp) +# ASN.1 source http://mibs.snmplabs.com:80/asn1/TRANSPORT-ADDRESS-MIB +# Produced by pysmi-0.1.3 at Tue Apr 18 01:08:18 2017 +# On host grommit.local platform Darwin version 16.4.0 by user ilya +# Using Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) # -( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") -( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") -( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") -( NotificationGroup, ModuleCompliance, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") -( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, mib_2, IpAddress, TimeTicks, Counter64, Unsigned32, iso, Gauge32, ModuleIdentity, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "mib-2", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "iso", "Gauge32", "ModuleIdentity", "ObjectIdentity", "Bits", "Counter32") -( DisplayString, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") -# -# WARNING: some of the classes below are manually implemented -# from pyasn1.compat.octets import int2oct, oct2int from pysnmp import error from pysnmp.carrier import sockfix @@ -35,29 +26,31 @@ if sys.platform != "win32": from socket import inet_ntoa, inet_aton - inet_ntop = lambda x,y: inet_ntoa(y) - inet_pton = lambda x,y: inet_aton(y) + + inet_ntop = lambda x, y: inet_ntoa(y) + inet_pton = lambda x, y: inet_aton(y) has_ipv6 = False elif has_ipv6: - import struct # The case of old Python at old Windows + import struct # The case of old Python at old Windows + def inet_pton(address_family, ip_string): if address_family == socket.AF_INET: return inet_aton(ip_string) elif address_family != socket.AF_INET6: raise socket.error( - 'Unknown address family %s' % (address_family,) - ) + 'Unknown address family %s' % (address_family,) + ) groups = ip_string.split(":") spaces = groups.count('') if '.' in groups[-1]: - groups[-1:] = [ "%x" % (x) for x in struct.unpack("!HH", inet_aton(groups[-1])) ] + groups[-1:] = ["%x" % x for x in struct.unpack("!HH", inet_aton(groups[-1]))] if spaces == 1: idx = groups.index('') - groups[idx:idx+1] = ['0'] * (8 - len(groups) + 1) + groups[idx:idx + 1] = ['0'] * (8 - len(groups) + 1) elif spaces == 2: zeros = ['0'] * (8 - len(groups) + 2) if ip_string.startswith('::'): @@ -66,7 +59,7 @@ groups[-2:] = zeros else: raise socket.error( - 'Invalid IPv6 address: "%s"' % (ip_string,) + 'Invalid IPv6 address: "%s"' % (ip_string,) ) elif spaces == 3: if ip_string != '::': @@ -76,10 +69,10 @@ return '\x00' * 16 elif spaces > 3: raise socket.error( - 'Invalid IPv6 address: "%s"' % (ip_string,) + 'Invalid IPv6 address: "%s"' % (ip_string,) ) - groups = [ t for t in [ int(t, 16) for t in groups ] if t & 0xFFFF == t ] + groups = [t for t in [int(t, 16) for t in groups] if t & 0xFFFF == t] if len(groups) != 8: raise socket.error( @@ -88,6 +81,7 @@ return struct.pack('!8H', *groups) + def inet_ntop(address_family, packed_ip): if address_family == socket.AF_INET: return inet_ntop(packed_ip) @@ -133,93 +127,129 @@ return ':'.join([f(x) for x in groups]) -transportAddressMIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 100)).setRevisions(("2002-11-01 00:00",)) +Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier") +NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") +ConstraintsIntersection, ConstraintsUnion, ValueRangeConstraint, ValueSizeConstraint, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", "ValueRangeConstraint", "ValueSizeConstraint", "SingleValueConstraint") +NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") +Integer32, Unsigned32, MibIdentifier, Counter32, ModuleIdentity, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, Bits, TimeTicks, ObjectIdentity, Counter64, Gauge32, IpAddress, iso, mib_2 = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "Unsigned32", "MibIdentifier", "Counter32", "ModuleIdentity", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "Bits", "TimeTicks", "ObjectIdentity", "Counter64", "Gauge32", "IpAddress", "iso", "mib-2") +DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") +transportAddressMIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 100)) +if mibBuilder.loadTexts: transportAddressMIB.setRevisions(('2002-11-01 00:00',)) if mibBuilder.loadTexts: transportAddressMIB.setLastUpdated('200211010000Z') if mibBuilder.loadTexts: transportAddressMIB.setOrganization('IETF Operations and Management Area') -if mibBuilder.loadTexts: transportAddressMIB.setContactInfo('Juergen Schoenwaelder (Editor)\n TU Braunschweig\n Bueltenweg 74/75\n 38106 Braunschweig, Germany\n\n Phone: +49 531 391-3289\n EMail: schoenw@ibr.cs.tu-bs.de\n\n Send comments to .') -if mibBuilder.loadTexts: transportAddressMIB.setDescription('This MIB module provides commonly used transport\n address definitions.\n\n Copyright (C) The Internet Society (2002). This version of\n this MIB module is part of RFC 3419; see the RFC itself for\n full legal notices.') +if mibBuilder.loadTexts: transportAddressMIB.setContactInfo('Juergen Schoenwaelder (Editor) TU Braunschweig Bueltenweg 74/75 38106 Braunschweig, Germany Phone: +49 531 391-3289 EMail: schoenw@ibr.cs.tu-bs.de Send comments to .') +if mibBuilder.loadTexts: transportAddressMIB.setDescription('This MIB module provides commonly used transport address definitions. Copyright (C) The Internet Society (2002). This version of this MIB module is part of RFC 3419; see the RFC itself for full legal notices.') transportDomains = MibIdentifier((1, 3, 6, 1, 2, 1, 100, 1)) transportDomainUdpIpv4 = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 1)) -if mibBuilder.loadTexts: transportDomainUdpIpv4.setDescription('The UDP over IPv4 transport domain. The corresponding\n transport address is of type TransportAddressIPv4 for\n global IPv4 addresses.') +if mibBuilder.loadTexts: transportDomainUdpIpv4.setStatus('current') +if mibBuilder.loadTexts: transportDomainUdpIpv4.setDescription('The UDP over IPv4 transport domain. The corresponding transport address is of type TransportAddressIPv4 for global IPv4 addresses.') transportDomainUdpIpv6 = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 2)) -if mibBuilder.loadTexts: transportDomainUdpIpv6.setDescription('The UDP over IPv6 transport domain. The corresponding\n transport address is of type TransportAddressIPv6 for\n global IPv6 addresses.') +if mibBuilder.loadTexts: transportDomainUdpIpv6.setStatus('current') +if mibBuilder.loadTexts: transportDomainUdpIpv6.setDescription('The UDP over IPv6 transport domain. The corresponding transport address is of type TransportAddressIPv6 for global IPv6 addresses.') transportDomainUdpIpv4z = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 3)) -if mibBuilder.loadTexts: transportDomainUdpIpv4z.setDescription('The UDP over IPv4 transport domain. The corresponding\n transport address is of type TransportAddressIPv4z for\n scoped IPv4 addresses with a zone index.') +if mibBuilder.loadTexts: transportDomainUdpIpv4z.setStatus('current') +if mibBuilder.loadTexts: transportDomainUdpIpv4z.setDescription('The UDP over IPv4 transport domain. The corresponding transport address is of type TransportAddressIPv4z for scoped IPv4 addresses with a zone index.') transportDomainUdpIpv6z = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 4)) -if mibBuilder.loadTexts: transportDomainUdpIpv6z.setDescription('The UDP over IPv6 transport domain. The corresponding\n transport address is of type TransportAddressIPv6z for\n scoped IPv6 addresses with a zone index.') +if mibBuilder.loadTexts: transportDomainUdpIpv6z.setStatus('current') +if mibBuilder.loadTexts: transportDomainUdpIpv6z.setDescription('The UDP over IPv6 transport domain. The corresponding transport address is of type TransportAddressIPv6z for scoped IPv6 addresses with a zone index.') transportDomainTcpIpv4 = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 5)) -if mibBuilder.loadTexts: transportDomainTcpIpv4.setDescription('The TCP over IPv4 transport domain. The corresponding\n transport address is of type TransportAddressIPv4 for\n global IPv4 addresses.') +if mibBuilder.loadTexts: transportDomainTcpIpv4.setStatus('current') +if mibBuilder.loadTexts: transportDomainTcpIpv4.setDescription('The TCP over IPv4 transport domain. The corresponding transport address is of type TransportAddressIPv4 for global IPv4 addresses.') transportDomainTcpIpv6 = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 6)) -if mibBuilder.loadTexts: transportDomainTcpIpv6.setDescription('The TCP over IPv6 transport domain. The corresponding\n transport address is of type TransportAddressIPv6 for\n global IPv6 addresses.') +if mibBuilder.loadTexts: transportDomainTcpIpv6.setStatus('current') +if mibBuilder.loadTexts: transportDomainTcpIpv6.setDescription('The TCP over IPv6 transport domain. The corresponding transport address is of type TransportAddressIPv6 for global IPv6 addresses.') transportDomainTcpIpv4z = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 7)) -if mibBuilder.loadTexts: transportDomainTcpIpv4z.setDescription('The TCP over IPv4 transport domain. The corresponding\n transport address is of type TransportAddressIPv4z for\n scoped IPv4 addresses with a zone index.') +if mibBuilder.loadTexts: transportDomainTcpIpv4z.setStatus('current') +if mibBuilder.loadTexts: transportDomainTcpIpv4z.setDescription('The TCP over IPv4 transport domain. The corresponding transport address is of type TransportAddressIPv4z for scoped IPv4 addresses with a zone index.') transportDomainTcpIpv6z = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 8)) -if mibBuilder.loadTexts: transportDomainTcpIpv6z.setDescription('The TCP over IPv6 transport domain. The corresponding\n transport address is of type TransportAddressIPv6z for\n scoped IPv6 addresses with a zone index.') +if mibBuilder.loadTexts: transportDomainTcpIpv6z.setStatus('current') +if mibBuilder.loadTexts: transportDomainTcpIpv6z.setDescription('The TCP over IPv6 transport domain. The corresponding transport address is of type TransportAddressIPv6z for scoped IPv6 addresses with a zone index.') transportDomainSctpIpv4 = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 9)) -if mibBuilder.loadTexts: transportDomainSctpIpv4.setDescription('The SCTP over IPv4 transport domain. The corresponding\n transport address is of type TransportAddressIPv4 for\n global IPv4 addresses. This transport domain usually\n represents the primary address on multihomed SCTP\n endpoints.') +if mibBuilder.loadTexts: transportDomainSctpIpv4.setStatus('current') +if mibBuilder.loadTexts: transportDomainSctpIpv4.setDescription('The SCTP over IPv4 transport domain. The corresponding transport address is of type TransportAddressIPv4 for global IPv4 addresses. This transport domain usually represents the primary address on multihomed SCTP endpoints.') transportDomainSctpIpv6 = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 10)) -if mibBuilder.loadTexts: transportDomainSctpIpv6.setDescription('The SCTP over IPv6 transport domain. The corresponding\n transport address is of type TransportAddressIPv6 for\n global IPv6 addresses. This transport domain usually\n represents the primary address on multihomed SCTP\n endpoints.') +if mibBuilder.loadTexts: transportDomainSctpIpv6.setStatus('current') +if mibBuilder.loadTexts: transportDomainSctpIpv6.setDescription('The SCTP over IPv6 transport domain. The corresponding transport address is of type TransportAddressIPv6 for global IPv6 addresses. This transport domain usually represents the primary address on multihomed SCTP endpoints.') transportDomainSctpIpv4z = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 11)) -if mibBuilder.loadTexts: transportDomainSctpIpv4z.setDescription('The SCTP over IPv4 transport domain. The corresponding\n transport address is of type TransportAddressIPv4z for\n scoped IPv4 addresses with a zone index. This transport\n domain usually represents the primary address on\n multihomed SCTP endpoints.') +if mibBuilder.loadTexts: transportDomainSctpIpv4z.setStatus('current') +if mibBuilder.loadTexts: transportDomainSctpIpv4z.setDescription('The SCTP over IPv4 transport domain. The corresponding transport address is of type TransportAddressIPv4z for scoped IPv4 addresses with a zone index. This transport domain usually represents the primary address on multihomed SCTP endpoints.') transportDomainSctpIpv6z = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 12)) -if mibBuilder.loadTexts: transportDomainSctpIpv6z.setDescription('The SCTP over IPv6 transport domain. The corresponding\n transport address is of type TransportAddressIPv6z for\n scoped IPv6 addresses with a zone index. This transport\n domain usually represents the primary address on\n multihomed SCTP endpoints.') +if mibBuilder.loadTexts: transportDomainSctpIpv6z.setStatus('current') +if mibBuilder.loadTexts: transportDomainSctpIpv6z.setDescription('The SCTP over IPv6 transport domain. The corresponding transport address is of type TransportAddressIPv6z for scoped IPv6 addresses with a zone index. This transport domain usually represents the primary address on multihomed SCTP endpoints.') transportDomainLocal = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 13)) -if mibBuilder.loadTexts: transportDomainLocal.setDescription('The Posix Local IPC transport domain. The corresponding\n transport address is of type TransportAddressLocal.\n\n The Posix Local IPC transport domain incorporates the\n well-known UNIX domain sockets.') +if mibBuilder.loadTexts: transportDomainLocal.setStatus('current') +if mibBuilder.loadTexts: transportDomainLocal.setDescription('The Posix Local IPC transport domain. The corresponding transport address is of type TransportAddressLocal. The Posix Local IPC transport domain incorporates the well-known UNIX domain sockets.') transportDomainUdpDns = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 14)) -if mibBuilder.loadTexts: transportDomainUdpDns.setDescription('The UDP transport domain using fully qualified domain\n names. The corresponding transport address is of type\n TransportAddressDns.') +if mibBuilder.loadTexts: transportDomainUdpDns.setStatus('current') +if mibBuilder.loadTexts: transportDomainUdpDns.setDescription('The UDP transport domain using fully qualified domain names. The corresponding transport address is of type TransportAddressDns.') transportDomainTcpDns = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 15)) -if mibBuilder.loadTexts: transportDomainTcpDns.setDescription('The TCP transport domain using fully qualified domain\n names. The corresponding transport address is of type\n TransportAddressDns.') +if mibBuilder.loadTexts: transportDomainTcpDns.setStatus('current') +if mibBuilder.loadTexts: transportDomainTcpDns.setDescription('The TCP transport domain using fully qualified domain names. The corresponding transport address is of type TransportAddressDns.') transportDomainSctpDns = ObjectIdentity((1, 3, 6, 1, 2, 1, 100, 1, 16)) -if mibBuilder.loadTexts: transportDomainSctpDns.setDescription('The SCTP transport domain using fully qualified domain\n names. The corresponding transport address is of type\n TransportAddressDns.') -class TransportDomain(ObjectIdentifier, TextualConvention): - pass - -class TransportAddressType(Integer32, TextualConvention): - subtypeSpec = Integer32.subtypeSpec+SingleValueConstraint(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,) - namedValues = NamedValues(("unknown", 0), ("udpIpv4", 1), ("udpIpv6", 2), ("udpIpv4z", 3), ("udpIpv6z", 4), ("tcpIpv4", 5), ("tcpIpv6", 6), ("tcpIpv4z", 7), ("tcpIpv6z", 8), ("sctpIpv4", 9), ("sctpIpv6", 10), ("sctpIpv4z", 11), ("sctpIpv6z", 12), ("local", 13), ("udpDns", 14), ("tcpDns", 15), ("sctpDns", 16),) +if mibBuilder.loadTexts: transportDomainSctpDns.setStatus('current') +if mibBuilder.loadTexts: transportDomainSctpDns.setDescription('The SCTP transport domain using fully qualified domain names. The corresponding transport address is of type TransportAddressDns.') -class TransportAddress(OctetString, TextualConvention): - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(0,255) +class TransportDomain(TextualConvention, ObjectIdentifier): + description = 'A value that represents a transport domain. Some possible values, such as transportDomainUdpIpv4, are defined in this module. Other possible values can be defined in other MIB modules.' + status = 'current' + +class TransportAddressType(TextualConvention, Integer32): + description = 'A value that represents a transport domain. This is the enumerated version of the transport domain registrations in this MIB module. The enumerated values have the following meaning: unknown(0) unknown transport address type udpIpv4(1) transportDomainUdpIpv4 udpIpv6(2) transportDomainUdpIpv6 udpIpv4z(3) transportDomainUdpIpv4z udpIpv6z(4) transportDomainUdpIpv6z tcpIpv4(5) transportDomainTcpIpv4 tcpIpv6(6) transportDomainTcpIpv6 tcpIpv4z(7) transportDomainTcpIpv4z tcpIpv6z(8) transportDomainTcpIpv6z sctpIpv4(9) transportDomainSctpIpv4 sctpIpv6(10) transportDomainSctpIpv6 sctpIpv4z(11) transportDomainSctpIpv4z sctpIpv6z(12) transportDomainSctpIpv6z local(13) transportDomainLocal udpDns(14) transportDomainUdpDns tcpDns(15) transportDomainTcpDns sctpDns(16) transportDomainSctpDns This textual convention can be used to represent transport domains in situations where a syntax of TransportDomain is unwieldy (for example, when used as an index). The usage of this textual convention implies that additional transport domains can only be supported by updating this MIB module. This extensibility restriction does not apply for the TransportDomain textual convention which allows MIB authors to define additional transport domains independently in other MIB modules.' + status = 'current' + subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) + namedValues = NamedValues(("unknown", 0), ("udpIpv4", 1), ("udpIpv6", 2), ("udpIpv4z", 3), ("udpIpv6z", 4), ("tcpIpv4", 5), ("tcpIpv6", 6), ("tcpIpv4z", 7), ("tcpIpv6z", 8), ("sctpIpv4", 9), ("sctpIpv6", 10), ("sctpIpv4z", 11), ("sctpIpv6z", 12), ("local", 13), ("udpDns", 14), ("tcpDns", 15), ("sctpDns", 16)) + +class TransportAddress(TextualConvention, OctetString): + description = "Denotes a generic transport address. A TransportAddress value is always interpreted within the context of a TransportAddressType or TransportDomain value. Every usage of the TransportAddress textual convention MUST specify the TransportAddressType or TransportDomain object which provides the context. Furthermore, MIB authors SHOULD define a separate TransportAddressType or TransportDomain object for each TransportAddress object. It is suggested that the TransportAddressType or TransportDomain is logically registered before the object(s) which use the TransportAddress textual convention if they appear in the same logical row. The value of a TransportAddress object must always be consistent with the value of the associated TransportAddressType or TransportDomain object. Attempts to set a TransportAddress object to a value which is inconsistent with the associated TransportAddressType or TransportDomain must fail with an inconsistentValue error. When this textual convention is used as a syntax of an index object, there may be issues with the limit of 128 sub-identifiers specified in SMIv2, STD 58. In this case, the OBJECT-TYPE declaration MUST include a 'SIZE' clause to limit the number of potential instance sub-identifiers." + status = 'current' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(0, 255) class TransportAddressIPv4(TextualConvention, OctetString): - displayHint = "1d.1d.1d.1d:2d" - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(6,6) + description = 'Represents a transport address consisting of an IPv4 address and a port number (as used for example by UDP, TCP and SCTP): octets contents encoding 1-4 IPv4 address network-byte order 5-6 port number network-byte order This textual convention SHOULD NOT be used directly in object definitions since it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with TransportAddressType or TransportDomain as a pair.' + status = 'current' + displayHint = '1d.1d.1d.1d:2d' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(6, 6) fixedLength = 6 - + def prettyIn(self, value): if isinstance(value, tuple): # Wild hack -- need to implement TextualConvention.prettyIn - value = inet_pton(socket.AF_INET, value[0]) + \ - int2oct((value[1] >> 8) & 0xff) + \ - int2oct(value[1] & 0xff) + value = inet_pton(socket.AF_INET, value[0]) + int2oct((value[1] >> 8) & 0xff) + int2oct(value[1] & 0xff) return OctetString.prettyIn(self, value) # Socket address syntax coercion - def __getitem__(self, i): + def __asSocketAddress(self): if not hasattr(self, '__tuple_value'): v = self.asOctets() self.__tuple_value = ( inet_ntop(socket.AF_INET, v[:4]), oct2int(v[4]) << 8 | oct2int(v[5]), ) - return self.__tuple_value[i] - + return self.__tuple_value + + def __iter__(self): + return iter(self.__asSocketAddress()) + + def __getitem__(self, item): + return self.__asSocketAddress()[item] + + class TransportAddressIPv6(TextualConvention, OctetString): - displayHint = "0a[2x:2x:2x:2x:2x:2x:2x:2x]0a:2d" - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(18,18) + description = 'Represents a transport address consisting of an IPv6 address and a port number (as used for example by UDP, TCP and SCTP): octets contents encoding 1-16 IPv6 address network-byte order 17-18 port number network-byte order This textual convention SHOULD NOT be used directly in object definitions since it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with TransportAddressType or TransportDomain as a pair.' + status = 'current' + displayHint = '0a[2x:2x:2x:2x:2x:2x:2x:2x]0a:2d' + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(18, 18) fixedLength = 18 def prettyIn(self, value): if not has_ipv6: raise error.PySnmpError('IPv6 not supported by platform') if isinstance(value, tuple): - value = inet_pton(socket.AF_INET6, value[0]) + \ - int2oct((value[1] >> 8) & 0xff) + \ - int2oct(value[1] & 0xff) + value = inet_pton(socket.AF_INET6, value[0]) + int2oct((value[1] >> 8) & 0xff) + int2oct(value[1] & 0xff) return OctetString.prettyIn(self, value) # Socket address syntax coercion - def __getitem__(self, i): + def __asSocketAddress(self): if not hasattr(self, '__tuple_value'): if not has_ipv6: raise error.PySnmpError('IPv6 not supported by platform') @@ -229,24 +259,39 @@ oct2int(v[16]) << 8 | oct2int(v[17]), 0, # flowinfo 0) # scopeid - return self.__tuple_value[i] + return self.__tuple_value + + def __iter__(self): + return iter(self.__asSocketAddress()) + + def __getitem__(self, item): + return self.__asSocketAddress()[item] -class TransportAddressIPv4z(OctetString, TextualConvention): +class TransportAddressIPv4z(TextualConvention, OctetString): + description = 'Represents a transport address consisting of an IPv4 address, a zone index and a port number (as used for example by UDP, TCP and SCTP): octets contents encoding 1-4 IPv4 address network-byte order 5-8 zone index network-byte order 9-10 port number network-byte order This textual convention SHOULD NOT be used directly in object definitions since it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with TransportAddressType or TransportDomain as a pair.' + status = 'current' displayHint = '1d.1d.1d.1d%4d:2d' - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(10,10) + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(10, 10) fixedLength = 10 -class TransportAddressIPv6z(OctetString, TextualConvention): +class TransportAddressIPv6z(TextualConvention, OctetString): + description = 'Represents a transport address consisting of an IPv6 address, a zone index and a port number (as used for example by UDP, TCP and SCTP): octets contents encoding 1-16 IPv6 address network-byte order 17-20 zone index network-byte order 21-22 port number network-byte order This textual convention SHOULD NOT be used directly in object definitions since it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with TransportAddressType or TransportDomain as a pair.' + status = 'current' displayHint = '0a[2x:2x:2x:2x:2x:2x:2x:2x%4d]0a:2d' - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(22,22) + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(22, 22) fixedLength = 22 -class TransportAddressLocal(OctetString, TextualConvention): +class TransportAddressLocal(TextualConvention, OctetString): + reference = 'Protocol Independent Interfaces (IEEE POSIX 1003.1g)' + description = "Represents a POSIX Local IPC transport address: octets contents encoding all POSIX Local IPC address string The Posix Local IPC transport domain subsumes UNIX domain sockets. This textual convention SHOULD NOT be used directly in object definitions since it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with TransportAddressType or TransportDomain as a pair. When this textual convention is used as a syntax of an index object, there may be issues with the limit of 128 sub-identifiers specified in SMIv2, STD 58. In this case, the OBJECT-TYPE declaration MUST include a 'SIZE' clause to limit the number of potential instance sub-identifiers." + status = 'current' displayHint = '1a' - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(1,255) + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(1, 255) -class TransportAddressDns(OctetString, TextualConvention): +class TransportAddressDns(TextualConvention, OctetString): + description = "Represents a DNS domain name followed by a colon ':' (ASCII character 0x3A) and a port number in ASCII. The name SHOULD be fully qualified whenever possible. Values of this textual convention are not directly useable as transport-layer addressing information, and require runtime resolution. As such, applications that write them must be prepared for handling errors if such values are not supported, or cannot be resolved (if resolution occurs at the time of the management operation). The DESCRIPTION clause of TransportAddress objects that may have TransportAddressDns values must fully describe how (and when) such names are to be resolved to IP addresses and vice versa. This textual convention SHOULD NOT be used directly in object definitions since it restricts addresses to a specific format. However, if it is used, it MAY be used either on its own or in conjunction with TransportAddressType or TransportDomain as a pair. When this textual convention is used as a syntax of an index object, there may be issues with the limit of 128 sub-identifiers specified in SMIv2, STD 58. In this case, the OBJECT-TYPE declaration MUST include a 'SIZE' clause to limit the number of potential instance sub-identifiers." + status = 'current' displayHint = '1a' - subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(1,255) + subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(1, 255) -mibBuilder.exportSymbols("TRANSPORT-ADDRESS-MIB", transportDomainTcpIpv4=transportDomainTcpIpv4, transportDomainTcpIpv6z=transportDomainTcpIpv6z, transportDomainLocal=transportDomainLocal, transportDomainSctpIpv4=transportDomainSctpIpv4, transportDomainTcpDns=transportDomainTcpDns, TransportAddressIPv6=TransportAddressIPv6, TransportAddressType=TransportAddressType, transportDomains=transportDomains, transportDomainUdpIpv6=transportDomainUdpIpv6, transportDomainUdpIpv6z=transportDomainUdpIpv6z, PYSNMP_MODULE_ID=transportAddressMIB, TransportAddressIPv4=TransportAddressIPv4, transportDomainSctpIpv6z=transportDomainSctpIpv6z, TransportDomain=TransportDomain, transportDomainUdpIpv4=transportDomainUdpIpv4, transportDomainTcpIpv4z=transportDomainTcpIpv4z, transportDomainSctpIpv4z=transportDomainSctpIpv4z, transportDomainSctpIpv6=transportDomainSctpIpv6, TransportAddressDns=TransportAddressDns, TransportAddress=TransportAddress, transportAddressMIB=transportAddressMIB, TransportAddressLocal=TransportAddressLocal, transportDomainUdpIpv4z=transportDomainUdpIpv4z, TransportAddressIPv6z=TransportAddressIPv6z, transportDomainTcpIpv6=transportDomainTcpIpv6, transportDomainUdpDns=transportDomainUdpDns, TransportAddressIPv4z=TransportAddressIPv4z, transportDomainSctpDns=transportDomainSctpDns) +mibBuilder.exportSymbols("TRANSPORT-ADDRESS-MIB", transportDomainUdpIpv6=transportDomainUdpIpv6, TransportDomain=TransportDomain, transportDomainSctpDns=transportDomainSctpDns, PYSNMP_MODULE_ID=transportAddressMIB, TransportAddressType=TransportAddressType, transportDomainTcpIpv4=transportDomainTcpIpv4, TransportAddressIPv6z=TransportAddressIPv6z, transportDomainLocal=transportDomainLocal, TransportAddressLocal=TransportAddressLocal, transportDomainUdpIpv4=transportDomainUdpIpv4, transportDomainUdpIpv4z=transportDomainUdpIpv4z, transportDomains=transportDomains, transportDomainSctpIpv4=transportDomainSctpIpv4, TransportAddressIPv6=TransportAddressIPv6, TransportAddressDns=TransportAddressDns, transportDomainSctpIpv6z=transportDomainSctpIpv6z, transportAddressMIB=transportAddressMIB, transportDomainTcpIpv6z=transportDomainTcpIpv6z, transportDomainSctpIpv6=transportDomainSctpIpv6, transportDomainUdpDns=transportDomainUdpDns, transportDomainTcpIpv6=transportDomainTcpIpv6, transportDomainUdpIpv6z=transportDomainUdpIpv6z, TransportAddressIPv4=TransportAddressIPv4, transportDomainSctpIpv4z=transportDomainSctpIpv4z, transportDomainTcpIpv4z=transportDomainTcpIpv4z, TransportAddress=TransportAddress, transportDomainTcpDns=transportDomainTcpDns, TransportAddressIPv4z=TransportAddressIPv4z) diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/rfc1902.py python-pysnmp4-4.4.3/pysnmp/smi/rfc1902.py --- python-pysnmp4-4.3.2/pysnmp/smi/rfc1902.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/rfc1902.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from pysnmp.proto import rfc1902, rfc1905 @@ -16,7 +16,8 @@ __all__ = ['ObjectIdentity', 'ObjectType', 'NotificationType'] -class ObjectIdentity: + +class ObjectIdentity(object): """Create an object representing MIB variable ID. At the protocol level, MIB variable is only identified by an OID. @@ -50,7 +51,7 @@ Other parameters ---------------- kwargs - MIB resolution options: + MIB resolution options(object): * whenever only MIB name is given, resolve into last variable defined in MIB if last=True. Otherwise resolves to first variable (default). @@ -256,7 +257,7 @@ Normally, ASN.1-to-Python MIB modules conversion is performed automatically through PySNMP/PySMI interaction. ASN1 MIB modules could also be manually compiled into Python via the - `mibdump.py `_ + `mibdump.py `_ tool. Examples @@ -355,7 +356,8 @@ addMibCompiler(mibViewController.mibBuilder, ifAvailable=True, ifNotAdded=True) else: - debug.logger & debug.flagMIB and debug.logger('adding MIB compiler with source paths %s' % ', '.join(self.__asn1SourcesToAdd)) + debug.logger & debug.flagMIB and debug.logger( + 'adding MIB compiler with source paths %s' % ', '.join(self.__asn1SourcesToAdd)) addMibCompiler( mibViewController.mibBuilder, sources=self.__asn1SourcesToAdd, @@ -375,7 +377,8 @@ if self.__state & self.stClean: return self - MibScalar, MibTableColumn = mibViewController.mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalar', 'MibTableColumn') + MibScalar, MibTableColumn = mibViewController.mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalar', + 'MibTableColumn') self.__indices = () @@ -418,7 +421,8 @@ self.__oid ) - debug.logger & debug.flagMIB and debug.logger('resolved %r into prefix %r and suffix %r' % (self.__args, prefix, suffix)) + debug.logger & debug.flagMIB and debug.logger( + 'resolved %r into prefix %r and suffix %r' % (self.__args, prefix, suffix)) modName, symName, _ = mibViewController.getNodeLocation(prefix) @@ -435,7 +439,7 @@ debug.logger & debug.flagMIB and debug.logger('resolved prefix %r into MIB node %r' % (prefix, mibNode)) - if isinstance(mibNode, MibTableColumn): # table column + if isinstance(mibNode, MibTableColumn): # table column if suffix: rowModName, rowSymName, _ = mibViewController.getNodeLocation( mibNode.name[:-1] @@ -444,7 +448,7 @@ rowModName, rowSymName ) self.__indices = rowNode.getIndicesFromInstId(suffix) - elif isinstance(mibNode, MibScalar): # scalar + elif isinstance(mibNode, MibScalar): # scalar if suffix: self.__indices = (rfc1902.ObjectName(suffix),) else: @@ -486,9 +490,10 @@ ) self.__label = label - debug.logger & debug.flagMIB and debug.logger('resolved %r into prefix %r and suffix %r' % (self.__args, prefix, suffix)) + debug.logger & debug.flagMIB and debug.logger( + 'resolved %r into prefix %r and suffix %r' % (self.__args, prefix, suffix)) - if isinstance(mibNode, MibTableColumn): # table + if isinstance(mibNode, MibTableColumn): # table rowModName, rowSymName, _ = mibViewController.getNodeLocation( mibNode.name[:-1] ) @@ -501,8 +506,9 @@ self.__oid += instIds self.__indices = rowNode.getIndicesFromInstId(instIds) except PyAsn1Error: - raise SmiError('Instance index %r to OID convertion failure at object %r: %s' % (self.__args[2:], mibNode.getLabel(), sys.exc_info()[1])) - elif self.__args[2:]: # any other kind of MIB node with indices + raise SmiError('Instance index %r to OID convertion failure at object %r: %s' % ( + self.__args[2:], mibNode.getLabel(), sys.exc_info()[1])) + elif self.__args[2:]: # any other kind of MIB node with indices if self.__args[2:]: instId = rfc1902.ObjectName( '.'.join([str(x) for x in self.__args[2:]]) @@ -522,9 +528,8 @@ s = rfc1902.OctetString() return '%s::%s%s%s' % ( self.__modName, self.__symName, - self.__indices and '.' or '', - '.'.join([x.isSuperTypeOf(s) and '"%s"' % x.prettyPrint() - or x.prettyPrint() for x in self.__indices]) + self.__indices and '.' or '', + '.'.join([x.isSuperTypeOf(s, matchConstraints=False) and '"%s"' % x.prettyPrint() or x.prettyPrint() for x in self.__indices]) ) else: raise SmiError('%s object not fully initialized' % self.__class__.__name__) @@ -628,12 +633,13 @@ else: raise SmiError('%s object not properly initialized for accessing %s' % (self.__class__.__name__, attr)) + # A two-element sequence of ObjectIdentity and SNMP data type object -class ObjectType: +class ObjectType(object): """Create an object representing MIB variable. Instances of :py:class:`~pysnmp.smi.rfc1902.ObjectType` class are - containters incorporating :py:class:`~pysnmp.smi.rfc1902.ObjectIdentity` + containers incorporating :py:class:`~pysnmp.smi.rfc1902.ObjectIdentity` class instance (identifying MIB variable) and optional value belonging to one of SNMP types (:RFC:`1902`). @@ -682,12 +688,13 @@ -------- >>> from pysnmp.smi.rfc1902 import * >>> ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0')) - ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0'), Null()) + ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0'), Null('')) >>> ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0), 'Linux i386') ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0), 'Linux i386') """ stDirty, stClean = 1, 2 + def __init__(self, objectIdentity, objectSyntax=rfc1905.unSpecified): if not isinstance(objectIdentity, ObjectIdentity): raise SmiError('initializer should be ObjectIdentity instance, not %r' % (objectIdentity,)) @@ -761,7 +768,7 @@ Normally, ASN.1-to-Python MIB modules conversion is performed automatically through PySNMP/PySMI interaction. ASN1 MIB modules could also be manually compiled into Python via the - `mibdump.py `_ + `mibdump.py `_ tool. Examples @@ -837,7 +844,8 @@ self.__args[0].resolveWithMib(mibViewController) - MibScalar, MibTableColumn = mibViewController.mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalar', 'MibTableColumn') + MibScalar, MibTableColumn = mibViewController.mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalar', + 'MibTableColumn') if not isinstance(self.__args[0].getMibNode(), (MibScalar, MibTableColumn)): @@ -856,9 +864,11 @@ try: self.__args[1] = self.__args[0].getMibNode().getSyntax().clone(self.__args[1]) except PyAsn1Error: - raise SmiError('MIB object %r having type %r failed to cast value %r: %s' % (self.__args[0].prettyPrint(), self.__args[0].getMibNode().getSyntax().__class__.__name__, self.__args[1], sys.exc_info()[1])) + raise SmiError('MIB object %r having type %r failed to cast value %r: %s' % ( + self.__args[0].prettyPrint(), self.__args[0].getMibNode().getSyntax().__class__.__name__, self.__args[1], + sys.exc_info()[1])) - if self.__args[1].isSuperTypeOf(rfc1902.ObjectIdentifier()): + if rfc1902.ObjectIdentifier().isSuperTypeOf(self.__args[1], matchConstraints=False): self.__args[1] = ObjectIdentity(self.__args[1]).resolveWithMib(mibViewController) self.__state |= self.stClean @@ -874,11 +884,12 @@ else: raise SmiError('%s object not fully initialized' % self.__class__.__name__) -class NotificationType: + +class NotificationType(object): """Create an object representing SNMP Notification. Instances of :py:class:`~pysnmp.smi.rfc1902.NotificationType` class are - containters incorporating :py:class:`~pysnmp.smi.rfc1902.ObjectIdentity` + containers incorporating :py:class:`~pysnmp.smi.rfc1902.ObjectIdentity` class instance (identifying particular notification) and a collection of MIB variables IDs that :py:class:`~pysnmp.entity.rfc3413.oneliner.cmdgen.NotificationOriginator` @@ -935,11 +946,12 @@ >>> from pysnmp.smi.rfc1902 import * >>> NotificationType(ObjectIdentity('1.3.6.1.6.3.1.1.5.3')) NotificationType(ObjectIdentity('1.3.6.1.6.3.1.1.5.3'), (), {}) - >>> NotificationType(ObjectIdentity('IP-MIB', 'linkDown'), ObjectName('3.5)) + >>> NotificationType(ObjectIdentity('IP-MIB', 'linkDown'), ObjectName('3.5')) NotificationType(ObjectIdentity('1.3.6.1.6.3.1.1.5.3'), ObjectName('3.5'), {}) """ stDirty, stClean = 1, 2 + def __init__(self, objectIdentity, instanceIndex=(), objects={}): if not isinstance(objectIdentity, ObjectIdentity): raise SmiError('initializer should be ObjectIdentity instance, not %r' % (objectIdentity,)) @@ -989,7 +1001,7 @@ """ debug.logger & debug.flagMIB and debug.logger('additional var-binds: %r' % (varBinds,)) if self.__state & self.stClean: - self.__varBinds.extend(varBinds) + raise SmiError('%s object is already sealed' % self.__class__.__name__) else: self.__additionalVarBinds.extend(varBinds) return self @@ -1046,7 +1058,7 @@ Normally, ASN.1-to-Python MIB modules conversion is performed automatically through PySNMP/PySMI interaction. ASN1 MIB modules could also be manually compiled into Python via the - `mibdump.py `_ + `mibdump.py `_ tool. Examples @@ -1138,18 +1150,32 @@ mibNode = self.__objectIdentity.getMibNode() + varBindsLocation = {} + if isinstance(mibNode, SmiNotificationType): for notificationObject in mibNode.getObjects(): - objectIdentity = ObjectIdentity(*notificationObject+self.__instanceIndex).resolveWithMib(mibViewController) + objectIdentity = ObjectIdentity(*notificationObject + self.__instanceIndex).resolveWithMib( + mibViewController) self.__varBinds.append( - ObjectType(objectIdentity, self.__objects.get(notificationObject, rfc1905.unSpecified)).resolveWithMib(mibViewController) + ObjectType(objectIdentity, + self.__objects.get(notificationObject, rfc1905.unSpecified)).resolveWithMib( + mibViewController) ) + varBindsLocation[objectIdentity] = len(self.__varBinds) - 1 else: - debug.logger & debug.flagMIB and debug.logger('WARNING: MIB object %r is not NOTIFICATION-TYPE (MIB not loaded?)' % (self.__objectIdentity,)) + debug.logger & debug.flagMIB and debug.logger( + 'WARNING: MIB object %r is not NOTIFICATION-TYPE (MIB not loaded?)' % (self.__objectIdentity,)) + + for varBinds in self.__additionalVarBinds: + if not isinstance(varBinds, ObjectType): + varBinds = ObjectType(ObjectIdentity(varBinds[0]), varBinds[1]) + varBinds.resolveWithMib(mibViewController) + if varBinds[0] in varBindsLocation: + self.__varBinds[varBindsLocation[varBinds[0]]] = varBinds + else: + self.__varBinds.append(varBinds) - if self.__additionalVarBinds: - self.__varBinds.extend(self.__additionalVarBinds) - self.__additionalVarBinds = [] + self.__additionalVarBinds = [] self.__state |= self.stClean diff -Nru python-pysnmp4-4.3.2/pysnmp/smi/view.py python-pysnmp4-4.4.3/pysnmp/smi/view.py --- python-pysnmp4-4.3.2/pysnmp/smi/view.py 2016-02-13 19:38:14.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp/smi/view.py 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,8 @@ # # This file is part of pysnmp software. # -# Copyright (c) 2005-2016, Ilya Etingof -# License: http://pysnmp.sf.net/license.html +# Copyright (c) 2005-2017, Ilya Etingof +# License: http://snmplabs.com/pysnmp/license.html # import sys from pysnmp.smi.indices import OrderedDict, OidOrderedDict @@ -13,16 +13,19 @@ if sys.version_info[0] <= 2: import types + classTypes = (types.ClassType, type) instanceTypes = (types.InstanceType, object) else: classTypes = (type,) instanceTypes = (object,) -class MibViewController: + +class MibViewController(object): def __init__(self, mibBuilder): self.mibBuilder = mibBuilder self.lastBuildId = -1 + self.__mibSymbolsIdx = OrderedDict() # Indexing part @@ -41,11 +44,11 @@ # # Module name -> module-scope indices - self.__mibSymbolsIdx = OrderedDict() + self.__mibSymbolsIdx.clear() # Oid <-> label indices - # This is potentionally ambiguous mapping. Sort modules in + # This is potentially ambiguous mapping. Sort modules in # ascending age for resolution def __sortFun(x, b=self.mibBuilder): if b.moduleID in b.mibSymbols[x]: @@ -76,13 +79,12 @@ # Types & MIB vars indices for n, v in self.mibBuilder.mibSymbols[modName].items(): - if n == self.mibBuilder.moduleID: # do not index this - continue # special symbol + if n == self.mibBuilder.moduleID: # do not index this + continue # special symbol if isinstance(v, classTypes): if n in mibMod['typeToModIdx']: raise error.SmiError( - 'Duplicate SMI type %s::%s, has %s' % \ - (modName, n, mibMod['typeToModIdx'][n]) + 'Duplicate SMI type %s::%s, has %s' % (modName, n, mibMod['typeToModIdx'][n]) ) globMibMod['typeToModIdx'][n] = modName mibMod['typeToModIdx'][n] = modName @@ -91,16 +93,15 @@ continue if n in mibMod['varToNameIdx']: raise error.SmiError( - 'Duplicate MIB variable %s::%s has %s' % \ - (modName, n, mibMod['varToNameIdx'][n]) + 'Duplicate MIB variable %s::%s has %s' % (modName, n, mibMod['varToNameIdx'][n]) ) globMibMod['varToNameIdx'][n] = v.name mibMod['varToNameIdx'][n] = v.name # Potentionally ambiguous mapping ahead globMibMod['oidToModIdx'][v.name] = modName mibMod['oidToModIdx'][v.name] = modName - globMibMod['oidToLabelIdx'][v.name] = (n, ) - mibMod['oidToLabelIdx'][v.name] = (n, ) + globMibMod['oidToLabelIdx'][v.name] = (n,) + mibMod['oidToLabelIdx'][v.name] = (n,) else: raise error.SmiError( 'Unexpected object %s::%s' % (modName, n) @@ -124,12 +125,12 @@ elif keydiff < 0: baseLabel = () keyLen = len(key) - i = keyLen-1 + i = keyLen - 1 while i: k = key[:i] if k in oidToLabelIdx: baseLabel = oidToLabelIdx[k] - if i != keyLen-1: + if i != keyLen - 1: baseLabel += key[i:-1] break i -= 1 @@ -207,9 +208,10 @@ if oid == label: raise error.NoSuchObjectError( str='Can\'t resolve node name %s::%s at %s' % - (modName, nodeName, self) + (modName, nodeName, self) ) - debug.logger & debug.flagMIB and debug.logger('getNodeNameByOid: resolved %s:%s -> %s.%s' % (modName, nodeName, label, suffix)) + debug.logger & debug.flagMIB and debug.logger( + 'getNodeNameByOid: resolved %s:%s -> %s.%s' % (modName, nodeName, label, suffix)) return oid, label, suffix def getNodeNameByDesc(self, nodeName, modName=''): @@ -224,7 +226,8 @@ raise error.NoSuchObjectError( str='No such symbol %s::%s at %s' % (modName, nodeName, self) ) - debug.logger & debug.flagMIB and debug.logger('getNodeNameByDesc: resolved %s:%s -> %s' % (modName, nodeName, oid)) + debug.logger & debug.flagMIB and debug.logger( + 'getNodeNameByDesc: resolved %s:%s -> %s' % (modName, nodeName, oid)) return self.getNodeNameByOid(oid, modName) def getNodeName(self, nodeName, modName=''): @@ -268,7 +271,7 @@ try: return self.getNodeName( self.__mibSymbolsIdx[modName]['oidToLabelIdx'].nextKey(oid) + suffix, modName - ) + ) except KeyError: raise error.NoSuchObjectError( str='No name next to %s::%s at %s' % (modName, nodeName, self) @@ -279,7 +282,7 @@ if len(oid) < 2: raise error.NoSuchObjectError( str='No parent name for %s::%s at %s' % - (modName, nodeName, self) + (modName, nodeName, self) ) return oid[:-1], label[:-1], oid[-1:] + suffix diff -Nru python-pysnmp4-4.3.2/pysnmp.egg-info/dependency_links.txt python-pysnmp4-4.4.3/pysnmp.egg-info/dependency_links.txt --- python-pysnmp4-4.3.2/pysnmp.egg-info/dependency_links.txt 2016-02-13 21:14:19.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp.egg-info/dependency_links.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ - diff -Nru python-pysnmp4-4.3.2/pysnmp.egg-info/PKG-INFO python-pysnmp4-4.4.3/pysnmp.egg-info/PKG-INFO --- python-pysnmp4-4.3.2/pysnmp.egg-info/PKG-INFO 2016-02-13 21:14:19.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp.egg-info/PKG-INFO 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -Metadata-Version: 1.1 -Name: pysnmp -Version: 4.3.2 -Summary: SNMP library for Python -Home-page: http://sourceforge.net/projects/pysnmp/ -Author: Ilya Etingof -Author-email: ilya@glas.net -License: BSD -Description: SNMP v1/v2c/v3 engine and apps written in pure-Python. Supports Manager/Agent/Proxy roles, scriptable MIBs, asynchronous operation and multiple transports. -Platform: any -Classifier: Development Status :: 5 - Production/Stable -Classifier: Environment :: Console -Classifier: Intended Audience :: Developers -Classifier: Intended Audience :: Education -Classifier: Intended Audience :: Information Technology -Classifier: Intended Audience :: System Administrators -Classifier: Intended Audience :: Telecommunications Industry -Classifier: License :: OSI Approved :: BSD License -Classifier: Natural Language :: English -Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 3 -Classifier: Topic :: Communications -Classifier: Topic :: Software Development :: Libraries :: Python Modules -Classifier: Topic :: System :: Monitoring -Classifier: Topic :: System :: Networking :: Monitoring -Classifier: Topic :: Software Development :: Libraries :: Python Modules diff -Nru python-pysnmp4-4.3.2/pysnmp.egg-info/requires.txt python-pysnmp4-4.4.3/pysnmp.egg-info/requires.txt --- python-pysnmp4-4.3.2/pysnmp.egg-info/requires.txt 2016-02-13 21:14:19.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp.egg-info/requires.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -pyasn1>=0.1.8 -pysmi -pycrypto>=2.4.1 diff -Nru python-pysnmp4-4.3.2/pysnmp.egg-info/SOURCES.txt python-pysnmp4-4.4.3/pysnmp.egg-info/SOURCES.txt --- python-pysnmp4-4.3.2/pysnmp.egg-info/SOURCES.txt 2016-02-13 21:14:20.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp.egg-info/SOURCES.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,458 +0,0 @@ -CHANGES.txt -LICENSE.txt -MANIFEST.in -README.txt -THANKS.txt -TODO.txt -requirements.txt -setup.cfg -setup.py -docs/Makefile -docs/README.txt -docs/net-snmpd.conf -docs/net-snmptrapd.conf -docs/mibs/PYSNMP-MIB.txt -docs/mibs/PYSNMP-SOURCE-MIB.txt -docs/mibs/PYSNMP-USM-MIB.txt -docs/source/changelog.rst -docs/source/conf.py -docs/source/contents.rst -docs/source/development.rst -docs/source/download.rst -docs/source/faq.rst -docs/source/license.rst -docs/source/quick-start.rst -docs/source/.static/css/rtdimproved.css -docs/source/.templates/layout.html -docs/source/docs/api-reference.rst -docs/source/docs/mib-object-instances.svg -docs/source/docs/nms-components.svg -docs/source/docs/oid-tree-mibs.svg -docs/source/docs/oid-tree.svg -docs/source/docs/pysnmp-architecture.rst -docs/source/docs/pysnmp-design.svg -docs/source/docs/pysnmp-hlapi-tutorial.rst -docs/source/docs/snmp-apps.svg -docs/source/docs/snmp-design.rst -docs/source/docs/snmp-engine.svg -docs/source/docs/snmp-history.rst -docs/source/docs/tutorial.rst -docs/source/docs/hlapi/asyncio/agent/ntforg/notification.rst -docs/source/docs/hlapi/asyncio/manager/cmdgen/bulkcmd.rst -docs/source/docs/hlapi/asyncio/manager/cmdgen/getcmd.rst -docs/source/docs/hlapi/asyncio/manager/cmdgen/nextcmd.rst -docs/source/docs/hlapi/asyncio/manager/cmdgen/setcmd.rst -docs/source/docs/hlapi/asyncore/agent/ntforg/notification.rst -docs/source/docs/hlapi/asyncore/manager/cmdgen/bulkcmd.rst -docs/source/docs/hlapi/asyncore/manager/cmdgen/getcmd.rst -docs/source/docs/hlapi/asyncore/manager/cmdgen/nextcmd.rst -docs/source/docs/hlapi/asyncore/manager/cmdgen/setcmd.rst -docs/source/docs/hlapi/asyncore/sync/agent/ntforg/notification.rst -docs/source/docs/hlapi/asyncore/sync/manager/cmdgen/bulkcmd.rst -docs/source/docs/hlapi/asyncore/sync/manager/cmdgen/getcmd.rst -docs/source/docs/hlapi/asyncore/sync/manager/cmdgen/nextcmd.rst -docs/source/docs/hlapi/asyncore/sync/manager/cmdgen/setcmd.rst -docs/source/docs/hlapi/twisted/agent/ntforg/notification.rst -docs/source/docs/hlapi/twisted/manager/cmdgen/bulkcmd.rst -docs/source/docs/hlapi/twisted/manager/cmdgen/getcmd.rst -docs/source/docs/hlapi/twisted/manager/cmdgen/nextcmd.rst -docs/source/docs/hlapi/twisted/manager/cmdgen/setcmd.rst -docs/source/examples/contents.rst -docs/source/examples/hlapi/asyncio/contents.rst -docs/source/examples/hlapi/asyncio/agent/ntforg/advanced-topics.rst -docs/source/examples/hlapi/asyncio/agent/ntforg/common-notifications.rst -docs/source/examples/hlapi/asyncio/manager/cmdgen/advanced-topics.rst -docs/source/examples/hlapi/asyncio/manager/cmdgen/snmp-versions.rst -docs/source/examples/hlapi/asyncio/manager/cmdgen/walking-operations.rst -docs/source/examples/hlapi/asyncore/contents.rst -docs/source/examples/hlapi/asyncore/agent/ntforg/advanced-topics.rst -docs/source/examples/hlapi/asyncore/agent/ntforg/common-notifications.rst -docs/source/examples/hlapi/asyncore/manager/cmdgen/advanced-topics.rst -docs/source/examples/hlapi/asyncore/manager/cmdgen/snmp-versions.rst -docs/source/examples/hlapi/asyncore/manager/cmdgen/walking-operations.rst -docs/source/examples/hlapi/asyncore/sync/contents.rst -docs/source/examples/hlapi/asyncore/sync/agent/ntforg/advanced-topics.rst -docs/source/examples/hlapi/asyncore/sync/agent/ntforg/common-notifications.rst -docs/source/examples/hlapi/asyncore/sync/agent/ntforg/evaluating-notification-type.rst -docs/source/examples/hlapi/asyncore/sync/agent/ntforg/snmp-v1-trap-variants.rst -docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/advanced-topics.rst -docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/mib-tweaks.rst -docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/modifying-variables.rst -docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/snmp-versions.rst -docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/table-operations.rst -docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/transport-tweaks.rst -docs/source/examples/hlapi/asyncore/sync/manager/cmdgen/walking-operations.rst -docs/source/examples/hlapi/trollius/contents.rst -docs/source/examples/hlapi/trollius/agent/ntforg/common-notifications.rst -docs/source/examples/hlapi/trollius/manager/cmdgen/snmp-versions.rst -docs/source/examples/hlapi/trollius/manager/cmdgen/walking-operations.rst -docs/source/examples/hlapi/twisted/contents.rst -docs/source/examples/hlapi/twisted/agent/ntforg/advanced-topics.rst -docs/source/examples/hlapi/twisted/agent/ntforg/common-notifications.rst -docs/source/examples/hlapi/twisted/manager/cmdgen/advanced-topics.rst -docs/source/examples/hlapi/twisted/manager/cmdgen/snmp-versions.rst -docs/source/examples/hlapi/twisted/manager/cmdgen/transport-tweaks.rst -docs/source/examples/hlapi/twisted/manager/cmdgen/walking-operations.rst -docs/source/examples/v1arch/asyncore/agent/cmdrsp/agent-side-mib-implementations.rst -docs/source/examples/v1arch/asyncore/agent/ntforg/transport-tweaks.rst -docs/source/examples/v1arch/asyncore/manager/cmdgen/fetching-variables.rst -docs/source/examples/v1arch/asyncore/manager/cmdgen/modifying-variables.rst -docs/source/examples/v1arch/asyncore/manager/cmdgen/transport-tweaks.rst -docs/source/examples/v1arch/asyncore/manager/cmdgen/walking-operations.rst -docs/source/examples/v1arch/asyncore/manager/ntfrcv/transport-tweaks.rst -docs/source/examples/v3arch/asyncio/contents.rst -docs/source/examples/v3arch/asyncio/agent/cmdrsp/snmp-versions.rst -docs/source/examples/v3arch/asyncio/manager/ntfrcv/transport-tweaks.rst -docs/source/examples/v3arch/asyncore/contents.rst -docs/source/examples/v3arch/asyncore/agent/cmdrsp/advanced-topics.rst -docs/source/examples/v3arch/asyncore/agent/cmdrsp/agent-side-mib-implementations.rst -docs/source/examples/v3arch/asyncore/agent/cmdrsp/snmp-versions.rst -docs/source/examples/v3arch/asyncore/agent/cmdrsp/transport-tweaks.rst -docs/source/examples/v3arch/asyncore/agent/ntforg/advanced-topics.rst -docs/source/examples/v3arch/asyncore/agent/ntforg/common-notifications.rst -docs/source/examples/v3arch/asyncore/agent/ntforg/evaluating-notification-type.rst -docs/source/examples/v3arch/asyncore/agent/ntforg/multiple-managers-operations.rst -docs/source/examples/v3arch/asyncore/agent/ntforg/snmp-versions.rst -docs/source/examples/v3arch/asyncore/agent/ntforg/transport-tweaks.rst -docs/source/examples/v3arch/asyncore/manager/cmdgen/advanced-topics.rst -docs/source/examples/v3arch/asyncore/manager/cmdgen/mib-tweaks.rst -docs/source/examples/v3arch/asyncore/manager/cmdgen/modifying-variables.rst -docs/source/examples/v3arch/asyncore/manager/cmdgen/snmp-versions.rst -docs/source/examples/v3arch/asyncore/manager/cmdgen/table-operations.rst -docs/source/examples/v3arch/asyncore/manager/cmdgen/transport-tweaks.rst -docs/source/examples/v3arch/asyncore/manager/cmdgen/walking-operations.rst -docs/source/examples/v3arch/asyncore/manager/ntfrcv/advanced-topics.rst -docs/source/examples/v3arch/asyncore/manager/ntfrcv/snmp-versions.rst -docs/source/examples/v3arch/asyncore/manager/ntfrcv/transport-tweaks.rst -docs/source/examples/v3arch/asyncore/proxy/command/protocol-conversion.rst -docs/source/examples/v3arch/asyncore/proxy/command/transport-conversion.rst -docs/source/examples/v3arch/trollius/contents.rst -docs/source/examples/v3arch/twisted/contents.rst -docs/source/examples/v3arch/twisted/agent/cmdrsp/agent-side-mib-implementations.rst -docs/source/examples/v3arch/twisted/agent/cmdrsp/snmp-versions.rst -docs/source/examples/v3arch/twisted/agent/cmdrsp/transport-tweaks.rst -docs/source/examples/v3arch/twisted/manager/ntfrcv/snmp-versions.rst -docs/source/examples/v3arch/twisted/manager/ntfrcv/transport-tweaks.rst -docs/source/faq/getting-peer-information.rst -docs/source/faq/how-to-implement-agent-mib.rst -docs/source/faq/ignored-snmp-packets.rst -docs/source/faq/listening-on-multiple-interfaces.rst -docs/source/faq/non-printable-snmp-values-apps.rst -docs/source/faq/non-printable-snmp-values-tools.rst -docs/source/faq/oids-not-increasing.rst -docs/source/faq/pass-custom-mib-to-manager.rst -docs/source/faq/py2exe-throws-error.rst -docs/source/faq/response-values-mib-resolution.rst -docs/source/faq/snmp-data-constraints-verification-failure.rst -docs/source/faq/walk-whole-mib.rst -examples/hlapi/asyncio/agent/ntforg/default-v1-trap.py -examples/hlapi/asyncio/agent/ntforg/multiple-notifications-at-once.py -examples/hlapi/asyncio/manager/cmdgen/getbulk-to-eom.py -examples/hlapi/asyncio/manager/cmdgen/multiple-concurrent-queries.py -examples/hlapi/asyncio/manager/cmdgen/multiple-sequential-queries.py -examples/hlapi/asyncio/manager/cmdgen/v1-get.py -examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py -examples/hlapi/asyncore/agent/ntforg/multiple-informs-at-once.py -examples/hlapi/asyncore/agent/ntforg/multiple-traps-at-once.py -examples/hlapi/asyncore/agent/ntforg/running-multiple-snmp-engines-at-once.py -examples/hlapi/asyncore/manager/cmdgen/multiple-concurrent-queries.py -examples/hlapi/asyncore/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py -examples/hlapi/asyncore/manager/cmdgen/pull-whole-mib.py -examples/hlapi/asyncore/manager/cmdgen/query-multiple-snmp-engines.py -examples/hlapi/asyncore/manager/cmdgen/v2c-get.py -examples/hlapi/asyncore/sync/agent/ntforg/custom-contextengineid.py -examples/hlapi/asyncore/sync/agent/ntforg/custom-contextname.py -examples/hlapi/asyncore/sync/agent/ntforg/custom-v1-trap.py -examples/hlapi/asyncore/sync/agent/ntforg/default-v1-trap.py -examples/hlapi/asyncore/sync/agent/ntforg/send-notification-with-additional-varbinds.py -examples/hlapi/asyncore/sync/agent/ntforg/v2c-trap-via-notification-type.py -examples/hlapi/asyncore/sync/agent/ntforg/v3-inform.py -examples/hlapi/asyncore/sync/agent/ntforg/v3-trap.py -examples/hlapi/asyncore/sync/manager/cmdgen/coerce-set-value-to-mib-spec.py -examples/hlapi/asyncore/sync/manager/cmdgen/custom-asn1-mib-search-path.py -examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid-and-contextname.py -examples/hlapi/asyncore/sync/manager/cmdgen/custom-contextengineid.py -examples/hlapi/asyncore/sync/manager/cmdgen/custom-pysnmp-mibs-search-path.py -examples/hlapi/asyncore/sync/manager/cmdgen/custom-timeout-and-retries.py -examples/hlapi/asyncore/sync/manager/cmdgen/custom-v3-security-name.py -examples/hlapi/asyncore/sync/manager/cmdgen/fetch-variables-over-ipv6.py -examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-index.py -examples/hlapi/asyncore/sync/manager/cmdgen/get-table-object-by-multiple-indices.py -examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py -examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-packets.py -examples/hlapi/asyncore/sync/manager/cmdgen/getbulk-limit-number-of-variables.py -examples/hlapi/asyncore/sync/manager/cmdgen/getnext-limit-number-of-variables.py -examples/hlapi/asyncore/sync/manager/cmdgen/getnext-multiple-oids-to-eom.py -examples/hlapi/asyncore/sync/manager/cmdgen/multiple-get-calls.py -examples/hlapi/asyncore/sync/manager/cmdgen/preload-pysnmp-mibs.py -examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-mib.py -examples/hlapi/asyncore/sync/manager/cmdgen/pull-whole-snmp-table.py -examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py -examples/hlapi/asyncore/sync/manager/cmdgen/set-multiple-scalar-values.py -examples/hlapi/asyncore/sync/manager/cmdgen/specific-v3-engine-id.py -examples/hlapi/asyncore/sync/manager/cmdgen/usm-md5-des.py -examples/hlapi/asyncore/sync/manager/cmdgen/usm-md5-none.py -examples/hlapi/asyncore/sync/manager/cmdgen/usm-none-none.py -examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py -examples/hlapi/asyncore/sync/manager/cmdgen/v1-get.py -examples/hlapi/asyncore/sync/manager/cmdgen/v2c-get.py -examples/hlapi/asyncore/sync/manager/cmdgen/v2c-getbulk.py -examples/hlapi/asyncore/sync/manager/cmdgen/waive-mib-lookup.py -examples/hlapi/trollius/agent/ntforg/default-v1-trap.py -examples/hlapi/trollius/manager/cmdgen/getbulk-to-eom.py -examples/hlapi/trollius/manager/cmdgen/v1-get.py -examples/hlapi/twisted/agent/ntforg/default-v1-trap.py -examples/hlapi/twisted/agent/ntforg/multiple-notifications-at-once.py -examples/hlapi/twisted/manager/cmdgen/custom-timeout-and-retries.py -examples/hlapi/twisted/manager/cmdgen/getbulk-to-eom.py -examples/hlapi/twisted/manager/cmdgen/multiple-concurrent-queries.py -examples/hlapi/twisted/manager/cmdgen/pull-mibs-from-multiple-agents-at-once.py -examples/hlapi/twisted/manager/cmdgen/pull-whole-mib.py -examples/hlapi/twisted/manager/cmdgen/v1-get.py -examples/smi/agent/custom-managed-object.py -examples/smi/agent/operations-on-managed-objects.py -examples/smi/manager/mib-tree-inspection.py -examples/smi/manager/var-binds-mib-resolution.py -examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py -examples/v1arch/asyncore/agent/ntforg/send-inform-over-ipv4-and-ipv6.py -examples/v1arch/asyncore/agent/ntforg/send-trap-over-ipv4-and-ipv6.py -examples/v1arch/asyncore/manager/cmdgen/broadcast-agent-discovery.py -examples/v1arch/asyncore/manager/cmdgen/fetch-scalar-value.py -examples/v1arch/asyncore/manager/cmdgen/getbulk-pull-whole-mib.py -examples/v1arch/asyncore/manager/cmdgen/getnext-pull-whole-mib.py -examples/v1arch/asyncore/manager/cmdgen/spoof-source-address.py -examples/v1arch/asyncore/manager/cmdgen/v2c-set.py -examples/v1arch/asyncore/manager/ntfrcv/listen-on-ipv4-and-ipv6-interfaces.py -examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py -examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py -examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py -examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py -examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py -examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py -examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py -examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py -examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py -examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py -examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py -examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py -examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py -examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py -examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py -examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py -examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py -examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py -examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py -examples/v3arch/asyncore/agent/ntforg/send-trap-to-multiple-managers.py -examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py -examples/v3arch/asyncore/agent/ntforg/v1-trap.py -examples/v3arch/asyncore/agent/ntforg/v2c-inform.py -examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py -examples/v3arch/asyncore/agent/ntforg/v2c-trap.py -examples/v3arch/asyncore/agent/ntforg/v3-trap.py -examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py -examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py -examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py -examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py -examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py -examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py -examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py -examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py -examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py -examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py -examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py -examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py -examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py -examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py -examples/v3arch/asyncore/manager/cmdgen/v1-get.py -examples/v3arch/asyncore/manager/cmdgen/v2c-set.py -examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py -examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py -examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py -examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py -examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py -examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py -examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py -examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py -examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py -examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py -examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py -examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py -examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py -examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py -examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py -examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py -pysnmp/__init__.py -pysnmp/cache.py -pysnmp/debug.py -pysnmp/error.py -pysnmp/nextid.py -pysnmp.egg-info/PKG-INFO -pysnmp.egg-info/SOURCES.txt -pysnmp.egg-info/dependency_links.txt -pysnmp.egg-info/requires.txt -pysnmp.egg-info/top_level.txt -pysnmp.egg-info/zip-safe -pysnmp/carrier/__init__.py -pysnmp/carrier/base.py -pysnmp/carrier/error.py -pysnmp/carrier/sockfix.py -pysnmp/carrier/sockmsg.py -pysnmp/carrier/asyncio/__init__.py -pysnmp/carrier/asyncio/base.py -pysnmp/carrier/asyncio/dispatch.py -pysnmp/carrier/asyncio/dgram/__init__.py -pysnmp/carrier/asyncio/dgram/base.py -pysnmp/carrier/asyncio/dgram/udp.py -pysnmp/carrier/asyncio/dgram/udp6.py -pysnmp/carrier/asyncore/__init__.py -pysnmp/carrier/asyncore/base.py -pysnmp/carrier/asyncore/dispatch.py -pysnmp/carrier/asyncore/dgram/__init__.py -pysnmp/carrier/asyncore/dgram/base.py -pysnmp/carrier/asyncore/dgram/udp.py -pysnmp/carrier/asyncore/dgram/udp6.py -pysnmp/carrier/asyncore/dgram/unix.py -pysnmp/carrier/asynsock/__init__.py -pysnmp/carrier/asynsock/dispatch.py -pysnmp/carrier/asynsock/dgram/__init__.py -pysnmp/carrier/asynsock/dgram/udp.py -pysnmp/carrier/asynsock/dgram/udp6.py -pysnmp/carrier/asynsock/dgram/unix.py -pysnmp/carrier/twisted/__init__.py -pysnmp/carrier/twisted/base.py -pysnmp/carrier/twisted/dispatch.py -pysnmp/carrier/twisted/dgram/__init__.py -pysnmp/carrier/twisted/dgram/base.py -pysnmp/carrier/twisted/dgram/udp.py -pysnmp/carrier/twisted/dgram/unix.py -pysnmp/entity/__init__.py -pysnmp/entity/config.py -pysnmp/entity/engine.py -pysnmp/entity/observer.py -pysnmp/entity/rfc3413/__init__.py -pysnmp/entity/rfc3413/cmdgen.py -pysnmp/entity/rfc3413/cmdrsp.py -pysnmp/entity/rfc3413/config.py -pysnmp/entity/rfc3413/context.py -pysnmp/entity/rfc3413/mibvar.py -pysnmp/entity/rfc3413/ntforg.py -pysnmp/entity/rfc3413/ntfrcv.py -pysnmp/entity/rfc3413/oneliner/__init__.py -pysnmp/entity/rfc3413/oneliner/cmdgen.py -pysnmp/entity/rfc3413/oneliner/ntforg.py -pysnmp/hlapi/__init__.py -pysnmp/hlapi/auth.py -pysnmp/hlapi/context.py -pysnmp/hlapi/lcd.py -pysnmp/hlapi/transport.py -pysnmp/hlapi/varbinds.py -pysnmp/hlapi/asyncio/__init__.py -pysnmp/hlapi/asyncio/cmdgen.py -pysnmp/hlapi/asyncio/ntforg.py -pysnmp/hlapi/asyncio/transport.py -pysnmp/hlapi/asyncore/__init__.py -pysnmp/hlapi/asyncore/cmdgen.py -pysnmp/hlapi/asyncore/ntforg.py -pysnmp/hlapi/asyncore/transport.py -pysnmp/hlapi/asyncore/sync/__init__.py -pysnmp/hlapi/asyncore/sync/cmdgen.py -pysnmp/hlapi/asyncore/sync/ntforg.py -pysnmp/hlapi/asyncore/sync/compat/__init__.py -pysnmp/hlapi/asyncore/sync/compat/cmdgen.py -pysnmp/hlapi/asyncore/sync/compat/ntforg.py -pysnmp/hlapi/twisted/__init__.py -pysnmp/hlapi/twisted/cmdgen.py -pysnmp/hlapi/twisted/ntforg.py -pysnmp/hlapi/twisted/transport.py -pysnmp/proto/__init__.py -pysnmp/proto/cache.py -pysnmp/proto/errind.py -pysnmp/proto/error.py -pysnmp/proto/rfc1155.py -pysnmp/proto/rfc1157.py -pysnmp/proto/rfc1901.py -pysnmp/proto/rfc1902.py -pysnmp/proto/rfc1905.py -pysnmp/proto/rfc3411.py -pysnmp/proto/rfc3412.py -pysnmp/proto/acmod/__init__.py -pysnmp/proto/acmod/rfc3415.py -pysnmp/proto/acmod/void.py -pysnmp/proto/api/__init__.py -pysnmp/proto/api/v1.py -pysnmp/proto/api/v2c.py -pysnmp/proto/api/verdec.py -pysnmp/proto/mpmod/__init__.py -pysnmp/proto/mpmod/base.py -pysnmp/proto/mpmod/cache.py -pysnmp/proto/mpmod/rfc2576.py -pysnmp/proto/mpmod/rfc3412.py -pysnmp/proto/proxy/__init__.py -pysnmp/proto/proxy/rfc2576.py -pysnmp/proto/secmod/__init__.py -pysnmp/proto/secmod/base.py -pysnmp/proto/secmod/cache.py -pysnmp/proto/secmod/rfc2576.py -pysnmp/proto/secmod/eso/__init__.py -pysnmp/proto/secmod/eso/priv/__init__.py -pysnmp/proto/secmod/eso/priv/aes192.py -pysnmp/proto/secmod/eso/priv/aes256.py -pysnmp/proto/secmod/eso/priv/aesbase.py -pysnmp/proto/secmod/eso/priv/des3.py -pysnmp/proto/secmod/rfc3414/__init__.py -pysnmp/proto/secmod/rfc3414/localkey.py -pysnmp/proto/secmod/rfc3414/service.py -pysnmp/proto/secmod/rfc3414/auth/__init__.py -pysnmp/proto/secmod/rfc3414/auth/base.py -pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py -pysnmp/proto/secmod/rfc3414/auth/hmacsha.py -pysnmp/proto/secmod/rfc3414/auth/noauth.py -pysnmp/proto/secmod/rfc3414/priv/__init__.py -pysnmp/proto/secmod/rfc3414/priv/base.py -pysnmp/proto/secmod/rfc3414/priv/des.py -pysnmp/proto/secmod/rfc3414/priv/nopriv.py -pysnmp/proto/secmod/rfc3826/__init__.py -pysnmp/proto/secmod/rfc3826/priv/__init__.py -pysnmp/proto/secmod/rfc3826/priv/aes.py -pysnmp/smi/__init__.py -pysnmp/smi/builder.py -pysnmp/smi/compiler.py -pysnmp/smi/error.py -pysnmp/smi/exval.py -pysnmp/smi/indices.py -pysnmp/smi/instrum.py -pysnmp/smi/rfc1902.py -pysnmp/smi/view.py -pysnmp/smi/mibs/ASN1-ENUMERATION.py -pysnmp/smi/mibs/ASN1-REFINEMENT.py -pysnmp/smi/mibs/ASN1.py -pysnmp/smi/mibs/PYSNMP-MIB.py -pysnmp/smi/mibs/PYSNMP-SOURCE-MIB.py -pysnmp/smi/mibs/PYSNMP-USM-MIB.py -pysnmp/smi/mibs/RFC1158-MIB.py -pysnmp/smi/mibs/RFC1213-MIB.py -pysnmp/smi/mibs/SNMP-COMMUNITY-MIB.py -pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py -pysnmp/smi/mibs/SNMP-MPD-MIB.py -pysnmp/smi/mibs/SNMP-NOTIFICATION-MIB.py -pysnmp/smi/mibs/SNMP-PROXY-MIB.py -pysnmp/smi/mibs/SNMP-TARGET-MIB.py -pysnmp/smi/mibs/SNMP-USER-BASED-SM-3DES-MIB.py -pysnmp/smi/mibs/SNMP-USER-BASED-SM-MIB.py -pysnmp/smi/mibs/SNMP-USM-AES-MIB.py -pysnmp/smi/mibs/SNMP-VIEW-BASED-ACM-MIB.py -pysnmp/smi/mibs/SNMPv2-CONF.py -pysnmp/smi/mibs/SNMPv2-MIB.py -pysnmp/smi/mibs/SNMPv2-SMI.py -pysnmp/smi/mibs/SNMPv2-TC.py -pysnmp/smi/mibs/SNMPv2-TM.py -pysnmp/smi/mibs/TRANSPORT-ADDRESS-MIB.py -pysnmp/smi/mibs/__init__.py -pysnmp/smi/mibs/instances/__PYSNMP-USM-MIB.py -pysnmp/smi/mibs/instances/__SNMP-FRAMEWORK-MIB.py -pysnmp/smi/mibs/instances/__SNMP-MPD-MIB.py -pysnmp/smi/mibs/instances/__SNMP-TARGET-MIB.py -pysnmp/smi/mibs/instances/__SNMP-USER-BASED-SM-MIB.py -pysnmp/smi/mibs/instances/__SNMP-VIEW-BASED-ACM-MIB.py -pysnmp/smi/mibs/instances/__SNMPv2-MIB.py -pysnmp/smi/mibs/instances/__init__.py \ No newline at end of file diff -Nru python-pysnmp4-4.3.2/pysnmp.egg-info/top_level.txt python-pysnmp4-4.4.3/pysnmp.egg-info/top_level.txt --- python-pysnmp4-4.3.2/pysnmp.egg-info/top_level.txt 2016-02-13 21:14:19.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp.egg-info/top_level.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -pysnmp diff -Nru python-pysnmp4-4.3.2/pysnmp.egg-info/zip-safe python-pysnmp4-4.4.3/pysnmp.egg-info/zip-safe --- python-pysnmp4-4.3.2/pysnmp.egg-info/zip-safe 2015-11-13 17:24:42.000000000 +0000 +++ python-pysnmp4-4.4.3/pysnmp.egg-info/zip-safe 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ - diff -Nru python-pysnmp4-4.3.2/README.md python-pysnmp4-4.4.3/README.md --- python-pysnmp4-4.3.2/README.md 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/README.md 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,159 @@ + +SNMP library for Python +----------------------- +[![PyPI](https://img.shields.io/pypi/v/pysnmp.svg?maxAge=2592000)](https://pypi.python.org/pypi/pysnmp) +[![Python Versions](https://img.shields.io/pypi/pyversions/pysnmp.svg)](https://pypi.python.org/pypi/pysnmp/) +[![Build status](https://travis-ci.org/etingof/pysnmp.svg?branch=master)](https://secure.travis-ci.org/etingof/pysnmp) +[![GitHub license](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/etingof/pysnmp/master/LICENSE.txt) + +This is a pure-Python, open source and free implementation of v1/v2c/v3 +SNMP engine distributed under 2-clause [BSD license](http://snmplabs.com/pysnmp/license.html). + +The PySNMP project was initially sponsored by a [PSF](http://www.python.org/psf/) grant. +Thank you! + +Features +-------- + +* Complete SNMPv1/v2c and SNMPv3 support +* SMI framework for resolving MIB information and implementing SMI + Managed Objects +* Complete SNMP entity implementation +* USM Extended Security Options support (3DES, 192/256-bit AES encryption) +* Extensible network transports framework (UDP/IPv4, UDP/IPv6) +* Asynchronous socket-based IO API support +* [Twisted](http://twistedmatrix.com), [Asyncio](https://docs.python.org/3/library/asyncio.html) + and [Trollius](http://trollius.readthedocs.org/index.html) integration +* [PySMI](http://snmplabs.com/pysmi/) integration for dynamic MIB compilation +* Built-in instrumentation exposing protocol engine operations +* Python eggs and py2exe friendly +* 100% Python, works with Python 2.4 though 3.6 +* MT-safe (if SnmpEngine is thread-local) + +Features, specific to SNMPv3 model include: + +* USM authentication (MD5/SHA-1/SHA-2) and privacy (DES/AES) protocols (RFC3414, RFC7860) +* View-based access control to use with any SNMP model (RFC3415) +* Built-in SNMP proxy PDU converter for building multi-lingual + SNMP entities (RFC2576) +* Remote SNMP engine configuration +* Optional SNMP engine discovery +* Shipped with standard SNMP applications (RC3413) + + +Download & Install +------------------ + +The PySNMP software is freely available for download from [PyPI](https://pypi.python.org/pypi/pysnmp) +and [GitHub](https://github.com/etingof/pysnmp.git). + +Just run: + +```bash +$ pip install pysnmp +``` + +to download and install PySNMP along with its dependencies: + +* [PyASN1](http://snmplabs.com/pyasn1/) +* [PyCryptodomex](https://pycryptodome.readthedocs.io) (required only if SNMPv3 encryption is in use) +* [PySMI](http://snmplabs.com/pysmi/) (required for MIB services only) + +Besides the library, command-line [SNMP utilities](https://github.com/etingof/pysnmp-apps) +written in pure-Python could be installed via: + +```bash +$ pip install pysnmp-apps +``` + +and used in the very similar manner as conventional Net-SNMP tools: + +```bash +$ snmpget.py -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 demo.snmplabs.com sysDescr.0 +SNMPv2-MIB::sysDescr.0 = STRING: Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686 +``` + +Examples +-------- + +PySNMP is designed in a layered fashion. Top-level and easiest to use API is known as +*hlapi*. Here's a quick example on how to SNMP GET: + +```python +from pysnmp.hlapi import * + +iterator = getCmd(SnmpEngine(), + CommunityData('public'), + UdpTransportTarget(('demo.snmplabs.com', 161)), + ContextData(), + ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))) + +errorIndication, errorStatus, errorIndex, varBinds = next(iterator) + +if errorIndication: # SNMP engine errors + print(errorIndication) +else: + if errorStatus: # SNMP agent errors + print('%s at %s' % (errorStatus.prettyPrint(), varBinds[int(errorIndex)-1] if errorIndex else '?')) + else: + for varBind in varBinds: # SNMP response contents + print(' = '.join([x.prettyPrint() for x in varBind])) +``` + +This is how to send SNMP TRAP: + +```python +from pysnmp.hlapi import * + +errorIndication, errorStatus, errorIndex, varBinds = next( + sendNotification( + SnmpEngine(OctetString(hexValue='8000000001020304')), + UsmUserData('usr-sha-aes128', 'authkey1', 'privkey1', + authProtocol=usmHMACSHAAuthProtocol, + privProtocol=usmAesCfb128Protocol), + UdpTransportTarget(('demo.snmplabs.com', 162)), + ContextData(), + 'trap', + NotificationType(ObjectIdentity('SNMPv2-MIB', 'authenticationFailure')) + ) +) + +if errorIndication: + print(errorIndication) +``` + +We maintain publicly available SNMP Agent and TRAP sink at +[demo.snmplabs.com](http://snmplabs.com/snmpsim/public-snmp-agent-simulator.html). You are +welcome to use it while experimenting with whatever SNMP software you deal with. + +```bash +$ python3 examples/hlapi/asyncore/sync/manager/cmdgen/usm-sha-aes128.py +SNMPv2-MIB::sysDescr.0 = SunOS zeus.snmplabs.com 4.1.3_U1 1 sun4m +$ +$ python3 examples//hlapi/asyncore/sync/agent/ntforg/v3-inform.py +SNMPv2-MIB::sysUpTime.0 = 0 +SNMPv2-MIB::snmpTrapOID.0 = SNMPv2-MIB::warmStart +SNMPv2-MIB::sysName.0 = system name +``` + +Other than that, PySNMP is capable to automatically fetch and use required MIBs from HTTP, FTP sites +or local directories. You could configure any MIB source available to you (including +[this one](http://mibs.snmplabs.com/asn1/)) for that purpose. + +For more example scripts please refer to [examples section](http://snmplabs.com/pysnmp/examples/contents.html#high-level-snmp) +at pysnmp web site. + +Documentation +------------- + +Library documentation and examples can be found at the [pysnmp project site](http://snmplabs.com/pysnmp/). + +If something does not work as expected, please +[open an issue](https://github.com/etingof/pysnmp/issues) at GitHub or +post your question [on Stack Overflow](http://stackoverflow.com/questions/ask) +or try browsing pysnmp +[mailing list archives](https://sourceforge.net/p/pysnmp/mailman/pysnmp-users/). + +Bug reports and PRs are appreciated! ;-) + +Copyright (c) 2005-2017, [Ilya Etingof](mailto:etingof@gmail.com). All rights reserved. diff -Nru python-pysnmp4-4.3.2/README.txt python-pysnmp4-4.4.3/README.txt --- python-pysnmp4-4.3.2/README.txt 2015-11-13 20:18:28.000000000 +0000 +++ python-pysnmp4-4.4.3/README.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ - -PYTHON SNMP FRAMEWORK ---------------------- - -This is a pure-Python, open source and free implementation of v1/v2c/v3 -SNMP engine. - -The PySNMP project has been sponsored by a PSF grant [11]. Thanks! - -FEATURES --------- - -* Complete SNMPv1/v2c and SNMPv3 support -* SMI framework for resolving MIB information and implementing SMI - Managed Objects -* Complete SNMP entity implementation -* USM Extended Security Options support (3DES, 192/256-bit AES encryption) -* Extensible network transports framework (UDP/IPv4, UDP/IPv6 and UNIX domain - sockets already implemented) -* Asynchronous socket-based IO API support -* Twisted, Asyncio and Trollius integration -* PySMI integration for dynamic MIB compilation -* Python eggs and py2exe friendly -* 100% Python, works with Python 2.4 though 3.5 -* MT-safe (only if run locally to a thread) - -Features, specific to SNMPv3 model include: - -* USM authentication (MD5/SHA) and privacy (DES/AES) protocols (RFC3414) -* View-based access control to use with any SNMP model (RFC3415) -* Built-in SNMP proxy PDU converter for building multi-lingual - SNMP entities (RFC2576) -* Remote SNMP engine configuration -* Optional SNMP engine discovery -* Shipped with standard SNMP applications (RC3413) - -MISFEATURES ------------ - -* Much slower than C implementations. Some optimization still possible. - -INSTALLATION ------------- - -The PySNMP package uses setuptools for package management. The PyASN1 [8] -package is required. For secure SNMPv3 communication, PyCrypto [9] -should also be installed. For MIB-related operations PySMI [10] package is -needed. - -OPERATION ---------- - -As of this writing, PySNMP implements two SNMP architectures -- the first -is a legacy one specified by SNMPv1 & v2c standards [5]. It is quite -low-level and protocol-oriented by design. In particular, it requires -application to manage authentication and access issues, deal with transport -failures and similar housekeeping stuff. - -The second model supported by PySNMP is aligned to SNMPv3 architecture, -as specified in [4]. Here is an example on querying SNMP agent -for arbitrary value (sysDescr) over SNMP v3 with authentication and -privacy enabled: - -8X---------------- cut here -------------------- - -from pysnmp.hlapi import * - -iterator = getCmd( - SnmpEngine(), - CommunityData('public'), - UdpTransportTarget(('demo.snmplabs.com', 161)), - ContextData(), - ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)) -) -errorIndication, errorStatus, errorIndex, varBinds = next(iterator) - -if errorIndication: # SNMP engine errors - print errorIndication -else: - if errorStatus: # SNMP agent errors - print(%s at %s' % (errorStatus.prettyPrint(), - errorIndex and varBinds[int(errorIndex)-1] or '?')) - else: - for varBind in varBinds: - print('='.join([x.prettyPrint() for x in varBind])) - -8X---------------- cut here -------------------- - -For more examples, please see the examples directory in the PySNMP distribution. - -MIB SUPPORT ------------ - -The pysnmp.smi package component defines and implements data model for SNMP SMI -objects. With that model, various objects defined in MIB file could be -implemented in Python, loaded into SNMP entity and used for verification and -visualisation purposes (SNMP manager side) and/or become management targets -(SNMP agent side). - -The PySMI package [10] could be used for automatic, one-time convertion of -ASN.1 MIB text files into Python code snippets designed to be dynamically -loaded and used by PySNMP engine. - -A large set of pre-compiled MIB files is shipped along the pysnmp-mibs -package.[2] - -AVAILABILITY ------------- - -The PySNMP software is freely available for download from PyPI and -project homepage [1] - -GETTING HELP ------------- - -If something does not work as expected, please, try browsing PySNMP -mailing list archives or post your question there. [7] - -FEEDBACK --------- - -I'm interested in bug reports and fixes, suggestions and improvements. -I'd be happy knowning whenever you used the PySNMP software for whatever -purpose. Please, send me a note then. Thanks! - -REFERENCES ----------- - -[1] PySNMP project homepage: - http://pysnmp.sf.net - -[2] Pre-compiled PySNMP MIB modules: - http://sourceforge.net/project/showfiles.php?group_id=14735 - -[3] PySNMP applications: - http://sourceforge.net/project/showfiles.php?group_id=14735 - -[4] SNMP Version 3 specification and related - http://www.ibr.cs.tu-bs.de/projects/snmpv3/ - -[5] SNMP Version 1/2 specifications: - http://www.ietf.org/rfc/rfc1155.txt - http://www.ietf.org/rfc/rfc1158.txt - http://www.ietf.org/rfc/rfc1901.txt - http://www.ietf.org/rfc/rfc1909.txt - -[6] PySNMP mailing list archives: - http://sourceforge.net/mail/?group_id=14735 - -[7] PyASN1 project homepage: - http://pyasn1.sf.net - -[8] PyCrypto package: - http://pycrypto.org - -[9] PySMI package: - http://sf.net/projects/pysmi - - -[10] Python Software Foundation - http://www.python.org/psf/ - -=-=-= -mailto: ilya@glas.net diff -Nru python-pysnmp4-4.3.2/requirements.txt python-pysnmp4-4.4.3/requirements.txt --- python-pysnmp4-4.3.2/requirements.txt 2015-09-27 20:09:38.000000000 +0000 +++ python-pysnmp4-4.4.3/requirements.txt 2017-12-22 11:53:40.000000000 +0000 @@ -1,3 +1,3 @@ -pyasn1>=0.1.8 pysmi -pycrypto>=2.4.1 +pycryptodomex +pyasn1>=0.2.3 diff -Nru python-pysnmp4-4.3.2/runtests.sh python-pysnmp4-4.4.3/runtests.sh --- python-pysnmp4-4.3.2/runtests.sh 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/runtests.sh 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +set -e + +for x in examples/hlapi/asyncore/sync/manager/cmdgen/*.py \ + examples/hlapi/asyncore/sync/agent/ntforg/*.py \ + examples/hlapi/asyncore/manager/cmdgen/*.py \ + examples/hlapi/asyncore/agent/ntforg/*.py \ + examples/v3arch/asyncore/manager/cmdgen/*.py \ + examples/v3arch/asyncore/agent/ntforg/*.py \ + examples/v1arch/asyncore/manager/cmdgen/*.py \ + examples/v1arch/asyncore/agent/ntforg/*.py \ + examples/smi/manager/*py \ + examples/smi/agent/*.py +do + case "${x}" in + *spoof*|*ipv6*) + echo "skipping ${x}" + continue + ;; + *) + python "${x}" + ;; + esac +done \ No newline at end of file diff -Nru python-pysnmp4-4.3.2/setup.cfg python-pysnmp4-4.4.3/setup.cfg --- python-pysnmp4-4.3.2/setup.cfg 2016-02-13 21:14:20.000000000 +0000 +++ python-pysnmp4-4.4.3/setup.cfg 2017-12-22 11:53:40.000000000 +0000 @@ -1,8 +1,2 @@ [bdist_wheel] universal = 1 - -[egg_info] -tag_date = 0 -tag_svn_revision = 0 -tag_build = - diff -Nru python-pysnmp4-4.3.2/setup.py python-pysnmp4-4.4.3/setup.py --- python-pysnmp4-4.3.2/setup.py 2015-10-16 16:50:39.000000000 +0000 +++ python-pysnmp4-4.4.3/setup.py 2017-12-22 11:53:40.000000000 +0000 @@ -20,110 +20,111 @@ Natural Language :: English Operating System :: OS Independent Programming Language :: Python :: 2 +Programming Language :: Python :: 2.4 +Programming Language :: Python :: 2.5 +Programming Language :: Python :: 2.6 +Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 +Programming Language :: Python :: 3.2 +Programming Language :: Python :: 3.3 +Programming Language :: Python :: 3.4 +Programming Language :: Python :: 3.5 +Programming Language :: Python :: 3.6 Topic :: Communications -Topic :: Software Development :: Libraries :: Python Modules Topic :: System :: Monitoring Topic :: System :: Networking :: Monitoring Topic :: Software Development :: Libraries :: Python Modules """ + def howto_install_setuptools(): print(""" Error: You need setuptools Python package! - It's very easy to install it, just type (as root on Linux): + It's very easy to install it, just type: - wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py + wget https://bootstrap.pypa.io/ez_setup.py python ez_setup.py Then you could make eggs from this package. """) + if sys.version_info[:2] < (2, 4): print("ERROR: this package requires Python 2.4 or later!") sys.exit(1) try: from setuptools import setup + params = { - 'install_requires': [ 'pyasn1>=0.1.8', 'pysmi' ], + 'install_requires': ['pyasn1>=0.2.3', 'pysmi', 'pycryptodomex'], 'zip_safe': True - } - if sys.platform.lower()[:3] != 'win': - params['install_requires'].append('pycrypto>=2.4.1') + } except ImportError: for arg in sys.argv: if 'egg' in arg: howto_install_setuptools() sys.exit(1) + from distutils.core import setup + params = {} if sys.version_info[:2] > (2, 4): - params['requires'] = [ 'pyasn1(>=0.1.8)', 'pysmi' ] - if sys.platform.lower()[:3] != 'win': - params['requires'].append('pycrypto(>=2.4.1)') - -if sys.platform.lower()[:3] == 'win': - try: - import Crypto - except ImportError: - sys.stderr.write("""WARNING! WARNING! WARNING! -PyCrypto binaries are required for SNMPv3 encryption to work. -You may wish to grab them from http://www.voidspace.org.uk/python/modules.shtml -and install into your system. -""") + params['requires'] = ['pyasn1(>=0.2.3)', 'pysmi', 'pycryptodomex'] doclines = [x.strip() for x in (__doc__ or '').split('\n') if x] - + params.update({ 'name': 'pysnmp', - 'version': open(os.path.join('pysnmp','__init__.py')).read().split('\'')[1], + 'version': open(os.path.join('pysnmp', '__init__.py')).read().split('\'')[1], 'description': doclines[0], 'long_description': ' '.join(doclines[1:]), - 'maintainer': 'Ilya Etingof ', + 'maintainer': 'Ilya Etingof ', 'author': 'Ilya Etingof', - 'author_email': 'ilya@glas.net', - 'url': 'http://sourceforge.net/projects/pysnmp/', - 'classifiers': [ x for x in classifiers.split('\n') if x ], + 'author_email': 'etingof@gmail.com', + 'url': 'https://github.com/etingof/pysnmp', + 'classifiers': [x for x in classifiers.split('\n') if x], 'platforms': ['any'], 'license': 'BSD', - 'packages': [ 'pysnmp', - 'pysnmp.smi', - 'pysnmp.smi.mibs', - 'pysnmp.smi.mibs.instances', - 'pysnmp.carrier', - 'pysnmp.carrier.asynsock', - 'pysnmp.carrier.asynsock.dgram', - 'pysnmp.carrier.asyncore', - 'pysnmp.carrier.asyncore.dgram', - 'pysnmp.carrier.twisted', - 'pysnmp.carrier.twisted.dgram', - 'pysnmp.carrier.asyncio', - 'pysnmp.carrier.asyncio.dgram', - 'pysnmp.entity', - 'pysnmp.entity.rfc3413', - 'pysnmp.entity.rfc3413.oneliner', - 'pysnmp.hlapi', - 'pysnmp.hlapi.asyncio', - 'pysnmp.hlapi.asyncore', - 'pysnmp.hlapi.asyncore.sync', - 'pysnmp.hlapi.asyncore.sync.compat', - 'pysnmp.hlapi.twisted', - 'pysnmp.proto', - 'pysnmp.proto.mpmod', - 'pysnmp.proto.secmod', - 'pysnmp.proto.secmod.rfc3414', - 'pysnmp.proto.secmod.rfc3414.auth', - 'pysnmp.proto.secmod.rfc3414.priv', - 'pysnmp.proto.secmod.rfc3826', - 'pysnmp.proto.secmod.rfc3826.priv', - 'pysnmp.proto.secmod.eso', - 'pysnmp.proto.secmod.eso.priv', - 'pysnmp.proto.acmod', - 'pysnmp.proto.proxy', - 'pysnmp.proto.api' ] - }) + 'packages': ['pysnmp', + 'pysnmp.smi', + 'pysnmp.smi.mibs', + 'pysnmp.smi.mibs.instances', + 'pysnmp.carrier', + 'pysnmp.carrier.asynsock', + 'pysnmp.carrier.asynsock.dgram', + 'pysnmp.carrier.asyncore', + 'pysnmp.carrier.asyncore.dgram', + 'pysnmp.carrier.twisted', + 'pysnmp.carrier.twisted.dgram', + 'pysnmp.carrier.asyncio', + 'pysnmp.carrier.asyncio.dgram', + 'pysnmp.entity', + 'pysnmp.entity.rfc3413', + 'pysnmp.entity.rfc3413.oneliner', + 'pysnmp.hlapi', + 'pysnmp.hlapi.asyncio', + 'pysnmp.hlapi.asyncore', + 'pysnmp.hlapi.asyncore.sync', + 'pysnmp.hlapi.asyncore.sync.compat', + 'pysnmp.hlapi.twisted', + 'pysnmp.proto', + 'pysnmp.proto.mpmod', + 'pysnmp.proto.secmod', + 'pysnmp.proto.secmod.rfc3414', + 'pysnmp.proto.secmod.rfc3414.auth', + 'pysnmp.proto.secmod.rfc3414.priv', + 'pysnmp.proto.secmod.rfc3826', + 'pysnmp.proto.secmod.rfc3826.priv', + 'pysnmp.proto.secmod.rfc7860', + 'pysnmp.proto.secmod.rfc7860.auth', + 'pysnmp.proto.secmod.eso', + 'pysnmp.proto.secmod.eso.priv', + 'pysnmp.proto.acmod', + 'pysnmp.proto.proxy', + 'pysnmp.proto.api'] +}) setup(**params) diff -Nru python-pysnmp4-4.3.2/THANKS.txt python-pysnmp4-4.4.3/THANKS.txt --- python-pysnmp4-4.3.2/THANKS.txt 2015-04-30 18:09:26.000000000 +0000 +++ python-pysnmp4-4.4.3/THANKS.txt 2017-12-22 11:53:40.000000000 +0000 @@ -27,5 +27,8 @@ Zachary Lorusso Floris Bruynooghe Laurelin of Middle Earth +Robert Reese +Olivier Verriest +Eugene M. Kim Thanks to Python Software Foundation for granting financial support for the project. diff -Nru python-pysnmp4-4.3.2/TODO.txt python-pysnmp4-4.4.3/TODO.txt --- python-pysnmp4-4.3.2/TODO.txt 2016-02-13 19:38:13.000000000 +0000 +++ python-pysnmp4-4.4.3/TODO.txt 2017-12-22 11:53:40.000000000 +0000 @@ -58,3 +58,14 @@ * add RowStatus checks when reading MIB tables (LCD) * Disallow empty SET value reaching scalar MIB object + +* Figure out why .getUnitis() are not propagated from SNMPv2-SMI::ObjectType to response object + +* Extent pysmi/mibdump tool to produce MIB instances from ASN.1 MIBs + +* Write a tool that parses iana-private-enterprise numbers into a pysnmp MIB instance + +* Make mibdump producing OID->MIB indices in form of pysnmp MIB instance and JSON + +* Write a helper function/module based on pysnmp that reports device details based on SNMP data. + In particular: description, vendor ID/name (sysObjectID), implemented MIBs (sysORTable) diff -Nru python-pysnmp4-4.3.2/.travis.yml python-pysnmp4-4.4.3/.travis.yml --- python-pysnmp4-4.3.2/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ python-pysnmp4-4.4.3/.travis.yml 2017-12-22 11:53:40.000000000 +0000 @@ -0,0 +1,20 @@ + +language: python +python: +# temporarily disabled due to broken pysmi dependency +# - "2.6" + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" + - "3.6" + - "nightly" +# - "pypy" +# - "pypy3" +install: + - pip install -r requirements.txt -r devel-requirements.txt + - pip install -e . + - pip install pysnmp-mibs +script: + - sh runtests.sh