summaryrefslogtreecommitdiff
path: root/pysnmp/proto
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2017-02-14 10:42:22 +0100
committerIlya Etingof <etingof@gmail.com>2017-02-14 10:42:22 +0100
commit8eb880295475a1a48fcf660b4c21d46b8cf25043 (patch)
tree23acd96cc89f12682b0bbf1bf7234eac0e71ed14 /pysnmp/proto
parent3d26f4e8fd6c799f3c537f31f4a6a75b7e78c1e4 (diff)
downloadpysnmp-git-8eb880295475a1a48fcf660b4c21d46b8cf25043.tar.gz
required pyasn1 version is now 0.2.3
added matchTags, matchConstraints flags to .setComponentBy() call
Diffstat (limited to 'pysnmp/proto')
-rw-r--r--pysnmp/proto/api/v1.py26
-rw-r--r--pysnmp/proto/api/v2c.py14
-rw-r--r--pysnmp/proto/mpmod/rfc2576.py4
-rw-r--r--pysnmp/proto/mpmod/rfc3412.py31
-rw-r--r--pysnmp/proto/secmod/rfc2576.py4
-rw-r--r--pysnmp/proto/secmod/rfc3414/service.py18
6 files changed, 48 insertions, 49 deletions
diff --git a/pysnmp/proto/api/v1.py b/pysnmp/proto/api/v1.py
index a863afd5..9b62f76a 100644
--- a/pysnmp/proto/api/v1.py
+++ b/pysnmp/proto/api/v1.py
@@ -39,8 +39,7 @@ class VarBindAPI(object):
varBind.setComponentByPosition(0, oid)
if val is None:
val = null
- varBind.setComponentByPosition(1).getComponentByPosition(1).setComponentByType(val.getTagSet(), val, 1,
- verifyConstraints=False)
+ varBind.setComponentByPosition(1).getComponentByPosition(1).setComponentByType(val.getTagSet(), val, verifyConstraints=False, matchTags=False, matchConstraints=False, innerFlag=True)
return varBind
@staticmethod
@@ -59,13 +58,13 @@ class PDUAPI(object):
def setDefaults(self, pdu):
pdu.setComponentByPosition(
- 0, getNextRequestID(), verifyConstraints=False
+ 0, getNextRequestID(), verifyConstraints=False, matchTags=False, matchConstraints=False
)
pdu.setComponentByPosition(
- 1, self._errorStatus, verifyConstraints=False
+ 1, self._errorStatus, verifyConstraints=False, matchTags=False, matchConstraints=False
)
pdu.setComponentByPosition(
- 2, self._errorIndex, verifyConstraints=False
+ 2, self._errorIndex, verifyConstraints=False, matchTags=False, matchConstraints=False
)
pdu.setComponentByPosition(3)
@@ -171,11 +170,11 @@ class TrapPDUAPI(object):
except Exception:
agentAddress = IpAddress('0.0.0.0')
self._networkAddress = NetworkAddress().setComponentByPosition(0, agentAddress)
- pdu.setComponentByPosition(0, self._entOid, verifyConstraints=False)
- pdu.setComponentByPosition(1, self._networkAddress, verifyConstraints=False)
- pdu.setComponentByPosition(2, self._genericTrap, verifyConstraints=False)
- pdu.setComponentByPosition(3, self._zeroInt, verifyConstraints=False)
- pdu.setComponentByPosition(4, self._zeroTime, verifyConstraints=False)
+ pdu.setComponentByPosition(0, self._entOid, verifyConstraints=False, matchTags=False, matchConstraints=False)
+ pdu.setComponentByPosition(1, self._networkAddress, verifyConstraints=False, matchTags=False, matchConstraints=False)
+ pdu.setComponentByPosition(2, self._genericTrap, verifyConstraints=False, matchTags=False, matchConstraints=False)
+ pdu.setComponentByPosition(3, self._zeroInt, verifyConstraints=False, matchTags=False, matchConstraints=False)
+ pdu.setComponentByPosition(4, self._zeroTime, verifyConstraints=False, matchTags=False, matchConstraints=False)
pdu.setComponentByPosition(5)
@staticmethod
@@ -257,8 +256,8 @@ class MessageAPI(object):
_community = univ.OctetString('public')
def setDefaults(self, msg):
- msg.setComponentByPosition(0, self._version, verifyConstraints=False)
- msg.setComponentByPosition(1, self._community, verifyConstraints=False)
+ msg.setComponentByPosition(0, self._version, verifyConstraints=False, matchTags=False, matchConstraints=False)
+ msg.setComponentByPosition(1, self._community, verifyConstraints=False, matchTags=False, matchConstraints=False)
return msg
@staticmethod
@@ -283,8 +282,7 @@ class MessageAPI(object):
@staticmethod
def setPDU(msg, value):
- msg.setComponentByPosition(2).getComponentByPosition(2).setComponentByType(value.getTagSet(), value, 1,
- verifyConstraints=False)
+ msg.setComponentByPosition(2).getComponentByPosition(2).setComponentByType(value.getTagSet(), value, verifyConstraints=False, matchTags=False, matchConstraints=False, innerFlag=True)
def getResponse(self, reqMsg):
rspMsg = Message()
diff --git a/pysnmp/proto/api/v2c.py b/pysnmp/proto/api/v2c.py
index 960c0c74..29e0ee3d 100644
--- a/pysnmp/proto/api/v2c.py
+++ b/pysnmp/proto/api/v2c.py
@@ -63,13 +63,13 @@ class PDUAPI(v1.PDUAPI):
def setEndOfMibError(self, pdu, errorIndex):
varBindList = self.getVarBindList(pdu)
varBindList[errorIndex - 1].setComponentByPosition(
- 1, rfc1905.endOfMibView, verifyConstraints=False
+ 1, rfc1905.endOfMibView, verifyConstraints=False, matchTags=False, matchConstraints=False
)
def setNoSuchInstanceError(self, pdu, errorIndex):
varBindList = self.getVarBindList(pdu)
varBindList[errorIndex - 1].setComponentByPosition(
- 1, rfc1905.noSuchInstance, verifyConstraints=False
+ 1, rfc1905.noSuchInstance, verifyConstraints=False, matchTags=False, matchConstraints=False
)
@@ -83,13 +83,13 @@ class BulkPDUAPI(PDUAPI):
def setDefaults(self, pdu):
PDUAPI.setDefaults(self, pdu)
pdu.setComponentByPosition(
- 0, getNextRequestID(), verifyConstraints=False
+ 0, getNextRequestID(), verifyConstraints=False, matchTags=False, matchConstraints=False
)
pdu.setComponentByPosition(
- 1, self._nonRepeaters, verifyConstraints=False
+ 1, self._nonRepeaters, verifyConstraints=False, matchTags=False, matchConstraints=False
)
pdu.setComponentByPosition(
- 2, self._maxRepetitions, verifyConstraints=False
+ 2, self._maxRepetitions, verifyConstraints=False, matchTags=False, matchConstraints=False
)
pdu.setComponentByPosition(3)
@@ -160,8 +160,8 @@ class MessageAPI(v1.MessageAPI):
_version = rfc1901.version.clone(1)
def setDefaults(self, msg):
- msg.setComponentByPosition(0, self._version, verifyConstraints=False)
- msg.setComponentByPosition(1, self._community, verifyConstraints=False)
+ msg.setComponentByPosition(0, self._version, verifyConstraints=False, matchTags=False, matchConstraints=False)
+ msg.setComponentByPosition(1, self._community, verifyConstraints=False, matchTags=False, matchConstraints=False)
return msg
def getResponse(self, reqMsg):
diff --git a/pysnmp/proto/mpmod/rfc2576.py b/pysnmp/proto/mpmod/rfc2576.py
index 7211e5a5..668eade2 100644
--- a/pysnmp/proto/mpmod/rfc2576.py
+++ b/pysnmp/proto/mpmod/rfc2576.py
@@ -63,7 +63,7 @@ class SnmpV1MessageProcessingModel(AbstractMessageProcessingModel):
msg.setComponentByPosition(0, self.messageProcessingModelID)
msg.setComponentByPosition(2)
msg.getComponentByPosition(2).setComponentByType(
- pdu.tagSet, pdu, verifyConstraints=False
+ pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False
)
# rfc3412: 7.1.7
@@ -193,7 +193,7 @@ class SnmpV1MessageProcessingModel(AbstractMessageProcessingModel):
msg.setComponentByPosition(0, messageProcessingModel)
msg.setComponentByPosition(2)
msg.getComponentByPosition(2).setComponentByType(
- pdu.tagSet, pdu, verifyConstraints=False
+ pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False
)
# att: msgId not set back to PDU as it's up to responder app
diff --git a/pysnmp/proto/mpmod/rfc3412.py b/pysnmp/proto/mpmod/rfc3412.py
index 7a53b4b1..8ea6d4a1 100644
--- a/pysnmp/proto/mpmod/rfc3412.py
+++ b/pysnmp/proto/mpmod/rfc3412.py
@@ -140,7 +140,7 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
scopedPDU.setComponentByPosition(1, contextName)
scopedPDU.setComponentByPosition(2)
scopedPDU.getComponentByPosition(2).setComponentByType(
- pdu.tagSet, pdu, verifyConstraints=False
+ pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False
)
# 7.1.7
@@ -148,12 +148,12 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
# 7.1.7a
msg.setComponentByPosition(
- 0, self.messageProcessingModelID, verifyConstraints=False
+ 0, self.messageProcessingModelID, verifyConstraints=False, matchTags=False, matchConstraints=False
)
headerData = msg.setComponentByPosition(1).getComponentByPosition(1)
# 7.1.7b
- headerData.setComponentByPosition(0, msgID, verifyConstraints=False)
+ headerData.setComponentByPosition(0, msgID, verifyConstraints=False, matchTags=False, matchConstraints=False)
snmpEngineMaxMessageSize, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols(
'__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize')
@@ -161,7 +161,7 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
# 7.1.7c
# XXX need to coerce MIB value as it has incompatible constraints set
headerData.setComponentByPosition(
- 1, snmpEngineMaxMessageSize.syntax, verifyConstraints=False
+ 1, snmpEngineMaxMessageSize.syntax, verifyConstraints=False, matchTags=False, matchConstraints=False
)
# 7.1.7d
@@ -181,7 +181,7 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
msgFlags |= 0x04
headerData.setComponentByPosition(
- 2, self._msgFlags[msgFlags], verifyConstraints=False
+ 2, self._msgFlags[msgFlags], verifyConstraints=False, matchTags=False, matchConstraints=False
)
# 7.1.7e
@@ -207,12 +207,12 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
securityLevel = 1
# Clear possible auth&priv flags
headerData.setComponentByPosition(
- 2, self._msgFlags[msgFlags & 0xfc], verifyConstraints=False
+ 2, self._msgFlags[msgFlags & 0xfc], verifyConstraints=False, matchTags=False, matchConstraints=False
)
# XXX
scopedPDU = self.__scopedPDU
scopedPDU.setComponentByPosition(
- 0, self._emptyStr, verifyConstraints=False
+ 0, self._emptyStr, verifyConstraints=False, matchTags=False, matchConstraints=False
)
scopedPDU.setComponentByPosition(1, contextName)
scopedPDU.setComponentByPosition(2)
@@ -222,7 +222,7 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
pMod.apiPDU.setDefaults(emptyPdu)
scopedPDU.getComponentByPosition(2).setComponentByType(
- emptyPdu.tagSet, emptyPdu, verifyConstraints=False
+ emptyPdu.tagSet, emptyPdu, verifyConstraints=False, matchTags=False, matchConstraints=False
)
debug.logger & debug.flagMP and debug.logger('prepareOutgoingMessage: force engineID discovery')
else:
@@ -367,20 +367,21 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
scopedPDU.setComponentByPosition(1, contextName)
scopedPDU.setComponentByPosition(2)
scopedPDU.getComponentByPosition(2).setComponentByType(
- pdu.tagSet, pdu, verifyConstraints=False
+ pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False
)
# 7.1.7
msg = self._snmpMsgSpec
# 7.1.7a
- msg.setComponentByPosition(0, self.messageProcessingModelID,
- verifyConstraints=False)
+ msg.setComponentByPosition(
+ 0, self.messageProcessingModelID, verifyConstraints=False, matchTags=False, matchConstraints=False
+ )
headerData = msg.setComponentByPosition(1).getComponentByPosition(1)
# 7.1.7b
- headerData.setComponentByPosition(0, msgID, verifyConstraints=False)
+ headerData.setComponentByPosition(0, msgID, verifyConstraints=False, matchTags=False, matchConstraints=False)
snmpEngineMaxMessageSize, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols(
'__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize')
@@ -388,7 +389,7 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
# 7.1.7c
# XXX need to coerce MIB value as it has incompatible constraints set
headerData.setComponentByPosition(
- 1, snmpEngineMaxMessageSize.syntax, verifyConstraints=False
+ 1, snmpEngineMaxMessageSize.syntax, verifyConstraints=False, matchTags=False, matchConstraints=False
)
# 7.1.7d
@@ -406,12 +407,12 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel):
msgFlags |= 0x04
headerData.setComponentByPosition(
- 2, self._msgFlags[msgFlags], verifyConstraints=False
+ 2, self._msgFlags[msgFlags], verifyConstraints=False, matchTags=False, matchConstraints=False
)
# 7.1.7e
headerData.setComponentByPosition(
- 3, securityModel, verifyConstraints=False
+ 3, securityModel, verifyConstraints=False, matchTags=False, matchConstraints=False
)
debug.logger & debug.flagMP and debug.logger('prepareResponseMessage: %s' % (msg.prettyPrint(),))
diff --git a/pysnmp/proto/secmod/rfc2576.py b/pysnmp/proto/secmod/rfc2576.py
index 3ef0778e..757ba03c 100644
--- a/pysnmp/proto/secmod/rfc2576.py
+++ b/pysnmp/proto/secmod/rfc2576.py
@@ -302,7 +302,7 @@ class SnmpV1SecurityModel(base.AbstractSecurityModel):
msg.setComponentByPosition(1, securityParameters)
msg.setComponentByPosition(2)
msg.getComponentByPosition(2).setComponentByType(
- pdu.tagSet, pdu, verifyConstraints=False
+ pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False
)
debug.logger & debug.flagMP and debug.logger('generateRequestMsg: %s' % (msg.prettyPrint(),))
@@ -332,7 +332,7 @@ class SnmpV1SecurityModel(base.AbstractSecurityModel):
msg.setComponentByPosition(1, communityName)
msg.setComponentByPosition(2)
msg.getComponentByPosition(2).setComponentByType(
- pdu.tagSet, pdu, verifyConstraints=False
+ pdu.tagSet, pdu, verifyConstraints=False, matchTags=False, matchConstraints=False
)
debug.logger & debug.flagMP and debug.logger('generateResponseMsg: %s' % (msg.prettyPrint(),))
diff --git a/pysnmp/proto/secmod/rfc3414/service.py b/pysnmp/proto/secmod/rfc3414/service.py
index 03e480af..4b4213c6 100644
--- a/pysnmp/proto/secmod/rfc3414/service.py
+++ b/pysnmp/proto/secmod/rfc3414/service.py
@@ -324,7 +324,7 @@ class SnmpUSMSecurityModel(AbstractSecurityModel):
scopedPDUData = msg.setComponentByPosition(3).getComponentByPosition(3)
scopedPDUData.setComponentByPosition(
- 0, scopedPDU, verifyConstraints=False
+ 0, scopedPDU, verifyConstraints=False, matchTags=False, matchConstraints=False
)
# 3.1.6a
@@ -390,10 +390,10 @@ class SnmpUSMSecurityModel(AbstractSecurityModel):
)
securityParameters.setComponentByPosition(
- 5, privParameters, verifyConstraints=False
+ 5, privParameters, verifyConstraints=False, matchTags=False, matchConstraints=False
)
scopedPDUData.setComponentByPosition(
- 1, encryptedData, verifyConstraints=False
+ 1, encryptedData, verifyConstraints=False, matchTags=False, matchConstraints=False
)
debug.logger & debug.flagSM and debug.logger(
@@ -407,18 +407,18 @@ class SnmpUSMSecurityModel(AbstractSecurityModel):
# 3.1.5
securityParameters.setComponentByPosition(
- 0, securityEngineID, verifyConstraints=False
+ 0, securityEngineID, verifyConstraints=False, matchTags=False, matchConstraints=False
)
securityParameters.setComponentByPosition(
- 1, snmpEngineBoots, verifyConstraints=False
+ 1, snmpEngineBoots, verifyConstraints=False, matchTags=False, matchConstraints=False
)
securityParameters.setComponentByPosition(
- 2, snmpEngineTime, verifyConstraints=False
+ 2, snmpEngineTime, verifyConstraints=False, matchTags=False, matchConstraints=False
)
# 3.1.7
securityParameters.setComponentByPosition(
- 3, usmUserName, verifyConstraints=False
+ 3, usmUserName, verifyConstraints=False, matchTags=False, matchConstraints=False
)
# 3.1.8a
@@ -469,14 +469,14 @@ class SnmpUSMSecurityModel(AbstractSecurityModel):
# 3.1.8b
else:
securityParameters.setComponentByPosition(
- 4, '', verifyConstraints=False
+ 4, '', verifyConstraints=False, matchTags=False, matchConstraints=False
)
debug.logger & debug.flagSM and debug.logger(
'__generateRequestOrResponseMsg: %s' % (securityParameters.prettyPrint(),))
try:
- msg.setComponentByPosition(2, encoder.encode(securityParameters), verifyConstraints=False)
+ msg.setComponentByPosition(2, encoder.encode(securityParameters), verifyConstraints=False, matchTags=False, matchConstraints=False)
except PyAsn1Error:
debug.logger & debug.flagSM and debug.logger(