diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-02-08 11:16:52 +0100 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-02-08 23:35:09 +0100 |
commit | 137ffef77e2eff4661c56a55204a7bc463f32b74 (patch) | |
tree | 0ef594691222b928f274578b3debc09cba1b67cf /pysnmp/entity/rfc3413 | |
parent | f31d8923d5343c167448738d0803407e3272c198 (diff) | |
download | pysnmp-git-137ffef77e2eff4661c56a55204a7bc463f32b74.tar.gz |
Add missing SNMP PDU error classes
Added missing SNMP PDU error classes and their handling in
Command Responder
Diffstat (limited to 'pysnmp/entity/rfc3413')
-rw-r--r-- | pysnmp/entity/rfc3413/cmdrsp.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/pysnmp/entity/rfc3413/cmdrsp.py b/pysnmp/entity/rfc3413/cmdrsp.py index 772cc5ea..44d73d50 100644 --- a/pysnmp/entity/rfc3413/cmdrsp.py +++ b/pysnmp/entity/rfc3413/cmdrsp.py @@ -18,6 +18,12 @@ class CommandResponderBase(object): acmID = 3 # default MIB access control method to use SUPPORTED_PDU_TYPES = () SMI_ERROR_MAP = { + pysnmp.smi.error.TooBigError: 'tooBig', + # this should never bubble up, SNMP exception objects should be passed as values + pysnmp.smi.error.NoSuchNameError: 'noSuchName', + pysnmp.smi.error.BadValueError: 'badValue', + pysnmp.smi.error.ReadOnlyError: 'readOnly', + pysnmp.smi.error.GenError: 'genErr', pysnmp.smi.error.NoAccessError: 'noAccess', pysnmp.smi.error.WrongTypeError: 'wrongType', pysnmp.smi.error.WrongLengthError: 'wrongLength', @@ -248,6 +254,11 @@ class CommandResponderBase(object): errorIndication = str(err) elif isinstance(err, pysnmp.smi.error.SmiError): + + if isinstance(err, pysnmp.smi.error.TooBigError): + # rfc1905: 4.2.1.3 + varBinds = [] + errorStatus = self.SMI_ERROR_MAP.get(err.__class__, 'genErr') try: @@ -256,12 +267,13 @@ class CommandResponderBase(object): except IndexError: errorIndex = len(varBinds) and 1 or 0 - return errorIndication, errorStatus, errorIndex + return errorIndication, errorStatus, errorIndex, varBinds def completeMgmtOperation(self, varBinds, **context): (errorIndication, - errorStatus, errorIndex) = self._mapSmiErrors(varBinds, **context) + errorStatus, errorIndex, + varBinds) = self._mapSmiErrors(varBinds, **context) stateReference = context['stateReference'] |