windows: fix the 64 bit builds on the latest mingw
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 20 Mar 2019 09:06:12 +0000 (10:06 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 20 Mar 2019 09:08:39 +0000 (10:08 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
src/win32/ifnet.c
src/win32/net.c

index 6ecd5ad..ca82d53 100644 (file)
@@ -105,10 +105,17 @@ struct MibIpInterfaceRow {
   BOOLEAN DisableDefaultRoutes;
 };
 
+#ifdef __WIN64
+typedef LONG64(__stdcall * GETIPINTERFACEENTRY) (struct MibIpInterfaceRow * Row);
+
+typedef LONG64(__stdcall * GETADAPTERSADDRESSES) (ULONG Family, DWORD Flags, PVOID Reserved, PIP_ADAPTER_ADDRESSES pAdapterAddresses,
+                                                 PULONG pOutBufLen);
+#else
 typedef DWORD(__stdcall * GETIPINTERFACEENTRY) (struct MibIpInterfaceRow * Row);
 
 typedef DWORD(__stdcall * GETADAPTERSADDRESSES) (ULONG Family, DWORD Flags, PVOID Reserved, PIP_ADAPTER_ADDRESSES pAdapterAddresses,
                                                  PULONG pOutBufLen);
+#endif
 
 struct InterfaceInfo {
   unsigned int Index;
index 3f3bedb..020b61d 100644 (file)
@@ -214,7 +214,11 @@ static OVERLAPPED RouterOver;
 void net_os_set_global_ifoptions(void)
 {
   HMODULE Lib;
+#ifdef __WIN64
+  long long int __stdcall(*enable_router)(HANDLE *, OVERLAPPED *);
+#else
   unsigned int __stdcall(*enable_router)(HANDLE *, OVERLAPPED *);
+#endif
   HANDLE Hand;
 
   Lib = LoadLibrary(WIDE_STRING("iphlpapi.dll"));
@@ -222,7 +226,11 @@ void net_os_set_global_ifoptions(void)
   if (Lib == NULL)
     return;
 
+#ifdef __WIN64
+  enable_router = (long long int __stdcall(*)(HANDLE *, OVERLAPPED *))GetProcAddress(Lib, WIDE_STRING("EnableRouter"));
+#else
   enable_router = (unsigned int __stdcall(*)(HANDLE *, OVERLAPPED *))GetProcAddress(Lib, WIDE_STRING("EnableRouter"));
+#endif
 
   if (enable_router == NULL)
     return;
@@ -250,7 +258,11 @@ static int
 disable_ip_forwarding(int Ver)
 {
   HMODULE Lib;
+#ifdef __WIN64
+  long long int __stdcall(*unenable_router)(OVERLAPPED *, unsigned int *);
+#else
   unsigned int __stdcall(*unenable_router)(OVERLAPPED *, unsigned int *);
+#endif
   unsigned int Count;
 
   Ver = Ver;
@@ -260,7 +272,11 @@ disable_ip_forwarding(int Ver)
   if (Lib == NULL)
     return 0;
 
+#ifdef __WIN64
+  unenable_router = (long long int __stdcall(*)(OVERLAPPED *, unsigned int *))GetProcAddress(Lib, WIDE_STRING("UnenableRouter"));
+#else
   unenable_router = (unsigned int __stdcall(*)(OVERLAPPED *, unsigned int *))GetProcAddress(Lib, WIDE_STRING("UnenableRouter"));
+#endif
 
   if (unenable_router == NULL)
     return 0;