[Openvpn-devel,3/5] pool: convert pool 'type' to enum

Message ID 20180605090421.9746-4-a@unstable.cc
State Changes Requested
Headers show
Series
  • Allow IPv6-only tunnels
Related show

Commit Message

Antonio Quartulli June 5, 2018, 9:04 a.m.
From: Antonio Quartulli <antonio@openvpn.net>

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>
---
 src/openvpn/pool.c |  2 +-
 src/openvpn/pool.h | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

Patch

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);