summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2017-10-18 12:14:53 +0200
committerIlya Etingof <etingof@gmail.com>2017-10-18 12:14:53 +0200
commitfff063aba993cab2ebe26cc416a4d2df3bc43a28 (patch)
tree266f1b7d85e178eeac0814b20567da047de809a5
parent05df34cc3ae0a04dbd1854f633e58b6180157d59 (diff)
downloadpysnmp-git-fff063aba993cab2ebe26cc416a4d2df3bc43a28.tar.gz
fixed non-translated PDU version retries at CommandGenerator
-rw-r--r--CHANGES.txt3
-rw-r--r--pysnmp/entity/rfc3413/cmdgen.py12
2 files changed, 14 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index a231a973..faa5c564 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -13,6 +13,9 @@ Revision 4.4.1, released 2017-10-XX
- 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
------------------------------------
diff --git a/pysnmp/entity/rfc3413/cmdgen.py b/pysnmp/entity/rfc3413/cmdgen.py
index d4f108a1..d4c9d92d 100644
--- a/pysnmp/entity/rfc3413/cmdgen.py
+++ b/pysnmp/entity/rfc3413/cmdgen.py
@@ -70,6 +70,7 @@ class CommandGenerator(object):
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
@@ -81,12 +82,21 @@ class CommandGenerator(object):
cbFun(snmpEngine, origSendRequestHandle,
statusInformation['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))