43namespace ph = std::placeholders;
48struct CtrlDhcp4Hooks {
49 int hooks_index_dhcp4_srv_configured_;
53 hooks_index_dhcp4_srv_configured_ = HooksManager::registerHook(
"dhcp4_srv_configured");
73void signalHandler(
int signo) {
75 if (signo == SIGHUP) {
76 ControlledDhcpv4Srv::processCommand(
"config-reload",
78 }
else if ((signo == SIGTERM) || (signo == SIGINT)) {
79 ControlledDhcpv4Srv::processCommand(
"shutdown",
94 start_ = boost::posix_time::second_clock::universal_time();
102 string reason = comment ? comment->stringValue() :
103 "no details available";
135 if (file_name.empty()) {
138 " Please use -c command line option.");
152 "a map, i.e., start with { and end with } and contain "
153 "at least an entry called 'Dhcp4' that itself is a map. "
155 <<
" is a valid JSON, but its top element is not a map."
156 " Did you forget to add { } around your configuration?");
166 "processCommand(\"config-set\", json)");
174 string reason = comment ? comment->stringValue() :
175 "no details available";
178 }
catch (
const std::exception& ex) {
184 .arg(file_name).arg(ex.what());
186 << file_name <<
"': " << ex.
what());
190 .arg(MultiThreadingMgr::instance().getMode() ?
"yes" :
"no")
191 .arg(MultiThreadingMgr::instance().getThreadPoolSize())
192 .arg(MultiThreadingMgr::instance().getPacketQueueSize());
198ControlledDhcpv4Srv::commandShutdownHandler(
const string&,
ConstElementPtr args) {
207 if (args->getType() != Element::map) {
213 if (param->getType() != Element::integer) {
215 "parameter 'exit-value' is not an integer"));
218 exit_value = param->intValue();
227ControlledDhcpv4Srv::commandLibReloadHandler(
const string&,
ConstElementPtr) {
232 MultiThreadingMgr::instance().getThreadPool().reset();
237 HooksManager::prepareUnloadLibraries();
238 static_cast<void>(HooksManager::unloadLibraries());
239 bool status = HooksManager::loadLibraries(loaded);
241 isc_throw(Unexpected,
"Failed to reload hooks libraries.");
243 }
catch (
const std::exception& ex) {
249 "Hooks libraries successfully reloaded.");
254ControlledDhcpv4Srv::commandConfigReloadHandler(
const string&,
263 }
catch (
const std::exception& ex) {
270 "Config reload failed: " +
string(ex.what())));
275ControlledDhcpv4Srv::commandConfigGetHandler(
const string&,
283ControlledDhcpv4Srv::commandConfigWriteHandler(
const string&,
288 if (args->getType() != Element::map) {
292 if (filename_param) {
293 if (filename_param->getType() != Element::string) {
295 "passed parameter 'filename' is not a string"));
297 filename = filename_param->stringValue();
301 if (filename.empty()) {
307 if (filename.empty()) {
309 "Please specify filename explicitly."));
328 params->set(
"size", Element::create(
static_cast<long long>(size)));
329 params->set(
"filename", Element::create(filename));
332 + filename +
" successful", params));
336ControlledDhcpv4Srv::commandConfigSetHandler(
const string&,
345 message =
"Missing mandatory 'arguments' parameter.";
347 dhcp4 = args->get(
"Dhcp4");
349 message =
"Missing mandatory 'Dhcp4' parameter.";
350 }
else if (dhcp4->getType() != Element::map) {
351 message =
"'Dhcp4' parameter expected to be a map.";
356 if (message.empty()) {
357 for (
auto obj : args->mapValue()) {
358 const string& obj_name = obj.first;
359 if (obj_name !=
"Dhcp4") {
362 if (message.empty()) {
363 message =
"Unsupported '" + obj_name +
"' parameter";
365 message +=
" (and '" + obj_name +
"')";
369 if (!message.empty()) {
374 if (!message.empty()) {
387 MultiThreadingMgr::instance().apply(
false, 0, 0);
435ControlledDhcpv4Srv::commandConfigTestHandler(
const string&,
444 message =
"Missing mandatory 'arguments' parameter.";
446 dhcp4 = args->get(
"Dhcp4");
448 message =
"Missing mandatory 'Dhcp4' parameter.";
449 }
else if (dhcp4->getType() != Element::map) {
450 message =
"'Dhcp4' parameter expected to be a map.";
455 if (message.empty()) {
456 for (
auto obj : args->mapValue()) {
457 const string& obj_name = obj.first;
458 if (obj_name !=
"Dhcp4") {
461 if (message.empty()) {
462 message =
"Unsupported '" + obj_name +
"' parameter";
464 message +=
" (and '" + obj_name +
"')";
468 if (!message.empty()) {
473 if (!message.empty()) {
493ControlledDhcpv4Srv::commandDhcpDisableHandler(
const std::string&,
495 std::ostringstream message;
496 int64_t max_period = 0;
507 if (args->getType() != Element::map) {
508 message <<
"arguments for the 'dhcp-disable' command must be a map";
513 if (max_period_element) {
515 if (max_period_element->getType() != Element::integer) {
516 message <<
"'max-period' argument must be a number";
520 max_period = max_period_element->intValue();
521 if (max_period <= 0) {
522 message <<
"'max-period' must be positive integer";
528 if (origin_element) {
530 if (origin_element->getType() != Element::string) {
531 message <<
"'origin' argument must be a string";
534 origin = origin_element->stringValue();
535 if (origin ==
"ha-partner") {
537 }
else if (origin !=
"user") {
538 if (origin.empty()) {
539 origin =
"(empty string)";
541 message <<
"invalid value used for 'origin' parameter: "
550 if (message.tellp() == 0) {
551 message <<
"DHCPv4 service disabled";
552 if (max_period > 0) {
553 message <<
" for " << max_period <<
" seconds";
558 network_state_->delayedEnableAll(
static_cast<unsigned>(max_period),
572ControlledDhcpv4Srv::commandDhcpEnableHandler(
const std::string&,
574 std::ostringstream message;
584 if (args->getType() != Element::map) {
585 message <<
"arguments for the 'dhcp-enable' command must be a map";
590 if (origin_element) {
592 if (origin_element->getType() != Element::string) {
593 message <<
"'origin' argument must be a string";
596 origin = origin_element->stringValue();
597 if (origin ==
"ha-partner") {
599 }
else if (origin !=
"user") {
600 if (origin.empty()) {
601 origin =
"(empty string)";
603 message <<
"invalid value used for 'origin' parameter: "
612 if (message.tellp() == 0) {
617 "DHCP service successfully enabled"));
625ControlledDhcpv4Srv::commandVersionGetHandler(
const string&,
ConstElementPtr) {
628 arguments->set(
"extended", extended);
636ControlledDhcpv4Srv::commandBuildReportHandler(
const string&,
644ControlledDhcpv4Srv::commandLeasesReclaimHandler(
const string&,
651 message =
"Missing mandatory 'remove' parameter.";
655 message =
"Missing mandatory 'remove' parameter.";
656 }
else if (remove_name->getType() != Element::boolean) {
657 message =
"'remove' parameter expected to be a boolean.";
659 bool remove_lease = remove_name->boolValue();
660 server_->
alloc_engine_->reclaimExpiredLeases4(0, 0, remove_lease);
662 message =
"Reclamation of expired leases is complete.";
670ControlledDhcpv4Srv::commandServerTagGetHandler(
const std::string&,
672 const std::string& tag =
675 response->set(
"server-tag", Element::create(tag));
681ControlledDhcpv4Srv::commandConfigBackendPullHandler(
const std::string&,
703 server_->
getCBControl()->databaseConfigFetch(srv_cfg, mode);
704 }
catch (
const std::exception& ex) {
708 "On demand configuration update failed: " +
712 "On demand configuration update successful."));
716ControlledDhcpv4Srv::commandStatusGetHandler(
const string&,
719 status->set(
"pid", Element::create(
static_cast<int>(getpid())));
721 auto now = boost::posix_time::second_clock::universal_time();
723 if (!
start_.is_not_a_date_time()) {
724 auto uptime = now -
start_;
725 status->set(
"uptime", Element::create(uptime.total_seconds()));
729 if (!last_commit.is_not_a_date_time()) {
730 auto reload = now - last_commit;
731 status->set(
"reload", Element::create(reload.total_seconds()));
734 auto& mt_mgr = MultiThreadingMgr::instance();
735 if (mt_mgr.getMode()) {
736 status->set(
"multi-threading-enabled", Element::create(
true));
737 status->set(
"thread-pool-size", Element::create(
static_cast<int32_t
>(
738 MultiThreadingMgr::instance().getThreadPoolSize())));
739 status->set(
"packet-queue-size", Element::create(
static_cast<int32_t
>(
740 MultiThreadingMgr::instance().getPacketQueueSize())));
741 ElementPtr queue_stats = Element::createList();
742 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(10)));
743 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(100)));
744 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(1000)));
745 status->set(
"packet-queue-statistics", queue_stats);
748 status->set(
"multi-threading-enabled", Element::create(
false));
755ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler(
const string&,
757 StatsMgr& stats_mgr = StatsMgr::instance();
762 "statistic-default-sample-count", Element::create(max_samples));
767ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler(
const string&,
769 StatsMgr& stats_mgr = StatsMgr::instance();
775 "statistic-default-sample-age", Element::create(max_age));
782 string txt = args ? args->str() :
"(none)";
785 .arg(command).arg(txt);
791 "Server object not initialized, so can't process command '" +
792 command +
"', arguments: '" + txt +
"'.");
797 if (command ==
"shutdown") {
798 return (srv->commandShutdownHandler(command, args));
800 }
else if (command ==
"libreload") {
801 return (srv->commandLibReloadHandler(command, args));
803 }
else if (command ==
"config-reload") {
804 return (srv->commandConfigReloadHandler(command, args));
806 }
else if (command ==
"config-set") {
807 return (srv->commandConfigSetHandler(command, args));
809 }
else if (command ==
"config-get") {
810 return (srv->commandConfigGetHandler(command, args));
812 }
else if (command ==
"config-test") {
813 return (srv->commandConfigTestHandler(command, args));
815 }
else if (command ==
"dhcp-disable") {
816 return (srv->commandDhcpDisableHandler(command, args));
818 }
else if (command ==
"dhcp-enable") {
819 return (srv->commandDhcpEnableHandler(command, args));
821 }
else if (command ==
"version-get") {
822 return (srv->commandVersionGetHandler(command, args));
824 }
else if (command ==
"build-report") {
825 return (srv->commandBuildReportHandler(command, args));
827 }
else if (command ==
"leases-reclaim") {
828 return (srv->commandLeasesReclaimHandler(command, args));
830 }
else if (command ==
"config-write") {
831 return (srv->commandConfigWriteHandler(command, args));
833 }
else if (command ==
"server-tag-get") {
834 return (srv->commandServerTagGetHandler(command, args));
836 }
else if (command ==
"config-backend-pull") {
837 return (srv->commandConfigBackendPullHandler(command, args));
839 }
else if (command ==
"status-get") {
840 return (srv->commandStatusGetHandler(command, args));
848 + command +
"':" + ex.
what() +
849 ", params: '" + txt +
"'"));
858 std::ostringstream err;
861 err <<
"Server object not initialized, can't process config.";
878 }
catch (
const std::exception& ex) {
879 err <<
"Failed to process configuration:" << ex.what();
886 std::bind(&ControlledDhcpv4Srv::dbLostCallback, srv, ph::_1);
889 std::bind(&ControlledDhcpv4Srv::dbRecoveredCallback, srv, ph::_1);
892 std::bind(&ControlledDhcpv4Srv::dbFailedCallback, srv, ph::_1);
895 cfg_db->setAppendedParameters(
"universe=4");
896 cfg_db->createManagers();
899 }
catch (
const std::exception& ex) {
900 err <<
"Unable to open database: " << ex.what();
907 }
catch (
const std::exception& ex) {
908 err <<
"Error starting DHCP_DDNS client after server reconfiguration: "
916 }
catch (
const std::exception& ex) {
917 std::ostringstream err;
918 err <<
"error starting DHCPv4-over-DHCPv6 IPC "
919 " after server reconfiguration: " << ex.what();
932 }
catch (
const std::exception& ex) {
933 err <<
"Error setting packet queue controls after server reconfiguration: "
952 setupTimers(&ControlledDhcpv4Srv::reclaimExpiredLeases,
953 &ControlledDhcpv4Srv::deleteExpiredReclaimedLeases,
956 }
catch (
const std::exception& ex) {
957 err <<
"unable to setup timers for periodically running the"
958 " reclamation of the expired leases: "
966 long fetch_time =
static_cast<long>(ctl_info->getConfigFetchWaitTime());
969 if (fetch_time > 0) {
976 fetch_time = 1000 * fetch_time;
979 boost::shared_ptr<unsigned> failure_count(
new unsigned(0));
981 registerTimer(
"Dhcp4CBFetchTimer",
982 std::bind(&ControlledDhcpv4Srv::cbFetchUpdates,
1000 if (HooksManager::calloutsPresent(
Hooks.hooks_index_dhcp4_srv_configured_)) {
1003 callout_handle->setArgument(
"io_context", srv->
getIOService());
1005 callout_handle->setArgument(
"json_config", config);
1006 callout_handle->setArgument(
"server_config",
CfgMgr::instance().getStagingCfg());
1008 HooksManager::callCallouts(
Hooks.hooks_index_dhcp4_srv_configured_,
1021 }
catch (
const std::exception& ex) {
1022 err <<
"Error applying multi threading settings: "
1039 std::ostringstream err;
1042 err <<
"Server object not initialized, can't process config.";
1050 uint16_t client_port )
1054 "There is another Dhcpv4Srv instance already.");
1072 CommandMgr::instance().registerCommand(
"build-report",
1073 std::bind(&ControlledDhcpv4Srv::commandBuildReportHandler,
this, ph::_1, ph::_2));
1075 CommandMgr::instance().registerCommand(
"config-backend-pull",
1076 std::bind(&ControlledDhcpv4Srv::commandConfigBackendPullHandler,
this, ph::_1, ph::_2));
1078 CommandMgr::instance().registerCommand(
"config-get",
1079 std::bind(&ControlledDhcpv4Srv::commandConfigGetHandler,
this, ph::_1, ph::_2));
1081 CommandMgr::instance().registerCommand(
"config-reload",
1082 std::bind(&ControlledDhcpv4Srv::commandConfigReloadHandler,
this, ph::_1, ph::_2));
1084 CommandMgr::instance().registerCommand(
"config-set",
1085 std::bind(&ControlledDhcpv4Srv::commandConfigSetHandler,
this, ph::_1, ph::_2));
1087 CommandMgr::instance().registerCommand(
"config-test",
1088 std::bind(&ControlledDhcpv4Srv::commandConfigTestHandler,
this, ph::_1, ph::_2));
1090 CommandMgr::instance().registerCommand(
"config-write",
1091 std::bind(&ControlledDhcpv4Srv::commandConfigWriteHandler,
this, ph::_1, ph::_2));
1093 CommandMgr::instance().registerCommand(
"dhcp-enable",
1094 std::bind(&ControlledDhcpv4Srv::commandDhcpEnableHandler,
this, ph::_1, ph::_2));
1096 CommandMgr::instance().registerCommand(
"dhcp-disable",
1097 std::bind(&ControlledDhcpv4Srv::commandDhcpDisableHandler,
this, ph::_1, ph::_2));
1099 CommandMgr::instance().registerCommand(
"libreload",
1100 std::bind(&ControlledDhcpv4Srv::commandLibReloadHandler,
this, ph::_1, ph::_2));
1102 CommandMgr::instance().registerCommand(
"leases-reclaim",
1103 std::bind(&ControlledDhcpv4Srv::commandLeasesReclaimHandler,
this, ph::_1, ph::_2));
1105 CommandMgr::instance().registerCommand(
"server-tag-get",
1106 std::bind(&ControlledDhcpv4Srv::commandServerTagGetHandler,
this, ph::_1, ph::_2));
1108 CommandMgr::instance().registerCommand(
"shutdown",
1109 std::bind(&ControlledDhcpv4Srv::commandShutdownHandler,
this, ph::_1, ph::_2));
1111 CommandMgr::instance().registerCommand(
"status-get",
1112 std::bind(&ControlledDhcpv4Srv::commandStatusGetHandler,
this, ph::_1, ph::_2));
1114 CommandMgr::instance().registerCommand(
"version-get",
1115 std::bind(&ControlledDhcpv4Srv::commandVersionGetHandler,
this, ph::_1, ph::_2));
1118 CommandMgr::instance().registerCommand(
"statistic-get",
1119 std::bind(&StatsMgr::statisticGetHandler, ph::_1, ph::_2));
1121 CommandMgr::instance().registerCommand(
"statistic-reset",
1122 std::bind(&StatsMgr::statisticResetHandler, ph::_1, ph::_2));
1124 CommandMgr::instance().registerCommand(
"statistic-remove",
1125 std::bind(&StatsMgr::statisticRemoveHandler, ph::_1, ph::_2));
1127 CommandMgr::instance().registerCommand(
"statistic-get-all",
1128 std::bind(&StatsMgr::statisticGetAllHandler, ph::_1, ph::_2));
1130 CommandMgr::instance().registerCommand(
"statistic-reset-all",
1131 std::bind(&StatsMgr::statisticResetAllHandler, ph::_1, ph::_2));
1133 CommandMgr::instance().registerCommand(
"statistic-remove-all",
1134 std::bind(&StatsMgr::statisticRemoveAllHandler, ph::_1, ph::_2));
1136 CommandMgr::instance().registerCommand(
"statistic-sample-age-set",
1137 std::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, ph::_1, ph::_2));
1139 CommandMgr::instance().registerCommand(
"statistic-sample-age-set-all",
1140 std::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler,
this, ph::_1, ph::_2));
1142 CommandMgr::instance().registerCommand(
"statistic-sample-count-set",
1143 std::bind(&StatsMgr::statisticSetMaxSampleCountHandler, ph::_1, ph::_2));
1145 CommandMgr::instance().registerCommand(
"statistic-sample-count-set-all",
1146 std::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler,
this, ph::_1, ph::_2));
1167 timer_mgr_->unregisterTimers();
1170 CommandMgr::instance().closeCommandSocket();
1173 CommandMgr::instance().deregisterCommand(
"build-report");
1174 CommandMgr::instance().deregisterCommand(
"config-backend-pull");
1175 CommandMgr::instance().deregisterCommand(
"config-get");
1176 CommandMgr::instance().deregisterCommand(
"config-reload");
1177 CommandMgr::instance().deregisterCommand(
"config-set");
1178 CommandMgr::instance().deregisterCommand(
"config-test");
1179 CommandMgr::instance().deregisterCommand(
"config-write");
1180 CommandMgr::instance().deregisterCommand(
"dhcp-disable");
1181 CommandMgr::instance().deregisterCommand(
"dhcp-enable");
1182 CommandMgr::instance().deregisterCommand(
"leases-reclaim");
1183 CommandMgr::instance().deregisterCommand(
"libreload");
1184 CommandMgr::instance().deregisterCommand(
"server-tag-get");
1185 CommandMgr::instance().deregisterCommand(
"shutdown");
1186 CommandMgr::instance().deregisterCommand(
"statistic-get");
1187 CommandMgr::instance().deregisterCommand(
"statistic-get-all");
1188 CommandMgr::instance().deregisterCommand(
"statistic-remove");
1189 CommandMgr::instance().deregisterCommand(
"statistic-remove-all");
1190 CommandMgr::instance().deregisterCommand(
"statistic-reset");
1191 CommandMgr::instance().deregisterCommand(
"statistic-reset-all");
1192 CommandMgr::instance().deregisterCommand(
"statistic-sample-age-set");
1193 CommandMgr::instance().deregisterCommand(
"statistic-sample-age-set-all");
1194 CommandMgr::instance().deregisterCommand(
"statistic-sample-count-set");
1195 CommandMgr::instance().deregisterCommand(
"statistic-sample-count-set-all");
1196 CommandMgr::instance().deregisterCommand(
"status-get");
1197 CommandMgr::instance().deregisterCommand(
"version-get");
1215ControlledDhcpv4Srv::reclaimExpiredLeases(
const size_t max_leases,
1216 const uint16_t timeout,
1217 const bool remove_lease,
1218 const uint16_t max_unwarned_cycles) {
1220 server_->
alloc_engine_->reclaimExpiredLeases4(max_leases, timeout,
1222 max_unwarned_cycles);
1223 }
catch (
const std::exception& ex) {
1232ControlledDhcpv4Srv::deleteExpiredReclaimedLeases(
const uint32_t secs) {
1233 server_->
alloc_engine_->deleteExpiredReclaimedLeases4(secs);
1239ControlledDhcpv4Srv::dbLostCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1240 if (!db_reconnect_ctl) {
1247 if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
1248 db_reconnect_ctl->alterServiceState()) {
1256 if (!db_reconnect_ctl->retriesLeft() ||
1257 !db_reconnect_ctl->retryInterval()) {
1259 .arg(db_reconnect_ctl->retriesLeft())
1260 .arg(db_reconnect_ctl->retryInterval());
1261 if (db_reconnect_ctl->exitOnFailure()) {
1271ControlledDhcpv4Srv::dbRecoveredCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1272 if (!db_reconnect_ctl) {
1279 if (db_reconnect_ctl->alterServiceState()) {
1285 db_reconnect_ctl->resetRetries();
1291ControlledDhcpv4Srv::dbFailedCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1292 if (!db_reconnect_ctl) {
1299 .arg(db_reconnect_ctl->maxRetries());
1301 if (db_reconnect_ctl->exitOnFailure()) {
1309ControlledDhcpv4Srv::cbFetchUpdates(
const SrvConfigPtr& srv_cfg,
1310 boost::shared_ptr<unsigned> failure_count) {
1318 (*failure_count) = 0;
1320 }
catch (
const std::exception& ex) {
1327 if (++(*failure_count) > 10) {
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown if a function is called in a prohibited way.
Implements an asynchronous "signal" for IOService driven processing.
static DbCallback db_recovered_callback_
Optional callback function to invoke if an opened connection recovery succeeded.
static DbCallback db_failed_callback_
Optional callback function to invoke if an opened connection recovery failed.
static DbCallback db_lost_callback_
Optional callback function to invoke if an opened connection is lost.
static const std::string FLUSH_RECLAIMED_TIMER_NAME
Name of the timer for flushing reclaimed leases.
static const std::string RECLAIM_EXPIRED_TIMER_NAME
Name of the timer for reclaiming expired leases.
void rollback()
Removes staging configuration.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
void commit()
Commits the staging configuration.
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
static void apply(data::ConstElementPtr value)
apply multi threading configuration
Controlled version of the DHCPv4 server.
static isc::data::ConstElementPtr processConfig(isc::data::ConstElementPtr new_config)
Configuration processor.
virtual ~ControlledDhcpv4Srv()
Destructor.
isc::data::ConstElementPtr loadConfigFile(const std::string &file_name)
Configure DHCPv4 server using the configuration file specified.
void cleanup()
Performs cleanup, immediately before termination.
static isc::data::ConstElementPtr processCommand(const std::string &command, isc::data::ConstElementPtr args)
Command processor.
ControlledDhcpv4Srv(uint16_t server_port=DHCP4_SERVER_PORT, uint16_t client_port=0)
Constructor.
void init(const std::string &config_file)
Initializes the server.
static ControlledDhcpv4Srv * getInstance()
Returns pointer to the sole instance of Dhcpv4Srv.
void shutdownServer(int exit_value)
Initiates shutdown procedure for the whole DHCPv4 server.
isc::data::ConstElementPtr checkConfig(isc::data::ConstElementPtr new_config)
Configuration checker.
static Dhcp4to6Ipc & instance()
Returns pointer to the sole instance of Dhcp4to6Ipc.
virtual void open()
Open communication socket.
void startD2()
Starts DHCP_DDNS client IO if DDNS updates are enabled.
void shutdown() override
Instructs the server to shut down.
asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service used by the server.
boost::shared_ptr< AllocEngine > alloc_engine_
Allocation Engine.
bool inTestMode() const
Checks if the server is running in unit test mode.
NetworkStatePtr & getNetworkState()
Returns pointer to the network state used by the server.
static std::string getVersion(bool extended)
returns Kea version on stdout and exit.
bool useBroadcast() const
Return bool value indicating that broadcast flags should be set on sockets.
NetworkStatePtr network_state_
Holds information about disabled DHCP service and/or disabled subnet/network scopes.
uint16_t getServerPort() const
Get UDP port on which server should listen.
CBControlDHCPv4Ptr getCBControl() const
Returns an object which controls access to the configuration backends.
static void setIOService(const isc::asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Host Manager.
static void create()
Creates new instance of the HostMgr.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
static void destroy()
Destroy lease manager.
static void setIOService(const isc::asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Lease Manager.
static void commitRuntimeOptionDefs()
Commits runtime option definitions.
Origin
Origin of the network state transition.
@ USER_COMMAND
The network state is being altered by a user command.
@ DB_CONNECTION
The network state is being altered by the DB connection recovery mechanics.
@ HA_COMMAND
The network state is being altered by a HA internal command.
Evaluation context, an interface to the expression evaluation.
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
@ PARSER_DHCP4
This parser will parse the content as Dhcp4 config wrapped in a map (that's the regular config file)
Manages a pool of asynchronous interval timers.
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
std::string getConfigFile() const
Returns config file name.
virtual size_t writeConfigFile(const std::string &config_file, isc::data::ConstElementPtr cfg=isc::data::ConstElementPtr()) const
Writes current configuration to specified file.
isc::asiolink::IOSignalSetPtr signal_set_
A pointer to the object installing custom signal handlers.
boost::posix_time::ptime start_
Timestamp of the start of the daemon.
void setExitValue(int value)
Sets the exit value.
isc::data::ConstElementPtr redactConfig(isc::data::ConstElementPtr const &config)
Redact a configuration.
Statistics Manager class.
RAII class creating a critical section.
This file contains several functions and constants that are used for handling commands and responses ...
Contains declarations for loggers used by the DHCPv4 server component.
Defines the Dhcp4o6Ipc class.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
isc::data::ConstElementPtr statisticSetMaxSampleCountAllHandler(const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-count-set-all command.
isc::data::ConstElementPtr statisticSetMaxSampleAgeAllHandler(const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-age-set-all command.
uint32_t getMaxSampleCountDefault() const
Get default count limit.
const StatsDuration & getMaxSampleAgeDefault() const
Get default duration limit.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
#define LOG_FATAL(LOGGER, MESSAGE)
Macro to conveniently test fatal output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
std::string getConfigReport()
const isc::log::MessageID DHCP4_NOT_RUNNING
const isc::log::MessageID DHCP4_DYNAMIC_RECONFIGURATION_FAIL
const isc::log::MessageID DHCP4_CONFIG_RECEIVED
const isc::log::MessageID DHCP4_DYNAMIC_RECONFIGURATION_SUCCESS
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
const isc::log::MessageID DHCP4_DB_RECONNECT_NO_DB_CTL
isc::data::ConstElementPtr configureDhcp4Server(Dhcpv4Srv &server, isc::data::ConstElementPtr config_set, bool check_only)
Configure DHCPv4 server (Dhcpv4Srv) with a set of configuration values.
const isc::log::MessageID DHCP4_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED
const isc::log::MessageID DHCP4_CONFIG_PACKET_QUEUE
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
const isc::log::MessageID DHCP4_CB_ON_DEMAND_FETCH_UPDATES_FAIL
const isc::log::MessageID DHCP4_CONFIG_LOAD_FAIL
const int DBG_DHCP4_COMMAND
Debug level used to log receiving commands.
const isc::log::MessageID DHCP4_HOOKS_LIBS_RELOAD_FAIL
const isc::log::MessageID DHCP4_DB_RECONNECT_DISABLED
const isc::log::MessageID DHCP4_CONFIG_UNRECOVERABLE_ERROR
const isc::log::MessageID DHCP4_DB_RECONNECT_SUCCEEDED
const isc::log::MessageID DHCP4_COMMAND_RECEIVED
const isc::log::MessageID DHCP4_MULTI_THREADING_INFO
isc::log::Logger dhcp4_logger(DHCP4_APP_LOGGER_NAME)
Base logger for DHCPv4 server.
const isc::log::MessageID DHCP4_DB_RECONNECT_FAILED
const isc::log::MessageID DHCP4_DYNAMIC_RECONFIGURATION
const isc::log::MessageID DHCP4_RECLAIM_EXPIRED_LEASES_FAIL
const isc::log::MessageID DHCP4_CONFIG_UNSUPPORTED_OBJECT
const isc::log::MessageID DHCP4_CB_PERIODIC_FETCH_UPDATES_FAIL
const isc::log::MessageID DHCP4_DB_RECONNECT_LOST_CONNECTION
std::vector< HookLibInfo > HookLibsCollection
A storage for information about hook libraries.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
long toSeconds(const StatsDuration &dur)
Returns the number of seconds in a duration.
Defines the logger used by the top-level component of kea-lfc.