2015-11-20 21:57:28 +01:00
|
|
|
#
|
|
|
|
# This file is part of pysnmp software.
|
|
|
|
#
|
2017-01-12 01:05:56 +01:00
|
|
|
# Copyright (c) 2005-2017, Ilya Etingof <etingof@gmail.com>
|
2015-11-20 21:57:28 +01:00
|
|
|
# License: http://pysnmp.sf.net/license.html
|
|
|
|
#
|
2011-02-11 08:50:59 +01:00
|
|
|
from pysnmp.proto.mpmod import cache
|
2013-06-03 23:58:52 +02:00
|
|
|
from pysnmp.proto import error
|
2005-06-14 12:43:02 +02:00
|
|
|
|
2016-04-02 23:43:14 +02:00
|
|
|
|
2016-06-12 14:07:24 +02:00
|
|
|
class AbstractMessageProcessingModel(object):
|
2013-06-04 08:26:02 +02:00
|
|
|
snmpMsgSpec = NotImplementedError
|
2016-04-02 23:43:14 +02:00
|
|
|
|
2005-06-14 12:43:02 +02:00
|
|
|
def __init__(self):
|
2011-01-23 13:34:58 +01:00
|
|
|
self._snmpMsgSpec = self.snmpMsgSpec() # local copy
|
2011-02-11 08:50:59 +01:00
|
|
|
self._cache = cache.Cache()
|
2015-10-17 11:54:53 +02:00
|
|
|
|
|
|
|
def prepareOutgoingMessage(self, snmpEngine, transportDomain,
|
|
|
|
transportAddress, messageProcessingModel,
|
|
|
|
securityModel, securityName, securityLevel,
|
|
|
|
contextEngineId, contextName, pduVersion,
|
|
|
|
pdu, expectResponse, sendPduHandle):
|
2006-09-05 17:37:40 +02:00
|
|
|
raise error.ProtocolError('method not implemented')
|
2015-10-17 11:54:53 +02:00
|
|
|
|
|
|
|
def prepareResponseMessage(self, snmpEngine, messageProcessingModel,
|
|
|
|
securityModel, securityName, securityLevel,
|
|
|
|
contextEngineId, contextName, pduVersion,
|
|
|
|
pdu, maxSizeResponseScopedPDU,
|
|
|
|
stateReference, statusInformation):
|
2006-09-05 17:37:40 +02:00
|
|
|
raise error.ProtocolError('method not implemented')
|
2005-06-27 14:42:22 +02:00
|
|
|
|
2015-10-17 11:54:53 +02:00
|
|
|
def prepareDataElements(self, snmpEngine, transportDomain,
|
|
|
|
transportAddress, wholeMsg):
|
2006-09-05 17:37:40 +02:00
|
|
|
raise error.ProtocolError('method not implemented')
|
2005-06-14 12:43:02 +02:00
|
|
|
|
2005-06-22 20:51:21 +02:00
|
|
|
def releaseStateInformation(self, sendPduHandle):
|
2005-06-22 23:48:22 +02:00
|
|
|
try:
|
2011-02-11 08:50:59 +01:00
|
|
|
self._cache.popBySendPduHandle(sendPduHandle)
|
2005-06-22 23:48:22 +02:00
|
|
|
except error.ProtocolError:
|
2016-04-02 23:43:14 +02:00
|
|
|
pass # XXX maybe these should all follow some scheme?
|
2015-10-17 11:54:53 +02:00
|
|
|
|
2006-09-20 18:26:13 +02:00
|
|
|
def receiveTimerTick(self, snmpEngine, timeNow):
|
2011-02-11 08:50:59 +01:00
|
|
|
self._cache.expireCaches()
|