51namespace ph = std::placeholders;
56struct CtrlDhcp4Hooks {
57 int hooks_index_dhcp4_srv_configured_;
81void signalHandler(
int signo) {
83 if (signo == SIGHUP) {
85 }
else if ((signo == SIGTERM) || (signo == SIGINT)) {
100 start_ = boost::posix_time::second_clock::universal_time();
108 string reason = comment ? comment->stringValue() :
109 "no details available";
138 if (file_name.empty()) {
141 " Please use -c command line option.");
155 "a map, i.e., start with { and end with } and contain "
156 "at least an entry called 'Dhcp4' that itself is a map. "
158 <<
" is a valid JSON, but its top element is not a map."
159 " Did you forget to add { } around your configuration?");
169 "process command \"config-set\"");
177 string reason = comment ? comment->stringValue() :
178 "no details available";
181 }
catch (
const std::exception& ex) {
187 .arg(file_name).arg(ex.what());
189 << file_name <<
"': " << ex.what());
201ControlledDhcpv4Srv::commandShutdownHandler(
const string&,
ConstElementPtr args) {
218 "parameter 'exit-value' is not an integer"));
221 exit_value = param->intValue();
230ControlledDhcpv4Srv::commandConfigReloadHandler(
const string&,
239 }
catch (
const std::exception& ex) {
246 "Config reload failed: " +
string(ex.what())));
251ControlledDhcpv4Srv::commandConfigGetHandler(
const string&,
261ControlledDhcpv4Srv::commandConfigHashGetHandler(
const string&,
273ControlledDhcpv4Srv::commandConfigWriteHandler(
const string&,
282 if (filename_param) {
285 "passed parameter 'filename' is not a string"));
287 filename = filename_param->stringValue();
291 if (filename.empty()) {
295 if (filename.empty()) {
297 "Please specify filename explicitly."));
302 }
catch (
const isc::Exception& ex) {
303 std::ostringstream msg;
304 msg <<
"not allowed to write config into " << filename
305 <<
": " << ex.
what();
315 }
catch (
const isc::Exception& ex) {
330 + filename +
" successful", params));
334ControlledDhcpv4Srv::commandConfigSetHandler(
const string&,
343 message =
"Missing mandatory 'arguments' parameter.";
345 dhcp4 = args->get(
"Dhcp4");
347 message =
"Missing mandatory 'Dhcp4' parameter.";
349 message =
"'Dhcp4' parameter expected to be a map.";
354 if (message.empty()) {
355 for (
auto const& obj : args->mapValue()) {
356 const string& obj_name = obj.first;
357 if (obj_name !=
"Dhcp4") {
360 if (message.empty()) {
361 message =
"Unsupported '" + obj_name +
"' parameter";
363 message +=
" (and '" + obj_name +
"')";
367 if (!message.empty()) {
372 if (!message.empty()) {
385 "Can not update configuration while lease file cleanup process is running."));
390 MultiThreadingCriticalSection cs;
439 }
catch (
const std::exception& ex) {
440 std::ostringstream err;
441 err <<
"Error initializing hooks: "
450ControlledDhcpv4Srv::commandConfigTestHandler(
const string&,
459 message =
"Missing mandatory 'arguments' parameter.";
461 dhcp4 = args->get(
"Dhcp4");
463 message =
"Missing mandatory 'Dhcp4' parameter.";
465 message =
"'Dhcp4' parameter expected to be a map.";
470 if (message.empty()) {
471 for (
auto const& obj : args->mapValue()) {
472 const string& obj_name = obj.first;
473 if (obj_name !=
"Dhcp4") {
476 if (message.empty()) {
477 message =
"Unsupported '" + obj_name +
"' parameter";
479 message +=
" (and '" + obj_name +
"')";
483 if (!message.empty()) {
488 if (!message.empty()) {
496 MultiThreadingCriticalSection cs;
508ControlledDhcpv4Srv::commandDhcpDisableHandler(
const std::string&,
510 std::ostringstream message;
511 int64_t max_period = 0;
523 message <<
"arguments for the 'dhcp-disable' command must be a map";
528 if (max_period_element) {
531 message <<
"'max-period' argument must be a number";
535 max_period = max_period_element->intValue();
536 if (max_period <= 0) {
537 message <<
"'max-period' must be positive integer";
550 if (origin_id_element) {
552 type = origin_id_element->intValue();
554 message <<
"'origin-id' argument must be a number";
556 }
else if (origin_element) {
557 switch (origin_element->getType()) {
559 origin = origin_element->stringValue();
560 if (origin ==
"ha-partner") {
562 }
else if (origin !=
"user") {
563 if (origin.empty()) {
564 origin =
"(empty string)";
566 message <<
"invalid value used for 'origin' parameter: "
571 type = origin_element->intValue();
575 message <<
"'origin' argument must be a string or a number";
582 if (message.tellp() == 0) {
583 message <<
"DHCPv4 service disabled";
584 if (max_period > 0) {
585 message <<
" for " << max_period <<
" seconds";
590 network_state_->delayedEnableService(
static_cast<unsigned>(max_period),
604ControlledDhcpv4Srv::commandDhcpEnableHandler(
const std::string&,
606 std::ostringstream message;
617 message <<
"arguments for the 'dhcp-enable' command must be a map";
629 if (origin_id_element) {
631 type = origin_id_element->intValue();
633 message <<
"'origin-id' argument must be a number";
635 }
else if (origin_element) {
636 switch (origin_element->getType()) {
638 origin = origin_element->stringValue();
639 if (origin ==
"ha-partner") {
641 }
else if (origin !=
"user") {
642 if (origin.empty()) {
643 origin =
"(empty string)";
645 message <<
"invalid value used for 'origin' parameter: "
650 type = origin_element->intValue();
654 message <<
"'origin' argument must be a string or a number";
661 if (message.tellp() == 0) {
666 "DHCP service successfully enabled"));
674ControlledDhcpv4Srv::commandVersionGetHandler(
const string&,
ConstElementPtr) {
677 arguments->set(
"extended", extended);
685ControlledDhcpv4Srv::commandBuildReportHandler(
const string&,
693ControlledDhcpv4Srv::commandLeasesReclaimHandler(
const string&,
700 message =
"Missing mandatory 'remove' parameter.";
704 message =
"Missing mandatory 'remove' parameter.";
706 message =
"'remove' parameter expected to be a boolean.";
708 bool remove_lease = remove_name->boolValue();
709 server_->alloc_engine_->reclaimExpiredLeases4(0, 0, remove_lease);
711 message =
"Reclamation of expired leases is complete.";
719ControlledDhcpv4Srv::commandSubnet4SelectTestHandler(
const string&,
727 bool ignore_link_sel =
729 SubnetSelector selector;
730 for (
auto const& entry : args->mapValue()) {
731 ostringstream errmsg;
732 if (entry.first ==
"interface") {
734 errmsg <<
"'interface' entry must be a string";
737 selector.
iface_name_ = entry.second->stringValue();
739 }
else if (entry.first ==
"address") {
741 errmsg <<
"'address' entry must be a string";
745 IOAddress addr(entry.second->stringValue());
747 errmsg <<
"bad 'address' entry: not IPv4";
752 }
catch (
const exception& ex) {
753 errmsg <<
"bad 'address' entry: " << ex.what();
756 }
else if (entry.first ==
"relay") {
758 errmsg <<
"'relay' entry must be a string";
762 IOAddress addr(entry.second->stringValue());
764 errmsg <<
"bad 'relay' entry: not IPv4";
769 }
catch (
const exception& ex) {
770 errmsg <<
"bad 'relay' entry: " << ex.what();
773 }
else if (entry.first ==
"local") {
775 errmsg <<
"'local' entry must be a string";
779 IOAddress addr(entry.second->stringValue());
781 errmsg <<
"bad 'local' entry: not IPv4";
786 }
catch (
const exception& ex) {
787 errmsg <<
"bad 'local' entry: " << ex.what();
790 }
else if (entry.first ==
"remote") {
792 errmsg <<
"'remote' entry must be a string";
796 IOAddress addr(entry.second->stringValue());
798 errmsg <<
"bad 'remote' entry: not IPv4";
803 }
catch (
const exception& ex) {
804 errmsg <<
"bad 'remote' entry: " << ex.what();
807 }
else if (entry.first ==
"link") {
809 errmsg <<
"'link' entry must be a string";
813 IOAddress addr(entry.second->stringValue());
815 errmsg <<
"bad 'link' entry: not IPv4";
818 if (!ignore_link_sel) {
822 }
catch (
const exception& ex) {
823 errmsg <<
"bad 'link' entry: " << ex.what();
826 }
else if (entry.first ==
"subnet") {
828 if (args->contains(
"link") && !ignore_link_sel) {
832 errmsg <<
"'subnet' entry must be a string";
836 IOAddress addr(entry.second->stringValue());
838 errmsg <<
"bad 'subnet' entry: not IPv4";
843 }
catch (
const exception& ex) {
844 errmsg <<
"bad 'subnet' entry: " << ex.what();
847 }
else if (entry.first ==
"classes") {
850 "'classes' entry must be a list"));
852 for (
auto const& item : entry.second->listValue()) {
854 errmsg <<
"'classes' entry must be a list of strings";
858 if (!item->stringValue().empty()) {
864 errmsg <<
"unknown entry '" << entry.first <<
"'";
869 getCfgSubnets4()->selectSubnet(selector);
874 subnet->getSharedNetwork(network);
877 msg <<
"selected shared network '" << network->getName()
878 <<
"' starting with subnet '" << subnet->toText()
879 <<
"' id " << subnet->getID();
881 msg <<
"selected subnet '" << subnet->toText()
882 <<
"' id " << subnet->getID();
888ControlledDhcpv4Srv::commandSubnet4o6SelectTestHandler(
const string&,
896 SubnetSelector selector;
900 for (
auto const& entry : args->mapValue()) {
901 ostringstream errmsg;
902 if (entry.first ==
"interface") {
904 errmsg <<
"'interface' entry must be a string";
907 selector.
iface_name_ = entry.second->stringValue();
909 }
if (entry.first ==
"interface-id") {
911 errmsg <<
"'interface-id' entry must be a string";
915 string str = entry.second->stringValue();
921 errmsg <<
"'interface-id' must be not empty";
929 errmsg <<
"value of 'interface-id' was not recognized";
932 }
else if (entry.first ==
"address") {
934 errmsg <<
"'address' entry must be a string";
938 IOAddress addr(entry.second->stringValue());
940 errmsg <<
"bad 'address' entry: not IPv4";
945 }
catch (
const exception& ex) {
946 errmsg <<
"bad 'address' entry: " << ex.what();
949 }
else if (entry.first ==
"relay") {
951 errmsg <<
"'relay' entry must be a string";
955 IOAddress addr(entry.second->stringValue());
957 errmsg <<
"bad 'relay' entry: not IPv4";
962 }
catch (
const exception& ex) {
963 errmsg <<
"bad 'relay' entry: " << ex.what();
966 }
else if (entry.first ==
"local") {
968 errmsg <<
"'local' entry must be a string";
972 IOAddress addr(entry.second->stringValue());
974 errmsg <<
"bad 'local' entry: not IPv6";
979 }
catch (
const exception& ex) {
980 errmsg <<
"bad 'local' entry: " << ex.what();
983 }
else if (entry.first ==
"remote") {
985 errmsg <<
"'remote' entry must be a string";
989 IOAddress addr(entry.second->stringValue());
991 errmsg <<
"bad 'remote' entry: not IPv6";
996 }
catch (
const exception& ex) {
997 errmsg <<
"bad 'remote' entry: " << ex.what();
1000 }
else if (entry.first ==
"link") {
1002 errmsg <<
"'link' entry must be a string";
1006 IOAddress addr(entry.second->stringValue());
1008 errmsg <<
"bad 'link' entry: not IPv6";
1013 }
catch (
const exception& ex) {
1014 errmsg <<
"bad 'link' entry: " << ex.what();
1017 }
else if (entry.first ==
"subnet") {
1019 errmsg <<
"'subnet' entry must be a string";
1023 IOAddress addr(entry.second->stringValue());
1025 errmsg <<
"bad 'subnet' entry: not IPv4";
1030 }
catch (
const exception& ex) {
1031 errmsg <<
"bad 'subnet' entry: " << ex.what();
1034 }
else if (entry.first ==
"classes") {
1037 "'classes' entry must be a list"));
1039 for (
auto const& item : entry.second->listValue()) {
1041 errmsg <<
"'classes' entry must be a list of strings";
1045 if (!item->stringValue().empty()) {
1051 errmsg <<
"unknown entry '" << entry.first <<
"'";
1056 getCfgSubnets4()->selectSubnet4o6(selector);
1061 subnet->getSharedNetwork(network);
1064 msg <<
"selected shared network '" << network->getName()
1065 <<
"' starting with subnet '" << subnet->toText()
1066 <<
"' id " << subnet->getID();
1068 msg <<
"selected subnet '" << subnet->toText()
1069 <<
"' id " << subnet->getID();
1075ControlledDhcpv4Srv::commandServerTagGetHandler(
const std::string&,
1077 const std::string& tag =
1086ControlledDhcpv4Srv::commandConfigBackendPullHandler(
const std::string&,
1094 MultiThreadingCriticalSection cs;
1107 auto mode = CBControlDHCPv4::FetchMode::FETCH_UPDATE;
1108 server_->getCBControl()->databaseConfigFetch(srv_cfg, mode);
1109 }
catch (
const std::exception& ex) {
1113 "On demand configuration update failed: " +
1114 string(ex.what())));
1117 "On demand configuration update successful."));
1121ControlledDhcpv4Srv::commandStatusGetHandler(
const string&,
1126 auto now = boost::posix_time::second_clock::universal_time();
1128 if (!
start_.is_not_a_date_time()) {
1129 auto uptime = now -
start_;
1134 if (!last_commit.is_not_a_date_time()) {
1135 auto reload = now - last_commit;
1140 if (mt_mgr.getMode()) {
1144 status->set(
"packet-queue-size",
Element::create(
static_cast<int32_t
>(
1147 queue_stats->add(
Element::create(mt_mgr.getThreadPool().getQueueStat(10)));
1148 queue_stats->add(
Element::create(mt_mgr.getThreadPool().getQueueStat(100)));
1149 queue_stats->add(
Element::create(mt_mgr.getThreadPool().getQueueStat(1000)));
1150 status->set(
"packet-queue-statistics", queue_stats);
1162 for (
auto const& entry : lm_info->mapValue()) {
1163 status->set(entry.first, entry.second);
1170 for (std::string
const&
error : interface->getErrors()) {
1177 if (socket_errors->empty()) {
1182 if (reconnect_ctl && reconnect_ctl->retriesLeft()) {
1187 sockets->set(
"errors", socket_errors);
1189 status->set(
"sockets", sockets);
1197ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler(
const string&,
1209ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler(
const string&,
1222ControlledDhcpv4Srv::commandLfcStartHandler(
const string&,
ConstElementPtr) {
1227 "no lease backend"));
1239 std::ostringstream err;
1242 err <<
"Server object not initialized, can't process config.";
1265 }
catch (
const std::exception& ex) {
1266 err <<
"Failed to process configuration:" << ex.what();
1273 std::bind(&ControlledDhcpv4Srv::dbLostCallback, srv, ph::_1);
1276 std::bind(&ControlledDhcpv4Srv::dbRecoveredCallback, srv, ph::_1);
1279 std::bind(&ControlledDhcpv4Srv::dbFailedCallback, srv, ph::_1);
1282 string params =
"universe=4";
1283 cfg_db->setAppendedParameters(params);
1284 cfg_db->createManagers();
1289 }
catch (
const std::exception& ex) {
1290 err <<
"Unable to open database: " << ex.what();
1297 }
catch (
const std::exception& ex) {
1298 err <<
"Error starting DHCP_DDNS client after server reconfiguration: "
1306 }
catch (
const std::exception& ex) {
1307 err <<
"error starting DHCPv4-over-DHCPv6 IPC "
1308 " after server reconfiguration: " << ex.what();
1321 }
catch (
const std::exception& ex) {
1322 err <<
"Error setting packet queue controls after server reconfiguration: "
1330 std::bind(&ControlledDhcpv4Srv::openSocketsFailedCallback, srv, ph::_1);
1346 setupTimers(&ControlledDhcpv4Srv::reclaimExpiredLeases,
1347 &ControlledDhcpv4Srv::deleteExpiredReclaimedLeases,
1350 }
catch (
const std::exception& ex) {
1351 err <<
"unable to setup timers for periodically running the"
1352 " reclamation of the expired leases: "
1353 << ex.what() <<
".";
1360 long fetch_time =
static_cast<long>(ctl_info->getConfigFetchWaitTime());
1363 if (fetch_time > 0) {
1369 if (!server_->inTestMode()) {
1370 fetch_time = 1000 * fetch_time;
1373 boost::shared_ptr<unsigned> failure_count(
new unsigned(0));
1375 registerTimer(
"Dhcp4CBFetchTimer",
1376 std::bind(&ControlledDhcpv4Srv::cbFetchUpdates,
1390 if (notify_libraries) {
1391 return (notify_libraries);
1400 }
catch (
const std::exception& ex) {
1401 err <<
"Error initializing the lease allocators: "
1412 }
catch (
const std::exception& ex) {
1413 err <<
"Error applying multi threading settings: "
1432 callout_handle->setArgument(
"io_context", srv->
getIOService());
1434 callout_handle->setArgument(
"json_config",
config);
1435 callout_handle->setArgument(
"server_config",
CfgMgr::instance().getStagingCfg());
1444 callout_handle->getArgument(
"error",
error);
1446 error =
"unknown error";
1461 "Server object not initialized, can't process config.");
1472 uint16_t client_port )
1476 "There is another Dhcpv4Srv instance already.");
1499 std::bind(&ControlledDhcpv4Srv::commandBuildReportHandler,
this, ph::_1, ph::_2));
1502 std::bind(&ControlledDhcpv4Srv::commandConfigBackendPullHandler,
this, ph::_1, ph::_2));
1505 std::bind(&ControlledDhcpv4Srv::commandConfigGetHandler,
this, ph::_1, ph::_2));
1508 std::bind(&ControlledDhcpv4Srv::commandConfigHashGetHandler,
this, ph::_1, ph::_2));
1511 std::bind(&ControlledDhcpv4Srv::commandConfigReloadHandler,
this, ph::_1, ph::_2));
1514 std::bind(&ControlledDhcpv4Srv::commandConfigSetHandler,
this, ph::_1, ph::_2));
1517 std::bind(&ControlledDhcpv4Srv::commandConfigTestHandler,
this, ph::_1, ph::_2));
1520 std::bind(&ControlledDhcpv4Srv::commandConfigWriteHandler,
this, ph::_1, ph::_2));
1523 std::bind(&ControlledDhcpv4Srv::commandDhcpEnableHandler,
this, ph::_1, ph::_2));
1526 std::bind(&ControlledDhcpv4Srv::commandDhcpDisableHandler,
this, ph::_1, ph::_2));
1529 std::bind(&ControlledDhcpv4Srv::commandLfcStartHandler,
this, ph::_1, ph::_2));
1532 std::bind(&ControlledDhcpv4Srv::commandLeasesReclaimHandler,
this, ph::_1, ph::_2));
1535 std::bind(&ControlledDhcpv4Srv::commandSubnet4SelectTestHandler,
this, ph::_1, ph::_2));
1538 std::bind(&ControlledDhcpv4Srv::commandSubnet4o6SelectTestHandler,
this, ph::_1, ph::_2));
1541 std::bind(&ControlledDhcpv4Srv::commandServerTagGetHandler,
this, ph::_1, ph::_2));
1544 std::bind(&ControlledDhcpv4Srv::commandShutdownHandler,
this, ph::_1, ph::_2));
1547 std::bind(&ControlledDhcpv4Srv::commandStatusGetHandler,
this, ph::_1, ph::_2));
1550 std::bind(&ControlledDhcpv4Srv::commandVersionGetHandler,
this, ph::_1, ph::_2));
1578 std::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler,
this, ph::_1, ph::_2));
1584 std::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler,
this, ph::_1, ph::_2));
1605 timer_mgr_->unregisterTimers();
1656ControlledDhcpv4Srv::reclaimExpiredLeases(
const size_t max_leases,
1657 const uint16_t timeout,
1658 const bool remove_lease,
1659 const uint16_t max_unwarned_cycles) {
1662 server_->
alloc_engine_->reclaimExpiredLeases4(max_leases, timeout,
1664 max_unwarned_cycles);
1668 getCfgExpiration()->getReclaimTimerWaitTime());
1670 }
catch (
const std::exception& ex) {
1679ControlledDhcpv4Srv::deleteExpiredReclaimedLeases(
const uint32_t secs) {
1681 server_->alloc_engine_->deleteExpiredReclaimedLeases4(secs);
1689ControlledDhcpv4Srv::dbLostCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1690 if (!db_reconnect_ctl) {
1697 if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
1698 db_reconnect_ctl->alterServiceState()) {
1703 .arg(db_reconnect_ctl->id())
1704 .arg(db_reconnect_ctl->timerName());;
1708 if (!db_reconnect_ctl->retriesLeft() ||
1709 !db_reconnect_ctl->retryInterval()) {
1711 .arg(db_reconnect_ctl->retriesLeft())
1712 .arg(db_reconnect_ctl->retryInterval())
1713 .arg(db_reconnect_ctl->id())
1714 .arg(db_reconnect_ctl->timerName());
1715 if (db_reconnect_ctl->exitOnFailure()) {
1725ControlledDhcpv4Srv::dbRecoveredCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1726 if (!db_reconnect_ctl) {
1733 if (db_reconnect_ctl->retriesLeft() != db_reconnect_ctl->maxRetries() &&
1734 db_reconnect_ctl->alterServiceState()) {
1739 .arg(db_reconnect_ctl->id())
1740 .arg(db_reconnect_ctl->timerName());
1742 db_reconnect_ctl->resetRetries();
1748ControlledDhcpv4Srv::dbFailedCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1749 if (!db_reconnect_ctl) {
1756 .arg(db_reconnect_ctl->maxRetries())
1757 .arg(db_reconnect_ctl->id())
1758 .arg(db_reconnect_ctl->timerName());
1760 if (db_reconnect_ctl->exitOnFailure()) {
1768ControlledDhcpv4Srv::openSocketsFailedCallback(
ReconnectCtlPtr reconnect_ctl) {
1769 if (!reconnect_ctl) {
1776 .arg(reconnect_ctl->maxRetries());
1778 if (reconnect_ctl->exitOnFailure()) {
1784ControlledDhcpv4Srv::cbFetchUpdates(
const SrvConfigPtr& srv_cfg,
1785 boost::shared_ptr<unsigned> failure_count) {
1787 MultiThreadingCriticalSection cs;
1791 server_->getCBControl()->databaseConfigFetch(srv_cfg,
1792 CBControlDHCPv4::FetchMode::FETCH_UPDATE);
1793 (*failure_count) = 0;
1795 }
catch (
const std::exception& ex) {
1802 if (++(*failure_count) > 10) {
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
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.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
static IOServiceMgr & instance()
Access the IOServiceMgr singleton instance.
size_t pollIOServices()
Poll IOService objects.
Implements an asynchronous "signal" for IOService driven processing.
static void setIOService(isc::asiolink::IOServicePtr io_service)
Set the I/O service.
virtual isc::data::ConstElementPtr processCommand(const isc::data::ConstElementPtr &cmd)
Triggers command processing.
void registerCommand(const std::string &cmd, CommandHandler handler)
Registers specified command handler for a given command.
static std::string getHash(const isc::data::ConstElementPtr &config)
returns a hash of a given Element structure
void deregisterCommand(const std::string &cmd)
Deregisters specified command handler.
static CommandMgr & instance()
CommandMgr is a singleton class.
static std::string DEFAULT_AUTHENTICATION_REALM
Default HTTP authentication realm.
void closeCommandSockets()
Close http control sockets.
static HttpCommandMgr & instance()
HttpCommandMgr is a singleton class.
void setIOService(const asiolink::IOServicePtr &io_service)
Sets IO service to be used by the http command manager.
static UnixCommandMgr & instance()
UnixCommandMgr is a singleton class.
void setIOService(const asiolink::IOServicePtr &io_service)
Sets IO service to be used by the unix command manager.
void closeCommandSockets()
Shuts down any open unix control sockets.
static ElementPtr create(const Position &pos=ZERO_POSITION())
Create a NullElement.
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
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
void commit()
Commits the staging configuration.
void clearStagingConfiguration()
Remove staging configuration.
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
static void apply(data::ConstElementPtr value)
apply multi threading configuration
void insert(const ClientClass &class_name)
Insert an element.
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.
virtual void open()
Open communication socket.
void startD2()
Starts DHCP_DDNS client IO if DDNS updates are enabled.
Dhcpv4Srv(uint16_t server_port=DHCP4_SERVER_PORT, uint16_t client_port=0, const bool use_bcast=true, const bool direct_response_desired=true)
Default constructor.
void shutdown() override
Instructs the server to shut down.
asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service used by the server.
boost::shared_ptr< AllocEngine > alloc_engine_
Allocation Engine.
NetworkStatePtr & getNetworkState()
Returns pointer to the network state used by the server.
static std::string getVersion(bool extended)
returns Kea version on stdout and exit.
bool useBroadcast() const
Return bool value indicating that broadcast flags should be set on sockets.
NetworkStatePtr network_state_
Holds information about disabled DHCP service and/or disabled subnet/network scopes.
uint16_t getServerPort() const
Get UDP port on which server should listen.
static void create()
Creates new instance of the HostMgr.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
static TrackingLeaseMgr & instance()
Return current lease manager.
static void destroy()
Destroy lease manager.
static bool haveInstance()
Indicates if the lease manager has been instantiated.
virtual data::ElementPtr getStatus() const
Return status information.
static void commitRuntimeOptionDefs()
Commits runtime option definitions.
static bool isLFCProcessRunning(const std::string file_name, Universe u)
Check if LFC is running.
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 checkWriteConfigFile(std::string &file)
Checks the to-be-written configuration file name.
void setExitValue(int value)
Sets the exit value.
isc::data::ConstElementPtr redactConfig(isc::data::ConstElementPtr const &config)
Redact a configuration.
static StatsMgr & instance()
Statistics Manager accessor method.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
void apply(bool enabled, uint32_t thread_count, uint32_t queue_size)
Apply the multi-threading related settings.
This file contains several functions and constants that are used for handling commands and responses ...
Contains declarations for loggers used by the DHCPv4 server component.
Defines the Dhcp4o6Ipc class.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
isc::data::ConstElementPtr statisticSetMaxSampleCountAllHandler(const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-count-set-all command.
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 statisticGlobalGetAllHandler(const std::string &name, const isc::data::ConstElementPtr ¶ms)
Handles statistic-global-get-all command.
isc::data::ConstElementPtr statisticSetMaxSampleAgeAllHandler(const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-age-set-all 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.
uint32_t getMaxSampleCountDefault() const
Get default count limit.
const StatsDuration & getMaxSampleAgeDefault() const
Get default duration limit.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
#define LOG_FATAL(LOGGER, MESSAGE)
Macro to conveniently test fatal output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
Parses a standard config/command level answer and returns arguments or text status code.
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(const int status_code, const std::string &text, const ConstElementPtr &arg)
Creates a standard config/command level answer message.
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
const int CONTROL_RESULT_COMMAND_UNSUPPORTED
Status code indicating that the specified command is not supported.
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 int DBG_DHCP4_BASIC
Debug level used to trace basic operations within the code.
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
const isc::log::MessageID DHCP4_RECLAIM_EXPIRED_LEASES_SKIPPED
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.
PerfMonMgrPtr mgr
PerfMonMgr singleton.
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.
asiolink::IOAddress local_address_
Address on which the message was received.
bool dhcp4o6_
Specifies if the packet is DHCP4o6.
asiolink::IOAddress option_select_
RAI link select or subnet select option.
std::string iface_name_
Name of the interface on which the message was received.
asiolink::IOAddress ciaddr_
ciaddr from the client's message.
ClientClasses client_classes_
Classes that the client belongs to.
asiolink::IOAddress remote_address_
Source address of the message.
OptionPtr interface_id_
Interface id option.
asiolink::IOAddress first_relay_linkaddr_
First relay link address.
asiolink::IOAddress giaddr_
giaddr from the client's message.