]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
pool: convert pool 'type' to enum
authorAntonio Quartulli <antonio@openvpn.net>
Fri, 8 Jun 2018 05:20:12 +0000 (13:20 +0800)
committerGert Doering <gert@greenie.muc.de>
Fri, 8 Jun 2018 13:37:21 +0000 (15:37 +0200)
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 <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180608052017.6696-4-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17000.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/pool.c
src/openvpn/pool.h

index 26eb0ebd561b1dd8b9587a88c534bd247e5cb2b1..5d503a33008d67ef4c60770c38442f1054065be7 100644 (file)
@@ -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 )
index 544d4180ed8a667b8e73df0ce01e2c7d7bfde7f5..73ea5599505c0c995a585acca315a557efb13487 100644 (file)
 #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);