From a72f5cfdd6c19a94737ddd38a0d782cda5eb9a5c Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Thu, 28 Jul 2022 19:03:20 +0300 Subject: [PATCH 01/17] gh-95389: socketmodule: expose popular `ETH_P_*` constants --- Modules/socketmodule.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 869bacde924d83..9ff6741972e165 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7719,6 +7719,24 @@ PyInit__socket(void) /* SOCK_RAW is marked as optional in the POSIX specification */ PyModule_AddIntMacro(m, SOCK_RAW); #endif +#ifdef ETH_P_IP + PyModule_AddIntMacro(m, ETH_P_IP); +#endif +#ifdef ETH_P_ARP + PyModule_AddIntMacro(m, ETH_P_ARP); +#endif +#ifdef ETH_P_IPV6 + PyModule_AddIntMacro(m, ETH_P_IPV6); +#endif +#ifdef ETH_P_8021Q + PyModule_AddIntMacro(m, ETH_P_8021Q); +#endif +#ifdef ETH_P_8021AD + PyModule_AddIntMacro(m, ETH_P_8021AD); +#endif +#ifdef ETH_P_ALL + PyModule_AddIntMacro(m, ETH_P_ALL); +#endif #ifdef SOCK_SEQPACKET PyModule_AddIntMacro(m, SOCK_SEQPACKET); #endif From 764884c5a1cfc26e6425c06ee7e506b3fc481a21 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Sat, 30 Jul 2022 17:07:00 +0300 Subject: [PATCH 02/17] added doc --- Doc/library/socket.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 84b6d797ddc013..bf1a348c1ddced 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -501,6 +501,19 @@ Constants .. availability:: Linux >= 2.2. +.. data:: ETH_P_IP + ETH_P_ARP + ETH_P_IPV6 + ETH_P_8021Q + ETH_P_8021AD + ETH_P_ALL + + Many constants of these forms, documented in the Linux documentation, are + also defined in the socket module. + + .. versionadded:: 3.12 + + .. data:: AF_RDS PF_RDS SOL_RDS From 36844c7e28656c733747ef74b24070d933a57932 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 30 Jul 2022 14:10:28 +0000 Subject: [PATCH 03/17] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst b/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst new file mode 100644 index 00000000000000..59545b1cdefcaa --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst @@ -0,0 +1 @@ +expose popular ``ETH_P_*`` constants in :mod:`socket`. Patch by Noam Cohen. From 6702add7b3b2ed30414f1ad68f852511ea95ed47 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Sat, 30 Jul 2022 17:24:45 +0300 Subject: [PATCH 04/17] sort constants alphabetically in doc --- Doc/library/socket.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index bf1a348c1ddced..0835f31bcb0995 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -501,12 +501,12 @@ Constants .. availability:: Linux >= 2.2. -.. data:: ETH_P_IP - ETH_P_ARP - ETH_P_IPV6 +.. data:: ETH_P_8021AD ETH_P_8021Q - ETH_P_8021AD ETH_P_ALL + ETH_P_ARP + ETH_P_IP + ETH_P_IPV6 Many constants of these forms, documented in the Linux documentation, are also defined in the socket module. From 7da1979443e65e1087173ff00963cbabddb9d314 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Sat, 30 Jul 2022 19:01:40 +0300 Subject: [PATCH 05/17] move definition --- Modules/socketmodule.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 9ff6741972e165..4b5e1a8b94347e 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7711,31 +7711,33 @@ PyInit__socket(void) PyModule_AddIntMacro(m, ALG_OP_VERIFY); #endif - /* Socket types */ - PyModule_AddIntMacro(m, SOCK_STREAM); - PyModule_AddIntMacro(m, SOCK_DGRAM); -/* We have incomplete socket support. */ -#ifdef SOCK_RAW - /* SOCK_RAW is marked as optional in the POSIX specification */ - PyModule_AddIntMacro(m, SOCK_RAW); +/* Ethernet Protocol ID's */ +#ifdef ETH_P_8021AD + PyModule_AddIntMacro(m, ETH_P_8021AD); #endif -#ifdef ETH_P_IP - PyModule_AddIntMacro(m, ETH_P_IP); +#ifdef ETH_P_8021Q + PyModule_AddIntMacro(m, ETH_P_8021Q); +#endif +#ifdef ETH_P_ALL + PyModule_AddIntMacro(m, ETH_P_ALL); #endif #ifdef ETH_P_ARP PyModule_AddIntMacro(m, ETH_P_ARP); #endif +#ifdef ETH_P_IP + PyModule_AddIntMacro(m, ETH_P_IP); +#endif #ifdef ETH_P_IPV6 PyModule_AddIntMacro(m, ETH_P_IPV6); #endif -#ifdef ETH_P_8021Q - PyModule_AddIntMacro(m, ETH_P_8021Q); -#endif -#ifdef ETH_P_8021AD - PyModule_AddIntMacro(m, ETH_P_8021AD); -#endif -#ifdef ETH_P_ALL - PyModule_AddIntMacro(m, ETH_P_ALL); + + /* Socket types */ + PyModule_AddIntMacro(m, SOCK_STREAM); + PyModule_AddIntMacro(m, SOCK_DGRAM); +/* We have incomplete socket support. */ +#ifdef SOCK_RAW + /* SOCK_RAW is marked as optional in the POSIX specification */ + PyModule_AddIntMacro(m, SOCK_RAW); #endif #ifdef SOCK_SEQPACKET PyModule_AddIntMacro(m, SOCK_SEQPACKET); From 18b0286af69ffc4a339bdb0005687440c1695774 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Sat, 30 Jul 2022 19:05:06 +0300 Subject: [PATCH 06/17] Update Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst Co-authored-by: Erlend Egeberg Aasland --- .../2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst b/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst index 59545b1cdefcaa..7b58d09ac04a64 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst @@ -1 +1 @@ -expose popular ``ETH_P_*`` constants in :mod:`socket`. Patch by Noam Cohen. +Expose popular ``ETH_P_*`` constants in :mod:`socket`. Patch by Noam Cohen. From cbc83037db8d606dbf5dc762708492569595b0f8 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Mon, 1 Aug 2022 14:56:44 +0300 Subject: [PATCH 07/17] better documentation --- Doc/library/socket.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 0835f31bcb0995..cadd773272c002 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -508,8 +508,11 @@ Constants ETH_P_IP ETH_P_IPV6 - Many constants of these forms, documented in the Linux documentation, are - also defined in the socket module. + IEEE 802.3 protocol numbers, can be used in :class:`~socket.socket` + constructor as *proto* if *type* is :const:`SOCK_RAW`. + For more information you can consult :manpage:`packet(7)`. + + .. availability:: Linux .. versionadded:: 3.12 From 2eec6345c594db1c928b34e471080364a6fe3072 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Mon, 1 Aug 2022 15:08:24 +0300 Subject: [PATCH 08/17] added missing include --- Modules/socketmodule.c | 10 +++++++++- configure | 2 +- configure.ac | 2 +- pyconfig.h.in | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 4b5e1a8b94347e..44dbd9e9b5f50c 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -247,6 +247,10 @@ shutdown(how) -- shut down traffic in one or both directions\n\ #include #endif +#ifdef HAVE_NET_ETHERNET_H +#include +#endif + /* Generic socket object definitions and includes */ #define PySocket_BUILDING_SOCKET #include "socketmodule.h" @@ -7711,7 +7715,11 @@ PyInit__socket(void) PyModule_AddIntMacro(m, ALG_OP_VERIFY); #endif -/* Ethernet Protocol ID's */ +/* + * Ethernet Protocol ID's + * There are many ID's - only most popular ones in a standard network + * are used. + */ #ifdef ETH_P_8021AD PyModule_AddIntMacro(m, ETH_P_8021AD); #endif diff --git a/configure b/configure index 5df9f83290da06..d939bce9a9b7d8 100755 --- a/configure +++ b/configure @@ -9058,7 +9058,7 @@ for ac_header in \ alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \ ieeefp.h io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/fs.h linux/memfd.h \ linux/random.h linux/soundcard.h \ - linux/tipc.h linux/wait.h netdb.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \ + linux/tipc.h linux/wait.h netdb.h net/ethernet.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \ sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \ sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \ sys/loadavg.h sys/lock.h sys/memfd.h sys/mkdev.h sys/mman.h sys/modem.h sys/param.h sys/poll.h \ diff --git a/configure.ac b/configure.ac index 38880fcc8cc15b..aa42911f738ab9 100644 --- a/configure.ac +++ b/configure.ac @@ -2643,7 +2643,7 @@ AC_CHECK_HEADERS([ \ alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \ ieeefp.h io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/fs.h linux/memfd.h \ linux/random.h linux/soundcard.h \ - linux/tipc.h linux/wait.h netdb.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \ + linux/tipc.h linux/wait.h netdb.h net/ethernet.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \ sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \ sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \ sys/loadavg.h sys/lock.h sys/memfd.h sys/mkdev.h sys/mman.h sys/modem.h sys/param.h sys/poll.h \ diff --git a/pyconfig.h.in b/pyconfig.h.in index 10e7ad12fa982c..3dbfcf98bc2d81 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -844,6 +844,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NETPACKET_PACKET_H +/* Define to 1 if you have the header file. */ +#undef HAVE_NET_ETHERNET_H + /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_H From 7081b272774bbd0607ae7dc1781b70e3c9c04a50 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Mon, 1 Aug 2022 15:17:48 +0300 Subject: [PATCH 09/17] comment explaining consts choice --- Modules/socketmodule.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 44dbd9e9b5f50c..5aa2d634690d79 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7717,8 +7717,8 @@ PyInit__socket(void) /* * Ethernet Protocol ID's - * There are many ID's - only most popular ones in a standard network - * are used. + * There are many ID's - only the ones required for a standard + * TCP/IP network stack are exposed. */ #ifdef ETH_P_8021AD PyModule_AddIntMacro(m, ETH_P_8021AD); From 886f908df18f9e0822136a2b18d57fba592b6853 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Mon, 1 Aug 2022 17:53:05 +0300 Subject: [PATCH 10/17] support macOS and FreeBSD --- Doc/library/socket.rst | 32 +++++++++++++++++++++----------- Modules/socketmodule.c | 31 +++++++++++++------------------ 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index cadd773272c002..d40f34f86116e2 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -183,7 +183,7 @@ created. Socket addresses are represented as follows: - *ifname* - String specifying the device name. - *proto* - An in network-byte-order integer specifying the Ethernet - protocol number. + protocol number. May be one of :ref:`ETHERTYPE_* constants ` or any other Ethernet protocol number. - *pkttype* - Optional integer specifying the packet type: - ``PACKET_HOST`` (the default) - Packet addressed to the local host. @@ -501,18 +501,16 @@ Constants .. availability:: Linux >= 2.2. -.. data:: ETH_P_8021AD - ETH_P_8021Q - ETH_P_ALL - ETH_P_ARP - ETH_P_IP - ETH_P_IPV6 +.. data:: ETH_P_ALL - IEEE 802.3 protocol numbers, can be used in :class:`~socket.socket` - constructor as *proto* if *type* is :const:`SOCK_RAW`. - For more information you can consult :manpage:`packet(7)`. + ``ETH_P_ALL`` can be used in :class:`~socket.socket` + constructor as *proto* for the :const:`AF_PACKET` family in order to + capture every packet. - .. availability:: Linux + For more information you can consult the Linux documentation + :manpage:`packet(7)`. + + .. availability:: Linux. .. versionadded:: 3.12 @@ -647,6 +645,18 @@ Constants .. versionadded:: 3.12 +.. _socket-ethernet-types: + +.. data:: ETHERTYPE_ARP + ETHERTYPE_IP + ETHERTYPE_IPV6 + ETHERTYPE_VLAN + + IEEE 802.3 protocol numbers. + + .. versionadded:: 3.12 + + Functions ^^^^^^^^^ diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 5aa2d634690d79..e99dfc643f94fc 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7715,28 +7715,23 @@ PyInit__socket(void) PyModule_AddIntMacro(m, ALG_OP_VERIFY); #endif -/* - * Ethernet Protocol ID's - * There are many ID's - only the ones required for a standard - * TCP/IP network stack are exposed. - */ -#ifdef ETH_P_8021AD - PyModule_AddIntMacro(m, ETH_P_8021AD); -#endif -#ifdef ETH_P_8021Q - PyModule_AddIntMacro(m, ETH_P_8021Q); +/* IEEE 802.3 protocol numbers required for a standard TCP/IP network stack */ +#ifdef ETHERTYPE_ARP + PyModule_AddIntMacro(m, ETHERTYPE_ARP); #endif -#ifdef ETH_P_ALL - PyModule_AddIntMacro(m, ETH_P_ALL); +#ifdef ETHERTYPE_IP + PyModule_AddIntMacro(m, ETHERTYPE_IP); #endif -#ifdef ETH_P_ARP - PyModule_AddIntMacro(m, ETH_P_ARP); +#ifdef ETHERTYPE_IPV6 + PyModule_AddIntMacro(m, ETHERTYPE_IPV6); #endif -#ifdef ETH_P_IP - PyModule_AddIntMacro(m, ETH_P_IP); +#ifdef ETHERTYPE_VLAN + PyModule_AddIntMacro(m, ETHERTYPE_VLAN); #endif -#ifdef ETH_P_IPV6 - PyModule_AddIntMacro(m, ETH_P_IPV6); + +/* Linux pseudo-protocol for sniffing every packet */ +#ifdef ETH_P_ALL + PyModule_AddIntMacro(m, ETH_P_ALL); #endif /* Socket types */ From 2a0accbf1c6798ff2df681e6623ee4ce59da72dc Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Mon, 1 Aug 2022 17:56:35 +0300 Subject: [PATCH 11/17] fix news entry --- .../2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst b/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst index 7b58d09ac04a64..000910c9e1c767 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst @@ -1 +1 @@ -Expose popular ``ETH_P_*`` constants in :mod:`socket`. Patch by Noam Cohen. +Expose some of ``ETHERTYPE_*`` and ``ETH_P_ALL`` constants in :mod:`socket`. Patch by Noam Cohen. From 8be938b0a75a77252171488fc75878cbb20e0470 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Mon, 1 Aug 2022 18:01:31 +0300 Subject: [PATCH 12/17] make doc clearer --- Doc/library/socket.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index d40f34f86116e2..25d591ef0bb6dd 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -182,8 +182,10 @@ created. Socket addresses are represented as follows: ``(ifname, proto[, pkttype[, hatype[, addr]]])`` where: - *ifname* - String specifying the device name. - - *proto* - An in network-byte-order integer specifying the Ethernet - protocol number. May be one of :ref:`ETHERTYPE_* constants ` or any other Ethernet protocol number. + - *proto* - The Ethernet protocol number. May be one of + :ref:`ETHERTYPE_* constants ` + or any other Ethernet protocol number. + In both cases, values must be in network-byte-order. - *pkttype* - Optional integer specifying the packet type: - ``PACKET_HOST`` (the default) - Packet addressed to the local host. From 7fd3467afe8e1acdf040a3ed90e9056915f3591e Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Mon, 1 Aug 2022 23:20:26 +0300 Subject: [PATCH 13/17] Update Doc/library/socket.rst Co-authored-by: CAM Gerlach --- Doc/library/socket.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 25d591ef0bb6dd..7fb94189f79f48 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -505,9 +505,9 @@ Constants .. data:: ETH_P_ALL - ``ETH_P_ALL`` can be used in :class:`~socket.socket` + :data:`!ETH_P_ALL` can be used in the :class:`~socket.socket` constructor as *proto* for the :const:`AF_PACKET` family in order to - capture every packet. + capture every packet, regardless of protocol. For more information you can consult the Linux documentation :manpage:`packet(7)`. From 257e46b1f99078508450d512c3ca3e7e7a159ce7 Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Mon, 1 Aug 2022 23:23:37 +0300 Subject: [PATCH 14/17] Apply suggestions from code review Co-authored-by: CAM Gerlach --- Doc/library/socket.rst | 10 +++++----- .../2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 7fb94189f79f48..3b18aa4a14c20d 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -182,10 +182,11 @@ created. Socket addresses are represented as follows: ``(ifname, proto[, pkttype[, hatype[, addr]]])`` where: - *ifname* - String specifying the device name. - - *proto* - The Ethernet protocol number. May be one of - :ref:`ETHERTYPE_* constants ` + - *proto* - The Ethernet protocol number. + May be :data:`ETH_P_ALL` to capture all protocols, + one of the :ref:`ETHERTYPE_* constants ` or any other Ethernet protocol number. - In both cases, values must be in network-byte-order. + Value must be in network-byte-order. - *pkttype* - Optional integer specifying the packet type: - ``PACKET_HOST`` (the default) - Packet addressed to the local host. @@ -509,8 +510,7 @@ Constants constructor as *proto* for the :const:`AF_PACKET` family in order to capture every packet, regardless of protocol. - For more information you can consult the Linux documentation - :manpage:`packet(7)`. + For more information, see the :manpage:`packet(7)` manpage. .. availability:: Linux. diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst b/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst index 000910c9e1c767..d31f00de6087cb 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2022-07-30-14-10-27.gh-issue-95389.nSGEkG.rst @@ -1 +1,3 @@ -Expose some of ``ETHERTYPE_*`` and ``ETH_P_ALL`` constants in :mod:`socket`. Patch by Noam Cohen. +Expose :data:`~socket.ETH_P_ALL` and some of the +:ref:`ETHERTYPE_* constants ` in :mod:`socket`. +Patch by Noam Cohen. From 36b1d6ab389db1cd480fca3cfb483f063d38d09e Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Mon, 1 Aug 2022 23:40:21 +0300 Subject: [PATCH 15/17] added footnote --- Doc/library/socket.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 3b18aa4a14c20d..4cd0ccdc2dbc5e 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -654,7 +654,7 @@ Constants ETHERTYPE_IPV6 ETHERTYPE_VLAN - IEEE 802.3 protocol numbers. + IEEE 802.3 protocol numbers [1]_. .. versionadded:: 3.12 @@ -2196,3 +2196,9 @@ the :data:`SO_REUSEADDR` flag tells the kernel to reuse a local socket in details of socket semantics. For Unix, refer to the manual pages; for Windows, see the WinSock (or Winsock 2) specification. For IPv6-ready APIs, readers may want to refer to :rfc:`3493` titled Basic Socket Interface Extensions for IPv6. + + +.. rubric:: Footnotes + +.. [1] See + https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.txt From 43b5d4596ab729cf81aed3ad4cca75928400457e Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Tue, 2 Aug 2022 07:07:24 +0300 Subject: [PATCH 16/17] Apply suggestions from code review Co-authored-by: CAM Gerlach --- Doc/library/socket.rst | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 4cd0ccdc2dbc5e..c6b8960099bfe0 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -654,7 +654,11 @@ Constants ETHERTYPE_IPV6 ETHERTYPE_VLAN - IEEE 802.3 protocol numbers [1]_. + `IEEE 802.3 protocol number + `_. + constants. + +.. availability:: Linux, FreeBSD, macOS. .. versionadded:: 3.12 @@ -2196,9 +2200,3 @@ the :data:`SO_REUSEADDR` flag tells the kernel to reuse a local socket in details of socket semantics. For Unix, refer to the manual pages; for Windows, see the WinSock (or Winsock 2) specification. For IPv6-ready APIs, readers may want to refer to :rfc:`3493` titled Basic Socket Interface Extensions for IPv6. - - -.. rubric:: Footnotes - -.. [1] See - https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.txt From fc9bc01fcb45e7165a271e15cb2eabb979ee85be Mon Sep 17 00:00:00 2001 From: Noam Cohen Date: Tue, 2 Aug 2022 07:11:53 +0300 Subject: [PATCH 17/17] doc fix --- Doc/library/socket.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index c6b8960099bfe0..73e5838aa2f0ac 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -658,7 +658,7 @@ Constants `_. constants. -.. availability:: Linux, FreeBSD, macOS. + .. availability:: Linux, FreeBSD, macOS. .. versionadded:: 3.12