Kea: netconf.h Source File

| Kea 3.2.0-git

netconf.h
Go to the documentation of this file.
1// Copyright (C) 2018-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
8
9#ifndef NETCONF_H
10#define NETCONF_H
11
12#include <netconf/control_socket.h>
13#include <netconf/http_control_socket.h>
14#include <netconf/netconf_cfg_mgr.h>
15#include <netconf/stdout_control_socket.h>
16#include <netconf/unix_control_socket.h>
17
18#include <map>
19
20#ifdef WDEPRECATED_LITERAL_OPERATOR_FLAG_SUPPORTED
21#pragma GCC diagnostic push
22#pragma GCC diagnostic ignored "-Wdeprecated-literal-operator"
23#endif
24// #include <sysrepo-cpp/Changes.hpp> // Will be required on newer sysrepo-cpp
25#include <sysrepo-cpp/Session.hpp>
26// #include <sysrepo-cpp/Subscription.hpp> // Will be required on newer sysrepo-cpp
27#ifdef WDEPRECATED_LITERAL_OPERATOR_FLAG_SUPPORTED
28#pragma GCC diagnostic pop
29#endif
30
31namespace isc {
32namespace netconf {
33
35class NetconfAgent;
36
38 using NetconfAgentPtr = std::shared_ptr<NetconfAgent>;
39
48 class NetconfAgent {
49public:
51 virtual ~NetconfAgent();
52
57 void initSysrepo();
58
67 void init(NetconfCfgMgrPtr cfg_mgr);
68
72 void clear();
73
81 static sysrepo::ErrorCode change(sysrepo::Session sess, const CfgServersMapPair& service_pair);
82
91 static sysrepo::ErrorCode done(sysrepo::Session sess, const CfgServersMapPair& service_pair);
92
101 static void logChanges(sysrepo::Session sess, std::string_view const& model);
102
103protected:
111 void keaConfig(const CfgServersMapPair& service_pair);
112
120 bool checkModule(const std::string& module_name) const;
121
126 void getModules();
127
139 void checkModules(CfgServersMapPtr const& servers = {}) const;
140
152 void yangConfig(const CfgServersMapPair& service_pair);
153
157 void subscribeToDataChanges(const CfgServersMapPair& service_pair);
158
162 void subscribeToNotifications(const CfgServersMapPair& service_pair);
163
166 void announceShutdown() const;
167
169 bool shouldShutdown() const;
170
172 std::optional<sysrepo::Session> startup_sess_;
173
175 std::optional<sysrepo::Session> running_sess_;
176
178 std::map<const std::string, const std::string> modules_;
179
181 std::map<const std::string, sysrepo::Subscription> subscriptions_;
182}; // NetconfAgent
183
184} // namespace netconf
185} // namespace isc
186
187#endif // NETCONF_H
isc::netconf::NetconfAgent
Netconf agent.
Definition netconf.h:48
isc::netconf::NetconfAgent::subscribeToDataChanges
void subscribeToDataChanges(const CfgServersMapPair &service_pair)
Subscribe changes for a module in YANG datastore.
Definition netconf.cc:427
isc::netconf::NetconfAgent::running_sess_
std::optional< sysrepo::Session > running_sess_
Sysrepo running datastore session.
Definition netconf.h:175
isc::netconf::NetconfAgent::getModules
void getModules()
Retrieve names and revisions of installed modules through the sysrepo API.
Definition netconf.cc:265
isc::netconf::NetconfAgent::logChanges
static void logChanges(sysrepo::Session sess, std::string_view const &model)
Log changes.
Definition netconf.cc:699
isc::netconf::NetconfAgent::yangConfig
void yangConfig(const CfgServersMapPair &service_pair)
Retrieve Kea server configuration from the YANG startup datastore and applies it to servers.
Definition netconf.cc:342
isc::netconf::NetconfAgent::~NetconfAgent
virtual ~NetconfAgent()
Destructor (call clear).
Definition netconf.cc:150
isc::netconf::NetconfAgent::initSysrepo
void initSysrepo()
Initialize sysrepo sessions.
Definition netconf.cc:250
isc::netconf::NetconfAgent::keaConfig
void keaConfig(const CfgServersMapPair &service_pair)
Get and display Kea server configuration.
Definition netconf.cc:190
isc::netconf::NetconfAgent::announceShutdown
void announceShutdown() const
Set the shutdown flag of the process to true so that it can exit at the earliest convenient time.
Definition netconf.cc:746
isc::netconf::NetconfAgent::checkModules
void checkModules(CfgServersMapPtr const &servers={}) const
Check module availability.
Definition netconf.cc:310
isc::netconf::NetconfAgent::subscriptions_
std::map< const std::string, sysrepo::Subscription > subscriptions_
Subscription map.
Definition netconf.h:181
isc::netconf::NetconfAgent::shouldShutdown
bool shouldShutdown() const
Check the shutdown flag of the process.
Definition netconf.cc:756
isc::netconf::NetconfAgent::clear
void clear()
Clear.
Definition netconf.cc:183
isc::netconf::NetconfAgent::change
static sysrepo::ErrorCode change(sysrepo::Session sess, const CfgServersMapPair &service_pair)
Event::Change callback.
Definition netconf.cc:522
isc::netconf::NetconfAgent::startup_sess_
std::optional< sysrepo::Session > startup_sess_
Sysrepo startup datastore session.
Definition netconf.h:172
isc::netconf::NetconfAgent::done
static sysrepo::ErrorCode done(sysrepo::Session sess, const CfgServersMapPair &service_pair)
Event::Done callback.
Definition netconf.cc:606
isc::netconf::NetconfAgent::init
void init(NetconfCfgMgrPtr cfg_mgr)
Initialization.
Definition netconf.cc:155
isc::netconf::NetconfAgent::subscribeToNotifications
void subscribeToNotifications(const CfgServersMapPair &service_pair)
Subscribe to notifications for a given YANG module.
Definition netconf.cc:476
isc::netconf::NetconfAgent::checkModule
bool checkModule(const std::string &module_name) const
Check essential module availability.
Definition netconf.cc:285
isc::netconf::NetconfAgent::modules_
std::map< const std::string, const std::string > modules_
Available modules and revisions in Sysrepo.
Definition netconf.h:178
control_socket.h
Contains declarations for control socket communication.
http_control_socket.h
Contains declarations for HTTP control socket communication.
isc::netconf
Definition control_socket.cc:20
isc::netconf::CfgServersMapPair
std::pair< std::string, CfgServerPtr > CfgServersMapPair
Defines a iterator pairing of name and CfgServer.
Definition netconf_config.h:278
isc::netconf::NetconfAgentPtr
std::shared_ptr< NetconfAgent > NetconfAgentPtr
Type definition for the pointer to the NetconfAgent.
Definition netconf.h:38
isc::netconf::NetconfCfgMgrPtr
boost::shared_ptr< NetconfCfgMgr > NetconfCfgMgrPtr
Defines a shared pointer to NetconfCfgMgr.
Definition netconf_cfg_mgr.h:176
isc::netconf::CfgServersMapPtr
std::shared_ptr< CfgServersMap > CfgServersMapPtr
Defines a pointer to map of CfgServers.
Definition netconf_config.h:281
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
netconf_cfg_mgr.h
stdout_control_socket.h
Contains declarations for stdout control socket communication.
unix_control_socket.h
Contains declarations for UNIX control socket communication.