diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-01-10 23:12:06 +0100 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-02-07 09:39:07 +0100 |
commit | 7e3c6b20ff3f976df63a8adefb0bab15ca25f253 (patch) | |
tree | 1f7ca43268424eaa2839fdb3a85db57b84cf24dc /pysnmp/carrier/asyncore | |
parent | 1dd94d8682fefd6df8c8a6998d1476c466706398 (diff) | |
download | pysnmp-git-7e3c6b20ff3f976df63a8adefb0bab15ca25f253.tar.gz |
Emit low-level sendmsg/recvmsg debugging
When running in transparent proxy mode, log syscall parameters
to aid troubleshooting
Diffstat (limited to 'pysnmp/carrier/asyncore')
-rw-r--r-- | pysnmp/carrier/asyncore/dgram/base.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pysnmp/carrier/asyncore/dgram/base.py b/pysnmp/carrier/asyncore/dgram/base.py index 37510a80..573e6f56 100644 --- a/pysnmp/carrier/asyncore/dgram/base.py +++ b/pysnmp/carrier/asyncore/dgram/base.py @@ -75,8 +75,10 @@ class DgramSocketTransport(AbstractSocketTransport): try: if self.socket.family in (socket.AF_INET, socket.AF_INET6): self.socket.setsockopt(socket.SOL_IP, socket.IP_PKTINFO, flag) + if self.socket.family == socket.AF_INET6: self.socket.setsockopt(socket.SOL_IPV6, socket.IPV6_RECVPKTINFO, flag) + except socket.error: raise error.CarrierError('setsockopt() for %s failed: %s' % (self.socket.family == socket.AF_INET6 and "IPV6_RECVPKTINFO" or "IP_PKTINFO", sys.exc_info()[1])) @@ -96,8 +98,10 @@ class DgramSocketTransport(AbstractSocketTransport): self.socket.setsockopt( socket.SOL_IPV6, socket.IP_TRANSPARENT, flag ) + except socket.error: raise error.CarrierError('setsockopt() for IP_TRANSPARENT failed: %s' % sys.exc_info()[1]) + except OSError: raise error.CarrierError('IP_TRANSPARENT socket option requires superuser priveleges') @@ -113,14 +117,17 @@ class DgramSocketTransport(AbstractSocketTransport): def normalizeAddress(self, transportAddress): if not isinstance(transportAddress, self.addressType): transportAddress = self.addressType(transportAddress) + if not transportAddress.getLocalAddress(): transportAddress.setLocalAddress(self.getLocalAddress()) + return transportAddress def getLocalAddress(self): # one evil OS does not seem to support getsockname() for DGRAM sockets try: return self.socket.getsockname() + except Exception: return '0.0.0.0', 0 |