summaryrefslogtreecommitdiff
path: root/pysnmp/proto/api
diff options
context:
space:
mode:
authorelie <elie>2010-11-14 23:17:39 +0000
committerelie <elie>2010-11-14 23:17:39 +0000
commitc06712e0321c304e7a07ae104076bd9309935eba (patch)
treecdeb71f323ce30c405b4d2bd8e1d108c611d9b97 /pysnmp/proto/api
parent2f7e1bee282d3539145bda323346c77f391cf1f7 (diff)
downloadpysnmp-git-c06712e0321c304e7a07ae104076bd9309935eba.tar.gz
* getVarBindTable() does not filter SNMP exception values anymore
* getVarBindTable() of v1 API now returns Null instead of None * GETNEXT/GETBULK apps now track EOM condition automatically
Diffstat (limited to 'pysnmp/proto/api')
-rw-r--r--pysnmp/proto/api/v1.py6
-rw-r--r--pysnmp/proto/api/v2c.py22
2 files changed, 12 insertions, 16 deletions
diff --git a/pysnmp/proto/api/v1.py b/pysnmp/proto/api/v1.py
index fdc458ad..dac8971b 100644
--- a/pysnmp/proto/api/v1.py
+++ b/pysnmp/proto/api/v1.py
@@ -41,6 +41,8 @@ apiVarBind = VarBindAPI()
getNextRequestID = nextid.Integer(0xffff)
class PDUAPI:
+ _null = univ.Null('')
+
def setDefaults(self, pdu):
pdu.setComponentByPosition(0, getNextRequestID())
pdu.setComponentByPosition(1, 0)
@@ -99,7 +101,9 @@ class PDUAPI:
def getVarBindTable(self, reqPDU, rspPDU):
if apiPDU.getErrorStatus(rspPDU) == 2:
- return [ map(lambda (x,y): (x, None), apiPDU.getVarBinds(reqPDU)) ]
+ return [
+ map(lambda (x,y): (x, self._null), apiPDU.getVarBinds(reqPDU))
+ ]
else:
return [ apiPDU.getVarBinds(rspPDU) ]
diff --git a/pysnmp/proto/api/v2c.py b/pysnmp/proto/api/v2c.py
index 6868452b..2d8dc30b 100644
--- a/pysnmp/proto/api/v2c.py
+++ b/pysnmp/proto/api/v2c.py
@@ -1,6 +1,5 @@
from pysnmp.proto import rfc1902, rfc1905, error
from pysnmp.proto.api import v1
-from pysnmp.smi import exval
from pyasn1.type import univ, namedtype, namedval
# Shortcuts to SNMP types
@@ -50,20 +49,19 @@ class PDUAPI(v1.PDUAPI):
return rspPDU
def getVarBindTable(self, reqPDU, rspPDU):
- varBinds = []
- for oid, val in apiPDU.getVarBinds(rspPDU):
- if exval.endOfMib.isSameTypeWith(val):
- val = None
- varBinds.append((oid, val))
- return [ varBinds ]
+ return [ apiPDU.getVarBinds(rspPDU) ]
def setEndOfMibError(self, pdu, errorIndex):
varBindList = self.getVarBindList(pdu)
- varBindList[errorIndex-1].setComponentByPosition(1, exval.endOfMib)
+ varBindList[errorIndex-1].setComponentByPosition(
+ 1, rfc1905.endOfMibView
+ )
def setNoSuchInstanceError(self, pdu, errorIndex):
varBindList = self.getVarBindList(pdu)
- varBindList[errorIndex-1].setComponentByPosition(1,exval.noSuchInstance)
+ varBindList[errorIndex-1].setComponentByPosition(
+ 1, rfc1905.noSuchInstance
+ )
apiPDU = PDUAPI()
@@ -99,12 +97,6 @@ class BulkPDUAPI(PDUAPI):
elif N:
varBindTable.append(rspVarBinds[:N])
- for varBindRow in varBindTable:
- for idx in range(len(varBindRow)):
- oid, val = varBindRow[idx]
- if exval.endOfMib.isSameTypeWith(val):
- varBindRow[idx] = (oid, None)
-
return varBindTable
apiBulkPDU = BulkPDUAPI()