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>
This commit is contained in:
Noam Cohen 2022-11-07 16:27:37 +02:00 committed by GitHub
parent 6168e714be
commit 80c08d1cd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 4 deletions

View file

@ -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
^^^^^^^^^