diff options
author | elie <elie> | 2005-06-27 12:42:22 +0000 |
---|---|---|
committer | elie <elie> | 2005-06-27 12:42:22 +0000 |
commit | 4547c57ff44dd7263c67470f1aa9b9fc7d6e26d0 (patch) | |
tree | 5fa9ffdc04ddf6507d0e394ea2bf55b9ab75c02c /pysnmp/proto | |
parent | 512e272f874fc397bb00bb261656729359f92f15 (diff) | |
download | pysnmp-git-4547c57ff44dd7263c67470f1aa9b9fc7d6e26d0.tar.gz |
minor syntax fixes followed pychecker report
Diffstat (limited to 'pysnmp/proto')
-rw-r--r-- | pysnmp/proto/acmod/rfc3415.py | 2 | ||||
-rw-r--r-- | pysnmp/proto/error.py | 1 | ||||
-rw-r--r-- | pysnmp/proto/mpmod/base.py | 46 | ||||
-rw-r--r-- | pysnmp/proto/mpmod/rfc2576.py | 7 | ||||
-rw-r--r-- | pysnmp/proto/mpmod/rfc3412.py | 31 | ||||
-rw-r--r-- | pysnmp/proto/proxy/rfc2576.py | 2 | ||||
-rw-r--r-- | pysnmp/proto/secmod/base.py | 8 | ||||
-rw-r--r-- | pysnmp/proto/secmod/rfc3414/priv/base.py | 6 | ||||
-rw-r--r-- | pysnmp/proto/secmod/rfc3414/service.py | 2 |
9 files changed, 69 insertions, 36 deletions
diff --git a/pysnmp/proto/acmod/rfc3415.py b/pysnmp/proto/acmod/rfc3415.py index 8c006c2d..27755345 100644 --- a/pysnmp/proto/acmod/rfc3415.py +++ b/pysnmp/proto/acmod/rfc3415.py @@ -92,7 +92,7 @@ def isAccessAllowed( continue if vacmViewTreeFamilyMask.syntax: mask = [] - for c in str(vacmViewTreeFamilyMask.syntax): + for c in map(None, str(vacmViewTreeFamilyMask.syntax)): mask = mask + map(lambda b,c=ord(c): b&c, __powOfTwoSeq) m = len(mask)-1 idx = l-1 diff --git a/pysnmp/proto/error.py b/pysnmp/proto/error.py index f812ae6e..00ac5a03 100644 --- a/pysnmp/proto/error.py +++ b/pysnmp/proto/error.py @@ -8,6 +8,7 @@ class ProtocolError(PySnmpError, PyAsn1Error): pass class SnmpV3Error(ProtocolError): pass class StatusInformation(SnmpV3Error): def __init__(self, **kwargs): + SnmpV3Error.__init__(self) # print kwargs self.__errorIndication = kwargs def __str__(self): return str(self.__errorIndication) diff --git a/pysnmp/proto/mpmod/base.py b/pysnmp/proto/mpmod/base.py index 94a8a141..30923b32 100644 --- a/pysnmp/proto/mpmod/base.py +++ b/pysnmp/proto/mpmod/base.py @@ -12,12 +12,46 @@ class AbstractMessageProcessingModel: self.__expirationQueue = {} self.__expirationTimer = 0L - def prepareOutgoingMessage(self, msgAndPduDsp, mibInstrumController, - **kwargs): pass - def prepareResponseMessage(self, msgAndPduDsp, mibInstrumController, - **kwargs): pass - def prepareDataElements(self, msgAndPduDsp, mibInstrumController, - wholeMsg): pass + def prepareOutgoingMessage( + self, + snmpEngine, + transportDomain, + transportAddress, + messageProcessingModel, + securityModel, + securityName, + securityLevel, + contextEngineID, + contextName, + pduVersion, + pdu, + expectResponse, + sendPduHandle + ): pass + + def prepareResponseMessage( + self, + snmpEngine, + messageProcessingModel, + securityModel, + securityName, + securityLevel, + contextEngineID, + contextName, + pduVersion, + pdu, + maxSizeResponseScopedPDU, + stateReference, + statusInformation + ): pass + + def prepareDataElements( + self, + snmpEngine, + transportDomain, + transportAddress, + wholeMsg + ): pass def _newStateReference(self): AbstractMessageProcessingModel.__stateReference = ( diff --git a/pysnmp/proto/mpmod/rfc2576.py b/pysnmp/proto/mpmod/rfc2576.py index 163ae8c2..ce27793e 100644 --- a/pysnmp/proto/mpmod/rfc2576.py +++ b/pysnmp/proto/mpmod/rfc2576.py @@ -68,9 +68,7 @@ class SnmpV1MessageProcessingModel(AbstractMessageProcessingModel): errorIndication = 'unsupportedSecurityModel' ) - # rfc3412: 7.1.9.a & rfc2576: 5.2.1 - if rfc3411.unconfirmedClassPDUs.has_key(pdu.tagSet): - securityEngineID = snmpEngineID + # rfc3412: 7.1.9.a & rfc2576: 5.2.1 --> no-op snmpEngineMaxMessageSize, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') @@ -166,6 +164,8 @@ class SnmpV1MessageProcessingModel(AbstractMessageProcessingModel): msg.setComponentByPosition(2) msg.getComponentByPosition(2).setComponentByType(pdu.tagSet, pdu) + # att: msgId not set back to PDU as it's up to responder app + # rfc3412: 7.1.7 globalData = ( msg, ) @@ -388,4 +388,3 @@ class SnmpV2cMessageProcessingModel(SnmpV1MessageProcessingModel): # XXX # cache expiration -# why ResponsePdu accepts non ASN1 objects? diff --git a/pysnmp/proto/mpmod/rfc3412.py b/pysnmp/proto/mpmod/rfc3412.py index 9323dbdb..6b844a5f 100644 --- a/pysnmp/proto/mpmod/rfc3412.py +++ b/pysnmp/proto/mpmod/rfc3412.py @@ -162,21 +162,18 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel): securityEngineID = peerSnmpEngineData['securityEngineID'] # 7.1.9.b - try: - ( securityParameters, - wholeMsg ) = smHandler.generateRequestMsg( - snmpEngine, - self.messageProcessingModelID, - msg, - snmpEngineMaxMessageSize.syntax, - securityModel, - securityEngineID, - securityName, - securityLevel, - scopedPDU - ) - except error.StatusInformation, statusInformation: - raise + ( securityParameters, + wholeMsg ) = smHandler.generateRequestMsg( + snmpEngine, + self.messageProcessingModelID, + msg, + snmpEngineMaxMessageSize.syntax, + securityModel, + securityEngineID, + securityName, + securityLevel, + scopedPDU + ) # Message size constraint verification if len(wholeMsg) > snmpEngineMaxMessageSize.syntax: @@ -385,7 +382,7 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel): msg, restOfwholeMsg = decoder.decode( wholeMsg, asn1Spec=self._snmpMsgSpec ) - except PyAsn1Error, why: + except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( @@ -606,7 +603,7 @@ class SnmpV3MessageProcessingModel(AbstractMessageProcessingModel): if rfc3411.confirmedClassPDUs.has_key(pduType): # 7.2.13a if securityEngineID != snmpEngineID: - smHandler.releaseStateInformation(securityStateRerefence) + smHandler.releaseStateInformation(securityStateReference) raise error.StatusInformation( errorIndication = 'engineIDMispatch' ) diff --git a/pysnmp/proto/proxy/rfc2576.py b/pysnmp/proto/proxy/rfc2576.py index dcab6d46..bed2a8b1 100644 --- a/pysnmp/proto/proxy/rfc2576.py +++ b/pysnmp/proto/proxy/rfc2576.py @@ -1,5 +1,5 @@ # PDU v1/v2c two-way proxy -from pysnmp.proto import rfc3411 +from pysnmp.proto import rfc3411, error from pysnmp.proto.api import v1, v2c from pysnmp.smi import exval diff --git a/pysnmp/proto/secmod/base.py b/pysnmp/proto/secmod/base.py index 8f32d711..1f691186 100644 --- a/pysnmp/proto/secmod/base.py +++ b/pysnmp/proto/secmod/base.py @@ -8,7 +8,7 @@ class AbstractSecurityModel: def processIncomingMsg( self, - mibInstrumController, + snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, @@ -23,7 +23,7 @@ class AbstractSecurityModel: def generateRequestMsg( self, - minInstrController, + snmpEngine, messageProcessingModel, globalData, maxMessageSize, @@ -39,7 +39,7 @@ class AbstractSecurityModel: def generateResponseMsg( self, - minInstrController, + snmpEngine, messageProcessingModel, globalData, maxMessageSize, @@ -73,4 +73,4 @@ class AbstractSecurityModel: return securityData def releaseStateInformation(self, stateReference): - self.__cachePop(stateReference) + self._cachePop(stateReference) diff --git a/pysnmp/proto/secmod/rfc3414/priv/base.py b/pysnmp/proto/secmod/rfc3414/priv/base.py index 8690d4de..83c1b098 100644 --- a/pysnmp/proto/secmod/rfc3414/priv/base.py +++ b/pysnmp/proto/secmod/rfc3414/priv/base.py @@ -1,4 +1,6 @@ class AbstractEncryptionService: serviceID = None - def encryptData(self, encryptKey, dataToEncrypt): pass - def decryptData(self, decryptKey, privParameters, encryptedData): pass + def encryptData(self, mibInstrumController, encryptKey, + dataToEncrypt):pass + def decryptData(self, mibInstrumController, decryptKey, + privParameters, encryptedData): pass diff --git a/pysnmp/proto/secmod/rfc3414/service.py b/pysnmp/proto/secmod/rfc3414/service.py index 65dcda80..e7960394 100644 --- a/pysnmp/proto/secmod/rfc3414/service.py +++ b/pysnmp/proto/secmod/rfc3414/service.py @@ -389,7 +389,7 @@ class SnmpUSMSecurityModel(AbstractSecurityModel): securityParameters, asn1Spec=self._securityParametersSpec ) - except PyAsn1Error, why: + except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( |