diff options
author | Noam Cohen <noam@noam.me> | 2022-11-07 14:27:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-07 14:27:37 (GMT) |
commit | 80c08d1cd67afdd1336c65ba23a044b6ac490f33 (patch) | |
tree | e7b0b57bc1dd5b2b29bf358696b9b75e0c24d5dd /Doc | |
parent | 6168e714be333b633dfa7e2d25549dea97a53431 (diff) | |
download | cpython-80c08d1cd67afdd1336c65ba23a044b6ac490f33.zip cpython-80c08d1cd67afdd1336c65ba23a044b6ac490f33.tar.gz cpython-80c08d1cd67afdd1336c65ba23a044b6ac490f33.tar.bz2 |
gh-95389: expose popular ETHERTYPE_* constants in the socket module (#95390)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/socket.rst | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 3f6cb48..c946407 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -189,8 +189,11 @@ 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. + - *proto* - The Ethernet protocol number. + May be :data:`ETH_P_ALL` to capture all protocols, + one of the :ref:`ETHERTYPE_* constants <socket-ethernet-types>` + or any other Ethernet protocol number. + Value must be in network-byte-order. - *pkttype* - Optional integer specifying the packet type: - ``PACKET_HOST`` (the default) - Packet addressed to the local host. @@ -508,6 +511,19 @@ Constants .. availability:: Linux >= 2.2. +.. data:: ETH_P_ALL + + :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, regardless of protocol. + + For more information, see the :manpage:`packet(7)` manpage. + + .. availability:: Linux. + + .. versionadded:: 3.12 + + .. data:: AF_RDS PF_RDS SOL_RDS @@ -638,6 +654,22 @@ Constants .. versionadded:: 3.12 +.. _socket-ethernet-types: + +.. data:: ETHERTYPE_ARP + ETHERTYPE_IP + ETHERTYPE_IPV6 + ETHERTYPE_VLAN + + `IEEE 802.3 protocol number + <https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.txt>`_. + constants. + + .. availability:: Linux, FreeBSD, macOS. + + .. versionadded:: 3.12 + + Functions ^^^^^^^^^ |