diff options
author | elie <elie> | 2013-02-07 20:02:12 +0000 |
---|---|---|
committer | elie <elie> | 2013-02-07 20:02:12 +0000 |
commit | 523054e1ddc45f0883bc48ff088a8714a3b064f3 (patch) | |
tree | 618203ed619c687aa9b2fad04801c3dc28ce0b66 /pysnmp/proto | |
parent | d577741cc42cb49760b32f83153ecd60cbad8fe2 (diff) | |
download | pysnmp-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.py | 4 |
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])) ) |