Kea 2.7.6
isc::dhcp::NetworkStateImpl Class Reference

Implementation of the NetworkState class. More...

+ Inheritance diagram for isc::dhcp::NetworkStateImpl:

Public Member Functions

 NetworkStateImpl ()
 Constructor.
 
 ~NetworkStateImpl ()
 Destructor.
 
void createTimer (const unsigned int seconds, unsigned int origin)
 Creates a timer counting the time when delayedEnable should be automatically called.
 
void delayedEnable (unsigned int origin)
 Enables DHCP service for an origin.
 
void destroyTimer (unsigned int origin)
 Destroys a timer if present.
 
std::string getTimerName (unsigned int origin) const
 Creates a unique timer name from the origin.
 
void resetForDbConnection ()
 Reset internal counters for a database connection origin.
 
void resetForLocalCommands ()
 Reset origin for local commands.
 
void resetForRemoteCommands ()
 Reset origin for remote commands.
 
void setDisableService (const bool disable, unsigned int origin)
 Sets appropriate disabled or enabled DHCP service state for the respective origin.
 
virtual ElementPtr toElement () const
 The network state as Element.
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor.
 

Public Attributes

uint32_t disabled_by_db_connection_
 Flag which indicates the state has been disabled by a DB connection loss.
 
std::unordered_set< unsigned int > disabled_by_origin_
 A set of requests to disable the service by origin.
 
NetworkState::Networks disabled_networks_
 A list of networks for which the DHCP service has been disabled.
 
NetworkState::Subnets disabled_subnets_
 A list of subnets for which the DHCP service has been disabled.
 
bool globally_disabled_
 A flag indicating if DHCP service is globally disabled.
 
TimerMgrPtr timer_mgr_
 A pointer to the common timer manager.
 

Detailed Description

Implementation of the NetworkState class.

Definition at line 26 of file network_state.cc.

Constructor & Destructor Documentation

◆ NetworkStateImpl()

isc::dhcp::NetworkStateImpl::NetworkStateImpl ( )
inline

Constructor.

Definition at line 31 of file network_state.cc.

◆ ~NetworkStateImpl()

isc::dhcp::NetworkStateImpl::~NetworkStateImpl ( )
inline

Destructor.

Definition at line 37 of file network_state.cc.

References destroyTimer(), and disabled_by_origin_.

+ Here is the call graph for this function:

Member Function Documentation

◆ createTimer()

void isc::dhcp::NetworkStateImpl::createTimer ( const unsigned int seconds,
unsigned int origin )
inline

Creates a timer counting the time when delayedEnable should be automatically called.

If the timer has been already scheduled, it is destroyed and replaced with a new timer.

Parameters
secondsNumber of seconds to elapse before the delayedEnable is called.
originThe origin of the state transition.

Definition at line 142 of file network_state.cc.

References isc::dhcp::NetworkState::DB_CONNECTION, delayedEnable(), destroyTimer(), getTimerName(), isc_throw, isc::asiolink::IntervalTimer::ONE_SHOT, and timer_mgr_.

+ Here is the call graph for this function:

◆ delayedEnable()

void isc::dhcp::NetworkStateImpl::delayedEnable ( unsigned int origin)
inline

Enables DHCP service for an origin.

If delayed enabling DHCP service has been scheduled, it cancels it.

Parameters
originThe origin of the state transition.

Definition at line 128 of file network_state.cc.

References destroyTimer(), and setDisableService().

Referenced by createTimer().

+ Here is the call graph for this function:

◆ destroyTimer()

void isc::dhcp::NetworkStateImpl::destroyTimer ( unsigned int origin)
inline

Destroys a timer if present.

Parameters
originThe origin of the state transition.

Definition at line 159 of file network_state.cc.

References isc::dhcp::NetworkState::DB_CONNECTION, getTimerName(), and timer_mgr_.

Referenced by ~NetworkStateImpl(), createTimer(), and delayedEnable().

+ Here is the call graph for this function:

◆ getTimerName()

std::string isc::dhcp::NetworkStateImpl::getTimerName ( unsigned int origin) const
inline

Creates a unique timer name from the origin.

Parameters
originThe origin of the state transition.
Returns
Unique timer name for the origin.

Definition at line 173 of file network_state.cc.

Referenced by createTimer(), and destroyTimer().

◆ resetForDbConnection()

void isc::dhcp::NetworkStateImpl::resetForDbConnection ( )
inline

Reset internal counters for a database connection origin.

