8000 gh-95389: socketmodule: expose popular `ETHERTYPE_*` constants by noamcohen97 · Pull Request #95390 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-95389: socketmodule: expose popular ETHERTYPE_* constants #95390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,19 @@ Constants
.. availability:: Linux >= 2.2.


.. data:: ETH_P_8021AD
ETH_P_8021Q
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.

.. versionadded:: 3.12


.. data:: AF_RDS
PF_RDS
SOL_RDS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
expose popular ``ETH_P_*`` constants in :mod:`socket`. Patch by Noam Cohen.
20 changes: 20 additions & 0 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -7711,6 +7711,26 @@ PyInit__socket(void)
PyModule_AddIntMacro(m, ALG_OP_VERIFY);
#endif

/* Ethernet Protocol ID's */
#ifdef ETH_P_8021AD
PyModule_AddIntMacro(m, ETH_P_8021AD);
#endif
#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

/* Socket types */
PyModule_AddIntMacro(m, SOCK_STREAM);
PyModule_AddIntMacro(m, SOCK_DGRAM);
Expand Down
0