diff options
Diffstat (limited to 'pysnmp/carrier')
-rw-r--r-- | pysnmp/carrier/asyncore/dgram/base.py | 2 | ||||
-rw-r--r-- | pysnmp/carrier/sockfix.py | 14 |
2 files changed, 12 insertions, 4 deletions
diff --git a/pysnmp/carrier/asyncore/dgram/base.py b/pysnmp/carrier/asyncore/dgram/base.py index 378974e6..4dcc77a3 100644 --- a/pysnmp/carrier/asyncore/dgram/base.py +++ b/pysnmp/carrier/asyncore/dgram/base.py @@ -78,7 +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) + self.socket.setsockopt(socket.SOL_IPV6, socket.IPV6_V6ONLY, int(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/sockfix.py b/pysnmp/carrier/sockfix.py index d4ea504e..02480bb2 100644 --- a/pysnmp/carrier/sockfix.py +++ b/pysnmp/carrier/sockfix.py @@ -6,7 +6,10 @@ # import socket -symbols = { +from pysnmp import debug + + +SYMBOLS = { 'IP_PKTINFO': 8, 'IP_TRANSPARENT': 19, 'SOL_IPV6': 41, @@ -14,6 +17,11 @@ symbols = { 'IPV6_PKTINFO': 50 } -for symbol in symbols: +for symbol, value in SYMBOLS.items(): if not hasattr(socket, symbol): - setattr(socket, symbol, symbols[symbol]) + setattr(socket, symbol, value) + + debug.logger & debug.flagIO and debug.logger( + 'WARNING: the socket module on this platform misses option %s. ' + 'Assuming its value is %d.' % (symbol, value) + ) |