From: "stipa (Code Review)" Date: Fri, 31 Oct 2025 14:14:18 +0000 References: Reply-To: lstipakov@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="4nfLVmHhNoc="; charset=UTF-8 Subject: [Openvpn-devel] [L] Change in openvpn[master]: tapctl: overhaul adapter management helpers and improve CLI UX List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --4nfLVmHhNoc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1335?usp=3Demail to review the following change. Change subject: tapctl: overhaul adapter management helpers and improve CLI= UX ...................................................................... tapctl: overhaul adapter management helpers and improve CLI UX - default to creating ovpn-dco adapters, refresh help text, validate CLI input, and print both GUID and name after creation; - refactor create/list/delete into dedicated helpers, add bulk deletion via delete --hwid, and centralize GUID/name resolution; - harden auto-naming to recognise both ovpn-dco and tap0901 HWIDs, honour reserved names, and reuse friendly names when deleting by GUID. Change-Id: I4d822bf7ae5f037e2414778e8fa74eca5e289e65 Signed-off-by: Lev Stipakov --- M src/tapctl/main.c 1 file changed, 601 insertions(+), 243 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1335/1 diff --git a/src/tapctl/main.c b/src/tapctl/main.c index 031e262..f72d261 100644 --- a/src/tapctl/main.c +++ b/src/tapctl/main.c @@ -1,5 +1,5 @@ /* - * tapctl -- Utility to manipulate TUN/TAP adapters on Windows + * tapctl -- Utility to manipulate virtual network adapters on Windows * https://community.openvpn.net/openvpn/wiki/Tapctl * * Copyright (C) 2002-2025 OpenVPN Inc @@ -28,6 +28,7 @@ #include #include #include +#include #include #ifdef _MSC_VER @@ -50,8 +51,8 @@ L"\n" L"Commands:\n" L"\n" - L"create Create a new TUN/TAP adapter\n" - L"list List TUN/TAP adapters\n" + L"create Create a new network adapter\n" + L"list List network adapters\n" L"delete Delete specified network adapter\n" L"help Display this text\n" L"\n" @@ -61,7 +62,7 @@ static const WCHAR usage_message_create[] =3D L"%ls\n" L"\n" - L"Creates a new TUN/TAP adapter\n" + L"Creates a new network adapter\n" L"\n" L"Usage:\n" L"\n" @@ -69,24 +70,24 @@ L"\n" L"Options:\n" L"\n" - L"--name Set TUN/TAP adapter name. Should the adapter with giv= en name \n" + L"--name Set network adapter name. Should the adapter with giv= en name \n" L" already exist, an error is returned. If this option i= s not \n" L" specified, a default adapter name is chosen by Window= s. \n" L" Note: This name can also be specified as OpenVPN's --= dev-node \n" L" option. = \n" - L"--hwid Adapter hardware ID. Default value is root\\tap0901, = which \n" - L" describes tap-windows6 driver. To work with ovpn-dco = driver, \n" - L" driver, specify 'ovpn-dco'. = \n" + L"--hwid Adapter hardware ID. Default value is ovpn-dco, which= creates \n" + L" a Data Channel Offload adapter. To create a tap-windo= ws6 \n" + L" adapter, specify 'root\\tap0901'. = \n" L"\n" L"Output:\n" L"\n" - L"This command prints newly created TUN/TAP adapter's GUID to stdout. = \n" + L"This command prints newly created network adapter's GUID to stdout. = \n" ; static const WCHAR usage_message_list[] =3D L"%ls\n" L"\n" - L"Lists TUN/TAP adapters\n" + L"Lists network adapters\n" L"\n" L"Usage:\n" L"\n" @@ -94,22 +95,28 @@ L"\n" L"Options:\n" L"\n" - L"--hwid Adapter hardware ID. By default, root\\tap0901, tap09= 01 and \n" - L" ovpn-dco adapters are listed. Use this switch to limi= t the list.\n" + L"--hwid Adapter hardware ID. By default, ovpn-dco, root\\tap0= 901 and \n" + L" tap0901 adapters are listed. Use this switch to limit= the list.\n" L"\n" L"Output:\n" L"\n" - L"This command prints all TUN/TAP adapters to stdout. = \n" + L"This command prints all network adapters to stdout. = \n" ; static const WCHAR usage_message_delete[] =3D L"%ls\n" L"\n" - L"Deletes the specified network adapter\n" + L"Deletes network adapters\n" L"\n" L"Usage:\n" L"\n" L"tapctl delete \n" + L"tapctl delete --hwid \n" + L"\n" + L"Options:\n" + L"\n" + L"--hwid Delete all adapters that use the specified hardware I= D. Cannot\n" + L" be combined with adapter GUID or name.\n" ; /* clang-format on */ @@ -123,84 +130,633 @@ fwprintf(stderr, usage_message, title_string); } +static int tapctl_cmd_create(int argc, LPCWSTR argv[], BOOL *pbRebootRequi= red); +static int tapctl_cmd_list(int argc, LPCWSTR argv[]); +static int tapctl_cmd_delete(int argc, LPCWSTR argv[], BOOL *pbRebootRequi= red); + /** - * Checks if adapter with given name doesn't already exist + * Locate an adapter node by its friendly name within the enumerated list. + * + * @param name Friendly name to search for. Comparison is case-in= sensitive. + * @param adapter_list Head of the adapter list returned by tap_list_adap= ters(). + * + * @return Pointer to the matching node, or NULL when not found. */ -static BOOL -is_adapter_name_available(LPCWSTR name, struct tap_adapter_node *adapter_l= ist, BOOL log) +static struct tap_adapter_node * +find_adapter_by_name(LPCWSTR name, struct tap_adapter_node *adapter_list) { for (struct tap_adapter_node *a =3D adapter_list; a; a =3D a->pNext) { - if (wcsicmp(name, a->szName) =3D=3D 0) + if (_wcsicmp(name, a->szName) =3D=3D 0) { - if (log) - { - LPOLESTR adapter_id =3D NULL; - StringFromIID((REFIID)&a->guid, &adapter_id); - fwprintf(stderr, - L"Adapter \"%ls\" already exists (GUID %" - L"ls).\n", - a->szName, adapter_id); - CoTaskMemFree(adapter_id); - } - - return FALSE; + return a; } } - return TRUE; + return NULL; } /** - * Returns unique adapter name based on hwid or NULL if name cannot be gen= erated. - * Caller is responsible for freeing it. + * Check whether the registry still reserves a given network-connection na= me. + * + * Windows keeps friendly names under + * HKLM\SYSTEM\CurrentControlSet\Control\Network\{NETCLASS}\{GUID}\Connect= ion\Name, + * even after an adapter is removed. netsh refuses to rename to any reserv= ed name. + * + * @param name Friendly name to test. + * + * @return TRUE if the name exists in the registry, FALSE otherwise. + */ +static BOOL +registry_name_exists(LPCWSTR name) +{ + static const WCHAR class_key[] =3D + L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4d36e972-e325-11ce= -bfc1-08002be10318}"; + + HKEY hClassKey =3D NULL; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, class_key, 0, KEY_READ, &hClassKe= y) !=3D ERROR_SUCCESS) + { + return FALSE; + } + + BOOL found =3D FALSE; + + for (DWORD index =3D 0;; ++index) + { + WCHAR adapter_id[64]; + DWORD adapter_id_len =3D _countof(adapter_id); + LONG result =3D RegEnumKeyEx(hClassKey, index, adapter_id, &adapte= r_id_len, NULL, NULL, NULL, + NULL); + if (result =3D=3D ERROR_NO_MORE_ITEMS) + { + break; + } + else if (result !=3D ERROR_SUCCESS) + { + continue; + } + + WCHAR connection_key[512]; + swprintf_s(connection_key, _countof(connection_key), L"%ls\\%ls\\C= onnection", class_key, + adapter_id); + + DWORD value_size =3D 0; + LONG query =3D RegGetValueW(HKEY_LOCAL_MACHINE, connection_key, L"= Name", + RRF_RT_REG_SZ | RRF_NOEXPAND, NULL, NULL= , &value_size); + if (query !=3D ERROR_SUCCESS || value_size < sizeof(WCHAR)) + { + continue; + } + + LPWSTR value =3D (LPWSTR)malloc(value_size); + if (!value) + { + continue; + } + + query =3D RegGetValueW(HKEY_LOCAL_MACHINE, connection_key, L"Name", + RRF_RT_REG_SZ | RRF_NOEXPAND, NULL, value, &v= alue_size); + if (query =3D=3D ERROR_SUCCESS && _wcsicmp(name, value) =3D=3D 0) + { + found =3D TRUE; + free(value); + break; + } + + free(value); + + if (found) + { + break; + } + } + + RegCloseKey(hClassKey); + return found; +} + +/** + * Determine whether a friendly name is currently in use by an adapter or = reserved + * in the registry. + * + * @param name Friendly name to test. + * @param adapter_list Head of the adapter list returned by tap_list_adap= ters(). + * + * @return TRUE when the name is taken/reserved, FALSE when available. + */ +static BOOL +tap_name_in_use(LPCWSTR name, struct tap_adapter_node *adapter_list) +{ + if (name =3D=3D NULL) + { + return FALSE; + } + + if (find_adapter_by_name(name, adapter_list)) + { + return TRUE; + } + + return registry_name_exists(name); +} + +/** + * Resolve the adapter name we should apply: + * - For user-specified names, ensure they are unique both in the adapte= r list and + * in the registry. On conflict, an explanatory message is printed and= NULL is returned. + * - For automatic naming, derive the base string from HWID and append t= he first available + * suffix recognised by Windows. + * + * @param requested_name Name provided via CLI or configuration (may be N= ULL/empty). + * @param hwid Hardware identifier of the adapter being created. + * @param adapter_list Existing adapters enumerated via tap_list_adapte= rs(). + * + * @return Newly allocated wide string containing the final name, or NULL = on failure. */ static LPWSTR -get_unique_adapter_name(LPCWSTR hwid, struct tap_adapter_node *adapter_lis= t) +tap_resolve_adapter_name(LPCWSTR requested_name, LPCWSTR hwid, + struct tap_adapter_node *adapter_list) { + if (requested_name && requested_name[0]) + { + struct tap_adapter_node *conflict =3D find_adapter_by_name(request= ed_name, adapter_list); + if (conflict) + { + LPOLESTR adapter_id =3D NULL; + StringFromIID((REFIID)&conflict->guid, &adapter_id); + fwprintf(stderr, + L"Adapter \"%ls\" already exists (GUID %" + L"ls).\n", + conflict->szName, adapter_id); + CoTaskMemFree(adapter_id); + return NULL; + } + + if (registry_name_exists(requested_name)) + { + fwprintf(stderr, L"Adapter name \"%ls\" is already in use.\n",= requested_name); + return NULL; + } + + return wcsdup(requested_name); + } + if (hwid =3D=3D NULL) { return NULL; } - LPCWSTR base_name; - if (wcsicmp(hwid, L"ovpn-dco") =3D=3D 0) + LPCWSTR base_name =3D NULL; + if (_wcsicmp(hwid, L"ovpn-dco") =3D=3D 0) { base_name =3D L"OpenVPN Data Channel Offload"; } - else if (wcsicmp(hwid, L"root\\" _L(TAP_WIN_COMPONENT_ID)) =3D=3D 0) + else if (_wcsicmp(hwid, L"root\\" _L(TAP_WIN_COMPONENT_ID)) =3D=3D 0 + || _wcsicmp(hwid, _L(TAP_WIN_COMPONENT_ID)) =3D=3D 0) { base_name =3D L"OpenVPN TAP-Windows6"; } else { + fwprintf(stderr, + L"Cannot auto-generate adapter name for hardware ID \"%ls= \".\n", hwid); return NULL; } - if (is_adapter_name_available(base_name, adapter_list, FALSE)) + if (!tap_name_in_use(base_name, adapter_list)) { return wcsdup(base_name); } size_t name_len =3D wcslen(base_name) + 10; - LPWSTR name =3D malloc(name_len * sizeof(WCHAR)); + LPWSTR name =3D (LPWSTR)malloc(name_len * sizeof(WCHAR)); if (name =3D=3D NULL) { return NULL; } - for (int i =3D 1; i < 100; ++i) + + /* Windows never assigns the "#1" suffix, so skip it to avoid netsh fa= ilures. */ + for (int i =3D 2; i < 100; ++i) { swprintf_s(name, name_len, L"%ls #%d", base_name, i); - if (is_adapter_name_available(name, adapter_list, FALSE)) + if (!tap_name_in_use(name, adapter_list)) { return name; } } + free(name); + fwprintf(stderr, L"Unable to find available adapter name based on \"%l= s\".\n", base_name); return NULL; } +static int +tapctl_cmd_create(int argc, LPCWSTR argv[], BOOL *pbRebootRequired) +{ + LPCWSTR szName =3D NULL; + LPCWSTR defaultHwId =3D L"ovpn-dco"; + LPCWSTR szHwId =3D defaultHwId; + LPWSTR adapter_name =3D NULL; + struct tap_adapter_node *pAdapterList =3D NULL; + GUID guidAdapter; + LPOLESTR szAdapterId =3D NULL; + DWORD dwResult; + int iResult =3D 1; + BOOL adapter_created =3D FALSE; + + for (int i =3D 2; i < argc; i++) + { + if (wcsicmp(argv[i], L"--name") =3D=3D 0) + { + if (++i >=3D argc) + { + fwprintf(stderr, L"--name option requires a value. Ignored= .\n"); + break; + } + szName =3D argv[i]; + if (szName[0] =3D=3D L'\0') + { + fwprintf(stderr, L"--name option cannot be empty. Ignored.= \n"); + szName =3D NULL; + } + } + else if (wcsicmp(argv[i], L"--hwid") =3D=3D 0) + { + if (++i >=3D argc) + { + fwprintf(stderr, + L"--hwid option requires a value. Using default \= "%ls\".\n", + defaultHwId); + break; + } + szHwId =3D argv[i]; + if (szHwId[0] =3D=3D L'\0') + { + fwprintf(stderr, + L"--hwid option cannot be empty. Using default \"= %ls\".\n", + defaultHwId); + szHwId =3D defaultHwId; + } + } + else + { + fwprintf(stderr, + L"Unknown option \"%ls" + L"\". Please, use \"tapctl help create\" to list supp= orted options. Ignored.\n", + argv[i]); + } + } + + dwResult =3D tap_create_adapter(NULL, L"Virtual Ethernet", szHwId, pbR= ebootRequired, + &guidAdapter); + if (dwResult !=3D ERROR_SUCCESS) + { + fwprintf(stderr, L"Creating network adapter failed (error 0x%x).\n= ", dwResult); + goto cleanup; + } + adapter_created =3D TRUE; + + dwResult =3D tap_list_adapters(NULL, NULL, &pAdapterList); + if (dwResult !=3D ERROR_SUCCESS) + { + fwprintf(stderr, L"Enumerating adapters failed (error 0x%x).\n", d= wResult); + goto cleanup; + } + + adapter_name =3D tap_resolve_adapter_name(szName, szHwId, pAdapterList= ); + if (adapter_name =3D=3D NULL) + { + goto cleanup; + } + + dwResult =3D tap_set_adapter_name(&guidAdapter, adapter_name, FALSE); + if (dwResult !=3D ERROR_SUCCESS) + { + StringFromIID((REFIID)&guidAdapter, &szAdapterId); + fwprintf(stderr, + L"Renaming network adapter %ls to \"%ls\" failed (error 0= x%x).\n", szAdapterId, + adapter_name, dwResult); + CoTaskMemFree(szAdapterId); + goto cleanup; + } + + iResult =3D 0; + StringFromIID((REFIID)&guidAdapter, &szAdapterId); + fwprintf(stdout, L"%ls\t%ls\n", szAdapterId, + (adapter_name && adapter_name[0]) ? adapter_name : L"(unnamed= )"); + CoTaskMemFree(szAdapterId); + +cleanup: + if (pAdapterList) + { + tap_free_adapter_list(pAdapterList); + } + free(adapter_name); + + if (adapter_created && iResult !=3D 0) + { + tap_delete_adapter(NULL, &guidAdapter, pbRebootRequired); + } + + return iResult; +} + +static int +tapctl_cmd_list(int argc, LPCWSTR argv[]) +{ + WCHAR szzHwId[0x100] =3D L"ovpn-dco\0" + L"root\\" _L(TAP_WIN_COMPONENT_ID) L"\0" _L(TAP= _WIN_COMPONENT_ID) L"\0"; + struct tap_adapter_node *pAdapterList =3D NULL; + DWORD dwResult; + int iResult =3D 0; + + for (int i =3D 2; i < argc; i++) + { + if (wcsicmp(argv[i], L"--hwid") =3D=3D 0) + { + if (++i >=3D argc) + { + fwprintf(stderr, + L"--hwid option requires a value. Please, use \"t= apctl help list\" to " + L"list supported options.\n"); + return 1; + } + memset(szzHwId, 0, sizeof(szzHwId)); + memcpy_s(szzHwId, + sizeof(szzHwId) - 2 * sizeof(WCHAR) /*requires double= zero termination*/, + argv[i], wcslen(argv[i]) * sizeof(WCHAR)); + } + else + { + fwprintf(stderr, + L"Unknown option \"%ls" + L"\". Please, use \"tapctl help list\" to list suppor= ted options. Ignored.\n", + argv[i]); + } + } + + dwResult =3D tap_list_adapters(NULL, szzHwId, &pAdapterList); + if (dwResult !=3D ERROR_SUCCESS) + { + fwprintf(stderr, L"Enumerating network adapters failed (error 0x%x= ).\n", dwResult); + return 1; + } + + for (struct tap_adapter_node *pAdapter =3D pAdapterList; pAdapter; pAd= apter =3D pAdapter->pNext) + { + LPOLESTR szAdapterId =3D NULL; + StringFromIID((REFIID)&pAdapter->guid, &szAdapterId); + fwprintf(stdout, L"%ls\t%ls\n", szAdapterId, pAdapter->szName); + CoTaskMemFree(szAdapterId); + } + + tap_free_adapter_list(pAdapterList); + return iResult; +} + +/** + * Delete every adapter matching the provided hardware ID. + * + * @param hwid Hardware ID string (must be non-NULL and non-em= pty). + * @param pbRebootRequired Pointer to reboot flag propagated from caller. + * + * @return 0 when every adapter was deleted successfully, 1 otherwise. + */ +static int +tapctl_delete_by_hwid(LPCWSTR hwid, BOOL *pbRebootRequired) +{ + if (hwid =3D=3D NULL || hwid[0] =3D=3D L'\0') + { + fwprintf(stderr, L"--hwid option cannot be empty.\n"); + return 1; + } + + size_t hw_len =3D wcslen(hwid); + size_t buf_len =3D hw_len + 2; + LPWSTR szzHwId =3D (LPWSTR)calloc(buf_len, sizeof(WCHAR)); + if (szzHwId =3D=3D NULL) + { + fwprintf(stderr, L"Out of memory.\n"); + return 1; + } + wmemcpy(szzHwId, hwid, hw_len); + + struct tap_adapter_node *pAdapterList =3D NULL; + DWORD dwResult =3D tap_list_adapters(NULL, szzHwId, &pAdapterList); + free(szzHwId); + if (dwResult !=3D ERROR_SUCCESS) + { + fwprintf(stderr, L"Enumerating network adapters failed (error 0x%x= ).\n", dwResult); + return 1; + } + + BOOL deleted_any =3D FALSE; + BOOL delete_error =3D FALSE; + + for (struct tap_adapter_node *pAdapter =3D pAdapterList; pAdapter; pAd= apter =3D pAdapter->pNext) + { + LPOLESTR szAdapterId =3D NULL; + StringFromIID((REFIID)&pAdapter->guid, &szAdapterId); + + dwResult =3D tap_delete_adapter(NULL, &pAdapter->guid, pbRebootReq= uired); + if (dwResult !=3D ERROR_SUCCESS) + { + fwprintf(stderr, + L"Deleting adapter \"%ls\" (GUID %ls) failed (error 0= x%x).\n", + pAdapter->szName, szAdapterId, dwResult); + delete_error =3D TRUE; + } + else + { + fwprintf(stdout, L"%ls\t%ls\n", szAdapterId, pAdapter->szName); + deleted_any =3D TRUE; + } + + CoTaskMemFree(szAdapterId); + } + + tap_free_adapter_list(pAdapterList); + + if (!deleted_any && !delete_error) + { + fwprintf(stderr, L"No adapters with hardware ID \"%ls\" found.\n",= hwid); + } + + return delete_error ? 1 : 0; +} + +/** + * Resolve an adapter identifier supplied on the command line. + * + * @param target Adapter GUID or friendly name provided by the us= er. + * @param pguidAdapter Receives the resolved adapter GUID on success. + * @param pszMatchedName Optional pointer that receives a duplicated adap= ter name when + * the lookup was done by name. Caller must free() = it. + * + * @return 0 on success, non-zero otherwise (an error message is printed o= n failure). + */ +static int +tapctl_resolve_delete_target(LPCWSTR target, GUID *pguidAdapter, LPWSTR *p= szMatchedName) +{ + if (SUCCEEDED(IIDFromString(target, (LPIID)pguidAdapter))) + { + if (pszMatchedName) + { + *pszMatchedName =3D NULL; + struct tap_adapter_node *pAdapterList =3D NULL; + if (tap_list_adapters(NULL, NULL, &pAdapterList) =3D=3D ERROR_= SUCCESS) + { + for (struct tap_adapter_node *pAdapter =3D pAdapterList; p= Adapter; + pAdapter =3D pAdapter->pNext) + { + if (IsEqualGUID(&pAdapter->guid, pguidAdapter)) + { + LPWSTR duplicated =3D wcsdup(pAdapter->szName); + if (duplicated =3D=3D NULL) + { + fwprintf(stderr, L"Out of memory.\n"); + tap_free_adapter_list(pAdapterList); + return 1; + } + *pszMatchedName =3D duplicated; + break; + } + } + tap_free_adapter_list(pAdapterList); + } + } + return 0; + } + + struct tap_adapter_node *pAdapterList =3D NULL; + DWORD dwResult =3D tap_list_adapters(NULL, NULL, &pAdapterList); + if (dwResult !=3D ERROR_SUCCESS) + { + fwprintf(stderr, L"Enumerating network adapters failed (error 0x%x= ).\n", dwResult); + return 1; + } + + struct tap_adapter_node *match =3D NULL; + for (struct tap_adapter_node *pAdapter =3D pAdapterList; pAdapter; pAd= apter =3D pAdapter->pNext) + { + if (wcsicmp(target, pAdapter->szName) =3D=3D 0) + { + match =3D pAdapter; + break; + } + } + + if (match =3D=3D NULL) + { + fwprintf(stderr, L"\"%ls\" adapter not found.\n", target); + tap_free_adapter_list(pAdapterList); + return 1; + } + + LPWSTR duplicated_name =3D pszMatchedName ? wcsdup(match->szName) : NU= LL; + if (pszMatchedName && duplicated_name =3D=3D NULL) + { + fwprintf(stderr, L"Out of memory.\n"); + tap_free_adapter_list(pAdapterList); + return 1; + } + + memcpy(pguidAdapter, &match->guid, sizeof(GUID)); + tap_free_adapter_list(pAdapterList); + + if (pszMatchedName) + { + *pszMatchedName =3D duplicated_name; + } + return 0; +} + +static int +tapctl_cmd_delete(int argc, LPCWSTR argv[], BOOL *pbRebootRequired) +{ + LPCWSTR szDeleteTarget =3D NULL; + LPCWSTR szDeleteHwId =3D NULL; + + for (int i =3D 2; i < argc; i++) + { + if (wcsicmp(argv[i], L"--hwid") =3D=3D 0) + { + if (++i >=3D argc) + { + fwprintf(stderr, + L"--hwid option requires a value. Please, use \"t= apctl help delete\" for " + L"usage info.\n"); + return 1; + } + if (argv[i][0] =3D=3D L'\0') + { + fwprintf(stderr, + L"--hwid option cannot be empty. Please, use \"ta= pctl help delete\" for " + L"usage info.\n"); + return 1; + } + szDeleteHwId =3D argv[i]; + } + else if (szDeleteTarget =3D=3D NULL) + { + szDeleteTarget =3D argv[i]; + } + else + { + fwprintf(stderr, + L"Unknown option \"%ls" + L"\". Please, use \"tapctl help delete\" for usage in= fo. Ignored.\n", + argv[i]); + } + } + + if (szDeleteHwId) + { + if (szDeleteTarget) + { + fwprintf(stderr, L"--hwid option cannot be combined with adapt= er GUID or name.\n"); + return 1; + } + return tapctl_delete_by_hwid(szDeleteHwId, pbRebootRequired); + } + + if (szDeleteTarget =3D=3D NULL) + { + fwprintf( + stderr, + L"Missing adapter GUID or name. Please, use \"tapctl help dele= te\" for usage info.\n"); + return 1; + } + + GUID guidAdapter; + LPWSTR matched_name =3D NULL; + if (tapctl_resolve_delete_target(szDeleteTarget, &guidAdapter, &matche= d_name) !=3D 0) + { + return 1; + } + + DWORD dwResult =3D tap_delete_adapter(NULL, &guidAdapter, pbRebootRequ= ired); + if (dwResult !=3D ERROR_SUCCESS) + { + fwprintf(stderr, + L"Deleting adapter \"%ls" + L"\" failed (error 0x%x).\n", + szDeleteTarget, dwResult); + free(matched_name); + return 1; + } + + LPOLESTR szAdapterId =3D NULL; + StringFromIID((REFIID)&guidAdapter, &szAdapterId); + fwprintf(stdout, L"%ls\t%ls\n", szAdapterId, + (matched_name && matched_name[0]) ? matched_name : szDeleteTa= rget); + CoTaskMemFree(szAdapterId); + free(matched_name); + + return 0; +} + /** * Program entry point */ @@ -248,215 +804,17 @@ } else if (wcsicmp(argv[1], L"create") =3D=3D 0) { - LPCWSTR szName =3D NULL; - LPCWSTR szHwId =3D L"root\\" _L(TAP_WIN_COMPONENT_ID); - - /* Parse options. */ - for (int i =3D 2; i < argc; i++) - { - if (wcsicmp(argv[i], L"--name") =3D=3D 0) - { - szName =3D argv[++i]; - } - else if (wcsicmp(argv[i], L"--hwid") =3D=3D 0) - { - szHwId =3D argv[++i]; - } - else - { - fwprintf( - stderr, - L"Unknown option \"%ls" - L"\". Please, use \"tapctl help create\" to list suppo= rted options. Ignored.\n", - argv[i]); - } - } - - /* Create TUN/TAP adapter. */ - GUID guidAdapter; - LPOLESTR szAdapterId =3D NULL; - DWORD dwResult =3D - tap_create_adapter(NULL, L"Virtual Ethernet", szHwId, &bReboot= Required, &guidAdapter); - if (dwResult !=3D ERROR_SUCCESS) - { - fwprintf(stderr, L"Creating TUN/TAP adapter failed (error 0x%x= ).\n", dwResult); - iResult =3D 1; - goto quit; - } - - /* Get existing network adapters. */ - struct tap_adapter_node *pAdapterList =3D NULL; - dwResult =3D tap_list_adapters(NULL, NULL, &pAdapterList); - if (dwResult !=3D ERROR_SUCCESS) - { - fwprintf(stderr, L"Enumerating adapters failed (error 0x%x).\n= ", dwResult); - iResult =3D 1; - goto create_delete_adapter; - } - - LPWSTR adapter_name =3D - szName ? wcsdup(szName) : get_unique_adapter_name(szHwId, pAda= pterList); - if (adapter_name) - { - /* Check for duplicates when name was specified, - * otherwise get_adapter_default_name() takes care of it */ - if (szName && !is_adapter_name_available(adapter_name, pAdapte= rList, TRUE)) - { - iResult =3D 1; - goto create_cleanup_pAdapterList; - } - - /* Rename the adapter. */ - dwResult =3D tap_set_adapter_name(&guidAdapter, adapter_name, = FALSE); - if (dwResult !=3D ERROR_SUCCESS) - { - StringFromIID((REFIID)&guidAdapter, &szAdapterId); - fwprintf(stderr, - L"Renaming TUN/TAP adapter %ls" - L" to \"%ls\" failed (error 0x%x).\n", - szAdapterId, adapter_name, dwResult); - CoTaskMemFree(szAdapterId); - iResult =3D 1; - goto quit; - } - } - - iResult =3D 0; - -create_cleanup_pAdapterList: - free(adapter_name); - - tap_free_adapter_list(pAdapterList); - if (iResult) - { - goto create_delete_adapter; - } - - /* Output adapter GUID. */ - StringFromIID((REFIID)&guidAdapter, &szAdapterId); - fwprintf(stdout, L"%ls\n", szAdapterId); - CoTaskMemFree(szAdapterId); - - iResult =3D 0; - goto quit; - -create_delete_adapter: - tap_delete_adapter(NULL, &guidAdapter, &bRebootRequired); - iResult =3D 1; + iResult =3D tapctl_cmd_create(argc, argv, &bRebootRequired); goto quit; } else if (wcsicmp(argv[1], L"list") =3D=3D 0) { - WCHAR szzHwId[0x100] =3D - L"root\\" _L(TAP_WIN_COMPONENT_ID) L"\0" _L(TAP_WIN_COMPONENT_= ID) L"\0" - = L"ovpn-dco\0"; - - /* Parse options. */ - for (int i =3D 2; i < argc; i++) - { - if (wcsicmp(argv[i], L"--hwid") =3D=3D 0) - { - memset(szzHwId, 0, sizeof(szzHwId)); - ++i; - memcpy_s(szzHwId, - sizeof(szzHwId) - 2 * sizeof(WCHAR) /*requires do= uble zero termination*/, - argv[i], wcslen(argv[i]) * sizeof(WCHAR)); - } - else - { - fwprintf( - stderr, - L"Unknown option \"%ls" - L"\". Please, use \"tapctl help list\" to list support= ed options. Ignored.\n", - argv[i]); - } - } - - /* Output list of adapters with given hardware ID. */ - struct tap_adapter_node *pAdapterList =3D NULL; - DWORD dwResult =3D tap_list_adapters(NULL, szzHwId, &pAdapterList); - if (dwResult !=3D ERROR_SUCCESS) - { - fwprintf(stderr, L"Enumerating TUN/TAP adapters failed (error = 0x%x).\n", dwResult); - iResult =3D 1; - goto quit; - } - - for (struct tap_adapter_node *pAdapter =3D pAdapterList; pAdapter;= pAdapter =3D pAdapter->pNext) - { - LPOLESTR szAdapterId =3D NULL; - StringFromIID((REFIID)&pAdapter->guid, &szAdapterId); - fwprintf(stdout, - L"%ls\t%" - L"ls\n", - szAdapterId, pAdapter->szName); - CoTaskMemFree(szAdapterId); - } - - iResult =3D 0; - tap_free_adapter_list(pAdapterList); + iResult =3D tapctl_cmd_list(argc, argv); + goto quit; } else if (wcsicmp(argv[1], L"delete") =3D=3D 0) { - if (argc < 3) - { - fwprintf( - stderr, - L"Missing adapter GUID or name. Please, use \"tapctl help = delete\" for usage info.\n"); - return 1; - } - - GUID guidAdapter; - if (FAILED(IIDFromString(argv[2], (LPIID)&guidAdapter))) - { - /* The argument failed to covert to GUID. Treat it as the adap= ter name. */ - struct tap_adapter_node *pAdapterList =3D NULL; - DWORD dwResult =3D tap_list_adapters(NULL, NULL, &pAdapterList= ); - if (dwResult !=3D ERROR_SUCCESS) - { - fwprintf(stderr, L"Enumerating TUN/TAP adapters failed (er= ror 0x%x).\n", dwResult); - iResult =3D 1; - goto quit; - } - - for (struct tap_adapter_node *pAdapter =3D pAdapterList;; pAda= pter =3D pAdapter->pNext) - { - if (pAdapter =3D=3D NULL) - { - fwprintf(stderr, L"\"%ls\" adapter not found.\n", argv= [2]); - iResult =3D 1; - goto delete_cleanup_pAdapterList; - } - else if (wcsicmp(argv[2], pAdapter->szName) =3D=3D 0) - { - memcpy(&guidAdapter, &pAdapter->guid, sizeof(GUID)); - break; - } - } - - iResult =3D 0; - -delete_cleanup_pAdapterList: - tap_free_adapter_list(pAdapterList); - if (iResult) - { - goto quit; - } - } - - /* Delete the network adapter. */ - DWORD dwResult =3D tap_delete_adapter(NULL, &guidAdapter, &bReboot= Required); - if (dwResult !=3D ERROR_SUCCESS) - { - fwprintf(stderr, - L"Deleting adapter \"%ls" - L"\" failed (error 0x%x).\n", - argv[2], dwResult); - iResult =3D 1; - goto quit; - } - - iResult =3D 0; + iResult =3D tapctl_cmd_delete(argc, argv, &bRebootRequired); goto quit; } else -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1335?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I4d822bf7ae5f037e2414778e8fa74eca5e289e65 Gerrit-Change-Number: 1335 Gerrit-PatchSet: 1 Gerrit-Owner: stipa Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld --4nfLVmHhNoc= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld, plaisthos.

