Kea: isc::radius::RadiusImpl Class Reference

| Kea 3.0.3-git

isc::radius::RadiusImpl Class Reference

Radius hooks library implementation. More...

`#include <radius.h>`

Inheritance diagram for isc::radius::RadiusImpl:
[legend]

## Public Member Functions
| ~RadiusImpl ()
| Destructor.
void | checkEarlyGlobalResvLookup ()
| Check the early global host reservations lookup flag.
bool | checkHostBackends ()
| Check host backends (cache and radius).
void | checkSharedNetworks ()
| Check shared network server configuration.
isc::asiolink::IOServicePtr | getIOContext ()
| Get the hook I/O service.
isc::asiolink::IOServicePtr | getIOService ()
| Get the hook I/O service.
void | init (data::ElementPtr &config)
| Initialize.
void | registerExchange (ExchangePtr exchange)
| Register Exchange.
void | reset ()
| Reset the state as it was just created.
void | setIOContext (isc::asiolink::IOServicePtr io_service)
| Set the hook I/O service.
void | setIOService (isc::asiolink::IOServicePtr io_service)
| Set the hook I/O service.
void | startServices ()
| Start the I/O mechanisms.
data::ElementPtr | toElement () const override
| Unparse implementation configuration.
void | unregisterExchange (ExchangePtr exchange)
| Unregister Exchange.
Public Member Functions inherited from isc::data::CfgToElement
virtual | ~CfgToElement ()
| Destructor.

## Static Public Member Functions
static RadiusImpl & | instance ()
| RadiusImpl is a singleton class.

## Public Attributes
boost::shared_ptr< RadiusAccounting > | acct_
| Pointer to accounting (never null).
boost::shared_ptr< RadiusAccess > | auth_
RadiusBackendPtr | backend_
| Radius backend.
std::string | bindaddr_
| bindaddr.
dhcp::CacheHostDataSourcePtr | cache_
| Host cache.
bool | canonical_mac_address_
| Canonical MAC address.
bool | clientid_pop0_
| Client Id pop leading zero(s).
bool | clientid_printable_
| Client Id try printable.
unsigned | deadtime_
| Deadtime.
std::string | dictionary_
| Dictionary path.
bool | extract_duid_
| Extract Duid from Client Id.
dhcp::Host::IdentifierType | id_type4_
| Identifier type for IPv4.
dhcp::Host::IdentifierType | id_type6_
| Identifier type for IPv6.
std::map< uint32_t, uint32_t > | remap_
| Subnet ID to NAS port map.
bool | reselect_subnet_address_
| Reselect subnet using address.
bool | reselect_subnet_pool_
| Reselect subnet using pool.
unsigned | retries_
| Retries.
std::string | session_history_filename_
| Session history filename.
asiolink::IoServiceThreadPoolPtr | thread_pool_
| Thread pool.
unsigned | thread_pool_size_
| Thread pool size.
unsigned | timeout_
| Timeout.

## Static Public Attributes
static std::atomic< bool > | shutdown_
| Flag which indicates that the instance is shutting down.

## Protected Member Functions
| RadiusImpl ()
| Protected constructor.
void | checkPausePermissions ()
| Check if the current thread can transition the thread pool to the paused state.
void | cleanup ()
| Clean up members.
void | pauseThreadPool ()
| Pause the thread pool.
void | resumeThreadPool ()
| Resume the thread pool.

## Static Protected Member Functions
static const RadiusImplPtr & | instancePtr ()
| Returns pointer to the sole instance of radius implementation.

## Detailed Description

Radius hooks library implementation.

Definition at line 50 of file radius.h.

## Constructor & Destructor Documentation

## ◆ ~RadiusImpl()

isc::radius::RadiusImpl::~RadiusImpl | ( |  | ) |

Destructor.

Definition at line 58 of file radius.cc.

References cleanup(), LOG_WARN, isc::radius::RADIUS_CLEANUP_EXCEPTION, and isc::radius::radius_logger.

Here is the call graph for this function:

## ◆ RadiusImpl()

isc::radius::RadiusImpl::RadiusImpl | ( |  | ) |
| protected

Protected constructor.

Definition at line 47 of file radius.cc.

