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

@ -247,6 +247,10 @@ shutdown(how) -- shut down traffic in one or both directions\n\
#include <net/if.h>
#endif
#ifdef HAVE_NET_ETHERNET_H
#include <net/ethernet.h>
#endif
/* Generic socket object definitions and includes */
#define PySocket_BUILDING_SOCKET
#include "socketmodule.h"
@ -7711,6 +7715,25 @@ PyInit__socket(void)
PyModule_AddIntMacro(m, ALG_OP_VERIFY);
#endif
/* IEEE 802.3 protocol numbers required for a standard TCP/IP network stack */
#ifdef ETHERTYPE_ARP
PyModule_AddIntMacro(m, ETHERTYPE_ARP);
#endif
#ifdef ETHERTYPE_IP
PyModule_AddIntMacro(m, ETHERTYPE_IP);
#endif
#ifdef ETHERTYPE_IPV6
PyModule_AddIntMacro(m, ETHERTYPE_IPV6);
#endif
#ifdef ETHERTYPE_VLAN
PyModule_AddIntMacro(m, ETHERTYPE_VLAN);
#endif
/* Linux pseudo-protocol for sniffing every packet */
#ifdef ETH_P_ALL
PyModule_AddIntMacro(m, ETH_P_ALL);
#endif
/* Socket types */
PyModule_AddIntMacro(m, SOCK_STREAM);
PyModule_AddIntMacro(m, SOCK_DGRAM);