Kea 3.3.4
network_state.h
Go to the documentation of this file.
1// Copyright (C) 2017-2025 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
23
42
70public:
71
77
82 static const unsigned int USER_COMMAND = 1;
83
88 static const unsigned int HA_LOCAL_COMMAND = 1000;
89
95 static const unsigned int HA_REMOTE_COMMAND = 2000;
96
99 static const unsigned int DB_CONNECTION = 3000;
100
102 typedef std::set<SubnetID> Subnets;
103
105 typedef std::set<std::string> Networks;
106
108 NetworkState();
109
117 void disableService(unsigned int origin);
118
126 void enableService(unsigned int origin);
127
131 bool disabledByUser() const;
132
137 bool disabledByDbConnection() const;
138
143 bool disabledByLocalCommand() const;
144
149 bool disabledByRemoteCommand() const;
150
156
162
168
174 void delayedEnableService(const unsigned int seconds,
175 unsigned int origin);
176
180 bool isServiceEnabled() const;
181
189 bool isDelayedEnableService() const;
190
192
193
200 void selectiveDisable(const NetworkState::Subnets& subnets);
201
208 void selectiveDisable(const NetworkState::Networks& networks);
209
216 void selectiveEnable(const NetworkState::Subnets& subnets);
217
224 void selectiveEnable(const NetworkState::Networks& networks);
225
229 virtual isc::data::ElementPtr toElement() const;
230
232
233private:
234
236 boost::shared_ptr<NetworkStateImpl> impl_;
237
239 const boost::scoped_ptr<std::mutex> mutex_;
240};
241
243typedef boost::shared_ptr<NetworkState> NetworkStatePtr;
244
245} // end of namespace isc::dhcp
246} // end of namespace isc
247
248#endif // NETWORK_STATE_H
Implementation of the NetworkState class.
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.
bool disabledByRemoteCommand() const
Check if the service state is disabled by remote commands.
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.
bool disabledByUser() const
Check if the service state is disabled by user.
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.
bool disabledByLocalCommand() const
Check if the service state is disabled by local commands.
void resetForRemoteCommands()
Reset origins for remote commands.
bool disabledByDbConnection() const
Check if the service state is disabled by database connection.
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
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.