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) {
237 MultiThreadingMgr::instance().getThreadPool().reset();
242 HooksManager::prepareUnloadLibraries();
243 static_cast<void>(HooksManager::unloadLibraries());
244 bool status = HooksManager::loadLibraries(loaded);
247 " (WARNING: libreload is deprecated).");
249 }
catch (
const std::exception& ex) {
255 "Hooks libraries successfully reloaded " 256 "(WARNING: libreload is deprecated).");
261 ControlledDhcpv6Srv::commandConfigReloadHandler(
const string&,
264 std::string file = ControlledDhcpv6Srv::getInstance()->getConfigFile();
267 auto result = loadConfigFile(file);
270 }
catch (
const std::exception& ex) {
277 "Config reload failed: " +
string(ex.what())));
282 ControlledDhcpv6Srv::commandConfigGetHandler(
const string&,
284 ConstElementPtr config = CfgMgr::instance().getCurrentCfg()->toElement();
290 ControlledDhcpv6Srv::commandConfigWriteHandler(
const string&,
295 if (args->getType() != Element::map) {
299 if (filename_param) {
300 if (filename_param->getType() != Element::string) {
302 "passed parameter 'filename' is not a string"));
304 filename = filename_param->stringValue();
308 if (filename.empty()) {
311 filename = getConfigFile();
314 if (filename.empty()) {
316 "Please specify filename explicitly."));
323 size = writeConfigFile(filename, cfg);
335 params->set(
"size", Element::create(static_cast<long long>(size)));
336 params->set(
"filename", Element::create(filename));
339 + filename +
" successful", params));
343 ControlledDhcpv6Srv::commandConfigSetHandler(
const string&,
352 message =
"Missing mandatory 'arguments' parameter.";
354 dhcp6 = args->get(
"Dhcp6");
356 message =
"Missing mandatory 'Dhcp6' parameter.";
357 }
else if (dhcp6->getType() != Element::map) {
358 message =
"'Dhcp6' parameter expected to be a map.";
363 if (message.empty()) {
364 for (
auto obj : args->mapValue()) {
365 const string& obj_name = obj.first;
366 if (obj_name !=
"Dhcp6") {
369 if (message.empty()) {
370 message =
"Unsupported '" + obj_name +
"' parameter";
372 message +=
" (and '" + obj_name +
"')";
376 if (!message.empty()) {
381 if (!message.empty()) {
394 MultiThreadingMgr::instance().apply(
false, 0, 0);
399 CfgMgr::instance().rollback();
405 Daemon::configureLogger(dhcp6, CfgMgr::instance().getStagingCfg());
409 CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
420 CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
423 CfgMgr::instance().commit();
424 }
else if (CfgMgr::instance().getCurrentCfg()->getSequence() != 0) {
431 CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
443 ControlledDhcpv6Srv::commandConfigTestHandler(
const string&,
452 message =
"Missing mandatory 'arguments' parameter.";
454 dhcp6 = args->get(
"Dhcp6");
456 message =
"Missing mandatory 'Dhcp6' parameter.";
457 }
else if (dhcp6->getType() != Element::map) {
458 message =
"'Dhcp6' parameter expected to be a map.";
463 if (message.empty()) {
464 for (
auto obj : args->mapValue()) {
465 const string& obj_name = obj.first;
466 if (obj_name !=
"Dhcp6") {
469 if (message.empty()) {
470 message =
"Unsupported '" + obj_name +
"' parameter";
472 message +=
" (and '" + obj_name +
"')";
476 if (!message.empty()) {
481 if (!message.empty()) {
494 CfgMgr::instance().rollback();
497 return (checkConfig(dhcp6));
501 ControlledDhcpv6Srv::commandDhcpDisableHandler(
const std::string&,
503 std::ostringstream message;
504 int64_t max_period = 0;
515 if (args->getType() != Element::map) {
516 message <<
"arguments for the 'dhcp-disable' command must be a map";
521 if (max_period_element) {
523 if (max_period_element->getType() != Element::integer) {
524 message <<
"'max-period' argument must be a number";
528 max_period = max_period_element->intValue();
529 if (max_period <= 0) {
530 message <<
"'max-period' must be positive integer";
536 if (origin_element) {
538 if (origin_element->getType() != Element::string) {
539 message <<
"'origin' argument must be a string";
542 origin = origin_element->stringValue();
543 if (origin ==
"ha-partner") {
544 type = NetworkState::Origin::HA_COMMAND;
545 }
else if (origin !=
"user") {
546 if (origin.empty()) {
547 origin =
"(empty string)";
549 message <<
"invalid value used for 'origin' parameter: " 558 if (message.tellp() == 0) {
559 message <<
"DHCPv6 service disabled";
560 if (max_period > 0) {
561 message <<
" for " << max_period <<
" seconds";
566 network_state_->delayedEnableAll(static_cast<unsigned>(max_period),
569 network_state_->disableService(type);
580 ControlledDhcpv6Srv::commandDhcpEnableHandler(
const std::string&,
582 std::ostringstream message;
592 if (args->getType() != Element::map) {
593 message <<
"arguments for the 'dhcp-enable' command must be a map";
598 if (origin_element) {
600 if (origin_element->getType() != Element::string) {
601 message <<
"'origin' argument must be a string";
604 origin = origin_element->stringValue();
605 if (origin ==
"ha-partner") {
606 type = NetworkState::Origin::HA_COMMAND;
607 }
else if (origin !=
"user") {
608 if (origin.empty()) {
609 origin =
"(empty string)";
611 message <<
"invalid value used for 'origin' parameter: " 620 if (message.tellp() == 0) {
621 network_state_->enableService(type);
625 "DHCP service successfully enabled"));
633 ControlledDhcpv6Srv::commandVersionGetHandler(
const string&,
ConstElementPtr) {
634 ElementPtr extended = Element::create(Dhcpv6Srv::getVersion(
true));
636 arguments->set(
"extended", extended);
638 Dhcpv6Srv::getVersion(
false),
644 ControlledDhcpv6Srv::commandBuildReportHandler(
const string&,
652 ControlledDhcpv6Srv::commandLeasesReclaimHandler(
const string&,
659 message =
"Missing mandatory 'remove' parameter.";
663 message =
"Missing mandatory 'remove' parameter.";
664 }
else if (remove_name->getType() != Element::boolean) {
665 message =
"'remove' parameter expected to be a boolean.";
667 bool remove_lease = remove_name->boolValue();
668 server_->alloc_engine_->reclaimExpiredLeases6(0, 0, remove_lease);
670 message =
"Reclamation of expired leases is complete.";
678 ControlledDhcpv6Srv::commandServerTagGetHandler(
const std::string&,
680 const std::string& tag =
681 CfgMgr::instance().getCurrentCfg()->getServerTag();
683 response->set(
"server-tag", Element::create(tag));
689 ControlledDhcpv6Srv::commandConfigBackendPullHandler(
const std::string&,
691 auto ctl_info = CfgMgr::instance().getCurrentCfg()->getConfigControlInfo();
700 if (TimerMgr::instance()->isTimerRegistered(
"Dhcp6CBFetchTimer")) {
701 TimerMgr::instance()->cancel(
"Dhcp6CBFetchTimer");
702 TimerMgr::instance()->setup(
"Dhcp6CBFetchTimer");
709 auto srv_cfg = CfgMgr::instance().getCurrentCfg();
710 auto mode = CBControlDHCPv6::FetchMode::FETCH_UPDATE;
711 server_->getCBControl()->databaseConfigFetch(srv_cfg, mode);
712 }
catch (
const std::exception& ex) {
716 "On demand configuration update failed: " +
720 "On demand configuration update successful."));
724 ControlledDhcpv6Srv::commandStatusGetHandler(
const string&,
727 status->set(
"pid", Element::create(static_cast<int>(getpid())));
729 auto now = boost::posix_time::second_clock::universal_time();
731 if (!start_.is_not_a_date_time()) {
732 auto uptime = now - start_;
733 status->set(
"uptime", Element::create(uptime.total_seconds()));
736 auto last_commit = CfgMgr::instance().getCurrentCfg()->getLastCommitTime();
737 if (!last_commit.is_not_a_date_time()) {
738 auto reload = now - last_commit;
739 status->set(
"reload", Element::create(reload.total_seconds()));
742 auto& mt_mgr = MultiThreadingMgr::instance();
743 if (mt_mgr.getMode()) {
744 status->set(
"multi-threading-enabled", Element::create(
true));
745 status->set(
"thread-pool-size", Element::create(static_cast<int32_t>(
746 MultiThreadingMgr::instance().getThreadPoolSize())));
747 status->set(
"packet-queue-size", Element::create(static_cast<int32_t>(
748 MultiThreadingMgr::instance().getPacketQueueSize())));
749 ElementPtr queue_stats = Element::createList();
750 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(10)));
751 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(100)));
752 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(1000)));
753 status->set(
"packet-queue-statistics", queue_stats);
756 status->set(
"multi-threading-enabled", Element::create(
false));
760 ElementPtr socket_errors(Element::createList());
761 for (
IfacePtr const& interface : IfaceMgr::instance().getIfaces()) {
762 for (std::string
const&
error : interface->getErrors()) {
763 socket_errors->add(Element::create(
error));
769 if (socket_errors->empty()) {
770 sockets->set(
"status", Element::create(
"ready"));
773 CfgMgr::instance().getCurrentCfg()->getCfgIface()->getReconnectCtl());
774 if (reconnect_ctl && reconnect_ctl->retriesLeft()) {
775 sockets->set(
"status", Element::create(
"retrying"));
777 sockets->set(
"status", Element::create(
"failed"));
779 sockets->set(
"errors", socket_errors);
781 status->set(
"sockets", sockets);
787 ControlledDhcpv6Srv::commandStatisticSetMaxSampleCountAllHandler(
const string&,
789 StatsMgr& stats_mgr = StatsMgr::instance();
793 CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
794 "statistic-default-sample-count", Element::create(max_samples));
799 ControlledDhcpv6Srv::commandStatisticSetMaxSampleAgeAllHandler(
const string&,
801 StatsMgr& stats_mgr = StatsMgr::instance();
806 CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
807 "statistic-default-sample-age", Element::create(max_age));
812 ControlledDhcpv6Srv::processCommand(
const string& command,
814 string txt = args ? args->str() :
"(none)";
817 .arg(command).arg(txt);
823 "Server object not initialized, so can't process command '" +
824 command +
"', arguments: '" + txt +
"'.");
829 if (command ==
"shutdown") {
830 return (srv->commandShutdownHandler(command, args));
832 }
else if (command ==
"libreload") {
833 return (srv->commandLibReloadHandler(command, args));
835 }
else if (command ==
"config-reload") {
836 return (srv->commandConfigReloadHandler(command, args));
838 }
else if (command ==
"config-set") {
839 return (srv->commandConfigSetHandler(command, args));
841 }
else if (command ==
"config-get") {
842 return (srv->commandConfigGetHandler(command, args));
844 }
else if (command ==
"config-test") {
845 return (srv->commandConfigTestHandler(command, args));
847 }
else if (command ==
"dhcp-disable") {
848 return (srv->commandDhcpDisableHandler(command, args));
850 }
else if (command ==
"dhcp-enable") {
851 return (srv->commandDhcpEnableHandler(command, args));
853 }
else if (command ==
"version-get") {
854 return (srv->commandVersionGetHandler(command, args));
856 }
else if (command ==
"build-report") {
857 return (srv->commandBuildReportHandler(command, args));
859 }
else if (command ==
"leases-reclaim") {
860 return (srv->commandLeasesReclaimHandler(command, args));
862 }
else if (command ==
"config-write") {
863 return (srv->commandConfigWriteHandler(command, args));
865 }
else if (command ==
"server-tag-get") {
866 return (srv->commandServerTagGetHandler(command, args));
868 }
else if (command ==
"config-backend-pull") {
869 return (srv->commandConfigBackendPullHandler(command, args));
871 }
else if (command ==
"status-get") {
872 return (srv->commandStatusGetHandler(command, args));
880 + command +
"': " + ex.
what() +
881 ", params: '" + txt +
"'"));
891 std::ostringstream err;
894 err <<
"Server object not initialized, can't process config.";
911 }
catch (
const std::exception& ex) {
912 err <<
"Failed to process configuration:" << ex.what();
918 DatabaseConnection::db_lost_callback_ =
919 std::bind(&ControlledDhcpv6Srv::dbLostCallback, srv, ph::_1);
921 DatabaseConnection::db_recovered_callback_ =
922 std::bind(&ControlledDhcpv6Srv::dbRecoveredCallback, srv, ph::_1);
924 DatabaseConnection::db_failed_callback_ =
925 std::bind(&ControlledDhcpv6Srv::dbFailedCallback, srv, ph::_1);
927 CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
928 string params =
"universe=6";
929 if (cfg_db->getExtendedInfoTablesEnabled()) {
930 params +=
" extended-info-tables=true";
932 cfg_db->setAppendedParameters(params);
933 cfg_db->createManagers();
936 }
catch (
const std::exception& ex) {
937 err <<
"Unable to open database: " << ex.what();
943 const std::string duid_file =
944 std::string(CfgMgr::instance().getDataDir()) +
"/" +
945 std::string(SERVER_DUID_FILE);
946 DuidPtr duid = CfgMgr::instance().getStagingCfg()->getCfgDUID()->create(duid_file);
954 }
catch (
const std::exception& ex) {
955 err <<
"unable to configure server identifier: " << ex.what();
962 }
catch (
const std::exception& ex) {
963 err <<
"Error starting DHCP_DDNS client after server reconfiguration: " 970 Dhcp6to4Ipc::instance().open();
971 }
catch (
const std::exception& ex) {
972 err <<
"error starting DHCPv4-over-DHCPv6 IPC " 973 " after server reconfiguration: " << ex.what();
980 qc = CfgMgr::instance().getStagingCfg()->getDHCPQueueControl();
981 if (IfaceMgr::instance().configureDHCPPacketQueue(AF_INET6, qc)) {
983 .arg(IfaceMgr::instance().getPacketQueue6()->getInfoStr());
986 }
catch (
const std::exception& ex) {
987 err <<
"Error setting packet queue controls after server reconfiguration: " 994 CfgIface::open_sockets_failed_callback_ =
995 std::bind(&ControlledDhcpv6Srv::openSocketsFailedCallback, srv, ph::_1);
1004 CfgMgr::instance().getStagingCfg()->getCfgIface()->
1009 CfgMgr::instance().getStagingCfg()->getCfgExpiration()->
1010 setupTimers(&ControlledDhcpv6Srv::reclaimExpiredLeases,
1011 &ControlledDhcpv6Srv::deleteExpiredReclaimedLeases,
1014 }
catch (
const std::exception& ex) {
1015 err <<
"unable to setup timers for periodically running the" 1016 " reclamation of the expired leases: " 1017 << ex.what() <<
".";
1022 auto ctl_info = CfgMgr::instance().getStagingCfg()->getConfigControlInfo();
1024 long fetch_time =
static_cast<long>(ctl_info->getConfigFetchWaitTime());
1027 if (fetch_time > 0) {
1033 if (!server_->inTestMode()) {
1034 fetch_time = 1000 * fetch_time;
1037 boost::shared_ptr<unsigned> failure_count(
new unsigned(0));
1038 TimerMgr::instance()->
1039 registerTimer(
"Dhcp6CBFetchTimer",
1040 std::bind(&ControlledDhcpv6Srv::cbFetchUpdates,
1041 server_, CfgMgr::instance().getStagingCfg(),
1045 TimerMgr::instance()->setup(
"Dhcp6CBFetchTimer");
1051 LibDHCP::commitRuntimeOptionDefs();
1058 if (HooksManager::calloutsPresent(Hooks.hooks_index_dhcp6_srv_configured_)) {
1061 callout_handle->setArgument(
"io_context", srv->
getIOService());
1063 callout_handle->setArgument(
"json_config", config);
1064 callout_handle->setArgument(
"server_config", CfgMgr::instance().getStagingCfg());
1066 HooksManager::callCallouts(Hooks.hooks_index_dhcp6_srv_configured_,
1070 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
1073 callout_handle->getArgument(
"error", error);
1075 error =
"unknown error";
1086 CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
1087 }
catch (
const std::exception& ex) {
1088 err <<
"Error applying multi threading settings: " 1106 "Server object not initialized, can't process config.");
1113 ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port,
1114 uint16_t client_port)
1118 "There is another Dhcpv6Srv instance already.");
1136 CommandMgr::instance().registerCommand(
"build-report",
1137 std::bind(&ControlledDhcpv6Srv::commandBuildReportHandler,
this, ph::_1, ph::_2));
1139 CommandMgr::instance().registerCommand(
"config-backend-pull",
1140 std::bind(&ControlledDhcpv6Srv::commandConfigBackendPullHandler,
this, ph::_1, ph::_2));
1142 CommandMgr::instance().registerCommand(
"config-get",
1143 std::bind(&ControlledDhcpv6Srv::commandConfigGetHandler,
this, ph::_1, ph::_2));
1145 CommandMgr::instance().registerCommand(
"config-reload",
1146 std::bind(&ControlledDhcpv6Srv::commandConfigReloadHandler,
this, ph::_1, ph::_2));
1148 CommandMgr::instance().registerCommand(
"config-test",
1149 std::bind(&ControlledDhcpv6Srv::commandConfigTestHandler,
this, ph::_1, ph::_2));
1151 CommandMgr::instance().registerCommand(
"config-write",
1152 std::bind(&ControlledDhcpv6Srv::commandConfigWriteHandler,
this, ph::_1, ph::_2));
1154 CommandMgr::instance().registerCommand(
"dhcp-disable",
1155 std::bind(&ControlledDhcpv6Srv::commandDhcpDisableHandler,
this, ph::_1, ph::_2));
1157 CommandMgr::instance().registerCommand(
"dhcp-enable",
1158 std::bind(&ControlledDhcpv6Srv::commandDhcpEnableHandler,
this, ph::_1, ph::_2));
1160 CommandMgr::instance().registerCommand(
"leases-reclaim",
1161 std::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler,
this, ph::_1, ph::_2));
1163 CommandMgr::instance().registerCommand(
"server-tag-get",
1164 std::bind(&ControlledDhcpv6Srv::commandServerTagGetHandler,
this, ph::_1, ph::_2));
1166 CommandMgr::instance().registerCommand(
"libreload",
1167 std::bind(&ControlledDhcpv6Srv::commandLibReloadHandler,
this, ph::_1, ph::_2));
1169 CommandMgr::instance().registerCommand(
"config-set",
1170 std::bind(&ControlledDhcpv6Srv::commandConfigSetHandler,
this, ph::_1, ph::_2));
1172 CommandMgr::instance().registerCommand(
"shutdown",
1173 std::bind(&ControlledDhcpv6Srv::commandShutdownHandler,
this, ph::_1, ph::_2));
1175 CommandMgr::instance().registerCommand(
"status-get",
1176 std::bind(&ControlledDhcpv6Srv::commandStatusGetHandler,
this, ph::_1, ph::_2));
1178 CommandMgr::instance().registerCommand(
"version-get",
1179 std::bind(&ControlledDhcpv6Srv::commandVersionGetHandler,
this, ph::_1, ph::_2));
1182 CommandMgr::instance().registerCommand(
"statistic-get",
1183 std::bind(&StatsMgr::statisticGetHandler, ph::_1, ph::_2));
1185 CommandMgr::instance().registerCommand(
"statistic-get-all",
1186 std::bind(&StatsMgr::statisticGetAllHandler, ph::_1, ph::_2));
1188 CommandMgr::instance().registerCommand(
"statistic-reset",
1189 std::bind(&StatsMgr::statisticResetHandler, ph::_1, ph::_2));
1191 CommandMgr::instance().registerCommand(
"statistic-reset-all",
1192 std::bind(&StatsMgr::statisticResetAllHandler, ph::_1, ph::_2));
1194 CommandMgr::instance().registerCommand(
"statistic-remove",
1195 std::bind(&StatsMgr::statisticRemoveHandler, ph::_1, ph::_2));
1197 CommandMgr::instance().registerCommand(
"statistic-remove-all",
1198 std::bind(&StatsMgr::statisticRemoveAllHandler, ph::_1, ph::_2));
1200 CommandMgr::instance().registerCommand(
"statistic-sample-age-set",
1201 std::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, ph::_1, ph::_2));
1203 CommandMgr::instance().registerCommand(
"statistic-sample-age-set-all",
1204 std::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleAgeAllHandler,
this, ph::_1, ph::_2));
1206 CommandMgr::instance().registerCommand(
"statistic-sample-count-set",
1207 std::bind(&StatsMgr::statisticSetMaxSampleCountHandler, ph::_1, ph::_2));
1209 CommandMgr::instance().registerCommand(
"statistic-sample-count-set-all",
1210 std::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleCountAllHandler,
this, ph::_1, ph::_2));
1231 timer_mgr_->unregisterTimers();
1234 CommandMgr::instance().closeCommandSocket();
1237 CommandMgr::instance().deregisterCommand(
"build-report");
1238 CommandMgr::instance().deregisterCommand(
"config-backend-pull");
1239 CommandMgr::instance().deregisterCommand(
"config-get");
1240 CommandMgr::instance().deregisterCommand(
"config-reload");
1241 CommandMgr::instance().deregisterCommand(
"config-set");
1242 CommandMgr::instance().deregisterCommand(
"config-test");
1243 CommandMgr::instance().deregisterCommand(
"config-write");
1244 CommandMgr::instance().deregisterCommand(
"dhcp-disable");
1245 CommandMgr::instance().deregisterCommand(
"dhcp-enable");
1246 CommandMgr::instance().deregisterCommand(
"leases-reclaim");
1247 CommandMgr::instance().deregisterCommand(
"libreload");
1248 CommandMgr::instance().deregisterCommand(
"server-tag-get");
1249 CommandMgr::instance().deregisterCommand(
"shutdown");
1250 CommandMgr::instance().deregisterCommand(
"statistic-get");
1251 CommandMgr::instance().deregisterCommand(
"statistic-get-all");
1252 CommandMgr::instance().deregisterCommand(
"statistic-remove");
1253 CommandMgr::instance().deregisterCommand(
"statistic-remove-all");
1254 CommandMgr::instance().deregisterCommand(
"statistic-reset");
1255 CommandMgr::instance().deregisterCommand(
"statistic-reset-all");
1256 CommandMgr::instance().deregisterCommand(
"statistic-sample-age-set");
1257 CommandMgr::instance().deregisterCommand(
"statistic-sample-age-set-all");
1258 CommandMgr::instance().deregisterCommand(
"statistic-sample-count-set");
1259 CommandMgr::instance().deregisterCommand(
"statistic-sample-count-set-all");
1260 CommandMgr::instance().deregisterCommand(
"status-get");
1261 CommandMgr::instance().deregisterCommand(
"version-get");
1279 ControlledDhcpv6Srv::reclaimExpiredLeases(
const size_t max_leases,
1280 const uint16_t timeout,
1281 const bool remove_lease,
1282 const uint16_t max_unwarned_cycles) {
1284 server_->
alloc_engine_->reclaimExpiredLeases6(max_leases, timeout,
1286 max_unwarned_cycles);
1287 }
catch (
const std::exception& ex) {
1296 ControlledDhcpv6Srv::deleteExpiredReclaimedLeases(
const uint32_t secs) {
1297 server_->
alloc_engine_->deleteExpiredReclaimedLeases6(secs);
1303 ControlledDhcpv6Srv::dbLostCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1304 if (!db_reconnect_ctl) {
1311 if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
1312 db_reconnect_ctl->alterServiceState()) {
1320 if (!db_reconnect_ctl->retriesLeft() ||
1321 !db_reconnect_ctl->retryInterval()) {
1323 .arg(db_reconnect_ctl->retriesLeft())
1324 .arg(db_reconnect_ctl->retryInterval());
1325 if (db_reconnect_ctl->exitOnFailure()) {
1335 ControlledDhcpv6Srv::dbRecoveredCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1336 if (!db_reconnect_ctl) {
1343 if (db_reconnect_ctl->alterServiceState()) {
1349 db_reconnect_ctl->resetRetries();
1355 ControlledDhcpv6Srv::dbFailedCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1356 if (!db_reconnect_ctl) {
1363 .arg(db_reconnect_ctl->maxRetries());
1365 if (db_reconnect_ctl->exitOnFailure()) {
1373 ControlledDhcpv6Srv::openSocketsFailedCallback(
ReconnectCtlPtr reconnect_ctl) {
1374 if (!reconnect_ctl) {
1381 .arg(reconnect_ctl->maxRetries());
1383 if (reconnect_ctl->exitOnFailure()) {
1389 ControlledDhcpv6Srv::cbFetchUpdates(
const SrvConfigPtr& srv_cfg,
1390 boost::shared_ptr<unsigned> failure_count) {
1397 CBControlDHCPv6::FetchMode::FETCH_UPDATE);
1398 (*failure_count) = 0;
1400 }
catch (
const std::exception& ex) {
1407 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
boost::shared_ptr< Iface > IfacePtr
Type definition for the pointer to an Iface object.
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
const isc::log::MessageID DHCP6_DEPRECATED
#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