OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::IP::PoolType< ADDR > Class Template Reference

#include <pool.hpp>

Public Member Functions

 PoolType ()=default
 
void add_range (const RangeType< ADDR > &range)
 Adds range of addresses to pool (pool will own the addresses).
 
void add_addr (const ADDR &addr)
 
size_t n_in_use () const noexcept
 Returns number of pool addresses currently in use.
 
size_t n_free () const noexcept
 Returns number of free pool addresses.
 
bool acquire_addr (ADDR &dest)
 
bool acquire_specific_addr (const ADDR &addr)
 Acquires a specific address from the pool.
 
void release_addr (const ADDR &addr)
 
virtual void freelist_fill ()
 
std::string to_string () const
 
virtual ~PoolType ()=default
 

Private Member Functions

auto is_address_available (const ADDR &addr) -> std::optional< decltype(map.begin())>
 Checks if address is available (free)
 
auto is_address_in_use (const ADDR &addr) -> std::optional< decltype(map.begin())>
 Checks if address is in use.
 

Private Attributes

std::deque< ADDR > freelist
 
std::unordered_map< ADDR, bool > map
 

Detailed Description

template<typename ADDR>
class openvpn::IP::PoolType< ADDR >

Definition at line 29 of file pool.hpp.

Constructor & Destructor Documentation

◆ PoolType()

template<typename ADDR >
openvpn::IP::PoolType< ADDR >::PoolType ( )
default

◆ ~PoolType()

template<typename ADDR >
virtual openvpn::IP::PoolType< ADDR >::~PoolType ( )
virtualdefault

Member Function Documentation

◆ acquire_addr()

template<typename ADDR >
bool openvpn::IP::PoolType< ADDR >::acquire_addr ( ADDR &  dest)
inline

Definition at line 76 of file pool.hpp.

Here is the caller graph for this function:

◆ acquire_specific_addr()

template<typename ADDR >
bool openvpn::IP::PoolType< ADDR >::acquire_specific_addr ( const ADDR &  addr)
inline

Acquires a specific address from the pool.

This function attempts to acquire a specific address from the pool. If the address is available, it marks the address as in use and returns true. If the address is not available, it returns false.

Parameters
addrThe IP address to acquire.
Returns
true if the address was successfully acquired, false otherwise.

Definition at line 108 of file pool.hpp.

Here is the caller graph for this function:

◆ add_addr()

template<typename ADDR >
void openvpn::IP::PoolType< ADDR >::add_addr ( const ADDR &  addr)
inline

Definition at line 47 of file pool.hpp.

Here is the caller graph for this function:

◆ add_range()

template<typename ADDR >
void openvpn::IP::PoolType< ADDR >::add_range ( const RangeType< ADDR > &  range)
inline

Adds range of addresses to pool (pool will own the addresses).

Parameters
rangeRangeType of IP Addresses

Definition at line 38 of file pool.hpp.

Here is the caller graph for this function:

◆ freelist_fill()

template<typename ADDR >
virtual void openvpn::IP::PoolType< ADDR >::freelist_fill ( )
inlinevirtual

Definition at line 133 of file pool.hpp.

Here is the caller graph for this function:

◆ is_address_available()

template<typename ADDR >
auto openvpn::IP::PoolType< ADDR >::is_address_available ( const ADDR &  addr) -> std::optional<decltype(map.begin())>
inlineprivate

Checks if address is available (free)

Parameters
addrIP Address to check
Returns
Optional iterator to position; std::nullopt if address is not available

Definition at line 162 of file pool.hpp.

Here is the caller graph for this function:

◆ is_address_in_use()

template<typename ADDR >
auto openvpn::IP::PoolType< ADDR >::is_address_in_use ( const ADDR &  addr) -> std::optional<decltype(map.begin())>
inlineprivate

Checks if address is in use.

Parameters
addrIP Address to check
Returns
Optional containing iterator to position if found, std::nullopt otherwise

Definition at line 175 of file pool.hpp.

Here is the caller graph for this function:

◆ n_free()

template<typename ADDR >
size_t openvpn::IP::PoolType< ADDR >::n_free ( ) const
inlinenoexcept

Returns number of free pool addresses.

Returns
number of free pool addresses

Definition at line 69 of file pool.hpp.

◆ n_in_use()

template<typename ADDR >
size_t openvpn::IP::PoolType< ADDR >::n_in_use ( ) const
inlinenoexcept

Returns number of pool addresses currently in use.

Returns
number of pool addresses currently in use

Definition at line 60 of file pool.hpp.

Here is the caller graph for this function:

◆ release_addr()

template<typename ADDR >
void openvpn::IP::PoolType< ADDR >::release_addr ( const ADDR &  addr)
inline

Definition at line 122 of file pool.hpp.

Here is the caller graph for this function:

◆ to_string()

template<typename ADDR >
std::string openvpn::IP::PoolType< ADDR >::to_string ( ) const
inline

Definition at line 137 of file pool.hpp.

Member Data Documentation

◆ freelist

template<typename ADDR >
std::deque<ADDR> openvpn::IP::PoolType< ADDR >::freelist
private

Definition at line 154 of file pool.hpp.

◆ map

template<typename ADDR >
std::unordered_map<ADDR, bool> openvpn::IP::PoolType< ADDR >::map
private

Definition at line 155 of file pool.hpp.


The documentation for this class was generated from the following file: