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-2018 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 #if P2MP
28 
29 /*#define IFCONFIG_POOL_TEST*/
30 
31 #include "basic.h"
32 #include "status.h"
33 
34 #define IFCONFIG_POOL_MAX 65536
35 #define IFCONFIG_POOL_MIN_NETBITS 16
36 
38 {
41 };
42 
44 {
45  bool in_use;
46  char *common_name;
47  time_t last_release;
48  bool fixed;
49 };
50 
52 {
54  struct {
55  enum pool_type type;
57  int size;
58  } ipv4;
59  struct {
60  bool enabled;
61  struct in6_addr base;
62  unsigned int size;
63  } ipv6;
65 };
66 
68 {
70  bool fixed;
71 };
72 
74 
75 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 );
76 
77 void ifconfig_pool_free(struct ifconfig_pool *pool);
78 
79 bool ifconfig_pool_verify_range(const int msglevel, const in_addr_t start, const in_addr_t end);
80 
81 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);
82 
83 bool ifconfig_pool_release(struct ifconfig_pool *pool, ifconfig_pool_handle hand, const bool hard);
84 
85 struct ifconfig_pool_persist *ifconfig_pool_persist_init(const char *filename, int refresh_freq);
86 
88 
90 
91 void ifconfig_pool_read(struct ifconfig_pool_persist *persist, struct ifconfig_pool *pool);
92 
93 void ifconfig_pool_write(struct ifconfig_pool_persist *persist, const struct ifconfig_pool *pool);
94 
95 #ifdef IFCONFIG_POOL_TEST
96 void ifconfig_pool_test(in_addr_t start, in_addr_t end);
97 
98 #endif
99 
100 #endif /* if P2MP */
101 #endif /* ifndef POOL_H */
struct ifconfig_pool_entry * list
Definition: pool.h:64
pool_type
Definition: pool.h:37
bool fixed
Definition: pool.h:48
bool ifconfig_pool_write_trigger(struct ifconfig_pool_persist *persist)
Definition: pool.c:460
#define in_addr_t
Definition: config-msvc.h:104
struct ifconfig_pool_persist * ifconfig_pool_persist_init(const char *filename, int refresh_freq)
Definition: pool.c:426
void ifconfig_pool_free(struct ifconfig_pool *pool)
Definition: pool.c:211
bool ifconfig_pool_verify_range(const int msglevel, const in_addr_t start, const in_addr_t end)
Definition: pool.c:125
int ifconfig_pool_handle
Definition: pool.h:73
in_addr_t base
Definition: pool.h:56
unsigned int size
Definition: pool.h:62
bool ifconfig_pool_release(struct ifconfig_pool *pool, ifconfig_pool_handle hand, const bool hard)
Definition: pool.c:274
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)
Definition: pool.c:150
bool duplicate_cn
Definition: pool.h:53
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:226
void ifconfig_pool_persist_close(struct ifconfig_pool_persist *persist)
Definition: pool.c:447
bool in_use
Definition: pool.h:45
char * common_name
Definition: pool.h:46
struct status_output * file
Definition: pool.h:69
time_t last_release
Definition: pool.h:47
bool enabled
Definition: pool.h:60
void ifconfig_pool_read(struct ifconfig_pool_persist *persist, struct ifconfig_pool *pool)
Definition: pool.c:473
void ifconfig_pool_write(struct ifconfig_pool_persist *persist, const struct ifconfig_pool *pool)
Definition: pool.c:528
Definition: pool.h:43
int size
Definition: pool.h:57
enum pool_type type
Definition: pool.h:55