Skip to content

Commit

Permalink
bpo-35569: Expose RFC 3542 IPv6 socket options on macOS (pythonGH-19526)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erlend Egeberg Aasland authored May 17, 2020
1 parent d7184d3 commit 9a45bfe
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
31 changes: 31 additions & 0 deletions Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,37 @@ def testWindowsSpecificConstants(self):
socket.IPPROTO_L2TP
socket.IPPROTO_SCTP

@unittest.skipUnless(sys.platform == 'darwin', 'macOS specific test')
@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'IPv6 required for this test')
def test3542SocketOptions(self):
# Ref. issue #35569 and https://tools.ietf.org/html/rfc3542
opts = {
'IPV6_CHECKSUM',
'IPV6_DONTFRAG',
'IPV6_DSTOPTS',
'IPV6_HOPLIMIT',
'IPV6_HOPOPTS',
'IPV6_NEXTHOP',
'IPV6_PATHMTU',
'IPV6_PKTINFO',
'IPV6_RECVDSTOPTS',
'IPV6_RECVHOPLIMIT',
'IPV6_RECVHOPOPTS',
'IPV6_RECVPATHMTU',
'IPV6_RECVPKTINFO',
'IPV6_RECVRTHDR',
'IPV6_RECVTCLASS',
'IPV6_RTHDR',
'IPV6_RTHDRDSTOPTS',
'IPV6_RTHDR_TYPE_0',
'IPV6_TCLASS',
'IPV6_USE_MIN_MTU',
}
for opt in opts:
self.assertTrue(
hasattr(socket, opt), f"Missing RFC3542 socket option '{opt}'"
)

def testHostnameRes(self):
# Testing hostname resolution mechanisms
hostname = socket.gethostname()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Expose RFC 3542 IPv6 socket options.
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,8 +1116,12 @@ def detect_crypt(self):
def detect_socket(self):
# socket(2)
if not VXWORKS:
self.add(Extension('_socket', ['socketmodule.c'],
depends=['socketmodule.h']))
kwargs = {'depends': ['socketmodule.h']}
if MACOS:
# Issue #35569: Expose RFC 3542 socket options.
kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542']

self.add(Extension('_socket', ['socketmodule.c'], **kwargs))
elif self.compiler.find_library_file(self.lib_dirs, 'net'):
libs = ['net']
self.add(Extension('_socket', ['socketmodule.c'],
Expand Down

0 comments on commit 9a45bfe

Please sign in to comment.