summaryrefslogtreecommitdiff
path: root/pysnmp/proto/api
diff options
context:
space:
mode:
authorelie <elie>2011-01-21 17:56:29 +0000
committerelie <elie>2011-01-21 17:56:29 +0000
commitc960502d1fb1987cab21567e7beef1127c1bb187 (patch)
tree1acd168f5414acdb589b1d5aa3073cccf0732d66 /pysnmp/proto/api
parent3159b81081d0153e11c367720b5c09ea403878ea (diff)
downloadpysnmp-git-c960502d1fb1987cab21567e7beef1127c1bb187.tar.gz
* pre-compute some more ASN.1 constants
* skip ASN.1 types verification where possible
Diffstat (limited to 'pysnmp/proto/api')
-rw-r--r--pysnmp/proto/api/v1.py28
-rw-r--r--pysnmp/proto/api/v2c.py10
2 files changed, 22 insertions, 16 deletions
diff --git a/pysnmp/proto/api/v1.py b/pysnmp/proto/api/v1.py
index cdeebcf4..dc422676 100644
--- a/pysnmp/proto/api/v1.py
+++ b/pysnmp/proto/api/v1.py
@@ -44,9 +44,15 @@ class PDUAPI:
_null = Null('')
_errorStatus = _errorIndex = Integer(0)
def setDefaults(self, pdu):
- pdu.setComponentByPosition(0, getNextRequestID())
- pdu.setComponentByPosition(1, self._errorStatus)
- pdu.setComponentByPosition(2, self._errorIndex)
+ pdu.setComponentByPosition(
+ 0, getNextRequestID(), verifyConstraints=False
+ )
+ pdu.setComponentByPosition(
+ 1, self._errorStatus, verifyConstraints=False
+ )
+ pdu.setComponentByPosition(
+ 2, self._errorIndex, verifyConstraints=False
+ )
pdu.setComponentByPosition(3)
def getRequestID(self, pdu): return pdu.getComponentByPosition(0)
@@ -118,11 +124,11 @@ class TrapPDUAPI:
_entOid = ObjectIdentifier((1,3,6,1,4,1,20408))
_zeroInt = univ.Integer(0)
def setDefaults(self, pdu):
- pdu.setComponentByPosition(0, self._entOid)
- pdu.setComponentByPosition(1).getComponentByPosition(1).setComponentByPosition(0, self.agentAddress)
- pdu.setComponentByPosition(2, self._zeroInt)
- pdu.setComponentByPosition(3, self._zeroInt)
- pdu.setComponentByPosition(4, self._zeroInt)
+ pdu.setComponentByPosition(0, self._entOid, verifyConstraints=False)
+ pdu.setComponentByPosition(1).getComponentByPosition(1).setComponentByPosition(0, self.agentAddress, verifyConstraints=False)
+ pdu.setComponentByPosition(2, self._zeroInt, verifyConstraints=False)
+ pdu.setComponentByPosition(3, self._zeroInt, verifyConstraints=False)
+ pdu.setComponentByPosition(4, self._zeroInt, verifyConstraints=False)
pdu.setComponentByPosition(5)
def getEnterprise(self, pdu): return pdu.getComponentByPosition(0)
@@ -170,8 +176,8 @@ class MessageAPI:
_verInt = univ.Integer(0)
_commStr = univ.OctetString('public')
def setDefaults(self, msg):
- msg.setComponentByPosition(0, self._verInt)
- msg.setComponentByPosition(1, self._commStr)
+ msg.setComponentByPosition(0, self._verInt, verifyConstraints=False)
+ msg.setComponentByPosition(1, self._commStr, verifyConstraints=False)
return msg
def getVersion(self, msg): return msg.getComponentByPosition(0)
@@ -182,7 +188,7 @@ class MessageAPI:
def getPDU(self, msg): return msg.getComponentByPosition(2).getComponent()
def setPDU(self, msg, value):
- msg.setComponentByPosition(2).getComponentByPosition(2).setComponentByType(value.getTagSet(), value, 1)
+ msg.setComponentByPosition(2).getComponentByPosition(2).setComponentByType(value.getTagSet(), value, 1, verifyConstraints=False)
def getResponse(self, reqMsg):
rspMsg = Message()
diff --git a/pysnmp/proto/api/v2c.py b/pysnmp/proto/api/v2c.py
index 0bff9a9a..235b5bc2 100644
--- a/pysnmp/proto/api/v2c.py
+++ b/pysnmp/proto/api/v2c.py
@@ -55,13 +55,13 @@ class PDUAPI(v1.PDUAPI):
def setEndOfMibError(self, pdu, errorIndex):
varBindList = self.getVarBindList(pdu)
varBindList[errorIndex-1].setComponentByPosition(
- 1, rfc1905.endOfMibView
+ 1, rfc1905.endOfMibView, verifyConstraints=False
)
def setNoSuchInstanceError(self, pdu, errorIndex):
varBindList = self.getVarBindList(pdu)
varBindList[errorIndex-1].setComponentByPosition(
- 1, rfc1905.noSuchInstance
+ 1, rfc1905.noSuchInstance, verifyConstraints=False
)
apiPDU = PDUAPI()
@@ -70,7 +70,7 @@ class BulkPDUAPI(PDUAPI):
_tenInt = rfc1902.Integer(10)
def setDefaults(self, pdu):
PDUAPI.setDefaults(self, pdu)
- pdu.setComponentByPosition(2, self._tenInt)
+ pdu.setComponentByPosition(2, self._tenInt, verifyConstraints=False)
def getNonRepeaters(self, pdu): return pdu.getComponentByPosition(1)
def setNonRepeaters(self, pdu, value): pdu.setComponentByPosition(1, value)
@@ -125,8 +125,8 @@ apiTrapPDU = TrapPDUAPI()
class MessageAPI(v1.MessageAPI):
_verInt = univ.Integer(1)
def setDefaults(self, msg):
- msg.setComponentByPosition(0, self._verInt)
- msg.setComponentByPosition(1, self._commStr)
+ msg.setComponentByPosition(0, self._verInt, verifyConstraints=False)
+ msg.setComponentByPosition(1, self._commStr, verifyConstraints=False)
return msg
def getResponse(self, reqMsg):