/usr/lib/python2.7/dist-packages/pysnmp/hlapi/transport.py is in python-pysnmp4 4.4.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #
# This file is part of pysnmp software.
#
# Copyright (c) 2005-2017, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pysnmp/license.html
#
from pyasn1.compat.octets import null
from pysnmp.carrier.base import AbstractTransport
from pysnmp import error
__all__ = []
class AbstractTransportTarget(object):
transportDomain = None
protoTransport = AbstractTransport
def __init__(self, transportAddr, timeout=1, retries=5, tagList=null):
self.transportAddr = self._resolveAddr(transportAddr)
self.timeout = timeout
self.retries = retries
self.tagList = tagList
self.iface = None
self.transport = None
def __repr__(self):
return '%s(%r, timeout=%r, retries=%r, tagList=%r)' % (
self.__class__.__name__, self.transportAddr,
self.timeout, self.retries, self.tagList
)
def getTransportInfo(self):
return self.transportDomain, self.transportAddr
def setLocalAddress(self, iface):
"""Set source address.
Parameters
----------
iface : tuple
Indicates network address of a local interface from which SNMP packets will be originated.
Format is the same as of `transportAddress`.
Returns
-------
self
"""
self.iface = iface
return self
def openClientMode(self):
self.transport = self.protoTransport().openClientMode(self.iface)
return self.transport
def verifyDispatcherCompatibility(self, snmpEngine):
if not self.protoTransport.isCompatibleWithDispatcher(snmpEngine.transportDispatcher):
raise error.PySnmpError('Transport %r is not compatible with dispatcher %r' % (
self.protoTransport, snmpEngine.transportDispatcher))
def _resolveAddr(self, transportAddr):
raise NotImplementedError()
|