Skip to content

Commit 9a45bfe

Browse files
author
Erlend Egeberg Aasland
authored
bpo-35569: Expose RFC 3542 IPv6 socket options on macOS (GH-19526)
1 parent d7184d3 commit 9a45bfe

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

Lib/test/test_socket.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,37 @@ def testWindowsSpecificConstants(self):
959959
socket.IPPROTO_L2TP
960960
socket.IPPROTO_SCTP
961961

962+
@unittest.skipUnless(sys.platform == 'darwin', 'macOS specific test')
963+
@unittest.skipUnless(socket_helper.IPV6_ENABLED, 'IPv6 required for this test')
964+
def test3542SocketOptions(self):
965+
# Ref. issue #35569 and https://tools.ietf.org/html/rfc3542
966+
opts = {
967+
'IPV6_CHECKSUM',
968+
'IPV6_DONTFRAG',
969+
'IPV6_DSTOPTS',
970+
'IPV6_HOPLIMIT',
971+
'IPV6_HOPOPTS',
972+
'IPV6_NEXTHOP',
973+
'IPV6_PATHMTU',
974+
'IPV6_PKTINFO',
975+
'IPV6_RECVDSTOPTS',
976+
'IPV6_RECVHOPLIMIT',
977+
'IPV6_RECVHOPOPTS',
978+
'IPV6_RECVPATHMTU',
979+
'IPV6_RECVPKTINFO',
980+
'IPV6_RECVRTHDR',
981+
'IPV6_RECVTCLASS',
982+
'IPV6_RTHDR',
983+
'IPV6_RTHDRDSTOPTS',
984+
'IPV6_RTHDR_TYPE_0',
985+
'IPV6_TCLASS',
986+
'IPV6_USE_MIN_MTU',
987+
}
988+
for opt in opts:
989+
self.assertTrue(
990+
hasattr(socket, opt), f"Missing RFC3542 socket option '{opt}'"
991+
)
992+
962993
def testHostnameRes(self):
963994
# Testing hostname resolution mechanisms
964995
hostname = socket.gethostname()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Expose RFC 3542 IPv6 socket options.

setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,8 +1116,12 @@ def detect_crypt(self):
11161116
def detect_socket(self):
11171117
# socket(2)
11181118
if not VXWORKS:
1119-
self.add(Extension('_socket', ['socketmodule.c'],
1120-
depends=['socketmodule.h']))
1119+
kwargs = {'depends': ['socketmodule.h']}
1120+
if MACOS:
1121+
# Issue #35569: Expose RFC 3542 socket options.
1122+
kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542']
1123+
1124+
self.add(Extension('_socket', ['socketmodule.c'], **kwargs))
11211125
elif self.compiler.find_library_file(self.lib_dirs, 'net'):
11221126
libs = ['net']
11231127
self.add(Extension('_socket', ['socketmodule.c'],

0 commit comments

Comments
 (0)