summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorNoam Cohen <noam@noam.me>2022-11-07 14:27:37 (GMT)
committerGitHub <noreply@github.com>2022-11-07 14:27:37 (GMT)
commit80c08d1cd67afdd1336c65ba23a044b6ac490f33 (patch)
treee7b0b57bc1dd5b2b29bf358696b9b75e0c24d5dd /Modules
parent6168e714be333b633dfa7e2d25549dea97a53431 (diff)
downloadcpython-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 'Modules')
-rw-r--r--Modules/socketmodule.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 869bacde..e99dfc6 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 <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);