summaryrefslogtreecommitdiff
path: root/pysnmp/proto
diff options
context:
space:
mode:
authorelie <elie>2013-02-07 20:02:12 +0000
committerelie <elie>2013-02-07 20:02:12 +0000
commit523054e1ddc45f0883bc48ff088a8714a3b064f3 (patch)
tree618203ed619c687aa9b2fad04801c3dc28ce0b66 /pysnmp/proto
parentd577741cc42cb49760b32f83153ecd60cbad8fe2 (diff)
downloadpysnmp-523054e1ddc45f0883bc48ff088a8714a3b064f3.tar.gz
Packet-level SNMP API (pysnmp.proto.api) getErrorIndex() method can now
be instructed to ignore portentially malformed errorIndex SNMP packet value what sometimes happens with buggy SNMP implementations.
Diffstat (limited to 'pysnmp/proto')
-rw-r--r--pysnmp/proto/api/v1.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/pysnmp/proto/api/v1.py b/pysnmp/proto/api/v1.py
index caca68d..ee58b59 100644
--- a/pysnmp/proto/api/v1.py
+++ b/pysnmp/proto/api/v1.py
@@ -61,9 +61,11 @@ class PDUAPI:
def getErrorStatus(self, pdu): return pdu.getComponentByPosition(1)
def setErrorStatus(self, pdu, value): pdu.setComponentByPosition(1, value)
- def getErrorIndex(self, pdu):
+ def getErrorIndex(self, pdu, muteErrors=False):
errorIndex = pdu.getComponentByPosition(2)
if errorIndex > len(pdu[3]):
+ if muteErrors:
+ return errorIndex.clone(len(pdu[3]))
raise error.ProtocolError(
'Error index out of range: %s > %s' % (errorIndex, len(pdu[3]))
)