From patchwork Mon Mar 9 02:17:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rozman X-Patchwork-Id: 1027 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id aLPvF1VCZl6tHAAAIUCqbw for ; Mon, 09 Mar 2020 09:19:17 -0400 Received: from proxy19.mail.ord1d.rsapps.net ([172.30.191.6]) by director8.mail.ord1d.rsapps.net with LMTP id qFfFF1VCZl7cagAAfY0hYg ; Mon, 09 Mar 2020 09:19:17 -0400 Received: from smtp22.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy19.mail.ord1d.rsapps.net with LMTP id CHOpF1VCZl4HRAAAyH2SIw ; Mon, 09 Mar 2020 09:19:17 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp22.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=rozman.si; dmarc=fail (p=none; dis=none) header.from=rozman.si X-Suspicious-Flag: YES X-Classification-ID: 93a724d6-6208-11ea-940d-5254001a15c2-1-1 Received: from [216.105.38.7] ([216.105.38.7:49344] helo=lists.sourceforge.net) by smtp22.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 3B/2E-10879-452466E5; Mon, 09 Mar 2020 09:19:17 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jBIIQ-00028J-CX; Mon, 09 Mar 2020 13:18:14 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jBIIO-00027l-Dl for openvpn-devel@lists.sourceforge.net; Mon, 09 Mar 2020 13:18:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Uouv4Uj+M/7ncyneH03jNhbDyh4XS2AG3CpgPWkVTaE=; b=DxqaoT8i/eqO5Y5wOrTkrm0HBM w2Jzo+gkKMrV1AQJhZzlEHNHe4eHUdTPelBKqryOwPUsRQGBeNeARPz0xHgG5weTFJadsFobYtRPo npn8A0klyolC0T8SnGdgKjxpbg/0vckSuVW/AcBTcLyix7viilTRMLoD8sM1Y0qrUc9I=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Uouv4Uj+M/7ncyneH03jNhbDyh4XS2AG3CpgPWkVTaE=; b=M03674bZB6dTDZv1UZGveeYQKi HhmBEcH28ZzWCgPpd1fpZ63KHovHVpCy23qJGFDa9dRBiaDHntoWlgeYEcqx5Yi0cacYoNW/dd/zy mB+4xTZsEkp+wVzHFf0HuZXpsDhie5ujvhJc5XLFOSlgmy0tSKh0LDc+30Ed0y2lcJd4=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jBIIL-0033PO-1z for openvpn-devel@lists.sourceforge.net; Mon, 09 Mar 2020 13:18:12 +0000 Received: by pub5.amebis.si (Postfix, from userid 1000) id D46401002FB6; Mon, 9 Mar 2020 14:17:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1583759877; bh=Uouv4Uj+M/7ncyneH03jNhbDyh4XS2AG3CpgPWkVTaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zq+x9/sPMhXY0vYCdijg4IWebwaIkdZ0RxdZw+LU42XN78bMXFoDFmiGZ2Th6IUwM ANmYtX1iHgCJrTsUBw5DgDcTlcpWlc01BmJGtVJ7UBOsmQYBRlNocz3mfiAo6tbcHS Co+db0VxyQo66uSgtYfe2xxbPGuoPby/+oR0n328= X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on brana.amebis.doma X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.3 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:a5ae:e83c:b7b:725]) by pub5.amebis.si (Postfix) with ESMTP id 487E91002FBE; Mon, 9 Mar 2020 14:17:49 +0100 (CET) From: Simon Rozman To: openvpn-devel@lists.sourceforge.net Date: Mon, 9 Mar 2020 14:17:22 +0100 Message-Id: <20200309131728.380-6-simon@rozman.si> X-Mailer: git-send-email 2.24.1.windows.2 In-Reply-To: <20200309131728.380-1-simon@rozman.si> References: <20200309131728.380-1-simon@rozman.si> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1jBIIL-0033PO-1z Subject: [Openvpn-devel] [PATCH 06/12] openvpnmsica: Simplify static function names X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Signed-off-by: Simon Rozman Acked-by: Lev Stipakov --- src/openvpnmsica/openvpnmsica.c | 63 +++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c index 4c186b13..749dce56 100644 --- a/src/openvpnmsica/openvpnmsica.c +++ b/src/openvpnmsica/openvpnmsica.c @@ -72,7 +72,7 @@ * @return ERROR_SUCCESS on success; An error code otherwise */ static UINT -openvpnmsica_setup_sequence( +setup_sequence( _In_ MSIHANDLE hInstall, _In_z_ LPCTSTR szProperty, _In_ struct msica_arg_seq *seq) @@ -101,7 +101,7 @@ openvpnmsica_setup_sequence( * title. */ static void -_openvpnmsica_debug_popup(_In_z_ LPCTSTR szFunctionName) +_debug_popup(_In_z_ LPCTSTR szFunctionName) { TCHAR szTitle[0x100], szMessage[0x100+MAX_PATH], szProcessPath[MAX_PATH]; @@ -129,9 +129,9 @@ _openvpnmsica_debug_popup(_In_z_ LPCTSTR szFunctionName) MessageBox(NULL, szMessage, szTitle, MB_OK); } -#define openvpnmsica_debug_popup(f) _openvpnmsica_debug_popup(f) +#define debug_popup(f) _debug_popup(f) #else /* ifdef _DEBUG */ -#define openvpnmsica_debug_popup(f) +#define debug_popup(f) #endif /* ifdef _DEBUG */ @@ -146,7 +146,7 @@ _openvpnmsica_debug_popup(_In_z_ LPCTSTR szFunctionName) * See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa368072.aspx */ static UINT -openvpnmsica_set_openvpnserv_state(_In_ MSIHANDLE hInstall) +set_openvpnserv_state(_In_ MSIHANDLE hInstall) { UINT uiResult; @@ -255,13 +255,13 @@ FindSystemInfo(_In_ MSIHANDLE hInstall) #pragma comment(linker, DLLEXP_EXPORT) #endif - openvpnmsica_debug_popup(TEXT(__FUNCTION__)); + debug_popup(TEXT(__FUNCTION__)); BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL)); OPENVPNMSICA_SAVE_MSI_SESSION(hInstall); - openvpnmsica_set_openvpnserv_state(hInstall); + set_openvpnserv_state(hInstall); if (bIsCoInitialized) { @@ -278,7 +278,7 @@ FindTAPInterfaces(_In_ MSIHANDLE hInstall) #pragma comment(linker, DLLEXP_EXPORT) #endif - openvpnmsica_debug_popup(TEXT(__FUNCTION__)); + debug_popup(TEXT(__FUNCTION__)); UINT uiResult; BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL)); @@ -444,7 +444,7 @@ CloseOpenVPNGUI(_In_ MSIHANDLE hInstall) #endif UNREFERENCED_PARAMETER(hInstall); /* This CA is does not interact with MSI session (report errors, access properties, tables, etc.). */ - openvpnmsica_debug_popup(TEXT(__FUNCTION__)); + debug_popup(TEXT(__FUNCTION__)); /* Find OpenVPN GUI window. */ HWND hWnd = FindWindow(TEXT("OpenVPN-GUI"), NULL); @@ -466,7 +466,7 @@ StartOpenVPNGUI(_In_ MSIHANDLE hInstall) #pragma comment(linker, DLLEXP_EXPORT) #endif - openvpnmsica_debug_popup(TEXT(__FUNCTION__)); + debug_popup(TEXT(__FUNCTION__)); UINT uiResult; BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL)); @@ -564,7 +564,11 @@ cleanup_CoInitialize: * @return ERROR_SUCCESS on success; An error code otherwise */ static DWORD -openvpnmsica_schedule_interface_create(_Inout_ struct msica_arg_seq *seq, _Inout_opt_ struct msica_arg_seq *seqRollback, _In_z_ LPCTSTR szDisplayName, _Inout_ int *iTicks) +schedule_interface_create( + _Inout_ struct msica_arg_seq *seq, + _Inout_opt_ struct msica_arg_seq *seqRollback, + _In_z_ LPCTSTR szDisplayName, + _Inout_ int *iTicks) { /* Get all available network interfaces. */ struct tap_interface_node *pInterfaceList = NULL; @@ -658,7 +662,12 @@ cleanup_pInterfaceList: * @return ERROR_SUCCESS on success; An error code otherwise */ static DWORD -openvpnmsica_schedule_interface_delete(_Inout_ struct msica_arg_seq *seq, _Inout_opt_ struct msica_arg_seq *seqCommit, _Inout_opt_ struct msica_arg_seq *seqRollback, _In_z_ LPCTSTR szDisplayName, _Inout_ int *iTicks) +schedule_interface_delete( + _Inout_ struct msica_arg_seq *seq, + _Inout_opt_ struct msica_arg_seq *seqCommit, + _Inout_opt_ struct msica_arg_seq *seqRollback, + _In_z_ LPCTSTR szDisplayName, + _Inout_ int *iTicks) { /* Get available TUN/TAP interfaces. */ struct tap_interface_node *pInterfaceList = NULL; @@ -725,7 +734,7 @@ EvaluateTAPInterfaces(_In_ MSIHANDLE hInstall) #pragma comment(linker, DLLEXP_EXPORT) #endif - openvpnmsica_debug_popup(TEXT(__FUNCTION__)); + debug_popup(TEXT(__FUNCTION__)); UINT uiResult; BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL)); @@ -887,7 +896,7 @@ EvaluateTAPInterfaces(_In_ MSIHANDLE hInstall) free(szValue); /* Component is or should be installed. Schedule interface creation. */ - if (openvpnmsica_schedule_interface_create( + if (schedule_interface_create( &seqInstallTAPInterfaces, bRollbackEnabled ? &seqInstallTAPInterfacesRollback : NULL, szDisplayNameEx, @@ -904,7 +913,7 @@ EvaluateTAPInterfaces(_In_ MSIHANDLE hInstall) * Note: On interface removal (product is being uninstalled), we tolerate dwResult error. * Better a partial uninstallation than no uninstallation at all. */ - openvpnmsica_schedule_interface_delete( + schedule_interface_delete( &seqUninstallTAPInterfaces, bRollbackEnabled ? &seqUninstallTAPInterfacesCommit : NULL, bRollbackEnabled ? &seqUninstallTAPInterfacesRollback : NULL, @@ -934,12 +943,12 @@ cleanup_hRecord: } /* Store deferred custom action parameters. */ - if ((uiResult = openvpnmsica_setup_sequence(hInstall, TEXT("InstallTAPInterfaces" ), &seqInstallTAPInterfaces )) != ERROR_SUCCESS - || (uiResult = openvpnmsica_setup_sequence(hInstall, TEXT("InstallTAPInterfacesCommit" ), &seqInstallTAPInterfacesCommit )) != ERROR_SUCCESS - || (uiResult = openvpnmsica_setup_sequence(hInstall, TEXT("InstallTAPInterfacesRollback" ), &seqInstallTAPInterfacesRollback )) != ERROR_SUCCESS - || (uiResult = openvpnmsica_setup_sequence(hInstall, TEXT("UninstallTAPInterfaces" ), &seqUninstallTAPInterfaces )) != ERROR_SUCCESS - || (uiResult = openvpnmsica_setup_sequence(hInstall, TEXT("UninstallTAPInterfacesCommit" ), &seqUninstallTAPInterfacesCommit )) != ERROR_SUCCESS - || (uiResult = openvpnmsica_setup_sequence(hInstall, TEXT("UninstallTAPInterfacesRollback"), &seqUninstallTAPInterfacesRollback)) != ERROR_SUCCESS) + if ((uiResult = setup_sequence(hInstall, TEXT("InstallTAPInterfaces" ), &seqInstallTAPInterfaces )) != ERROR_SUCCESS + || (uiResult = setup_sequence(hInstall, TEXT("InstallTAPInterfacesCommit" ), &seqInstallTAPInterfacesCommit )) != ERROR_SUCCESS + || (uiResult = setup_sequence(hInstall, TEXT("InstallTAPInterfacesRollback" ), &seqInstallTAPInterfacesRollback )) != ERROR_SUCCESS + || (uiResult = setup_sequence(hInstall, TEXT("UninstallTAPInterfaces" ), &seqUninstallTAPInterfaces )) != ERROR_SUCCESS + || (uiResult = setup_sequence(hInstall, TEXT("UninstallTAPInterfacesCommit" ), &seqUninstallTAPInterfacesCommit )) != ERROR_SUCCESS + || (uiResult = setup_sequence(hInstall, TEXT("UninstallTAPInterfacesRollback"), &seqUninstallTAPInterfacesRollback)) != ERROR_SUCCESS) { goto cleanup_hRecordProg; } @@ -979,7 +988,9 @@ cleanup_exec_seq: * @return TRUE on success; FALSE otherwise */ static BOOL -openvpnmsica_parse_guid(_In_z_ LPCWSTR szArg, _Out_ GUID *guid) +parse_guid( + _In_z_ LPCWSTR szArg, + _Out_ GUID *guid) { if (swscanf_s(szArg, _L(PRIXGUID), PRIGUID_PARAM_REF(*guid)) != 11) { @@ -997,7 +1008,7 @@ ProcessDeferredAction(_In_ MSIHANDLE hInstall) #pragma comment(linker, DLLEXP_EXPORT) #endif - openvpnmsica_debug_popup(TEXT(__FUNCTION__)); + debug_popup(TEXT(__FUNCTION__)); UINT uiResult; BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL)); @@ -1112,7 +1123,7 @@ ProcessDeferredAction(_In_ MSIHANDLE hInstall) { /* Delete the interface by GUID. */ GUID guid; - if (!openvpnmsica_parse_guid(szArg[i] + 7, &guid)) + if (!parse_guid(szArg[i] + 7, &guid)) { goto invalid_argument; } @@ -1122,7 +1133,7 @@ ProcessDeferredAction(_In_ MSIHANDLE hInstall) { /* Enable the interface. */ GUID guid; - if (!openvpnmsica_parse_guid(szArg[i] + 7, &guid)) + if (!parse_guid(szArg[i] + 7, &guid)) { goto invalid_argument; } @@ -1132,7 +1143,7 @@ ProcessDeferredAction(_In_ MSIHANDLE hInstall) { /* Disable the interface. */ GUID guid; - if (!openvpnmsica_parse_guid(szArg[i] + 8, &guid)) + if (!parse_guid(szArg[i] + 8, &guid)) { goto invalid_argument; }