stipa would like plaisthos and flichtenheld to review t= his change.

V= iew Change

tapctl: overhaul adapter management helpers=
 and improve CLI UX

- default to creating ovpn-dco adapters, refres= h help text,
validate CLI input, and print both GUID and name after crea= tion;

- refactor create/list/delete into dedicated helpers,
add = bulk deletion via delete --hwid, and centralize
GUID/name resolution;
- harden auto-naming to recognise both ovpn-dco and
tap0901 HWIDs,= honour reserved names, and reuse friendly names
when deleting by GUID.<= br>
Change-Id: I4d822bf7ae5f037e2414778e8fa74eca5e289e65
Signed-off-b= y: Lev Stipakov <lev@...515...>
---
M src/tapctl/main.c
1 fi= le changed, 601 insertions(+), 243 deletions(-)

=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1335/1
diff --git a/src/tapctl/main.c b/src/tapctl/main.c
inde= x 031e262..f72d261 100644
--- a/src/tapctl/main.c+++ b/src/tapctl/main.c
@@ -1,5 +1,5 @@
/*
- * tapctl -- = Utility to manipulate TUN/TAP adapters on Windows
+ * tapctl -- Utility to manipulate virtual n= etwork adapters on Windows
* https://community= .openvpn.net/openvpn/wiki/Tapctl
*
* C= opyright (C) 2002-2025 OpenVPN Inc <sales@...515...>
= @@ -28,6 +28,7 @@
#include <objbase.h>
#include <setupapi.h>
#include <stdio.h>
+#include <stdlib.h= >
#include <wchar.h>

= #ifdef _MSC_VER
@@ -50,8 +51,8 @@
= L"\n"
L"Commands:\n"
= L"\n"
- L"create Create a new TUN/TAP adapter\n"
<= span style=3D"color: hsl(0, 100%, 40%);">- L"list List TUN/TA= P adapters\n"

+ = L"create Create a new network adapter\n"
+ L"list List network ad= apters\n"
L"delete Delete specified netw= ork adapter\n"
L"help Display this tex= t\n"
L"\n"
@@ -61,7 +62= ,7 @@
static const WCHAR usage_message_create[] =3D=
L"%ls\n"
L"\n"
- L"Creates a new T= UN/TAP adapter\n"
- L"--name <name> Set TUN/TAP adapter name. Should the adap= ter with given name \n"
+ L"--name <name> Set network adapter name. Shoul= d the adapter with given name \n"
L" = already exist, an error is returned. If this option is not \= n"
L" specified, a default ada= pter name is chosen by Windows. \n"
L&quo= t; Note: This name can also be specified as OpenVPN's --d= ev-node \n"
L" option. = \n"
- L"--hwid <hwid> Adapt= er hardware ID. Default value is root\\tap0901, which \n"
<= br>- L" des= cribes tap-windows6 driver. To work with ovpn-dco driver, \n"
- L" d= river, specify 'ovpn-dco'. \n&q= uot;
+ L"--hw= id <hwid> Adapter hardware ID. Default value is ovpn-dco, which crea= tes \n"
+ L= " a Data Channel Offload adapter. To create a tap-window= s6 \n"
+ = L" adapter, specify 'root\\tap0901'. = \n"
L"\n"=
L"Output:\n"
L"\n"<= /span>
- L"This comman= d prints newly created TUN/TAP adapter's GUID to stdout. \n&= quot;
+ L"Thi= s command prints newly created network adapter's GUID to stdout. = \n"
;

static = const WCHAR usage_message_list[] =3D
L"%ls\n"= ;
L"\n"
- L"Lists TUN/TAP adapters\n"
+ L"Lists network adapters\n&= quot;
L"\n"
L"Usag= e:\n"
L"\n"
@@ -94,22 += 95,28 @@
L"\n"
L"O= ptions:\n"
L"\n"
- L"--hwid <hwid> Adapter har= dware ID. By default, root\\tap0901, tap0901 and \n"
- L" ovpn-dco adap= ters are listed. Use this switch to limit the list.\n"
+ L"--hwid <hwid> Ada= pter hardware ID. By default, ovpn-dco, root\\tap0901 and \n"
=
+ L" = tap0901 adapters are listed. Use this switch to limit the list.\n"

L"\n"
L"Output:\n&quo= t;
L"\n"
- L"This command prints all TUN/TAP adapters to st= dout. \n"
+ L"This command prints all network adapters t= o stdout. \n"
;
=
static const WCHAR usage_message_delete[] =3D
L"%ls\n"
L"\n"

- L"Deletes the s= pecified network adapter\n"
+ L"Deletes network adapters\n"
= L"\n"
L"Usage:\n"
L"\n"
L"tapctl delete <adapt= er GUID | adapter name>\n"
+ L"tapctl delete --hwid <hardware ID>\n"<= /span>
+ L"\n"<= /span>
+ L"Options:\= n"
+ L"\= n"
+ L"-= -hwid <hwid> Delete all adapters that use the specified hardware ID.= Cannot\n"
+ = L" be combined with adapter GUID or name.\n"=
;
/* clang-format on */

