OpenVPN
pool.h
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single TCP/UDP port, with support for SSL/TLS-based
4  * session authentication and key exchange,
5  * packet encryption, packet authentication, and
6  * packet compression.
7  *
8  * Copyright (C) 2002-2023 OpenVPN Inc <sales@openvpn.net>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2
12  * as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #ifndef POOL_H
25 #define POOL_H
26 
27 /*#define IFCONFIG_POOL_TEST*/
28 
29 #include "basic.h"
30 #include "status.h"
31 
32 #define IFCONFIG_POOL_MAX 65536
33 #define IFCONFIG_POOL_MIN_NETBITS 16
34 
36 {
39 };
40 
42 {
43  bool in_use;
44  char *common_name;
45  time_t last_release;
46  bool fixed;
47 };
48 
50 {
52  struct {
53  bool enabled;
55  in_addr_t base;
56  } ipv4;
57  struct {
58  bool enabled;
59  struct in6_addr base;
60  } ipv6;
61  int size;
63 };
64 
66 {
68  bool fixed;
69 };
70 
72 
73 struct ifconfig_pool *ifconfig_pool_init(const bool ipv4_pool,
74  enum pool_type type, in_addr_t start,
75  in_addr_t end, const bool duplicate_cn,
76  const bool ipv6_pool,
77  const struct in6_addr ipv6_base,
78  const int ipv6_netbits);
79 
80 void ifconfig_pool_free(struct ifconfig_pool *pool);
81 
82 bool ifconfig_pool_verify_range(const int msglevel, const in_addr_t start, const in_addr_t end);
83 
84 ifconfig_pool_handle ifconfig_pool_acquire(struct ifconfig_pool *pool, in_addr_t *local, in_addr_t *remote, struct in6_addr *remote_ipv6, const char *common_name);
85 
86 bool ifconfig_pool_release(struct ifconfig_pool *pool, ifconfig_pool_handle hand, const bool hard);
87 
88 struct ifconfig_pool_persist *ifconfig_pool_persist_init(const char *filename, int refresh_freq);
89 
91 
93 
94 void ifconfig_pool_read(struct ifconfig_pool_persist *persist, struct ifconfig_pool *pool);
95 
96 void ifconfig_pool_write(struct ifconfig_pool_persist *persist, const struct ifconfig_pool *pool);
97 
98 #ifdef IFCONFIG_POOL_TEST
99 void ifconfig_pool_test(in_addr_t start, in_addr_t end);
100 
101 #endif
102 
103 #endif /* ifndef POOL_H */
ifconfig_pool::enabled
bool enabled
Definition: pool.h:53
ifconfig_pool_handle
int ifconfig_pool_handle
Definition: pool.h:71
ifconfig_pool_persist::file
struct status_output * file
Definition: pool.h:67
ifconfig_pool_entry::fixed
bool fixed
Definition: pool.h:46
ifconfig_pool_persist
Definition: pool.h:65
ifconfig_pool
Definition: pool.h:49
ifconfig_pool_read
void ifconfig_pool_read(struct ifconfig_pool_persist *persist, struct ifconfig_pool *pool)
Definition: pool.c:598
IFCONFIG_POOL_30NET
@ IFCONFIG_POOL_30NET
Definition: pool.h:37
ifconfig_pool_persist_close
void ifconfig_pool_persist_close(struct ifconfig_pool_persist *persist)
Definition: pool.c:572
ifconfig_pool_init
struct ifconfig_pool * ifconfig_pool_init(const bool ipv4_pool, 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)
Definition: pool.c:146
ifconfig_pool_entry::in_use
bool in_use
Definition: pool.h:43
ifconfig_pool_entry::common_name
char * common_name
Definition: pool.h:44
ifconfig_pool::list
struct ifconfig_pool_entry * list
Definition: pool.h:62
ifconfig_pool_write_trigger
bool ifconfig_pool_write_trigger(struct ifconfig_pool_persist *persist)
Definition: pool.c:585
ifconfig_pool::ipv4
struct ifconfig_pool::@10 ipv4
pool_type
pool_type
Definition: pool.h:35
status_output
Definition: status.h:48
ifconfig_pool_free
void ifconfig_pool_free(struct ifconfig_pool *pool)
Definition: pool.c:290
ifconfig_pool::duplicate_cn
bool duplicate_cn
Definition: pool.h:51
IFCONFIG_POOL_INDIV
@ IFCONFIG_POOL_INDIV
Definition: pool.h:38
ifconfig_pool::type
enum pool_type type
Definition: pool.h:54
ifconfig_pool_write
void ifconfig_pool_write(struct ifconfig_pool_persist *persist, const struct ifconfig_pool *pool)
Definition: pool.c:733
ifconfig_pool_verify_range
bool ifconfig_pool_verify_range(const int msglevel, const in_addr_t start, const in_addr_t end)
Definition: pool.c:121
ifconfig_pool_persist::fixed
bool fixed
Definition: pool.h:68
ifconfig_pool_acquire
ifconfig_pool_handle ifconfig_pool_acquire(struct ifconfig_pool *pool, in_addr_t *local, in_addr_t *remote, struct in6_addr *remote_ipv6, const char *common_name)
Definition: pool.c:306
basic.h
ifconfig_pool_release
bool ifconfig_pool_release(struct ifconfig_pool *pool, ifconfig_pool_handle hand, const bool hard)
Definition: pool.c:357
ifconfig_pool_entry::last_release
time_t last_release
Definition: pool.h:45
ifconfig_pool_persist_init
struct ifconfig_pool_persist * ifconfig_pool_persist_init(const char *filename, int refresh_freq)
Definition: pool.c:551
ifconfig_pool_entry
Definition: pool.h:41
ifconfig_pool::ipv6
struct ifconfig_pool::@11 ipv6
status.h
ifconfig_pool::base
in_addr_t base
Definition: pool.h:55
ifconfig_pool::size
int size
Definition: pool.h:61