diff options
author | Ilya Etingof <etingof@gmail.com> | 2017-08-13 00:14:49 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2017-08-13 10:49:18 +0200 |
commit | 30167082cd3f2706f733168da8647bbc4126696d (patch) | |
tree | 62688e576db0cc64f0262910368e1e63694927b8 /pysnmp | |
parent | 33c6f6ecc6ed6d1896cbe95cda4d663752200dbd (diff) | |
download | pysnmp-git-30167082cd3f2706f733168da8647bbc4126696d.tar.gz |
fixed indices rendering for InetAddressIPv6 type
Also added a workaround to pyasn1 constraints
relationships resolution bug that affected SNMP table
indices rendering.
Diffstat (limited to 'pysnmp')
-rw-r--r-- | pysnmp/smi/mibs/INET-ADDRESS-MIB.py | 2 | ||||
-rw-r--r-- | pysnmp/smi/mibs/SNMPv2-SMI.py | 6 | ||||
-rw-r--r-- | pysnmp/smi/mibs/SNMPv2-TC.py | 17 | ||||
-rw-r--r-- | pysnmp/smi/rfc1902.py | 4 |
4 files changed, 15 insertions, 14 deletions
diff --git a/pysnmp/smi/mibs/INET-ADDRESS-MIB.py b/pysnmp/smi/mibs/INET-ADDRESS-MIB.py index 6e5fefbb..481c55bc 100644 --- a/pysnmp/smi/mibs/INET-ADDRESS-MIB.py +++ b/pysnmp/smi/mibs/INET-ADDRESS-MIB.py @@ -71,7 +71,7 @@ class InetAddress(TextualConvention, OctetString): InetAddressType.namedValues.getValue("ipv4"): InetAddressIPv4(), InetAddressType.namedValues.getValue("ipv6"): InetAddressIPv6(), InetAddressType.namedValues.getValue("ipv4z"): InetAddressIPv4z(), - InetAddressType.namedValues.getValue("ipv6"): InetAddressIPv6z(), + InetAddressType.namedValues.getValue("ipv6z"): InetAddressIPv6z(), InetAddressType.namedValues.getValue("dns"): InetAddressDNS() } diff --git a/pysnmp/smi/mibs/SNMPv2-SMI.py b/pysnmp/smi/mibs/SNMPv2-SMI.py index c9caf9e7..148ce9a1 100644 --- a/pysnmp/smi/mibs/SNMPv2-SMI.py +++ b/pysnmp/smi/mibs/SNMPv2-SMI.py @@ -1009,9 +1009,9 @@ class MibTableRow(MibTree): return obj.clone(value), () elif obj.isFixedLength(): l = obj.getFixedLength() - return obj.clone(value[:l]), value[l:] + return obj.clone(tuple(value[:l])), value[l:] else: - return obj.clone(value[1:value[0] + 1]), value[value[0] + 1:] + return obj.clone(tuple(value[1:value[0] + 1])), value[value[0] + 1:] elif baseTag == self.__oidBaseTag: if impliedFlag: return obj.clone(value), () @@ -1019,7 +1019,7 @@ class MibTableRow(MibTree): return obj.clone(value[1:value[0] + 1]), value[value[0] + 1:] # rfc2578, 7.1 elif baseTag == self.__bitsBaseTag: - return obj.clone(value[1:value[0] + 1]), value[value[0] + 1:] + return obj.clone(tuple(value[1:value[0] + 1])), value[value[0] + 1:] else: raise error.SmiError('Unknown value type for index %r' % (obj,)) diff --git a/pysnmp/smi/mibs/SNMPv2-TC.py b/pysnmp/smi/mibs/SNMPv2-TC.py index 76b94074..7818b4cc 100644 --- a/pysnmp/smi/mibs/SNMPv2-TC.py +++ b/pysnmp/smi/mibs/SNMPv2-TC.py @@ -49,9 +49,9 @@ class TextualConvention(object): def prettyOut(self, value): # override asn1 type method """Implements DISPLAY-HINT evaluation""" - if self.displayHint and (self.__integer.isSuperTypeOf(self) and not self.getNamedValues() or - self.__unsigned32.isSuperTypeOf(self) or - self.__timeticks.isSuperTypeOf(self)): + if self.displayHint and (self.__integer.isSuperTypeOf(self, matchConstraints=False) and not self.getNamedValues() or + self.__unsigned32.isSuperTypeOf(self, matchConstraints=False) or + self.__timeticks.isSuperTypeOf(self, matchConstraints=False)): _ = lambda t, f=0: (t, f) displayHintType, decimalPrecision = _(*self.displayHint.split('-')) if displayHintType == 'x': @@ -76,7 +76,7 @@ class TextualConvention(object): raise SmiError( 'Unsupported numeric type spec "%s" at %s' % (displayHintType, self.__class__.__name__) ) - elif self.displayHint and self.__octetString.isSuperTypeOf(self): + elif self.displayHint and self.__octetString.isSuperTypeOf(self, matchConstraints=False): outputValue = '' runningValue = OctetString(value).asOctets() displayHint = self.displayHint @@ -193,9 +193,10 @@ class TextualConvention(object): else: raise SmiError('TEXTUAL-CONVENTION has no underlying SNMP base type') - if self.displayHint and (self.__integer.isSuperTypeOf(self) and self.getNamedValues() or - self.__unsigned32.isSuperTypeOf(self) or - self.__timeticks.isSuperTypeOf(self)): + if self.displayHint and (self.__integer.isSuperTypeOf(self, matchConstraints=False) and + self.getNamedValues() or + self.__unsigned32.isSuperTypeOf(self, matchConstraints=False) or + self.__timeticks.isSuperTypeOf(self, matchConstraints=False)): value = str(value) _ = lambda t, f=0: (t, f) @@ -241,7 +242,7 @@ class TextualConvention(object): 'Unsupported numeric type spec "%s" at %s' % (displayHintType, self.__class__.__name__) ) - elif self.displayHint and self.__octetString.isSuperTypeOf(self): + elif self.displayHint and self.__octetString.isSuperTypeOf(self, matchConstraints=False): numBase = { 'x': 16, 'd': 10, diff --git a/pysnmp/smi/rfc1902.py b/pysnmp/smi/rfc1902.py index 657269b2..61c8ad0c 100644 --- a/pysnmp/smi/rfc1902.py +++ b/pysnmp/smi/rfc1902.py @@ -529,7 +529,7 @@ class ObjectIdentity(object): return '%s::%s%s%s' % ( self.__modName, self.__symName, self.__indices and '.' or '', - '.'.join([x.isSuperTypeOf(s) and '"%s"' % x.prettyPrint() or x.prettyPrint() for x in self.__indices]) + '.'.join([x.isSuperTypeOf(s, matchConstraints=False) and '"%s"' % x.prettyPrint() or x.prettyPrint() for x in self.__indices]) ) else: raise SmiError('%s object not fully initialized' % self.__class__.__name__) @@ -868,7 +868,7 @@ class ObjectType(object): self.__args[0].prettyPrint(), self.__args[0].getMibNode().getSyntax().__class__.__name__, self.__args[1], sys.exc_info()[1])) - if self.__args[1].isSuperTypeOf(rfc1902.ObjectIdentifier()): + if self.__args[1].isSuperTypeOf(rfc1902.ObjectIdentifier(), matchConstraints=False): self.__args[1] = ObjectIdentity(self.__args[1]).resolveWithMib(mibViewController) self.__state |= self.stClean |