Note
The dhcp service will remain disabled until all flags are cleared.

Definition at line 84 of file network_state.cc.

References disabled_by_db_connection_, disabled_by_origin_, and globally_disabled_.

◆ resetForLocalCommands()

void isc::dhcp::NetworkStateImpl::resetForLocalCommands ( )
inline

Reset origin for local commands.

Note
The dhcp service will remain disabled until all flags are cleared.

Definition at line 94 of file network_state.cc.

References disabled_by_db_connection_, disabled_by_origin_, globally_disabled_, isc::dhcp::NetworkState::HA_LOCAL_COMMAND, and isc::dhcp::NetworkState::HA_REMOTE_COMMAND.

◆ resetForRemoteCommands()

void isc::dhcp::NetworkStateImpl::resetForRemoteCommands ( )
inline

Reset origin for remote commands.

Note
The dhcp service will remain disabled until all flags are cleared.

Definition at line 110 of file network_state.cc.

References isc::dhcp::NetworkState::DB_CONNECTION, disabled_by_db_connection_, disabled_by_origin_, globally_disabled_, and isc::dhcp::NetworkState::HA_REMOTE_COMMAND.

◆ setDisableService()

void isc::dhcp::NetworkStateImpl::setDisableService ( const bool disable,
unsigned int origin )
inline

Sets appropriate disabled or enabled DHCP service state for the respective origin.

Note
If any of the user commands, HA internal commands or connection recovery processes disable the dhcp service, the service will remain disabled until all flags are cleared. In the case of the connection recovery a reference count is used internally, so that all connections must be restored before enabling the network state.
Parameters
disableThe value of the flag used to perform the transition.
originThe origin of the state transition.

Definition at line 55 of file network_state.cc.

References isc::dhcp::NetworkState::DB_CONNECTION, disabled_by_db_connection_, disabled_by_origin_, and globally_disabled_.

Referenced by delayedEnable().

◆ toElement()

virtual ElementPtr isc::dhcp::NetworkStateImpl::toElement ( ) const
inlinevirtual

The network state as Element.

Returns
The network state as Element.

Implements isc::data::CfgToElement.

Definition at line 182 of file network_state.cc.

References isc::data::Element::create(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::dhcp::NetworkState::DB_CONNECTION, disabled_by_db_connection_, disabled_by_origin_, globally_disabled_, isc::dhcp::NetworkState::HA_LOCAL_COMMAND, isc::dhcp::NetworkState::HA_REMOTE_COMMAND, and isc::dhcp::NetworkState::USER_COMMAND.

+ Here is the call graph for this function:

Member Data Documentation

◆ disabled_by_db_connection_

uint32_t isc::dhcp::NetworkStateImpl::disabled_by_db_connection_

Flag which indicates the state has been disabled by a DB connection loss.

Definition at line 228 of file network_state.cc.

Referenced by resetForDbConnection(), resetForLocalCommands(), resetForRemoteCommands(), setDisableService(), and toElement().

◆ disabled_by_origin_

std::unordered_set<unsigned int> isc::dhcp::NetworkStateImpl::disabled_by_origin_

A set of requests to disable the service by origin.

Definition at line 224 of file network_state.cc.

Referenced by ~NetworkStateImpl(), resetForDbConnection(), resetForLocalCommands(), resetForRemoteCommands(), setDisableService(), and toElement().

◆ disabled_networks_

NetworkState::Networks isc::dhcp::NetworkStateImpl::disabled_networks_

A list of networks for which the DHCP service has been disabled.

Definition at line 215 of file network_state.cc.

◆ disabled_subnets_

NetworkState::Subnets isc::dhcp::NetworkStateImpl::disabled_subnets_

A list of subnets for which the DHCP service has been disabled.

Definition at line 212 of file network_state.cc.

◆ globally_disabled_

bool isc::dhcp::NetworkStateImpl::globally_disabled_

A flag indicating if DHCP service is globally disabled.

Definition at line 209 of file network_state.cc.

Referenced by resetForDbConnection(), resetForLocalCommands(), resetForRemoteCommands(), setDisableService(), and toElement().

◆ timer_mgr_

TimerMgrPtr isc::dhcp::NetworkStateImpl::timer_mgr_

A pointer to the common timer manager.

This pointer is held here to make sure that the timer manager is not destroyed before an instance of this class is destroyed.

Definition at line 221 of file network_state.cc.

Referenced by createTimer(), and destroyTimer().


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