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);
246 }
catch (
const std::exception& ex) {
252 "Hooks libraries successfully reloaded.");
257 ControlledDhcpv6Srv::commandConfigReloadHandler(
const string&,
260 std::string file = ControlledDhcpv6Srv::getInstance()->getConfigFile();
263 auto result = loadConfigFile(file);
266 }
catch (
const std::exception& ex) {
273 "Config reload failed: " +
string(ex.what())));
278 ControlledDhcpv6Srv::commandConfigGetHandler(
const string&,
280 ConstElementPtr config = CfgMgr::instance().getCurrentCfg()->toElement();
286 ControlledDhcpv6Srv::commandConfigWriteHandler(
const string&,
291 if (args->getType() != Element::map) {
295 if (filename_param) {
296 if (filename_param->getType() != Element::string) {
298 "passed parameter 'filename' is not a string"));
300 filename = filename_param->stringValue();
304 if (filename.empty()) {
307 filename = getConfigFile();
310 if (filename.empty()) {
312 "Please specify filename explicitly."));
319 size = writeConfigFile(filename, cfg);
331 params->set(
"size", Element::create(static_cast<long long>(size)));
332 params->set(
"filename", Element::create(filename));
335 + filename +
" successful", params));
339 ControlledDhcpv6Srv::commandConfigSetHandler(
const string&,
348 message =
"Missing mandatory 'arguments' parameter.";
350 dhcp6 = args->get(
"Dhcp6");
352 message =
"Missing mandatory 'Dhcp6' parameter.";
353 }
else if (dhcp6->getType() != Element::map) {
354 message =
"'Dhcp6' parameter expected to be a map.";
359 if (message.empty()) {
360 for (
auto obj : args->mapValue()) {
361 const string& obj_name = obj.first;
362 if (obj_name !=
"Dhcp6") {
365 if (message.empty()) {
366 message =
"Unsupported '" + obj_name +
"' parameter";
368 message +=
" (and '" + obj_name +
"')";
372 if (!message.empty()) {
377 if (!message.empty()) {
390 MultiThreadingMgr::instance().apply(
false, 0, 0);
395 CfgMgr::instance().rollback();
401 Daemon::configureLogger(dhcp6, CfgMgr::instance().getStagingCfg());
405 CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
416 CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
419 CfgMgr::instance().commit();
424 CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
426 if (CfgMgr::instance().getCurrentCfg()->getSequence() != 0) {
438 ControlledDhcpv6Srv::commandConfigTestHandler(
const string&,
447 message =
"Missing mandatory 'arguments' parameter.";
449 dhcp6 = args->get(
"Dhcp6");
451 message =
"Missing mandatory 'Dhcp6' parameter.";
452 }
else if (dhcp6->getType() != Element::map) {
453 message =
"'Dhcp6' parameter expected to be a map.";
458 if (message.empty()) {
459 for (
auto obj : args->mapValue()) {
460 const string& obj_name = obj.first;
461 if (obj_name !=
"Dhcp6") {
464 if (message.empty()) {
465 message =
"Unsupported '" + obj_name +
"' parameter";
467 message +=
" (and '" + obj_name +
"')";
471 if (!message.empty()) {
476 if (!message.empty()) {
489 CfgMgr::instance().rollback();
492 return (checkConfig(dhcp6));
496 ControlledDhcpv6Srv::commandDhcpDisableHandler(
const std::string&,
498 std::ostringstream message;
499 int64_t max_period = 0;
510 if (args->getType() != Element::map) {
511 message <<
"arguments for the 'dhcp-disable' command must be a map";
516 if (max_period_element) {
518 if (max_period_element->getType() != Element::integer) {
519 message <<
"'max-period' argument must be a number";
523 max_period = max_period_element->intValue();
524 if (max_period <= 0) {
525 message <<
"'max-period' must be positive integer";
531 if (origin_element) {
533 if (origin_element->getType() != Element::string) {
534 message <<
"'origin' argument must be a string";
537 origin = origin_element->stringValue();
538 if (origin ==
"ha-partner") {
539 type = NetworkState::Origin::HA_COMMAND;
540 }
else if (origin !=
"user") {
541 if (origin.empty()) {
542 origin =
"(empty string)";
544 message <<
"invalid value used for 'origin' parameter: " 553 if (message.tellp() == 0) {
554 message <<
"DHCPv6 service disabled";
555 if (max_period > 0) {
556 message <<
" for " << max_period <<
" seconds";
561 network_state_->delayedEnableAll(static_cast<unsigned>(max_period),
564 network_state_->disableService(type);
575 ControlledDhcpv6Srv::commandDhcpEnableHandler(
const std::string&,
577 std::ostringstream message;
587 if (args->getType() != Element::map) {
588 message <<
"arguments for the 'dhcp-enable' command must be a map";
593 if (origin_element) {
595 if (origin_element->getType() != Element::string) {
596 message <<
"'origin' argument must be a string";
599 origin = origin_element->stringValue();
600 if (origin ==
"ha-partner") {
601 type = NetworkState::Origin::HA_COMMAND;
602 }
else if (origin !=
"user") {
603 if (origin.empty()) {
604 origin =
"(empty string)";
606 message <<
"invalid value used for 'origin' parameter: " 615 if (message.tellp() == 0) {
616 network_state_->enableService(type);
620 "DHCP service successfully enabled"));
628 ControlledDhcpv6Srv::commandVersionGetHandler(
const string&,
ConstElementPtr) {
629 ElementPtr extended = Element::create(Dhcpv6Srv::getVersion(
true));
631 arguments->set(
"extended", extended);
633 Dhcpv6Srv::getVersion(
false),
639 ControlledDhcpv6Srv::commandBuildReportHandler(
const string&,
647 ControlledDhcpv6Srv::commandLeasesReclaimHandler(
const string&,
654 message =
"Missing mandatory 'remove' parameter.";
658 message =
"Missing mandatory 'remove' parameter.";
659 }
else if (remove_name->getType() != Element::boolean) {
660 message =
"'remove' parameter expected to be a boolean.";
662 bool remove_lease = remove_name->boolValue();
663 server_->alloc_engine_->reclaimExpiredLeases6(0, 0, remove_lease);
665 message =
"Reclamation of expired leases is complete.";
673 ControlledDhcpv6Srv::commandServerTagGetHandler(
const std::string&,
675 const std::string& tag =
676 CfgMgr::instance().getCurrentCfg()->getServerTag();
678 response->set(
"server-tag", Element::create(tag));
684 ControlledDhcpv6Srv::commandConfigBackendPullHandler(
const std::string&,
686 auto ctl_info = CfgMgr::instance().getCurrentCfg()->getConfigControlInfo();
695 if (TimerMgr::instance()->isTimerRegistered(
"Dhcp6CBFetchTimer")) {
696 TimerMgr::instance()->cancel(
"Dhcp6CBFetchTimer");
697 TimerMgr::instance()->setup(
"Dhcp6CBFetchTimer");
704 auto srv_cfg = CfgMgr::instance().getCurrentCfg();
705 auto mode = CBControlDHCPv6::FetchMode::FETCH_UPDATE;
706 server_->getCBControl()->databaseConfigFetch(srv_cfg, mode);
707 }
catch (
const std::exception& ex) {
711 "On demand configuration update failed: " +
715 "On demand configuration update successful."));
719 ControlledDhcpv6Srv::commandStatusGetHandler(
const string&,
722 status->set(
"pid", Element::create(static_cast<int>(getpid())));
724 auto now = boost::posix_time::second_clock::universal_time();
726 if (!start_.is_not_a_date_time()) {
727 auto uptime = now - start_;
728 status->set(
"uptime", Element::create(uptime.total_seconds()));
731 auto last_commit = CfgMgr::instance().getCurrentCfg()->getLastCommitTime();
732 if (!last_commit.is_not_a_date_time()) {
733 auto reload = now - last_commit;
734 status->set(
"reload", Element::create(reload.total_seconds()));
737 auto& mt_mgr = MultiThreadingMgr::instance();
738 if (mt_mgr.getMode()) {
739 status->set(
"multi-threading-enabled", Element::create(
true));
740 status->set(
"thread-pool-size", Element::create(static_cast<int32_t>(
741 MultiThreadingMgr::instance().getThreadPoolSize())));
742 status->set(
"packet-queue-size", Element::create(static_cast<int32_t>(
743 MultiThreadingMgr::instance().getPacketQueueSize())));
744 ElementPtr queue_stats = Element::createList();
745 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(10)));
746 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(100)));
747 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(1000)));
748 status->set(
"packet-queue-statistics", queue_stats);
751 status->set(
"multi-threading-enabled", Element::create(
false));
758 ControlledDhcpv6Srv::commandStatisticSetMaxSampleCountAllHandler(
const string&,
760 StatsMgr& stats_mgr = StatsMgr::instance();
764 CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
765 "statistic-default-sample-count", Element::create(max_samples));
770 ControlledDhcpv6Srv::commandStatisticSetMaxSampleAgeAllHandler(
const string&,
772 StatsMgr& stats_mgr = StatsMgr::instance();
777 CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
778 "statistic-default-sample-age", Element::create(max_age));
783 ControlledDhcpv6Srv::processCommand(
const string& command,
785 string txt = args ? args->str() :
"(none)";
788 .arg(command).arg(txt);
794 "Server object not initialized, so can't process command '" +
795 command +
"', arguments: '" + txt +
"'.");
800 if (command ==
"shutdown") {
801 return (srv->commandShutdownHandler(command, args));
803 }
else if (command ==
"libreload") {
804 return (srv->commandLibReloadHandler(command, args));
806 }
else if (command ==
"config-reload") {
807 return (srv->commandConfigReloadHandler(command, args));
809 }
else if (command ==
"config-set") {
810 return (srv->commandConfigSetHandler(command, args));
812 }
else if (command ==
"config-get") {
813 return (srv->commandConfigGetHandler(command, args));
815 }
else if (command ==
"config-test") {
816 return (srv->commandConfigTestHandler(command, args));
818 }
else if (command ==
"dhcp-disable") {
819 return (srv->commandDhcpDisableHandler(command, args));
821 }
else if (command ==
"dhcp-enable") {
822 return (srv->commandDhcpEnableHandler(command, args));
824 }
else if (command ==
"version-get") {
825 return (srv->commandVersionGetHandler(command, args));
827 }
else if (command ==
"build-report") {
828 return (srv->commandBuildReportHandler(command, args));
830 }
else if (command ==
"leases-reclaim") {
831 return (srv->commandLeasesReclaimHandler(command, args));
833 }
else if (command ==
"config-write") {
834 return (srv->commandConfigWriteHandler(command, args));
836 }
else if (command ==
"server-tag-get") {
837 return (srv->commandServerTagGetHandler(command, args));
839 }
else if (command ==
"config-backend-pull") {
840 return (srv->commandConfigBackendPullHandler(command, args));
842 }
else if (command ==
"status-get") {
843 return (srv->commandStatusGetHandler(command, args));
851 + command +
"':" + ex.
what() +
852 ", params: '" + txt +
"'"));
862 std::ostringstream err;
865 err <<
"Server object not initialized, can't process config.";
882 }
catch (
const std::exception& ex) {
883 err <<
"Failed to process configuration:" << ex.what();
889 DatabaseConnection::db_lost_callback_ =
890 std::bind(&ControlledDhcpv6Srv::dbLostCallback, srv, ph::_1);
892 DatabaseConnection::db_recovered_callback_ =
893 std::bind(&ControlledDhcpv6Srv::dbRecoveredCallback, srv, ph::_1);
895 DatabaseConnection::db_failed_callback_ =
896 std::bind(&ControlledDhcpv6Srv::dbFailedCallback, srv, ph::_1);
898 CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
899 cfg_db->setAppendedParameters(
"universe=6");
900 cfg_db->createManagers();
903 }
catch (
const std::exception& ex) {
904 err <<
"Unable to open database: " << ex.what();
910 const std::string duid_file =
911 std::string(CfgMgr::instance().getDataDir()) +
"/" +
912 std::string(SERVER_DUID_FILE);
913 DuidPtr duid = CfgMgr::instance().getStagingCfg()->getCfgDUID()->create(duid_file);
921 }
catch (
const std::exception& ex) {
922 std::ostringstream err;
923 err <<
"unable to configure server identifier: " << ex.what();
930 }
catch (
const std::exception& ex) {
931 err <<
"Error starting DHCP_DDNS client after server reconfiguration: " 938 Dhcp6to4Ipc::instance().open();
939 }
catch (
const std::exception& ex) {
940 std::ostringstream err;
941 err <<
"error starting DHCPv4-over-DHCPv6 IPC " 942 " after server reconfiguration: " << ex.what();
949 qc = CfgMgr::instance().getStagingCfg()->getDHCPQueueControl();
950 if (IfaceMgr::instance().configureDHCPPacketQueue(AF_INET6, qc)) {
952 .arg(IfaceMgr::instance().getPacketQueue6()->getInfoStr());
955 }
catch (
const std::exception& ex) {
956 err <<
"Error setting packet queue controls after server reconfiguration: " 963 CfgIface::open_sockets_failed_callback_ =
964 std::bind(&ControlledDhcpv6Srv::openSocketsFailedCallback, srv, ph::_1);
973 CfgMgr::instance().getStagingCfg()->getCfgIface()->
978 CfgMgr::instance().getStagingCfg()->getCfgExpiration()->
979 setupTimers(&ControlledDhcpv6Srv::reclaimExpiredLeases,
980 &ControlledDhcpv6Srv::deleteExpiredReclaimedLeases,
983 }
catch (
const std::exception& ex) {
984 err <<
"unable to setup timers for periodically running the" 985 " reclamation of the expired leases: " 991 auto ctl_info = CfgMgr::instance().getStagingCfg()->getConfigControlInfo();
993 long fetch_time =
static_cast<long>(ctl_info->getConfigFetchWaitTime());
996 if (fetch_time > 0) {
1002 if (!server_->inTestMode()) {
1003 fetch_time = 1000 * fetch_time;
1006 boost::shared_ptr<unsigned> failure_count(
new unsigned(0));
1007 TimerMgr::instance()->
1008 registerTimer(
"Dhcp6CBFetchTimer",
1009 std::bind(&ControlledDhcpv6Srv::cbFetchUpdates,
1010 server_, CfgMgr::instance().getStagingCfg(),
1014 TimerMgr::instance()->setup(
"Dhcp6CBFetchTimer");
1020 LibDHCP::commitRuntimeOptionDefs();
1027 if (HooksManager::calloutsPresent(Hooks.hooks_index_dhcp6_srv_configured_)) {
1030 callout_handle->setArgument(
"io_context", srv->
getIOService());
1032 callout_handle->setArgument(
"json_config", config);
1033 callout_handle->setArgument(
"server_config", CfgMgr::instance().getStagingCfg());
1035 HooksManager::callCallouts(Hooks.hooks_index_dhcp6_srv_configured_,
1047 CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
1048 }
catch (
const std::exception& ex) {
1049 err <<
"Error applying multi threading settings: " 1067 "Server object not initialized, can't process config.");
1074 ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port,
1075 uint16_t client_port)
1079 "There is another Dhcpv6Srv instance already.");
1097 CommandMgr::instance().registerCommand(
"build-report",
1098 std::bind(&ControlledDhcpv6Srv::commandBuildReportHandler,
this, ph::_1, ph::_2));
1100 CommandMgr::instance().registerCommand(
"config-backend-pull",
1101 std::bind(&ControlledDhcpv6Srv::commandConfigBackendPullHandler,
this, ph::_1, ph::_2));
1103 CommandMgr::instance().registerCommand(
"config-get",
1104 std::bind(&ControlledDhcpv6Srv::commandConfigGetHandler,
this, ph::_1, ph::_2));
1106 CommandMgr::instance().registerCommand(
"config-reload",
1107 std::bind(&ControlledDhcpv6Srv::commandConfigReloadHandler,
this, ph::_1, ph::_2));
1109 CommandMgr::instance().registerCommand(
"config-test",
1110 std::bind(&ControlledDhcpv6Srv::commandConfigTestHandler,
this, ph::_1, ph::_2));
1112 CommandMgr::instance().registerCommand(
"config-write",
1113 std::bind(&ControlledDhcpv6Srv::commandConfigWriteHandler,
this, ph::_1, ph::_2));
1115 CommandMgr::instance().registerCommand(
"dhcp-disable",
1116 std::bind(&ControlledDhcpv6Srv::commandDhcpDisableHandler,
this, ph::_1, ph::_2));
1118 CommandMgr::instance().registerCommand(
"dhcp-enable",
1119 std::bind(&ControlledDhcpv6Srv::commandDhcpEnableHandler,
this, ph::_1, ph::_2));
1121 CommandMgr::instance().registerCommand(
"leases-reclaim",
1122 std::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler,
this, ph::_1, ph::_2));
1124 CommandMgr::instance().registerCommand(
"server-tag-get",
1125 std::bind(&ControlledDhcpv6Srv::commandServerTagGetHandler,
this, ph::_1, ph::_2));
1127 CommandMgr::instance().registerCommand(
"libreload",
1128 std::bind(&ControlledDhcpv6Srv::commandLibReloadHandler,
this, ph::_1, ph::_2));
1130 CommandMgr::instance().registerCommand(
"config-set",
1131 std::bind(&ControlledDhcpv6Srv::commandConfigSetHandler,
this, ph::_1, ph::_2));
1133 CommandMgr::instance().registerCommand(
"shutdown",
1134 std::bind(&ControlledDhcpv6Srv::commandShutdownHandler,
this, ph::_1, ph::_2));
1136 CommandMgr::instance().registerCommand(
"status-get",
1137 std::bind(&ControlledDhcpv6Srv::commandStatusGetHandler,
this, ph::_1, ph::_2));
1139 CommandMgr::instance().registerCommand(
"version-get",
1140 std::bind(&ControlledDhcpv6Srv::commandVersionGetHandler,
this, ph::_1, ph::_2));
1143 CommandMgr::instance().registerCommand(
"statistic-get",
1144 std::bind(&StatsMgr::statisticGetHandler, ph::_1, ph::_2));
1146 CommandMgr::instance().registerCommand(
"statistic-get-all",
1147 std::bind(&StatsMgr::statisticGetAllHandler, ph::_1, ph::_2));
1149 CommandMgr::instance().registerCommand(
"statistic-reset",
1150 std::bind(&StatsMgr::statisticResetHandler, ph::_1, ph::_2));
1152 CommandMgr::instance().registerCommand(
"statistic-reset-all",
1153 std::bind(&StatsMgr::statisticResetAllHandler, ph::_1, ph::_2));
1155 CommandMgr::instance().registerCommand(
"statistic-remove",
1156 std::bind(&StatsMgr::statisticRemoveHandler, ph::_1, ph::_2));
1158 CommandMgr::instance().registerCommand(
"statistic-remove-all",
1159 std::bind(&StatsMgr::statisticRemoveAllHandler, ph::_1, ph::_2));
1161 CommandMgr::instance().registerCommand(
"statistic-sample-age-set",
1162 std::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, ph::_1, ph::_2));
1164 CommandMgr::instance().registerCommand(
"statistic-sample-age-set-all",
1165 std::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleAgeAllHandler,
this, ph::_1, ph::_2));
1167 CommandMgr::instance().registerCommand(
"statistic-sample-count-set",
1168 std::bind(&StatsMgr::statisticSetMaxSampleCountHandler, ph::_1, ph::_2));
1170 CommandMgr::instance().registerCommand(
"statistic-sample-count-set-all",
1171 std::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleCountAllHandler,
this, ph::_1, ph::_2));
1192 timer_mgr_->unregisterTimers();
1195 CommandMgr::instance().closeCommandSocket();
1198 CommandMgr::instance().deregisterCommand(
"build-report");
1199 CommandMgr::instance().deregisterCommand(
"config-backend-pull");
1200 CommandMgr::instance().deregisterCommand(
"config-get");
1201 CommandMgr::instance().deregisterCommand(
"config-reload");
1202 CommandMgr::instance().deregisterCommand(
"config-set");
1203 CommandMgr::instance().deregisterCommand(
"config-test");
1204 CommandMgr::instance().deregisterCommand(
"config-write");
1205 CommandMgr::instance().deregisterCommand(
"dhcp-disable");
1206 CommandMgr::instance().deregisterCommand(
"dhcp-enable");
1207 CommandMgr::instance().deregisterCommand(
"leases-reclaim");
1208 CommandMgr::instance().deregisterCommand(
"libreload");
1209 CommandMgr::instance().deregisterCommand(
"server-tag-get");
1210 CommandMgr::instance().deregisterCommand(
"shutdown");
1211 CommandMgr::instance().deregisterCommand(
"statistic-get");
1212 CommandMgr::instance().deregisterCommand(
"statistic-get-all");
1213 CommandMgr::instance().deregisterCommand(
"statistic-remove");
1214 CommandMgr::instance().deregisterCommand(
"statistic-remove-all");
1215 CommandMgr::instance().deregisterCommand(
"statistic-reset");
1216 CommandMgr::instance().deregisterCommand(
"statistic-reset-all");
1217 CommandMgr::instance().deregisterCommand(
"statistic-sample-age-set");
1218 CommandMgr::instance().deregisterCommand(
"statistic-sample-age-set-all");
1219 CommandMgr::instance().deregisterCommand(
"statistic-sample-count-set");
1220 CommandMgr::instance().deregisterCommand(
"statistic-sample-count-set-all");
1221 CommandMgr::instance().deregisterCommand(
"status-get");
1222 CommandMgr::instance().deregisterCommand(
"version-get");
1240 ControlledDhcpv6Srv::reclaimExpiredLeases(
const size_t max_leases,
1241 const uint16_t timeout,
1242 const bool remove_lease,
1243 const uint16_t max_unwarned_cycles) {
1245 server_->
alloc_engine_->reclaimExpiredLeases6(max_leases, timeout,
1247 max_unwarned_cycles);
1248 }
catch (
const std::exception& ex) {
1257 ControlledDhcpv6Srv::deleteExpiredReclaimedLeases(
const uint32_t secs) {
1258 server_->
alloc_engine_->deleteExpiredReclaimedLeases6(secs);
1264 ControlledDhcpv6Srv::dbLostCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1265 if (!db_reconnect_ctl) {
1272 if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
1273 db_reconnect_ctl->alterServiceState()) {
1281 if (!db_reconnect_ctl->retriesLeft() ||
1282 !db_reconnect_ctl->retryInterval()) {
1284 .arg(db_reconnect_ctl->retriesLeft())
1285 .arg(db_reconnect_ctl->retryInterval());
1286 if (db_reconnect_ctl->exitOnFailure()) {
1296 ControlledDhcpv6Srv::dbRecoveredCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1297 if (!db_reconnect_ctl) {
1304 if (db_reconnect_ctl->alterServiceState()) {
1310 db_reconnect_ctl->resetRetries();
1316 ControlledDhcpv6Srv::dbFailedCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1317 if (!db_reconnect_ctl) {
1324 .arg(db_reconnect_ctl->maxRetries());
1326 if (db_reconnect_ctl->exitOnFailure()) {
1334 ControlledDhcpv6Srv::openSocketsFailedCallback(
ReconnectCtlPtr reconnect_ctl) {
1335 if (!reconnect_ctl) {
1342 .arg(reconnect_ctl->maxRetries());
1344 if (reconnect_ctl->exitOnFailure()) {
1350 ControlledDhcpv6Srv::cbFetchUpdates(
const SrvConfigPtr& srv_cfg,
1351 boost::shared_ptr<unsigned> failure_count) {
1358 CBControlDHCPv6::FetchMode::FETCH_UPDATE);
1359 (*failure_count) = 0;
1361 }
catch (
const std::exception& ex) {
1368 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
uint16_t getServerPort() const
Get UDP port on which server should listen.
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.
CBControlDHCPv6Ptr getCBControl() const
Returns an object which controls access to the configuration backends.
isc::data::ConstElementPtr statisticSetMaxSampleCountAllHandler(const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-count-set-all command.
const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION_SUCCESS
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
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.
#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_OPEN_SOCKETS_NO_RECONNECT_CTL
const isc::log::MessageID DHCP6_DB_RECONNECT_NO_DB_CTL
const isc::log::MessageID DHCP6_COMMAND_RECEIVED
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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 ...
const isc::log::MessageID DHCP6_OPEN_SOCKETS_FAILED
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.
A generic exception that is thrown when an unexpected error condition occurs.
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.
uint32_t getMaxSampleCountDefault() const
Get default count limit.
ConstElementPtr redactConfig(ConstElementPtr const &element, list< string > const &json_path)
Redact a configuration.
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-lfc.
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()
static void setIOService(const isc::asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Lease Manager.
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.
const StatsDuration & getMaxSampleAgeDefault() const
Get default duration limit.
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