43 namespace ph = std::placeholders;
48 struct CtrlDhcp6Hooks {
49 int hooks_index_dhcp6_srv_configured_;
53 hooks_index_dhcp6_srv_configured_ = HooksManager::registerHook(
"dhcp6_srv_configured");
65 static const char* SERVER_DUID_FILE =
"kea-dhcp6-serverid";
76 void signalHandler(
int signo) {
78 if (signo == SIGHUP) {
79 ControlledDhcpv6Srv::processCommand(
"config-reload",
81 }
else if ((signo == SIGTERM) || (signo == SIGINT)) {
82 ControlledDhcpv6Srv::processCommand(
"shutdown",
95 ControlledDhcpv6Srv::loadConfigFile(
const std::string& file_name) {
104 if (file_name.empty()) {
107 "use -c command line option.");
112 json = parser.
parseFile(file_name, Parser6Context::PARSER_DHCP6);
121 "a map, i.e., start with { and end with } and contain "
122 "at least an entry called 'Dhcp6' that itself is a map. "
124 <<
" is a valid JSON, but its top element is not a map."
125 " Did you forget to add { } around your configuration?");
129 result = ControlledDhcpv6Srv::processCommand(
"config-set", json);
135 "processCommand(\"config-set\", json)");
143 string reason = comment ? comment->stringValue() :
144 "no details available";
147 }
catch (
const std::exception& ex) {
150 CfgMgr::instance().rollback();
153 .arg(file_name).arg(ex.what());
155 << file_name <<
"': " << ex.
what());
159 .arg(MultiThreadingMgr::instance().getMode() ?
"yes" :
"no")
160 .arg(MultiThreadingMgr::instance().getThreadPoolSize())
161 .arg(MultiThreadingMgr::instance().getPacketQueueSize());
167 ControlledDhcpv6Srv::init(
const std::string& file_name) {
169 start_ = boost::posix_time::second_clock::universal_time();
177 string reason = comment ? comment->stringValue() :
178 "no details available";
189 signal_set_.reset(
new IOSignalSet(getIOService(), signalHandler));
191 signal_set_->add(SIGINT);
192 signal_set_->add(SIGHUP);
193 signal_set_->add(SIGTERM);
196 void ControlledDhcpv6Srv::cleanup() {
201 ControlledDhcpv6Srv::commandShutdownHandler(
const string&,
ConstElementPtr args) {
202 if (!ControlledDhcpv6Srv::getInstance()) {
210 if (args->getType() != Element::map) {
216 if (param->getType() != Element::integer) {
218 "parameter 'exit-value' is not an integer"));
221 exit_value = param->intValue();
225 ControlledDhcpv6Srv::getInstance()->shutdownServer(exit_value);
230 ControlledDhcpv6Srv::commandLibReloadHandler(
const string&,
ConstElementPtr) {
235 MultiThreadingMgr::instance().getThreadPool().reset();
240 HooksManager::prepareUnloadLibraries();
241 static_cast<void>(HooksManager::unloadLibraries());
242 bool status = HooksManager::loadLibraries(loaded);
244 isc_throw(Unexpected,
"Failed to reload hooks libraries.");
246 }
catch (
const std::exception& ex) {
252 "Hooks libraries successfully reloaded.");
257 ControlledDhcpv6Srv::commandConfigReloadHandler(
const string&,
260 std::string file = ControlledDhcpv6Srv::getInstance()->getConfigFile();
263 return (loadConfigFile(file));
264 }
catch (
const std::exception& ex) {
271 "Config reload failed: " +
string(ex.what())));
276 ControlledDhcpv6Srv::commandConfigGetHandler(
const string&,
278 ConstElementPtr config = CfgMgr::instance().getCurrentCfg()->toElement();
284 ControlledDhcpv6Srv::commandConfigWriteHandler(
const string&,
289 if (args->getType() != Element::map) {
293 if (filename_param) {
294 if (filename_param->getType() != Element::string) {
296 "passed parameter 'filename' is not a string"));
298 filename = filename_param->stringValue();
302 if (filename.empty()) {
305 filename = getConfigFile();
308 if (filename.empty()) {
310 "Please specify filename explicitly."));
317 size = writeConfigFile(filename, cfg);
329 params->set(
"size", Element::create(static_cast<long long>(size)));
330 params->set(
"filename", Element::create(filename));
333 + filename +
" successful", params));
337 ControlledDhcpv6Srv::commandConfigSetHandler(
const string&,
346 message =
"Missing mandatory 'arguments' parameter.";
348 dhcp6 = args->get(
"Dhcp6");
350 message =
"Missing mandatory 'Dhcp6' parameter.";
351 }
else if (dhcp6->getType() != Element::map) {
352 message =
"'Dhcp6' parameter expected to be a map.";
357 if (message.empty()) {
358 for (
auto obj : args->mapValue()) {
359 const string& obj_name = obj.first;
360 if (obj_name !=
"Dhcp6") {
363 if (message.empty()) {
364 message =
"Unsupported '" + obj_name +
"' parameter";
366 message +=
" (and '" + obj_name +
"')";
370 if (!message.empty()) {
375 if (!message.empty()) {
388 MultiThreadingMgr::instance().apply(
false, 0, 0);
393 CfgMgr::instance().rollback();
399 Daemon::configureLogger(dhcp6, CfgMgr::instance().getStagingCfg());
403 CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
414 CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
417 CfgMgr::instance().commit();
422 CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
424 if (CfgMgr::instance().getCurrentCfg()->getSequence() != 0) {
436 ControlledDhcpv6Srv::commandConfigTestHandler(
const string&,
445 message =
"Missing mandatory 'arguments' parameter.";
447 dhcp6 = args->get(
"Dhcp6");
449 message =
"Missing mandatory 'Dhcp6' parameter.";
450 }
else if (dhcp6->getType() != Element::map) {
451 message =
"'Dhcp6' parameter expected to be a map.";
456 if (message.empty()) {
457 for (
auto obj : args->mapValue()) {
458 const string& obj_name = obj.first;
459 if (obj_name !=
"Dhcp6") {
462 if (message.empty()) {
463 message =
"Unsupported '" + obj_name +
"' parameter";
465 message +=
" (and '" + obj_name +
"')";
469 if (!message.empty()) {
474 if (!message.empty()) {
487 CfgMgr::instance().rollback();
490 return (checkConfig(dhcp6));
494 ControlledDhcpv6Srv::commandDhcpDisableHandler(
const std::string&,
496 std::ostringstream message;
497 int64_t max_period = 0;
508 if (args->getType() != Element::map) {
509 message <<
"arguments for the 'dhcp-disable' command must be a map";
514 if (max_period_element) {
516 if (max_period_element->getType() != Element::integer) {
517 message <<
"'max-period' argument must be a number";
521 max_period = max_period_element->intValue();
522 if (max_period <= 0) {
523 message <<
"'max-period' must be positive integer";
529 if (origin_element) {
531 if (origin_element->getType() != Element::string) {
532 message <<
"'origin' argument must be a string";
535 origin = origin_element->stringValue();
536 if (origin ==
"ha-partner") {
537 type = NetworkState::Origin::HA_COMMAND;
538 }
else if (origin !=
"user") {
539 if (origin.empty()) {
540 origin =
"(empty string)";
542 message <<
"invalid value used for 'origin' parameter: "
551 if (message.tellp() == 0) {
552 message <<
"DHCPv6 service disabled";
553 if (max_period > 0) {
554 message <<
" for " << max_period <<
" seconds";
559 network_state_->delayedEnableAll(static_cast<unsigned>(max_period),
562 network_state_->disableService(type);
573 ControlledDhcpv6Srv::commandDhcpEnableHandler(
const std::string&,
575 std::ostringstream message;
585 if (args->getType() != Element::map) {
586 message <<
"arguments for the 'dhcp-enable' command must be a map";
591 if (origin_element) {
593 if (origin_element->getType() != Element::string) {
594 message <<
"'origin' argument must be a string";
597 origin = origin_element->stringValue();
598 if (origin ==
"ha-partner") {
599 type = NetworkState::Origin::HA_COMMAND;
600 }
else if (origin !=
"user") {
601 if (origin.empty()) {
602 origin =
"(empty string)";
604 message <<
"invalid value used for 'origin' parameter: "
613 if (message.tellp() == 0) {
614 network_state_->enableService(type);
618 "DHCP service successfully enabled"));
626 ControlledDhcpv6Srv::commandVersionGetHandler(
const string&,
ConstElementPtr) {
627 ElementPtr extended = Element::create(Dhcpv6Srv::getVersion(
true));
629 arguments->set(
"extended", extended);
631 Dhcpv6Srv::getVersion(
false),
637 ControlledDhcpv6Srv::commandBuildReportHandler(
const string&,
645 ControlledDhcpv6Srv::commandLeasesReclaimHandler(
const string&,
652 message =
"Missing mandatory 'remove' parameter.";
656 message =
"Missing mandatory 'remove' parameter.";
657 }
else if (remove_name->getType() != Element::boolean) {
658 message =
"'remove' parameter expected to be a boolean.";
660 bool remove_lease = remove_name->boolValue();
661 server_->alloc_engine_->reclaimExpiredLeases6(0, 0, remove_lease);
663 message =
"Reclamation of expired leases is complete.";
671 ControlledDhcpv6Srv::commandServerTagGetHandler(
const std::string&,
673 const std::string& tag =
674 CfgMgr::instance().getCurrentCfg()->getServerTag();
676 response->set(
"server-tag", Element::create(tag));
682 ControlledDhcpv6Srv::commandConfigBackendPullHandler(
const std::string&,
684 auto ctl_info = CfgMgr::instance().getCurrentCfg()->getConfigControlInfo();
693 if (TimerMgr::instance()->isTimerRegistered(
"Dhcp6CBFetchTimer")) {
694 TimerMgr::instance()->cancel(
"Dhcp6CBFetchTimer");
695 TimerMgr::instance()->setup(
"Dhcp6CBFetchTimer");
702 auto srv_cfg = CfgMgr::instance().getCurrentCfg();
703 auto mode = CBControlDHCPv6::FetchMode::FETCH_UPDATE;
704 server_->getCBControl()->databaseConfigFetch(srv_cfg, mode);
705 }
catch (
const std::exception& ex) {
709 "On demand configuration update failed: " +
713 "On demand configuration update successful."));
717 ControlledDhcpv6Srv::commandStatusGetHandler(
const string&,
720 status->set(
"pid", Element::create(static_cast<int>(getpid())));
722 auto now = boost::posix_time::second_clock::universal_time();
724 if (!start_.is_not_a_date_time()) {
725 auto uptime = now - start_;
726 status->set(
"uptime", Element::create(uptime.total_seconds()));
729 auto last_commit = CfgMgr::instance().getCurrentCfg()->getLastCommitTime();
730 if (!last_commit.is_not_a_date_time()) {
731 auto reload = now - last_commit;
732 status->set(
"reload", Element::create(reload.total_seconds()));
735 auto& mt_mgr = MultiThreadingMgr::instance();
736 if (mt_mgr.getMode()) {
737 status->set(
"multi-threading-enabled", Element::create(
true));
738 status->set(
"thread-pool-size", Element::create(static_cast<int32_t>(
739 MultiThreadingMgr::instance().getThreadPoolSize())));
740 status->set(
"packet-queue-size", Element::create(static_cast<int32_t>(
741 MultiThreadingMgr::instance().getPacketQueueSize())));
742 ElementPtr queue_stats = Element::createList();
743 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(10)));
744 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(100)));
745 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(1000)));
746 status->set(
"packet-queue-statistics", queue_stats);
749 status->set(
"multi-threading-enabled", Element::create(
false));
756 ControlledDhcpv6Srv::commandStatisticSetMaxSampleCountAllHandler(
const string&,
758 StatsMgr& stats_mgr = StatsMgr::instance();
762 CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
763 "statistic-default-sample-count", Element::create(max_samples));
768 ControlledDhcpv6Srv::commandStatisticSetMaxSampleAgeAllHandler(
const string&,
770 StatsMgr& stats_mgr = StatsMgr::instance();
775 CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
776 "statistic-default-sample-age", Element::create(max_age));
781 ControlledDhcpv6Srv::processCommand(
const string& command,
783 string txt = args ? args->str() :
"(none)";
786 .arg(command).arg(txt);
792 "Server object not initialized, so can't process command '" +
793 command +
"', arguments: '" + txt +
"'.");
798 if (command ==
"shutdown") {
799 return (srv->commandShutdownHandler(command, args));
801 }
else if (command ==
"libreload") {
802 return (srv->commandLibReloadHandler(command, args));
804 }
else if (command ==
"config-reload") {
805 return (srv->commandConfigReloadHandler(command, args));
807 }
else if (command ==
"config-set") {
808 return (srv->commandConfigSetHandler(command, args));
810 }
else if (command ==
"config-get") {
811 return (srv->commandConfigGetHandler(command, args));
813 }
else if (command ==
"config-test") {
814 return (srv->commandConfigTestHandler(command, args));
816 }
else if (command ==
"dhcp-disable") {
817 return (srv->commandDhcpDisableHandler(command, args));
819 }
else if (command ==
"dhcp-enable") {
820 return (srv->commandDhcpEnableHandler(command, args));
822 }
else if (command ==
"version-get") {
823 return (srv->commandVersionGetHandler(command, args));
825 }
else if (command ==
"build-report") {
826 return (srv->commandBuildReportHandler(command, args));
828 }
else if (command ==
"leases-reclaim") {
829 return (srv->commandLeasesReclaimHandler(command, args));
831 }
else if (command ==
"config-write") {
832 return (srv->commandConfigWriteHandler(command, args));
834 }
else if (command ==
"server-tag-get") {
835 return (srv->commandServerTagGetHandler(command, args));
837 }
else if (command ==
"config-backend-pull") {
838 return (srv->commandConfigBackendPullHandler(command, args));
840 }
else if (command ==
"status-get") {
841 return (srv->commandStatusGetHandler(command, args));
849 + command +
"':" + ex.
what() +
850 ", params: '" + txt +
"'"));
860 std::ostringstream err;
863 err <<
"Server object not initialized, can't process config.";
880 }
catch (
const std::exception& ex) {
881 err <<
"Failed to process configuration:" << ex.what();
887 DatabaseConnection::db_lost_callback_ =
888 std::bind(&ControlledDhcpv6Srv::dbLostCallback, srv, ph::_1);
890 DatabaseConnection::db_recovered_callback_ =
891 std::bind(&ControlledDhcpv6Srv::dbRecoveredCallback, srv, ph::_1);
893 DatabaseConnection::db_failed_callback_ =
894 std::bind(&ControlledDhcpv6Srv::dbFailedCallback, srv, ph::_1);
896 CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
897 cfg_db->setAppendedParameters(
"universe=6");
898 cfg_db->createManagers();
901 }
catch (
const std::exception& ex) {
902 err <<
"Unable to open database: " << ex.what();
908 const std::string duid_file =
909 std::string(CfgMgr::instance().getDataDir()) +
"/" +
910 std::string(SERVER_DUID_FILE);
911 DuidPtr duid = CfgMgr::instance().getStagingCfg()->getCfgDUID()->create(duid_file);
919 }
catch (
const std::exception& ex) {
920 std::ostringstream err;
921 err <<
"unable to configure server identifier: " << ex.what();
928 }
catch (
const std::exception& ex) {
929 err <<
"Error starting DHCP_DDNS client after server reconfiguration: "
936 Dhcp6to4Ipc::instance().open();
937 }
catch (
const std::exception& ex) {
938 std::ostringstream err;
939 err <<
"error starting DHCPv4-over-DHCPv6 IPC "
940 " after server reconfiguration: " << ex.what();
947 qc = CfgMgr::instance().getStagingCfg()->getDHCPQueueControl();
948 if (IfaceMgr::instance().configureDHCPPacketQueue(AF_INET6, qc)) {
950 .arg(IfaceMgr::instance().getPacketQueue6()->getInfoStr());
953 }
catch (
const std::exception& ex) {
954 err <<
"Error setting packet queue controls after server reconfiguration: "
966 CfgMgr::instance().getStagingCfg()->getCfgIface()->
971 CfgMgr::instance().getStagingCfg()->getCfgExpiration()->
972 setupTimers(&ControlledDhcpv6Srv::reclaimExpiredLeases,
973 &ControlledDhcpv6Srv::deleteExpiredReclaimedLeases,
976 }
catch (
const std::exception& ex) {
977 err <<
"unable to setup timers for periodically running the"
978 " reclamation of the expired leases: "
984 auto ctl_info = CfgMgr::instance().getStagingCfg()->getConfigControlInfo();
986 long fetch_time =
static_cast<long>(ctl_info->getConfigFetchWaitTime());
989 if (fetch_time > 0) {
995 if (!server_->inTestMode()) {
996 fetch_time = 1000 * fetch_time;
999 boost::shared_ptr<unsigned> failure_count(
new unsigned(0));
1000 TimerMgr::instance()->
1001 registerTimer(
"Dhcp6CBFetchTimer",
1002 std::bind(&ControlledDhcpv6Srv::cbFetchUpdates,
1003 server_, CfgMgr::instance().getStagingCfg(),
1007 TimerMgr::instance()->setup(
"Dhcp6CBFetchTimer");
1013 LibDHCP::commitRuntimeOptionDefs();
1020 if (HooksManager::calloutsPresent(Hooks.hooks_index_dhcp6_srv_configured_)) {
1023 callout_handle->setArgument(
"io_context", srv->
getIOService());
1025 callout_handle->setArgument(
"json_config", config);
1026 callout_handle->setArgument(
"server_config", CfgMgr::instance().getStagingCfg());
1028 HooksManager::callCallouts(Hooks.hooks_index_dhcp6_srv_configured_,
1040 CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
1041 }
catch (
const std::exception& ex) {
1042 err <<
"Error applying multi threading settings: "
1060 "Server object not initialized, can't process config.");
1067 ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port,
1068 uint16_t client_port)
1072 "There is another Dhcpv6Srv instance already.");
1090 CommandMgr::instance().registerCommand(
"build-report",
1091 std::bind(&ControlledDhcpv6Srv::commandBuildReportHandler,
this, ph::_1, ph::_2));
1093 CommandMgr::instance().registerCommand(
"config-backend-pull",
1094 std::bind(&ControlledDhcpv6Srv::commandConfigBackendPullHandler,
this, ph::_1, ph::_2));
1096 CommandMgr::instance().registerCommand(
"config-get",
1097 std::bind(&ControlledDhcpv6Srv::commandConfigGetHandler,
this, ph::_1, ph::_2));
1099 CommandMgr::instance().registerCommand(
"config-reload",
1100 std::bind(&ControlledDhcpv6Srv::commandConfigReloadHandler,
this, ph::_1, ph::_2));
1102 CommandMgr::instance().registerCommand(
"config-test",
1103 std::bind(&ControlledDhcpv6Srv::commandConfigTestHandler,
this, ph::_1, ph::_2));
1105 CommandMgr::instance().registerCommand(
"config-write",
1106 std::bind(&ControlledDhcpv6Srv::commandConfigWriteHandler,
this, ph::_1, ph::_2));
1108 CommandMgr::instance().registerCommand(
"dhcp-disable",
1109 std::bind(&ControlledDhcpv6Srv::commandDhcpDisableHandler,
this, ph::_1, ph::_2));
1111 CommandMgr::instance().registerCommand(
"dhcp-enable",
1112 std::bind(&ControlledDhcpv6Srv::commandDhcpEnableHandler,
this, ph::_1, ph::_2));
1114 CommandMgr::instance().registerCommand(
"leases-reclaim",
1115 std::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler,
this, ph::_1, ph::_2));
1117 CommandMgr::instance().registerCommand(
"server-tag-get",
1118 std::bind(&ControlledDhcpv6Srv::commandServerTagGetHandler,
this, ph::_1, ph::_2));
1120 CommandMgr::instance().registerCommand(
"libreload",
1121 std::bind(&ControlledDhcpv6Srv::commandLibReloadHandler,
this, ph::_1, ph::_2));
1123 CommandMgr::instance().registerCommand(
"config-set",
1124 std::bind(&ControlledDhcpv6Srv::commandConfigSetHandler,
this, ph::_1, ph::_2));
1126 CommandMgr::instance().registerCommand(
"shutdown",
1127 std::bind(&ControlledDhcpv6Srv::commandShutdownHandler,
this, ph::_1, ph::_2));
1129 CommandMgr::instance().registerCommand(
"status-get",
1130 std::bind(&ControlledDhcpv6Srv::commandStatusGetHandler,
this, ph::_1, ph::_2));
1132 CommandMgr::instance().registerCommand(
"version-get",
1133 std::bind(&ControlledDhcpv6Srv::commandVersionGetHandler,
this, ph::_1, ph::_2));
1136 CommandMgr::instance().registerCommand(
"statistic-get",
1137 std::bind(&StatsMgr::statisticGetHandler, ph::_1, ph::_2));
1139 CommandMgr::instance().registerCommand(
"statistic-get-all",
1140 std::bind(&StatsMgr::statisticGetAllHandler, ph::_1, ph::_2));
1142 CommandMgr::instance().registerCommand(
"statistic-reset",
1143 std::bind(&StatsMgr::statisticResetHandler, ph::_1, ph::_2));
1145 CommandMgr::instance().registerCommand(
"statistic-reset-all",
1146 std::bind(&StatsMgr::statisticResetAllHandler, ph::_1, ph::_2));
1148 CommandMgr::instance().registerCommand(
"statistic-remove",
1149 std::bind(&StatsMgr::statisticRemoveHandler, ph::_1, ph::_2));
1151 CommandMgr::instance().registerCommand(
"statistic-remove-all",
1152 std::bind(&StatsMgr::statisticRemoveAllHandler, ph::_1, ph::_2));
1154 CommandMgr::instance().registerCommand(
"statistic-sample-age-set",
1155 std::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, ph::_1, ph::_2));
1157 CommandMgr::instance().registerCommand(
"statistic-sample-age-set-all",
1158 std::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleAgeAllHandler,
this, ph::_1, ph::_2));
1160 CommandMgr::instance().registerCommand(
"statistic-sample-count-set",
1161 std::bind(&StatsMgr::statisticSetMaxSampleCountHandler, ph::_1, ph::_2));
1163 CommandMgr::instance().registerCommand(
"statistic-sample-count-set-all",
1164 std::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleCountAllHandler,
this, ph::_1, ph::_2));
1185 timer_mgr_->unregisterTimers();
1188 CommandMgr::instance().closeCommandSocket();
1191 CommandMgr::instance().deregisterCommand(
"build-report");
1192 CommandMgr::instance().deregisterCommand(
"config-backend-pull");
1193 CommandMgr::instance().deregisterCommand(
"config-get");
1194 CommandMgr::instance().deregisterCommand(
"config-reload");
1195 CommandMgr::instance().deregisterCommand(
"config-set");
1196 CommandMgr::instance().deregisterCommand(
"config-test");
1197 CommandMgr::instance().deregisterCommand(
"config-write");
1198 CommandMgr::instance().deregisterCommand(
"dhcp-disable");
1199 CommandMgr::instance().deregisterCommand(
"dhcp-enable");
1200 CommandMgr::instance().deregisterCommand(
"leases-reclaim");
1201 CommandMgr::instance().deregisterCommand(
"libreload");
1202 CommandMgr::instance().deregisterCommand(
"server-tag-get");
1203 CommandMgr::instance().deregisterCommand(
"shutdown");
1204 CommandMgr::instance().deregisterCommand(
"statistic-get");
1205 CommandMgr::instance().deregisterCommand(
"statistic-get-all");
1206 CommandMgr::instance().deregisterCommand(
"statistic-remove");
1207 CommandMgr::instance().deregisterCommand(
"statistic-remove-all");
1208 CommandMgr::instance().deregisterCommand(
"statistic-reset");
1209 CommandMgr::instance().deregisterCommand(
"statistic-reset-all");
1210 CommandMgr::instance().deregisterCommand(
"statistic-sample-age-set");
1211 CommandMgr::instance().deregisterCommand(
"statistic-sample-age-set-all");
1212 CommandMgr::instance().deregisterCommand(
"statistic-sample-count-set");
1213 CommandMgr::instance().deregisterCommand(
"statistic-sample-count-set-all");
1214 CommandMgr::instance().deregisterCommand(
"status-get");
1215 CommandMgr::instance().deregisterCommand(
"version-get");
1233 ControlledDhcpv6Srv::reclaimExpiredLeases(
const size_t max_leases,
1234 const uint16_t timeout,
1235 const bool remove_lease,
1236 const uint16_t max_unwarned_cycles) {
1238 server_->
alloc_engine_->reclaimExpiredLeases6(max_leases, timeout,
1240 max_unwarned_cycles);
1241 }
catch (
const std::exception& ex) {
1250 ControlledDhcpv6Srv::deleteExpiredReclaimedLeases(
const uint32_t secs) {
1251 server_->
alloc_engine_->deleteExpiredReclaimedLeases6(secs);
1257 ControlledDhcpv6Srv::dbLostCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1258 if (!db_reconnect_ctl) {
1265 if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
1266 db_reconnect_ctl->alterServiceState()) {
1274 if (!db_reconnect_ctl->retriesLeft() ||
1275 !db_reconnect_ctl->retryInterval()) {
1277 .arg(db_reconnect_ctl->retriesLeft())
1278 .arg(db_reconnect_ctl->retryInterval());
1279 if (db_reconnect_ctl->exitOnFailure()) {
1289 ControlledDhcpv6Srv::dbRecoveredCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1290 if (!db_reconnect_ctl) {
1297 if (db_reconnect_ctl->alterServiceState()) {
1303 db_reconnect_ctl->resetRetries();
1309 ControlledDhcpv6Srv::dbFailedCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1310 if (!db_reconnect_ctl) {
1317 .arg(db_reconnect_ctl->maxRetries());
1319 if (db_reconnect_ctl->exitOnFailure()) {
1327 ControlledDhcpv6Srv::cbFetchUpdates(
const SrvConfigPtr& srv_cfg,
1328 boost::shared_ptr<unsigned> failure_count) {
1335 CBControlDHCPv6::FetchMode::FETCH_UPDATE);
1336 (*failure_count) = 0;
1338 }
catch (
const std::exception& ex) {
1345 if (++(*failure_count) > 10) {
RAII class creating a critical section.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
boost::shared_ptr< DUID > DuidPtr
virtual void shutdownServer(int exit_value)
Initiates shutdown procedure for the whole DHCPv6 server.
static ControlledDhcpv6Srv * getInstance()
Returns pointer to the sole instance of Dhcpv6Srv.
virtual ~ControlledDhcpv6Srv()
Destructor.
static DbCallback db_lost_callback_
Optional callback function to invoke if an opened connection is lost.
const isc::log::MessageID DHCP6_USING_SERVERID
isc::data::ConstElementPtr configureDhcp6Server(Dhcpv6Srv &server, isc::data::ConstElementPtr config_set, bool check_only)
Configures DHCPv6 server.
const isc::log::MessageID DHCP6_CONFIG_LOAD_FAIL
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
const isc::log::MessageID DHCP6_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED
void shutdown() override
Instructs the server to shut down.
static void setIOService(const isc::asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Host Manager.
isc::data::ConstElementPtr statisticSetMaxSampleCountAllHandler(const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-count-set-all command.
static void destroy()
Destroy lease manager.
const isc::log::MessageID DHCP6_RECLAIM_EXPIRED_LEASES_FAIL
const isc::log::MessageID DHCP6_CONFIG_PACKET_QUEUE
Manages a pool of asynchronous interval timers.
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
The network state is being altered by the DB connection recovery mechanics.
ConstElementPtr redactConfig(ConstElementPtr const &element, list< string > const &json_path)
Redact a configuration.
uint16_t getServerPort() const
Get UDP port on which server should listen.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
boost::shared_ptr< Element > ElementPtr
Evaluation context, an interface to the expression evaluation.
const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION
const isc::log::MessageID DHCP6_CB_ON_DEMAND_FETCH_UPDATES_FAIL
const isc::log::MessageID DHCP6_DB_RECONNECT_NO_DB_CTL
const isc::log::MessageID DHCP6_COMMAND_RECEIVED
static DbCallback db_failed_callback_
Optional callback function to invoke if an opened connection recovery failed.
Statistics Manager class.
std::vector< HookLibInfo > HookLibsCollection
A storage for information about hook libraries.
const isc::log::MessageID DHCP6_DB_RECONNECT_DISABLED
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
NetworkStatePtr & getNetworkState()
Returns pointer to the network state used by the server.
Origin
Origin of the network state transition.
const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION_FAIL
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
static const std::string FLUSH_RECLAIMED_TIMER_NAME
Name of the timer for flushing reclaimed leases.
const isc::log::MessageID DHCP6_CONFIG_UNSUPPORTED_OBJECT
const isc::log::MessageID DHCP6_CB_PERIODIC_FETCH_UPDATES_FAIL
Implements an asynchronous "signal" for IOService driven processing.
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
const int DBG_DHCP6_COMMAND
Debug level used to log receiving commands.
static void create()
Creates new instance of the HostMgr.
static DbCallback db_recovered_callback_
Optional callback function to invoke if an opened connection recovery succeeded.
boost::shared_ptr< const Element > ConstElementPtr
Defines the Dhcp6to4Ipc class.
NetworkStatePtr network_state_
Holds information about disabled DHCP service and/or disabled subnet/network scopes.
const isc::log::MessageID DHCP6_DB_RECONNECT_LOST_CONNECTION
isc::data::ConstElementPtr redactConfig(isc::data::ConstElementPtr const &config)
Redact a configuration.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
This is a base class for exceptions thrown from the DNS library module.
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
Defines the logger used by the top-level component of kea-dhcp-ddns.
CBControlDHCPv6Ptr getCBControl() const
Returns an object which controls access to the configuration backends.
const isc::log::MessageID DHCP6_DB_RECONNECT_SUCCEEDED
void setExitValue(int value)
Sets the exit value.
void startD2()
Starts DHCP_DDNS client IO if DDNS updates are enabled.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
static const std::string RECLAIM_EXPIRED_TIMER_NAME
Name of the timer for reclaiming expired leases.
This file contains several functions and constants that are used for handling commands and responses ...
asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service used by the server.
const isc::log::MessageID DHCP6_CONFIG_UNRECOVERABLE_ERROR
A generic exception that is thrown if a function is called in a prohibited way.
const isc::log::MessageID DHCP6_MULTI_THREADING_INFO
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
void cleanup()
Performs cleanup, immediately before termination.
const isc::log::MessageID DHCP6_CONFIG_RECEIVED
isc::data::ConstElementPtr statisticSetMaxSampleAgeAllHandler(const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-age-set-all command.
boost::shared_ptr< AllocEngine > alloc_engine_
Allocation Engine.
std::string getConfigReport()
const StatsDuration & getMaxSampleAgeDefault() const
Get default duration limit.
static void setIOService(const isc::asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Lease Manager.
uint32_t getMaxSampleCountDefault() const
Get default count limit.
const isc::log::MessageID DHCP6_DB_RECONNECT_FAILED
#define LOG_FATAL(LOGGER, MESSAGE)
Macro to conveniently test fatal output and log it.
Controlled version of the DHCPv6 server.
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
const isc::log::MessageID DHCP6_NOT_RUNNING
isc::log::Logger dhcp6_logger(DHCP6_APP_LOGGER_NAME)
Base logger for DHCPv6 server.
long toSeconds(const StatsDuration &dur)
Returns the number of seconds in a duration.
const isc::log::MessageID DHCP6_HOOKS_LIBS_RELOAD_FAIL