Kea 2.5.8
network_state.h
Go to the documentation of this file.
1// Copyright (C) 2017-2023 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
18namespace isc {
19namespace dhcp {
20
21class NetworkStateImpl;
22
41
72public:
73
77 DHCPv6
78 };
79
85
90 static const unsigned int USER_COMMAND = 1;
91
96 static const unsigned int HA_LOCAL_COMMAND = 1000;
97
103 static const unsigned int HA_REMOTE_COMMAND = 2000;
104
107 static const unsigned int DB_CONNECTION = 3000;
108
110 typedef std::set<SubnetID> Subnets;
111
113 typedef std::set<std::string> Networks;
114
116 NetworkState(const ServerType& server_type);
117
125 void disableService(unsigned int origin);
126
134 void enableService(unsigned int origin);
135
141
147 void delayedEnableService(const unsigned int seconds,
148 unsigned int origin);
149
153 bool isServiceEnabled() const;
154
162 bool isDelayedEnableService() const;
163
165
166
173 void selectiveDisable(const NetworkState::Subnets& subnets);
174
181 void selectiveDisable(const NetworkState::Networks& networks);
182
189 void selectiveEnable(const NetworkState::Subnets& subnets);
190
197 void selectiveEnable(const NetworkState::Networks& networks);
198
200
201private:
202
204 boost::shared_ptr<NetworkStateImpl> impl_;
205
207 const boost::scoped_ptr<std::mutex> mutex_;
208};
209
211typedef boost::shared_ptr<NetworkState> NetworkStatePtr;
212
213} // end of namespace isc::dhcp
214} // end of namespace isc
215
216#endif // NETWORK_STATE_H
Controls the DHCP service enabling status.
Definition: network_state.h:71
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.
static const unsigned int USER_COMMAND
Origin of the network state transition.
Definition: network_state.h:90
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.
Definition: network_state.h:96
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 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.
ServerType
DHCP server type.
Definition: network_state.h:75
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.
boost::shared_ptr< NetworkState > NetworkStatePtr
Pointer to the NetworkState object.
Defines the logger used by the top-level component of kea-lfc.