Kea: host_cache.cc Source File

| Kea 3.2.0-git

host_cache.cc
Go to the documentation of this file.
1// Copyright (C) 2020-2025 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
9#include <host_cache.h>
10#include <host_cache_impl.h>
11#include <host_cache_parsers.h>
12#include <host_cache_log.h>
13#include <database/db_exceptions.h>
14#include <dhcpsrv/cfgmgr.h>
15#include <util/encode/encode.h>
16#include <util/filesystem.h>
17#include <util/multi_threading_mgr.h>
18#include <util/str.h>
19#include <string>
20#include <sstream>
21#include <fstream>
22
23using namespace std;
24using namespace isc::asiolink;
25using namespace isc::config;
26using namespace isc::data;
27using namespace isc::db;
28using namespace isc::dhcp;
29using namespace isc::util;
30using namespace isc::util::file;
31
32namespace isc {
33namespace host_cache {
34
35HostCache::HostCache() : impl_(new HostCacheImpl()), mutex_(new std::mutex) {
36}
37
38HostCache::~HostCache() {
39 impl_.reset();
40}
41
42 void HostCache::configure(const ConstElementPtr&config) {
43 HCConfigParser parser;
44 parser.parse(*this, config);
45}
46
47 void HostCache::setMaximum(size_t maximum) {
48 MultiThreadingLock lock(*mutex_);
49 impl_->setMaximum(maximum);
50}
51
52 size_t HostCache::getMaximum() const {
53 MultiThreadingLock lock(*mutex_);
54 return (impl_->getMaximum());
55}
56
57 ConstHostCollection
58HostCache::getAll(const Host::IdentifierType& /*identifier_type*/,
59 const uint8_t* /*identifier_begin*/,
60 const size_t /*identifier_len*/) const {
61 return (ConstHostCollection());
62}
63
64 ConstHostCollection
65HostCache::getAll4(const dhcp::SubnetID& /*subnet_id*/) const {
66 return (ConstHostCollection());
67}
68
69 ConstHostCollection
70HostCache::getAll6(const dhcp::SubnetID& /*subnet_id*/) const {
71 return (ConstHostCollection());
72}
73
74 ConstHostCollection
75HostCache::getAllbyHostname(const std::string& /*hostname*/) const {
76 return (ConstHostCollection());
77}
78
79 ConstHostCollection
80HostCache::getAllbyHostname4(const std::string& /*hostname*/,
81 const dhcp::SubnetID& /*subnet_id*/) const {
82 return (ConstHostCollection());
83}
84
85 ConstHostCollection
86HostCache::getAllbyHostname6(const std::string& /*hostname*/,
87 const dhcp::SubnetID& /*subnet_id*/) const {
88 return (ConstHostCollection());
89}
90
91 dhcp::ConstHostCollection
92HostCache::getPage4(const dhcp::SubnetID& /*subnet_id*/,
93 size_t& /*source_index*/,
94 uint64_t /*lower_host_id*/,
95 const dhcp::HostPageSize& /*page_size*/) const {
96 return (ConstHostCollection());
97}
98
99 dhcp::ConstHostCollection
100HostCache::getPage6(const dhcp::SubnetID& /*subnet_id*/,
101 size_t& /*source_index*/,
102 uint64_t /*lower_host_id*/,
103 const dhcp::HostPageSize& /*page_size*/) const {
104 return (ConstHostCollection());
105}
106
107 dhcp::ConstHostCollection
108 HostCache::getPage4(size_t& /*source_index*/,
109 uint64_t /*lower_host_id*/,
110 const dhcp:: HostPageSize& /*page_size*/) const {
111 return (ConstHostCollection());
112}
113
114 dhcp::ConstHostCollection
115 HostCache::getPage6(size_t& /*source_index*/,
116 uint64_t /*lower_host_id*/,
117 const dhcp::HostPageSize& /*page_size*/) const {
118 return (ConstHostCollection());
119}
120
121 ConstHostCollection
122 HostCache::getAll4(const asiolink::IOAddress& /*address*/) const {
123 return (ConstHostCollection());
124}
125
126 ConstHostPtr
127HostCache::get4(const dhcp::SubnetID& subnet_id,
128 const dhcp::Host::IdentifierType& identifier_type,
129 const uint8_t* identifier_begin,
130 const size_t identifier_len) const {
131 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_TRACE,
132 HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER)
133 .arg("IPv4")
134 .arg(subnet_id)
135 .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
136 identifier_len));
137
138 ConstHostPtr host;
139 {
140 MultiThreadingLock lock(*mutex_);
141 host = impl_->get4(subnet_id, identifier_type,
142 identifier_begin, identifier_len);
143 }
144 if (host) {
145 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS,
146 HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER_HOST)
147 .arg(subnet_id)
148 .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
149 identifier_len))
150 .arg(host->toText());
151 }
152 return (host);
153}
154
155 ConstHostPtr
156 HostCache::get4(const dhcp::SubnetID& subnet_id,
157 const asiolink::IOAddress& address) const {
158 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_TRACE,
159 HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS4)
160 .arg(subnet_id)
161 .arg(address.toText());
162
163 // Must not specify address other than IPv4.
164 if (!address.isV4()) {
165 return (ConstHostPtr());
166 }
167 ConstHostPtr host;
168 {
169 MultiThreadingLock lock(*mutex_);
170 host = impl_->get4(subnet_id, address);
171 }
172 if (host) {
173 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS,
174 HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS4_HOST)
175 .arg(subnet_id)
176 .arg(address.toText())
177 .arg(host->toText());
178 }
179 return (host);
180}
181
182 ConstHostCollection
183 HostCache::getAll4(const dhcp::SubnetID& /*subnet_id*/,
184 const asiolink::IOAddress& /*address*/) const {
185 return (ConstHostCollection());
186}
187
188 ConstHostPtr
189HostCache::get6(const dhcp::SubnetID& subnet_id,
190 const dhcp::Host::IdentifierType& identifier_type,
191 const uint8_t* identifier_begin,
192 const size_t identifier_len) const {
193 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_TRACE,
194 HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER)
195 .arg("IPv6")
196 .arg(subnet_id)
197 .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
198 identifier_len));
199
200 ConstHostPtr host;
201 {
202 MultiThreadingLock lock(*mutex_);
203 host = impl_->get6(subnet_id, identifier_type,
204 identifier_begin, identifier_len);
205 }
206 if (host) {
207 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS,
208 HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER_HOST)
209 .arg(subnet_id)
210 .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
211 identifier_len))
212 .arg(host->toText());
213 }
214 return (host);
215}
216
217 ConstHostPtr
218 HostCache::get6(const asiolink::IOAddress& prefix,
219 const uint8_t prefix_len) const {
220 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_TRACE,
221 HOST_CACHE_GET_ONE_PREFIX)
222 .arg(prefix.toText())
223 .arg(static_cast<int>(prefix_len));
224
225 ConstHostPtr host;
226 {
227 MultiThreadingLock lock(*mutex_);
228 host = impl_->get6(prefix, prefix_len);
229 }
230 if (host) {
231 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS,
232 HOST_CACHE_GET_ONE_PREFIX_HOST)
233 .arg(prefix.toText())
234 .arg(static_cast<int>(prefix_len))
235 .arg(host->toText());
236 }
237 return (host);
238}
239
240 ConstHostPtr
241 HostCache::get6(const dhcp::SubnetID& subnet_id,
242 const asiolink::IOAddress& address) const {
243 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_TRACE,
244 HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS6)
245 .arg(subnet_id)
246 .arg(address.toText());
247
248 // Must not specify address other than IPv6.
249 if (!address.isV6()) {
250 return (ConstHostPtr());
251 }
252
253 ConstHostPtr host;
254 {
255 MultiThreadingLock lock(*mutex_);
256 host = impl_->get6(subnet_id, address);
257 }
258 if (host) {
259 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS,
260 HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS6_HOST)
261 .arg(subnet_id)
262 .arg(address.toText())
263 .arg(host->toText());
264 }
265 return (host);
266}
267
268 ConstHostCollection
269 HostCache::getAll6(const dhcp::SubnetID& /*subnet_id*/,
270 const asiolink::IOAddress& /*address*/) const {
271 return (ConstHostCollection());
272}
273
274 ConstHostCollection
275 HostCache::getAll6(const IOAddress& /*address*/) const {
276 return (ConstHostCollection());
277}
278
279void
280HostCache::add(const HostPtr& host) {
281 if (!host) {
282 return;
283 }
284
285 // At least one subnet ID must be used.
286 if (host->getIPv4SubnetID() == SUBNET_ID_UNUSED &&
287 host->getIPv6SubnetID() == SUBNET_ID_UNUSED) {
288 return;
289 }
290
291 bool ret;
292 {
293 MultiThreadingLock lock(*mutex_);
294 ret = impl_->add(host);
295 }
296 if (ret) {
297 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS, HOST_CACHE_ADD)
298 .arg(host->toText());
299 } else {
300 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS,
301 HOST_CACHE_ADD_DUPLICATE)
302 .arg(host->toText());
303 isc_throw(DuplicateEntry, "Host cache duplicate entry error");
304 }
305}
306
307bool
308HostCache::del(const SubnetID& subnet_id, const IOAddress& addr) {
309 string txt;
310 if (addr.isV4()) {
311 {
312 MultiThreadingLock lock(*mutex_);
313 txt = impl_->del4(subnet_id, addr);
314 }
315 if (!txt.empty()) {
316 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS,
317 HOST_CACHE_DEL_SUBNET_ID_ADDRESS4)
318 .arg(subnet_id)
319 .arg(addr.toText())
320 .arg(txt);
321 }
322 } else if (addr.isV6()) {
323 {
324 MultiThreadingLock lock(*mutex_);
325 txt = impl_->del6(subnet_id, addr);
326 }
327 if (!txt.empty()) {
328 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS,
329 HOST_CACHE_DEL_SUBNET_ID_ADDRESS6)
330 .arg(subnet_id)
331 .arg(addr.toText())
332 .arg(txt);
333 }
334 }
335 return (false);
336}
337
338bool
339HostCache::del4(const SubnetID& subnet_id,
340 const Host::IdentifierType& identifier_type,
341 const uint8_t* identifier_begin,
342 const size_t identifier_len) {
343 string txt;
344 {
345 MultiThreadingLock lock(*mutex_);
346 txt = impl_->del4(subnet_id, identifier_type,
347 identifier_begin, identifier_len);
348 }
349 if (!txt.empty()) {
350 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS,
351 HOST_CACHE_DEL_SUBNET_ID_IDENTIFIER4)
352 .arg(subnet_id)
353 .arg(Host::getIdentifierAsText(identifier_type,
354 identifier_begin,
355 identifier_len))
356 .arg(txt);
357 }
358 return (false);
359}
360
361bool
362HostCache::del6(const SubnetID& subnet_id,
363 const Host::IdentifierType& identifier_type,
364 const uint8_t* identifier_begin,
365 const size_t identifier_len) {
366 string txt;
367 {
368 MultiThreadingLock lock(*mutex_);
369 txt = impl_->del6(subnet_id, identifier_type,
370 identifier_begin, identifier_len);
371 }
372 if (!txt.empty()) {
373 LOG_DEBUG(host_cache_logger, HOST_CACHE_DBG_RESULTS,
374 HOST_CACHE_DEL_SUBNET_ID_IDENTIFIER6)
375 .arg(subnet_id)
376 .arg(Host::getIdentifierAsText(identifier_type,
377 identifier_begin,
378 identifier_len))
379 .arg(txt);
380 }
381 return (false);
382}
383
384void
385HostCache::update(HostPtr const& host) {
386 MultiThreadingLock lock(*mutex_);
387 impl_->update(host);
388}
389
390bool
391HostCache::setIPReservationsUnique(const bool unique) {
392 // This backend does not support the mode in which multiple reservations
393 // for the same IP address are created. If selecting this mode is
394 // attempted this function returns false to indicate that this is
395 // not allowed.
396 return (unique);
397}
398
399 ElementPtr
400HostCache::toElement() const {
401 MultiThreadingLock lock(*mutex_);
402 return (impl_->toElement());
403}
404
405size_t
406HostCache::insert(const ConstHostPtr& host, bool overwrite) {
407 MultiThreadingLock lock(*mutex_);
408 return (impl_->insert(host, overwrite));
409}
410
411bool
412HostCache::remove(const HostPtr& host) {
413 MultiThreadingLock lock(*mutex_);
414 return (impl_->remove(host));
415}
416
417void
418HostCache::flush(size_t count) {
419 MultiThreadingLock lock(*mutex_);
420 if (count == 0) {
421 impl_->clear();
422 } else {
423 impl_->flush(count);
424 }
425}
426
427size_t
428HostCache::size() const {
429 MultiThreadingLock lock(*mutex_);
430 return (impl_->size());
431}
432
433size_t
434HostCache::capacity() const {
435 MultiThreadingLock lock(*mutex_);
436 return (impl_->capacity());
437}
438
439 ConstHostCollection
440HostCache::get(const Host::IdentifierType& identifier_type,
441 const uint8_t* identifier_begin,
442 const size_t identifier_len) const {
443 MultiThreadingLock lock(*mutex_);
444 return (impl_->get(identifier_type, identifier_begin, identifier_len));
445}
446
447int
448HostCache::cacheSizeHandler(hooks::CalloutHandle& handle) {
449 size_t count;
450 try {
451 extractCommand(handle);
452
453 MultiThreadingLock lock(*mutex_);
454 count = impl_->size();
455 } catch (const std::exception& ex) {
456 LOG_ERROR(host_cache_logger, HOST_CACHE_COMMAND_SIZE_FAILED)
457 .arg(ex.what());
458 setErrorResponse(handle, ex.what());
459 return (1);
460 }
461
462 LOG_INFO(host_cache_logger, HOST_CACHE_COMMAND_SIZE)
463 .arg(count);
464 ostringstream msg;
465 msg << count << " entries.";
466 ElementPtr result = Element::createMap();
467 result->set("size", Element::create(static_cast<int64_t>(count)));
468 ConstElementPtr response =
469 createAnswer(CONTROL_RESULT_SUCCESS, msg.str(), result);
470 setResponse(handle, response);
471 return (0);
472}
473
474int
475HostCache::cacheClearHandler(hooks::CalloutHandle& handle) {
476 MultiThreadingCriticalSection cs;
477
478 try {
479 extractCommand(handle);
480
481 impl_->clear();
482 } catch (const std::exception& ex) {
483 LOG_ERROR(host_cache_logger, HOST_CACHE_COMMAND_CLEAR_FAILED)
484 .arg(ex.what());
485 setErrorResponse(handle, ex.what());
486 return (1);
487 }
488
489 LOG_INFO(host_cache_logger, HOST_CACHE_COMMAND_CLEAR);
490 setSuccessResponse(handle, "Cache cleared.");
491 return (0);
492}
493
494int
495HostCache::cacheFlushHandler(hooks::CalloutHandle& handle) {
496 MultiThreadingCriticalSection cs;
497
498 size_t how_many = 0;
499 size_t before = impl_->size();
500 string txt = "(missing parameters)";
501 try {
502 extractCommand(handle);
503 if (cmd_args_) {
504 txt = cmd_args_->str();
505 }
506
507 if (!cmd_args_) {
508 isc_throw(BadValue, "no parameters specified for the command");
509 }
510
511 int64_t val = cmd_args_->intValue();
512
513 if (val == 0) {
514 isc_throw(BadValue, "invalid (0) parameter: "
515 "please use cache-clear command");
516 }
517
518 if (val < 0) {
519 isc_throw(BadValue, "invalid (<0) parameter");
520 }
521
522 if (val > HCConfigParser::MAXIMUM) {
523 val = HCConfigParser::MAXIMUM + 1;
524 }
525
526 how_many = static_cast<size_t>(val);
527 impl_->flush(how_many);
528 } catch (const std::exception& ex) {
529 LOG_ERROR(host_cache_logger, HOST_CACHE_COMMAND_FLUSH_FAILED)
530 .arg(txt)
531 .arg(ex.what());
532 setErrorResponse(handle, ex.what());
533 return (1);
534 }
535
536 LOG_INFO(host_cache_logger, HOST_CACHE_COMMAND_FLUSH);
537 ostringstream msg;
538 msg << "Cache flushed (" << before - impl_->size() << " entries removed).";
539 setSuccessResponse(handle, msg.str());
540 return (0);
541}
542
543int
544HostCache::cacheGetHandler(hooks::CalloutHandle& handle) {
545 MultiThreadingCriticalSection cs;
546
547 ConstElementPtr dump;
548 size_t count = 0;
549 try {
550 extractCommand(handle);
551
552 dump = impl_->toElement();
553 count = dump->size();
554 } catch (const std::exception& ex) {
555 LOG_ERROR(host_cache_logger, HOST_CACHE_COMMAND_GET_FAILED)
556 .arg(ex.what());
557 setErrorResponse(handle, ex.what());
558 return (1);
559 }
560
561 LOG_INFO(host_cache_logger, HOST_CACHE_COMMAND_GET)
562 .arg(count);
563 ostringstream msg;
564 msg << count << " entries returned.";
565 ConstElementPtr response =
566 createAnswer(count > 0 ? CONTROL_RESULT_SUCCESS : CONTROL_RESULT_EMPTY,
567 msg.str(), dump);
568 setResponse(handle, response);
569 return (0);
570}
571
572int
573HostCache::cacheGetByIdHandler(hooks::CalloutHandle& handle) {
574 Host::IdentifierType id_type;
575 vector<uint8_t> ident;
576 string txt = "(missing parameters)";
577 ElementPtr result = Element::createList();
578 size_t count = 0;
579 try {
580 extractCommand(handle);
581 if (cmd_args_) {
582 txt = cmd_args_->str();
583 }
584
585 if (!cmd_args_) {
586 isc_throw(BadValue, "no parameters specified for the command");
587 }
588
589 if (cmd_args_->getType() != Element::map) {
590 isc_throw(BadValue, "invalid (not a map) parameter");
591 }
592
593 // Take parameters.
594 string ident_txt;
595 unsigned have_ident = 0;
596 auto& map = cmd_args_->mapValue();
597 for (auto const& cfg : map) {
598 if (cfg.first == "hw-address") {
599 id_type = Host::IDENT_HWADDR;
600 ++have_ident;
601 ident_txt = cfg.second->stringValue();
602 } else if (cfg.first == "duid") {
603 id_type= Host::IDENT_DUID;
604 ++have_ident;
605 ident_txt = cfg.second->stringValue();
606 } else if (cfg.first == "circuit-id") {
607 id_type= Host::IDENT_CIRCUIT_ID;
608 ++have_ident;
609 ident_txt = cfg.second->stringValue();
610 } else if (cfg.first == "client-id") {
611 id_type= Host::IDENT_CLIENT_ID;
612 ++have_ident;
613 ident_txt = cfg.second->stringValue();
614 } else if (cfg.first == "flex-id") {
615 id_type= Host::IDENT_FLEX;
616 ++have_ident;
617 ident_txt = cfg.second->stringValue();
618 } else {
619 isc_throw(BadValue,
620 "unknown parameter '" << cfg.first << "'");
621 }
622 }
623
624 // Decode parameters.
625 if (have_ident == 0) {
626 isc_throw(BadValue, "an identifier is required");
627 }
628 if (have_ident > 1) {
629 isc_throw(BadValue, "only one identifier can be specified");
630 }
631 if (ident_txt.empty()) {
632 isc_throw(BadValue, "invalid (empty) identifier");
633 }
634 try {
635 ident = util::str::quotedStringToBinary(ident_txt);
636 if (ident.empty()) {
637 util::str::decodeFormattedHexString(ident_txt, ident);
638 }
639 } catch (...) {
640 isc_throw(BadValue, "invalid identifier '" << ident_txt << "'");
641 }
642
643 // Get the entry list and build the result.
644 ConstHostCollection hosts;
645 {
646 MultiThreadingLock lock(*mutex_);
647 hosts = impl_->get(id_type, &ident[0], ident.size());
648 }
649 for (auto const& host : hosts) {
650 result->add(host_cache::toElement(host));
651 }
652 count = result->size();
653 } catch (const std::exception& ex) {
654 LOG_ERROR(host_cache_logger, HOST_CACHE_COMMAND_GET_BY_ID_FAILED)
655 .arg(ex.what());
656 setErrorResponse(handle, ex.what());
657 return (1);
658 }
659
660 LOG_INFO(host_cache_logger, HOST_CACHE_COMMAND_GET_BY_ID)
661 .arg(count);
662 ostringstream msg;
663 msg << count << " entries returned.";
664 ConstElementPtr response =
665 createAnswer(count ? CONTROL_RESULT_SUCCESS : CONTROL_RESULT_EMPTY,
666 msg.str(), result);
667 setResponse(handle, response);
668 return (0);
669}
670
671int
672HostCache::cacheInsertHandler(hooks::CalloutHandle& handle) {
673 string filename;
674 size_t count = 0;
675 size_t overwritten = 0;
676 string txt = "(missing parameters)";
677 try {
678 extractCommand(handle);
679 if (cmd_args_) {
680 txt = cmd_args_->str();
681 }
682
683 if (!cmd_args_) {
684 isc_throw(BadValue, "no parameters specified for the command");
685 }
686
687 if (cmd_args_->getType() == Element::map) {
688 HCEntryParser parser;
689 HostPtr entry = parser.parse(cmd_args_);
690
691 ++count;
692 try {
693 MultiThreadingLock lock(*mutex_);
694 overwritten += impl_->insert(entry, true);
695 } catch (const std::exception& ex) {
696 isc_throw(BadValue,
697 "Insert host (" << entry->toText()
698 << ") failed: " << ex.what());
699 }
700 } else {
701 HCEntryListParser parser;
702 HostCollection entries = parser.parse(cmd_args_);
703
704 for (auto const& entry : entries) {
705 ++count;
706 try {
707 MultiThreadingLock lock(*mutex_);
708 overwritten += impl_->insert(entry, true);
709 } catch (const std::exception& ex) {
710 isc_throw(BadValue, "Insert failed at " << count
711 << " host (" << entry->toText()
712 << "): " << ex.what());
713 }
714 }
715 }
716 } catch (const std::exception& ex) {
717 LOG_ERROR(host_cache_logger, HOST_CACHE_COMMAND_INSERT_FAILED)
718 .arg(txt)
719 .arg(ex.what());
720 setErrorResponse(handle, ex.what());
721 return (1);
722 }
723
724 LOG_INFO(host_cache_logger, HOST_CACHE_COMMAND_INSERT)
725 .arg(count)
726 .arg(overwritten);
727 ostringstream msg;
728 msg << count << " entries inserted (" << overwritten
729 << " overwritten by more recent entries).";
730 setSuccessResponse(handle, msg.str());
731 return (0);
732}
733
734int
735HostCache::cacheWriteHandler(hooks::CalloutHandle& handle) {
736 MultiThreadingCriticalSection cs;
737
738 ConstElementPtr dump;
739 string filename;
740 size_t count = 0;
741 string txt = "(missing parameters)";
742 try {
743 extractCommand(handle);
744 if (cmd_args_) {
745 txt = cmd_args_->str();
746 }
747
748 if (!cmd_args_) {
749 isc_throw(BadValue, "no parameters specified for the command");
750 }
751
752 if (cmd_args_->getType() != Element::string) {
753 isc_throw(BadValue, "invalid (not a string) parameter");
754 }
755
756 try {
757 filename = CfgMgr::instance().validatePath(cmd_args_->stringValue());
758 } catch (const SecurityWarn& ex) {
759 LOG_WARN(host_cache_logger, HOST_CACHE_PATH_SECURITY_WARNING)
760 .arg(ex.what());
761 filename = cmd_args_->stringValue();
762 } catch (const std::exception& ex) {
763 isc_throw(BadValue, "parameter is invalid: " << ex.what());
764 }
765
766 ofstream out(filename, ios::trunc);
767 if (!out.good()) {
768 isc_throw(Unexpected, "Unable to open file '" << filename
769 << "' for writing.");
770 }
771
772 dump = impl_->toElement();
773 count = dump->size();
774 prettyPrint(dump, out);
775 out.close();
776 } catch (const std::exception& ex) {
777 LOG_ERROR(host_cache_logger, HOST_CACHE_COMMAND_WRITE_FAILED)
778 .arg(txt)
779 .arg(ex.what());
780 setErrorResponse(handle, ex.what());
781 return (1);
782 }
783
784 LOG_INFO(host_cache_logger, HOST_CACHE_COMMAND_WRITE)
785 .arg(count);
786 ostringstream msg;
787 msg << count << " entries dumped to '" << filename << "'.";
788 setSuccessResponse(handle, msg.str());
789 return (0);
790}
791
792int
793HostCache::cacheLoadHandler(hooks::CalloutHandle& handle) {
794 MultiThreadingCriticalSection cs;
795
796 string filename;
797 size_t count = 0;
798 size_t overwritten = 0;
799 string txt = "(missing parameters)";
800 try {
801 extractCommand(handle);
802 if (cmd_args_) {
803 txt = cmd_args_->str();
804 }
805
806 if (!cmd_args_) {
807 isc_throw(BadValue, "no parameters specified for the command");
808 }
809
810 if (cmd_args_->getType() != Element::string) {
811 isc_throw(BadValue, "invalid (not a string) parameter");
812 }
813
814 filename = cmd_args_->stringValue();
815 if (filename.empty()) {
816 isc_throw(BadValue, "invalid (empty string) parameter");
817 }
818
819 ConstElementPtr json = Element::fromJSONFile(filename);
820 if (!json) {
821 isc_throw(Unexpected, "No entries found.");
822 }
823 HCEntryListParser parser;
824 HostCollection entries = parser.parse(json);
825
826 for (auto const& entry : entries) {
827 ++count;
828 try {
829 overwritten += impl_->insert(entry, true);
830 } catch (const std::exception& ex) {
831 isc_throw(BadValue, "Insert failed at " << count
832 << " host ( " << entry->toText()
833 << "): " << ex.what());
834 }
835 }
836 } catch (const std::exception& ex) {
837 LOG_ERROR(host_cache_logger, HOST_CACHE_COMMAND_LOAD_FAILED)
838 .arg(txt)
839 .arg(ex.what());
840 setErrorResponse(handle, ex.what());
841 return (1);
842 }
843
844 LOG_INFO(host_cache_logger, HOST_CACHE_COMMAND_LOAD)
845 .arg(count)
846 .arg(overwritten);
847 ostringstream msg;
848 msg << count << " entries loaded from '" << filename << "' ("
849 << overwritten << " overwritten by more recent entries).";
850 setSuccessResponse(handle, msg.str());
851 return (0);
852}
853
854int
855HostCache::cacheRemoveHandler(hooks::CalloutHandle& handle) {
856 uint16_t family = AF_UNIX;
857 SubnetID subnet_id;
858 string addr_txt;
859 Host::IdentifierType id_type;
860 vector<uint8_t> ident;
861 string txt = "(missing parameters)";
862 string del_txt;
863 try {
864 extractCommand(handle);
865 if (cmd_args_) {
866 txt = cmd_args_->str();
867 }
868
869 if (!cmd_args_) {
870 isc_throw(BadValue, "no parameters specified for the command");
871 }
872
873 if (cmd_args_->getType() != Element::map) {
874 isc_throw(BadValue, "invalid (not a map) parameter");
875 }
876
877 // Take parameters.
878 string ident_txt;
879 bool have_ident = false;
880 bool valid = true;
881 auto& map = cmd_args_->mapValue();
882 for (auto const& cfg : map) {
883 if (cfg.first == "subnet-id") {
884 if (family != AF_UNIX) {
885 valid = false;
886 }
887 family = AF_UNSPEC;
888 subnet_id = static_cast<uint32_t>(cfg.second->intValue());
889 } else if (cfg.first == "subnet-id4") {
890 if (family != AF_UNIX) {
891 valid = false;
892 }
893 family = AF_INET;
894 subnet_id = static_cast<uint32_t>(cfg.second->intValue());
895 } else if (cfg.first == "subnet-id6") {
896 if (family != AF_UNIX) {
897 valid = false;
898 }
899 family = AF_INET6;
900 subnet_id = static_cast<uint32_t>(cfg.second->intValue());
901 } else if (cfg.first == "ip-address") {
902 addr_txt = cfg.second->stringValue();
903 } else if (cfg.first == "hw-address") {
904 id_type = Host::IDENT_HWADDR;
905 if (have_ident) {
906 valid = false;
907 }
908 have_ident = true;
909 ident_txt = cfg.second->stringValue();
910 } else if (cfg.first == "duid") {
911 id_type= Host::IDENT_DUID;
912 if (have_ident) {
913 valid = false;
914 }
915 have_ident = true;
916 ident_txt = cfg.second->stringValue();
917 } else if (cfg.first == "circuit-id") {
918 id_type= Host::IDENT_CIRCUIT_ID;
919 if (have_ident) {
920 valid = false;
921 }
922 have_ident = true;
923 ident_txt = cfg.second->stringValue();
924 } else if (cfg.first == "client-id") {
925 id_type= Host::IDENT_CLIENT_ID;
926 if (have_ident) {
927 valid = false;
928 }
929 have_ident = true;
930 ident_txt = cfg.second->stringValue();
931 } else if (cfg.first == "flex-id") {
932 id_type= Host::IDENT_FLEX;
933 if (have_ident) {
934 valid = false;
935 }
936 have_ident = true;
937 ident_txt = cfg.second->stringValue();
938 } else {
939 isc_throw(BadValue,
940 "unknown parameter '" << cfg.first << "'");
941 }
942 }
943
944 // Decode parameters.
945 IOAddress addr(0);
946 if (valid && !addr_txt.empty()) {
947 if (have_ident) {
948 valid = false;
949 }
950 if (family == AF_UNIX) {
951 isc_throw(BadValue, "subnet-id is required");
952 }
953 addr = IOAddress(addr_txt);
954 if (addr.isV4()) {
955 if (family == AF_INET6) {
956 valid = false;
957 }
958 if (addr.isV4Zero()) {
959 isc_throw(BadValue, "invalid ip-address '0.0.0.0'");
960 }
961 family = AF_INET;
962 } else if (addr.isV6()) {
963 if (family == AF_INET) {
964 valid = false;
965 }
966 if (addr.isV6Zero()) {
967 isc_throw(BadValue, "invalid ip-address '::'");
968 }
969 family = AF_INET6;
970 } else {
971 isc_throw(Unexpected,
972 "invalid ip-address '" << addr_txt << "'");
973 }
974 } else if (valid) {
975 if (!have_ident) {
976 isc_throw(BadValue,
977 "either ip-address or an identifier is required");
978 }
979 if (ident_txt.empty()) {
980 isc_throw(BadValue, "invalid (empty) identifier");
981 }
982 if ((family != AF_INET) && (family != AF_INET6)) {
983 isc_throw(BadValue,
984 "either subnet-id4 or subnet-id6 is required");
985 }
986 try {
987 ident = util::str::quotedStringToBinary(ident_txt);
988 if (ident.empty()) {
989 util::str::decodeFormattedHexString(ident_txt, ident);
990 }
991 } catch (...) {
992 isc_throw(BadValue,
993 "invalid identifier '" << ident_txt << "'");
994 }
995 }
996
997 // Something is wrong?
998 if (!valid) {
999 isc_throw(BadValue, "inconsistent parameters");
1000 }
1001
1002 // Call del*().
1003 MultiThreadingLock lock(*mutex_);
1004 if (!addr_txt.empty()) {
1005 if (family == AF_INET) {
1006 del_txt = impl_->del4(subnet_id, addr);
1007 } else {
1008 del_txt = impl_->del6(subnet_id, addr);
1009 }
1010 } else if (family == AF_INET) {
1011 del_txt = impl_->del4(subnet_id, id_type, &ident[0], ident.size());
1012 } else {
1013 del_txt = impl_->del6(subnet_id, id_type, &ident[0], ident.size());
1014 }
1015 } catch (const std::exception& ex) {
1016 LOG_ERROR(host_cache_logger, HOST_CACHE_COMMAND_REMOVE_FAILED)
1017 .arg(txt)
1018 .arg(ex.what());
1019 setErrorResponse(handle, ex.what());
1020 return (1);
1021 }
1022
1023 LOG_INFO(host_cache_logger, HOST_CACHE_COMMAND_REMOVE)
1024 .arg(txt);
1025 if (!del_txt.empty()) {
1026 setSuccessResponse(handle, "Host removed.");
1027 } else {
1028 setErrorResponse(handle, "Host not removed (not found).",
1029 CONTROL_RESULT_EMPTY);
1030 }
1031 return (0);
1032}
1033
1034} // end of namespace isc::host_cache
1035} // end of namespace isc
cfgmgr.h
Element::create
static ElementPtr create(const Position &pos=ZERO_POSITION())
Create a NullElement.
Definition data.cc:299
Element::map
@ map
Definition data.h:160
Element::string
@ string
Definition data.h:157
Element::fromJSONFile
static ElementPtr fromJSONFile(const std::string &file_name, bool preproc=false)
Reads contents of specified file and interprets it as JSON.
Definition data.cc:883
Element::createMap
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:354
Element::createList
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition data.cc:349
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition exceptions/exceptions.h:132
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition exceptions/exceptions.cc:32
isc::Unexpected
A generic exception that is thrown when an unexpected error condition occurs.
Definition exceptions/exceptions.h:153
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
isc::asiolink::IOAddress::isV4Zero
bool isV4Zero() const
Convenience function to check if it is an IPv4 zero address.
Definition io_address.h:129
isc::asiolink::IOAddress::toText
std::string toText() const
Convert the address to a string.
Definition io_address.cc:60
isc::asiolink::IOAddress::isV6
bool isV6() const
Convenience function to check for an IPv6 address.
Definition io_address.h:144
isc::asiolink::IOAddress::isV4
bool isV4() const
Convenience function to check for an IPv4 address.
Definition io_address.h:122
isc::asiolink::IOAddress::isV6Zero
bool isV6Zero() const
Convenience function to check if it is an IPv4 zero address.
Definition io_address.h:151
isc::config::CmdsImpl::setErrorResponse
void setErrorResponse(hooks::CalloutHandle &handle, const std::string &text, int status=CONTROL_RESULT_ERROR)
Set the callout argument "response" to indicate an error.
Definition cmds_impl.h:54
isc::config::CmdsImpl::cmd_args_
data::ConstElementPtr cmd_args_
Stores the command arguments extracted by a call to extractCommand.
Definition cmds_impl.h:72
isc::config::CmdsImpl::extractCommand
void extractCommand(hooks::CalloutHandle &handle)
Extracts the command name and arguments from a Callout handle.
Definition cmds_impl.h:29
isc::config::CmdsImpl::setSuccessResponse
void setSuccessResponse(hooks::CalloutHandle &handle, const std::string &text)
Set the callout argument "response" to indicate success.
Definition cmds_impl.h:43
isc::config::CmdsImpl::setResponse
void setResponse(hooks::CalloutHandle &handle, data::ConstElementPtr &response)
Set the callout argument "response" to the given response.
Definition cmds_impl.h:64
isc::db::DuplicateEntry
Database duplicate entry error.
Definition db_exceptions.h:30
isc::dhcp::CfgMgr::validatePath
std::string validatePath(const std::string data_path) const
Validates a file path against the supported directory for DHCP data.
Definition cfgmgr.cc:40
isc::dhcp::CfgMgr::instance
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:29
isc::dhcp::HostPageSize
Wraps value holding size of the page with host reservations.
Definition base_host_data_source.h:53
isc::dhcp::Host::getIdentifierAsText
std::string getIdentifierAsText() const
Returns host identifier in a textual form.
Definition host.cc:319
isc::dhcp::Host::IdentifierType
IdentifierType
Type of the host identifier.
Definition host.h:337
isc::dhcp::Host::IDENT_HWADDR
@ IDENT_HWADDR
Definition host.h:338
isc::dhcp::Host::IDENT_FLEX
@ IDENT_FLEX
Flexible host identifier.
Definition host.h:342
isc::dhcp::Host::IDENT_DUID
@ IDENT_DUID
Definition host.h:339
isc::dhcp::Host::IDENT_CLIENT_ID
@ IDENT_CLIENT_ID
Definition host.h:341
isc::dhcp::Host::IDENT_CIRCUIT_ID
@ IDENT_CIRCUIT_ID
Definition host.h:340
isc::hooks::CalloutHandle
Per-packet callout handle.
Definition callout_handle.h:78
isc::host_cache::HCConfigParser
Configuration parser for Host Cache.
Definition host_cache_parsers.h:20
isc::host_cache::HCConfigParser::MAXIMUM
static const int64_t MAXIMUM
Absolute maximum number of elements.
Definition host_cache_parsers.h:34
isc::host_cache::HCConfigParser::parse
void parse(HostCache &hcref, const data::ConstElementPtr &config)
Parses Host Cache configuration.
Definition host_cache_parsers.cc:30
isc::host_cache::HCEntryListParser
Host cache content parser.
Definition host_cache_parsers.h:51
isc::host_cache::HCEntryListParser::parse
dhcp::HostCollection parse(const data::ConstElementPtr &entry_list)
Parses Host Cache entries.
Definition host_cache_parsers.h:60
isc::host_cache::HCEntryParser
Host cache entry parser.
Definition host_cache_parsers.h:38
isc::host_cache::HCEntryParser::parse
dhcp::HostPtr parse(const data::ConstElementPtr &entry)
Parses Host Cache entry.
Definition host_cache_parsers.cc:62
isc::host_cache::HostCacheImpl
Host Cache hooks library implementation.
Definition host_cache_impl.h:24
isc::host_cache::HostCache::size
virtual size_t size() const
Return the number of entries.
Definition host_cache.cc:428
isc::host_cache::HostCache::configure
virtual void configure(const data::ConstElementPtr &config)
Parses configuration.
Definition host_cache.cc:42
isc::host_cache::HostCache::setIPReservationsUnique
virtual bool setIPReservationsUnique(const bool unique)
Controls whether IP reservations are unique or non-unique.
Definition host_cache.cc:391
isc::host_cache::HostCache::impl_
boost::shared_ptr< HostCacheImpl > impl_
Implementation.
Definition host_cache.h:674
isc::host_cache::HostCache::getMaximum
virtual size_t getMaximum() const
Get maximum number of cached hosts.
Definition host_cache.cc:52
isc::host_cache::HostCache::flush
virtual void flush(size_t count)
Flush entries.
Definition host_cache.cc:418
isc::host_cache::HostCache::cacheLoadHandler
int cacheLoadHandler(hooks::CalloutHandle &handle)
cache-load command handler.
Definition host_cache.cc:793
isc::host_cache::HostCache::getAll
virtual dhcp::ConstHostCollection getAll(const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
BaseHostDataSource methods.
Definition host_cache.cc:58
isc::host_cache::HostCache::del6
virtual bool del6(const dhcp::SubnetID &subnet_id, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)
Attempts to delete a host by (subnet-id6, identifier, identifier-type).
Definition host_cache.cc:362
isc::host_cache::HostCache::del4
virtual bool del4(const dhcp::SubnetID &subnet_id, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)
Attempts to delete a host by (subnet-id4, identifier, identifier-type).
Definition host_cache.cc:339
isc::host_cache::HostCache::getAllbyHostname4
virtual dhcp::ConstHostCollection getAllbyHostname4(const std::string &hostname, const dhcp::SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv4 subnet.
Definition host_cache.cc:80
isc::host_cache::HostCache::~HostCache
virtual ~HostCache()
Destructor.
Definition host_cache.cc:38
isc::host_cache::HostCache::update
void update(isc::dhcp::HostPtr const &host)
Implements isc::dhcp::BaseHostDataSource::update() for HostCache.
Definition host_cache.cc:385
isc::host_cache::HostCache::get6
virtual dhcp::ConstHostPtr get6(const dhcp::SubnetID &subnet_id, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
Returns a host connected to the IPv6 subnet.
Definition host_cache.cc:189
isc::host_cache::HostCache::HostCache
HostCache()
Constructor.
Definition host_cache.cc:35
isc::host_cache::HostCache::cacheRemoveHandler
int cacheRemoveHandler(hooks::CalloutHandle &handle)
cache-remove command handler.
Definition host_cache.cc:855
isc::host_cache::HostCache::capacity
virtual size_t capacity() const
Return the maximum number of entries.
Definition host_cache.cc:434
isc::host_cache::HostCache::setMaximum
virtual void setMaximum(size_t maximum)
Set maximum number of cached hosts (0 means unbound).
Definition host_cache.cc:47
isc::host_cache::HostCache::add
virtual void add(const dhcp::HostPtr &host)
Adds a new host to the collection.
Definition host_cache.cc:280
isc::host_cache::HostCache::cacheInsertHandler
int cacheInsertHandler(hooks::CalloutHandle &handle)
cache-insert command handler.
Definition host_cache.cc:672
isc::host_cache::HostCache::mutex_
boost::scoped_ptr< std::mutex > mutex_
mutex
Definition host_cache.h:677
isc::host_cache::HostCache::del
virtual bool del(const dhcp::SubnetID &subnet_id, const asiolink::IOAddress &addr)
Attempts to delete a host by (subnet-id, address).
Definition host_cache.cc:308
isc::host_cache::HostCache::insert
virtual size_t insert(const dhcp::ConstHostPtr &host, bool overwrite)
Insert a host into the cache.
Definition host_cache.cc:406
isc::host_cache::HostCache::cacheGetByIdHandler
int cacheGetByIdHandler(hooks::CalloutHandle &handle)
cache-get-by-id command handler.
Definition host_cache.cc:573
isc::host_cache::HostCache::cacheWriteHandler
int cacheWriteHandler(hooks::CalloutHandle &handle)
cache-write command handler.
Definition host_cache.cc:735
isc::host_cache::HostCache::getPage4
virtual dhcp::ConstHostCollection getPage4(const dhcp::SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const dhcp::HostPageSize &page_size) const
Return range of hosts in a DHCPv4 subnet.
Definition host_cache.cc:92
isc::host_cache::HostCache::getAll6
virtual dhcp::ConstHostCollection getAll6(const dhcp::SubnetID &subnet_id) const
Return all hosts in a DHCPv6 subnet.
Definition host_cache.cc:70
isc::host_cache::HostCache::getAll4
virtual dhcp::ConstHostCollection getAll4(const dhcp::SubnetID &subnet_id) const
Return all hosts in a DHCPv4 subnet.
Definition host_cache.cc:65
isc::host_cache::HostCache::cacheFlushHandler
int cacheFlushHandler(hooks::CalloutHandle &handle)
cache-flush command handler.
Definition host_cache.cc:495
isc::host_cache::HostCache::getAllbyHostname6
virtual dhcp::ConstHostCollection getAllbyHostname6(const std::string &hostname, const dhcp::SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv6 subnet.
Definition host_cache.cc:86
isc::host_cache::HostCache::getAllbyHostname
virtual dhcp::ConstHostCollection getAllbyHostname(const std::string &hostname) const
Return all hosts with a hostname.
Definition host_cache.cc:75
isc::host_cache::HostCache::get
virtual dhcp::ConstHostCollection get(const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
Return all hosts connected to any subnet for which reservations have been made using a specified iden...
Definition host_cache.cc:440
isc::host_cache::HostCache::cacheSizeHandler
int cacheSizeHandler(hooks::CalloutHandle &handle)
Command handlers.
Definition host_cache.cc:448
isc::host_cache::HostCache::remove
virtual bool remove(const dhcp::HostPtr &host)
Remove a host from the cache.
Definition host_cache.cc:412
isc::host_cache::HostCache::toElement
virtual data::ElementPtr toElement() const
Returns the whole content of the cache as Element tree.
Definition host_cache.cc:400
isc::host_cache::HostCache::getPage6
virtual dhcp::ConstHostCollection getPage6(const dhcp::SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const dhcp::HostPageSize &page_size) const
Return range of hosts in a DHCPv6 subnet.
Definition host_cache.cc:100
isc::host_cache::HostCache::get4
virtual dhcp::ConstHostPtr get4(const dhcp::SubnetID &subnet_id, const dhcp::Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
Returns a host connected to the IPv4 subnet.
Definition host_cache.cc:127
isc::host_cache::HostCache::cacheGetHandler
int cacheGetHandler(hooks::CalloutHandle &handle)
cache-get command handler.
Definition host_cache.cc:544
isc::host_cache::HostCache::cacheClearHandler
int cacheClearHandler(hooks::CalloutHandle &handle)
cache-clear command handler.
Definition host_cache.cc:475
isc::util::MultiThreadingCriticalSection
RAII class creating a critical section.
Definition multi_threading_mgr.h:374
isc::util::file::SecurityWarn
A generic exception that is thrown if a parameter given violates security check but enforcement is la...
Definition filesystem.h:22
db_exceptions.h
encode.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
filesystem.h
host_cache.h
host_cache_impl.h
host_cache_log.h
host_cache_parsers.h
LOG_ERROR
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition macros.h:32
LOG_INFO
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition macros.h:20
LOG_WARN
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
Definition macros.h:26
LOG_DEBUG
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition macros.h:14
multi_threading_mgr.h
isc::asiolink
Definition addr_utilities.cc:170
isc::config
Definition command_interpreter.cc:23
isc::config::CONTROL_RESULT_EMPTY
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
Definition command_interpreter.h:53
isc::config::createAnswer
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
Definition command_interpreter.cc:54
isc::config::CONTROL_RESULT_SUCCESS
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
Definition command_interpreter.h:42
isc::data
Definition base_stamped_element.cc:12
isc::data::prettyPrint
void prettyPrint(ConstElementPtr element, std::ostream &out, unsigned indent, unsigned step)
Pretty prints the data into stream.
Definition data.cc:1747
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
isc::db
Definition audit_entry.cc:14
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::HostPtr
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
Definition host.h:837
isc::dhcp::ConstHostCollection
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition host.h:843
isc::dhcp::HostCollection
std::vector< HostPtr > HostCollection
Collection of the Host objects.
Definition host.h:846
isc::dhcp::SubnetID
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
isc::dhcp::ConstHostPtr
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition host.h:840
isc::host_cache
Definition container.h:22
isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS4_HOST
const isc::log::MessageID HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS4_HOST
Definition host_cache_messages.h:40
isc::host_cache::HOST_CACHE_ADD_DUPLICATE
const isc::log::MessageID HOST_CACHE_ADD_DUPLICATE
Definition host_cache_messages.h:12
isc::host_cache::HOST_CACHE_COMMAND_REMOVE_FAILED
const isc::log::MessageID HOST_CACHE_COMMAND_REMOVE_FAILED
Definition host_cache_messages.h:26
isc::host_cache::HOST_CACHE_COMMAND_CLEAR_FAILED
const isc::log::MessageID HOST_CACHE_COMMAND_CLEAR_FAILED
Definition host_cache_messages.h:14
isc::host_cache::HOST_CACHE_COMMAND_GET_BY_ID
const isc::log::MessageID HOST_CACHE_COMMAND_GET_BY_ID
Definition host_cache_messages.h:18
isc::host_cache::HOST_CACHE_COMMAND_FLUSH
const isc::log::MessageID HOST_CACHE_COMMAND_FLUSH
Definition host_cache_messages.h:15
isc::host_cache::HOST_CACHE_COMMAND_LOAD_FAILED
const isc::log::MessageID HOST_CACHE_COMMAND_LOAD_FAILED
Definition host_cache_messages.h:24
isc::host_cache::HOST_CACHE_COMMAND_GET
const isc::log::MessageID HOST_CACHE_COMMAND_GET
Definition host_cache_messages.h:17
isc::host_cache::HOST_CACHE_ADD
const isc::log::MessageID HOST_CACHE_ADD
Definition host_cache_messages.h:11
isc::host_cache::HOST_CACHE_DBG_RESULTS
const int HOST_CACHE_DBG_RESULTS
Records the results of the lookups.
Definition host_cache_log.h:33
isc::host_cache::HOST_CACHE_COMMAND_INSERT
const isc::log::MessageID HOST_CACHE_COMMAND_INSERT
Definition host_cache_messages.h:21
isc::host_cache::HOST_CACHE_COMMAND_WRITE_FAILED
const isc::log::MessageID HOST_CACHE_COMMAND_WRITE_FAILED
Definition host_cache_messages.h:30
isc::host_cache::HOST_CACHE_DEL_SUBNET_ID_IDENTIFIER4
const isc::log::MessageID HOST_CACHE_DEL_SUBNET_ID_IDENTIFIER4
Definition host_cache_messages.h:35
isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER_HOST
const isc::log::MessageID HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER_HOST
Definition host_cache_messages.h:44
isc::host_cache::HOST_CACHE_COMMAND_SIZE_FAILED
const isc::log::MessageID HOST_CACHE_COMMAND_SIZE_FAILED
Definition host_cache_messages.h:28
isc::host_cache::HOST_CACHE_COMMAND_FLUSH_FAILED
const isc::log::MessageID HOST_CACHE_COMMAND_FLUSH_FAILED
Definition host_cache_messages.h:16
isc::host_cache::HOST_CACHE_COMMAND_LOAD
const isc::log::MessageID HOST_CACHE_COMMAND_LOAD
Definition host_cache_messages.h:23
isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER
const isc::log::MessageID HOST_CACHE_GET_ONE_SUBNET_ID_IDENTIFIER
Definition host_cache_messages.h:43
isc::host_cache::HOST_CACHE_DEL_SUBNET_ID_ADDRESS4
const isc::log::MessageID HOST_CACHE_DEL_SUBNET_ID_ADDRESS4
Definition host_cache_messages.h:33
isc::host_cache::HOST_CACHE_GET_ONE_PREFIX
const isc::log::MessageID HOST_CACHE_GET_ONE_PREFIX
Definition host_cache_messages.h:37
isc::host_cache::HOST_CACHE_COMMAND_GET_BY_ID_FAILED
const isc::log::MessageID HOST_CACHE_COMMAND_GET_BY_ID_FAILED
Definition host_cache_messages.h:19
isc::host_cache::HOST_CACHE_DEL_SUBNET_ID_ADDRESS6
const isc::log::MessageID HOST_CACHE_DEL_SUBNET_ID_ADDRESS6
Definition host_cache_messages.h:34
isc::host_cache::HOST_CACHE_GET_ONE_PREFIX_HOST
const isc::log::MessageID HOST_CACHE_GET_ONE_PREFIX_HOST
Definition host_cache_messages.h:38
isc::host_cache::HOST_CACHE_COMMAND_CLEAR
const isc::log::MessageID HOST_CACHE_COMMAND_CLEAR
Definition host_cache_messages.h:13
isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS6
const isc::log::MessageID HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS6
Definition host_cache_messages.h:41
isc::host_cache::HOST_CACHE_COMMAND_SIZE
const isc::log::MessageID HOST_CACHE_COMMAND_SIZE
Definition host_cache_messages.h:27
isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS4
const isc::log::MessageID HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS4
Definition host_cache_messages.h:39
isc::host_cache::HOST_CACHE_COMMAND_REMOVE
const isc::log::MessageID HOST_CACHE_COMMAND_REMOVE
Definition host_cache_messages.h:25
isc::host_cache::HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS6_HOST
const isc::log::MessageID HOST_CACHE_GET_ONE_SUBNET_ID_ADDRESS6_HOST
Definition host_cache_messages.h:42
isc::host_cache::HOST_CACHE_COMMAND_GET_FAILED
const isc::log::MessageID HOST_CACHE_COMMAND_GET_FAILED
Definition host_cache_messages.h:20
isc::host_cache::toElement
ElementPtr toElement(const ConstHostPtr &host)
Unparse a host cache entry.
Definition entry.cc:25
isc::host_cache::HOST_CACHE_COMMAND_WRITE
const isc::log::MessageID HOST_CACHE_COMMAND_WRITE
Definition host_cache_messages.h:29
isc::host_cache::HOST_CACHE_DBG_TRACE
const int HOST_CACHE_DBG_TRACE
Host Cache hooks library logging levels.
Definition host_cache_log.h:27
isc::host_cache::HOST_CACHE_COMMAND_INSERT_FAILED
const isc::log::MessageID HOST_CACHE_COMMAND_INSERT_FAILED
Definition host_cache_messages.h:22
isc::host_cache::HOST_CACHE_PATH_SECURITY_WARNING
const isc::log::MessageID HOST_CACHE_PATH_SECURITY_WARNING
Definition host_cache_messages.h:46
isc::host_cache::HOST_CACHE_DEL_SUBNET_ID_IDENTIFIER6
const isc::log::MessageID HOST_CACHE_DEL_SUBNET_ID_IDENTIFIER6
Definition host_cache_messages.h:36
isc::host_cache::host_cache_logger
isc::log::Logger host_cache_logger("host-cache-hooks")
Host Cache Logger.
Definition host_cache_log.h:43
isc::util::file
Definition filesystem.cc:29
isc::util::str::decodeFormattedHexString
void decodeFormattedHexString(const string &hex_string, vector< uint8_t > &binary)
Converts a formatted string of hexadecimal digits into a vector.
Definition str.cc:212
isc::util::str::quotedStringToBinary
vector< uint8_t > quotedStringToBinary(const string &quoted_string)
Converts a string in quotes into vector.
Definition str.cc:139
isc::util
Definition time_utils.cc:43
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
str.h
isc::util::MultiThreadingLock
RAII lock object to protect the code in the same scope with a mutex.
Definition multi_threading_mgr.h:349