43namespace ph = std::placeholders;
48struct CtrlDhcp4Hooks {
49 int hooks_index_dhcp4_srv_configured_;
53 hooks_index_dhcp4_srv_configured_ = HooksManager::registerHook(
"dhcp4_srv_configured");
73void signalHandler(
int signo) {
75 if (signo == SIGHUP) {
76 ControlledDhcpv4Srv::processCommand(
"config-reload",
78 }
else if ((signo == SIGTERM) || (signo == SIGINT)) {
79 ControlledDhcpv4Srv::processCommand(
"shutdown",
94 start_ = boost::posix_time::second_clock::universal_time();
102 string reason = comment ? comment->stringValue() :
103 "no details available";
135 if (file_name.empty()) {
138 " Please use -c command line option.");
152 "a map, i.e., start with { and end with } and contain "
153 "at least an entry called 'Dhcp4' that itself is a map. "
155 <<
" is a valid JSON, but its top element is not a map."
156 " Did you forget to add { } around your configuration?");
166 "processCommand(\"config-set\", json)");
174 string reason = comment ? comment->stringValue() :
175 "no details available";
178 }
catch (
const std::exception& ex) {
184 .arg(file_name).arg(ex.what());
186 << file_name <<
"': " << ex.
what());
190 .arg(MultiThreadingMgr::instance().getMode() ?
"yes" :
"no")
191 .arg(MultiThreadingMgr::instance().getThreadPoolSize())
192 .arg(MultiThreadingMgr::instance().getPacketQueueSize());
198ControlledDhcpv4Srv::commandShutdownHandler(
const string&,
ConstElementPtr args) {
215 "parameter 'exit-value' is not an integer"));
218 exit_value = param->intValue();
227ControlledDhcpv4Srv::commandLibReloadHandler(
const string&,
ConstElementPtr) {
232 MultiThreadingMgr::instance().getThreadPool().reset();
237 HooksManager::prepareUnloadLibraries();
238 static_cast<void>(HooksManager::unloadLibraries());
239 bool status = HooksManager::loadLibraries(loaded);
241 isc_throw(Unexpected,
"Failed to reload hooks libraries.");
243 }
catch (
const std::exception& ex) {
249 "Hooks libraries successfully reloaded.");
254ControlledDhcpv4Srv::commandConfigReloadHandler(
const string&,
263 }
catch (
const std::exception& ex) {
270 "Config reload failed: " +
string(ex.what())));
275ControlledDhcpv4Srv::commandConfigGetHandler(
const string&,
283ControlledDhcpv4Srv::commandConfigWriteHandler(
const string&,
292 if (filename_param) {
295 "passed parameter 'filename' is not a string"));
297 filename = filename_param->stringValue();
301 if (filename.empty()) {
307 if (filename.empty()) {
309 "Please specify filename explicitly."));
332 + filename +
" successful", params));
336ControlledDhcpv4Srv::commandConfigSetHandler(
const string&,
345 message =
"Missing mandatory 'arguments' parameter.";
347 dhcp4 = args->get(
"Dhcp4");
349 message =
"Missing mandatory 'Dhcp4' parameter.";
351 message =
"'Dhcp4' parameter expected to be a map.";
356 if (message.empty()) {
357 for (
auto obj : args->mapValue()) {
358 const string& obj_name = obj.first;
359 if (obj_name !=
"Dhcp4") {
362 if (message.empty()) {
363 message =
"Unsupported '" + obj_name +
"' parameter";
365 message +=
" (and '" + obj_name +
"')";
369 if (!message.empty()) {
374 if (!message.empty()) {
387 MultiThreadingMgr::instance().apply(
false, 0, 0);
435ControlledDhcpv4Srv::commandConfigTestHandler(
const string&,
444 message =
"Missing mandatory 'arguments' parameter.";
446 dhcp4 = args->get(
"Dhcp4");
448 message =
"Missing mandatory 'Dhcp4' parameter.";
450 message =
"'Dhcp4' parameter expected to be a map.";
455 if (message.empty()) {
456 for (
auto obj : args->mapValue()) {
457 const string& obj_name = obj.first;
458 if (obj_name !=
"Dhcp4") {
461 if (message.empty()) {
462 message =
"Unsupported '" + obj_name +
"' parameter";
464 message +=
" (and '" + obj_name +
"')";
468 if (!message.empty()) {
473 if (!message.empty()) {
493ControlledDhcpv4Srv::commandDhcpDisableHandler(
const std::string&,
495 std::ostringstream message;
496 int64_t max_period = 0;
508 message <<
"arguments for the 'dhcp-disable' command must be a map";
513 if (max_period_element) {
516 message <<
"'max-period' argument must be a number";
520 max_period = max_period_element->intValue();
521 if (max_period <= 0) {
522 message <<
"'max-period' must be positive integer";
528 if (origin_element) {
531 message <<
"'origin' argument must be a string";
534 origin = origin_element->stringValue();
535 if (origin ==
"ha-partner") {
537 }
else if (origin !=
"user") {
538 if (origin.empty()) {
539 origin =
"(empty string)";
541 message <<
"invalid value used for 'origin' parameter: "
550 if (message.tellp() == 0) {
551 message <<
"DHCPv4 service disabled";
552 if (max_period > 0) {
553 message <<
" for " << max_period <<
" seconds";
558 network_state_->delayedEnableAll(
static_cast<unsigned>(max_period),
572ControlledDhcpv4Srv::commandDhcpEnableHandler(
const std::string&,
574 std::ostringstream message;
585 message <<
"arguments for the 'dhcp-enable' command must be a map";
590 if (origin_element) {
593 message <<
"'origin' argument must be a string";
596 origin = origin_element->stringValue();
597 if (origin ==
"ha-partner") {
599 }
else if (origin !=
"user") {
600 if (origin.empty()) {
601 origin =
"(empty string)";
603 message <<
"invalid value used for 'origin' parameter: "
612 if (message.tellp() == 0) {
617 "DHCP service successfully enabled"));
625ControlledDhcpv4Srv::commandVersionGetHandler(
const string&,
ConstElementPtr) {
628 arguments->set(
"extended", extended);
636ControlledDhcpv4Srv::commandBuildReportHandler(
const string&,
644ControlledDhcpv4Srv::commandLeasesReclaimHandler(
const string&,
651 message =
"Missing mandatory 'remove' parameter.";
655 message =
"Missing mandatory 'remove' parameter.";
657 message =
"'remove' parameter expected to be a boolean.";
659 bool remove_lease = remove_name->boolValue();
660 server_->
alloc_engine_->reclaimExpiredLeases4(0, 0, remove_lease);
662 message =
"Reclamation of expired leases is complete.";
670ControlledDhcpv4Srv::commandServerTagGetHandler(
const std::string&,
672 const std::string& tag =
681ControlledDhcpv4Srv::commandConfigBackendPullHandler(
const std::string&,
702 auto mode = CBControlDHCPv4::FetchMode::FETCH_UPDATE;
703 server_->
getCBControl()->databaseConfigFetch(srv_cfg, mode);
704 }
catch (
const std::exception& ex) {
708 "On demand configuration update failed: " +
712 "On demand configuration update successful."));
716ControlledDhcpv4Srv::commandStatusGetHandler(
const string&,
721 auto now = boost::posix_time::second_clock::universal_time();
723 if (!
start_.is_not_a_date_time()) {
724 auto uptime = now -
start_;
729 if (!last_commit.is_not_a_date_time()) {
730 auto reload = now - last_commit;
734 auto& mt_mgr = MultiThreadingMgr::instance();
735 if (mt_mgr.getMode()) {
738 MultiThreadingMgr::instance().getThreadPoolSize())));
740 MultiThreadingMgr::instance().getPacketQueueSize())));
742 queue_stats->add(
Element::create(mt_mgr.getThreadPool().getQueueStat(10)));
743 queue_stats->add(
Element::create(mt_mgr.getThreadPool().getQueueStat(100)));
744 queue_stats->add(
Element::create(mt_mgr.getThreadPool().getQueueStat(1000)));
745 status->set(
"packet-queue-statistics", queue_stats);
754 for (std::string
const&
error : interface->getErrors()) {
761 if (socket_errors->empty()) {
766 if (reconnect_ctl && reconnect_ctl->retriesLeft()) {
771 sockets->set(
"errors", socket_errors);
773 status->set(
"sockets", sockets);
779ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler(
const string&,
781 StatsMgr& stats_mgr = StatsMgr::instance();
791ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler(
const string&,
793 StatsMgr& stats_mgr = StatsMgr::instance();
806 string txt = args ? args->str() :
"(none)";
809 .arg(command).arg(txt);
815 "Server object not initialized, so can't process command '" +
816 command +
"', arguments: '" + txt +
"'.");
821 if (command ==
"shutdown") {
822 return (srv->commandShutdownHandler(command, args));
824 }
else if (command ==
"libreload") {
825 return (srv->commandLibReloadHandler(command, args));
827 }
else if (command ==
"config-reload") {
828 return (srv->commandConfigReloadHandler(command, args));
830 }
else if (command ==
"config-set") {
831 return (srv->commandConfigSetHandler(command, args));
833 }
else if (command ==
"config-get") {
834 return (srv->commandConfigGetHandler(command, args));
836 }
else if (command ==
"config-test") {
837 return (srv->commandConfigTestHandler(command, args));
839 }
else if (command ==
"dhcp-disable") {
840 return (srv->commandDhcpDisableHandler(command, args));
842 }
else if (command ==
"dhcp-enable") {
843 return (srv->commandDhcpEnableHandler(command, args));
845 }
else if (command ==
"version-get") {
846 return (srv->commandVersionGetHandler(command, args));
848 }
else if (command ==
"build-report") {
849 return (srv->commandBuildReportHandler(command, args));
851 }
else if (command ==
"leases-reclaim") {
852 return (srv->commandLeasesReclaimHandler(command, args));
854 }
else if (command ==
"config-write") {
855 return (srv->commandConfigWriteHandler(command, args));
857 }
else if (command ==
"server-tag-get") {
858 return (srv->commandServerTagGetHandler(command, args));
860 }
else if (command ==
"config-backend-pull") {
861 return (srv->commandConfigBackendPullHandler(command, args));
863 }
else if (command ==
"status-get") {
864 return (srv->commandStatusGetHandler(command, args));
872 + command +
"':" + ex.
what() +
873 ", params: '" + txt +
"'"));
882 std::ostringstream err;
885 err <<
"Server object not initialized, can't process config.";
902 }
catch (
const std::exception& ex) {
903 err <<
"Failed to process configuration:" << ex.what();
910 std::bind(&ControlledDhcpv4Srv::dbLostCallback, srv, ph::_1);
913 std::bind(&ControlledDhcpv4Srv::dbRecoveredCallback, srv, ph::_1);
916 std::bind(&ControlledDhcpv4Srv::dbFailedCallback, srv, ph::_1);
919 cfg_db->setAppendedParameters(
"universe=4");
920 cfg_db->createManagers();
923 }
catch (
const std::exception& ex) {
924 err <<
"Unable to open database: " << ex.what();
931 }
catch (
const std::exception& ex) {
932 err <<
"Error starting DHCP_DDNS client after server reconfiguration: "
940 }
catch (
const std::exception& ex) {
941 err <<
"error starting DHCPv4-over-DHCPv6 IPC "
942 " after server reconfiguration: " << ex.what();
955 }
catch (
const std::exception& ex) {
956 err <<
"Error setting packet queue controls after server reconfiguration: "
964 std::bind(&ControlledDhcpv4Srv::openSocketsFailedCallback, srv, ph::_1);
980 setupTimers(&ControlledDhcpv4Srv::reclaimExpiredLeases,
981 &ControlledDhcpv4Srv::deleteExpiredReclaimedLeases,
984 }
catch (
const std::exception& ex) {
985 err <<
"unable to setup timers for periodically running the"
986 " reclamation of the expired leases: "
994 long fetch_time =
static_cast<long>(ctl_info->getConfigFetchWaitTime());
997 if (fetch_time > 0) {
1004 fetch_time = 1000 * fetch_time;
1007 boost::shared_ptr<unsigned> failure_count(
new unsigned(0));
1009 registerTimer(
"Dhcp4CBFetchTimer",
1010 std::bind(&ControlledDhcpv4Srv::cbFetchUpdates,
1028 if (HooksManager::calloutsPresent(
Hooks.hooks_index_dhcp4_srv_configured_)) {
1031 callout_handle->setArgument(
"io_context", srv->
getIOService());
1033 callout_handle->setArgument(
"json_config", config);
1034 callout_handle->setArgument(
"server_config",
CfgMgr::instance().getStagingCfg());
1036 HooksManager::callCallouts(
Hooks.hooks_index_dhcp4_srv_configured_,
1040 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
1043 callout_handle->getArgument(
"error",
error);
1045 error =
"unknown error";
1057 }
catch (
const std::exception& ex) {
1058 err <<
"Error applying multi threading settings: "
1075 std::ostringstream err;
1078 err <<
"Server object not initialized, can't process config.";
1086 uint16_t client_port )
1090 "There is another Dhcpv4Srv instance already.");
1108 CommandMgr::instance().registerCommand(
"build-report",
1109 std::bind(&ControlledDhcpv4Srv::commandBuildReportHandler,
this, ph::_1, ph::_2));
1111 CommandMgr::instance().registerCommand(
"config-backend-pull",
1112 std::bind(&ControlledDhcpv4Srv::commandConfigBackendPullHandler,
this, ph::_1, ph::_2));
1114 CommandMgr::instance().registerCommand(
"config-get",
1115 std::bind(&ControlledDhcpv4Srv::commandConfigGetHandler,
this, ph::_1, ph::_2));
1117 CommandMgr::instance().registerCommand(
"config-reload",
1118 std::bind(&ControlledDhcpv4Srv::commandConfigReloadHandler,
this, ph::_1, ph::_2));
1120 CommandMgr::instance().registerCommand(
"config-set",
1121 std::bind(&ControlledDhcpv4Srv::commandConfigSetHandler,
this, ph::_1, ph::_2));
1123 CommandMgr::instance().registerCommand(
"config-test",
1124 std::bind(&ControlledDhcpv4Srv::commandConfigTestHandler,
this, ph::_1, ph::_2));
1126 CommandMgr::instance().registerCommand(
"config-write",
1127 std::bind(&ControlledDhcpv4Srv::commandConfigWriteHandler,
this, ph::_1, ph::_2));
1129 CommandMgr::instance().registerCommand(
"dhcp-enable",
1130 std::bind(&ControlledDhcpv4Srv::commandDhcpEnableHandler,
this, ph::_1, ph::_2));
1132 CommandMgr::instance().registerCommand(
"dhcp-disable",
1133 std::bind(&ControlledDhcpv4Srv::commandDhcpDisableHandler,
this, ph::_1, ph::_2));
1135 CommandMgr::instance().registerCommand(
"libreload",
1136 std::bind(&ControlledDhcpv4Srv::commandLibReloadHandler,
this, ph::_1, ph::_2));
1138 CommandMgr::instance().registerCommand(
"leases-reclaim",
1139 std::bind(&ControlledDhcpv4Srv::commandLeasesReclaimHandler,
this, ph::_1, ph::_2));
1141 CommandMgr::instance().registerCommand(
"server-tag-get",
1142 std::bind(&ControlledDhcpv4Srv::commandServerTagGetHandler,
this, ph::_1, ph::_2));
1144 CommandMgr::instance().registerCommand(
"shutdown",
1145 std::bind(&ControlledDhcpv4Srv::commandShutdownHandler,
this, ph::_1, ph::_2));
1147 CommandMgr::instance().registerCommand(
"status-get",
1148 std::bind(&ControlledDhcpv4Srv::commandStatusGetHandler,
this, ph::_1, ph::_2));
1150 CommandMgr::instance().registerCommand(
"version-get",
1151 std::bind(&ControlledDhcpv4Srv::commandVersionGetHandler,
this, ph::_1, ph::_2));
1154 CommandMgr::instance().registerCommand(
"statistic-get",
1155 std::bind(&StatsMgr::statisticGetHandler, ph::_1, ph::_2));
1157 CommandMgr::instance().registerCommand(
"statistic-reset",
1158 std::bind(&StatsMgr::statisticResetHandler, ph::_1, ph::_2));
1160 CommandMgr::instance().registerCommand(
"statistic-remove",
1161 std::bind(&StatsMgr::statisticRemoveHandler, ph::_1, ph::_2));
1163 CommandMgr::instance().registerCommand(
"statistic-get-all",
1164 std::bind(&StatsMgr::statisticGetAllHandler, ph::_1, ph::_2));
1166 CommandMgr::instance().registerCommand(
"statistic-reset-all",
1167 std::bind(&StatsMgr::statisticResetAllHandler, ph::_1, ph::_2));
1169 CommandMgr::instance().registerCommand(
"statistic-remove-all",
1170 std::bind(&StatsMgr::statisticRemoveAllHandler, ph::_1, ph::_2));
1172 CommandMgr::instance().registerCommand(
"statistic-sample-age-set",
1173 std::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, ph::_1, ph::_2));
1175 CommandMgr::instance().registerCommand(
"statistic-sample-age-set-all",
1176 std::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler,
this, ph::_1, ph::_2));
1178 CommandMgr::instance().registerCommand(
"statistic-sample-count-set",
1179 std::bind(&StatsMgr::statisticSetMaxSampleCountHandler, ph::_1, ph::_2));
1181 CommandMgr::instance().registerCommand(
"statistic-sample-count-set-all",
1182 std::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler,
this, ph::_1, ph::_2));
1203 timer_mgr_->unregisterTimers();
1206 CommandMgr::instance().closeCommandSocket();
1209 CommandMgr::instance().deregisterCommand(
"build-report");
1210 CommandMgr::instance().deregisterCommand(
"config-backend-pull");
1211 CommandMgr::instance().deregisterCommand(
"config-get");
1212 CommandMgr::instance().deregisterCommand(
"config-reload");
1213 CommandMgr::instance().deregisterCommand(
"config-set");
1214 CommandMgr::instance().deregisterCommand(
"config-test");
1215 CommandMgr::instance().deregisterCommand(
"config-write");
1216 CommandMgr::instance().deregisterCommand(
"dhcp-disable");
1217 CommandMgr::instance().deregisterCommand(
"dhcp-enable");
1218 CommandMgr::instance().deregisterCommand(
"leases-reclaim");
1219 CommandMgr::instance().deregisterCommand(
"libreload");
1220 CommandMgr::instance().deregisterCommand(
"server-tag-get");
1221 CommandMgr::instance().deregisterCommand(
"shutdown");
1222 CommandMgr::instance().deregisterCommand(
"statistic-get");
1223 CommandMgr::instance().deregisterCommand(
"statistic-get-all");
1224 CommandMgr::instance().deregisterCommand(
"statistic-remove");
1225 CommandMgr::instance().deregisterCommand(
"statistic-remove-all");
1226 CommandMgr::instance().deregisterCommand(
"statistic-reset");
1227 CommandMgr::instance().deregisterCommand(
"statistic-reset-all");
1228 CommandMgr::instance().deregisterCommand(
"statistic-sample-age-set");
1229 CommandMgr::instance().deregisterCommand(
"statistic-sample-age-set-all");
1230 CommandMgr::instance().deregisterCommand(
"statistic-sample-count-set");
1231 CommandMgr::instance().deregisterCommand(
"statistic-sample-count-set-all");
1232 CommandMgr::instance().deregisterCommand(
"status-get");
1233 CommandMgr::instance().deregisterCommand(
"version-get");
1251ControlledDhcpv4Srv::reclaimExpiredLeases(
const size_t max_leases,
1252 const uint16_t timeout,
1253 const bool remove_lease,
1254 const uint16_t max_unwarned_cycles) {
1256 server_->
alloc_engine_->reclaimExpiredLeases4(max_leases, timeout,
1258 max_unwarned_cycles);
1259 }
catch (
const std::exception& ex) {
1268ControlledDhcpv4Srv::deleteExpiredReclaimedLeases(
const uint32_t secs) {
1269 server_->
alloc_engine_->deleteExpiredReclaimedLeases4(secs);
1275ControlledDhcpv4Srv::dbLostCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1276 if (!db_reconnect_ctl) {
1283 if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
1284 db_reconnect_ctl->alterServiceState()) {
1292 if (!db_reconnect_ctl->retriesLeft() ||
1293 !db_reconnect_ctl->retryInterval()) {
1295 .arg(db_reconnect_ctl->retriesLeft())
1296 .arg(db_reconnect_ctl->retryInterval());
1297 if (db_reconnect_ctl->exitOnFailure()) {
1307ControlledDhcpv4Srv::dbRecoveredCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1308 if (!db_reconnect_ctl) {
1315 if (db_reconnect_ctl->alterServiceState()) {
1321 db_reconnect_ctl->resetRetries();
1327ControlledDhcpv4Srv::dbFailedCallback(
ReconnectCtlPtr db_reconnect_ctl) {
1328 if (!db_reconnect_ctl) {
1335 .arg(db_reconnect_ctl->maxRetries());
1337 if (db_reconnect_ctl->exitOnFailure()) {
1345ControlledDhcpv4Srv::openSocketsFailedCallback(
ReconnectCtlPtr reconnect_ctl) {
1346 if (!reconnect_ctl) {
1353 .arg(reconnect_ctl->maxRetries());
1355 if (reconnect_ctl->exitOnFailure()) {
1361ControlledDhcpv4Srv::cbFetchUpdates(
const SrvConfigPtr& srv_cfg,
1362 boost::shared_ptr<unsigned> failure_count) {
1369 CBControlDHCPv4::FetchMode::FETCH_UPDATE);
1370 (*failure_count) = 0;
1372 }
catch (
const std::exception& ex) {
1379 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.
Implements an asynchronous "signal" for IOService driven processing.
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 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.
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.
void rollback()
Removes staging configuration.
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.
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
static void apply(data::ConstElementPtr value)
apply multi threading configuration
Controlled version of the DHCPv4 server.
static isc::data::ConstElementPtr processConfig(isc::data::ConstElementPtr new_config)
Configuration processor.
virtual ~ControlledDhcpv4Srv()
Destructor.
isc::data::ConstElementPtr loadConfigFile(const std::string &file_name)
Configure DHCPv4 server using the configuration file specified.
void cleanup()
Performs cleanup, immediately before termination.
static isc::data::ConstElementPtr processCommand(const std::string &command, isc::data::ConstElementPtr args)
Command processor.
ControlledDhcpv4Srv(uint16_t server_port=DHCP4_SERVER_PORT, uint16_t client_port=0)
Constructor.
void init(const std::string &config_file)
Initializes the server.
static ControlledDhcpv4Srv * getInstance()
Returns pointer to the sole instance of Dhcpv4Srv.
void shutdownServer(int exit_value)
Initiates shutdown procedure for the whole DHCPv4 server.
isc::data::ConstElementPtr checkConfig(isc::data::ConstElementPtr new_config)
Configuration checker.
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.
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.
bool inTestMode() const
Checks if the server is running in unit test mode.
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.
CBControlDHCPv4Ptr getCBControl() const
Returns an object which controls access to the configuration backends.
static void setIOService(const isc::asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Host Manager.
static void create()
Creates new instance of the HostMgr.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
static void destroy()
Destroy lease manager.
static void setIOService(const isc::asiolink::IOServicePtr &io_service)
Sets IO service to be used by the Lease Manager.
static void commitRuntimeOptionDefs()
Commits runtime option definitions.
Origin
Origin of the network state transition.
@ USER_COMMAND
The network state is being altered by a user command.
@ DB_CONNECTION
The network state is being altered by the DB connection recovery mechanics.
@ HA_COMMAND
The network state is being altered by a HA internal command.
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.
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.
isc::data::ConstElementPtr redactConfig(isc::data::ConstElementPtr const &config)
Redact a configuration.
Statistics Manager class.
RAII class creating a critical section.
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.
isc::data::ConstElementPtr statisticSetMaxSampleAgeAllHandler(const isc::data::ConstElementPtr ¶ms)
Handles statistic-sample-age-set-all 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 ...
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
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< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
boost::shared_ptr< Iface > IfacePtr
Type definition for the pointer to an Iface object.
isc::data::ConstElementPtr configureDhcp4Server(Dhcpv4Srv &server, isc::data::ConstElementPtr config_set, bool check_only)
Configure DHCPv4 server (Dhcpv4Srv) with a set of configuration values.
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_HOOKS_LIBS_RELOAD_FAIL
const isc::log::MessageID DHCP4_DB_RECONNECT_DISABLED
const isc::log::MessageID DHCP4_CONFIG_UNRECOVERABLE_ERROR
const isc::log::MessageID DHCP4_DB_RECONNECT_SUCCEEDED
const isc::log::MessageID DHCP4_COMMAND_RECEIVED
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.
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
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
std::vector< HookLibInfo > HookLibsCollection
A storage for information about hook libraries.
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.
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
Defines the logger used by the top-level component of kea-lfc.