summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2010-11-14 11:30:54 +0000
committerelie <elie>2010-11-14 11:30:54 +0000
commitdeae96cda237ecc9e3d44878928bece6394fbcf0 (patch)
tree15c79c009b69b6672bfb3dbe82501597c12ef9be
parentc770b66faac4527396f13ef3bd28ce7b187d8fe5 (diff)
downloadpysnmp-deae96cda237ecc9e3d44878928bece6394fbcf0.tar.gz
SNMP exception values exported from rfc1905 and made printable
-rw-r--r--pysnmp/proto/rfc1905.py29
-rw-r--r--pysnmp/smi/exval.py8
2 files changed, 29 insertions, 8 deletions
diff --git a/pysnmp/proto/rfc1905.py b/pysnmp/proto/rfc1905.py
index 3a2ad8d..b1912c2 100644
--- a/pysnmp/proto/rfc1905.py
+++ b/pysnmp/proto/rfc1905.py
@@ -4,13 +4,34 @@ from pysnmp.proto import rfc1902
# Value reference -- max bindings in VarBindList
max_bindings = rfc1902.Integer(2147483647L)
-class _BindValue(univ.Choice): # Made a separate class for better readability
+# Take SNMP exception values out of BindValue structure for convenience
+
+noSuchObject = univ.Null().subtype(
+ implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0x00)
+ )
+noSuchObject.prettyOut = lambda x: 'No Such Object currently exists at this OID'
+noSuchObject.prettyIn = lambda x: ''
+
+noSuchInstance = univ.Null().subtype(
+ implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0x01)
+ )
+noSuchInstance.prettyOut = lambda x: 'No Such Instance currently exists at this OID'
+noSuchInstance.prettyIn = lambda x: ''
+
+endOfMibView = univ.Null().subtype(
+ implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0x02)
+ )
+endOfMibView.prettyOut = lambda x: 'No more variables left in this MIB View'
+endOfMibView.prettyIn = lambda x: ''
+
+# Made a separate class for better readability
+class _BindValue(univ.Choice):
componentType = namedtype.NamedTypes(
namedtype.NamedType('value', rfc1902.ObjectSyntax()),
namedtype.NamedType('unSpecified', univ.Null()),
- namedtype.NamedType('noSuchObject', univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0x00))),
- namedtype.NamedType('noSuchInstance', univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0x01))),
- namedtype.NamedType('endOfMibView', univ.Null().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0x02)))
+ namedtype.NamedType('noSuchObject', noSuchObject),
+ namedtype.NamedType('noSuchInstance', noSuchInstance),
+ namedtype.NamedType('endOfMibView', endOfMibView)
)
class VarBind(univ.Sequence):
diff --git a/pysnmp/smi/exval.py b/pysnmp/smi/exval.py
index f904bcb..3fc1e72 100644
--- a/pysnmp/smi/exval.py
+++ b/pysnmp/smi/exval.py
@@ -1,6 +1,6 @@
-from pyasn1.type import univ, tag
+from pysnmp.proto import rfc1905
-noSuchObject = univ.Null('').subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0x00))
-noSuchInstance = univ.Null('').subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0x01))
-endOfMib = univ.Null('').subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0x02))
+noSuchObject = rfc1905.noSuchObject
+noSuchInstance = rfc1905.noSuchInstance
+endOfMibView = endOfMib = rfc1905.endOfMibView