@@ -123,84 +130,633 @@
fwprintf(stderr, usa= ge_message, title_string);
}

<= span style=3D"color: hsl(120, 100%, 40%);">+static int tapctl_cmd_create(in= t argc, LPCWSTR argv[], BOOL *pbRebootRequired);

+static int tapctl_cmd_list(int argc, LPCWSTR a= rgv[]);
+static int t= apctl_cmd_delete(int argc, LPCWSTR argv[], BOOL *pbRebootRequired);<= br>+
/**
- * Checks if adapter with g= iven name doesn't already exist
+ * Locate an adapter node by its friendly name within the e= numerated list.
+ *
+ * @param name = Friendly name to search for. Comparison is case-insensitive.
<= span style=3D"color: hsl(120, 100%, 40%);">+ * @param adapter_list Head of= the adapter list returned by tap_list_adapters().

+ *
+ * @return Pointer to the matching node, or NULL when not fou= nd.
*/
-is_adap= ter_name_available(LPCWSTR name, struct tap_adapter_node *adapter_list, BOO= L log)
+static struct= tap_adapter_node *
+= find_adapter_by_name(LPCWSTR name, struct tap_adapter_node *adapter_list)
{
for (struct tap_adapter_node *a =3D = adapter_list; a; a =3D a->pNext)
{
- if (wcsicmp(name, a->szName= ) =3D=3D 0)
+ = if (_wcsicmp(name, a->szName) =3D=3D 0)
{
- if (log)=
- {
- LPOLESTR adapter_id = =3D NULL;

- = StringFromIID((REFIID)&a->guid, &adapter_id);
- fwprintf(stderr,

- = L"Adapter \"%ls\" already exists (GUID %"
- L"ls)= .\n",
- = a->szName, adapter_id);
- CoTaskMemFree(adapter_id);
- }
-
- return FALSE;
+ return a;
} }

- return TRUE;
+ return NULL;
}

