summaryrefslogtreecommitdiff
path: root/pysnmp/hlapi/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'pysnmp/hlapi/context.py')
-rw-r--r--pysnmp/hlapi/context.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/pysnmp/hlapi/context.py b/pysnmp/hlapi/context.py
new file mode 100644
index 0000000..0d86480
--- /dev/null
+++ b/pysnmp/hlapi/context.py
@@ -0,0 +1,48 @@
+from pyasn1.compat.octets import null
+
+__all__ = ['ContextData']
+
+class ContextData:
+ """Creates UDP/IPv6 configuration entry and initialize socket API if needed.
+
+ This object can be used by
+ :py:class:`~pysnmp.entity.rfc3413.oneliner.cmdgen.AsyncCommandGenerator` or
+ :py:class:`~pysnmp.entity.rfc3413.oneliner.ntforg.AsyncNotificationOriginator`
+ and their derevatives for forming SNMP PDU and also adding new entries to
+ Local Configuration Datastore (LCD) in order to support SNMPv1/v2c with
+ SNMPv3 interoperability.
+
+ See :RFC:`3411#section-4.1` for SNMP Context details.
+
+ Parameters
+ ----------
+ contextEngineId : str
+ Uniquely identifies an SNMP entity that may realize an instance of
+ a MIB with a particular contextName (:RFC:`3411#section-3.3.2`).
+ More frequently than not, ContextEngineID is the same as
+ authoritative SnmpEngineID, however if SNMP Engine serves multiple
+ SNMP Entities, their ContextEngineIDs would be distinct.
+ Default is authoritative SNMP Engine ID.
+ contextName : str
+ Used to name an instance of MIB (:RFC:`3411#section-3.3.3`).
+ Default is empty string.
+
+ Examples
+ --------
+ >>> from pysnmp.entity.rfc3413.oneliner.ctx import ContextData
+ >>> ContextData()
+ ContextData(contextEngineId=None, contextName='')
+ >>> ContextData(OctetString(hexValue='01020ABBA0'))
+ ContextData(contextEngineId=OctetString(hexValue='01020abba0'), contextName='')
+ >>> ContextData(contextName='mycontext')
+ ContextData(contextEngineId=None, contextName='mycontext')
+
+ """
+ def __init__(self, contextEngineId=None, contextName=null):
+ self.contextEngineId = contextEngineId
+ self.contextName = contextName
+
+ def __repr__(self):
+ return '%s(contextEngineId=%r, contextName=%r)' % (
+ self.__class__.__name__, self.contextEngineId, self.contextName
+ )