49namespace ph = std::placeholders;
54struct CtrlDhcp4Hooks {
55 int hooks_index_dhcp4_srv_configured_;
79void signalHandler(
int signo) {
81 if (signo == SIGHUP) {
83 }
else if ((signo == SIGTERM) || (signo == SIGINT)) {
98 start_ = boost::posix_time::second_clock::universal_time();
106 string reason = comment ? comment->stringValue() :
107 "no details available";
136 if (file_name.empty()) {
139 " Please use -c command line option.");
153 "a map, i.e., start with { and end with } and contain "
154 "at least an entry called 'Dhcp4' that itself is a map. "
156 <<
" is a valid JSON, but its top element is not a map."
157 " Did you forget to add { } around your configuration?");
167 "process command \"config-set\"");
175 string reason = comment ? comment->stringValue() :
176 "no details available";
179 }
catch (
const std::exception& ex) {
185 .arg(file_name).arg(ex.what());
187 << file_name <<
"': " << ex.
what());
199ControlledDhcpv4Srv::commandShutdownHandler(
const string&,
ConstElementPtr args) {
216 "parameter 'exit-value' is not an integer"));
219 exit_value = param->intValue();
228ControlledDhcpv4Srv::commandConfigReloadHandler(
const string&,
237 }
catch (
const std::exception& ex) {
244 "Config reload failed: " +
string(ex.what())));
249ControlledDhcpv4Srv::commandConfigGetHandler(
const string&,
259ControlledDhcpv4Srv::commandConfigHashGetHandler(
const string&,
271ControlledDhcpv4Srv::commandConfigWriteHandler(
const string&,
280 if (filename_param) {
283 "passed parameter 'filename' is not a string"));
285 filename = filename_param->stringValue();
289 if (filename.empty()) {
295 if (filename.empty()) {
297 "Please specify filename explicitly."));
320 + filename +
" successful", params));
324ControlledDhcpv4Srv::commandConfigSetHandler(
const string&,
333 message =
"Missing mandatory 'arguments' parameter.";
335 dhcp4 = args->get(
"Dhcp4");
337 message =
"Missing mandatory 'Dhcp4' parameter.";
339 message =
"'Dhcp4' parameter expected to be a map.";
344 if (message.empty()) {
345 for (
auto const& obj : args->mapValue()) {
346 const string& obj_name = obj.first;
347 if (obj_name !=
"Dhcp4") {
350 if (message.empty()) {
351 message =
"Unsupported '" + obj_name +
"' parameter";
353 message +=
" (and '" + obj_name +
"')";
357 if (!message.empty()) {
362 if (!message.empty()) {
419 }
catch (
const std::exception& ex) {
420 std::ostringstream err;
421 err <<
"Error initializing hooks: "
430ControlledDhcpv4Srv::commandConfigTestHandler(
const string&,
439 message =
"Missing mandatory 'arguments' parameter.";
441 dhcp4 = args->get(
"Dhcp4");
443 message =
"Missing mandatory 'Dhcp4' parameter.";
445 message =
"'Dhcp4' parameter expected to be a map.";
450 if (message.empty()) {
451 for (
auto const& obj : args->mapValue()) {
452 const string& obj_name = obj.first;
453 if (obj_name !=
"Dhcp4") {
456 if (message.empty()) {
457 message =
"Unsupported '" + obj_name +
"' parameter";
459 message +=
" (and '" + obj_name +
"')";
463 if (!message.empty()) {
468 if (!message.empty()) {
488ControlledDhcpv4Srv::commandDhcpDisableHandler(
const std::string&,
490 std::ostringstream message;
491 int64_t max_period = 0;
503 message <<
"arguments for the 'dhcp-disable' command must be a map";
508 if (max_period_element) {
511 message <<
"'max-period' argument must be a number";
515 max_period = max_period_element->intValue();
516 if (max_period <= 0) {
517 message <<
"'max-period' must be positive integer";
530 if (origin_id_element) {
532 type = origin_id_element->intValue();
534 message <<
"'origin-id' argument must be a number";
536 }
else if (origin_element) {
537 switch (origin_element->getType()) {
539 origin = origin_element->stringValue();
540 if (origin ==
"ha-partner") {
542 }
else if (origin !=
"user") {
543 if (origin.empty()) {
544 origin =
"(empty string)";
546 message <<
"invalid value used for 'origin' parameter: "
551 type = origin_element->intValue();
555 message <<
"'origin' argument must be a string or a number";
562 if (message.tellp() == 0) {
563 message <<
"DHCPv4 service disabled";
564 if (max_period > 0) {
565 message <<
" for " << max_period <<
" seconds";
570 network_state_->delayedEnableService(
static_cast<unsigned>(max_period),
584ControlledDhcpv4Srv::commandDhcpEnableHandler(
const std::string&,
586 std::ostringstream message;
597 message <<
"arguments for the 'dhcp-enable' command must be a map";
609 if (origin_id_element) {
611 type = origin_id_element->intValue();
613 message <<
"'origin-id' argument must be a number";
615 }
else if (origin_element) {
616 switch (origin_element->getType()) {
618 origin = origin_element->stringValue();
619 if (origin ==
"ha-partner") {
621 }
else if (origin !=
"user") {
622 if (origin.empty()) {
623 origin =
"(empty string)";
625 message <<
"invalid value used for 'origin' parameter: "
630 type = origin_element->intValue();
634 message <<
"'origin' argument must be a string or a number";
641 if (message.tellp() == 0) {
646 "DHCP service successfully enabled"));
654ControlledDhcpv4Srv::commandVersionGetHandler(
const string&,
ConstElementPtr) {
657 arguments->set(
"extended", extended);
665ControlledDhcpv4Srv::commandBuildReportHandler(
const string&,
673ControlledDhcpv4Srv::commandLeasesReclaimHandler(
const string&,
680 message =
"Missing mandatory 'remove' parameter.";
684 message =
"Missing mandatory 'remove' parameter.";
686 message =
"'remove' parameter expected to be a boolean.";
688 bool remove_lease = remove_name->boolValue();
689 server_->alloc_engine_->reclaimExpiredLeases4(0, 0, remove_lease);
691 message =
"Reclamation of expired leases is complete.";
699ControlledDhcpv4Srv::commandSubnet4SelectTestHandler(
const string&,
707 bool ignore_link_sel =
710 for (
auto const& entry : args->mapValue()) {
711 ostringstream errmsg;
712 if (entry.first ==
"interface") {
714 errmsg <<
"'interface' entry must be a string";
717 selector.
iface_name_ = entry.second->stringValue();
719 }
else if (entry.first ==
"address") {
721 errmsg <<
"'address' entry must be a string";
725 IOAddress addr(entry.second->stringValue());
727 errmsg <<
"bad 'address' entry: not IPv4";
730 selector.ciaddr_ = addr;
732 }
catch (
const exception& ex) {
733 errmsg <<
"bad 'address' entry: " << ex.what();
736 }
else if (entry.first ==
"relay") {
738 errmsg <<
"'relay' entry must be a string";
742 IOAddress addr(entry.second->stringValue());
744 errmsg <<
"bad 'relay' entry: not IPv4";
747 selector.giaddr_ = addr;
749 }
catch (
const exception& ex) {
750 errmsg <<
"bad 'relay' entry: " << ex.what();
753 }
else if (entry.first ==
"local") {
755 errmsg <<
"'local' entry must be a string";
759 IOAddress addr(entry.second->stringValue());
761 errmsg <<
"bad 'local' entry: not IPv4";
764 selector.local_address_ = addr;
766 }
catch (
const exception& ex) {
767 errmsg <<
"bad 'local' entry: " << ex.what();
770 }
else if (entry.first ==
"remote") {
772 errmsg <<
"'remote' entry must be a string";
776 IOAddress addr(entry.second->stringValue());
778 errmsg <<
"bad 'remote' entry: not IPv4";
781 selector.remote_address_ = addr;
783 }
catch (
const exception& ex) {
784 errmsg <<
"bad 'remote' entry: " << ex.what();
787 }
else if (entry.first ==
"link") {
789 errmsg <<
"'link' entry must be a string";
793 IOAddress addr(entry.second->stringValue());
795 errmsg <<
"bad 'link' entry: not IPv4";
798 if (!ignore_link_sel) {
799 selector.option_select_ = addr;
802 }
catch (
const exception& ex) {
803 errmsg <<
"bad 'link' entry: " << ex.what();
806 }
else if (entry.first ==
"subnet") {
808 if (args->contains(
"link") && !ignore_link_sel) {
812 errmsg <<
"'subnet' entry must be a string";
816 IOAddress addr(entry.second->stringValue());
818 errmsg <<
"bad 'subnet' entry: not IPv4";
821 selector.option_select_ = addr;
823 }
catch (
const exception& ex) {
824 errmsg <<
"bad 'subnet' entry: " << ex.what();
827 }
else if (entry.first ==
"classes") {
830 "'classes' entry must be a list"));
832 for (
auto const& item : entry.second->listValue()) {
834 errmsg <<
"'classes' entry must be a list of strings";
838 if (!item->stringValue().empty()) {
839 selector.client_classes_.insert(item->stringValue());
844 errmsg <<
"unknown entry '" << entry.first <<
"'";
849 getCfgSubnets4()->selectSubnet(selector);
854 subnet->getSharedNetwork(network);
857 msg <<
"selected shared network '" << network->getName()
858 <<
"' starting with subnet '" << subnet->toText()
859 <<
"' id " << subnet->getID();
861 msg <<
"selected subnet '" << subnet->toText()
862 <<
"' id " << subnet->getID();
868ControlledDhcpv4Srv::commandSubnet4o6SelectTestHandler(
const string&,
880 for (
auto const& entry : args->mapValue()) {
881 ostringstream errmsg;
882 if (entry.first ==
"interface") {
884 errmsg <<
"'interface' entry must be a string";
887 selector.iface_name_ = entry.second->stringValue();
889 }
if (entry.first ==
"interface-id") {
891 errmsg <<
"'interface-id' entry must be a string";
895 string str = entry.second->stringValue();
901 errmsg <<
"'interface-id' must be not empty";
909 errmsg <<
"value of 'interface-id' was not recognized";
912 }
else if (entry.first ==
"address") {
914 errmsg <<
"'address' entry must be a string";
918 IOAddress addr(entry.second->stringValue());
920 errmsg <<
"bad 'address' entry: not IPv4";
923 selector.ciaddr_ = addr;
925 }
catch (
const exception& ex) {
926 errmsg <<
"bad 'address' entry: " << ex.what();
929 }
else if (entry.first ==
"relay") {
931 errmsg <<
"'relay' entry must be a string";
935 IOAddress addr(entry.second->stringValue());
937 errmsg <<
"bad 'relay' entry: not IPv4";
940 selector.giaddr_ = addr;
942 }
catch (
const exception& ex) {
943 errmsg <<
"bad 'relay' entry: " << ex.what();
946 }
else if (entry.first ==
"local") {
948 errmsg <<
"'local' entry must be a string";
952 IOAddress addr(entry.second->stringValue());
954 errmsg <<
"bad 'local' entry: not IPv6";
957 selector.local_address_ = addr;
959 }
catch (
const exception& ex) {
960 errmsg <<
"bad 'local' entry: " << ex.what();
963 }
else if (entry.first ==
"remote") {
965 errmsg <<
"'remote' entry must be a string";
969 IOAddress addr(entry.second->stringValue());
971 errmsg <<
"bad 'remote' entry: not IPv6";
974 selector.remote_address_ = addr;
976 }
catch (
const exception& ex) {
977 errmsg <<
"bad 'remote' entry: " << ex.what();
980 }
else if (entry.first ==
"link") {
982 errmsg <<
"'link' entry must be a string";
986 IOAddress addr(entry.second->stringValue());
988 errmsg <<
"bad 'link' entry: not IPv6";
991 selector.first_relay_linkaddr_ = addr;
993 }
catch (
const exception& ex) {
994 errmsg <<
"bad 'link' entry: " << ex.what();
997 }
else if (entry.first ==
"subnet") {
999 errmsg <<
"'subnet' entry must be a string";
1003 IOAddress addr(entry.second->stringValue());
1005 errmsg <<
"bad 'subnet' entry: not IPv4";
1008 selector.option_select_ = addr;
1010 }
catch (
const exception& ex) {
1011 errmsg <<
"bad 'subnet' entry: " << ex.what();
1014 }
else if (entry.first ==
"classes") {
1017 "'classes' entry must be a list"));
1019 for (
auto const& item : entry.second->listValue()) {
1021 errmsg <<
"'classes' entry must be a list of strings";
1025 if (!item->stringValue().empty()) {
1026 selector.client_classes_.insert(item->stringValue());
1031 errmsg <<
"unknown entry '" << entry.first <<
"'";
1036 getCfgSubnets4()->selectSubnet4o6(selector);
1041 subnet->getSharedNetwork(network);
1044 msg <<
"selected shared network '" << network->getName()
1045 <<
"' starting with subnet '" << subnet->toText()
1046 <<
"' id " << subnet->getID();
1048 msg <<
"selected subnet '" << subnet->toText()
1049 <<
"' id " << subnet->getID();
1055ControlledDhcpv4Srv::commandServerTagGetHandler(
const std::string&,
1057 const std::string& tag =
1066ControlledDhcpv4Srv::commandConfigBackendPullHandler(
const std::string&,
1068 auto ctl_info =
CfgMgr::instance().getCurrentCfg()->getConfigControlInfo();
1088 server_->getCBControl()->databaseConfigFetch(srv_cfg, mode);
1089 }
catch (
const std::exception& ex) {
1093 "On demand configuration update failed: " +
1094 string(ex.what())));
1097 "On demand configuration update successful."));
1101ControlledDhcpv4Srv::commandStatusGetHandler(
const string&,
1106 auto now = boost::posix_time::second_clock::universal_time();
1108 if (!
start_.is_not_a_date_time()) {
1109 auto uptime = now -
start_;
1113 auto last_commit =
CfgMgr::instance().getCurrentCfg()->getLastCommitTime();
1114 if (!last_commit.is_not_a_date_time()) {
1115 auto reload = now - last_commit;
1120 if (mt_mgr.getMode()) {
1124 status->set(
"packet-queue-size",
Element::create(
static_cast<int32_t
>(
1127 queue_stats->add(
Element::create(mt_mgr.getThreadPool().getQueueStat(10)));
1128 queue_stats->add(
Element::create(mt_mgr.getThreadPool().getQueueStat(100)));
1129 queue_stats->add(
Element::create(mt_mgr.getThreadPool().getQueueStat(1000)));
1130 status->set(
"packet-queue-statistics", queue_stats);
1139 for (std::string
const&
error : interface->getErrors()) {
1146 if (socket_errors->empty()) {
1151 if (reconnect_ctl && reconnect_ctl->retriesLeft()) {
1156 sockets->set(
"errors", socket_errors);
1158 status->set(
"sockets", sockets);
1166ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler(
const string&,
1169 ConstElementPtr answer = stats_mgr.statisticSetMaxSampleCountAllHandler(args);
1171 long max_samples = stats_mgr.getMaxSampleCountDefault();
1178ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler(
const string&,
1181 ConstElementPtr answer = stats_mgr.statisticSetMaxSampleAgeAllHandler(args);
1183 auto duration = stats_mgr.getMaxSampleAgeDefault();
1199 std::ostringstream err;
1202 err <<
"Server object not initialized, can't process config.";
1207 .arg(srv->redactConfig(config)->str());
1225 }
catch (
const std::exception& ex) {
1226 err <<
"Failed to process configuration:" << ex.what();
1233 std::bind(&ControlledDhcpv4Srv::dbLostCallback, srv, ph::_1);
1236 std::bind(&ControlledDhcpv4Srv::dbRecoveredCallback, srv, ph::_1);
1239 std::bind(&ControlledDhcpv4Srv::dbFailedCallback, srv, ph::_1);
1242 string params =
"universe=4";
1243 cfg_db->setAppendedParameters(params);
1244 cfg_db->createManagers();
1246 srv->getNetworkState()->resetForDbConnection();
1247 srv->getNetworkState()->resetForLocalCommands();
1248 srv->getNetworkState()->resetForRemoteCommands();
1249 }
catch (
const std::exception& ex) {
1250 err <<
"Unable to open database: " << ex.what();
1257 }
catch (
const std::exception& ex) {
1258 err <<
"Error starting DHCP_DDNS client after server reconfiguration: "
1266 }
catch (
const std::exception& ex) {
1267 err <<
"error starting DHCPv4-over-DHCPv6 IPC "
1268 " after server reconfiguration: " << ex.what();
1281 }
catch (
const std::exception& ex) {
1282 err <<
"Error setting packet queue controls after server reconfiguration: "
1290 std::bind(&ControlledDhcpv4Srv::openSocketsFailedCallback, srv, ph::_1);
1300 openSockets(AF_INET, srv->getServerPort(),
1306 setupTimers(&ControlledDhcpv4Srv::reclaimExpiredLeases,
1307 &ControlledDhcpv4Srv::deleteExpiredReclaimedLeases,
1310 }
catch (
const std::exception& ex) {
1311 err <<
"unable to setup timers for periodically running the"
1312 " reclamation of the expired leases: "
1313 << ex.what() <<
".";
1318 auto ctl_info =
CfgMgr::instance().getStagingCfg()->getConfigControlInfo();
1320 long fetch_time =
static_cast<long>(ctl_info->getConfigFetchWaitTime());
1323 if (fetch_time > 0) {
1329 if (!server_->inTestMode()) {
1330 fetch_time = 1000 * fetch_time;
1333 boost::shared_ptr<unsigned> failure_count(
new unsigned(0));
1335 registerTimer(
"Dhcp4CBFetchTimer",
1336 std::bind(&ControlledDhcpv4Srv::cbFetchUpdates,
1350 if (notify_libraries) {
1351 return (notify_libraries);
1358 CfgMgr::instance().getStagingCfg()->getCfgSubnets4()->initAllocatorsAfterConfigure();
1360 }
catch (
const std::exception& ex) {
1361 err <<
"Error initializing the lease allocators: "
1372 }
catch (
const std::exception& ex) {
1373 err <<
"Error applying multi threading settings: "
1392 callout_handle->setArgument(
"io_context", srv->getIOService());
1393 callout_handle->setArgument(
"network_state", srv->getNetworkState());
1394 callout_handle->setArgument(
"json_config", config);
1395 callout_handle->setArgument(
"server_config",
CfgMgr::instance().getStagingCfg());
1404 callout_handle->getArgument(
"error",
error);
1406 error =
"unknown error";
1421 "Server object not initialized, can't process config.");
1426 .arg(srv->redactConfig(config)->str());
1432 uint16_t client_port )
1436 "There is another Dhcpv4Srv instance already.");
1459 std::bind(&ControlledDhcpv4Srv::commandBuildReportHandler,
this, ph::_1, ph::_2));
1462 std::bind(&ControlledDhcpv4Srv::commandConfigBackendPullHandler,
this, ph::_1, ph::_2));
1465 std::bind(&ControlledDhcpv4Srv::commandConfigGetHandler,
this, ph::_1, ph::_2));
1468 std::bind(&ControlledDhcpv4Srv::commandConfigHashGetHandler,
this, ph::_1, ph::_2));
1471 std::bind(&ControlledDhcpv4Srv::commandConfigReloadHandler,
this, ph::_1, ph::_2));
1474 std::bind(&ControlledDhcpv4Srv::commandConfigSetHandler,
this, ph::_1, ph::_2));
1477 std::bind(&ControlledDhcpv4Srv::commandConfigTestHandler,
this, ph::_1, ph::_2));
1480 std::bind(&ControlledDhcpv4Srv::commandConfigWriteHandler,
this, ph::_1, ph::_2));
1483 std::bind(&ControlledDhcpv4Srv::commandDhcpEnableHandler,
this, ph::_1, ph::_2));
1486 std::bind(&ControlledDhcpv4Srv::commandDhcpDisableHandler,
this, ph::_1, ph::_2));
1489 std::bind(&ControlledDhcpv4Srv::commandLeasesReclaimHandler,
this, ph::_1, ph::_2));
1492 std::bind(&ControlledDhcpv4Srv::commandSubnet4SelectTestHandler,
this, ph::_1, ph::_2));
1495 std::bind(&ControlledDhcpv4Srv::commandSubnet4o6SelectTestHandler,
this, ph::_1, ph::_2));
1498 std::bind(&ControlledDhcpv4Srv::commandServerTagGetHandler,
this, ph::_1, ph::_2));
1501 std::bind(&ControlledDhcpv4Srv::commandShutdownHandler,
this, ph::_1, ph::_2));
1504 std::bind(&ControlledDhcpv4Srv::commandStatusGetHandler,
this, ph::_1, ph::_2));
1507 std::bind(&ControlledDhcpv4Srv::commandVersionGetHandler,
this, ph::_1, ph::_2));
1532 std::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler,
this, ph::_1, ph::_2));
1538 std::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler,
this, ph::_1, ph::_2));
1559 timer_mgr_->unregisterTimers();
1608ControlledDhcpv4Srv::reclaimExpiredLeases(
const size_t max_leases,
1609 const uint16_t timeout,
1610 const bool remove_lease,
1611 const uint16_t max_unwarned_cycles) {
1613 server_->alloc_engine_->reclaimExpiredLeases4(max_leases, timeout,
1615 max_unwarned_cycles);
1616 }
catch (
const std::exception& ex) {
1625ControlledDhcpv4Srv::deleteExpiredReclaimedLeases(
const uint32_t secs) {
1626 server_->alloc_engine_->deleteExpiredReclaimedLeases4(secs);
1632ControlledDhcpv4Srv::dbLostCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1633 if (!db_reconnect_ctl) {
1640 if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
1641 db_reconnect_ctl->alterServiceState()) {
1649 if (!db_reconnect_ctl->retriesLeft() ||
1650 !db_reconnect_ctl->retryInterval()) {
1652 .arg(db_reconnect_ctl->retriesLeft())
1653 .arg(db_reconnect_ctl->retryInterval());
1654 if (db_reconnect_ctl->exitOnFailure()) {
1664ControlledDhcpv4Srv::dbRecoveredCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1665 if (!db_reconnect_ctl) {
1672 if (db_reconnect_ctl->alterServiceState()) {
1678 db_reconnect_ctl->resetRetries();
1684ControlledDhcpv4Srv::dbFailedCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1685 if (!db_reconnect_ctl) {
1692 .arg(db_reconnect_ctl->maxRetries());
1694 if (db_reconnect_ctl->exitOnFailure()) {
1702ControlledDhcpv4Srv::openSocketsFailedCallback(
ReconnectCtlPtr reconnect_ctl) {
1703 if (!reconnect_ctl) {
1710 .arg(reconnect_ctl->maxRetries());
1712 if (reconnect_ctl->exitOnFailure()) {
1718ControlledDhcpv4Srv::cbFetchUpdates(
const SrvConfigPtr& srv_cfg,
1719 boost::shared_ptr<unsigned> failure_count) {
1725 server_->getCBControl()->databaseConfigFetch(srv_cfg,
1727 (*failure_count) = 0;
1729 }
catch (
const std::exception& ex) {
1736 if (++(*failure_count) > 10) {
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown if a function is called in a prohibited way.
The IOAddress class represents an IP addresses (version agnostic)
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
static IOServiceMgr & instance()
Access the IOServiceMgr singleton instance.
Implements an asynchronous "signal" for IOService driven processing.
static void setIOService(isc::asiolink::IOServicePtr io_service)
Set the I/O service.
static std::string getHash(const isc::data::ConstElementPtr &config)
returns a hash of a given Element structure
static CommandMgr & instance()
CommandMgr is a singleton class.
static std::string DEFAULT_AUTHENTICATION_REALM
Default HTTP authentication realm.
static HttpCommandMgr & instance()
HttpCommandMgr is a singleton class.
static UnixCommandMgr & instance()
UnixCommandMgr is a singleton class.
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
static void setIOService(const isc::asiolink::IOServicePtr &io_service)
Sets IO service to be used by the database backends.
static DbCallback db_recovered_callback_
Optional callback function to invoke if an opened connection recovery succeeded.
static DbCallback db_failed_callback_
Optional callback function to invoke if an opened connection recovery failed.
static DbCallback db_lost_callback_
Optional callback function to invoke if an opened connection is lost.
RAII class to enable DB reconnect retries on server startup.
static const std::string FLUSH_RECLAIMED_TIMER_NAME
Name of the timer for flushing reclaimed leases.
static const std::string RECLAIM_EXPIRED_TIMER_NAME
Name of the timer for reclaiming expired leases.
static OpenSocketsFailedCallback open_sockets_failed_callback_
Optional callback function to invoke if all retries of the opening sockets fail.
static CfgMgr & instance()
returns a single instance of Configuration Manager
static void apply(data::ConstElementPtr value)
apply multi threading configuration
Controlled version of the DHCPv4 server.
virtual ~ControlledDhcpv4Srv()
Destructor.
static isc::data::ConstElementPtr finishConfigHookLibraries(isc::data::ConstElementPtr config)
Configuration checker for hook libraries.
isc::data::ConstElementPtr loadConfigFile(const std::string &file_name)
Configure DHCPv4 server using the configuration file specified.
void cleanup()
Performs cleanup, immediately before termination.
ControlledDhcpv4Srv(uint16_t server_port=DHCP4_SERVER_PORT, uint16_t client_port=0)
Constructor.
static isc::data::ConstElementPtr checkConfig(isc::data::ConstElementPtr config)
Configuration checker.
void init(const std::string &config_file)
Initializes the server.
static isc::data::ConstElementPtr processConfig(isc::data::ConstElementPtr config)
Configuration processor.
static ControlledDhcpv4Srv * getInstance()
Returns pointer to the sole instance of Dhcpv4Srv.
virtual void shutdownServer(int exit_value)
Initiates shutdown procedure for the whole DHCPv4 server.
static Dhcp4to6Ipc & instance()
Returns pointer to the sole instance of Dhcp4to6Ipc.
void shutdown() override
Instructs the server to shut down.
asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service used by the server.
static std::string getVersion(bool extended)
returns Kea version on stdout and exit.
bool useBroadcast() const
Return bool value indicating that broadcast flags should be set on sockets.
NetworkStatePtr network_state_
Holds information about disabled DHCP service and/or disabled subnet/network scopes.
static void create()
Creates new instance of the HostMgr.
Handles network interfaces, transmission and reception.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
static void destroy()
Destroy lease manager.
static void commitRuntimeOptionDefs()
Commits runtime option definitions.
static const unsigned int DB_CONNECTION
The network state is being altered by the DB connection recovery mechanics.
static const unsigned int USER_COMMAND
Origin of the network state transition.
static const unsigned int HA_REMOTE_COMMAND
The network state is being altered by a "dhcp-disable" or "dhcp-enable" command sent by a HA partner.
Evaluation context, an interface to the expression evaluation.
isc::data::ElementPtr parseFile(const std::string &filename, ParserType parser_type)
Run the parser on the file specified.
@ PARSER_DHCP4
This parser will parse the content as Dhcp4 config wrapped in a map (that's the regular config file)
Manages a pool of asynchronous interval timers.
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
@ NEXT_STEP_DROP
drop the packet
static int registerHook(const std::string &name)
Register Hook.
static bool calloutsPresent(int index)
Are callouts present?
static boost::shared_ptr< CalloutHandle > createCalloutHandle()
Return callout handle.
static void callCallouts(int index, CalloutHandle &handle)
Calls the callouts for a given hook.
std::string getConfigFile() const
Returns config file name.
virtual size_t writeConfigFile(const std::string &config_file, isc::data::ConstElementPtr cfg=isc::data::ConstElementPtr()) const
Writes current configuration to specified file.
isc::asiolink::IOSignalSetPtr signal_set_
A pointer to the object installing custom signal handlers.
boost::posix_time::ptime start_
Timestamp of the start of the daemon.
void setExitValue(int value)
Sets the exit value.
Statistics Manager class.
static StatsMgr & instance()
Statistics Manager accessor method.
RAII class creating a critical section.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
This file contains several functions and constants that are used for handling commands and responses ...
Contains declarations for loggers used by the DHCPv4 server component.
Defines the Dhcp4o6Ipc class.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
static isc::data::ConstElementPtr statisticResetHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-reset command.
static isc::data::ConstElementPtr statisticGetAllHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-get-all command.
static isc::data::ConstElementPtr statisticRemoveHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-remove command.
static isc::data::ConstElementPtr statisticGetHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-get command.
static isc::data::ConstElementPtr statisticResetAllHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-reset-all command.
static isc::data::ConstElementPtr statisticSetMaxSampleAgeHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-age-set command.
static isc::data::ConstElementPtr statisticRemoveAllHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-remove-all command.
static isc::data::ConstElementPtr statisticSetMaxSampleCountHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-count-set command.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
#define LOG_FATAL(LOGGER, MESSAGE)
Macro to conveniently test fatal output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
ConstElementPtr createCommand(const std::string &command)
Creates a standard command message with no argument (of the form { "command": "my_command" })
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
std::string getConfigReport()
const isc::log::MessageID DHCP4_NOT_RUNNING
const isc::log::MessageID DHCP4_DYNAMIC_RECONFIGURATION_FAIL
const isc::log::MessageID DHCP4_CONFIG_RECEIVED
const isc::log::MessageID DHCP4_DYNAMIC_RECONFIGURATION_SUCCESS
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
boost::shared_ptr< Iface > IfacePtr
Type definition for the pointer to an Iface object.
const isc::log::MessageID DHCP4_DB_RECONNECT_NO_DB_CTL
const isc::log::MessageID DHCP4_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED
const isc::log::MessageID DHCP4_CONFIG_PACKET_QUEUE
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
const isc::log::MessageID DHCP4_CB_ON_DEMAND_FETCH_UPDATES_FAIL
const isc::log::MessageID DHCP4_CONFIG_LOAD_FAIL
const int DBG_DHCP4_COMMAND
Debug level used to log receiving commands.
const isc::log::MessageID DHCP4_DB_RECONNECT_DISABLED
const isc::log::MessageID DHCP4_CONFIG_UNRECOVERABLE_ERROR
const isc::log::MessageID DHCP4_DB_RECONNECT_SUCCEEDED
isc::data::ConstElementPtr configureDhcp4Server(Dhcpv4Srv &server, isc::data::ConstElementPtr config_set, bool check_only, bool extra_checks)
Configure DHCPv4 server (Dhcpv4Srv) with a set of configuration values.
const isc::log::MessageID DHCP4_MULTI_THREADING_INFO
const isc::log::MessageID DHCP4_OPEN_SOCKETS_NO_RECONNECT_CTL
isc::log::Logger dhcp4_logger(DHCP4_APP_LOGGER_NAME)
Base logger for DHCPv4 server.
boost::shared_ptr< SharedNetwork4 > SharedNetwork4Ptr
Pointer to SharedNetwork4 object.
const isc::log::MessageID DHCP4_DB_RECONNECT_FAILED
const isc::log::MessageID DHCP4_OPEN_SOCKETS_FAILED
const isc::log::MessageID DHCP4_DYNAMIC_RECONFIGURATION
const isc::log::MessageID DHCP4_RECLAIM_EXPIRED_LEASES_FAIL
boost::shared_ptr< Option > OptionPtr
const isc::log::MessageID DHCP4_CONFIG_UNSUPPORTED_OBJECT
const isc::log::MessageID DHCP4_CB_PERIODIC_FETCH_UPDATES_FAIL
const isc::log::MessageID DHCP4_DB_RECONNECT_LOST_CONNECTION
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
long toSeconds(const StatsDuration &dur)
Returns the number of seconds in a duration.
void decodeFormattedHexString(const string &hex_string, vector< uint8_t > &binary)
Converts a formatted string of hexadecimal digits into a vector.
vector< uint8_t > quotedStringToBinary(const string "ed_string)
Converts a string in quotes into vector.
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
Defines the logger used by the top-level component of kea-lfc.
Subnet selector used to specify parameters used to select a subnet.
bool dhcp4o6_
Specifies if the packet is DHCP4o6.
std::string iface_name_
Name of the interface on which the message was received.