Kea 2.7.7
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
22class NetworkStateImpl;
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
133
139
145
151 void delayedEnableService(const unsigned int seconds,
152 unsigned int origin);
153
157 bool isServiceEnabled() const;
158
166 bool isDelayedEnableService() const;
167
169
170
177 void selectiveDisable(const NetworkState::Subnets& subnets);
178
185 void selectiveDisable(const NetworkState::Networks& networks);
186
193 void selectiveEnable(const NetworkState::Subnets& subnets);
194
201 void selectiveEnable(const NetworkState::Networks& networks);
202
206 virtual isc::data::ElementPtr toElement() const;
207
209
210private:
211
213 boost::shared_ptr<NetworkStateImpl> impl_;
214
216 const boost::scoped_ptr<std::mutex> mutex_;
217};
218
220typedef boost::shared_ptr<NetworkState> NetworkStatePtr;
221
222} // end of namespace isc::dhcp
223} // end of namespace isc
224
225#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.
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< SubnetID > Subnets
Type of the container holding collection of subnet identifiers.
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.