summaryrefslogtreecommitdiff
path: root/pysnmp/carrier
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2016-03-30 23:29:55 +0200
committerIlya Etingof <etingof@gmail.com>2016-03-30 23:29:55 +0200
commit8e655f46e39b78290818345bb07e98dbe7b063b9 (patch)
treeb4053b17e0df7eac0b84a7f21314f24ded43ea95 /pysnmp/carrier
parent39dac83818d73bdb78e47b005903a86966bd1f55 (diff)
downloadpysnmp-git-8e655f46e39b78290818345bb07e98dbe7b063b9.tar.gz
pep8 fixes
Diffstat (limited to 'pysnmp/carrier')
-rw-r--r--pysnmp/carrier/asyncore/base.py2
-rw-r--r--pysnmp/carrier/sockmsg.py12
2 files changed, 14 insertions, 0 deletions
diff --git a/pysnmp/carrier/asyncore/base.py b/pysnmp/carrier/asyncore/base.py
index 22f3dd14..da68774d 100644
--- a/pysnmp/carrier/asyncore/base.py
+++ b/pysnmp/carrier/asyncore/base.py
@@ -17,6 +17,8 @@ class AbstractSocketTransport(asyncore.dispatcher, AbstractTransport):
retryCount = 0
retryInterval = 0
bufferSize = 131070
+
+ # noinspection PyUnusedLocal
def __init__(self, sock=None, sockMap=None):
asyncore.dispatcher.__init__(self)
if sock is None:
diff --git a/pysnmp/carrier/sockmsg.py b/pysnmp/carrier/sockmsg.py
index f95452af..c408a755 100644
--- a/pysnmp/carrier/sockmsg.py
+++ b/pysnmp/carrier/sockmsg.py
@@ -16,10 +16,13 @@
# http://carnivore.it/2012/10/12/python3.3_sendmsg_and_recvmsg
#
import sys
+
if sys.version_info[:2] < (3, 3):
+ # noinspection PyUnusedLocal
def getRecvFrom(addressType):
raise error.CarrierError('sendmsg()/recvmsg() interface is not supported by this OS and/or Python version')
+
def getSendTo(addressType):
raise error.CarrierError('sendmsg()/recvmsg() interface is not supported by this OS and/or Python version')
else:
@@ -31,9 +34,11 @@ else:
uint32_t = ctypes.c_uint32
in_addr_t = uint32_t
+
class in_addr(ctypes.Structure):
_fields_ = [('s_addr', in_addr_t)]
+
class in6_addr_U(ctypes.Union):
_fields_ = [
('__u6_addr8', ctypes.c_uint8 * 16),
@@ -41,11 +46,13 @@ else:
('__u6_addr32', ctypes.c_uint32 * 4),
]
+
class in6_addr(ctypes.Structure):
_fields_ = [
('__in6_u', in6_addr_U),
]
+
class in_pktinfo(ctypes.Structure):
_fields_ = [
('ipi_ifindex', ctypes.c_int),
@@ -53,12 +60,14 @@ else:
('ipi_addr', in_addr),
]
+
class in6_pktinfo(ctypes.Structure):
_fields_ = [
('ipi6_addr', in6_addr),
('ipi6_ifindex', ctypes.c_uint),
]
+
def getRecvFrom(addressType):
def recvfrom(s, sz):
_to = None
@@ -73,8 +82,10 @@ else:
addr = ipaddress.ip_address(memoryview(addr.ipi6_addr).tobytes())
_to = (str(addr), s.getsockname()[1])
return data, addressType(_from).setLocalAddress(_to)
+
return recvfrom
+
def getSendTo(addressType):
def sendto(s, _data, _to):
ancdata = []
@@ -91,4 +102,5 @@ else:
_f.ipi6_addr = in6_addr.from_buffer_copy(addr.packed)
ancdata = [(socket.SOL_IPV6, socket.IPV6_PKTINFO, memoryview(_f).tobytes())]
return s.sendmsg([_data], ancdata, 0, _to)
+
return sendto