Kea 2.2.0
host_mgr.cc
Go to the documentation of this file.
1// Copyright (C) 2014-2020 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#include <dhcpsrv/cfg_hosts.h>
9#include <dhcpsrv/cfgmgr.h>
10#include <dhcpsrv/host_mgr.h>
11#include <dhcpsrv/hosts_log.h>
13
14namespace {
15
22isc::dhcp::ConstCfgHostsPtr getCfgHosts() {
23 return (isc::dhcp::CfgMgr::instance().getCurrentCfg()->getCfgHosts());
24}
25
26} // end of anonymous namespace
27
28namespace isc {
29namespace dhcp {
30
31using namespace isc::asiolink;
32using namespace isc::db;
33
34IOServicePtr HostMgr::io_service_ = IOServicePtr();
35
36boost::scoped_ptr<HostMgr>&
37HostMgr::getHostMgrPtr() {
38 static boost::scoped_ptr<HostMgr> host_mgr_ptr;
39 return (host_mgr_ptr);
40}
41
42void
44 getHostMgrPtr().reset(new HostMgr());
45}
46
47void
48HostMgr::addBackend(const std::string& access) {
49 HostDataSourceFactory::add(getHostMgrPtr()->alternate_sources_, access);
50}
51
52bool
53HostMgr::delBackend(const std::string& db_type) {
54 if (getHostMgrPtr()->cache_ptr_ &&
55 getHostMgrPtr()->cache_ptr_->getType() == db_type) {
56 getHostMgrPtr()->cache_ptr_.reset();
57 }
58 return (HostDataSourceFactory::del(getHostMgrPtr()->alternate_sources_,
59 db_type));
60}
61
62bool
63HostMgr::delBackend(const std::string& db_type, const std::string& access,
64 bool if_unusable) {
65 return (HostDataSourceFactory::del(getHostMgrPtr()->alternate_sources_,
66 db_type, access, if_unusable));
67}
68
69void
71 getHostMgrPtr()->alternate_sources_.clear();
72}
73
76 if (alternate_sources_.empty()) {
77 return (HostDataSourcePtr());
78 }
79 return (alternate_sources_[0]);
80}
81
82bool
84 if (getHostMgrPtr()->cache_ptr_) {
85 return (true);
86 }
87 HostDataSourceList& sources = getHostMgrPtr()->alternate_sources_;
88 if (sources.empty()) {
89 return (false);
90 }
91 CacheHostDataSourcePtr cache_ptr =
92 boost::dynamic_pointer_cast<CacheHostDataSource>(sources[0]);
93 if (cache_ptr) {
94 getHostMgrPtr()->cache_ptr_ = cache_ptr;
95 if (logging) {
97 .arg(cache_ptr->getType());
98 }
99 return (true);
100 }
101 return (false);
102}
103
104HostMgr&
106 boost::scoped_ptr<HostMgr>& host_mgr_ptr = getHostMgrPtr();
107 if (!host_mgr_ptr) {
108 create();
109 }
110 return (*host_mgr_ptr);
111}
112
115 const uint8_t* identifier_begin,
116 const size_t identifier_len) const {
117 ConstHostCollection hosts = getCfgHosts()->getAll(identifier_type,
118 identifier_begin,
119 identifier_len);
120 for (auto source : alternate_sources_) {
121 ConstHostCollection hosts_plus =
122 source->getAll(identifier_type, identifier_begin, identifier_len);
123 hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
124 }
125 return (hosts);
126}
127
129HostMgr::getAll4(const SubnetID& subnet_id) const {
130 ConstHostCollection hosts = getCfgHosts()->getAll4(subnet_id);
131 for (auto source : alternate_sources_) {
132 ConstHostCollection hosts_plus = source->getAll4(subnet_id);
133 hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
134 }
135 return (hosts);
136}
137
138
140HostMgr::getAll6(const SubnetID& subnet_id) const {
141 ConstHostCollection hosts = getCfgHosts()->getAll6(subnet_id);
142 for (auto source : alternate_sources_) {
143 ConstHostCollection hosts_plus = source->getAll6(subnet_id);
144 hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
145 }
146 return (hosts);
147}
148
150HostMgr::getAllbyHostname(const std::string& hostname) const {
151 ConstHostCollection hosts = getCfgHosts()->getAllbyHostname(hostname);
152 for (auto source : alternate_sources_) {
153 ConstHostCollection hosts_plus = source->getAllbyHostname(hostname);
154 hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
155 }
156 return (hosts);
157}
158
160HostMgr::getAllbyHostname4(const std::string& hostname,
161 const SubnetID& subnet_id) const {
162 ConstHostCollection hosts = getCfgHosts()->getAllbyHostname4(hostname,
163 subnet_id);
164 for (auto source : alternate_sources_) {
165 ConstHostCollection hosts_plus = source->getAllbyHostname4(hostname,
166 subnet_id);
167 hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
168 }
169 return (hosts);
170}
171
173HostMgr::getAllbyHostname6(const std::string& hostname,
174 const SubnetID& subnet_id) const {
175 ConstHostCollection hosts = getCfgHosts()->getAllbyHostname6(hostname,
176 subnet_id);
177 for (auto source : alternate_sources_) {
178 ConstHostCollection hosts_plus = source->getAllbyHostname6(hostname,
179 subnet_id);
180 hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
181 }
182 return (hosts);
183}
184
187 size_t& source_index,
188 uint64_t lower_host_id,
189 const HostPageSize& page_size) const {
190 // Return empty if (and only if) sources are exhausted.
191 if (source_index > alternate_sources_.size()) {
192 return (ConstHostCollection());
193 }
194
196 // Source index 0 means config file.
197 if (source_index == 0) {
198 hosts = getCfgHosts()->
199 getPage4(subnet_id, source_index, lower_host_id, page_size);
200 } else {
201 hosts = alternate_sources_[source_index - 1]->
202 getPage4(subnet_id, source_index, lower_host_id, page_size);
203 }
204
205 // When got something return it.
206 if (!hosts.empty()) {
207 return (hosts);
208 }
209
210 // Nothing from this source: try the next one.
211 // Note the recursion is limited to the number of sources in all cases.
212 ++source_index;
213 return (getPage4(subnet_id, source_index, 0UL, page_size));
214}
215
218 size_t& source_index,
219 uint64_t lower_host_id,
220 const HostPageSize& page_size) const {
221 // Return empty if (and only if) sources are exhausted.
222 if (source_index > alternate_sources_.size()) {
223 return (ConstHostCollection());
224 }
225
227 // Source index 0 means config file.
228 if (source_index == 0) {
229 hosts = getCfgHosts()->
230 getPage6(subnet_id, source_index, lower_host_id, page_size);
231 } else {
232 hosts = alternate_sources_[source_index - 1]->
233 getPage6(subnet_id, source_index, lower_host_id, page_size);
234 }
235
236 // When got something return it.
237 if (!hosts.empty()) {
238 return (hosts);
239 }
240
241 // Nothing from this source: try the next one.
242 // Note the recursion is limited to the number of sources in all cases.
243 ++source_index;
244 return (getPage6(subnet_id, source_index, 0UL, page_size));
245}
246
248HostMgr::getPage4(size_t& source_index,
249 uint64_t lower_host_id,
250 const HostPageSize& page_size) const {
251 // Return empty if (and only if) sources are exhausted.
252 if (source_index > alternate_sources_.size()) {
253 return (ConstHostCollection());
254 }
255
257 // Source index 0 means config file.
258 if (source_index == 0) {
259 hosts = getCfgHosts()->
260 getPage4(source_index, lower_host_id, page_size);
261 } else {
262 hosts = alternate_sources_[source_index - 1]->
263 getPage4(source_index, lower_host_id, page_size);
264 }
265
266 // When got something return it.
267 if (!hosts.empty()) {
268 return (hosts);
269 }
270
271 // Nothing from this source: try the next one.
272 // Note the recursion is limited to the number of sources in all cases.
273 ++source_index;
274 return (getPage4(source_index, 0UL, page_size));
275}
276
278HostMgr::getPage6(size_t& source_index,
279 uint64_t lower_host_id,
280 const HostPageSize& page_size) const {
281 // Return empty if (and only if) sources are exhausted.
282 if (source_index > alternate_sources_.size()) {
283 return (ConstHostCollection());
284 }
285
287 // Source index 0 means config file.
288 if (source_index == 0) {
289 hosts = getCfgHosts()->
290 getPage6(source_index, lower_host_id, page_size);
291 } else {
292 hosts = alternate_sources_[source_index - 1]->
293 getPage6(source_index, lower_host_id, page_size);
294 }
295
296 // When got something return it.
297 if (!hosts.empty()) {
298 return (hosts);
299 }
300
301 // Nothing from this source: try the next one.
302 // Note the recursion is limited to the number of sources in all cases.
303 ++source_index;
304 return (getPage6(source_index, 0UL, page_size));
305}
306
308HostMgr::getAll4(const IOAddress& address) const {
309 ConstHostCollection hosts = getCfgHosts()->getAll4(address);
310 for (auto source : alternate_sources_) {
311 ConstHostCollection hosts_plus = source->getAll4(address);
312 hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
313 }
314 return (hosts);
315}
316
318HostMgr::get4Any(const SubnetID& subnet_id,
319 const Host::IdentifierType& identifier_type,
320 const uint8_t* identifier_begin,
321 const size_t identifier_len) const {
322 ConstHostPtr host = getCfgHosts()->get4(subnet_id, identifier_type,
323 identifier_begin, identifier_len);
324
325 // Found it in the config file or there are no backends configured?
326 // Then we're done here.
327 if (host || alternate_sources_.empty()) {
328 return (host);
329 }
330
333 .arg(subnet_id)
334 .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
335 identifier_len));
336
337 // Try to find a host in each configured backend. We return as soon
338 // as we find first hit.
339 for (auto source : alternate_sources_) {
340 host = source->get4(subnet_id, identifier_type,
341 identifier_begin, identifier_len);
342
343 if (host) {
346 .arg(subnet_id)
347 .arg(Host::getIdentifierAsText(identifier_type,
348 identifier_begin,
349 identifier_len))
350 .arg(source->getType())
351 .arg(host->toText());
352
353 if (source != cache_ptr_) {
354 cache(host);
355 }
356 return (host);
357 }
358 }
361 .arg(subnet_id)
362 .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
363 identifier_len));
364 return (ConstHostPtr());
365}
366
368HostMgr::get4(const SubnetID& subnet_id,
369 const Host::IdentifierType& identifier_type,
370 const uint8_t* identifier_begin,
371 const size_t identifier_len) const {
372 ConstHostPtr host = get4Any(subnet_id, identifier_type,
373 identifier_begin, identifier_len);
374 if (host && host->getNegative()) {
375 return (ConstHostPtr());
376 } else if (!host && negative_caching_) {
377 cacheNegative(subnet_id, SubnetID(SUBNET_ID_UNUSED),
378 identifier_type, identifier_begin, identifier_len);
379 }
380 return (host);
381}
382
384HostMgr::get4(const SubnetID& subnet_id,
385 const asiolink::IOAddress& address) const {
386 ConstHostPtr host = getCfgHosts()->get4(subnet_id, address);
387 if (host || alternate_sources_.empty()) {
388 return (host);
389 }
392 .arg(subnet_id)
393 .arg(address.toText());
394 for (auto source : alternate_sources_) {
395 host = source->get4(subnet_id, address);
396 if (host && host->getNegative()) {
397 return (ConstHostPtr());
398 }
399 if (host && source != cache_ptr_) {
400 cache(host);
401 }
402 if (host) {
403 return (host);
404 }
405 }
406 return (ConstHostPtr());
407}
408
410HostMgr::getAll4(const SubnetID& subnet_id,
411 const asiolink::IOAddress& address) const {
412 auto hosts = getCfgHosts()->getAll4(subnet_id, address);
413
416 .arg(subnet_id)
417 .arg(address.toText());
418
419 for (auto source : alternate_sources_) {
420 auto hosts_plus = source->getAll4(subnet_id, address);
421 hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
422 }
423 return (hosts);
424}
425
427HostMgr::get6(const IOAddress& prefix, const uint8_t prefix_len) const {
428 ConstHostPtr host = getCfgHosts()->get6(prefix, prefix_len);
429 if (host || alternate_sources_.empty()) {
430 return (host);
431 }
433 .arg(prefix.toText())
434 .arg(static_cast<int>(prefix_len));
435 for (auto source : alternate_sources_) {
436 host = source->get6(prefix, prefix_len);
437 if (host && host->getNegative()) {
438 return (ConstHostPtr());
439 }
440 if (host && source != cache_ptr_) {
441 cache(host);
442 }
443 if (host) {
444 return (host);
445 }
446 }
447 return (ConstHostPtr());
448}
449
451HostMgr::get6Any(const SubnetID& subnet_id,
452 const Host::IdentifierType& identifier_type,
453 const uint8_t* identifier_begin,
454 const size_t identifier_len) const {
455 ConstHostPtr host = getCfgHosts()->get6(subnet_id, identifier_type,
456 identifier_begin, identifier_len);
457 if (host || alternate_sources_.empty()) {
458 return (host);
459 }
460
463 .arg(subnet_id)
464 .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
465 identifier_len));
466
467 for (auto source : alternate_sources_) {
468 host = source->get6(subnet_id, identifier_type,
469 identifier_begin, identifier_len);
470
471 if (host) {
474 .arg(subnet_id)
475 .arg(Host::getIdentifierAsText(identifier_type,
476 identifier_begin,
477 identifier_len))
478 .arg(source->getType())
479 .arg(host->toText());
480
481 if (source != cache_ptr_) {
482 cache(host);
483 }
484 return (host);
485 }
486 }
487
490 .arg(subnet_id)
491 .arg(Host::getIdentifierAsText(identifier_type, identifier_begin,
492 identifier_len));
493
494 return (ConstHostPtr());
495}
496
498HostMgr::get6(const SubnetID& subnet_id,
499 const Host::IdentifierType& identifier_type,
500 const uint8_t* identifier_begin,
501 const size_t identifier_len) const {
502 ConstHostPtr host = get6Any(subnet_id, identifier_type,
503 identifier_begin, identifier_len);
504 if (host && host->getNegative()) {
505 return (ConstHostPtr());
506 } else if (!host && negative_caching_) {
507 cacheNegative(SubnetID(SUBNET_ID_UNUSED), subnet_id,
508 identifier_type, identifier_begin, identifier_len);
509 }
510 return (host);
511}
512
514HostMgr::get6(const SubnetID& subnet_id,
515 const asiolink::IOAddress& addr) const {
516 ConstHostPtr host = getCfgHosts()->get6(subnet_id, addr);
517 if (host || alternate_sources_.empty()) {
518 return (host);
519 }
522 .arg(subnet_id)
523 .arg(addr.toText());
524 for (auto source : alternate_sources_) {
525 host = source->get6(subnet_id, addr);
526 if (host && host->getNegative()) {
527 return (ConstHostPtr());
528 }
529 if (host && source != cache_ptr_) {
530 cache(host);
531 }
532 if (host) {
533 return (host);
534 }
535 }
536 return (ConstHostPtr());
537}
538
540HostMgr::getAll6(const SubnetID& subnet_id,
541 const asiolink::IOAddress& address) const {
542 auto hosts = getCfgHosts()->getAll6(subnet_id, address);
543
546 .arg(subnet_id)
547 .arg(address.toText());
548
549 for (auto source : alternate_sources_) {
550 auto hosts_plus = source->getAll6(subnet_id, address);
551 hosts.insert(hosts.end(), hosts_plus.begin(), hosts_plus.end());
552 }
553 return (hosts);
554}
555
556void
557HostMgr::add(const HostPtr& host) {
558 if (alternate_sources_.empty()) {
559 isc_throw(NoHostDataSourceManager, "Unable to add new host because there is "
560 "no hosts-database configured.");
561 }
562 for (auto source : alternate_sources_) {
563 source->add(host);
564 }
565 // If no backend throws the host should be cached.
566 if (cache_ptr_) {
567 cache(host);
568 }
569}
570
571bool
572HostMgr::del(const SubnetID& subnet_id, const asiolink::IOAddress& addr) {
573 if (alternate_sources_.empty()) {
574 isc_throw(NoHostDataSourceManager, "Unable to delete a host because there is "
575 "no hosts-database configured.");
576 }
577
578 for (auto source : alternate_sources_) {
579 if (source->del(subnet_id, addr)) {
580 return (true);
581 }
582 }
583 return (false);
584}
585
586bool
587HostMgr::del4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
588 const uint8_t* identifier_begin, const size_t identifier_len) {
589 if (alternate_sources_.empty()) {
590 isc_throw(NoHostDataSourceManager, "Unable to delete a host because there is "
591 "no hosts-database configured.");
592 }
593
594 for (auto source : alternate_sources_) {
595 if (source->del4(subnet_id, identifier_type,
596 identifier_begin, identifier_len)) {
597 return (true);
598 }
599 }
600 return (false);
601}
602
603bool
604HostMgr::del6(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
605 const uint8_t* identifier_begin, const size_t identifier_len) {
606 if (alternate_sources_.empty()) {
607 isc_throw(NoHostDataSourceManager, "unable to delete a host because there is "
608 "no alternate host data source present");
609 }
610
611 for (auto source : alternate_sources_) {
612 if (source->del6(subnet_id, identifier_type,
613 identifier_begin, identifier_len)) {
614 return (true);
615 }
616 }
617 return (false);
618}
619
620void
622 if (cache_ptr_) {
623 // Need a real host.
624 if (!host || host->getNegative()) {
625 return;
626 }
627 // Replace any existing value.
628 // Don't check the result as it does not matter?
629 cache_ptr_->insert(host, true);
630 }
631}
632
633void
634HostMgr::cacheNegative(const SubnetID& ipv4_subnet_id,
635 const SubnetID& ipv6_subnet_id,
636 const Host::IdentifierType& identifier_type,
637 const uint8_t* identifier_begin,
638 const size_t identifier_len) const {
639 if (cache_ptr_ && negative_caching_) {
640 HostPtr host(new Host(identifier_begin, identifier_len,
641 identifier_type,
642 ipv4_subnet_id, ipv6_subnet_id,
644 host->setNegative(true);
645 // Don't replace any existing value.
646 // nor matter if it fails.
647 cache_ptr_->insert(host, false);
648 }
649}
650
651bool
653 // Iterate over the alternate sources first, because they may include those
654 // for which the new setting is not supported.
655 for (auto source : alternate_sources_) {
656 if (!source->setIPReservationsUnique(unique)) {
657 // One of the sources does not support this new mode of operation.
658 // Let's log a warning and back off the changes to the default
659 // setting which should always be supported.
660 ip_reservations_unique_ = true;
662 .arg(source->getType());
663 for (auto source : alternate_sources_) {
664 source->setIPReservationsUnique(true);
665 }
666 return (false);
667 }
668 }
669 // Successfully configured the HostMgr to use the new setting.
670 // Remember this setting so we can return it via the
671 // getIPReservationsUnique.
672 ip_reservations_unique_ = unique;
673 return (true);
674}
675
676
677} // end of isc::dhcp namespace
678} // end of isc namespace
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition: cfgmgr.cc:25
static void add(HostDataSourceList &sources, const std::string &dbaccess)
Create and add an instance of a host data source.
static bool del(HostDataSourceList &sources, const std::string &db_type)
Delete a host data source.
Host Manager.
Definition: host_mgr.h:55
virtual void add(const HostPtr &host)
Adds a new host to the alternate data source.
Definition: host_mgr.cc:557
static void delAllBackends()
Delete all alternate backends.
Definition: host_mgr.cc:70
static void create()
Creates new instance of the HostMgr.
Definition: host_mgr.cc:43
bool negative_caching_
The negative caching flag.
Definition: host_mgr.h:654
virtual void cacheNegative(const SubnetID &ipv4_subnet_id, const SubnetID &ipv6_subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
Cache a negative answer.
Definition: host_mgr.cc:634
virtual ConstHostCollection getPage6(const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const
Returns range of hosts in a DHCPv6 subnet.
Definition: host_mgr.cc:217
virtual bool setIPReservationsUnique(const bool unique)
Controls whether IP reservations are unique or non-unique.
Definition: host_mgr.cc:652
virtual ConstHostCollection getAll(const 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_mgr.cc:114
virtual ConstHostCollection getAllbyHostname6(const std::string &hostname, const SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv6 subnet.
Definition: host_mgr.cc:173
virtual ConstHostCollection getAllbyHostname4(const std::string &hostname, const SubnetID &subnet_id) const
Return all hosts with a hostname in a DHCPv4 subnet.
Definition: host_mgr.cc:160
virtual ConstHostPtr get4Any(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
Returns any host connected to the IPv4 subnet.
Definition: host_mgr.cc:318
virtual void cache(ConstHostPtr host) const
Cache an answer.
Definition: host_mgr.cc:621
virtual bool del6(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)
Attempts to delete a host by (subnet6-id, identifier, identifier-type)
Definition: host_mgr.cc:604
static bool delBackend(const std::string &db_type)
Delete an alternate host backend (aka host data source).
Definition: host_mgr.cc:53
static void addBackend(const std::string &access)
Add an alternate host backend (aka host data source).
Definition: host_mgr.cc:48
virtual ConstHostPtr get6(const SubnetID &subnet_id, const 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_mgr.cc:498
virtual ConstHostCollection getAll6(const SubnetID &subnet_id) const
Return all hosts in a DHCPv6 subnet.
Definition: host_mgr.cc:140
virtual ConstHostCollection getPage4(const SubnetID &subnet_id, size_t &source_index, uint64_t lower_host_id, const HostPageSize &page_size) const
Returns range of hosts in a DHCPv4 subnet.
Definition: host_mgr.cc:186
virtual ConstHostPtr get4(const SubnetID &subnet_id, const 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_mgr.cc:368
HostDataSourcePtr getHostDataSource() const
Returns the first host data source.
Definition: host_mgr.cc:75
static bool checkCacheBackend(bool logging=false)
Check for the cache host backend.
Definition: host_mgr.cc:83
virtual bool del(const SubnetID &subnet_id, const asiolink::IOAddress &addr)
Attempts to delete hosts by address.
Definition: host_mgr.cc:572
static HostMgr & instance()
Returns a sole instance of the HostMgr.
Definition: host_mgr.cc:105
virtual ConstHostCollection getAll4(const SubnetID &subnet_id) const
Return all hosts in a DHCPv4 subnet.
Definition: host_mgr.cc:129
virtual ConstHostPtr get6Any(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
Returns any host connected to the IPv6 subnet.
Definition: host_mgr.cc:451
virtual ConstHostCollection getAllbyHostname(const std::string &hostname) const
Return all hosts with a hostname.
Definition: host_mgr.cc:150
virtual bool del4(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len)
Attempts to delete a host by (subnet4-id, identifier, identifier-type)
Definition: host_mgr.cc:587
Wraps value holding size of the page with host reservations.
Represents a device with IPv4 and/or IPv6 reservations.
Definition: host.h:297
IdentifierType
Type of the host identifier.
Definition: host.h:307
std::string getIdentifierAsText() const
Returns host identifier in a textual form.
Definition: host.cc:256
No host data source instance exception.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#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_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition: macros.h:14
boost::shared_ptr< BaseHostDataSource > HostDataSourcePtr
HostDataSource pointer.
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER_NULL
isc::log::Logger hosts_logger("hosts")
Logger for the HostMgr and the code it calls.
Definition: hosts_log.h:51
boost::shared_ptr< const CfgHosts > ConstCfgHostsPtr
Const pointer.
Definition: cfg_hosts.h:944
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET6_PREFIX
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
Definition: host.h:785
std::vector< ConstHostPtr > ConstHostCollection
Collection of the const Host objects.
Definition: host.h:791
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_ADDRESS6
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER_HOST
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER_HOST
std::vector< HostDataSourcePtr > HostDataSourceList
HostDataSource list.
const isc::log::MessageID HOSTS_CFG_CACHE_HOST_DATA_SOURCE
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_ADDRESS4
const int HOSTS_DBG_TRACE
Logging levels for the host reservations management.
Definition: hosts_log.h:27
boost::shared_ptr< CacheHostDataSource > CacheHostDataSourcePtr
CacheHostDataSource pointer.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition: subnet_id.h:24
const isc::log::MessageID HOSTS_MGR_NON_UNIQUE_IP_UNSUPPORTED
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
Definition: host.h:788
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET_ALL_SUBNET_ID_ADDRESS4
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET_ALL_SUBNET_ID_ADDRESS6
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_IDENTIFIER_NULL
const int HOSTS_DBG_RESULTS
Records the results of the lookups.
Definition: hosts_log.h:33
const isc::log::MessageID HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_IDENTIFIER
Defines the logger used by the top-level component of kea-lfc.