From 3bf584c580cd7876d0ea80f4c67ccfd68a7cf1d6 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Wed, 2 Aug 2023 18:53:13 +0100 Subject: [PATCH] Add tweaks to support windows XP --- src/win32/edge_utils_win32.c | 1 + src/win32/wintap.c | 16 ++++++++++++++++ tools/n2n-route.c | 15 +++++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/win32/edge_utils_win32.c b/src/win32/edge_utils_win32.c index fa76ab9..5c47efb 100644 --- a/src/win32/edge_utils_win32.c +++ b/src/win32/edge_utils_win32.c @@ -17,6 +17,7 @@ */ #include +#include #include "edge_utils_win32.h" diff --git a/src/win32/wintap.c b/src/win32/wintap.c index d1f77a2..1feb8c5 100644 --- a/src/win32/wintap.c +++ b/src/win32/wintap.c @@ -2,6 +2,9 @@ (C) 2007-22 - Luca Deri */ +#include +#include + #include "n2n.h" #include "n2n_win32.h" @@ -333,6 +336,15 @@ int open_wintap(struct tuntap_dev *device, /* ****************** */ +#ifdef _WIN64 + /* Setting the metric is not actually 64-bit specific. + * The assumption here is that anyone needing a metric set will also + * need a new enough OS that they will be on 64-bit. + * + * The alternative is that people trying to run old games are probably on + * Windows XP and are probably 32-bit. + */ + /* metric */ PMIB_IPINTERFACE_ROW Row; @@ -357,6 +369,7 @@ int open_wintap(struct tuntap_dev *device, free(Row); } +#endif /* _WIN64 */ /* ****************** */ @@ -452,6 +465,8 @@ int tuntap_open(struct tuntap_dev *device, void tuntap_close(struct tuntap_dev *tuntap) { +#ifdef _WIN64 + /* See comment in open_wintap for notes about this ifdef */ PMIB_IPINTERFACE_ROW Row; if(tuntap->metric) { /* only required if a value has been given (and thus stored) */ @@ -471,6 +486,7 @@ void tuntap_close(struct tuntap_dev *tuntap) { free(Row); } +#endif /* _WIN64 */ CloseHandle(tuntap->device_handle); } diff --git a/tools/n2n-route.c b/tools/n2n-route.c index fa63fa2..8ff14b5 100644 --- a/tools/n2n-route.c +++ b/tools/n2n-route.c @@ -51,7 +51,14 @@ #include // for send, socket, AF_INET, recv, connect #endif -#if defined (__linux__) || defined(_WIN32) /* currently, Linux and Windows only */ +#if defined (__linux__) || defined(_WIN64) /* currently, Linux and Windows only */ +/* Technically, this could be supported on some 32-bit windows. + * The assumption here is that a version of Windows new enough to + * support the features needed is probably running with 64-bit. + * + * The alternative is that people trying to run old games are probably on + * Windows XP and are probably 32-bit. + */ #define WITH_ADDRESS 1 @@ -1088,16 +1095,16 @@ end_route_tool: } -#else /* if defined(__linux__) || defined(_WIN32) -- currently, Linux and Windows only */ +#else /* if defined(__linux__) || defined(_WIN64) -- currently, Linux and Windows only */ int main (int argc, char* argv[]) { - traceEvent(TRACE_WARNING, "currently, only Linux and Windows are supported"); + traceEvent(TRACE_WARNING, "currently, only Linux and 64-bit Windows are supported"); traceEvent(TRACE_WARNING, "if you want to port to other OS, please find the source code having clearly marked the platform-dependant portions"); return 0; } -#endif /* if defined (__linux__) || defined(_WIN32) -- currently, Linux and Windows only */ +#endif /* if defined (__linux__) || defined(_WIN64) -- currently, Linux and Windows only */