/**
- * Returns uniq= ue adapter name based on hwid or NULL if name cannot be generated.- * Caller is responsible for f= reeing it.
+ * Check = whether the registry still reserves a given network-connection name.=
+ *
+ * Windows keeps friendly names under

+ * HKLM\SYSTEM\CurrentC= ontrolSet\Control\Network\{NETCLASS}\{GUID}\Connection\Name,
+ * even after an adapter is remove= d. netsh refuses to rename to any reserved name.
+ *
+ * @param name Friendly name to test.
+ *
+ * @return TRUE if the name exists in the registry, FALSE oth= erwise.
+ */+static BOOL
+registry_name_exists(LPCWSTR name)
+{
+ static const WCHAR class_key[] =3D<= /span>
+ L"SYSTE= M\\CurrentControlSet\\Control\\Network\\{4d36e972-e325-11ce-bfc1-08002be103= 18}";
++ HKEY hClassKey =3D NULL;=
+ if (RegOpenKeyE= x(HKEY_LOCAL_MACHINE, class_key, 0, KEY_READ, &hClassKey) !=3D ERROR_SU= CCESS)
+ {<= br>+ return FALSE;
+ }
+
+ BOOL found =3D FALSE;
+
+ for (DWORD index =3D 0;; ++index)
+ {
+ WCHAR adapter_id[64];
+ DWORD adapter_id_len =3D _countof(adapter_id);

+ LONG result = =3D RegEnumKeyEx(hClassKey, index, adapter_id, &adapter_id_len, NULL, N= ULL, NULL,
+ = NULL);
+ if (result =3D=3D ERROR_NO_MORE_ITEMS)
+ {
+ break;
+ }
+ else if (result !=3D ERROR_SUCCESS)
+ {
+ continue;
+ }
+
+ WCHAR connection_key[512];
+ swprintf_s(connection_key, _countof(connectio= n_key), L"%ls\\%ls\\Connection", class_key,
+ adapter_id);+
+ DWORD value_size =3D 0;
+ LONG query =3D RegGetValueW(= HKEY_LOCAL_MACHINE, connection_key, L"Name",
+ RRF_RT= _REG_SZ | RRF_NOEXPAND, NULL, NULL, &value_size);
+ if (query !=3D ERROR_SUCCESS || v= alue_size < sizeof(WCHAR))
+ {
+= continue;
+ }
+<= br>+ LPWSTR value =3D (L= PWSTR)malloc(value_size);
+ if (!value)
+ {
+ = continue;
+ = }
+
<= span style=3D"color: hsl(120, 100%, 40%);">+ query =3D RegGetValueW(= HKEY_LOCAL_MACHINE, connection_key, L"Name",
+ RRF_RT_REG_= SZ | RRF_NOEXPAND, NULL, value, &value_size);
+ if (query =3D=3D ERROR_SUCCESS &&= amp; _wcsicmp(name, value) =3D=3D 0)
+ {
+ found =3D TRUE;
+ free(value);
+ break;
+ }
+
+ fr= ee(value);
++ if (found)+ {
+ break;
+ }
+ }
+
+ RegC= loseKey(hClassKey);
+= return found;
+}<= /span>
+
+/**
+ * Determine whether a friendly name is currently in us= e by an adapter or reserved
+ * in the registry.
+ *
+ * @param= name Friendly name to test.
+ * @param adapter_list Head of the adapter list returned= by tap_list_adapters().
+ *
+ * @return T= RUE when the name is taken/reserved, FALSE when available.
+ */
+static BOOL
+tap_name_in_use(LPCWSTR name, struct tap_adapter_node *adapt= er_list)
+{+ if (name =3D=3D NULL)
+ {
+ return FALSE;
+ }

+
+ if (find_adapter_by_name(name, adapter_list))
+ {
+ return TRUE;
+ }
+
+ retur= n registry_name_exists(name);
+}
+<= br>+/**
+ * Resolve the adapter name we should app= ly:
+ * - For user-= specified names, ensure they are unique both in the adapter list and=
+ * in the registry. On= conflict, an explanatory message is printed and NULL is returned.+ * - For automatic naming,= derive the base string from HWID and append the first available
= + * suffix recognised by Wi= ndows.
+ *
= + * @param requested_name Name= provided via CLI or configuration (may be NULL/empty).
+ * @param hwid Hardware iden= tifier of the adapter being created.
+ * @param adapter_list Existing adapters enumerated via= tap_list_adapters().
+ *
+ * @return Newl= y allocated wide string containing the final name, or NULL on failure.
*/
static LPWSTR
-get_unique_adapter_name(LPCWSTR hwid, struct tap_= adapter_node *adapter_list)
+tap_resolve_adapter_name(LPCWSTR requested_name, LPCWSTR hwid,
+ = struct tap_adapter_node *adapter_list)
{
+ if (requested_name && re= quested_name[0])
+ = {
+ struct ta= p_adapter_node *conflict =3D find_adapter_by_name(requested_name, adapter_l= ist);
+ if (co= nflict)
+ {

+ LPOLESTR a= dapter_id =3D NULL;
+= StringFromIID((REFIID)&conflict->guid, &adapter_id);=
+ fwprint= f(stderr,
+ = L"Adapter \"%ls\" already exists (GUID %"
+ L= "ls).\n",
+= conflict->szName, adapter_id);
+ CoTaskMemFree(adapter_id);
+ return NU= LL;
+ }=
+
+ if (registry_name_exists(requested_na= me))
+ {

+ fwprintf(stde= rr, L"Adapter name \"%ls\" is already in use.\n", reque= sted_name);
+ = return NULL;
+ = }
+
+ return wcsdup(requested_= name);
+ }<= br>+
if (h= wid =3D=3D NULL)
{
return NUL= L;
}

- LPCWSTR base_name;
- if (wcsicmp(hwid, L"ovpn-dco") =3D=3D = 0)
+ LPCWSTR base_= name =3D NULL;
+ i= f (_wcsicmp(hwid, L"ovpn-dco") =3D=3D 0)
{
base_name =3D L"OpenVPN Data Channel Offload&q= uot;;
}
- else if (wcsicmp(hwid, L"root\\" _L(TAP_WIN_COMPONENT_= ID)) =3D=3D 0)
+ e= lse if (_wcsicmp(hwid, L"root\\" _L(TAP_WIN_COMPONENT_ID)) =3D=3D= 0
+ || _= wcsicmp(hwid, _L(TAP_WIN_COMPONENT_ID)) =3D=3D 0)
{

base_name =3D L"OpenVPN TAP-Windows6";
}
else
{=
+ fwprintf(stderr,
+ L&qu= ot;Cannot auto-generate adapter name for hardware ID \"%ls\".\n&q= uot;, hwid);
return NULL;
}

- i= f (is_adapter_name_available(base_name, adapter_list, FALSE))
+ if (!tap_name_in_use(base_nam= e, adapter_list))

{
return wc= sdup(base_name);
}

= size_t name_len =3D wcslen(base_name) + 10;
- LPWSTR name =3D malloc(name_len * sizeof(WCHA= R));
+ LPWSTR name= =3D (LPWSTR)malloc(name_len * sizeof(WCHAR));
if (nam= e =3D=3D NULL)
{
return NULL;=
}
- for (int i =3D 1; i < 100; ++i)
+
+ /* Windows never assigns the "#1" suffix, so skip it to avo= id netsh failures. */
+ for (int i =3D 2; i < 100; ++i)
{
<= span> swprintf_s(name, name_len, L"%ls #%d", base_name, i= );


- = if (is_adapter_name_available(name, adapter_list, FALSE))
= + if (!tap_name_in_use(n= ame, adapter_list))
{
= return name;
}
}
<= span>

+ free(name= );
+ fwprintf(stde= rr, L"Unable to find available adapter name based on \"%ls\"= .\n", base_name);
return NULL;
}=

+s= tatic int
+tapctl_cmd= _create(int argc, LPCWSTR argv[], BOOL *pbRebootRequired)
+{
+ LPCWSTR szName =3D NULL;
+ LPCWSTR defaultHwId =3D L"ovpn-dco&qu= ot;;
+ LPCWSTR szH= wId =3D defaultHwId;
= + LPWSTR adapter_name =3D NULL;
+ struct tap_adapter_node *pAdapterList =3D NULL;+ GUID guidAdapter;=
+ LPOLESTR szAdapterId = =3D NULL;
+ DWORD = dwResult;
+ int iR= esult =3D 1;
+ BOO= L adapter_created =3D FALSE;
+
+ for (i= nt i =3D 2; i < argc; i++)
+ {
+ = if (wcsicmp(argv[i], L"--name") =3D=3D 0)
+ {
+ if (++i >=3D argc)
+ {
+ fwprintf(stderr, L"-= -name option requires a value. Ignored.\n");
+ break;
+ }
+ szName =3D argv[i];
+ if (szName[0] =3D=3D L&= #39;\0')
+ = {
+ = fwprintf(stderr, L"--name option cannot be empty. Ignored.\n")= ;
+ sz= Name =3D NULL;
+ = }
+ }
+ else if (wcsi= cmp(argv[i], L"--hwid") =3D=3D 0)
+ {
+ if (++i >=3D argc)
+ {
+ fwprintf(stderr,
+ L"--hwid o= ption requires a value. Using default \"%ls\".\n",+ defa= ultHwId);
+ = break;
+ = }
+ s= zHwId =3D argv[i];
+ = if (szHwId[0] =3D=3D L'\0')
+ {
+ fwprintf(stderr,
+ L"--hwid op= tion cannot be empty. Using default \"%ls\".\n",
<= span style=3D"color: hsl(120, 100%, 40%);">+ defaul= tHwId);

+ = szHwId =3D defaultHwId;
+ }
+ }
+ = else
+ {

+ fwprintf(stde= rr,
+ = L"Unknown option \"%ls"
+ L"\". Please, use \&= quot;tapctl help create\" to list supported options. Ignored.\n",=
+ = argv[i]);
+ = }
+ }
+
+ dwResult =3D tap_create_adapter(NULL, L"Vi= rtual Ethernet", szHwId, pbRebootRequired,
+ &guidAdap= ter);
+ if (dwResu= lt !=3D ERROR_SUCCESS)
+ fwp= rintf(stderr, L"Creating network adapter failed (error 0x%x).\n",= dwResult);
+ = goto cleanup;
+ }<= /span>
+ adapter_created = =3D TRUE;
++ dwResult =3D tap_list_ada= pters(NULL, NULL, &pAdapterList);
+ if (dwResult !=3D ERROR_SUCCESS)
+ {
+ fwprintf(stderr, L"Enumerating adapters f= ailed (error 0x%x).\n", dwResult);
+ goto cleanup;
+ }
+
+ adapter= _name =3D tap_resolve_adapter_name(szName, szHwId, pAdapterList);+ if (adapter_name =3D=3D N= ULL)
+ {+ goto cleanup;<= br>+ }
+
+ dwResult =3D tap_set_adapter_name(&guidAdapter, adap= ter_name, FALSE);
+ = if (dwResult !=3D ERROR_SUCCESS)
+ {
= + StringFromIID((REFIID)&guidAdapter, &szAdapterId);<= br>+ fwprintf(stderr,

+ L&quo= t;Renaming network adapter %ls to \"%ls\" failed (error 0x%x).\n&= quot;, szAdapterId,
+= adapter_name, dwResult);
+ CoTaskMemFree(szAdapterId);
+ goto cleanup;
+ }
+
+ iResult =3D 0;
+ StringFromIID((REFIID)&guidAdapter, &szAdapterId);=
+ fwprintf(stdout, L&quo= t;%ls\t%ls\n", szAdapterId,
+ (adapter_name && adapter_name[0]) ? adapt= er_name : L"(unnamed)");
+ CoTaskMemFree(szAdapterId);
+
+cleanup:
+ = if (pAdapterList)
+ = {
+ tap_fre= e_adapter_list(pAdapterList);
+ }
+ = free(adapter_name);
+=
+ if (adapter_cre= ated && iResult !=3D 0)
+ {
+ = tap_delete_adapter(NULL, &guidAdapter, pbRebootRequired);<= br>+ }
+
+ return iResult;
+}
+
+static int
<= span style=3D"color: hsl(120, 100%, 40%);">+tapctl_cmd_list(int argc, LPCWS= TR argv[])

+{<= br>+ WCHAR szzHwId[0x100] = =3D L"ovpn-dco\0"
+ L"root\\" _L(TAP_WIN_COMPONENT= _ID) L"\0" _L(TAP_WIN_COMPONENT_ID) L"\0";
+ struct tap_adapter_node *pAd= apterList =3D NULL;
+= DWORD dwResult;
+= int iResult =3D 0;
+ for (int i = =3D 2; i < argc; i++)
+ {
+ i= f (wcsicmp(argv[i], L"--hwid") =3D=3D 0)
+ {
+ if (++i >=3D argc)
+ {
+ fwprintf(stderr,
+ L"-= -hwid option requires a value. Please, use \"tapctl help list\" t= o "
+ = L"list supported options.\n");
+ return 1;
+ }
+ memset(szzHwId, 0, sizeof(sz= zHwId));
+ = memcpy_s(szzHwId,
+ = sizeof(szzHwId) - 2 * sizeof(WCHAR) /*requires double z= ero termination*/,
+ = argv[i], wcslen(argv[i]) * sizeof(WCHAR));
+ }
+ else
+ {
+ fwprintf(stderr,
+ L"Unknown option \"= ;%ls"
+ = L"\". Please, use \"tapctl help list\" to l= ist supported options. Ignored.\n",
+ argv[i]);
+ }
+ }
+
+ dwRes= ult =3D tap_list_adapters(NULL, szzHwId, &pAdapterList);
+ if (dwResult !=3D ERROR_SUCCES= S)
+ {
<= span style=3D"color: hsl(120, 100%, 40%);">+ fwprintf(stderr, L"= ;Enumerating network adapters failed (error 0x%x).\n", dwResult);

+ return 1;=
+ }
+
+ for (struct tap_adapter_node *pAdapter =3D pAdapterList= ; pAdapter; pAdapter =3D pAdapter->pNext)
+ {
+ LPOLESTR szAdapterId =3D NULL;
+ StringFromIID((REFIID)&pAdapter-&= gt;guid, &szAdapterId);
+ fwprintf(stdout, L"%ls\t%ls\n", szAdapterId, pAda= pter->szName);
+ = CoTaskMemFree(szAdapterId);
+ }
+=
+ tap_free_adapte= r_list(pAdapterList);
+ return iResult;
+}
+
+/**
+ * Delete every adapter matching the provided hardw= are ID.
+ *+ * @param hwid Ha= rdware ID string (must be non-NULL and non-empty).
+ * @param pbRebootRequired Pointer to reboot= flag propagated from caller.
+ *
+ * @ret= urn 0 when every adapter was deleted successfully, 1 otherwise.
<= span style=3D"color: hsl(120, 100%, 40%);">+ */
+static int
+tapctl_delete_by_hwid(LPCWSTR hwid, BOOL *pbRebootRequir= ed)
+{
+ if (hwid =3D=3D NULL || hwid[0= ] =3D=3D L'\0')
+ {
+ fw= printf(stderr, L"--hwid option cannot be empty.\n");
+ return 1;
+ }
+
+ size_t hw_len =3D wcslen(hwid);
+ size_t buf_len =3D hw_len + 2;
+ LPWSTR szzHwId =3D (LPWSTR)callo= c(buf_len, sizeof(WCHAR));
+ if (szzHwId =3D=3D NULL)
+ {
+ fwprintf(stderr, L"Out of memory.\n");
+ return 1;
+ }
+ wmemcpy(szzHwId, hwid, hw_len);
+
+ struct tap_adapter_node *pAdapterList =3D NULL;

+ DWORD dwResult =3D = tap_list_adapters(NULL, szzHwId, &pAdapterList);
+ free(szzHwId);
+ if (dwResult !=3D ERROR_SUCCESS)
+ {
+ fwprintf(stderr, L"Enumer= ating network adapters failed (error 0x%x).\n", dwResult);
<= span style=3D"color: hsl(120, 100%, 40%);">+ return 1;

+ }
+
+ BOOL deleted_any =3D FALSE;
+ BOOL delete_error =3D FALSE;
+
+ for (struct tap_adapter_node *pAdapter =3D pAdapterList;= pAdapter; pAdapter =3D pAdapter->pNext)
+ {
+ LPOLESTR szAdapterId =3D NULL;
+ StringFromIID((REFIID)&pAdapter-&g= t;guid, &szAdapterId);
+
+ dwRe= sult =3D tap_delete_adapter(NULL, &pAdapter->guid, pbRebootRequired)= ;
+ if (dwResu= lt !=3D ERROR_SUCCESS)
+ = fwprintf(stderr,
+ L"Deleting adapter \"%ls\" (GUID %ls)= failed (error 0x%x).\n",
+ pAdapter->szName, szAdapterId, dwResult)= ;
+ delete= _error =3D TRUE;
+ = }
+ else<= /span>
+ {
= + fwprintf(stdout, L= "%ls\t%ls\n", szAdapterId, pAdapter->szName);
+ deleted_any =3D TRUE;

+ }
+
+ CoTaskMemFree(szAdapterId);
+ }
+
+ tap_free_adapter_list(pAdapterList);
+
+ if (!deleted_any && !delete_error)
+ {
+ fwprintf(stderr, L"No adapters with hard= ware ID \"%ls\" found.\n", hwid);
+ }
+
+ = return delete_error ? 1 : 0;
+}
++/**
+ * Resolve an adapter identifier supplied on= the command line.
+ = *
+ * @param target = Adapter GUID or friendly name provided by the user.
+ * @param pguidAdapter Receives = the resolved adapter GUID on success.
+ * @param pszMatchedName Optional pointer that receives = a duplicated adapter name when
+ * the lookup was done by name. Caller mu= st free() it.
+ *
+ * @return 0 on success= , non-zero otherwise (an error message is printed on failure).
+ */

