summaryrefslogtreecommitdiff
path: root/examples/v3arch/asyncore/proxy
diff options
context:
space:
mode:
Diffstat (limited to 'examples/v3arch/asyncore/proxy')
-rw-r--r--examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py21
-rw-r--r--examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py18
-rw-r--r--examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py16
-rw-r--r--examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py22
4 files changed, 41 insertions, 36 deletions
diff --git a/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py b/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py
index d06261a3..475435ee 100644
--- a/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py
+++ b/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py
@@ -70,8 +70,7 @@ config.addV1System(snmpEngine, '1-my-area', 'public')
# to let it match first in snmpCommunityTable on response processing.
#
-config.addV1System(snmpEngine, '0-distant-area', 'public',
- transportTag='remote')
+config.addV1System(snmpEngine, '0-distant-area', 'public', transportTag='remote')
#
# Transport target used by Manager
@@ -81,20 +80,21 @@ config.addTargetParams(
snmpEngine, 'distant-agent-auth', '0-distant-area', 'noAuthNoPriv', 1
)
config.addTargetAddr(
- snmpEngine, 'distant-agent',
- udp.domainName, ('195.218.195.228', 161),
- 'distant-agent-auth', retryCount=0, tagList='remote'
+ snmpEngine, 'distant-agent',
+ udp.domainName, ('195.218.195.228', 161),
+ 'distant-agent-auth', retryCount=0, tagList='remote'
)
# Default SNMP context
config.addContext(snmpEngine, '')
+
class CommandResponder(cmdrsp.CommandResponderBase):
- cmdGenMap = {
+ cmdGenMap = {
v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(),
v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(),
v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(),
- v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
+ v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
}
pduTypes = cmdGenMap.keys() # This app will handle these PDUs
@@ -105,14 +105,14 @@ class CommandResponder(cmdrsp.CommandResponderBase):
contextEngineId = None # address authoritative SNMP Engine
try:
self.cmdGenMap[PDU.tagSet].sendPdu(
- snmpEngine, 'distant-agent',
+ snmpEngine, 'distant-agent',
contextEngineId, contextName,
PDU,
self.handleResponsePdu, cbCtx
)
except error.PySnmpError:
self.handleResponsePdu(
- stateReference, 'error', None, cbCtx
+ snmpEngine, stateReference, 'error', None, cbCtx
)
# SNMP response relay
@@ -131,9 +131,10 @@ class CommandResponder(cmdrsp.CommandResponderBase):
self.releaseStateInformation(stateReference)
+
CommandResponder(snmpEngine, context.SnmpContext(snmpEngine))
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send responses
try:
diff --git a/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py b/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py
index c8dc63eb..71e2347e 100644
--- a/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py
+++ b/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py
@@ -79,20 +79,21 @@ config.addTargetParams(snmpEngine, 'distant-agent-auth', 'distant-area',
'noAuthNoPriv', 0)
config.addTargetAddr(
- snmpEngine, 'distant-agent',
- udp.domainName + (2,), ('195.218.195.228', 161),
- 'distant-agent-auth', retryCount=0, tagList='distant'
+ snmpEngine, 'distant-agent',
+ udp.domainName + (2,), ('195.218.195.228', 161),
+ 'distant-agent-auth', retryCount=0, tagList='distant'
)
# Default SNMP context
config.addContext(snmpEngine, '')
+
class CommandResponder(cmdrsp.CommandResponderBase):
- cmdGenMap = {
+ cmdGenMap = {
v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(),
v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(),
v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(),
- v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
+ v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
}
pduTypes = cmdGenMap.keys() # This app will handle these PDUs
@@ -103,14 +104,14 @@ class CommandResponder(cmdrsp.CommandResponderBase):
contextEngineId = None # address authoritative SNMP Engine
try:
self.cmdGenMap[PDU.tagSet].sendPdu(
- snmpEngine, 'distant-agent',
+ snmpEngine, 'distant-agent',
contextEngineId, contextName,
PDU,
self.handleResponsePdu, cbCtx
)
except error.PySnmpError:
self.handleResponsePdu(
- stateReference, 'error', None, cbCtx
+ snmpEngine, stateReference, 'error', None, cbCtx
)
# SNMP response relay
@@ -129,9 +130,10 @@ class CommandResponder(cmdrsp.CommandResponderBase):
self.releaseStateInformation(stateReference)
+
CommandResponder(snmpEngine, context.SnmpContext(snmpEngine))
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send responses
try:
diff --git a/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py b/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py
index e232e19e..e49d604b 100644
--- a/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py
+++ b/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py
@@ -79,20 +79,21 @@ config.addTargetParams(
snmpEngine, 'distant-agent-auth', 'usr-md5-none', 'authNoPriv'
)
config.addTargetAddr(
- snmpEngine, 'distant-agent',
- udp.domainName + (2,), ('195.218.195.228', 161),
- 'distant-agent-auth', retryCount=0
+ snmpEngine, 'distant-agent',
+ udp.domainName + (2,), ('195.218.195.228', 161),
+ 'distant-agent-auth', retryCount=0
)
# Default SNMP context
config.addContext(snmpEngine, '')
+
class CommandResponder(cmdrsp.CommandResponderBase):
- cmdGenMap = {
+ cmdGenMap = {
v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(),
v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(),
v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(),
- v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
+ v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
}
pduTypes = cmdGenMap.keys() # This app will handle these PDUs
@@ -110,7 +111,7 @@ class CommandResponder(cmdrsp.CommandResponderBase):
)
except error.PySnmpError:
self.handleResponsePdu(
- stateReference, 'error', None, cbCtx
+ snmpEngine, stateReference, 'error', None, cbCtx
)
# SNMP response relay
@@ -129,9 +130,10 @@ class CommandResponder(cmdrsp.CommandResponderBase):
self.releaseStateInformation(stateReference)
+
CommandResponder(snmpEngine, context.SnmpContext(snmpEngine))
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send responses
try:
diff --git a/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py b/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py
index 8247e45e..2cc397c7 100644
--- a/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py
+++ b/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py
@@ -82,20 +82,21 @@ config.addTargetParams(snmpEngine, 'distant-agent-auth', 'my-area',
'noAuthNoPriv', 0)
config.addTargetAddr(
- snmpEngine, 'distant-agent',
- udp.domainName + (2,), ('195.218.195.228', 161),
- 'distant-agent-auth', retryCount=0
+ snmpEngine, 'distant-agent',
+ udp.domainName + (2,), ('195.218.195.228', 161),
+ 'distant-agent-auth', retryCount=0
)
# Default SNMP context
config.addContext(snmpEngine, '')
+
class CommandResponder(cmdrsp.CommandResponderBase):
- cmdGenMap = {
+ cmdGenMap = {
v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(),
v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(),
v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(),
- v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
+ v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
}
pduTypes = cmdGenMap.keys() # This app will handle these PDUs
@@ -106,14 +107,14 @@ class CommandResponder(cmdrsp.CommandResponderBase):
contextEngineId = None # address authoritative SNMP Engine
try:
self.cmdGenMap[PDU.tagSet].sendPdu(
- snmpEngine, 'distant-agent',
+ snmpEngine, 'distant-agent',
contextEngineId, contextName,
PDU,
self.handleResponsePdu, cbCtx
)
except error.PySnmpError:
self.handleResponsePdu(
- stateReference, 'error', None, cbCtx
+ snmpEngine, stateReference, 'error', None, cbCtx
)
# SNMP response relay
@@ -126,15 +127,14 @@ class CommandResponder(cmdrsp.CommandResponderBase):
PDU = v2c.apiPDU.getResponse(reqPDU)
PDU.setErrorStatus(PDU, 5)
- self.sendPdu(
- snmpEngine, stateReference, PDU
- )
+ self.sendPdu(snmpEngine, stateReference, PDU)
self.releaseStateInformation(stateReference)
+
CommandResponder(snmpEngine, context.SnmpContext(snmpEngine))
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send responses
try: