Kea 3.2.0-git
ctrl_dhcp6_srv.cc
Go to the documentation of this file.
1// Copyright (C) 2014-2026 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
12#include <cc/data.h>
13#include <config/command_mgr.h>
18#include <dhcp/libdhcp++.h>
20#include <dhcp6/dhcp6_log.h>
21#include <dhcp6/dhcp6to4_ipc.h>
26#include <dhcpsrv/cfgmgr.h>
27#include <dhcpsrv/db_type.h>
28#include <dhcpsrv/host_mgr.h>
32#include <hooks/hooks.h>
33#include <hooks/hooks_manager.h>
35#include <stats/stats_mgr.h>
36#include <util/encode/encode.h>
38
39#include <signal.h>
40
41#include <sstream>
42
43using namespace isc::asiolink;
44using namespace isc::config;
45using namespace isc::data;
46using namespace isc::db;
47using namespace isc::dhcp;
48using namespace isc::hooks;
49using namespace isc::stats;
50using namespace isc::util;
51using namespace std;
52namespace ph = std::placeholders;
53
54namespace {
55
57struct CtrlDhcp6Hooks {
58 int hooks_index_dhcp6_srv_configured_;
59
61 CtrlDhcp6Hooks() {
62 hooks_index_dhcp6_srv_configured_ = HooksManager::registerHook("dhcp6_srv_configured");
63 }
64
65};
66
67// Declare a Hooks object. As this is outside any function or method, it
68// will be instantiated (and the constructor run) when the module is loaded.
69// As a result, the hook indexes will be defined before any method in this
70// module is called.
71CtrlDhcp6Hooks Hooks;
72
73// Name of the file holding server identifier.
74static const char* SERVER_DUID_FILE = "kea-dhcp6-serverid";
75
85void signalHandler(int signo) {
86 // SIGHUP signals a request to reconfigure the server.
87 if (signo == SIGHUP) {
89 } else if ((signo == SIGTERM) || (signo == SIGINT)) {
91 }
92}
93
94}
95
96namespace isc {
97namespace dhcp {
98
99ControlledDhcpv6Srv* ControlledDhcpv6Srv::server_ = 0;
100
101void
102ControlledDhcpv6Srv::init(const std::string& file_name) {
103 // Keep the call timestamp.
104 start_ = boost::posix_time::second_clock::universal_time();
105
106 // Configure the server using JSON file.
107 ConstElementPtr result = loadConfigFile(file_name);
108
109 int rcode;
110 ConstElementPtr comment = isc::config::parseAnswer(rcode, result);
111 if (rcode != CONTROL_RESULT_SUCCESS) {
112 string reason = comment ? comment->stringValue() :
113 "no details available";
114 isc_throw(isc::BadValue, reason);
115 }
116
117 // Set signal handlers. When the SIGHUP is received by the process
118 // the server reconfiguration will be triggered. When SIGTERM or
119 // SIGINT will be received, the server will start shutting down.
120 signal_set_.reset(new IOSignalSet(getIOService(), signalHandler));
121
122 signal_set_->add(SIGINT);
123 signal_set_->add(SIGHUP);
124 signal_set_->add(SIGTERM);
125}
126
128 signal_set_.reset();
129 getIOService()->stopAndPoll();
130}
131
133ControlledDhcpv6Srv::loadConfigFile(const std::string& file_name) {
134 // This is a configuration backend implementation that reads the
135 // configuration from a JSON file.
136
139
140 // Basic sanity check: file name must not be empty.
141 try {
142 if (file_name.empty()) {
143 // Basic sanity check: file name must not be empty.
144 isc_throw(isc::BadValue, "JSON configuration file not specified."
145 " Please use -c command line option.");
146 }
147
148 // Read contents of the file and parse it as JSON
149 Parser6Context parser;
150 json = parser.parseFile(file_name, Parser6Context::PARSER_DHCP6);
151 if (!json) {
152 isc_throw(isc::BadValue, "no configuration found");
153 }
154
155 // Let's do sanity check before we call json->get() which
156 // works only for map.
157 if (json->getType() != isc::data::Element::map) {
158 isc_throw(isc::BadValue, "Configuration file is expected to be "
159 "a map, i.e., start with { and end with } and contain "
160 "at least an entry called 'Dhcp6' that itself is a map. "
161 << file_name
162 << " is a valid JSON, but its top element is not a map."
163 " Did you forget to add { } around your configuration?");
164 }
165
166 // Use parsed JSON structures to configure the server
167 result = CommandMgr::instance().processCommand(createCommand("config-set", json));
168 if (!result) {
169 // Undetermined status of the configuration. This should never
170 // happen, but as the configureDhcp6Server returns a pointer, it is
171 // theoretically possible that it will return NULL.
172 isc_throw(isc::BadValue, "undefined result of "
173 "process command \"config-set\"");
174 }
175
176 // Now check is the returned result is successful (rcode=0) or not
177 // (see @ref isc::config::parseAnswer).
178 int rcode;
179 ConstElementPtr comment = isc::config::parseAnswer(rcode, result);
180 if (rcode != CONTROL_RESULT_SUCCESS) {
181 string reason = comment ? comment->stringValue() :
182 "no details available";
183 isc_throw(isc::BadValue, reason);
184 }
185 } catch (const std::exception& ex) {
186 // If configuration failed at any stage, we drop the staging
187 // configuration and continue to use the previous one.
189
191 .arg(file_name).arg(ex.what());
192 isc_throw(isc::BadValue, "configuration error using file '"
193 << file_name << "': " << ex.what());
194 }
195
197 .arg(MultiThreadingMgr::instance().getMode() ? "yes" : "no")
198 .arg(MultiThreadingMgr::instance().getThreadPoolSize())
199 .arg(MultiThreadingMgr::instance().getPacketQueueSize());
200
201 return (result);
202}
203
204bool
208
213 return (createAnswer(CONTROL_RESULT_ERROR, "Shutdown failure."));
214 }
215
216 int exit_value = 0;
217 if (args) {
218 // @todo Should we go ahead and shutdown even if the args are invalid?
219 if (args->getType() != Element::map) {
220 return (createAnswer(CONTROL_RESULT_ERROR, "Argument must be a map"));
221 }
222
223 ConstElementPtr param = args->get("exit-value");
224 if (param) {
225 if (param->getType() != Element::integer) {
227 "parameter 'exit-value' is not an integer"));
228 }
229
230 exit_value = param->intValue();
231 }
232 }
233
235 return (createAnswer(CONTROL_RESULT_SUCCESS, "Shutting down."));
236}
237
240 ConstElementPtr /*args*/) {
241 if (!IfaceMgr::instance().isMainThread()) {
243 "Illegal operation executing 'config-reload' on a different thread than main thread"));
244 }
245 // Get configuration file name.
247 try {
249 auto result = loadConfigFile(file);
251 return (result);
252 } catch (const std::exception& ex) {
253 // Log the unsuccessful reconfiguration. The reason for failure
254 // should be already logged. Don't rethrow an exception so as
255 // the server keeps working.
257 .arg(file);
259 "Config reload failed: " + string(ex.what())));
260 }
261}
262
265 ConstElementPtr /*args*/) {
267 string hash = BaseCommandMgr::getHash(config);
268 config->set("hash", Element::create(hash));
269
271}
272
275 ConstElementPtr /*args*/) {
277
278 string hash = BaseCommandMgr::getHash(config);
279
281 params->set("hash", Element::create(hash));
282 return (createAnswer(CONTROL_RESULT_SUCCESS, params));
283}
284
287 ConstElementPtr args) {
288 string filename;
289
290 if (args) {
291 if (args->getType() != Element::map) {
292 return (createAnswer(CONTROL_RESULT_ERROR, "Argument must be a map"));
293 }
294 ConstElementPtr filename_param = args->get("filename");
295 if (filename_param) {
296 if (filename_param->getType() != Element::string) {
298 "passed parameter 'filename' is not a string"));
299 }
300 filename = filename_param->stringValue();
301 }
302 }
303
304 if (filename.empty()) {
305 // filename parameter was not specified, so let's use whatever we remember
306 // from the command-line
307 filename = getConfigFile();
308 if (filename.empty()) {
309 return (createAnswer(CONTROL_RESULT_ERROR, "Unable to determine filename."
310 "Please specify filename explicitly."));
311 }
312 } else {
313 try {
314 checkWriteConfigFile(filename);
315 } catch (const isc::Exception& ex) {
316 std::ostringstream msg;
317 msg << "not allowed to write config into " << filename
318 << ": " << ex.what();
319 return (createAnswer(CONTROL_RESULT_ERROR, msg.str()));
320 }
321 }
322
323 // Ok, it's time to write the file.
324 size_t size = 0;
325 try {
326 ConstElementPtr cfg = CfgMgr::instance().getCurrentCfg()->toElement();
327 size = writeConfigFile(filename, cfg);
328 } catch (const isc::Exception& ex) {
329 return (createAnswer(CONTROL_RESULT_ERROR, string("Error during config-write: ")
330 + ex.what()));
331 }
332 if (size == 0) {
333 return (createAnswer(CONTROL_RESULT_ERROR, "Error writing configuration to "
334 + filename));
335 }
336
337 // Ok, it's time to return the successful response.
339 params->set("size", Element::create(static_cast<long long>(size)));
340 params->set("filename", Element::create(filename));
341
342 return (createAnswer(CONTROL_RESULT_SUCCESS, "Configuration written to "
343 + filename + " successful", params));
344}
345
348 ConstElementPtr args) {
349 if (!IfaceMgr::instance().isMainThread()) {
351 "Illegal operation executing 'config-set' on a different thread than main thread"));
352 }
353 const int status_code = CONTROL_RESULT_ERROR;
354 ConstElementPtr dhcp6;
355 string message;
356
357 // Command arguments are expected to be:
358 // { "Dhcp6": { ... } }
359 if (!args) {
360 message = "Missing mandatory 'arguments' parameter.";
361 } else {
362 dhcp6 = args->get("Dhcp6");
363 if (!dhcp6) {
364 message = "Missing mandatory 'Dhcp6' parameter.";
365 } else if (dhcp6->getType() != Element::map) {
366 message = "'Dhcp6' parameter expected to be a map.";
367 }
368 }
369
370 // Check unsupported objects.
371 if (message.empty()) {
372 for (auto const& obj : args->mapValue()) {
373 const string& obj_name = obj.first;
374 if (obj_name != "Dhcp6") {
376 .arg(obj_name);
377 if (message.empty()) {
378 message = "Unsupported '" + obj_name + "' parameter";
379 } else {
380 message += " (and '" + obj_name + "')";
381 }
382 }
383 }
384 if (!message.empty()) {
385 message += ".";
386 }
387 }
388
389 if (!message.empty()) {
390 // Something is amiss with arguments, return a failure response.
391 ConstElementPtr result = isc::config::createAnswer(status_code,
392 message);
393 return (result);
394 }
395
397 (LeaseMgrFactory::instance().getType() == "memfile")) {
399 auto file_name = mgr.getLeaseFilePath(Memfile_LeaseMgr::V6);
402 "Can not update configuration while lease file cleanup process is running."));
403 }
404 }
405
406 // stop thread pool (if running)
408
409 // We are starting the configuration process so we should remove any
410 // staging configuration that has been created during previous
411 // configuration attempts.
413
414 // Parse the logger configuration explicitly into the staging config.
415 // Note this does not alter the current loggers, they remain in
416 // effect until we apply the logging config below. If no logging
417 // is supplied logging will revert to default logging.
418 Daemon::configureLogger(dhcp6, CfgMgr::instance().getStagingCfg());
419
420 // Let's apply the new logging. We do it early, so we'll be able to print
421 // out what exactly is wrong with the new config in case of problems.
422 CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
423
424 // Now we configure the server proper.
425 ConstElementPtr result = processConfig(dhcp6);
426
427 // If the configuration parsed successfully, apply the new logger
428 // configuration and then commit the new configuration. We apply
429 // the logging first in case there's a configuration failure.
430 int rcode = 0;
431 isc::config::parseAnswer(rcode, result);
432 if (getShutdown() && (rcode == CONTROL_RESULT_SUCCESS)) {
433 // Do not return success when a fatal error was triggered.
435 message = "Reconfiguration triggered a fatal error: shutting down.";
436 result = isc::config::createAnswer(rcode, message);
437 }
438 if (rcode == CONTROL_RESULT_SUCCESS) {
439 CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
440
441 // Use new configuration.
443 } else if (CfgMgr::instance().getCurrentCfg()->getSequence() != 0) {
444 // Ok, we applied the logging from the upcoming configuration, but
445 // there were problems with the config. As such, we need to back off
446 // and revert to the previous logging configuration. This is not done if
447 // sequence == 0, because that would mean always reverting to stdout by
448 // default, and it is arguably more helpful to have the error in a
449 // potential file or syslog configured in the upcoming configuration.
450 CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
451
452 if (rcode == CONTROL_RESULT_FATAL_ERROR) {
453 // Not initial configuration so someone can believe we reverted
454 // to the previous configuration. It is not the case so be clear
455 // about this.
457 }
458 }
459
461 try {
462 // Handle events registered by hooks using external IOService objects.
464 } catch (const std::exception& ex) {
465 if (rcode == CONTROL_RESULT_FATAL_ERROR) {
466 return (result);
467 }
468 std::ostringstream err;
469 err << "Error initializing hooks: "
470 << ex.what();
472 }
473
474 return (result);
475}
476
479 ConstElementPtr args) {
480 if (!IfaceMgr::instance().isMainThread()) {
482 "Illegal operation executing 'config-test' on a different thread than main thread"));
483 }
484 const int status_code = CONTROL_RESULT_ERROR; // 1 indicates an error
485 ConstElementPtr dhcp6;
486 string message;
487
488 // Command arguments are expected to be:
489 // { "Dhcp6": { ... } }
490 if (!args) {
491 message = "Missing mandatory 'arguments' parameter.";
492 } else {
493 dhcp6 = args->get("Dhcp6");
494 if (!dhcp6) {
495 message = "Missing mandatory 'Dhcp6' parameter.";
496 } else if (dhcp6->getType() != Element::map) {
497 message = "'Dhcp6' parameter expected to be a map.";
498 }
499 }
500
501 // Check unsupported objects.
502 if (message.empty()) {
503 for (auto const& obj : args->mapValue()) {
504 const string& obj_name = obj.first;
505 if (obj_name != "Dhcp6") {
507 .arg(obj_name);
508 if (message.empty()) {
509 message = "Unsupported '" + obj_name + "' parameter";
510 } else {
511 message += " (and '" + obj_name + "')";
512 }
513 }
514 }
515 if (!message.empty()) {
516 message += ".";
517 }
518 }
519
520 if (!message.empty()) {
521 // Something is amiss with arguments, return a failure response.
522 ConstElementPtr result = isc::config::createAnswer(status_code,
523 message);
524 return (result);
525 }
526
527 // stop thread pool (if running)
529
530 // We are starting the configuration process so we should remove any
531 // staging configuration that has been created during previous
532 // configuration attempts.
534
535 // Now we check the server proper.
536 return (checkConfig(dhcp6));
537}
538
541 ConstElementPtr args) {
542 std::ostringstream message;
543 int64_t max_period = 0;
544 std::string origin;
545
546 // If the args map does not contain 'origin' parameter, the default type
547 // will be used (user command).
548 auto type = NetworkState::USER_COMMAND;
549
550 // Parse arguments to see if the 'max-period' or 'origin' parameters have
551 // been specified.
552 if (args) {
553 // Arguments must be a map.
554 if (args->getType() != Element::map) {
555 message << "arguments for the 'dhcp-disable' command must be a map";
556
557 } else {
558 ConstElementPtr max_period_element = args->get("max-period");
559 // max-period is optional.
560 if (max_period_element) {
561 // It must be an integer, if specified.
562 if (max_period_element->getType() != Element::integer) {
563 message << "'max-period' argument must be a number";
564
565 } else {
566 // It must be positive integer.
567 max_period = max_period_element->intValue();
568 if (max_period <= 0) {
569 message << "'max-period' must be positive integer";
570 }
571 }
572 }
573 // 'origin-id' replaces the older parameter 'origin' since Kea 2.5.8
574 // stable release. However, the 'origin' is kept for backward compatibility
575 // with Kea versions before 2.5.8. It is common to receive both parameters
576 // because HA hook library sends both in case the partner server hasn't been
577 // upgraded to the new version. The 'origin-id' takes precedence over the
578 // 'origin'.
579 ConstElementPtr origin_id_element = args->get("origin-id");
580 ConstElementPtr origin_element = args->get("origin");
581 // The 'origin-id' and 'origin' arguments are optional.
582 if (origin_id_element) {
583 if (origin_id_element->getType() == Element::integer) {
584 type = origin_id_element->intValue();
585 } else {
586 message << "'origin-id' argument must be a number";
587 }
588 } else if (origin_element) {
589 switch (origin_element->getType()) {
590 case Element::string:
591 origin = origin_element->stringValue();
592 if (origin == "ha-partner") {
594 } else if (origin != "user") {
595 if (origin.empty()) {
596 origin = "(empty string)";
597 }
598 message << "invalid value used for 'origin' parameter: "
599 << origin;
600 }
601 break;
602 case Element::integer:
603 type = origin_element->intValue();
604 break;
605 default:
606 // It must be a string or a number, if specified.
607 message << "'origin' argument must be a string or a number";
608 }
609 }
610 }
611 }
612
613 // No error occurred, so let's disable the service.
614 if (message.tellp() == 0) {
615 message << "DHCPv6 service disabled";
616 if (max_period > 0) {
617 message << " for " << max_period << " seconds";
618
619 // The user specified that the DHCP service should resume not
620 // later than in max-period seconds. If the 'dhcp-enable' command
621 // is not sent, the DHCP service will resume automatically.
622 network_state_->delayedEnableService(static_cast<unsigned>(max_period),
623 type);
624 }
625 network_state_->disableService(type);
626
627 // Success.
628 return (config::createAnswer(CONTROL_RESULT_SUCCESS, message.str()));
629 }
630
631 // Failure.
632 return (config::createAnswer(CONTROL_RESULT_ERROR, message.str()));
633}
634
637 ConstElementPtr args) {
638 std::ostringstream message;
639 std::string origin;
640
641 // If the args map does not contain 'origin' parameter, the default type
642 // will be used (user command).
643 auto type = NetworkState::USER_COMMAND;
644
645 // Parse arguments to see if the 'origin' parameter has been specified.
646 if (args) {
647 // Arguments must be a map.
648 if (args->getType() != Element::map) {
649 message << "arguments for the 'dhcp-enable' command must be a map";
650
651 } else {
652 // 'origin-id' replaces the older parameter 'origin' since Kea 2.5.8
653 // stable release. However, the 'origin' is kept for backward compatibility
654 // with Kea versions before 2.5.8. It is common to receive both parameters
655 // because HA hook library sends both in case the partner server hasn't been
656 // upgraded to the new version. The 'origin-id' takes precedence over the
657 // 'origin'.
658 ConstElementPtr origin_id_element = args->get("origin-id");
659 ConstElementPtr origin_element = args->get("origin");
660 // The 'origin-id' and 'origin' arguments are optional.
661 if (origin_id_element) {
662 if (origin_id_element->getType() == Element::integer) {
663 type = origin_id_element->intValue();
664 } else {
665 message << "'origin-id' argument must be a number";
666 }
667 } else if (origin_element) {
668 switch (origin_element->getType()) {
669 case Element::string:
670 origin = origin_element->stringValue();
671 if (origin == "ha-partner") {
673 } else if (origin != "user") {
674 if (origin.empty()) {
675 origin = "(empty string)";
676 }
677 message << "invalid value used for 'origin' parameter: "
678 << origin;
679 }
680 break;
681 case Element::integer:
682 type = origin_element->intValue();
683 break;
684 default:
685 // It must be a string or a number, if specified.
686 message << "'origin' argument must be a string or a number";
687 }
688 }
689 }
690 }
691
692 // No error occurred, so let's enable the service.
693 if (message.tellp() == 0) {
694 network_state_->enableService(type);
695
696 // Success.
698 "DHCP service successfully enabled"));
699 }
700
701 // Failure.
702 return (config::createAnswer(CONTROL_RESULT_ERROR, message.str()));
703}
704
709 std::string message;
710 bool error = false;
711 try {
712 ifaces->set("interfaces", IfaceMgr::instance().ifacesToElement());
713 } catch (const std::exception& ex) {
714 error = true;
715 message = ex.what();
716 } catch (...) {
717 error = true;
718 message = "unknown error";
719 }
720
721 ostringstream msg;
722 if (!error) {
724 << " interfaces detected.";
725 return (isc::config::createAnswer(CONTROL_RESULT_SUCCESS, msg.str(), ifaces));
726 } else {
727 msg << "Unexpected error while retrieving the list of detected interfaces: " << message;
729 }
730}
731
734 ConstElementPtr args) {
735 if (!IfaceMgr::instance().isMainThread()) {
737 "Illegal operation executing 'interface-redetect' on a different thread than main thread"));
738 }
739 std::string message;
740 bool error = false;
741 try {
742 // stop thread pool (if running)
746 } catch (const std::exception& ex) {
747 error = true;
748 message = ex.what();
749 } catch (...) {
750 error = true;
751 message = "unknown error";
752 }
753
754 ostringstream msg;
755 if (!error) {
757 } else {
758 msg << "Unexpected error while retrieving the list of detected interfaces: " << message;
760 }
761}
762
765 ConstElementPtr args) {
766 if (!IfaceMgr::instance().isMainThread()) {
768 "Illegal operation executing 'interface-add' on a different thread than main thread"));
769 }
770 string message;
771 ConstElementPtr ifaces_config;
772 if (!args) {
773 message = "Missing mandatory 'arguments' parameter.";
774 } else {
775 if (args->getType() != Element::map) {
776 message = "arguments for the 'interface-add' command must be a map";
777 } else {
778 ifaces_config = args->get("interfaces");
779 if (!ifaces_config) {
780 message = "Missing mandatory 'interfaces' map parameter in 'arguments'.";
781 }
782 auto map = args->mapValue();
783 for (auto const& key : map) {
784 if (key.first != "interfaces") {
785 message = "Unsupported '" + key.first + "' map parameter in 'arguments'.";
786 break;
787 }
788 }
789 }
790 }
791
792 if (!message.empty()) {
794 }
795 if (!ifaces_config->size()) {
796 return (isc::config::createAnswer(CONTROL_RESULT_SUCCESS, "Interface configuration successfully updated."));
797 }
798 bool error = false;
799 try {
800 CfgIfacePtr running_cfg = CfgMgr::instance().getCurrentCfg()->getCfgIface();
802 std::set<std::string> seen;
803 auto running_ifaces = running_cfg->toElement()->get("interfaces");
804 if (running_ifaces && (running_ifaces->getType() == Element::list)) {
805 for (auto const& item : running_ifaces->listValue()) {
806 seen.insert(item->stringValue());
807 ifaces->add(item);
808 }
809 }
810 for (auto const& item : ifaces_config->listValue()) {
811 auto const& str = item->stringValue();
812 if (seen.find(item->stringValue()) != seen.end()) {
813 continue;
814 }
815 seen.insert(item->stringValue());
816 ifaces->add(item);
817 }
818 IfacesConfigParser parser(AF_INET6, true);
819 CfgIfacePtr cfg_iface(new CfgIface());
820 parser.parseInterfacesList(cfg_iface, ifaces);
821 running_cfg->update(*cfg_iface);
822 running_cfg->triggerOpenSocketsWithRetry(AF_INET6, getServerPort());
823 } catch (const std::exception& ex) {
824 error = true;
825 message = ex.what();
826 } catch (...) {
827 error = true;
828 message = "unknown error";
829 }
830
831 ostringstream msg;
832 if (!error) {
833 if (getShutdown()) {
834 return (isc::config::createAnswer(CONTROL_RESULT_FATAL_ERROR, "Interface configuration update triggered a fatal error: shutting down."));
835 }
836 return (isc::config::createAnswer(CONTROL_RESULT_SUCCESS, "Interface configuration successfully updated."));
837 } else {
838 msg << "Updating used interfaces failed: " << message;
840 }
841}
842
846 ElementPtr arguments = Element::createMap();
847 arguments->set("extended", extended);
850 arguments);
851 return (answer);
852}
853
861
864 ConstElementPtr args) {
865 int status_code = CONTROL_RESULT_ERROR;
866 string message;
867
868 // args must be { "remove": <bool> }
869 if (!args) {
870 message = "Missing mandatory 'remove' parameter.";
871 } else {
872 ConstElementPtr remove_name = args->get("remove");
873 if (!remove_name) {
874 message = "Missing mandatory 'remove' parameter.";
875 } else if (remove_name->getType() != Element::boolean) {
876 message = "'remove' parameter expected to be a boolean.";
877 } else {
878 bool remove_lease = remove_name->boolValue();
879 server_->alloc_engine_->reclaimExpiredLeases6(0, 0, remove_lease);
880 status_code = 0;
881 message = "Reclamation of expired leases is complete.";
882 }
883 }
884 ConstElementPtr answer = isc::config::createAnswer(status_code, message);
885 return (answer);
886}
887
890 ConstElementPtr args) {
891 if (!args) {
892 return (createAnswer(CONTROL_RESULT_ERROR, "empty arguments"));
893 }
894 if (args->getType() != Element::map) {
895 return (createAnswer(CONTROL_RESULT_ERROR, "arguments must be a map"));
896 }
897 SubnetSelector selector;
899 for (auto const& entry : args->mapValue()) {
900 ostringstream errmsg;
901 if (entry.first == "interface") {
902 if (entry.second->getType() != Element::string) {
903 errmsg << "'interface' entry must be a string";
904 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
905 }
906 selector.iface_name_ = entry.second->stringValue();
907 continue;
908 } if (entry.first == "interface-id") {
909 if (entry.second->getType() != Element::string) {
910 errmsg << "'interface-id' entry must be a string";
911 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
912 }
913 try {
914 string str = entry.second->stringValue();
915 vector<uint8_t> id = util::str::quotedStringToBinary(str);
916 if (id.empty()) {
918 }
919 if (id.empty()) {
920 errmsg << "'interface-id' must be not empty";
921 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
922 }
925 id));
926 continue;
927 } catch (...) {
928 errmsg << "value of 'interface-id' was not recognized";
929 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
930 }
931 } else if (entry.first == "remote") {
932 if (entry.second->getType() != Element::string) {
933 errmsg << "'remote' entry must be a string";
934 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
935 }
936 try {
937 IOAddress addr(entry.second->stringValue());
938 if (!addr.isV6()) {
939 errmsg << "bad 'remote' entry: not IPv6";
940 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
941 }
942 selector.remote_address_ = addr;
943 continue;
944 } catch (const exception& ex) {
945 errmsg << "bad 'remote' entry: " << ex.what();
946 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
947 }
948 } else if (entry.first == "link") {
949 if (entry.second->getType() != Element::string) {
950 errmsg << "'link' entry must be a string";
951 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
952 }
953 try {
954 IOAddress addr(entry.second->stringValue());
955 if (!addr.isV6()) {
956 errmsg << "bad 'link' entry: not IPv6";
957 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
958 }
959 selector.first_relay_linkaddr_ = addr;
960 continue;
961 } catch (const exception& ex) {
962 errmsg << "bad 'link' entry: " << ex.what();
963 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
964 }
965 } else if (entry.first == "classes") {
966 if (entry.second->getType() != Element::list) {
968 "'classes' entry must be a list"));
969 }
970 for (auto const& item : entry.second->listValue()) {
971 if (!item || (item->getType() != Element::string)) {
972 errmsg << "'classes' entry must be a list of strings";
973 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
974 }
975 // Skip empty client classes.
976 if (!item->stringValue().empty()) {
977 selector.client_classes_.insert(item->stringValue());
978 }
979 }
980 continue;
981 } else {
982 errmsg << "unknown entry '" << entry.first << "'";
983 return (createAnswer(CONTROL_RESULT_ERROR, errmsg.str()));
984 }
985 }
987 getCfgSubnets6()->selectSubnet(selector);
988 if (!subnet) {
989 return (createAnswer(CONTROL_RESULT_EMPTY, "no subnet selected"));
990 }
991 SharedNetwork6Ptr network;
992 subnet->getSharedNetwork(network);
993 ostringstream msg;
994 if (network) {
995 msg << "selected shared network '" << network->getName()
996 << "' starting with subnet '" << subnet->toText()
997 << "' id " << subnet->getID();
998 } else {
999 msg << "selected subnet '" << subnet->toText()
1000 << "' id " << subnet->getID();
1001 }
1002 return (createAnswer(CONTROL_RESULT_SUCCESS, msg.str()));
1003}
1004
1008 const std::string& tag =
1009 CfgMgr::instance().getCurrentCfg()->getServerTag();
1010 ElementPtr response = Element::createMap();
1011 response->set("server-tag", Element::create(tag));
1012
1013 return (createAnswer(CONTROL_RESULT_SUCCESS, response));
1014}
1015
1019 if (!IfaceMgr::instance().isMainThread()) {
1021 "Illegal operation executing 'config-backend-pull' on a different thread than main thread"));
1022 }
1023 auto ctl_info = CfgMgr::instance().getCurrentCfg()->getConfigControlInfo();
1024 if (!ctl_info) {
1025 return (createAnswer(CONTROL_RESULT_EMPTY, "No config backend."));
1026 }
1027
1028 // stop thread pool (if running)
1030
1031 // Reschedule the periodic CB fetch.
1032 if (TimerMgr::instance()->isTimerRegistered("Dhcp6CBFetchTimer")) {
1033 TimerMgr::instance()->cancel("Dhcp6CBFetchTimer");
1034 TimerMgr::instance()->setup("Dhcp6CBFetchTimer");
1035 }
1036
1037 // Code from cbFetchUpdates.
1038 // The configuration to use is the current one because this is called
1039 // after the configuration manager commit.
1040 try {
1041 auto srv_cfg = CfgMgr::instance().getCurrentCfg();
1042 auto mode = CBControlDHCPv6::FetchMode::FETCH_UPDATE;
1043 server_->getCBControl()->databaseConfigFetch(srv_cfg, mode);
1044 } catch (const std::exception& ex) {
1046 .arg(ex.what());
1048 "On demand configuration update failed: " +
1049 string(ex.what())));
1050 }
1052 "On demand configuration update successful."));
1053}
1054
1057 ConstElementPtr /*args*/) {
1058 ElementPtr status = Element::createMap();
1059 status->set("pid", Element::create(static_cast<int>(getpid())));
1060
1061 auto now = boost::posix_time::second_clock::universal_time();
1062 // Sanity check: start_ is always initialized.
1063 if (!start_.is_not_a_date_time()) {
1064 auto uptime = now - start_;
1065 status->set("uptime", Element::create(uptime.total_seconds()));
1066 }
1067
1068 auto last_commit = CfgMgr::instance().getCurrentCfg()->getLastCommitTime();
1069 if (!last_commit.is_not_a_date_time()) {
1070 auto reload = now - last_commit;
1071 status->set("reload", Element::create(reload.total_seconds()));
1072 }
1073
1074 auto& mt_mgr = MultiThreadingMgr::instance();
1075 if (mt_mgr.getMode()) {
1076 status->set("multi-threading-enabled", Element::create(true));
1077 status->set("thread-pool-size", Element::create(static_cast<int32_t>(
1078 MultiThreadingMgr::instance().getThreadPoolSize())));
1079 status->set("packet-queue-size", Element::create(static_cast<int32_t>(
1080 MultiThreadingMgr::instance().getPacketQueueSize())));
1081 ElementPtr queue_stats = Element::createList();
1082 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(10)));
1083 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(100)));
1084 queue_stats->add(Element::create(mt_mgr.getThreadPool().getQueueStat(1000)));
1085 status->set("packet-queue-statistics", queue_stats);
1086
1087 } else {
1088 status->set("multi-threading-enabled", Element::create(false));
1089 }
1090
1091 // Merge lease manager status.
1092 ElementPtr lm_info;
1095 }
1096 if (lm_info && (lm_info->getType() == Element::map)) {
1097 for (auto const& entry : lm_info->mapValue()) {
1098 status->set(entry.first, entry.second);
1099 }
1100 }
1101
1102 status->set("extended-info-tables", Element::create(
1103 CfgMgr::instance().getCurrentCfg()->getCfgDbAccess()->getExtendedInfoTablesEnabled()));
1104
1105 // Iterate through the interfaces and get all the errors.
1106 ElementPtr socket_errors(Element::createList());
1107 for (IfacePtr const& interface : IfaceMgr::instance().getIfaces()) {
1108 for (std::string const& error : interface->getErrors()) {
1109 socket_errors->add(Element::create(error));
1110 }
1111 }
1112
1113 // Abstract the information from all sockets into a single status.
1114 ElementPtr sockets(Element::createMap());
1115 if (socket_errors->empty()) {
1116 sockets->set("status", Element::create("ready"));
1117 } else {
1118 ReconnectCtlPtr const reconnect_ctl(
1119 CfgMgr::instance().getCurrentCfg()->getCfgIface()->getReconnectCtl());
1120 if (reconnect_ctl && reconnect_ctl->retriesLeft()) {
1121 sockets->set("status", Element::create("retrying"));
1122 } else {
1123 sockets->set("status", Element::create("failed"));
1124 }
1125 sockets->set("errors", socket_errors);
1126 }
1127 status->set("sockets", sockets);
1128
1129 status->set("dhcp-state", network_state_->toElement());
1130
1131 return (createAnswer(CONTROL_RESULT_SUCCESS, status));
1132}
1133
1136 ConstElementPtr args) {
1137 StatsMgr& stats_mgr = StatsMgr::instance();
1139 // Update the default parameter.
1140 long max_samples = stats_mgr.getMaxSampleCountDefault();
1141 CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
1142 "statistic-default-sample-count", Element::create(max_samples));
1143 return (answer);
1144}
1145
1148 ConstElementPtr args) {
1149 StatsMgr& stats_mgr = StatsMgr::instance();
1150 ConstElementPtr answer = stats_mgr.statisticSetMaxSampleAgeAllHandler(args);
1151 // Update the default parameter.
1152 auto duration = stats_mgr.getMaxSampleAgeDefault();
1153 long max_age = toSeconds(duration);
1154 CfgMgr::instance().getCurrentCfg()->addConfiguredGlobal(
1155 "statistic-default-sample-age", Element::create(max_age));
1156 return (answer);
1157}
1158
1162 return (LeaseMgrFactory::instance().lfcStartHandler());
1163 }
1165 "no lease backend"));
1166}
1167
1171
1172 // Allow DB reconnect on startup. The database connection parameters specify
1173 // respective details.
1175
1176 // Single stream instance used in all error clauses
1177 std::ostringstream err;
1178
1179 if (!srv) {
1180 err << "Server object not initialized, can't process config.";
1182 }
1183
1185 .arg(srv->redactConfig(config)->str());
1186
1188
1189 // Check that configuration was successful. If not, do not reopen sockets
1190 // and don't bother with DDNS stuff.
1191 try {
1192 int rcode = 0;
1193 isc::config::parseAnswer(rcode, answer);
1194 if (rcode != CONTROL_RESULT_SUCCESS) {
1195 return (answer);
1196 }
1197 } catch (const std::exception& ex) {
1198 err << "Failed to process configuration:" << ex.what();
1200 }
1201
1202 // Enable allocator initialization prior to creating lease manager.
1204
1205 // Re-open lease and host database with new parameters.
1206 try {
1208 std::bind(&ControlledDhcpv6Srv::dbLostCallback, srv, ph::_1);
1209
1211 std::bind(&ControlledDhcpv6Srv::dbRecoveredCallback, srv, ph::_1);
1212
1214 std::bind(&ControlledDhcpv6Srv::dbFailedCallback, srv, ph::_1);
1215
1216 CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
1217 string params = "universe=6";
1218 if (cfg_db->getExtendedInfoTablesEnabled()) {
1219 params += " extended-info-tables=true";
1220 }
1221 cfg_db->setAppendedParameters(params);
1222 cfg_db->createManagers();
1223 // Reset counters related to connections as all managers have been recreated.
1224 srv->getNetworkState()->resetForDbConnection();
1225 srv->getNetworkState()->resetForLocalCommands();
1226 srv->getNetworkState()->resetForRemoteCommands();
1227 } catch (const std::exception& ex) {
1228 err << "Unable to open database: " << ex.what();
1230 }
1231
1232 // Regenerate server identifier if needed.
1233 try {
1234 const std::string duid_file =
1235 std::string(CfgMgr::instance().getDataDir()) + "/" +
1236 std::string(SERVER_DUID_FILE);
1237 DuidPtr duid = CfgMgr::instance().getStagingCfg()->getCfgDUID()->create(duid_file);
1238 server_->serverid_.reset(new Option(Option::V6, D6O_SERVERID, duid->getDuid()));
1239 if (duid) {
1241 .arg(duid->toText())
1242 .arg(duid_file);
1243 }
1244
1245 } catch (const std::exception& ex) {
1246 err << "unable to configure server identifier: " << ex.what();
1248 }
1249
1250 // Server will start DDNS communications if its enabled.
1251 try {
1252 srv->startD2();
1253 } catch (const std::exception& ex) {
1254 err << "Error starting DHCP_DDNS client after server reconfiguration: "
1255 << ex.what();
1257 }
1258
1259 // Setup DHCPv4-over-DHCPv6 IPC
1260 try {
1262 } catch (const std::exception& ex) {
1263 err << "error starting DHCPv4-over-DHCPv6 IPC "
1264 " after server reconfiguration: " << ex.what();
1266 }
1267
1268 // Configure DHCP packet queueing
1269 try {
1271 qc = CfgMgr::instance().getStagingCfg()->getDHCPQueueControl();
1272 if (IfaceMgr::instance().configureDHCPPacketQueue(AF_INET6, qc)) {
1274 .arg(IfaceMgr::instance().getPacketQueue6()->getInfoStr());
1275 }
1276
1277 } catch (const std::exception& ex) {
1278 err << "Error setting packet queue controls after server reconfiguration: "
1279 << ex.what();
1281 }
1282
1283 // Configure a callback to shut down the server when the bind socket
1284 // attempts exceeded.
1286 std::bind(&ControlledDhcpv6Srv::openSocketsFailedCallback, srv, ph::_1);
1287
1288 // Configuration may change active interfaces. Therefore, we have to reopen
1289 // sockets according to new configuration. It is possible that this
1290 // operation will fail for some interfaces but the openSockets function
1291 // guards against exceptions and invokes a callback function to
1292 // log warnings. Since we allow that this fails for some interfaces there
1293 // is no need to rollback configuration if socket fails to open on any
1294 // of the interfaces.
1295 CfgMgr::instance().getStagingCfg()->getCfgIface()->
1296 openSockets(AF_INET6, srv->getServerPort());
1297
1298 // Install the timers for handling leases reclamation.
1299 try {
1300 CfgMgr::instance().getStagingCfg()->getCfgExpiration()->
1301 setupTimers(&ControlledDhcpv6Srv::reclaimExpiredLeases,
1302 &ControlledDhcpv6Srv::deleteExpiredReclaimedLeases,
1303 server_);
1304
1305 } catch (const std::exception& ex) {
1306 err << "unable to setup timers for periodically running the"
1307 " reclamation of the expired leases: "
1308 << ex.what() << ".";
1310 }
1311
1312 // Setup config backend polling, if configured for it.
1313 auto ctl_info = CfgMgr::instance().getStagingCfg()->getConfigControlInfo();
1314 if (ctl_info) {
1315 long fetch_time = static_cast<long>(ctl_info->getConfigFetchWaitTime());
1316 // Only schedule the CB fetch timer if the fetch wait time is greater
1317 // than 0.
1318 if (fetch_time > 0) {
1319 // When we run unit tests, we want to use milliseconds unit for the
1320 // specified interval. Otherwise, we use seconds. Note that using
1321 // milliseconds as a unit in unit tests prevents us from waiting 1
1322 // second on more before the timer goes off. Instead, we wait one
1323 // millisecond which significantly reduces the test time.
1324 if (!server_->inTestMode()) {
1325 fetch_time = 1000 * fetch_time;
1326 }
1327
1328 boost::shared_ptr<unsigned> failure_count(new unsigned(0));
1330 registerTimer("Dhcp6CBFetchTimer",
1331 std::bind(&ControlledDhcpv6Srv::cbFetchUpdates,
1332 server_, CfgMgr::instance().getStagingCfg(),
1333 failure_count),
1334 fetch_time,
1336 TimerMgr::instance()->setup("Dhcp6CBFetchTimer");
1337 }
1338 }
1339
1340 // Finally, we can commit runtime option definitions in libdhcp++. This is
1341 // exception free.
1343
1345 if (notify_libraries) {
1346 return (notify_libraries);
1347 }
1348
1349 // Apply multi threading settings.
1350 // @note These settings are applied/updated only if no errors occur while
1351 // applying the new configuration.
1352 // @todo This should be fixed.
1353 try {
1354 CfgMultiThreading::apply(CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
1355 } catch (const std::exception& ex) {
1356 err << "Error applying multi threading settings: "
1357 << ex.what();
1359 }
1360
1361 return (answer);
1362}
1363
1367 // This hook point notifies hooks libraries that the configuration of the
1368 // DHCPv6 server has completed. It provides the hook library with the pointer
1369 // to the common IO service object, new server configuration in the JSON
1370 // format and with the pointer to the configuration storage where the
1371 // parsed configuration is stored.
1372 if (HooksManager::calloutsPresent(Hooks.hooks_index_dhcp6_srv_configured_)) {
1374
1375 callout_handle->setArgument("io_context", srv->getIOService());
1376 callout_handle->setArgument("network_state", srv->getNetworkState());
1377 callout_handle->setArgument("json_config", config);
1378 callout_handle->setArgument("server_config", CfgMgr::instance().getStagingCfg());
1379
1380 HooksManager::callCallouts(Hooks.hooks_index_dhcp6_srv_configured_,
1381 *callout_handle);
1382
1383 // If next step is DROP, report a configuration error.
1384 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
1385 string error;
1386 try {
1387 callout_handle->getArgument("error", error);
1388 } catch (NoSuchArgument const& ex) {
1389 error = "unknown error";
1390 }
1392 }
1393 }
1394
1395 return (ConstElementPtr());
1396}
1397
1401
1402 if (!srv) {
1404 "Server object not initialized, can't process config.");
1405 return (no_srv);
1406 }
1407
1409 .arg(srv->redactConfig(config)->str());
1410
1411 return (configureDhcp6Server(*srv, config, true));
1412}
1413
1414ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port /*= DHCP6_SERVER_PORT*/,
1415 uint16_t client_port /*= 0*/)
1416 : Dhcpv6Srv(server_port, client_port), timer_mgr_(TimerMgr::instance()) {
1417 if (getInstance()) {
1419 "There is another Dhcpv6Srv instance already.");
1420 }
1421 server_ = this; // remember this instance for later use in handlers
1422
1423 // ProcessSpawn uses IO service to handle signal set events.
1425
1426 // TimerMgr uses IO service to run asynchronous timers.
1427 TimerMgr::instance()->setIOService(getIOService());
1428
1429 // Command managers use IO service to run asynchronous socket operations.
1432
1433 // Set the HTTP default socket address to the IPv6 (vs IPv4) loopback.
1435
1436 // Set the HTTP authentication default realm.
1438
1439 // Set the HTTP supported service.
1441
1442 // DatabaseConnection uses IO service to run asynchronous timers.
1444
1445 // These are the commands always supported by the DHCPv6 server.
1446 // Please keep the list in alphabetic order.
1447 CommandMgr::instance().registerCommand("build-report",
1448 std::bind(&ControlledDhcpv6Srv::commandBuildReportHandler, this, ph::_1, ph::_2));
1449
1450 CommandMgr::instance().registerCommand("config-backend-pull",
1451 std::bind(&ControlledDhcpv6Srv::commandConfigBackendPullHandler, this, ph::_1, ph::_2));
1452
1454 std::bind(&ControlledDhcpv6Srv::commandConfigGetHandler, this, ph::_1, ph::_2));
1455
1456 CommandMgr::instance().registerCommand("config-hash-get",
1457 std::bind(&ControlledDhcpv6Srv::commandConfigHashGetHandler, this, ph::_1, ph::_2));
1458
1459 CommandMgr::instance().registerCommand("config-reload",
1460 std::bind(&ControlledDhcpv6Srv::commandConfigReloadHandler, this, ph::_1, ph::_2));
1461
1463 std::bind(&ControlledDhcpv6Srv::commandConfigSetHandler, this, ph::_1, ph::_2));
1464
1465 CommandMgr::instance().registerCommand("config-test",
1466 std::bind(&ControlledDhcpv6Srv::commandConfigTestHandler, this, ph::_1, ph::_2));
1467
1468 CommandMgr::instance().registerCommand("config-write",
1469 std::bind(&ControlledDhcpv6Srv::commandConfigWriteHandler, this, ph::_1, ph::_2));
1470
1471 CommandMgr::instance().registerCommand("dhcp-enable",
1472 std::bind(&ControlledDhcpv6Srv::commandDhcpEnableHandler, this, ph::_1, ph::_2));
1473
1474 CommandMgr::instance().registerCommand("dhcp-disable",
1475 std::bind(&ControlledDhcpv6Srv::commandDhcpDisableHandler, this, ph::_1, ph::_2));
1476
1477 CommandMgr::instance().registerCommand("interface-add",
1478 std::bind(&ControlledDhcpv6Srv::commandInterfaceAddHandler, this, ph::_1, ph::_2));
1479
1480 CommandMgr::instance().registerCommand("interface-list",
1481 std::bind(&ControlledDhcpv6Srv::commandInterfaceListHandler, this, ph::_1, ph::_2));
1482
1483 CommandMgr::instance().registerCommand("interface-redetect",
1484 std::bind(&ControlledDhcpv6Srv::commandInterfaceRedetectHandler, this, ph::_1, ph::_2));
1485
1486 CommandMgr::instance().registerCommand("kea-lfc-start",
1487 std::bind(&ControlledDhcpv6Srv::commandLfcStartHandler, this, ph::_1, ph::_2));
1488
1489 CommandMgr::instance().registerCommand("leases-reclaim",
1490 std::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler, this, ph::_1, ph::_2));
1491
1492 CommandMgr::instance().registerCommand("subnet6-select-test",
1493 std::bind(&ControlledDhcpv6Srv::commandSubnet6SelectTestHandler, this, ph::_1, ph::_2));
1494
1495 CommandMgr::instance().registerCommand("server-tag-get",
1496 std::bind(&ControlledDhcpv6Srv::commandServerTagGetHandler, this, ph::_1, ph::_2));
1497
1499 std::bind(&ControlledDhcpv6Srv::commandShutdownHandler, this, ph::_1, ph::_2));
1500
1502 std::bind(&ControlledDhcpv6Srv::commandStatusGetHandler, this, ph::_1, ph::_2));
1503
1504 CommandMgr::instance().registerCommand("version-get",
1505 std::bind(&ControlledDhcpv6Srv::commandVersionGetHandler, this, ph::_1, ph::_2));
1506
1507 // Register statistic related commands
1508 CommandMgr::instance().registerCommand("statistic-get",
1509 std::bind(&StatsMgr::statisticGetHandler, ph::_1, ph::_2));
1510
1511 CommandMgr::instance().registerCommand("statistic-reset",
1512 std::bind(&StatsMgr::statisticResetHandler, ph::_1, ph::_2));
1513
1514 CommandMgr::instance().registerCommand("statistic-remove",
1515 std::bind(&StatsMgr::statisticRemoveHandler, ph::_1, ph::_2));
1516
1517 CommandMgr::instance().registerCommand("statistic-get-all",
1518 std::bind(&StatsMgr::statisticGetAllHandler, ph::_1, ph::_2));
1519
1520 CommandMgr::instance().registerCommand("statistic-global-get-all",
1521 std::bind(&StatsMgr::statisticGlobalGetAllHandler, ph::_1, ph::_2));
1522
1523 CommandMgr::instance().registerCommand("statistic-reset-all",
1524 std::bind(&StatsMgr::statisticResetAllHandler, ph::_1, ph::_2));
1525
1526 CommandMgr::instance().registerCommand("statistic-remove-all",
1527 std::bind(&StatsMgr::statisticRemoveAllHandler, ph::_1, ph::_2));
1528
1529 CommandMgr::instance().registerCommand("statistic-sample-age-set",
1530 std::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, ph::_1, ph::_2));
1531
1532 CommandMgr::instance().registerCommand("statistic-sample-age-set-all",
1533 std::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleAgeAllHandler, this, ph::_1, ph::_2));
1534
1535 CommandMgr::instance().registerCommand("statistic-sample-count-set",
1536 std::bind(&StatsMgr::statisticSetMaxSampleCountHandler, ph::_1, ph::_2));
1537
1538 CommandMgr::instance().registerCommand("statistic-sample-count-set-all",
1540}
1541
1543 setExitValue(exit_value);
1544 getIOService()->stop(); // Stop ASIO transmissions
1545 shutdown(); // Initiate DHCPv6 shutdown procedure.
1546}
1547
1549 try {
1550 MultiThreadingMgr::instance().apply(false, 0, 0);
1553
1554 // The closure captures either a shared pointer (memory leak)
1555 // or a raw pointer (pointing to a deleted object).
1559
1560 timer_mgr_->unregisterTimers();
1561
1562 cleanup();
1563
1564 // Close command sockets.
1567
1568 // Deregister any registered commands (please keep in alphabetic order)
1569 CommandMgr::instance().deregisterCommand("build-report");
1570 CommandMgr::instance().deregisterCommand("config-backend-pull");
1572 CommandMgr::instance().deregisterCommand("config-hash-get");
1573 CommandMgr::instance().deregisterCommand("config-reload");
1575 CommandMgr::instance().deregisterCommand("config-test");
1576 CommandMgr::instance().deregisterCommand("config-write");
1577 CommandMgr::instance().deregisterCommand("dhcp-disable");
1578 CommandMgr::instance().deregisterCommand("dhcp-enable");
1579 CommandMgr::instance().deregisterCommand("interface-add");
1580 CommandMgr::instance().deregisterCommand("interface-list");
1581 CommandMgr::instance().deregisterCommand("interface-redetect");
1582 CommandMgr::instance().deregisterCommand("kea-lfc-start");
1583 CommandMgr::instance().deregisterCommand("leases-reclaim");
1584 CommandMgr::instance().deregisterCommand("subnet6-select-test");
1585 CommandMgr::instance().deregisterCommand("server-tag-get");
1587 CommandMgr::instance().deregisterCommand("statistic-get");
1588 CommandMgr::instance().deregisterCommand("statistic-get-all");
1589 CommandMgr::instance().deregisterCommand("statistic-global-get-all");
1590 CommandMgr::instance().deregisterCommand("statistic-remove");
1591 CommandMgr::instance().deregisterCommand("statistic-remove-all");
1592 CommandMgr::instance().deregisterCommand("statistic-reset");
1593 CommandMgr::instance().deregisterCommand("statistic-reset-all");
1594 CommandMgr::instance().deregisterCommand("statistic-sample-age-set");
1595 CommandMgr::instance().deregisterCommand("statistic-sample-age-set-all");
1596 CommandMgr::instance().deregisterCommand("statistic-sample-count-set");
1597 CommandMgr::instance().deregisterCommand("statistic-sample-count-set-all");
1599 CommandMgr::instance().deregisterCommand("version-get");
1600
1601 // Reset DatabaseConnection IO service.
1603 } catch (...) {
1604 // Don't want to throw exceptions from the destructor. The server
1605 // is shutting down anyway.
1606 }
1607
1608 server_ = NULL; // forget this instance. There should be no callback anymore
1609 // at this stage anyway.
1610}
1611
1612void
1613ControlledDhcpv6Srv::reclaimExpiredLeases(const size_t max_leases,
1614 const uint16_t timeout,
1615 const bool remove_lease,
1616 const uint16_t max_unwarned_cycles) {
1617 try {
1618 if (network_state_->isServiceEnabled()) {
1619 server_->alloc_engine_->reclaimExpiredLeases6(max_leases, timeout,
1620 remove_lease,
1621 max_unwarned_cycles);
1622 } else {
1624 .arg(CfgMgr::instance().getCurrentCfg()->
1625 getCfgExpiration()->getReclaimTimerWaitTime());
1626 }
1627 } catch (const std::exception& ex) {
1629 .arg(ex.what());
1630 }
1631 // We're using the ONE_SHOT timer so there is a need to re-schedule it.
1633}
1634
1635void
1636ControlledDhcpv6Srv::deleteExpiredReclaimedLeases(const uint32_t secs) {
1637 if (network_state_->isServiceEnabled()) {
1638 server_->alloc_engine_->deleteExpiredReclaimedLeases6(secs);
1639 }
1640
1641 // We're using the ONE_SHOT timer so there is a need to re-schedule it.
1643}
1644
1645bool
1646ControlledDhcpv6Srv::dbLostCallback(ReconnectCtlPtr db_reconnect_ctl) {
1647 if (!db_reconnect_ctl) {
1648 // This should never happen
1650 return (false);
1651 }
1652
1653 // Disable service until the connection is recovered.
1654 if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
1655 db_reconnect_ctl->alterServiceState()) {
1656 network_state_->disableService(NetworkState::DB_CONNECTION + db_reconnect_ctl->id());
1657 }
1658
1660 .arg(db_reconnect_ctl->id())
1661 .arg(db_reconnect_ctl->timerName());
1662
1663 // If reconnect isn't enabled log it, initiate a shutdown if needed and
1664 // return false.
1665 if (!db_reconnect_ctl->retriesLeft() ||
1666 !db_reconnect_ctl->retryInterval()) {
1668 .arg(db_reconnect_ctl->retriesLeft())
1669 .arg(db_reconnect_ctl->retryInterval())
1670 .arg(db_reconnect_ctl->id())
1671 .arg(db_reconnect_ctl->timerName());
1672 if (db_reconnect_ctl->exitOnFailure()) {
1673 shutdownServer(EXIT_FAILURE);
1674 }
1675 return (false);
1676 }
1677
1678 return (true);
1679}
1680
1681bool
1682ControlledDhcpv6Srv::dbRecoveredCallback(ReconnectCtlPtr db_reconnect_ctl) {
1683 if (!db_reconnect_ctl) {
1684 // This should never happen
1686 return (false);
1687 }
1688
1689 // Enable service after the connection is recovered.
1690 if (db_reconnect_ctl->retriesLeft() != db_reconnect_ctl->maxRetries() &&
1691 db_reconnect_ctl->alterServiceState()) {
1692 network_state_->enableService(NetworkState::DB_CONNECTION + db_reconnect_ctl->id());
1693 }
1694
1696 .arg(db_reconnect_ctl->id())
1697 .arg(db_reconnect_ctl->timerName());
1698
1699 db_reconnect_ctl->resetRetries();
1700
1701 return (true);
1702}
1703
1704bool
1705ControlledDhcpv6Srv::dbFailedCallback(ReconnectCtlPtr db_reconnect_ctl) {
1706 if (!db_reconnect_ctl) {
1707 // This should never happen
1709 return (false);
1710 }
1711
1713 .arg(db_reconnect_ctl->maxRetries())
1714 .arg(db_reconnect_ctl->id())
1715 .arg(db_reconnect_ctl->timerName());
1716
1717 if (db_reconnect_ctl->exitOnFailure()) {
1718 shutdownServer(EXIT_FAILURE);
1719 }
1720
1721 return (true);
1722}
1723
1724void
1725ControlledDhcpv6Srv::openSocketsFailedCallback(ReconnectCtlPtr reconnect_ctl) {
1726 if (!reconnect_ctl) {
1727 // This should never happen
1729 return;
1730 }
1731
1732 if (reconnect_ctl->exitOnFailure()) {
1734 .arg(reconnect_ctl->maxRetries());
1735 shutdownServer(EXIT_FAILURE);
1736 } else {
1738 .arg(reconnect_ctl->maxRetries());
1739 }
1740}
1741
1742void
1743ControlledDhcpv6Srv::cbFetchUpdates(const SrvConfigPtr& srv_cfg,
1744 boost::shared_ptr<unsigned> failure_count) {
1745 // stop thread pool (if running)
1746 MultiThreadingCriticalSection cs;
1747
1748 try {
1749 // Fetch any configuration backend updates since our last fetch.
1750 server_->getCBControl()->databaseConfigFetch(srv_cfg,
1751 CBControlDHCPv6::FetchMode::FETCH_UPDATE);
1752 (*failure_count) = 0;
1753
1754 } catch (const std::exception& ex) {
1756 .arg(ex.what());
1757
1758 // We allow at most 10 consecutive failures after which we stop
1759 // making further attempts to fetch the configuration updates.
1760 // Let's return without re-scheduling the timer.
1761 if (++(*failure_count) > 10) {
1764 return;
1765 }
1766 }
1767
1768 // Reschedule the timer to fetch new updates or re-try if
1769 // the previous attempt resulted in an error.
1770 if (TimerMgr::instance()->isTimerRegistered("Dhcp6CBFetchTimer")) {
1771 TimerMgr::instance()->setup("Dhcp6CBFetchTimer");
1772 }
1773}
1774
1775} // namespace dhcp
1776} // namespace isc
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.
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.
static isc::asiolink::IOAddress DEFAULT_SOCKET_ADDRESS
Default socket address (127.0.0.1).
static std::string SUPPORTED_SERVICE
Supported service.
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.
Definition data.cc:299
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:354
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition data.cc:349
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.
Represents selection of interfaces for DHCP server.
Definition cfg_iface.h:131
static OpenSocketsFailedCallback open_sockets_failed_callback_
Optional callback function to invoke if all retries of the opening sockets fail.
Definition cfg_iface.h:369
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:29
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition cfgmgr.cc:121
void commit()
Commits the staging configuration.
Definition cfgmgr.cc:93
void clearStagingConfiguration()
Remove staging configuration.
Definition cfgmgr.cc:88
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Definition cfgmgr.cc:116
static void apply(data::ConstElementPtr value)
apply multi threading configuration
void insert(const ClientClass &class_name)
Insert an element.
Definition classify.h:160
Controlled version of the DHCPv6 server.
bool getShutdown() const
Return the server shutdown flag value.
isc::data::ConstElementPtr commandVersionGetHandler(const std::string &command, isc::data::ConstElementPtr args)
@Brief handler for processing 'version-get' command
void init(const std::string &config_file)
Initializes the server.
void cleanup()
Performs cleanup, immediately before termination.
isc::data::ConstElementPtr commandConfigSetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for processing 'config-set' command
isc::data::ConstElementPtr commandInterfaceAddHandler(const std::string &command, isc::data::ConstElementPtr args)
Handler for processing 'interface-add' command.
isc::data::ConstElementPtr commandInterfaceRedetectHandler(const std::string &command, isc::data::ConstElementPtr args)
Handler for processing 'interface-redetect' command.
isc::data::ConstElementPtr commandShutdownHandler(const std::string &command, isc::data::ConstElementPtr args)
Handler for processing 'shutdown' command.
isc::data::ConstElementPtr commandConfigBackendPullHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for config-backend-pull command
isc::data::ConstElementPtr commandLfcStartHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for processing 'kea-lfc-start' command
isc::data::ConstElementPtr commandConfigHashGetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for processing 'config-hash-get' command
isc::data::ConstElementPtr commandServerTagGetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for server-tag-get command
isc::data::ConstElementPtr commandStatisticSetMaxSampleCountAllHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for processing 'statistic-sample-count-set-all' command
isc::data::ConstElementPtr commandStatisticSetMaxSampleAgeAllHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for processing 'statistic-sample-age-set-all' command
isc::data::ConstElementPtr commandStatusGetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for processing 'status-get' command
isc::data::ConstElementPtr commandDhcpEnableHandler(const std::string &command, isc::data::ConstElementPtr args)
A handler for processing 'dhcp-enable' command.
isc::data::ConstElementPtr commandConfigReloadHandler(const std::string &command, isc::data::ConstElementPtr args)
Handler for processing 'config-reload' command.
isc::data::ConstElementPtr commandLeasesReclaimHandler(const std::string &command, isc::data::ConstElementPtr args)
Handler for processing 'leases-reclaim' command.
isc::data::ConstElementPtr commandConfigWriteHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for processing 'config-write' command
isc::data::ConstElementPtr commandBuildReportHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for processing 'build-report' command
static isc::data::ConstElementPtr finishConfigHookLibraries(isc::data::ConstElementPtr config)
Configuration checker for hook libraries.
virtual ~ControlledDhcpv6Srv()
Destructor.
static isc::data::ConstElementPtr processConfig(isc::data::ConstElementPtr config)
Configuration processor.
isc::data::ConstElementPtr commandConfigGetHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for processing 'config-get' command
virtual void shutdownServer(int exit_value)
Initiates shutdown procedure for the whole DHCPv6 server.
static ControlledDhcpv6Srv * getInstance()
Returns pointer to the sole instance of Dhcpv6Srv.
isc::data::ConstElementPtr loadConfigFile(const std::string &file_name)
Configure DHCPv6 server using the configuration file specified.
static isc::data::ConstElementPtr checkConfig(isc::data::ConstElementPtr config)
Configuration checker.
isc::data::ConstElementPtr commandInterfaceListHandler(const std::string &command, isc::data::ConstElementPtr args)
Handler for processing 'interface-list' command.
isc::data::ConstElementPtr commandSubnet6SelectTestHandler(const std::string &command, isc::data::ConstElementPtr args)
Handler for processing 'subnet6-select-test' command.
ControlledDhcpv6Srv(uint16_t server_port=DHCP6_SERVER_PORT, uint16_t client_port=0)
Constructor.
isc::data::ConstElementPtr commandDhcpDisableHandler(const std::string &command, isc::data::ConstElementPtr args)
A handler for processing 'dhcp-disable' command.
isc::data::ConstElementPtr commandConfigTestHandler(const std::string &command, isc::data::ConstElementPtr args)
handler for processing 'config-test' command
virtual void open()
Open communication socket.
static Dhcp6to4Ipc & instance()
Returns pointer to the sole instance of Dhcp6to4Ipc.
void shutdown() override
Instructs the server to shut down.
Definition dhcp6_srv.cc:371
boost::shared_ptr< AllocEngine > alloc_engine_
Allocation Engine.
Definition dhcp6_srv.h:1264
uint16_t getServerPort() const
Get UDP port on which server should listen.
NetworkStatePtr & getNetworkState()
Returns pointer to the network state used by the server.
Definition dhcp6_srv.h:115
NetworkStatePtr network_state_
Holds information about disabled DHCP service and/or disabled subnet/network scopes.
Definition dhcp6_srv.h:1272
Dhcpv6Srv(uint16_t server_port=DHCP6_SERVER_PORT, uint16_t client_port=0)
Default constructor.
Definition dhcp6_srv.cc:272
static std::string getVersion(bool extended)
returns Kea version on stdout and exit.
asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service used by the server.
Definition dhcp6_srv.h:110
volatile bool shutdown_
Indicates if shutdown is in progress.
Definition dhcp6_srv.h:1248
void startD2()
Starts DHCP_DDNS client IO if DDNS updates are enabled.
static void create()
Creates new instance of the HostMgr.
Definition host_mgr.cc:52
size_t size() const
Return the number of interfaces.
Definition iface_mgr.h:635
const IfaceCollection & getIfaces()
Returns container with all interfaces.
Definition iface_mgr.h:942
void detectIfaces(bool update_only=false)
Detects network interfaces.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
Definition iface_mgr.cc:52
Parser for the configuration of interfaces.
void parseInterfacesList(const CfgIfacePtr &cfg_iface, isc::data::ConstElementPtr ifaces_list)
parses interfaces-list structure
static TrackingLeaseMgr & instance()
Return current lease manager.
static bool init_allocators_
Flag which indicates if allocators must be initialized.
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.
Definition libdhcp++.cc:248
Concrete implementation of a lease database backend using flat file.
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_DHCP6
This parser will parse the content as Dhcp6 config wrapped in a map (that's the regular config file).
RAII class creating a critical section for the receiver thread.
Definition iface_mgr.h:1867
Manages a pool of asynchronous interval timers.
Definition timer_mgr.h:62
static const TimerMgrPtr & instance()
Returns pointer to the sole instance of the TimerMgr.
Definition timer_mgr.cc:446
@ 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.
Definition daemon.cc:107
virtual size_t writeConfigFile(const std::string &config_file, isc::data::ConstElementPtr cfg=isc::data::ConstElementPtr()) const
Writes current configuration to specified file.
Definition daemon.cc:269
isc::asiolink::IOSignalSetPtr signal_set_
A pointer to the object installing custom signal handlers.
Definition daemon.h:272
boost::posix_time::ptime start_
Timestamp of the start of the daemon.
Definition daemon.h:278
void checkWriteConfigFile(std::string &file)
Checks the to-be-written configuration file name.
Definition daemon.cc:132
void setExitValue(int value)
Sets the exit value.
Definition daemon.h:242
isc::data::ConstElementPtr redactConfig(isc::data::ConstElementPtr const &config)
Redact a configuration.
Definition daemon.cc:297
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.
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 ...
Dhcp4Hooks Hooks
Definition dhcp4_srv.cc:213
@ D6O_INTERFACE_ID
Definition dhcp6.h:38
@ D6O_SERVERID
Definition dhcp6.h:22
Defines the Dhcp6to4Ipc class.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
isc::data::ConstElementPtr statisticSetMaxSampleCountAllHandler(const isc::data::ConstElementPtr &params)
Handles statistic-sample-count-set-all command.
static isc::data::ConstElementPtr statisticResetHandler(const std::string &name, const isc::data::ConstElementPtr &params)
Handles statistic-reset command.
static isc::data::ConstElementPtr statisticGetAllHandler(const std::string &name, const isc::data::ConstElementPtr &params)
Handles statistic-get-all command.
static isc::data::ConstElementPtr statisticRemoveHandler(const std::string &name, const isc::data::ConstElementPtr &params)
Handles statistic-remove command.
static isc::data::ConstElementPtr statisticGetHandler(const std::string &name, const isc::data::ConstElementPtr &params)
Handles statistic-get command.
static isc::data::ConstElementPtr statisticGlobalGetAllHandler(const std::string &name, const isc::data::ConstElementPtr &params)
Handles statistic-global-get-all command.
isc::data::ConstElementPtr statisticSetMaxSampleAgeAllHandler(const isc::data::ConstElementPtr &params)
Handles statistic-sample-age-set-all command.
static isc::data::ConstElementPtr statisticResetAllHandler(const std::string &name, const isc::data::ConstElementPtr &params)
Handles statistic-reset-all command.
static isc::data::ConstElementPtr statisticSetMaxSampleAgeHandler(const std::string &name, const isc::data::ConstElementPtr &params)
Handles statistic-sample-age-set command.
static isc::data::ConstElementPtr statisticRemoveAllHandler(const std::string &name, const isc::data::ConstElementPtr &params)
Handles statistic-remove-all command.
static isc::data::ConstElementPtr statisticSetMaxSampleCountHandler(const std::string &name, const isc::data::ConstElementPtr &params)
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.
Definition macros.h:32
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition macros.h:20
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
Definition macros.h:26
#define LOG_FATAL(LOGGER, MESSAGE)
Macro to conveniently test fatal output and log it.
Definition macros.h:38
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition macros.h:14
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_FATAL_ERROR
Status code indicating that the command was unsuccessful and the configuration could not be reverted ...
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
@ error
Definition db_log.h:124
std::string getConfigReport()
Definition cfgrpt.cc:20
const isc::log::MessageID DHCP6_DB_RECONNECT_NO_DB_CTL
const isc::log::MessageID DHCP6_OPEN_SOCKETS_NO_RECONNECT_CTL
const isc::log::MessageID DHCP6_USING_SERVERID
const isc::log::MessageID DHCP6_CONFIG_LOAD_FAIL
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
Definition subnet.h:620
const isc::log::MessageID DHCP6_DB_RECONNECT_SUCCEEDED
isc::data::ConstElementPtr configureDhcp6Server(Dhcpv6Srv &server, isc::data::ConstElementPtr config_set, bool check_only, bool extra_checks)
Configure DHCPv6 server (Dhcpv6Srv) with a set of configuration values.
const isc::log::MessageID DHCP6_RECLAIM_EXPIRED_LEASES_SKIPPED
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
boost::shared_ptr< Iface > IfacePtr
Type definition for the pointer to an Iface object.
Definition iface_mgr.h:555
boost::shared_ptr< DUID > DuidPtr
Definition duid.h:136
const int DBG_DHCP6_COMMAND
Debug level used to log receiving commands.
Definition dhcp6_log.h:28
const isc::log::MessageID DHCP6_CB_PERIODIC_FETCH_UPDATES_FAIL
const isc::log::MessageID DHCP6_RECLAIM_EXPIRED_LEASES_FAIL
boost::shared_ptr< CfgIface > CfgIfacePtr
A pointer to the CfgIface .
Definition cfg_iface.h:522
const isc::log::MessageID DHCP6_OPEN_SOCKETS_FAILED
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION_SUCCESS
const isc::log::MessageID DHCP6_CB_ON_DEMAND_FETCH_UPDATES_FAIL
const isc::log::MessageID DHCP6_CB_PERIODIC_FETCH_UPDATES_RETRIES_EXHAUSTED
const isc::log::MessageID DHCP6_NOT_RUNNING
boost::shared_ptr< SharedNetwork6 > SharedNetwork6Ptr
Pointer to SharedNetwork6 object.
const isc::log::MessageID DHCP6_FATAL_OPEN_SOCKETS_FAILED
const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION_FAIL
const isc::log::MessageID DHCP6_CONFIG_UNSUPPORTED_OBJECT
const isc::log::MessageID DHCP6_CONFIG_UNRECOVERABLE_ERROR
const isc::log::MessageID DHCP6_CONFIG_RECEIVED
const isc::log::MessageID DHCP6_DB_RECONNECT_DISABLED
const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION
const isc::log::MessageID DHCP6_DB_RECONNECT_LOST_CONNECTION
const int DBG_DHCP6_BASIC
Debug level used to trace basic operations within the code.
Definition dhcp6_log.h:31
isc::log::Logger dhcp6_logger(DHCP6_APP_LOGGER_NAME)
Base logger for DHCPv6 server.
Definition dhcp6_log.h:88
const isc::log::MessageID DHCP6_MULTI_THREADING_INFO
const isc::log::MessageID DHCP6_DB_RECONNECT_FAILED
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
const isc::log::MessageID DHCP6_CONFIG_PACKET_QUEUE
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.
Definition observation.h:49
void decodeFormattedHexString(const string &hex_string, vector< uint8_t > &binary)
Converts a formatted string of hexadecimal digits into a vector.
Definition str.cc:212
vector< uint8_t > quotedStringToBinary(const string &quoted_string)
Converts a string in quotes into vector.
Definition str.cc:139
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.
std::string iface_name_
Name of the interface on which the message was received.
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.