![]() |
Kea 3.1.1
|
Radius hooks library implementation. More...
#include <radius.h>
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. | |
![]() | |
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. | |
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.
|
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().
void isc::radius::RadiusImpl::checkEarlyGlobalResvLookup | ( | ) |
Check the early global host reservations lookup flag.
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().
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.
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.
|
protected |
Check if the current thread can transition the thread pool to the paused state.
Used as a CS callback.
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().
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:
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().
|
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().
|
inline |
|
inline |
void isc::radius::RadiusImpl::init | ( | data::ElementPtr & | config | ) |
Initialize.
config | Configuration specified for the hooks library. |
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_.
|
static |
RadiusImpl is a singleton class.
This method returns reference to its sole instance.
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().
|
staticprotected |
Returns pointer to the sole instance of radius implementation.
Definition at line 42 of file radius.cc.
References RadiusImpl().
Referenced by instance().
|
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().
void isc::radius::RadiusImpl::registerExchange | ( | ExchangePtr | exchange | ) |
void isc::radius::RadiusImpl::reset | ( | ) |
|
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().
|
inline |
|
inline |
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().
|
overridevirtual |
Unparse implementation 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_.
void isc::radius::RadiusImpl::unregisterExchange | ( | ExchangePtr | exchange | ) |
Unregister Exchange.
exchange | The exchange to unregister. |
Definition at line 72 of file radius.cc.
Referenced by isc::radius::RadiusAsyncAcct::invokeCallback(), and isc::radius::RadiusAsyncAuth::invokeCallback().
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().
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().
RadiusBackendPtr isc::radius::RadiusImpl::backend_ |
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().
dhcp::CacheHostDataSourcePtr isc::radius::RadiusImpl::cache_ |
Host cache.
Definition at line 160 of file radius.h.
Referenced by checkHostBackends(), and cleanup().
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().
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().
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().
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().
std::string isc::radius::RadiusImpl::dictionary_ |
Dictionary path.
Definition at line 148 of file radius.h.
Referenced by isc::radius::RadiusConfigParser::parse(), and toElement().
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().
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().
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().
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().
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().
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().
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().
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().
|
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().
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().
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().
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().