Kea  2.3.2-git
network_state.h
Go to the documentation of this file.
1 // Copyright (C) 2017-2021 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef NETWORK_STATE_H
8 #define NETWORK_STATE_H
9 
10 #include <cc/data.h>
11 #include <dhcpsrv/subnet_id.h>
12 #include <boost/scoped_ptr.hpp>
13 #include <boost/shared_ptr.hpp>
14 #include <set>
15 #include <mutex>
16 #include <string>
17 
18 namespace isc {
19 namespace dhcp {
20 
21 class NetworkStateImpl;
22 
70 class NetworkState {
71 public:
72 
74  enum ServerType {
77  };
78 
84  enum class Origin {
88  HA_COMMAND,
92  };
93 
95  typedef std::set<SubnetID> Subnets;
96 
98  typedef std::set<std::string> Networks;
99 
101  NetworkState(const ServerType& server_type);
102 
110  void disableService(const NetworkState::Origin& origin);
111 
119  void enableService(const NetworkState::Origin& origin);
120 
127  void reset(const NetworkState::Origin& type);
128 
133  void enableAll(const NetworkState::Origin& origin);
134 
140  void delayedEnableAll(const unsigned int seconds,
141  const NetworkState::Origin& origin);
142 
146  bool isServiceEnabled() const;
147 
155  bool isDelayedEnableAll() const;
156 
158 
159 
166  void selectiveDisable(const NetworkState::Subnets& subnets);
167 
174  void selectiveDisable(const NetworkState::Networks& networks);
175 
182  void selectiveEnable(const NetworkState::Subnets& subnets);
183 
190  void selectiveEnable(const NetworkState::Networks& networks);
191 
193 
194 private:
195 
197  boost::shared_ptr<NetworkStateImpl> impl_;
198 
200  const boost::scoped_ptr<std::mutex> mutex_;
201 };
202 
204 typedef boost::shared_ptr<NetworkState> NetworkStatePtr;
205 
206 } // end of namespace isc::dhcp
207 } // end of namespace isc
208 
209 #endif // NETWORK_STATE_H
std::set< std::string > Networks
Type of the container holding collection of shared network names.
Definition: network_state.h:98
NetworkState(const ServerType &server_type)
Constructor.
void enableService(const NetworkState::Origin &origin)
Enable the DHCP service state for respective transition origin.
ServerType
DHCP server type.
Definition: network_state.h:74
The network state is being altered by the DB connection recovery mechanics.
void delayedEnableAll(const unsigned int seconds, const NetworkState::Origin &origin)
Schedules enabling DHCP service in the future.
void reset(const NetworkState::Origin &type)
Reset internal counters.
Holds information about DHCP service enabling status.
Definition: network_state.h:70
std::set< SubnetID > Subnets
Type of the container holding collection of subnet identifiers.
Definition: network_state.h:95
void selectiveEnable(const NetworkState::Subnets &subnets)
Enable DHCP service for selected subnets.
The network state is being altered by a user command.
void enableAll(const NetworkState::Origin &origin)
Enables DHCP service globally and for scopes which have been disabled as a result of control command...
Origin
Origin of the network state transition.
Definition: network_state.h:84
The network state is being altered by a HA internal command.
void selectiveDisable(const NetworkState::Subnets &subnets)
Disable DHCP service for selected subnets.
Defines the logger used by the top-level component of kea-lfc.
bool isServiceEnabled() const
Checks if the DHCP service is globally enabled.
void disableService(const NetworkState::Origin &origin)
Disable the DHCP service state for respective transition origin.
boost::shared_ptr< NetworkState > NetworkStatePtr
Pointer to the NetworkState object.
bool isDelayedEnableAll() const
Checks if delayed enabling of DHCP services is scheduled.