From patchwork Fri Mar 19 04:31:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1636 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id +H/yOh/EVGBkSAAAIUCqbw (envelope-from ) for ; Fri, 19 Mar 2021 11:32:47 -0400 Received: from proxy18.mail.iad3b.rsapps.net ([172.31.255.6]) by director9.mail.ord1d.rsapps.net with LMTP id KB/sOh/EVGAPIgAAalYnBA (envelope-from ) for ; Fri, 19 Mar 2021 11:32:47 -0400 Received: from smtp2.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy18.mail.iad3b.rsapps.net with LMTPS id CLOjMh/EVGAiWAAA3NpJmQ (envelope-from ) for ; Fri, 19 Mar 2021 11:32:47 -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: smtp2.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; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 5ac8a65c-88c8-11eb-ac77-5254000fbace-1-1 Received: from [216.105.38.7] ([216.105.38.7:49186] helo=lists.sourceforge.net) by smtp2.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id AC/09-28034-E14C4506; Fri, 19 Mar 2021 11:32:47 -0400 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.92.3) (envelope-from ) id 1lNH6M-00067c-KC; Fri, 19 Mar 2021 15:31:50 +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.92.3) (envelope-from ) id 1lNH6E-000679-Ao for openvpn-devel@lists.sourceforge.net; Fri, 19 Mar 2021 15:31:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding: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=MHRBdXLWB5NAHZTOsXSMbh8jUuQAxx9QsYt/CNJBuGE=; b=LId6jyIhOxM6ebNxT8BEAw8UdX on8o7Wo2SBatWZ9IK/vai+3eSUkiuABckqJ7tj0jCq2AIaG4xjWtuGzG8HpngAVcUIkQECAERZ5A0 pL8/Adiogwx8CrM3np1RIwtTRBchp+eeSB6uClRvC7lnGNCiEbkZWUE1PlIJzZNSoC3Y=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version: Content-Type:Content-Transfer-Encoding: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=MHRBdXLWB5NAHZTOsXSMbh8jUuQAxx9QsYt/CNJBuGE=; b=Y43Grv4bDHcWGdAgPgVK+dEhQe uabfoDLXL20vADXchH8DcUpTNqlCiXfnM8lWcIYlSlxmShANGv5QbKJpCwIdFYQbFTtxHNUxSVZUM ocC4HKKyZ33Z/Zug/ete7sC4ISdkY67GLGE0YUxX6RWFM4RMSe39J/UQWETkImIh+jO4=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lNH69-00029R-01 for openvpn-devel@lists.sourceforge.net; Fri, 19 Mar 2021 15:31:40 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1lNH61-000Mo3-ON for openvpn-devel@lists.sourceforge.net; Fri, 19 Mar 2021 16:31:29 +0100 Received: (nullmailer pid 8778 invoked by uid 10006); Fri, 19 Mar 2021 15:31:29 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Fri, 19 Mar 2021 16:31:28 +0100 Message-Id: <20210319153129.8734-1-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 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: rfc2549.org] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1lNH69-00029R-01 Subject: [Openvpn-devel] [PATCH 1/2] Move extract_iv_proto to ssl_util.c/h 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This function is used by both NCP and push, so move it to a more proper place. Signed-off-by: Arne Schwabe Acked-By: David Sommerseth --- src/openvpn/multi.c | 1 + src/openvpn/push.c | 18 +----------------- src/openvpn/push.h | 10 ---------- src/openvpn/ssl_util.c | 16 ++++++++++++++++ src/openvpn/ssl_util.h | 8 ++++++++ 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index d10f188c..f7e0f680 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -51,6 +51,7 @@ #include "crypto_backend.h" +#include "ssl_util.h" /*#define MULTI_DEBUG_EVENT_LOOP*/ diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 320ad737..a6519557 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -37,6 +37,7 @@ #include "manage.h" #include "memdbg.h" +#include "ssl_util.h" #if P2MP @@ -1057,21 +1058,4 @@ remove_iroutes_from_push_route_list(struct options *o) gc_free(&gc); } } - -unsigned int -extract_iv_proto(const char *peer_info) -{ - const char *optstr = peer_info ? strstr(peer_info, "IV_PROTO=") : NULL; - if (optstr) - { - int proto = 0; - int r = sscanf(optstr, "IV_PROTO=%d", &proto); - if (r == 1 && proto > 0) - { - return proto; - } - } - return 0; -} - #endif /* if P2MP */ diff --git a/src/openvpn/push.h b/src/openvpn/push.h index 377f94a6..bb787a62 100644 --- a/src/openvpn/push.h +++ b/src/openvpn/push.h @@ -91,16 +91,6 @@ void send_restart(struct context *c, const char *kill_msg); */ void send_push_reply_auth_token(struct tls_multi *multi); - -/** - * Extracts the IV_PROTO variable and returns its value or 0 - * if it cannot be extracted. - * - * @param peer_info peer info string to search for IV_PROTO - */ -unsigned int -extract_iv_proto(const char *peer_info); - /** * Parses an AUTH_PENDING message and if in pull mode extends the timeout * diff --git a/src/openvpn/ssl_util.c b/src/openvpn/ssl_util.c index a74e3b72..f6e66be4 100644 --- a/src/openvpn/ssl_util.c +++ b/src/openvpn/ssl_util.c @@ -59,3 +59,19 @@ extract_var_peer_info(const char *peer_info, const char *var, var_value[var_end - var_start] = '\0'; return var_value; } + +unsigned int +extract_iv_proto(const char *peer_info) +{ + const char *optstr = peer_info ? strstr(peer_info, "IV_PROTO=") : NULL; + if (optstr) + { + int proto = 0; + int r = sscanf(optstr, "IV_PROTO=%d", &proto); + if (r == 1 && proto > 0) + { + return proto; + } + } + return 0; +} diff --git a/src/openvpn/ssl_util.h b/src/openvpn/ssl_util.h index bc2ae30d..741a7782 100644 --- a/src/openvpn/ssl_util.h +++ b/src/openvpn/ssl_util.h @@ -46,4 +46,12 @@ extract_var_peer_info(const char *peer_info, const char *var, struct gc_arena *gc); +/** + * Extracts the IV_PROTO variable and returns its value or 0 + * if it cannot be extracted. + * + * @param peer_info peer info string to search for IV_PROTO + */ +unsigned int +extract_iv_proto(const char *peer_info); #endif