From 588d7539f473e2b1ae2114b3ad49132f1207ebb7 Mon Sep 17 00:00:00 2001 From: Daiyuu Nobori Date: Mon, 27 Jul 2020 05:30:57 +0200 Subject: [PATCH] vpntest.c: add "setupapi" command to test SetupAPI (Windows only) Co-authored-by: Davide Beatrici --- src/vpntest/vpntest.c | 46 +++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/vpntest/vpntest.c b/src/vpntest/vpntest.c index bfc52350..8dd3061e 100644 --- a/src/vpntest/vpntest.c +++ b/src/vpntest/vpntest.c @@ -14,24 +14,6 @@ #include #include "vpntest.h" -void server_manager_test(UINT num, char **arg) -{ -#ifdef OS_WIN32 - SMExec(); -#else // OS_WIN32 - Print("This command is supported only on Win32."); -#endif // OS_WIN32 -} - -void client_manager_test(UINT num, char **arg) -{ -#ifdef OS_WIN32 - CMExec(); -#else // OS_WIN32 - Print("This command is supported only on Win32."); -#endif // OS_WIN32 -} - void client_test(UINT num, char **arg) { Print("VPN Client Test. Press Enter key to stop the VPN Client .\n"); @@ -70,6 +52,26 @@ void bridge_test(UINT num, char **arg) StFree(); } +#ifdef OS_WIN32 +void server_manager_test(UINT num, char **arg) +{ + SMExec(); +} + +void client_manager_test(UINT num, char **arg) +{ + CMExec(); +} + +void setup_test(UINT num, char **arg) +{ + char name[MAX_SIZE]; + Print("SetupAPI test. Please enter the name of the NIC I should retrieve the status of.\n"); + GetLine(name, sizeof(name)); + Print("Status: %s\n", MsIsVLanEnabledWithoutLock(name) ? "enabled" : "disabled"); +} +#endif + void memory_leak_test(UINT num, char **arg) { char *a = Malloc(1); @@ -78,7 +80,6 @@ void memory_leak_test(UINT num, char **arg) Print("Just now I called Malloc(1) and never free! Ha ha ha !!\n"); } - // The list of test functions // Test function definition list typedef void (TEST_PROC)(UINT num, char **arg); @@ -95,8 +96,11 @@ TEST_LIST test_list[] = {"c", client_test, "VPN Client in Test Mode, enter key to graceful stop."}, {"s", server_test, "VPN Server in Test Mode, enter key to graceful stop."}, {"b", bridge_test, "VPN Bridge in Test Mode, enter key to graceful stop."}, - {"sm", server_manager_test, "VPN Server Manager UI in Test Mode (Win32 only)"}, - {"cm", client_manager_test, "VPN Client Manager UI in Test Mode (Win32 only)"}, +#ifdef OS_WIN32 + {"sm", server_manager_test, "VPN Server Manager UI in Test Mode."}, + {"cm", client_manager_test, "VPN Client Manager UI in Test Mode."}, + {"setupapi", setup_test, "SetupAPI test: tries to retrieve the specified NIC's status."}, +#endif {"memory_leak", memory_leak_test, "Memory leak test: Try to leak one byte by malloc()."}, };