From patchwork Thu Jun 7 19:20:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 355 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.28.255.1]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id syQUEmISGlsqKgAAIUCqbw for ; Fri, 08 Jun 2018 01:21:38 -0400 Received: from director9.mail.ord1c.rsapps.net ([172.28.255.1]) by director12.mail.ord1d.rsapps.net (Dovecot) with LMTP id mfxJAWISGlsjCAAAIasKDg ; Fri, 08 Jun 2018 01:21:38 -0400 Received: from smtp12.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director9.mail.ord1c.rsapps.net with LMTP id eMiZEWISGlvnCwAA4V03VA ; Fri, 08 Jun 2018 01:21:38 -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: smtp12.gate.ord1c.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=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: d11e5314-6adb-11e8-b809-bc305bf03e5c-1-1 Received: from [216.105.38.7] ([216.105.38.7:33841] helo=lists.sourceforge.net) by smtp12.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id E5/39-06599-1621A1B5; Fri, 08 Jun 2018 01:21:38 -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.90_1) (envelope-from ) id 1fR9pc-00048o-2T; Fri, 08 Jun 2018 05:21:00 +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 1fR9pb-00048e-Pt for openvpn-devel@lists.sourceforge.net; Fri, 08 Jun 2018 05:20:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=y20EsHFTH7Nm999WxYe5EwtdobaiwtaRBeL8ihmO0gk=; b=XNqq/74zjVOi60KBCus4Q6uaVL 30XEihKgkh7ui2EQ2AS0+aqeq/ZBiG4qKKWr9pSVpTRfqWx/NIWOJ3lNQOLkbtEU52RpTriWW4tG2 039haszZIUkpUGsMLHaQZZiqCyDd0wNJQ6qPOFIn5/3gxfWgBktDguiSwjN1zh5j8ZIg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding: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=y20EsHFTH7Nm999WxYe5EwtdobaiwtaRBeL8ihmO0gk=; b=fQ1JeOJ7ugJDQKebf5YyuokHW0 zIQJ3H5tRuQcTifh0kf9WbnLWGdpEb9ulVTiDcMc3Q8+hjzH41Wxc44HKbyK3I5kowmXgAA42HhGe CoueI1cGil4U/MfuTVm6gYCwBLLYAU8JdJYlLwkQBtUcuY2vXxSxPm21SAH7PTz+sTcQ=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1fR9pZ-003Txw-SB for openvpn-devel@lists.sourceforge.net; Fri, 08 Jun 2018 05:20:59 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Fri, 8 Jun 2018 13:20:12 +0800 Message-Id: <20180608052017.6696-4-a@unstable.cc> In-Reply-To: <20180608052017.6696-1-a@unstable.cc> References: <20180608052017.6696-1-a@unstable.cc> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [5.148.176.60 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1fR9pZ-003Txw-SB Subject: [Openvpn-devel] [PATCH v2 3/8] pool: convert pool 'type' to enum 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: , Cc: Antonio Quartulli MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Antonio Quartulli The pool 'type' member is actually an enumered type, therefore declare it as 'enum' to improve static code analisys and readability. Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- src/openvpn/pool.c | 2 +- src/openvpn/pool.h | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/openvpn/pool.c b/src/openvpn/pool.c index 26eb0ebd..5d503a33 100644 --- a/src/openvpn/pool.c +++ b/src/openvpn/pool.c @@ -147,7 +147,7 @@ ifconfig_pool_verify_range(const int msglevel, const in_addr_t start, const in_a } struct ifconfig_pool * -ifconfig_pool_init(int type, in_addr_t start, in_addr_t end, +ifconfig_pool_init(enum pool_type type, in_addr_t start, in_addr_t end, const bool duplicate_cn, const bool ipv6_pool, const struct in6_addr ipv6_base, const int ipv6_netbits ) diff --git a/src/openvpn/pool.h b/src/openvpn/pool.h index 544d4180..73ea5599 100644 --- a/src/openvpn/pool.h +++ b/src/openvpn/pool.h @@ -34,8 +34,11 @@ #define IFCONFIG_POOL_MAX 65536 #define IFCONFIG_POOL_MIN_NETBITS 16 -#define IFCONFIG_POOL_30NET 0 -#define IFCONFIG_POOL_INDIV 1 +enum pool_type +{ + IFCONFIG_POOL_30NET, + IFCONFIG_POOL_INDIV +}; struct ifconfig_pool_entry { @@ -49,7 +52,7 @@ struct ifconfig_pool { bool duplicate_cn; struct { - int type; + enum pool_type type; in_addr_t base; int size; } ipv4; @@ -69,7 +72,7 @@ struct ifconfig_pool_persist typedef int ifconfig_pool_handle; -struct ifconfig_pool *ifconfig_pool_init(int type, in_addr_t start, in_addr_t end, const bool duplicate_cn, const bool ipv6_pool, const struct in6_addr ipv6_base, const int ipv6_netbits ); +struct ifconfig_pool *ifconfig_pool_init(enum pool_type type, in_addr_t start, in_addr_t end, const bool duplicate_cn, const bool ipv6_pool, const struct in6_addr ipv6_base, const int ipv6_netbits ); void ifconfig_pool_free(struct ifconfig_pool *pool);