References acct_, auth_, bindaddr_, canonical_mac_address_, clientid_pop0_, clientid_printable_, deadtime_, extract_duid_, id_type4_, id_type6_, reselect_subnet_address_, reselect_subnet_pool_, retries_, and thread_pool_size_.

Referenced by instancePtr().

## Member Function Documentation

## ◆ checkEarlyGlobalResvLookup()

void isc::radius::RadiusImpl::checkEarlyGlobalResvLookup | ( |  | ) |

Check the early global host reservations lookup flag.

Exceptions

  ConfigError | when the server configuration is not compatible.

Definition at line 314 of file radius.cc.

References isc::dhcp::CfgGlobals::EARLY_GLOBAL_RESERVATIONS_LOOKUP, isc::dhcp::CfgMgr::getStagingCfg(), isc::dhcp::CfgMgr::instance(), and isc_throw.

Referenced by init().

Here is the call graph for this function:

## ◆ checkHostBackends()

bool isc::radius::RadiusImpl::checkHostBackends | ( |  | ) |

Check host backends (cache and radius).

As a side effect when the host cache backend is found the cache_ field is set.

Todo
  : Calls to addBackend() (in particular the cache one) should be moved to Kea core (cf #5562). Note they must be after the load function so currently this method is called at first use.

Returns
  true when found, false when an error occurred.

Definition at line 377 of file radius.cc.

References isc::dhcp::HostMgr::addBackend(), cache_, isc::dhcp::HostMgr::getHostDataSource(), isc::dhcp::HostMgr::instance(), LOG_ERROR, isc::radius::RADIUS_ACCESS_HOST_BACKEND_ERROR, isc::radius::RADIUS_ACCESS_NO_HOST_CACHE, and isc::radius::radius_logger.

Here is the call graph for this function:

## ◆ checkPausePermissions()

void isc::radius::RadiusImpl::checkPausePermissions | ( |  | ) |
| protected

Check if the current thread can transition the thread pool to the paused state.

Used as a CS callback.

Exceptions

  MultiThreadingInvalidOperation | if the state transition is done on any of the worker threads.

Definition at line 209 of file radius.cc.

References LOG_ERROR, isc::radius::radius_logger, isc::radius::RADIUS_PAUSE_ILLEGAL, isc::radius::RADIUS_PAUSE_PERMISSIONS_FAILED, thread_pool_, and isc::Exception::what().

Referenced by startServices().

Here is the call graph for this function:

## ◆ checkSharedNetworks()

void isc::radius::RadiusImpl::checkSharedNetworks | ( |  | ) |

Check shared network server configuration.

This verifies the compatibility of the server configuration with the RADIUS hook, in particular with shared networks:

- set the disable single query flag
- verify that any shared network with more than one subnet uses only global reservations.
  Exceptions

    ConfigError | when the server configuration is not compatible.

Definition at line 323 of file radius.cc.

References isc::dhcp::CfgMgr::getStagingCfg(), isc::dhcp::CfgMgr::instance(), isc::dhcp::HostMgr::instance(), isc_throw, and isc::dhcp::HostMgr::setDisableSingleQuery().

Referenced by init().

Here is the call graph for this function:

## ◆ cleanup()

void isc::radius::RadiusImpl::cleanup | ( |  | ) |
| protected

Clean up members.

Definition at line 77 of file radius.cc.

References acct_, auth_, backend_, bindaddr_, cache_, canonical_mac_address_, clientid_pop0_, clientid_printable_, isc::dhcp::HostMgr::delBackend(), isc::dhcp::HostDataSourceFactory::deregisterFactory(), extract_duid_, getIOService(), id_type4_, id_type6_, isc::dhcp::Host::IDENT_CLIENT_ID, isc::dhcp::Host::IDENT_DUID, isc::util::MultiThreadingMgr::instance(), remap_, isc::util::MultiThreadingMgr::removeCriticalSectionCallbacks(), reselect_subnet_address_, reselect_subnet_pool_, retries_, session_history_filename_, thread_pool_, thread_pool_size_, and timeout_.

Referenced by ~RadiusImpl(), and reset().

Here is the call graph for this function:

## ◆ getIOContext()

isc::asiolink::IOServicePtr isc::radius::RadiusImpl::getIOContext | ( |  | ) |
| inline

Get the hook I/O service.

Returns
  the hook I/O service.

Definition at line 107 of file radius.h.

## ◆ getIOService()

isc::asiolink::IOServicePtr isc::radius::RadiusImpl::getIOService | ( |  | ) |
| inline

Get the hook I/O service.

Returns
  the hook I/O service.

Definition at line 121 of file radius.h.

Referenced by cleanup().

## ◆ init()

void isc::radius::RadiusImpl::init | ( | data::ElementPtr & | config | ) |

Initialize.

Parameters

  config | Configuration specified for the hooks library.

Exceptions

  ConfigError | when configuration fails.

Definition at line 130 of file radius.cc.

References acct_, auth_, backend_, checkEarlyGlobalResvLookup(), checkSharedNetworks(), isc_throw, LOG_ERROR, isc::radius::RadiusConfigParser::parse(), isc::radius::RADIUS_ACCESS_NO_HOST_CACHE, isc::radius::radius_logger, isc::dhcp::HostDataSourceFactory::registeredFactory(), isc::dhcp::HostDataSourceFactory::registerFactory(), and session_history_filename_.

Here is the call graph for this function:

## ◆ instance()

RadiusImpl & isc::radius::RadiusImpl::instance | ( |  | ) |
| static

RadiusImpl is a singleton class.

This method returns reference to its sole instance.

Returns
  the only existing instance of radius implementation.

Definition at line 37 of file radius.cc.

References instancePtr().

Referenced by isc::radius::RadiusAcctHandler::RadiusAcctHandler(), isc::radius::RadiusAuthHandler::RadiusAuthHandler(), isc::radius::RadiusRequest::RadiusRequest(), isc::radius::RadiusAccounting::buildAcct(), isc::radius::RadiusAccounting::buildAcct(), isc::radius::RadiusAccounting::buildAcct4(), isc::radius::RadiusAccounting::buildAcct6(), isc::radius::RadiusAccess::buildAuth(), isc::radius::RadiusAccess::buildAuth(), command_processed(), dhcp4_srv_configured(), dhcp6_srv_configured(), isc::radius::RadiusBackendImpl::get4(), isc::radius::RadiusBackendImpl::get6(), isc::radius::RadiusAccess::getIdentifier(), isc::radius::RadiusAccess::getIdentifier(), isc::radius::getNASPort(), isc::radius::RadiusAsyncAcct::invokeCallback(), isc::radius::RadiusAsyncAuth::invokeCallback(), lease4_decline(), lease4_expire(), lease4_release(), lease4_renew(), lease4_select(), lease6_decline(), lease6_expire(), lease6_rebind(), lease6_release(), lease6_renew(), lease6_select(), load(), isc::radius::RadiusConfigParser::parse(), isc::radius::RadiusServerParser::parse(), subnet4_select(), subnet6_select(), isc::radius::RadiusAccess::terminate4Internal(), isc::radius::RadiusAccess::terminate6Internal(), and unload().

Here is the call graph for this function:

## ◆ instancePtr()

const RadiusImplPtr & isc::radius::RadiusImpl::instancePtr | ( |  | ) |
| staticprotected

Returns pointer to the sole instance of radius implementation.

Returns
  Shared pointer to the RadiusImpl instance.

Definition at line 42 of file radius.cc.

References RadiusImpl().

Referenced by instance().

Here is the call graph for this function:

## ◆ pauseThreadPool()

void isc::radius::RadiusImpl::pauseThreadPool | ( |  | ) |
| protected

Pause the thread pool.

Used as a CS callback.

Definition at line 229 of file radius.cc.

References LOG_ERROR, isc::radius::radius_logger, isc::radius::RADIUS_PAUSE_FAILED, and thread_pool_.

Referenced by startServices().

## ◆ registerExchange()

void isc::radius::RadiusImpl::registerExchange | ( | ExchangePtr | exchange | ) |

Register Exchange.

Parameters

  exchange | The exchange to register.

Definition at line 67 of file radius.cc.

## ◆ reset()

void isc::radius::RadiusImpl::reset | ( |  | ) |

Reset the state as it was just created.

Definition at line 124 of file radius.cc.

References cleanup(), and shutdown_.

Referenced by unload().

Here is the call graph for this function:

## ◆ resumeThreadPool()

void isc::radius::RadiusImpl::resumeThreadPool | ( |  | ) |
| protected

Resume the thread pool.

Used as a CS callback.

Definition at line 244 of file radius.cc.

References LOG_ERROR, isc::radius::radius_logger, isc::radius::RADIUS_RESUME_FAILED, and thread_pool_.

Referenced by startServices().

## ◆ setIOContext()

void isc::radius::RadiusImpl::setIOContext | ( | isc::asiolink::IOServicePtr | io_service | ) |
| inline

Set the hook I/O service.

Parameters

  io_service | the hook I/O service.

Definition at line 114 of file radius.h.

## ◆ setIOService()

void isc::radius::RadiusImpl::setIOService | ( | isc::asiolink::IOServicePtr | io_service | ) |
| inline

Set the hook I/O service.

Parameters

  io_service | the hook I/O service.

Definition at line 128 of file radius.h.

## ◆ startServices()

void isc::radius::RadiusImpl::startServices | ( |  | ) |

Start the I/O mechanisms.

Start the thread pool for MT or create the IO context for ST.

Definition at line 155 of file radius.cc.

References isc::util::MultiThreadingMgr::addCriticalSectionCallbacks(), checkPausePermissions(), isc::util::MultiThreadingMgr::detectThreadCount(), isc::dhcp::CfgMultiThreading::extract(), isc::dhcp::CfgMgr::instance(), isc::util::MultiThreadingMgr::instance(), LOG_INFO, pauseThreadPool(), isc::radius::radius_logger, isc::radius::RADIUS_THREAD_POOL_STARTED, resumeThreadPool(), thread_pool_, and thread_pool_size_.

Referenced by dhcp4_srv_configured(), and dhcp6_srv_configured().

Here is the call graph for this function:

## ◆ toElement()

ElementPtr isc::radius::RadiusImpl::toElement | ( |  | ) | const
| overridevirtual

Unparse implementation configuration.

Returns
  a pointer to unparsed configuration.

Implements isc::data::CfgToElement.

Definition at line 411 of file radius.cc.

References acct_, auth_, bindaddr_, canonical_mac_address_, clientid_pop0_, clientid_printable_, Element::create(), Element::createList(), Element::createMap(), deadtime_, dictionary_, extract_duid_, isc::dhcp::Host::getIdentifierName(), id_type4_, id_type6_, remap_, reselect_subnet_address_, reselect_subnet_pool_, retries_, session_history_filename_, thread_pool_size_, and timeout_.

Here is the call graph for this function:

## ◆ unregisterExchange()

void isc::radius::RadiusImpl::unregisterExchange | ( | ExchangePtr | exchange | ) |

Unregister Exchange.

Parameters

  exchange | The exchange to unregister.

Definition at line 72 of file radius.cc.

Referenced by isc::radius::RadiusAsyncAcct::invokeCallback(), and isc::radius::RadiusAsyncAuth::invokeCallback().

## Member Data Documentation

## ◆ acct_

boost::shared_ptr<RadiusAccounting> isc::radius::RadiusImpl::acct_

Pointer to accounting (never null).

Definition at line 157 of file radius.h.

Referenced by RadiusImpl(), isc::radius::RadiusRequest::RadiusRequest(), cleanup(), init(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ auth_

boost::shared_ptr<RadiusAccess> isc::radius::RadiusImpl::auth_

Definition at line 154 of file radius.h.

Referenced by RadiusImpl(), isc::radius::RadiusRequest::RadiusRequest(), cleanup(), init(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ backend_

RadiusBackendPtr isc::radius::RadiusImpl::backend_

Radius backend.

Definition at line 163 of file radius.h.

Referenced by cleanup(), and init().

## ◆ bindaddr_

std::string isc::radius::RadiusImpl::bindaddr_

bindaddr.

Definition at line 166 of file radius.h.

Referenced by RadiusImpl(), cleanup(), isc::radius::RadiusConfigParser::parse(), isc::radius::RadiusServerParser::parse(), and toElement().

## ◆ cache_

dhcp::CacheHostDataSourcePtr isc::radius::RadiusImpl::cache_

Host cache.

Definition at line 160 of file radius.h.

Referenced by checkHostBackends(), and cleanup().

## ◆ canonical_mac_address_

bool isc::radius::RadiusImpl::canonical_mac_address_

Canonical MAC address.

Definition at line 169 of file radius.h.

Referenced by RadiusImpl(), cleanup(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ clientid_pop0_

bool isc::radius::RadiusImpl::clientid_pop0_

Client Id pop leading zero(s).

Definition at line 172 of file radius.h.

Referenced by RadiusImpl(), cleanup(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ clientid_printable_

bool isc::radius::RadiusImpl::clientid_printable_

Client Id try printable.

Definition at line 175 of file radius.h.

Referenced by RadiusImpl(), cleanup(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ deadtime_

unsigned isc::radius::RadiusImpl::deadtime_

Deadtime.

Definition at line 178 of file radius.h.

Referenced by RadiusImpl(), isc::radius::RadiusConfigParser::parse(), isc::radius::RadiusServerParser::parse(), and toElement().

## ◆ dictionary_

std::string isc::radius::RadiusImpl::dictionary_

Dictionary path.

Definition at line 148 of file radius.h.

Referenced by isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ extract_duid_

bool isc::radius::RadiusImpl::extract_duid_

Extract Duid from Client Id.

Definition at line 181 of file radius.h.

Referenced by RadiusImpl(), cleanup(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ id_type4_

dhcp::Host::IdentifierType isc::radius::RadiusImpl::id_type4_

Identifier type for IPv4.

Definition at line 202 of file radius.h.

Referenced by RadiusImpl(), isc::radius::RadiusAccounting::buildAcct(), isc::radius::RadiusAccounting::buildAcct4(), cleanup(), isc::radius::RadiusAccess::getIdentifier(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ id_type6_

dhcp::Host::IdentifierType isc::radius::RadiusImpl::id_type6_

Identifier type for IPv6.

Definition at line 205 of file radius.h.

Referenced by RadiusImpl(), isc::radius::RadiusAccounting::buildAcct(), isc::radius::RadiusAccounting::buildAcct6(), cleanup(), isc::radius::RadiusAccess::getIdentifier(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ remap_

std::map<uint32_t, uint32_t> isc::radius::RadiusImpl::remap_

Subnet ID to NAS port map.

Definition at line 151 of file radius.h.

Referenced by cleanup(), isc::radius::getNASPort(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ reselect_subnet_address_

bool isc::radius::RadiusImpl::reselect_subnet_address_

Reselect subnet using address.

Definition at line 187 of file radius.h.

Referenced by RadiusImpl(), cleanup(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ reselect_subnet_pool_

bool isc::radius::RadiusImpl::reselect_subnet_pool_

Reselect subnet using pool.

Definition at line 184 of file radius.h.

Referenced by RadiusImpl(), cleanup(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ retries_

unsigned isc::radius::RadiusImpl::retries_

Retries.

Definition at line 190 of file radius.h.

Referenced by RadiusImpl(), isc::radius::RadiusRequest::RadiusRequest(), cleanup(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ session_history_filename_

std::string isc::radius::RadiusImpl::session_history_filename_

Session history filename.

Definition at line 193 of file radius.h.

Referenced by cleanup(), init(), isc::radius::RadiusConfigParser::parse(), and toElement().

## ◆ shutdown_

std::atomic< bool > isc::radius::RadiusImpl::shutdown_
| static

Flag which indicates that the instance is shutting down.

Definition at line 211 of file radius.h.

Referenced by isc::radius::Exchange::open(), isc::radius::Exchange::receivedHandler(), reset(), and isc::radius::Exchange::sentHandler().

## ◆ thread_pool_

asiolink::IoServiceThreadPoolPtr isc::radius::RadiusImpl::thread_pool_

Thread pool.

Definition at line 208 of file radius.h.

Referenced by checkPausePermissions(), cleanup(), pauseThreadPool(), resumeThreadPool(), and startServices().

## ◆ thread_pool_size_

unsigned isc::radius::RadiusImpl::thread_pool_size_

Thread pool size.

Definition at line 196 of file radius.h.

Referenced by RadiusImpl(), cleanup(), isc::radius::RadiusConfigParser::parse(), startServices(), and toElement().

## ◆ timeout_

unsigned isc::radius::RadiusImpl::timeout_

Timeout.

Definition at line 199 of file radius.h.

Referenced by cleanup(), isc::radius::RadiusConfigParser::parse(), isc::radius::RadiusServerParser::parse(), and toElement().

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

- radius.h
- radius.cc