Kea 2.7.5
network_state.h
Go to the documentation of this file.
1// Copyright (C) 2017-2024 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/cfg_to_element.h>
11#include <cc/data.h>
12#include <dhcpsrv/subnet_id.h>
13#include <boost/scoped_ptr.hpp>
14#include <boost/shared_ptr.hpp>
15#include <set>
16#include <mutex>
17#include <string>
18
19namespace isc {
20namespace dhcp {
21
22class NetworkStateImpl;
23
42
73public:
74
80
85 static const unsigned int USER_COMMAND = 1;
86
91 static const unsigned int HA_LOCAL_COMMAND = 1000;
92
98 static const unsigned int HA_REMOTE_COMMAND = 2000;
99
102 static const unsigned int DB_CONNECTION = 3000;
103
105 typedef std::set<SubnetID> Subnets;
106
108 typedef std::set<std::string> Networks;
109
111 NetworkState();
112
120 void disableService(unsigned int origin);
121
129 void enableService(unsigned int origin);
130
136
142
148
154 void delayedEnableService(const unsigned int seconds,
155 unsigned int origin);
156
160 bool isServiceEnabled() const;
161
169 bool isDelayedEnableService() const;
170
172
173
180 void selectiveDisable(const NetworkState::Subnets& subnets);
181
188 void selectiveDisable(const NetworkState::Networks& networks);
189
196 void selectiveEnable(const NetworkState::Subnets& subnets);
197
204 void selectiveEnable(const NetworkState::Networks& networks);
205
209 virtual isc::data::ElementPtr toElement() const;
210
212
213private:
214
216 boost::shared_ptr<NetworkStateImpl> impl_;
217
219 const boost::scoped_ptr<std::mutex> mutex_;
220};
221
223typedef boost::shared_ptr<NetworkState> NetworkStatePtr;
224
225} // end of namespace isc::dhcp
226} // end of namespace isc
227
228#endif // NETWORK_STATE_H
Controls the DHCP service enabling status.
static const unsigned int DB_CONNECTION
The network state is being altered by the DB connection recovery mechanics.
void selectiveDisable(const NetworkState::Subnets &subnets)
Disable DHCP service for selected subnets.
std::set< SubnetID > Subnets
Type of the container holding collection of subnet identifiers.
virtual isc::data::ElementPtr toElement() const
The network state as Element.
static const unsigned int USER_COMMAND
Origin of the network state transition.
std::set< std::string > Networks
Type of the container holding collection of shared network names.
static const unsigned int HA_LOCAL_COMMAND
The network state is being altered by an HA internal command.
bool isDelayedEnableService() const
Checks if delayed enabling of DHCP services is scheduled.
static const unsigned int HA_REMOTE_COMMAND
The network state is being altered by a "dhcp-disable" or "dhcp-enable" command sent by a HA partner.
void resetForDbConnection()
Reset internal counters for database connection.
void resetForLocalCommands()
Reset origins for local commands.
void selectiveEnable(const NetworkState::Subnets &subnets)
Enable DHCP service for selected subnets.
void enableService(unsigned int origin)
Enable the DHCP service state for respective transition origin.
void disableService(unsigned int origin)
Disable the DHCP service state for respective transition origin.
bool isServiceEnabled() const
Checks if the DHCP service is globally enabled.
void delayedEnableService(const unsigned int seconds, unsigned int origin)
Schedules enabling DHCP service in the future.
void resetForRemoteCommands()
Reset origins for remote commands.
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
boost::shared_ptr< NetworkState > NetworkStatePtr
Pointer to the NetworkState object.
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.