diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-07-30 20:29:22 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-07-30 20:29:22 +0200 |
commit | e8fa401677432e4e48d1a9c36b996ef94b043d90 (patch) | |
tree | 1be033d04237ee0e582349d309049ebf6c0437b7 /pysnmp/hlapi/varbinds.py | |
parent | 9dd4bcc9983b39424e1ecbe907b5645ee8d57f9e (diff) | |
download | pysnmp-git-release-4.4.10.tar.gz |
Make received MIB objects resolution more forgivingv4.4.10release-4.4.10
Previously, MIB resolution errors were ignored (whenever possible)
for objects we were sending and receiving. This change tightens
outgoing objects MIB compliance (send will fail), but tolerate
non quite compliant objects we receive.
Also, extend the same policy onto `NotificationOriginator`.
Diffstat (limited to 'pysnmp/hlapi/varbinds.py')
-rw-r--r-- | pysnmp/hlapi/varbinds.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pysnmp/hlapi/varbinds.py b/pysnmp/hlapi/varbinds.py index ece7b92b..fdffc1b3 100644 --- a/pysnmp/hlapi/varbinds.py +++ b/pysnmp/hlapi/varbinds.py @@ -36,14 +36,15 @@ class CommandGeneratorVarBinds(AbstractVarBinds): else: varBind = ObjectType(ObjectIdentity(varBind[0]), varBind[1]) - __varBinds.append(varBind.resolveWithMib(mibViewController)) + __varBinds.append(varBind.resolveWithMib(mibViewController, ignoreErrors=False)) return __varBinds def unmakeVarBinds(self, snmpEngine, varBinds, lookupMib=True): if lookupMib: mibViewController = self.getMibViewController(snmpEngine) - varBinds = [ObjectType(ObjectIdentity(x[0]), x[1]).resolveWithMib(mibViewController) for x in varBinds] + varBinds = [ObjectType(ObjectIdentity(x[0]), x[1]).resolveWithMib( + mibViewController) for x in varBinds] return varBinds @@ -52,7 +53,8 @@ class NotificationOriginatorVarBinds(AbstractVarBinds): def makeVarBinds(self, snmpEngine, varBinds): mibViewController = self.getMibViewController(snmpEngine) if isinstance(varBinds, NotificationType): - varBinds.resolveWithMib(mibViewController) + varBinds.resolveWithMib( + mibViewController, ignoreErrors=False) __varBinds = [] for varBind in varBinds: if isinstance(varBind, ObjectType): @@ -61,11 +63,13 @@ class NotificationOriginatorVarBinds(AbstractVarBinds): varBind = ObjectType(*varBind) else: varBind = ObjectType(ObjectIdentity(varBind[0]), varBind[1]) - __varBinds.append(varBind.resolveWithMib(mibViewController)) + __varBinds.append(varBind.resolveWithMib( + mibViewController, ignoreErrors=False)) return __varBinds def unmakeVarBinds(self, snmpEngine, varBinds, lookupMib=False): if lookupMib: mibViewController = self.getMibViewController(snmpEngine) - varBinds = [ObjectType(ObjectIdentity(x[0]), x[1]).resolveWithMib(mibViewController) for x in varBinds] + varBinds = [ObjectType(ObjectIdentity(x[0]), x[1]).resolveWithMib( + mibViewController) for x in varBinds] return varBinds |