diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-01-10 23:27:07 +0100 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-01-10 23:27:07 +0100 |
commit | 11eb3fa691c6889a2d66ee3417d562deb6b35ec4 (patch) | |
tree | e982d8742acad5a9b6f2804f60613a8c90cb8c55 | |
parent | bded1e349662eeb634383ad46ec3e1605b317ec7 (diff) | |
download | pysnmp-git-11eb3fa691c6889a2d66ee3417d562deb6b35ec4.tar.gz |
Add `IPV6_V6ONLY` IPV6 socket option
SO says this is required for proper UDP socket multi-homing.
-rw-r--r-- | pysnmp/carrier/asyncore/dgram/base.py | 1 | ||||
-rw-r--r-- | pysnmp/carrier/sockmsg.py | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/pysnmp/carrier/asyncore/dgram/base.py b/pysnmp/carrier/asyncore/dgram/base.py index 4edae19b..d38f3080 100644 --- a/pysnmp/carrier/asyncore/dgram/base.py +++ b/pysnmp/carrier/asyncore/dgram/base.py @@ -78,6 +78,7 @@ class DgramSocketTransport(AbstractSocketTransport): if self.socket.family == socket.AF_INET6: self.socket.setsockopt(socket.SOL_IPV6, socket.IPV6_RECVPKTINFO, flag) + self.socket.setsockopt(socket.SOL_IPV6, socket.IPV6_V6ONLY, not 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])) diff --git a/pysnmp/carrier/sockmsg.py b/pysnmp/carrier/sockmsg.py index 0b21233b..97273306 100644 --- a/pysnmp/carrier/sockmsg.py +++ b/pysnmp/carrier/sockmsg.py @@ -92,7 +92,7 @@ else: debug.logger & debug.flagIO and debug.logger( 'recvfrom: received %d octets from %s to %s; ' - 'iov blob %r' % (len(data), _from, _to, ancdata)) + 'iov blob %s' % (len(data), _from, _to, debug.hexdump(ancdata))) return data, addressType(_from).setLocalAddress(_to) @@ -120,7 +120,7 @@ else: ancdata = [(socket.SOL_IPV6, socket.IPV6_PKTINFO, memoryview(_f).tobytes())] debug.logger & debug.flagIO and debug.logger( - 'sendto: sending %d octets to %s; iov blob %r' % (len(data), _to, ancdata)) + 'sendto: sending %d octets to %s; iov blob %s' % (len(data), _to, debug.hexdump(ancdata))) return s.sendmsg([_data], ancdata, 0, _to) |