diff options
author | elie <elie> | 2012-04-14 08:26:38 +0000 |
---|---|---|
committer | elie <elie> | 2012-04-14 08:26:38 +0000 |
commit | 57f2106422a98ed55fbdd6ded6b105068f872c6b (patch) | |
tree | 61411f46761322fdb3986cb6a7cf08ec4934f42c /pysnmp/entity/rfc3413/cmdgen.py | |
parent | 53e8fc28176a01d53ca62df924fc365dd0c5f1ad (diff) | |
download | pysnmp-57f2106422a98ed55fbdd6ded6b105068f872c6b.tar.gz |
fix to ContextName handling in bytes form whilst running Python3. Data
mismatch error would return otherwise.
Diffstat (limited to 'pysnmp/entity/rfc3413/cmdgen.py')
-rw-r--r-- | pysnmp/entity/rfc3413/cmdgen.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/pysnmp/entity/rfc3413/cmdgen.py b/pysnmp/entity/rfc3413/cmdgen.py index 478e2cc..1b68bf2 100644 --- a/pysnmp/entity/rfc3413/cmdgen.py +++ b/pysnmp/entity/rfc3413/cmdgen.py @@ -4,7 +4,6 @@ from pysnmp.entity.rfc3413 import config from pysnmp.proto.proxy import rfc2576 from pysnmp import error, nextid, debug from pyasn1.type import univ -from pyasn1.compat.octets import null getNextHandle = nextid.Integer(0x7fffffff) @@ -39,6 +38,7 @@ class CommandGeneratorBase: _null = univ.Null('') def __init__(self): self.__pendingReqs = {} + self.__SnmpEngineID, self.__SnmpAdminString = None, None def processResponsePdu( self, @@ -156,7 +156,7 @@ class CommandGeneratorBase: cbFun, cbCtx=None, contextEngineId=None, - contextName=null + contextName='' ): raise error.PySnmpError('Method not implemented') @@ -184,6 +184,14 @@ class CommandGeneratorBase: # Convert timeout in seconds into timeout in timer ticks timeoutInTicks = float(timeout)/100/snmpEngine.transportDispatcher.getTimerResolution() + if not self.__SnmpEngineID or not self.__SnmpAdminString: + self.__SnmpEngineID, self.__SnmpAdminString = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpEngineID', 'SnmpAdminString') + + # Cast possible strings into bytes + if contextEngineId: + contextEngineId = self.__SnmpEngineID(contextEngineId) + contextName = self.__SnmpAdminString(contextName) + # 3.1 sendPduHandle = snmpEngine.msgAndPduDsp.sendPdu( snmpEngine, @@ -233,7 +241,7 @@ class GetCommandGenerator(CommandGeneratorBase): cbFun, cbCtx=None, contextEngineId=None, - contextName=null + contextName='' ): ( transportDomain, transportAddress, @@ -311,7 +319,7 @@ class SetCommandGenerator(CommandGeneratorBase): cbFun, cbCtx=None, contextEngineId=None, - contextName=null + contextName='' ): ( transportDomain, transportAddress, @@ -394,7 +402,7 @@ class NextCommandGenerator(CommandGeneratorBase): cbFun, cbCtx=None, contextEngineId=None, - contextName=null + contextName='' ): ( transportDomain, transportAddress, @@ -510,7 +518,7 @@ class BulkCommandGenerator(CommandGeneratorBase): cbFun, cbCtx=None, contextEngineId=None, - contextName=null + contextName='' ): ( transportDomain, transportAddress, |