From patchwork Wed Feb 5 06:55:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Rozman X-Patchwork-Id: 976 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id 4J+PJwICO14hVwAAIUCqbw for ; Wed, 05 Feb 2020 12:57:22 -0500 Received: from proxy5.mail.iad3b.rsapps.net ([172.31.255.6]) by director7.mail.ord1d.rsapps.net with LMTP id OG2uJAICO17HWQAAovjBpQ ; Wed, 05 Feb 2020 12:57:22 -0500 Received: from smtp8.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy5.mail.iad3b.rsapps.net with LMTP id +J2bHgICO15lOQAA13hMnw ; Wed, 05 Feb 2020 12:57:22 -0500 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: smtp8.gate.iad3b.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: f4968cc8-4840-11ea-b959-5254005eee35-1-1 Received: from [216.105.38.7] ([216.105.38.7:39406] helo=lists.sourceforge.net) by smtp8.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id AB/DF-04452-1020B3E5; Wed, 05 Feb 2020 12:57:21 -0500 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1izOuV-00028X-EE; Wed, 05 Feb 2020 17:56:23 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1izOuU-00028Q-22 for openvpn-devel@lists.sourceforge.net; Wed, 05 Feb 2020 17:56:22 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=NPzYm5f0XtURK3DX/tRJ9X88F4ei4PJ2Fq3lenDTi7M=; b=EJT8ndQILHA9uOsnYEn3oA9eLt UA0M2ULo9DZu+w/jhOYRV3tMzkBugldBOJXNgdRPikfax42n2eTK4vXX8yhkD/vOzvUhfTTj+mf0z H2wJdtC3wxdRh4BUXOw7h61jmed1C8T2LYY9asBJFbePySIWPE3FGmsyC53FH3dnIw7o=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=NPzYm5f0XtURK3DX/tRJ9X88F4ei4PJ2Fq3lenDTi7M=; b=J i0PafIU6aLi7tXPBkoegcy+fIA//qLZ8z7Ec+y1jPxNlagDO6wxVzzsim3p5nRTRQ581DxBoEd2y8 p6uZHoMVXXIN3Pqo7fhWVp/lCcUETBnZ6KpGAUk8/6APf4p9hPBYdVh1BiIRVO2WCI8hjpTmpoueS BSD0ya/k+2HgZddw=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1izOuP-00B8rg-AF for openvpn-devel@lists.sourceforge.net; Wed, 05 Feb 2020 17:56:22 +0000 Received: by pub5.amebis.si (Postfix, from userid 1000) id 474291002FBE; Wed, 5 Feb 2020 18:56:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1580925361; bh=NPzYm5f0XtURK3DX/tRJ9X88F4ei4PJ2Fq3lenDTi7M=; h=From:To:Cc:Subject:Date:From; b=sjShO0qOGUMhskO8kKwcoUO33vaexUCka7C/RQxJ1A8WZrCnwMMypNMtxIpaetg4L YrFweAPA4MY/RuVBrWytFAqON12t6MX0YPVCcRu1dxRvxe1gAHtQa507ps7lnz1ZC4 FDaphhwEZE6oqdEqSVJSBWgGJrgLHkMX6n8o3Qa8= 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=unavailable autolearn_force=no version=3.4.3 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:dc1d:9533:3ace:bf6b]) by pub5.amebis.si (Postfix) with ESMTP id B818C1002FB5; Wed, 5 Feb 2020 18:55:58 +0100 (CET) From: Simon Rozman To: openvpn-devel@lists.sourceforge.net Date: Wed, 5 Feb 2020 18:55:56 +0100 Message-Id: <20200205175556.1877-1-simon@rozman.si> X-Mailer: git-send-email 2.24.1.windows.2 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rozman.si] -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: 1izOuP-00B8rg-AF Subject: [Openvpn-devel] [PATCH] tun.c: refactor driver detection and make it case-insensitive 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 Hardware IDs are case insensitive on Windows. Furthermore the driver detection logic has been made more explicit and easier to read. Signed-off-by: Simon Rozman Acked-by: Lev Stipakov --- src/openvpn/tun.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index af09e676..070b0fa0 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -3692,11 +3692,19 @@ get_tap_reg(struct gc_arena *gc) if (status == ERROR_SUCCESS && data_type == REG_SZ) { + /* Is this adapter supported? */ enum windows_driver_type windows_driver = WINDOWS_DRIVER_UNSPECIFIED; + if (strcasecmp(component_id, TAP_WIN_COMPONENT_ID) == 0 || + strcasecmp(component_id, "root\\" TAP_WIN_COMPONENT_ID) == 0) + { + windows_driver = WINDOWS_DRIVER_TAP_WINDOWS6; + } + else if (strcasecmp(component_id, WINTUN_COMPONENT_ID) == 0) + { + windows_driver = WINDOWS_DRIVER_WINTUN; + } - if ((windows_driver = WINDOWS_DRIVER_TAP_WINDOWS6, !strcmp(component_id, TAP_WIN_COMPONENT_ID)) - || (windows_driver = WINDOWS_DRIVER_TAP_WINDOWS6, !strcmp(component_id, "root\\" TAP_WIN_COMPONENT_ID)) - || (windows_driver = WINDOWS_DRIVER_WINTUN, !strcmp(component_id, WINTUN_COMPONENT_ID))) + if (windows_driver != WINDOWS_DRIVER_UNSPECIFIED) { struct tap_reg *reg; ALLOC_OBJ_CLEAR_GC(reg, struct tap_reg, gc);