Compare commits
8 Commits
master
...
fix-zero-b
Author | SHA1 | Date |
---|---|---|
Ilya Etingof | 34d19a7e77 | |
Ilya Etingof | 1021d56e1b | |
Ilya Etingof | c419576445 | |
Ilya Etingof | dff00bf90f | |
Ilya Etingof | bec02e6fc1 | |
Ilya Etingof | 6aed418b86 | |
Ilya Etingof | 4b21d3da29 | |
Ilya Etingof | 194d2ec820 |
|
@ -1,4 +1,11 @@
|
|||
|
||||
Revision 4.4.5, released 2018-04-XX
|
||||
-----------------------------------
|
||||
|
||||
- Fixed zero SNMPv3 boots/time values put in SNMPv3 TRAP messages
|
||||
- Fixed broken InetAddressType rendering caused by a pyasn1 regression
|
||||
- Fixed typo in RFC1158 module
|
||||
|
||||
Revision 4.4.4, released 2018-01-03
|
||||
-----------------------------------
|
||||
|
||||
|
|
|
@ -59,11 +59,11 @@ to download and install PySNMP along with its dependencies:
|
|||
* [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)
|
||||
Besides the library, command-line [SNMP utilities](https://github.com/etingof/snmpclitools)
|
||||
written in pure-Python could be installed via:
|
||||
|
||||
```bash
|
||||
$ pip install pysnmp-apps
|
||||
$ pip install snmpclitools
|
||||
```
|
||||
|
||||
and used in the very similar manner as conventional Net-SNMP tools:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
sphinx
|
||||
Sphinx <= 1.6; python_version < '2.7'
|
||||
Sphinx > 1.6; python_version >= '2.7'
|
||||
twisted
|
||||
trollius; python_version < '3.0'
|
||||
|
|
|
@ -24,7 +24,7 @@ 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 <https://pypi.python.org/pypi/pysnmp-apps/>`_
|
||||
`command-line tools <https://pypi.python.org/pypi/snmpclitools/>`_
|
||||
are shipped along with the system. Those tools mimic the interface
|
||||
and behaviour of popular Net-SNMP snmpget/snmpset/snmpwalk utilities.
|
||||
They may be useful in a cross-platform situations as well as a testing
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# http://www.python.org/dev/peps/pep-0396/
|
||||
__version__ = '4.4.4'
|
||||
__version__ = '4.4.5'
|
||||
# backward compatibility
|
||||
version = tuple([int(x) for x in __version__.split('.')])
|
||||
majorVersionId = version[0]
|
||||
|
|
|
@ -13,7 +13,7 @@ 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
|
||||
from pysnmp.proto import rfc1155, rfc3411, errind, error
|
||||
from pysnmp import debug
|
||||
from pyasn1.type import univ, namedtype, constraint
|
||||
from pyasn1.codec.ber import encoder, decoder, eoo
|
||||
|
@ -333,35 +333,40 @@ class SnmpUSMSecurityModel(AbstractSecurityModel):
|
|||
0, scopedPDU, verifyConstraints=False, matchTags=False, matchConstraints=False
|
||||
)
|
||||
|
||||
# 3.1.6a
|
||||
if securityStateReference is None and securityLevel in (2, 3):
|
||||
if securityEngineID in self.__timeline:
|
||||
(snmpEngineBoots, snmpEngineTime, latestReceivedEngineTime,
|
||||
snmpEngineBoots = snmpEngineTime = 0
|
||||
|
||||
if securityLevel in (2, 3):
|
||||
pdu = scopedPDU.getComponentByPosition(2).getComponent()
|
||||
|
||||
# 3.1.6.b
|
||||
if pdu.tagSet in rfc3411.unconfirmedClassPDUs:
|
||||
(snmpEngineBoots,
|
||||
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')
|
||||
|
||||
# 3.1.6a
|
||||
elif securityEngineID in self.__timeline:
|
||||
(snmpEngineBoots,
|
||||
snmpEngineTime,
|
||||
latestReceivedEngineTime,
|
||||
latestUpdateTimestamp) = self.__timeline[securityEngineID]
|
||||
|
||||
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,))
|
||||
# 3.1.6.b
|
||||
elif securityStateReference is not None: # XXX Report?
|
||||
(snmpEngineBoots,
|
||||
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')
|
||||
# 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: use snmpEngineBoots %s snmpEngineTime %s for securityEngineID %r' % (
|
||||
snmpEngineBoots, snmpEngineTime, securityEngineID))
|
||||
# 3.1.6.c
|
||||
else:
|
||||
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))
|
||||
|
||||
# 3.1.4a
|
||||
if securityLevel == 3:
|
||||
|
|
|
@ -80,7 +80,7 @@ class InetAddress(TextualConvention, OctetString):
|
|||
for parentIndex in reversed(parentIndices):
|
||||
if isinstance(parentIndex, InetAddressType):
|
||||
try:
|
||||
return parentRow.setFromName(cls.typeMap[parentIndex], value, impliedFlag, parentIndices)
|
||||
return parentRow.setFromName(cls.typeMap[int(parentIndex)], value, impliedFlag, parentIndices)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
@ -90,7 +90,7 @@ class InetAddress(TextualConvention, OctetString):
|
|||
for parentIndex in reversed(parentIndices):
|
||||
if isinstance(parentIndex, InetAddressType):
|
||||
try:
|
||||
return parentRow.getAsName(self.typeMap[parentIndex].clone(self.asOctets()), impliedFlag, parentIndices)
|
||||
return parentRow.getAsName(self.typeMap[int(parentIndex)].clone(self.asOctets().decode('ascii')), impliedFlag, parentIndices)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
|
|
@ -17,5 +17,5 @@ Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, iso, Gau
|
|||
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')
|
||||
if mibBuilder.loadTexts: snmpOutReadOnlys.setStatus('mandatory')
|
||||
mibBuilder.exportSymbols("RFC1158-MIB", snmpOutReadOnlys=snmpOutReadOnlys, snmpInBadTypes=snmpInBadTypes)
|
||||
|
|
|
@ -184,7 +184,7 @@ class TextualConvention(object):
|
|||
"""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
|
||||
Here we are trying to do our best, but be prepared
|
||||
for failures on complicated DISPLAY-HINTs.
|
||||
|
||||
Keep in mind that this parser only works with "text"
|
||||
|
@ -259,6 +259,7 @@ class TextualConvention(object):
|
|||
|
||||
# how do we know if object is initialized with display-hint
|
||||
# formatted text? based on "text" input maybe?
|
||||
# That boils down to `str` object on Py3 or `unicode` on Py2.
|
||||
if octets.isStringType(value) and not octets.isOctetsType(value):
|
||||
value = base.prettyIn(self, value)
|
||||
else:
|
||||
|
@ -267,6 +268,7 @@ class TextualConvention(object):
|
|||
outputValue = octets.str2octs('')
|
||||
runningValue = value
|
||||
displayHint = self.displayHint
|
||||
|
||||
while runningValue and displayHint:
|
||||
# 1 this information is totally lost, just fail explicitly
|
||||
if displayHint[0] == '*':
|
||||
|
|
Loading…
Reference in New Issue