+static int
+tapctl_resolve_delete_target(LPCWSTR target, GUID *pguidA= dapter, LPWSTR *pszMatchedName)
+{
+ if= (SUCCEEDED(IIDFromString(target, (LPIID)pguidAdapter)))
+ {
+ if (pszMatchedName)
+ {
+ *pszMatchedName =3D NULL;
+ struct tap_adapter_node = *pAdapterList =3D NULL;
+ if (tap_list_adapters(NULL, NULL, &pAdapterList) =3D=3D= ERROR_SUCCESS)
+ = {
+ = for (struct tap_adapter_node *pAdapter =3D pAdapterList; pAdapter;

+ p= Adapter =3D pAdapter->pNext)
+ {
+ if (IsEqualGUID(&pAdapter->guid, pguid= Adapter))
+ = {
+ = LPWSTR duplicated =3D wcsdup(pAdapter->szName);+ if (= duplicated =3D=3D NULL)
+ {
+ fwprintf(stderr, L"Out of memory= .\n");
+ = tap_free_adapter_list(pAdapterList);
+ return 1;<= /span>
+ = }
+ = *pszMatchedName =3D duplicated;
+ break;
+ }
+ }
+ tap_free_adapter_list(pAd= apterList);
+ = }
+ }
+ return 0;=
+ }
+
+ struct tap_adapter_node *pAdapterList =3D NULL;<= br>+ DWORD dwResult =3D tap_= list_adapters(NULL, NULL, &pAdapterList);
+ if (dwResult !=3D ERROR_SUCCESS)
+ {

+ fwprintf(stderr, L"Enumerating ne= twork adapters failed (error 0x%x).\n", dwResult);
+ return 1;
+ }
+
= + struct tap_adapter_node *match =3D NULL;
+ for (struct tap_adapter_node *pAdapter =3D pA= dapterList; pAdapter; pAdapter =3D pAdapter->pNext)
+ {
+ if (wcsicmp(target, pAdapter->szName) =3D= =3D 0)
+ {
+ match =3D p= Adapter;
+ = break;
+ }
+ }
+
+ if (match =3D=3D NULL)
+ {
+ fwprintf(stderr, L"\"%ls\" adapter not = found.\n", target);
+ tap_free_adapter_list(pAdapterList);
+ return 1;
+ }
+
+ L= PWSTR duplicated_name =3D pszMatchedName ? wcsdup(match->szName) : NULL;=
+ if (pszMatchedN= ame && duplicated_name =3D=3D NULL)
+ {
+ fwprintf(stderr, L"Out of memory.\n");+ tap_free_adapter_lis= t(pAdapterList);
+ = return 1;
+ }=
+
+ memcpy(pguidAdapter, &match-&g= t;guid, sizeof(GUID));
+
+ if (pszMatchedName)
+ {
+ = *pszMatchedName =3D duplicated_name;
+ }
+ return 0;
+= }
+
+static int
+tapctl_cmd_delete(int argc, LPCWSTR argv[], BO= OL *pbRebootRequired)
+{
+ LPCWSTR szDe= leteTarget =3D NULL;
= + LPCWSTR szDeleteHwId =3D NULL;
+
+ = for (int i =3D 2; i < argc; i++)
+ {
+ {
+ if (++i >=3D argc)<= br>+ {
+ fwprintf(stderr,<= /span>
+ = L"--hwid option requires a value. Please, use \"tapctl help = delete\" for "
+ L"usage info.\n");
+ return 1;
= + }
+ if (argv[i][0] =3D=3D L&= #39;\0')
+ = {
+ = fwprintf(stderr,
+= L"--hwid option cannot be empty. Please, use = \"tapctl help delete\" for "
+ L"usage info.\n"= );
+ r= eturn 1;
+ = }
+ szDel= eteHwId =3D argv[i];
= + }
+ e= lse if (szDeleteTarget =3D=3D NULL)
+ {
+ szDeleteTarget =3D argv[i];
+ }
+ else
+ {
+ = fwprintf(stderr,
+ L"Unknown option \"%ls"<= br>+ L"= ;\". Please, use \"tapctl help delete\" for usage info. Igno= red.\n",
+ = argv[i]);
+ }
+ }=
+
+ if (szDeleteHwId)
+ {
+ if (szDeleteTarget)
+ {
+ fwprintf(stderr, L"--hwid option c= annot be combined with adapter GUID or name.\n");
+ return 1;
+ }
+ return tapctl_delete_by_hwid(szDeleteHwI= d, pbRebootRequired);
+ }
+
<= span style=3D"color: hsl(120, 100%, 40%);">+ if (szDeleteTarget =3D=3D N= ULL)

+ {+ fwprintf(
<= span style=3D"color: hsl(120, 100%, 40%);">+ stderr,

<= span style=3D"color: hsl(120, 100%, 40%);">+ L"Missing adap= ter GUID or name. Please, use \"tapctl help delete\" for usage in= fo.\n");

+ = return 1;
+ }
+
+ GUID guidAdapter;
+ LPWSTR matched_name =3D NULL;

+ if (tapctl_resolve_de= lete_target(szDeleteTarget, &guidAdapter, &matched_name) !=3D 0)
+ {
+ return 1;
+ }
+
+ DWORD dwResult =3D tap_delete_adapter(NULL, &guidAdapter, pbReb= ootRequired);
+ if= (dwResult !=3D ERROR_SUCCESS)
+ {
+ = fwprintf(stderr,
+ L"Deleting adapter \"%ls"
+ L"\" fai= led (error 0x%x).\n",

+ szDeleteTarget, dwResult);
+ free(matched_name);
+ return 1;
+ }
+
+ LPOLESTR szAdapterId =3D NULL;
+ StringFromIID((REFIID)&guidAdapter, &szAdapt= erId);
+ fwprintf(= stdout, L"%ls\t%ls\n", szAdapterId,
+ (matched_name && matched_nam= e[0]) ? matched_name : szDeleteTarget);
+ CoTaskMemFree(szAdapterId);
+ free(matched_name);
+
+ return 0;
+}
+
/**
* Program entry point
= */
@@ -248,215 +804,17 @@
}
= else if (wcsicmp(argv[1], L"create") =3D=3D 0)<= br> {
- = LPCWSTR szName =3D NULL;
- LPCWSTR szHwId =3D L"root\\" _L(TAP_WIN_COMPONENT_ID= );
-
- /* Parse options. */
<= span style=3D"color: hsl(0, 100%, 40%);">- for (int i =3D 2; i < = argc; i++)

- {
- if (wcsicmp= (argv[i], L"--name") =3D=3D 0)
- {
- szName =3D argv[++i];
- }
- else if (wcsicmp(argv[i], L"--hwid"= ;) =3D=3D 0)
- = {
- s= zHwId =3D argv[++i];
- = }
- = else
- {<= /span>
- fwprin= tf(
- = stderr,
- = L"Unknown option \"%ls"
- L"\". Please, use \&= quot;tapctl help create\" to list supported options. Ignored.\n",=
- a= rgv[i]);
- }=
- }
<= span style=3D"color: hsl(0, 100%, 40%);">-

- /* Create TUN/TAP adapter. */
- GUID guidAdapter;
- LPOLESTR szAdapterId =3D N= ULL;

- DWORD dwR= esult =3D
- = tap_create_adapter(NULL, L"Virtual Ethernet", szHwId, &bReboo= tRequired, &guidAdapter);
- if (dwResult !=3D ERROR_SUCCESS)
- {
- fwprintf(stderr, L"Creating TUN/TAP adapter= failed (error 0x%x).\n", dwResult);
- iResult =3D 1;
- goto quit;
- }
-
- = /* Get existing network adapters. */
- struct tap_adapter_node *pAdapterList =3D NULL;
- dwResult =3D tap_= list_adapters(NULL, NULL, &pAdapterList);
- if (dwResult !=3D ERROR_SUCCESS)
= - {
- fwprintf(stderr, L"Enumera= ting adapters failed (error 0x%x).\n", dwResult);
- iResult =3D 1;
- goto create_delete_adapte= r;

- }-
- LPWSTR adapter_name =3D
- szName ? wcsdup(szName) : get_= unique_adapter_name(szHwId, pAdapterList);
- if (adapter_name)
- {
- /* Check for duplicates when name was specified,
- * otherwis= e get_adapter_default_name() takes care of it */
- if (szName && !is_adapter_na= me_available(adapter_name, pAdapterList, TRUE))
- {
- iResult =3D 1;
- goto create_cleanup_pAdapterList= ;
- }=
-
- /* Rename the adapter. */
<= span style=3D"color: hsl(0, 100%, 40%);">- dwResult =3D tap_set_= adapter_name(&guidAdapter, adapter_name, FALSE);

- if (dwResult !=3D ERROR_SUCCESS= )
- {=
- StringFromII= D((REFIID)&guidAdapter, &szAdapterId);
- fwprintf(stderr,
- L"Renamin= g TUN/TAP adapter %ls"
- L" to \"%ls\" failed (error 0= x%x).\n",
- = szAdapterId, adapter_name, dwResult);
- CoTaskMemFree(szAdapterId= );
- iRe= sult =3D 1;
- = goto quit;
- = }
- }
-
- iResult =3D 0;
-
-create_cleanup_pAdapterList:
- free(adapter_name);
-
- if (iResult)
- {
- goto create_delete_adapter;
- }
-
- = /* Output adapter GUID. */
- StringFromIID((REFIID)&guidAdapter, &szAdapterI= d);
- fwprintf(s= tdout, L"%ls\n", szAdapterId);
- CoTaskMemFree(szAdapterId);
-
- iResult =3D 0;
- goto quit;
-
-create_dele= te_adapter:
- ta= p_delete_adapter(NULL, &guidAdapter, &bRebootRequired);
<= span style=3D"color: hsl(0, 100%, 40%);">- iResult =3D 1;

= + iResult =3D tapctl_cmd= _create(argc, argv, &bRebootRequired);
goto qu= it;
}
else if (wcsicmp(argv[1], L= "list") =3D=3D 0)
{
- WCHAR szzHwId[0x100] =3D
- L"root\\" _L(= TAP_WIN_COMPONENT_ID) L"\0" _L(TAP_WIN_COMPONENT_ID) L"\0&qu= ot;
- = L"ovpn-dco= \0";
-
<= span style=3D"color: hsl(0, 100%, 40%);">- /* Parse options. */
- for (int i =3D 2; = i < argc; i++)
- = {
- if (= wcsicmp(argv[i], L"--hwid") =3D=3D 0)
- {
- memset(szzHwId, 0, sizeof(szzHwId));
- ++i;

- memcpy_s(sz= zHwId,
- = sizeof(szzHwId) - 2 * sizeof(WCHAR) /*requires double zero termin= ation*/,
- = argv[i], wcslen(argv[i]) * sizeof(WCHAR));
- }
- else
- {
- fwprintf(
- stderr,
- L"Unknown option \"%ls&= quot;
- = L"\". Please, use \"tapctl help list\" to list supp= orted options. Ignored.\n",
- argv[i]);
- }
- }
-<= /span>
- /* Output list= of adapters with given hardware ID. */
- struct tap_adapter_node *pAdapterList =3D NULL;
- DWORD dwResult = =3D tap_list_adapters(NULL, szzHwId, &pAdapterList);
- if (dwResult !=3D ERROR_SUCCESS)=
- {
<= span style=3D"color: hsl(0, 100%, 40%);">- fwprintf(stderr, L&qu= ot;Enumerating TUN/TAP adapters failed (error 0x%x).\n", dwResult);
- iResult =3D = 1;
- goto qu= it;
- }-
- for (struct tap_adapter_node *pAdapter =3D = pAdapterList; pAdapter; pAdapter =3D pAdapter->pNext)
- {
- LPOLESTR szAdapterId =3D NULL;- StringFromIID((REFI= ID)&pAdapter->guid, &szAdapterId);
- fwprintf(stdout,
- L"%ls\t%"
- L&q= uot;ls\n",
- = szAdapterId, pAdapter->szName);
- CoTaskMemFree(szAdapterId);<= br>- }
-
- iResult =3D 0;
- tap_free_adapter_list(pAdapterList);
+ iResult =3D tapctl_cmd_list(= argc, argv);
+ = goto quit;
}
else if (wcsicmp(ar= gv[1], L"delete") =3D=3D 0)
{
- if (argc < 3)

<= span style=3D"color: hsl(0, 100%, 40%);">- {

- fwprintf(
- stderr,
- L"Missing adapter GU= ID or name. Please, use \"tapctl help delete\" for usage info.\n&= quot;);
- re= turn 1;
- }
-
- GUID guidAdapter;
- if (FAILED(IIDFromString(argv[2], (= LPIID)&guidAdapter)))
- {
- = /* The argument failed to covert to GUID. Treat it as the adapter name.= */
- struct= tap_adapter_node *pAdapterList =3D NULL;
- DWORD dwResult =3D tap_list_adapters(NULL, = NULL, &pAdapterList);
- if (dwResult !=3D ERROR_SUCCESS)
- {
- fwprintf(stderr, L"Enumerating TUN/= TAP adapters failed (error 0x%x).\n", dwResult);
- iResult =3D 1;
- goto quit;
<= br>- }
-

- for (struct tap_adapter_node *pAdapter =3D pAd= apterList;; pAdapter =3D pAdapter->pNext)
- {
- if (pAdapter =3D=3D NULL)
- {
- fwprintf(stderr, L"= ;\"%ls\" adapter not found.\n", argv[2]);
- iResult =3D 1;
- goto de= lete_cleanup_pAdapterList;
- }
= - else if (wcsicmp(argv[2], pAdapter->szName) =3D=3D 0)
- {
- memcpy(= &guidAdapter, &pAdapter->guid, sizeof(GUID));
- break;
- }

- }
-
- iResult =3D 0;
-
-delete_cl= eanup_pAdapterList:
- = tap_free_adapter_list(pAdapterList);
- if (iResult)
- {
- goto quit;
- }
- }
-
- /* Delet= e the network adapter. */
- DWORD dwResult =3D tap_delete_adapter(NULL, &guidAdapter, &= amp;bRebootRequired);
-= if (dwResult !=3D ERROR_SUCCESS)
- {
- fwprintf(stderr,
- L"Deleting adapter \"%ls"=
- = L"\" failed (error 0x%x).\n",
- argv[2], dwResult);
<= span style=3D"color: hsl(0, 100%, 40%);">- iResult =3D 1;
=
- goto quit;
- }
-
- iResult =3D 0;
+ iResult =3D tapctl_cmd_delete(argc, argv, &bR= ebootRequired);
goto quit;
}<= /span>
else

To view, visi= t change= 1335. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4d822bf7ae5f037e2414778e8fa= 74eca5e289e65
Gerrit-Change-Number: 1335
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --4nfLVmHhNoc=--