summaryrefslogtreecommitdiff
path: root/pysnmp/entity
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2018-08-12 17:22:58 +0200
committerGitHub <noreply@github.com>2018-08-12 17:22:58 +0200
commitac0b956d006a4b7b32780e852740b56ecd826c7e (patch)
tree4576911add0e18525991109acdb2a91bc4b2fde8 /pysnmp/entity
parent488ec26798a4493ee0fc45e730f88f1365f56df7 (diff)
downloadpysnmp-git-ac0b956d006a4b7b32780e852740b56ecd826c7e.tar.gz
Add `hlapi.v1arch` API (#186)
* Add `hlapi.v1arch` API Introduce new sub-package `pysnmp.hlapi.v1arch` which wraps otherwise very detailed packet-level SNMP messaging into a handful of convenience functions. As a side effect, the `pysnmp.hlapi.*` sub-packages moved under `pysnmp.hlapi.v3arch` though `pysnmp.hlapi` still exposes `pysnmp.hlappi.v3arch.*` symbols to retain some degree of backward compatibility. The signature of the hlapi `.sendNotification()` call has changed to accept `*varBinds` instead of a sequence of `varBinds`. The rationale is to unify this method call with similar methods of CommandGenerator. * Add v1arch docs and reshuffle hlapi docs
Diffstat (limited to 'pysnmp/entity')
-rw-r--r--pysnmp/entity/rfc3413/cmdgen.py30
1 files changed, 2 insertions, 28 deletions
diff --git a/pysnmp/entity/rfc3413/cmdgen.py b/pysnmp/entity/rfc3413/cmdgen.py
index 90180c67..9f5d891d 100644
--- a/pysnmp/entity/rfc3413/cmdgen.py
+++ b/pysnmp/entity/rfc3413/cmdgen.py
@@ -18,28 +18,6 @@ getNextHandle = nextid.Integer(0x7fffffff)
__null = univ.Null('')
-def getNextVarBinds(varBinds, origVarBinds=None):
- errorIndication = None
- idx = nonNulls = len(varBinds)
- rspVarBinds = []
- while idx:
- idx -= 1
- if varBinds[idx][1].tagSet in (rfc1905.NoSuchObject.tagSet,
- rfc1905.NoSuchInstance.tagSet,
- rfc1905.EndOfMibView.tagSet):
- nonNulls -= 1
- elif origVarBinds is not None:
- if v2c.ObjectIdentifier(origVarBinds[idx][0]).asTuple() >= varBinds[idx][0].asTuple():
- errorIndication = errind.oidNotIncreasing
-
- rspVarBinds.insert(0, (varBinds[idx][0], __null))
-
- if not nonNulls:
- rspVarBinds = []
-
- return errorIndication, rspVarBinds
-
-
class CommandGenerator(object):
_null = univ.Null('')
@@ -289,9 +267,7 @@ class NextCommandGenerator(NextCommandGeneratorSingleRun):
elif not varBindTable:
errorIndication, varBinds = errind.emptyResponse, ()
else:
- errorIndication, varBinds = getNextVarBinds(
- varBindTable[-1], v2c.apiPDU.getVarBinds(reqPDU)
- )
+ errorIndication, varBinds = v2c.apiPDU.getNextVarBinds(varBindTable[-1])
if not cbFun(snmpEngine, sendRequestHandle, errorIndication,
v2c.apiPDU.getErrorStatus(PDU),
@@ -371,9 +347,7 @@ class BulkCommandGenerator(BulkCommandGeneratorSingleRun):
elif not varBindTable:
errorIndication, varBinds = errind.emptyResponse, ()
else:
- errorIndication, varBinds = getNextVarBinds(
- varBindTable[-1], v2c.apiPDU.getVarBinds(reqPDU)
- )
+ errorIndication, varBinds = v2c.apiBulkPDU.getNextVarBinds(varBindTable[-1])
nonRepeaters = v2c.apiBulkPDU.getNonRepeaters(reqPDU)
if nonRepeaters:
varBinds = v2c.apiBulkPDU.getVarBinds(reqPDU)[:int(nonRepeaters)] + varBinds[int(nonRepeaters):]