summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2019-03-28 14:20:30 (GMT)
committerGitHub <noreply@github.com>2019-03-28 14:20:30 (GMT)
commit3eca28c61363a03b81b9fb12775490d6e42d8ecf (patch)
treec1f4488531517a141f47bb5bc688494bee69b61e /Modules
parent8abd7c7e37714ce0c42f871f81e52f14c155d1bd (diff)
downloadcpython-3eca28c61363a03b81b9fb12775490d6e42d8ecf.zip
cpython-3eca28c61363a03b81b9fb12775490d6e42d8ecf.tar.gz
cpython-3eca28c61363a03b81b9fb12775490d6e42d8ecf.tar.bz2
bpo-29515: add missing socket.IPPROTO_* constants on Windows (GH-12183)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index b48f8a9..c024542 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -309,6 +309,40 @@ http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.c.diff?r1=1.82&
# include <fcntl.h>
# endif
+/* Macros based on the IPPROTO enum, see: https://bugs.python.org/issue29515 */
+#ifdef MS_WINDOWS
+#define IPPROTO_ICMP IPPROTO_ICMP
+#define IPPROTO_IGMP IPPROTO_IGMP
+#define IPPROTO_GGP IPPROTO_GGP
+#define IPPROTO_TCP IPPROTO_TCP
+#define IPPROTO_PUP IPPROTO_PUP
+#define IPPROTO_UDP IPPROTO_UDP
+#define IPPROTO_IDP IPPROTO_IDP
+#define IPPROTO_ND IPPROTO_ND
+#define IPPROTO_RAW IPPROTO_RAW
+#define IPPROTO_MAX IPPROTO_MAX
+#define IPPROTO_HOPOPTS IPPROTO_HOPOPTS
+#define IPPROTO_IPV4 IPPROTO_IPV4
+#define IPPROTO_IPV6 IPPROTO_IPV6
+#define IPPROTO_ROUTING IPPROTO_ROUTING
+#define IPPROTO_FRAGMENT IPPROTO_FRAGMENT
+#define IPPROTO_ESP IPPROTO_ESP
+#define IPPROTO_AH IPPROTO_AH
+#define IPPROTO_ICMPV6 IPPROTO_ICMPV6
+#define IPPROTO_NONE IPPROTO_NONE
+#define IPPROTO_DSTOPTS IPPROTO_DSTOPTS
+#define IPPROTO_EGP IPPROTO_EGP
+#define IPPROTO_PIM IPPROTO_PIM
+#define IPPROTO_ICLFXBM IPPROTO_ICLFXBM // WinSock2 only
+#define IPPROTO_ST IPPROTO_ST // WinSock2 only
+#define IPPROTO_CBT IPPROTO_CBT // WinSock2 only
+#define IPPROTO_IGP IPPROTO_IGP // WinSock2 only
+#define IPPROTO_RDP IPPROTO_RDP // WinSock2 only
+#define IPPROTO_PGM IPPROTO_PGM // WinSock2 only
+#define IPPROTO_L2TP IPPROTO_L2TP // WinSock2 only
+#define IPPROTO_SCTP IPPROTO_SCTP // WinSock2 only
+#endif /* MS_WINDOWS */
+
/* Provides the IsWindows7SP1OrGreater() function */
#include <versionhelpers.h>
@@ -356,7 +390,7 @@ remove_unusable_flags(PyObject *m)
for (int i=0; i<sizeof(win_runtime_flags)/sizeof(FlagRuntimeInfo); i++) {
info.dwBuildNumber = win_runtime_flags[i].build_number;
- /* greater than or equal to the specified version?
+ /* greater than or equal to the specified version?
Compatibility Mode will not cheat VerifyVersionInfo(...) */
if (VerifyVersionInfo(
&info,
@@ -7659,6 +7693,17 @@ PyInit__socket(void)
PyModule_AddIntMacro(m, IPPROTO_MAX);
#endif
+#ifdef MS_WINDOWS
+ PyModule_AddIntMacro(m, IPPROTO_ICLFXBM);
+ PyModule_AddIntMacro(m, IPPROTO_ST);
+ PyModule_AddIntMacro(m, IPPROTO_CBT);
+ PyModule_AddIntMacro(m, IPPROTO_IGP);
+ PyModule_AddIntMacro(m, IPPROTO_RDP);
+ PyModule_AddIntMacro(m, IPPROTO_PGM);
+ PyModule_AddIntMacro(m, IPPROTO_L2TP);
+ PyModule_AddIntMacro(m, IPPROTO_SCTP);
+#endif
+
#ifdef SYSPROTO_CONTROL
PyModule_AddIntMacro(m, SYSPROTO_CONTROL);
#endif