Kea  1.5.0
isc::dhcp::NetworkState Class Reference

Holds information about DHCP service enabling status. More...

#include <network_state.h>

Public Types

typedef std::set< std::string > Networks
 Type of the container holding collection of shared network names. More...
 
enum  ServerType { DHCPv4, DHCPv6 }
 DHCP server type. More...
 
typedef std::set< SubnetIDSubnets
 Type of the container holding collection of subnet identifiers. More...
 

Public Member Functions

 NetworkState (const ServerType &server_type)
 Constructor. More...
 
void delayedEnableAll (const unsigned int seconds)
 Schedules enabling DHCP service in the future. More...
 
void disableService ()
 Globally disables DHCP service. More...
 
void enableAll ()
 Enables DHCP service globally and for scopes which have been disabled as a result of control command. More...
 
void enableService ()
 Globally enables DHCP service. More...
 
bool isDelayedEnableAll () const
 Checks if delayed enabling of DHCP services is scheduled. More...
 
bool isServiceEnabled () const
 Checks if the DHCP service is globally enabled. More...
 
Selective disabling/enabling DHCP service per scopes
void selectiveDisable (const NetworkState::Subnets &subnets)
 Disable DHCP service for selected subnets. More...
 
void selectiveDisable (const NetworkState::Networks &networks)
 Disable DHCP service for selected networks. More...
 
void selectiveEnable (const NetworkState::Subnets &subnets)
 Enable DHCP service for selected subnets. More...
 
void selectiveEnable (const NetworkState::Networks &networks)
 Enable DHCP service for selected networks. More...
 

Detailed Description

Holds information about DHCP service enabling status.

When the DHCP server receives a command to disable DHCP service entirely or for specific networks, this has to be recorded to allow for re-enabling DHCP service for these networks as a result of receiving a command from the administrator or when the timeout for re-enabling the service occurs.

In the future, it will be possible to specify "disabled" parameter for a subnet (or network) in the configuration file to indicate that this subnet should be excluded from the service. When a command is subsequently sent to temporarily disable a service for some other subnets for a specified amount ot time, only these subnets should be re-enabled when the time elapses. This class fulfils this requirement by recording the subnets disabled with a command and re-enabling them when required. The subnets specified as "disabled" in the configuration file should remain disabled until explcitly enabled with a control command.

This class also allows for disabling the DHCP service globally. In this case the server drops all received packets.

The "dhcp-disable" and "dhcp-enable" commands are used for globally disabling and enabling the DHCP service. The "dhcp-disable-scopes" and "dhcp-enable-scopes" commands are used to disable and enable DHCP service for subnets and networks. In case of the "dhcp-disable" and "dhcp-disable-scopes" commands, it is possible to specify "max-period" parameter which provides a timeout, after which the settings are reverted (service is re-enabled globally and/or for specific scopes).

Disabling DHCP service with a timeout is useful to guard against issues when the controlling client dies after disabling the DHCP service on the server, e.g. failover peers may instruct each other to disable the DHCP service while database synchronization takes place. If the peer subsequently dies, the surviving server must re-enable DHCP on its own.

Todo:
This class currently supports only the case of globally disabling the DHCP service. Disabling per network/subnet will be added later.

Definition at line 57 of file network_state.h.

Member Typedef Documentation

◆ Networks

typedef std::set<std::string> isc::dhcp::NetworkState::Networks

Type of the container holding collection of shared network names.

Definition at line 70 of file network_state.h.

◆ Subnets

Type of the container holding collection of subnet identifiers.

Definition at line 67 of file network_state.h.

Member Enumeration Documentation

◆ ServerType

DHCP server type.

Enumerator
DHCPv4 
DHCPv6 

Definition at line 61 of file network_state.h.

Constructor & Destructor Documentation

◆ NetworkState()

isc::dhcp::NetworkState::NetworkState ( const ServerType server_type)

Constructor.

Definition at line 101 of file network_state.cc.

Member Function Documentation

◆ delayedEnableAll()

void isc::dhcp::NetworkState::delayedEnableAll ( const unsigned int  seconds)

Schedules enabling DHCP service in the future.

Parameters
secondsNumber of seconds after which the service should be enabled unless enableAll is enabled before that time.

Definition at line 121 of file network_state.cc.

◆ disableService()

void isc::dhcp::NetworkState::disableService ( )

Globally disables DHCP service.

The DHCP service becomes disabled for all subnets and networks, regardless of the per scope settings.

Definition at line 106 of file network_state.cc.

◆ enableAll()

void isc::dhcp::NetworkState::enableAll ( )

Enables DHCP service globally and for scopes which have been disabled as a result of control command.

Definition at line 116 of file network_state.cc.

◆ enableService()

void isc::dhcp::NetworkState::enableService ( )

Globally enables DHCP service.

The DHCP service becomes enabled but per scope settings are in effect. In order to enable the service for all scopes previously disabled with a control command, use enableAll.

Definition at line 111 of file network_state.cc.

◆ isDelayedEnableAll()

bool isc::dhcp::NetworkState::isDelayedEnableAll ( ) const

Checks if delayed enabling of DHCP services is scheduled.

It indicates that the timer is present which counts the time until enableAll function will be called automatically.

Returns
true if delayed enabling of the DHCP service is scheduled, false otherwise.

Definition at line 131 of file network_state.cc.

References isc::dhcp::TimerMgr::instance().

+ Here is the call graph for this function:

◆ isServiceEnabled()

bool isc::dhcp::NetworkState::isServiceEnabled ( ) const

Checks if the DHCP service is globally enabled.

Returns
true if the service is globally enabled, false otherwise.

Definition at line 126 of file network_state.cc.

◆ selectiveDisable() [1/2]

void isc::dhcp::NetworkState::selectiveDisable ( const NetworkState::Subnets subnets)

Disable DHCP service for selected subnets.

Parameters
subnetsCollection of subnet identifiers for which the service should be disabled.
Exceptions
isc::NotImplemented

Definition at line 136 of file network_state.cc.

References isc_throw.

◆ selectiveDisable() [2/2]

void isc::dhcp::NetworkState::selectiveDisable ( const NetworkState::Networks networks)

Disable DHCP service for selected networks.

Parameters
networksCollection of shared network names for which the service should be disabled.
Exceptions
isc::NotImplemented

Definition at line 141 of file network_state.cc.

References isc_throw.

◆ selectiveEnable() [1/2]

void isc::dhcp::NetworkState::selectiveEnable ( const NetworkState::Subnets subnets)

Enable DHCP service for selected subnets.

Parameters
subnetsCollection of subnet identifiers for which the service should be disabled.
Exceptions
isc::NotImplemented

Definition at line 146 of file network_state.cc.

References isc_throw.

◆ selectiveEnable() [2/2]

void isc::dhcp::NetworkState::selectiveEnable ( const NetworkState::Networks networks)

Enable DHCP service for selected networks.

Parameters
networksCollection of shared network names for which the service should be enabled.
Exceptions
isc::NotImplemented

Definition at line 151 of file network_state.cc.

References isc_throw.


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