8#include <kea_version.h>
62#include <boost/algorithm/string.hpp>
63#include <boost/foreach.hpp>
64#include <boost/pointer_cast.hpp>
65#include <boost/shared_ptr.hpp>
82namespace ph = std::placeholders;
88 int hook_index_buffer4_receive_;
89 int hook_index_pkt4_receive_;
90 int hook_index_subnet4_select_;
91 int hook_index_leases4_committed_;
92 int hook_index_lease4_release_;
93 int hook_index_pkt4_send_;
94 int hook_index_buffer4_send_;
95 int hook_index_lease4_decline_;
96 int hook_index_host4_identifier_;
97 int hook_index_ddns4_update_;
101 hook_index_buffer4_receive_ = HooksManager::registerHook(
"buffer4_receive");
102 hook_index_pkt4_receive_ = HooksManager::registerHook(
"pkt4_receive");
103 hook_index_subnet4_select_ = HooksManager::registerHook(
"subnet4_select");
104 hook_index_leases4_committed_ = HooksManager::registerHook(
"leases4_committed");
105 hook_index_lease4_release_ = HooksManager::registerHook(
"lease4_release");
106 hook_index_pkt4_send_ = HooksManager::registerHook(
"pkt4_send");
107 hook_index_buffer4_send_ = HooksManager::registerHook(
"buffer4_send");
108 hook_index_lease4_decline_ = HooksManager::registerHook(
"lease4_decline");
109 hook_index_host4_identifier_ = HooksManager::registerHook(
"host4_identifier");
110 hook_index_ddns4_update_ = HooksManager::registerHook(
"ddns4_update");
116std::set<std::string> dhcp4_statistics = {
118 "pkt4-discover-received",
119 "pkt4-offer-received",
120 "pkt4-request-received",
123 "pkt4-release-received",
124 "pkt4-decline-received",
125 "pkt4-inform-received",
126 "pkt4-unknown-received",
133 "v4-allocation-fail",
134 "v4-allocation-fail-shared-network",
135 "v4-allocation-fail-subnet",
136 "v4-allocation-fail-no-pools",
137 "v4-allocation-fail-classes",
138 "v4-reservation-conflicts"
157 : alloc_engine_(alloc_engine), query_(query), resp_(),
160 if (!alloc_engine_) {
162 " when creating an instance of the Dhcpv4Exchange");
167 " creating an instance of the Dhcpv4Exchange");
176 context_->subnet_ = subnet;
182 if (subnet && !context_->early_global_reservations_lookup_) {
185 context_->clientid_.reset(
new ClientId(opt_clientid->getData()));
191 if (subnet->getReservationsInSubnet() ||
192 subnet->getReservationsGlobal()) {
195 if (!context_->early_global_reservations_lookup_) {
200 alloc_engine->findReservation(*context_);
203 subnet->getSharedNetwork(sn);
213 auto global_host = context_->globalHost();
214 auto current_host = context_->currentHost();
215 if ((!context_->early_global_reservations_lookup_ &&
216 global_host && !global_host->getClientClasses4().empty()) ||
217 (!sn && current_host && !current_host->getClientClasses4().empty())) {
238 if (!context_->hosts_.empty()) {
239 query->addClass(
"KNOWN");
241 .arg(query->getLabel())
244 query->addClass(
"UNKNOWN");
246 .arg(query->getLabel())
254 if (!classes.
empty()) {
256 .arg(query_->getLabel())
261 if (query_->inClass(
"DROP")) {
263 .arg(query_->toText());
265 static_cast<int64_t
>(1));
272 uint8_t resp_type = 0;
286 resp_.reset(
new Pkt4(resp_type,
getQuery()->getTransid()));
288 copyDefaultOptions();
302 const Pkt6Ptr& query6 = query->getPkt6();
306 if (!query6->relay_info_.empty()) {
307 resp6->copyRelayInfo(query6);
310 resp6->setIface(query6->getIface());
311 resp6->setIndex(query6->getIndex());
312 resp6->setRemoteAddr(query6->getRemoteAddr());
313 resp6->setRemotePort(query6->getRemotePort());
314 resp_.reset(
new Pkt4o6(resp_, resp6));
318Dhcpv4Exchange::copyDefaultFields() {
319 resp_->setIface(query_->getIface());
320 resp_->setIndex(query_->getIndex());
327 resp_->setCiaddr(query_->getCiaddr());
331 resp_->setHops(query_->getHops());
334 resp_->setHWAddr(query_->getHWAddr());
337 resp_->setGiaddr(query_->getGiaddr());
346 HWAddrPtr src_hw_addr = query_->getLocalHWAddr();
348 resp_->setLocalHWAddr(src_hw_addr);
350 HWAddrPtr dst_hw_addr = query_->getRemoteHWAddr();
352 resp_->setRemoteHWAddr(dst_hw_addr);
356 resp_->setFlags(query_->getFlags());
360Dhcpv4Exchange::copyDefaultOptions() {
365 if (client_id && echo) {
366 resp_->addOption(client_id);
373 resp_->addOption(rai);
386 resp_->addOption(subnet_sel);
398 cfg->getIdentifierTypes()) {
401 if (context->hwaddr_ && !context->hwaddr_->hwaddr_.empty()) {
402 context->addHostIdentifier(id_type, context->hwaddr_->hwaddr_);
407 if (context->clientid_) {
408 const std::vector<uint8_t>& vec = context->clientid_->getDuid();
413 if ((vec[0] == CLIENT_ID_OPTION_TYPE_DUID) && (vec.size() > 5)) {
415 context->addHostIdentifier(id_type,
416 std::vector<uint8_t>(vec.begin() + 5,
427 OptionPtr circuit_id_opt = rai->getOption(RAI_OPTION_AGENT_CIRCUIT_ID);
428 if (circuit_id_opt) {
429 const OptionBuffer& circuit_id_vec = circuit_id_opt->getData();
430 if (!circuit_id_vec.empty()) {
431 context->addHostIdentifier(id_type, circuit_id_vec);
439 if (context->clientid_) {
440 const std::vector<uint8_t>& vec = context->clientid_->getDuid();
442 context->addHostIdentifier(id_type, vec);
448 if (!HooksManager::calloutsPresent(
Hooks.hook_index_host4_identifier_)) {
455 std::vector<uint8_t> id;
464 callout_handle->setArgument(
"query4", context->query_);
465 callout_handle->setArgument(
"id_type", type);
466 callout_handle->setArgument(
"id_value",
id);
469 HooksManager::callCallouts(
Hooks.hook_index_host4_identifier_,
472 callout_handle->getArgument(
"id_type", type);
473 callout_handle->getArgument(
"id_value",
id);
475 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_CONTINUE) &&
481 context->addHostIdentifier(type,
id);
496 for (
auto def : *defs_ptr) {
500 if (def->getMatchExpr()) {
501 query->classes_.erase(def->getName());
508 if (context->currentHost() && context->query_) {
509 const ClientClasses& classes = context->currentHost()->getClientClasses4();
511 cclass != classes.
cend(); ++cclass) {
512 context->query_->addClass(*cclass);
519 if (context_->subnet_) {
521 context_->subnet_->getSharedNetwork(shared_network);
522 if (shared_network) {
524 if (host && (host->getIPv4SubnetID() != SUBNET_ID_GLOBAL)) {
536 if (!host->getNextServer().isV4Zero()) {
537 resp_->setSiaddr(host->getNextServer());
540 std::string sname = host->getServerHostname();
541 if (!sname.empty()) {
542 resp_->setSname(
reinterpret_cast<const uint8_t*
>(sname.c_str()),
546 std::string bootfile = host->getBootFileName();
547 if (!bootfile.empty()) {
548 resp_->setFile(
reinterpret_cast<const uint8_t*
>(bootfile.c_str()),
556 boost::shared_ptr<OptionString> vendor_class =
568 pkt->addClass(
"ALL");
582 for (ClientClassDefList::const_iterator it = defs_ptr->cbegin();
583 it != defs_ptr->cend(); ++it) {
591 if ((*it)->getRequired()) {
595 if ((*it)->getDependOnKnown() != depend_on_known) {
604 .arg((*it)->getName())
607 pkt->addClass((*it)->getName());
610 .arg((*it)->getName())
615 .arg((*it)->getName())
619 .arg((*it)->getName())
620 .arg(
"get exception?");
628 const bool use_bcast,
const bool direct_response_desired)
629 : io_service_(new
IOService()), server_port_(server_port),
630 client_port_(client_port), shutdown_(true),
631 alloc_engine_(), use_bcast_(use_bcast),
634 test_send_responses_to_source_(false) {
636 const char* env = std::getenv(
"KEA_TEST_SEND_RESPONSES_TO_SOURCE");
639 test_send_responses_to_source_ =
true;
668 }
catch (
const std::exception &e) {
683 for (
auto it = dhcp4_statistics.begin(); it != dhcp4_statistics.end(); ++it) {
685 stats_mgr.
setValue((*it),
static_cast<int64_t
>(0));
695 }
catch (
const std::exception& ex) {
702 }
catch (
const std::exception& ex) {
714 HooksManager::prepareUnloadLibraries();
715 if (!HooksManager::unloadLibraries()) {
716 auto names = HooksManager::getLibraryNames();
718 if (!names.empty()) {
720 for (
size_t i = 1; i < names.size(); ++i) {
721 msg += std::string(
", ") + names[i];
736 bool sanity_only)
const {
739 if (query->isDhcp4o6()) {
748 subnet = cfgmgr.
getCurrentCfg()->getCfgSubnets4()->selectSubnet(selector);
753 HooksManager::calloutsPresent(
Hooks.hook_index_subnet4_select_)) {
766 callout_handle->setArgument(
"query4", query);
767 callout_handle->setArgument(
"subnet4", subnet);
768 callout_handle->setArgument(
"subnet4collection",
770 getCfgSubnets4()->getAll());
773 HooksManager::callCallouts(
Hooks.hook_index_subnet4_select_,
779 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
782 .arg(query->getLabel());
788 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
791 .arg(query->getLabel());
797 callout_handle->getArgument(
"subnet4", subnet);
803 .arg(query->getLabel())
804 .arg(subnet->getID());
808 .arg(query->getLabel())
809 .arg(subnet->toText());
814 .arg(query->getLabel());
822 bool sanity_only)
const {
827 selector.
ciaddr_ = query->getCiaddr();
828 selector.
giaddr_ = query->getGiaddr();
839 Pkt4o6Ptr query4o6 = boost::dynamic_pointer_cast<Pkt4o6>(query);
843 const Pkt6Ptr& query6 = query4o6->getPkt6();
846 if (query6 && !query6->relay_info_.empty()) {
862 OptionCustomPtr oc = boost::dynamic_pointer_cast<OptionCustom>(sbnsel);
869 subnet = cfgmgr.
getCurrentCfg()->getCfgSubnets4()->selectSubnet4o6(selector);
874 HooksManager::calloutsPresent(
Hooks.hook_index_subnet4_select_)) {
884 callout_handle->setArgument(
"query4", query);
885 callout_handle->setArgument(
"subnet4", subnet);
886 callout_handle->setArgument(
"subnet4collection",
888 getCfgSubnets4()->getAll());
891 HooksManager::callCallouts(
Hooks.hook_index_subnet4_select_,
897 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
900 .arg(query->getLabel());
906 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
909 .arg(query->getLabel());
915 callout_handle->getArgument(
"subnet4", subnet);
921 .arg(query->getLabel())
922 .arg(subnet->getID());
926 .arg(query->getLabel())
927 .arg(subnet->toText());
932 .arg(query->getLabel());
955 ctx->hwaddr_ = query->getHWAddr();
961 ctx->early_global_reservations_lookup_ = egrl->boolValue();
965 if (ctx->early_global_reservations_lookup_) {
969 ctx->clientid_.reset(
new ClientId(opt_clientid->getData()));
978 if (global_host && !global_host->getClientClasses4().empty()) {
983 const ClientClasses& classes = global_host->getClientClasses4();
985 cclass != classes.
cend(); ++cclass) {
986 query->addClass(*cclass);
995 query->addClass(
"KNOWN");
997 .arg(query->getLabel())
1004 if (query->inClass(
"DROP")) {
1007 .arg(query->toText());
1009 static_cast<int64_t
>(1));
1014 ctx->hosts_[SUBNET_ID_GLOBAL] = global_host;
1029 while (__AFL_LOOP(fuzzer.maxLoopCount())) {
1039 }
catch (
const std::exception& e) {
1056 MultiThreadingMgr::instance().apply(
false, 0, 0);
1070 uint32_t timeout = 1;
1081 .arg(query->getRemoteAddr().toText())
1082 .arg(query->getRemotePort())
1083 .arg(query->getLocalAddr().toText())
1084 .arg(query->getLocalPort())
1085 .arg(query->getIface());
1101 }
catch (
const std::exception& e) {
1116 .arg(query->getLabel());
1119 if (MultiThreadingMgr::instance().getMode()) {
1120 typedef function<void()> CallBack;
1121 boost::shared_ptr<CallBack> call_back =
1124 if (!MultiThreadingMgr::instance().getThreadPool().add(call_back)) {
1137 }
catch (
const std::exception& e) {
1164 static_cast<int64_t
>(1));
1166 bool skip_unpack =
false;
1170 if (HooksManager::calloutsPresent(
Hooks.hook_index_buffer4_receive_)) {
1183 callout_handle->setArgument(
"query4", query);
1186 HooksManager::callCallouts(
Hooks.hook_index_buffer4_receive_,
1192 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
1195 .arg(query->getRemoteAddr().toText())
1196 .arg(query->getLocalAddr().toText())
1197 .arg(query->getIface());
1205 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
1208 .arg(query->getRemoteAddr().toText())
1209 .arg(query->getLocalAddr().toText())
1210 .arg(query->getIface());
1214 callout_handle->getArgument(
"query4", query);
1222 .arg(query->getRemoteAddr().toText())
1223 .arg(query->getLocalAddr().toText())
1224 .arg(query->getIface());
1232 }
catch (
const std::exception& e) {
1235 .arg(query->getRemoteAddr().toText())
1236 .arg(query->getLocalAddr().toText())
1237 .arg(query->getIface())
1242 static_cast<int64_t
>(1));
1244 static_cast<int64_t
>(1));
1265 static_cast<int64_t
>(1));
1271 int type = query->getType();
1273 .arg(query->getLabel())
1274 .arg(query->getName())
1276 .arg(query->getRemoteAddr())
1277 .arg(query->getLocalAddr())
1278 .arg(query->getIface());
1280 .arg(query->getLabel())
1281 .arg(query->toText());
1284 if (HooksManager::calloutsPresent(
Hooks.hook_index_pkt4_receive_)) {
1297 callout_handle->setArgument(
"query4", query);
1300 HooksManager::callCallouts(
Hooks.hook_index_pkt4_receive_,
1306 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) ||
1307 (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP)) {
1310 .arg(query->getLabel());
1314 callout_handle->getArgument(
"query4", query);
1318 if (query->inClass(
"DROP")) {
1320 .arg(query->toText());
1322 static_cast<int64_t
>(1));
1331 bool allow_packet_park) {
1340 }
catch (
const std::exception& e) {
1350 bool allow_packet_park) {
1355 if (MultiThreadingMgr::instance().getMode() &&
1362 this, query, rsp, allow_packet_park));
1363 if (!client_handler.
tryLock(query, cont)) {
1374 switch (query->getType()) {
1404 }
catch (
const std::exception& e) {
1414 .arg(query->getLabel())
1419 static_cast<int64_t
>(1));
1423 if (ctx && HooksManager::calloutsPresent(
Hooks.hook_index_leases4_committed_)) {
1447 std::shared_ptr<ScopedCalloutHandleState> callout_handle_state =
1448 std::make_shared<ScopedCalloutHandleState>(callout_handle);
1453 callout_handle->setArgument(
"query4", query);
1457 if (ctx->new_lease_ && (ctx->new_lease_->reuseable_valid_lft_ == 0)) {
1458 new_leases->push_back(ctx->new_lease_);
1460 callout_handle->setArgument(
"leases4", new_leases);
1463 if (ctx->old_lease_) {
1464 if ((!ctx->new_lease_) || (ctx->new_lease_->addr_ != ctx->old_lease_->addr_)) {
1465 deleted_leases->push_back(ctx->old_lease_);
1468 callout_handle->setArgument(
"deleted_leases4", deleted_leases);
1470 if (allow_packet_park) {
1472 uint32_t parked_packet_limit = 0;
1476 parked_packet_limit = ppl->intValue();
1479 if (parked_packet_limit) {
1480 const auto& parking_lot = ServerHooks::getServerHooks().
1481 getParkingLotPtr(
"leases4_committed");
1483 if (parking_lot && (parking_lot->size() >= parked_packet_limit)) {
1487 .arg(parked_packet_limit)
1488 .arg(query->getLabel());
1490 static_cast<int64_t
>(1));
1500 HooksManager::park(
"leases4_committed", query,
1501 [
this, callout_handle, query, rsp, callout_handle_state]()
mutable {
1502 if (MultiThreadingMgr::instance().getMode()) {
1503 typedef function<void()> CallBack;
1504 boost::shared_ptr<CallBack> call_back =
1506 this, callout_handle, query, rsp));
1507 callout_handle_state->on_completion_ = [call_back]() {
1508 MultiThreadingMgr::instance().getThreadPool().add(call_back);
1519 HooksManager::callCallouts(
Hooks.hook_index_leases4_committed_,
1523 if (allow_packet_park) {
1524 HooksManager::drop(
"leases4_committed", query);
1530 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_PARK)
1531 && allow_packet_park) {
1533 .arg(query->getLabel());
1541 HooksManager::drop(
"leases4_committed", query);
1542 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
1544 .arg(query->getLabel());
1562 }
catch (
const std::exception& e) {
1578 bool skip_pack =
false;
1581 if (HooksManager::calloutsPresent(
Hooks.hook_index_pkt4_send_)) {
1594 callout_handle->setArgument(
"query4", query);
1597 callout_handle->setArgument(
"response4", rsp);
1600 HooksManager::callCallouts(
Hooks.hook_index_pkt4_send_,
1608 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
1610 .arg(query->getLabel());
1615 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
1617 .arg(rsp->getLabel());
1626 .arg(rsp->getLabel());
1628 }
catch (
const std::exception& e) {
1630 .arg(rsp->getLabel())
1648 if (HooksManager::calloutsPresent(
Hooks.hook_index_buffer4_send_)) {
1660 callout_handle->setArgument(
"response4", rsp);
1663 HooksManager::callCallouts(
Hooks.hook_index_buffer4_send_,
1669 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) ||
1670 (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP)) {
1673 .arg(rsp->getLabel());
1677 callout_handle->getArgument(
"response4", rsp);
1681 .arg(rsp->getLabel())
1682 .arg(rsp->getName())
1683 .arg(
static_cast<int>(rsp->getType()))
1684 .arg(rsp->getLocalAddr().isV4Zero() ?
"*" : rsp->getLocalAddr().toText())
1685 .arg(rsp->getLocalPort())
1686 .arg(rsp->getRemoteAddr())
1687 .arg(rsp->getRemotePort())
1688 .arg(rsp->getIface().empty() ?
"to be determined from routing" :
1693 .arg(rsp->getLabel())
1694 .arg(rsp->getName())
1695 .arg(
static_cast<int>(rsp->getType()))
1696 .arg(rsp->toText());
1702 }
catch (
const std::exception& e) {
1704 .arg(rsp->getLabel())
1714 boost::shared_ptr<Option4AddrLst> generated =
1715 boost::dynamic_pointer_cast<Option4AddrLst>(srvid);
1721 if (addrs.size() != 1) {
1723 <<
"Expected to contain a single IPv4 address.");
1726 return (addrs[0].toText());
1744 if (local_addr.
isV4Bcast() || query->isDhcp4o6()) {
1767 if (host && !host->getCfgOption4()->empty()) {
1768 co_list.push_back(host->getCfgOption4());
1775 addr = resp->getYiaddr();
1779 if (pool && !pool->getCfgOption()->empty()) {
1780 co_list.push_back(pool->getCfgOption());
1785 if (!subnet->getCfgOption()->empty()) {
1786 co_list.push_back(subnet->getCfgOption());
1791 subnet->getSharedNetwork(network);
1792 if (network && !network->getCfgOption()->empty()) {
1793 co_list.push_back(network->getCfgOption());
1799 cclass != classes.
cend(); ++cclass) {
1802 getClientClassDictionary()->findClass(*cclass);
1814 if (ccdef->getCfgOption()->empty()) {
1819 co_list.push_back(ccdef->getCfgOption());
1843 if (co_list.empty()) {
1849 std::vector<uint8_t> requested_opts;
1857 requested_opts = option_prl->
getValues();
1860 for (CfgOptionList::const_iterator copts = co_list.begin();
1861 copts != co_list.end(); ++copts) {
1869 for (OptionContainerPersistIndex::const_iterator desc = range.first;
1870 desc != range.second; ++desc) {
1872 if (desc->option_) {
1873 uint8_t code =
static_cast<uint8_t
>(desc->option_->getType());
1874 requested_opts.push_back(code);
1881 for (std::vector<uint8_t>::const_iterator opt = requested_opts.begin();
1882 opt != requested_opts.end(); ++opt) {
1884 if (!resp->getOption(*opt)) {
1886 for (CfgOptionList::const_iterator copts = co_list.begin();
1887 copts != co_list.end(); ++copts) {
1891 resp->addOption(desc.
option_);
1914 if (co_list.empty()) {
1918 uint32_t vendor_id = 0;
1923 boost::shared_ptr<OptionVendor> vendor_req = boost::dynamic_pointer_cast<
1933 boost::shared_ptr<OptionVendor> vendor_rsp = boost::dynamic_pointer_cast<
1939 if (!vendor_req && !vendor_rsp) {
1946 std::vector<uint8_t> requested_opts;
1959 oro = boost::dynamic_pointer_cast<OptionUint8Array>(oro_generic);
1962 requested_opts = oro->getValues();
1968 for (CfgOptionList::const_iterator copts = co_list.begin();
1969 copts != co_list.end(); ++copts) {
1978 for (OptionContainerPersistIndex::const_iterator desc = range.first;
1979 desc != range.second; ++desc) {
1981 if (desc->option_) {
1982 uint8_t code =
static_cast<uint8_t
>(desc->option_->getType());
1983 requested_opts.push_back(code);
1989 if (requested_opts.empty()) {
2001 for (std::vector<uint8_t>::const_iterator code = requested_opts.begin();
2002 code != requested_opts.end(); ++code) {
2003 if (!vendor_rsp->getOption(*code)) {
2004 for (CfgOptionList::const_iterator copts = co_list.begin();
2005 copts != co_list.end(); ++copts) {
2008 vendor_rsp->addOption(desc.
option_);
2027 static const uint16_t required_options[] = {
2033 static size_t required_options_size =
2034 sizeof(required_options) /
sizeof(required_options[0]);
2044 if (co_list.empty()) {
2052 for (
int i = 0; i < required_options_size; ++i) {
2053 OptionPtr opt = resp->getOption(required_options[i]);
2056 for (CfgOptionList::const_iterator copts = co_list.begin();
2057 copts != co_list.end(); ++copts) {
2059 required_options[i]);
2061 resp->addOption(desc.
option_);
2081 .arg(query->getLabel());
2082 processClientFqdnOption(ex);
2087 .arg(query->getLabel());
2088 processHostnameOption(ex);
2094 std::string hostname;
2095 bool fqdn_fwd =
false;
2096 bool fqdn_rev =
false;
2100 fqdn = boost::dynamic_pointer_cast<Option4ClientFqdn>(resp->getOption(
DHO_FQDN));
2102 hostname = fqdn->getDomainName();
2105 opt_hostname = boost::dynamic_pointer_cast<OptionString>
2109 hostname = opt_hostname->getValue();
2114 if (hostname ==
".") {
2120 if (ex.
getContext()->getDdnsParams()->getEnableUpdates()) {
2129 if (HooksManager::calloutsPresent(
Hooks.hook_index_ddns4_update_)) {
2140 callout_handle->setArgument(
"query4", query);
2141 callout_handle->setArgument(
"response4", resp);
2142 callout_handle->setArgument(
"subnet4", subnet);
2143 callout_handle->setArgument(
"hostname", hostname);
2144 callout_handle->setArgument(
"fwd-update", fqdn_fwd);
2145 callout_handle->setArgument(
"rev-update", fqdn_rev);
2146 callout_handle->setArgument(
"ddns-params", ex.
getContext()->getDdnsParams());
2149 HooksManager::callCallouts(
Hooks.hook_index_ddns4_update_, *callout_handle);
2152 string hook_hostname;
2153 bool hook_fqdn_fwd =
false;
2154 bool hook_fqdn_rev =
false;
2155 callout_handle->getArgument(
"hostname", hook_hostname);
2156 callout_handle->getArgument(
"fwd-update", hook_fqdn_fwd);
2157 callout_handle->getArgument(
"rev-update", hook_fqdn_rev);
2161 if ((hostname != hook_hostname) || (fqdn_fwd != hook_fqdn_fwd) ||
2162 (fqdn_rev != hook_fqdn_rev)) {
2164 .arg(hostname).arg(hook_hostname).arg(fqdn_fwd).arg(hook_fqdn_fwd)
2165 .arg(fqdn_rev).arg(hook_fqdn_rev);
2166 hostname = hook_hostname;
2167 fqdn_fwd = hook_fqdn_fwd;
2168 fqdn_rev = hook_fqdn_rev;
2172 OptionStringPtr hostname_opt = boost::dynamic_pointer_cast<OptionString>
2175 hostname_opt->setValue(hook_hostname);
2193 ctx->fwd_dns_update_ = fqdn_fwd;
2194 ctx->rev_dns_update_ = fqdn_rev;
2195 ctx->hostname_ = hostname;
2220 .arg(fqdn->toText());
2236 !ex.
getContext()->currentHost()->getHostname().empty()) {
2263 .arg(fqdn_resp->
toText());
2273 OptionStringPtr opt_hostname = boost::dynamic_pointer_cast<OptionString>
2279 .arg(opt_hostname->getValue());
2287 if (ctx->currentHost() && !ctx->currentHost()->getHostname().empty()) {
2289 std::string hostname = d2_mgr.
qualifyName(ctx->currentHost()->getHostname(),
2292 boost::algorithm::to_lower(hostname);
2310 ex.
getContext()->getDdnsParams()->getReplaceClientNameMode();
2313 if (!opt_hostname) {
2333 .arg(opt_hostname->getValue());
2336 unsigned int label_count;
2342 }
catch (
const std::exception& exc) {
2353 if (label_count == 0) {
2371 || label_count < 2) {
2385 ex.
getContext()->getDdnsParams()->getHostnameSanitizer();
2388 hostname = sanitizer->scrub(hostname);
2392 boost::algorithm::to_lower(hostname);
2394 if (label_count == 2) {
2402 opt_hostname_resp.reset(
2413 .arg(opt_hostname_resp->getValue());
2423 "NULL lease specified when creating NameChangeRequest");
2431 if (!old_lease || ddns_params.
getUpdateOnRenew() || !lease->hasIdenticalFqdn(*old_lease)) {
2462 .arg(query->getLabel())
2463 .arg(query->getRemoteAddr().toText())
2464 .arg(query->getName());
2480 if (opt_requested_address) {
2481 hint = opt_requested_address->readAddress();
2483 }
else if (!query->getCiaddr().isV4Zero()) {
2484 hint = query->getCiaddr();
2496 bool fake_allocation = (query->getType() ==
DHCPDISCOVER);
2506 if (!fake_allocation && !opt_serverid && opt_requested_address) {
2509 .arg(query->getLabel())
2510 .arg(hint.toText());
2526 if (!leases_client_id.empty()) {
2532 for (
auto l = leases_client_id.begin(); l != leases_client_id.end(); ++l) {
2533 if ((*l)->subnet_id_ == s->getID()) {
2543 s = s->getNextSubnet(original_subnet, query->getClasses());
2551 if (!lease && hwaddr) {
2555 if (!leases_hwaddr.empty()) {
2560 for (
auto l = leases_hwaddr.begin(); l != leases_hwaddr.end(); ++l) {
2561 if ((*l)->subnet_id_ == s->getID()) {
2571 s = s->getNextSubnet(original_subnet, query->getClasses());
2580 bool authoritative = original_subnet->getAuthoritative();
2581 bool known_client = lease && lease->belongsToClient(hwaddr, client_id);
2582 if (!authoritative && !known_client) {
2585 .arg(query->getLabel())
2586 .arg(hint.toText());
2594 if ((known_client && (lease->addr_ != hint)) ||
2595 (!known_client && authoritative)) {
2598 .arg(query->getLabel())
2599 .arg(hint.toText());
2610 ctx->requested_address_ = hint;
2611 ctx->fake_allocation_ = fake_allocation;
2612 ctx->callout_handle_ = callout_handle;
2628 bool client_name_changed =
false;
2632 if (subnet && ctx->subnet_ && subnet->getID() != ctx->subnet_->getID()) {
2634 subnet->getSharedNetwork(network);
2636 .arg(query->getLabel())
2637 .arg(subnet->toText())
2638 .arg(ctx->subnet_->toText())
2639 .arg(network ? network->getName() :
"<no network?>");
2641 subnet = ctx->subnet_;
2656 ctx->hostname_ =
"";
2657 ctx->fwd_dns_update_ =
false;
2658 ctx->rev_dns_update_ =
false;
2665 if ((lease->hostname_ != ctx->hostname_) ||
2666 (lease->fqdn_fwd_ != ctx->fwd_dns_update_) ||
2667 (lease->fqdn_rev_ != ctx->rev_dns_update_)) {
2668 lease->hostname_ = ctx->hostname_;
2669 lease->fqdn_fwd_ = ctx->fwd_dns_update_;
2670 lease->fqdn_rev_ = ctx->rev_dns_update_;
2671 client_name_changed =
true;
2679 if (fake_allocation) {
2681 .arg(query->getLabel())
2682 .arg(lease->addr_.toText());
2685 .arg(query->getLabel())
2686 .arg(lease->addr_.toText())
2694 if (!ctx->subnet_->getMatchClientId()) {
2696 .arg(ctx->query_->getLabel())
2697 .arg(ctx->subnet_->getID());
2700 resp->setYiaddr(lease->addr_);
2706 if (!fake_allocation) {
2711 resp->setCiaddr(query->getCiaddr());
2720 if (lease->reuseable_valid_lft_ > 0) {
2721 lease->valid_lft_ = lease->reuseable_valid_lft_;
2723 .arg(query->getLabel())
2724 .arg(lease->addr_.toText())
2730 lease->valid_lft_));
2731 resp->addOption(opt);
2734 resp->addOption(getNetmaskOption(subnet));
2740 if (!fake_allocation) {
2746 .arg(query->getLabel())
2754 if (ctx->unknown_requested_addr_) {
2766 s = s->getNextSubnet(original_subnet);
2774 .arg(query->getLabel())
2775 .arg(query->getCiaddr().toText())
2776 .arg(opt_requested_address ?
2777 opt_requested_address->readAddress().toText() :
"(no address)");
2785 .arg(query->getLabel())
2786 .arg(query->getCiaddr().toText())
2787 .arg(opt_requested_address ?
2788 opt_requested_address->readAddress().toText() :
"(no address)");
2800 const Pkt4Ptr& query,
const Pkt4Ptr& resp,
bool client_name_changed) {
2809 opt_hostname = boost::dynamic_pointer_cast<OptionString>(resp->getOption(
DHO_HOST_NAME));
2810 if (!opt_hostname) {
2817 if (lease->hostname_.empty()) {
2824 .
generateFqdn(lease->addr_, *(ctx->getDdnsParams()),
static_cast<bool>(fqdn));
2827 .arg(query->getLabel())
2828 .arg(lease->hostname_);
2830 client_name_changed =
true;
2833 if (client_name_changed) {
2838 if (!ctx->fake_allocation_) {
2840 lease->reuseable_valid_lft_ = 0;
2853 opt_hostname->setValue(lease->hostname_);
2857 .arg(query->getLabel())
2858 .arg(lease->hostname_)
2868 uint32_t t2_time = 0;
2870 if (!subnet->getT2().unspecified()) {
2871 t2_time = subnet->getT2();
2872 }
else if (subnet->getCalculateTeeTimes()) {
2874 t2_time =
static_cast<uint32_t
>(round(subnet->getT2Percent() * (lease->valid_lft_)));
2879 uint32_t timer_ceiling = lease->valid_lft_;
2880 if (t2_time > 0 && t2_time < timer_ceiling) {
2882 resp->addOption(t2);
2884 timer_ceiling = t2_time;
2887 uint32_t t1_time = 0;
2889 if (!subnet->getT1().unspecified()) {
2890 t1_time = subnet->getT1();
2891 }
else if (subnet->getCalculateTeeTimes()) {
2893 t1_time =
static_cast<uint32_t
>(round(subnet->getT1Percent() * (lease->valid_lft_)));
2898 if (t1_time > 0 && t1_time < timer_ceiling) {
2900 resp->addOption(t1);
2910 if (rai && rai->getOption(RAI_OPTION_RELAY_PORT)) {
2912 return (query->getRemotePort());
2940 }
else if (((query->getType() ==
DHCPINFORM) &&
2941 ((!query->getCiaddr().isV4Zero()) ||
2942 (!query->isRelayed() && !query->getRemoteAddr().isV4Zero()))) ||
2943 ((query->getType() !=
DHCPINFORM) && !query->isRelayed())) {
2944 response->setRemotePort(DHCP4_CLIENT_PORT);
2949 response->setRemotePort(relay_port ? relay_port : DHCP4_SERVER_PORT);
2953 if (query->isRelayed() &&
2959 response->resetIndex();
2961 response->setIface(query->getIface());
2965 IOAddress local_addr = query->getLocalAddr();
2974 if (local_addr.
isV4Bcast() || query->isDhcp4o6()) {
2985 response->setLocalAddr(local_addr);
2994 response->setIndex(query->getIndex());
2995 response->setIface(query->getIface());
3001 response->setLocalPort(DHCP4_SERVER_PORT);
3013 if (query->isDhcp4o6()) {
3014 response->setRemoteAddr(query->getRemoteAddr());
3026 if (!query->getCiaddr().isV4Zero()) {
3027 response->setRemoteAddr(query->getCiaddr());
3034 }
else if (query->isRelayed()) {
3035 response->setRemoteAddr(query->getGiaddr());
3036 response->setFlags(response->getFlags() | BOOTP_BROADCAST);
3041 response->setRemoteAddr(query->getRemoteAddr());
3048 if (query->isRelayed()) {
3057 query->getCiaddr().isV4Zero()) {
3058 response->setFlags(BOOTP_BROADCAST);
3060 response->setRemoteAddr(query->getGiaddr());
3064 }
else if (!query->getCiaddr().isV4Zero()) {
3065 response->setRemoteAddr(query->getCiaddr());
3070 }
else if (response->getType() ==
DHCPNAK) {
3074 }
else if (!response->getYiaddr().isV4Zero()) {
3089 response->setRemoteAddr(response ->getYiaddr());
3097 response->setRemoteAddr(query->getRemoteAddr());
3102 response->setRemoteAddr(query->getRemoteAddr());
3114 IOAddress subnet_next_server = subnet->getSiaddr();
3115 if (!subnet_next_server.
isV4Zero()) {
3116 response->setSiaddr(subnet_next_server);
3119 const string& sname = subnet->getSname();
3120 if (!sname.empty()) {
3126 response->setSname(
reinterpret_cast<const uint8_t*
>(sname.c_str()),
3130 const string& filename = subnet->getFilename();
3131 if (!filename.empty()) {
3137 response->setFile(
reinterpret_cast<const uint8_t*
>(filename.c_str()),
3145 if (!classes.
empty()) {
3158 size_t found_cnt = 0;
3160 name != classes.
cend() && found_cnt < 3; ++name) {
3172 next_server = cl->getNextServer();
3174 response->setSiaddr(next_server);
3179 if (sname.empty()) {
3180 sname = cl->getSname();
3181 if (!sname.empty()) {
3187 response->setSname(
reinterpret_cast<const uint8_t*
>(sname.c_str()),
3193 if (filename.empty()) {
3194 filename = cl->getFilename();
3195 if (!filename.empty()) {
3201 response->setFile(
reinterpret_cast<const uint8_t*
>(filename.c_str()),
3215Dhcpv4Srv::getNetmaskOption(
const Subnet4Ptr& subnet) {
3244 if (MultiThreadingMgr::instance().getMode()) {
3318 if (MultiThreadingMgr::instance().getMode()) {
3331 }
else if (request->inClass(
"BOOTP")) {
3333 response->addClass(
"BOOTP");
3337 if (!response->getYiaddr().isV4Zero()) {
3400 .arg(release->getLabel())
3401 .arg(release->getCiaddr().toText());
3405 if (!lease->belongsToClient(release->getHWAddr(), client_id)) {
3407 .arg(release->getLabel())
3408 .arg(release->getCiaddr().toText());
3415 if (HooksManager::calloutsPresent(
Hooks.hook_index_lease4_release_)) {
3428 callout_handle->setArgument(
"query4", release);
3431 callout_handle->setArgument(
"lease4", lease);
3434 HooksManager::callCallouts(
Hooks.hook_index_lease4_release_,
3440 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) ||
3441 (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP)) {
3445 .arg(release->getLabel());
3457 context->old_lease_ = lease;
3461 .arg(release->getLabel())
3462 .arg(lease->addr_.toText());
3465 StatsMgr::instance().addValue(
3466 StatsMgr::generateName(
"subnet", lease->subnet_id_,
"assigned-addresses"),
3467 static_cast<int64_t
>(-1));
3475 .arg(release->getLabel())
3476 .arg(lease->addr_.toText());
3481 .arg(release->getLabel())
3482 .arg(release->getCiaddr())
3499 if (!opt_requested_address) {
3502 " in DHCPDECLINE sent from " << decline->getLabel());
3504 IOAddress addr(opt_requested_address->readAddress());
3522 .arg(addr.
toText()).arg(decline->getLabel());
3530 client_id.reset(
new ClientId(opt_clientid->getData()));
3534 if (!lease->belongsToClient(decline->getHWAddr(), client_id)) {
3537 string client_hw = decline->getHWAddr() ?
3538 decline->getHWAddr()->toText(
false) :
"(none)";
3539 string lease_hw = lease->hwaddr_ ?
3540 lease->hwaddr_->toText(
false) :
"(none)";
3543 string client_id_txt = client_id ? client_id->toText() :
"(none)";
3544 string lease_id_txt = lease->client_id_ ?
3545 lease->client_id_->toText() :
"(none)";
3549 .arg(addr.
toText()).arg(decline->getLabel())
3550 .arg(client_hw).arg(lease_hw).arg(client_id_txt).arg(lease_id_txt);
3567 if (HooksManager::calloutsPresent(
Hooks.hook_index_lease4_decline_)) {
3580 callout_handle->setArgument(
"query4", decline);
3583 callout_handle->setArgument(
"lease4", lease);
3586 HooksManager::callCallouts(
Hooks.hook_index_lease4_decline_,
3591 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) ||
3592 (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP)) {
3594 .arg(decline->getLabel()).arg(lease->addr_.toText());
3599 Lease4Ptr old_values = boost::make_shared<Lease4>(*lease);
3613 .arg(decline->getLabel())
3614 .arg(lease->addr_.toText())
3626 StatsMgr::instance().addValue(
3627 StatsMgr::generateName(
"subnet", lease->subnet_id_,
"declined-addresses"),
3628 static_cast<int64_t
>(1));
3631 StatsMgr::instance().addValue(
"declined-addresses",
static_cast<int64_t
>(1));
3643 context->new_lease_ = lease;
3646 .arg(decline->getLabel()).arg(lease->valid_lft_);
3693 if (ack->getRemoteAddr() != inform->getGiaddr()) {
3695 .arg(inform->getLabel())
3696 .arg(ack->getRemoteAddr())
3697 .arg(ack->getIface());
3720 .arg(query->getLabel())
3721 .arg(query->getIface());
3729 .arg(query->getLabel())
3730 .arg(query->getIface());
3740 if (pkt->isRelayed()) {
3745 if (pkt->isDhcp4o6()) {
3754 if (pkt->getRemoteAddr().isV4Zero() &&
3755 pkt->getCiaddr().isV4Zero()) {
3766 bool result = (!pkt->getLocalAddr().isV4Bcast() ||
3781 type = query->getType();
3785 .arg(query->getLabel())
3786 .arg(query->getIface());
3810 .arg(query->getLabel());
3817 .arg(query->getLabel())
3822 .arg(query->getLabel())
3849 boost::dynamic_pointer_cast<OptionCustom>(option);
3852 if (!option_custom) {
3860 if (option_custom->getDataFieldsNum() != 1) {
3866 IOAddress server_id = option_custom->readAddress();
3867 if (!server_id.
isV4()) {
3875 OptionPtr rai_suboption = rai_option->getOption(RAI_OPTION_SERVER_ID_OVERRIDE);
3876 if (rai_suboption && (server_id.
toBytes() == rai_suboption->toBinary())) {
3917 if (cfg_subnets->hasSubnetWithServerId(server_id)) {
3924 if (cfg_networks->hasNetworkWithServerId(server_id)) {
3931 cclass != classes.
cend(); ++cclass) {
3934 getClientClassDictionary()->findClass(*cclass);
3939 if (ccdef->getCfgOption()->empty()) {
3944 OptionCustomPtr context_opt_server_id = boost::dynamic_pointer_cast<OptionCustom>
3946 if (context_opt_server_id && (context_opt_server_id->readAddress() == server_id)) {
3954 OptionCustomPtr opt_server_id = boost::dynamic_pointer_cast<OptionCustom>
3957 return (opt_server_id && (opt_server_id->readAddress() == server_id));
3967 <<
" received in message "
3968 << query->getName());
3975 " received in message "
3976 << query->getName());
3986 if (query->getHWAddr() && !query->getHWAddr()->hwaddr_.empty()) {
3995 if (!client_id || client_id->len() == client_id->getHeaderLen()) {
3997 " provided in message "
3998 << query->getName());
4015 subnet->getSharedNetwork(network);
4017 const ClientClasses& to_add = network->getRequiredClasses();
4019 cclass != to_add.
cend(); ++cclass) {
4027 cclass != to_add.
cend(); ++cclass) {
4035 addr = resp->getYiaddr();
4042 cclass != to_add.
cend(); ++cclass) {
4056 cclass != classes.
cend(); ++cclass) {
4079 query->addClass(*cclass);
4092 .arg(
"get exception?");
4100 BOOST_FOREACH(
const uint16_t& code, query->getDeferredOptions()) {
4105 cclass != classes.
cend(); ++cclass) {
4109 getClientClassDictionary()->findClass(*cclass);
4115 if (!ccdef->getCfgOptionDef()) {
4153 opt = def->optionFactory(
Option::V4, code, buf);
4154 }
catch (
const std::exception& e) {
4162 while (query->delOption(code)) {
4166 query->addOption(opt);
4178 this, ph::_1, ph::_2));
4196 arg(result).arg((ncr ? ncr->toText() :
" NULL "));
4208 std::stringstream tmp;
4212 tmp << endl << EXTENDED_VERSION << endl;
4213 tmp <<
"linked with:" << endl;
4214 tmp << Logger::getVersion() << endl;
4215 tmp << CryptoLink::getVersion() << endl;
4216 tmp <<
"database:" << endl;
4235 string stat_name =
"pkt4-unknown-received";
4237 switch (query->getType()) {
4239 stat_name =
"pkt4-discover-received";
4243 stat_name =
"pkt4-offer-received";
4246 stat_name =
"pkt4-request-received";
4250 stat_name =
"pkt4-ack-received";
4254 stat_name =
"pkt4-nak-received";
4257 stat_name =
"pkt4-release-received";
4260 stat_name =
"pkt4-decline-received";
4263 stat_name =
"pkt4-inform-received";
4277 static_cast<int64_t
>(1));
4283 static_cast<int64_t
>(1));
4287 switch (response->getType()) {
4289 stat_name =
"pkt4-offer-sent";
4292 stat_name =
"pkt4-ack-sent";
4295 stat_name =
"pkt4-nak-sent";
4303 static_cast<int64_t
>(1));
4307 return (
Hooks.hook_index_buffer4_receive_);
4311 return (
Hooks.hook_index_pkt4_receive_);
4315 return (
Hooks.hook_index_subnet4_select_);
4319 return (
Hooks.hook_index_lease4_release_);
4323 return (
Hooks.hook_index_pkt4_send_);
4327 return (
Hooks.hook_index_buffer4_send_);
4331 return (
Hooks.hook_index_lease4_decline_);
4336 HooksManager::clearParkingLots();
4340 static std::list<std::list<std::string>>
const list({
4341 {
"config-control",
"config-databases",
"[]"},
4342 {
"hooks-libraries",
"[]",
"parameters",
"*"},
4344 {
"hosts-databases",
"[]"},
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 when an unexpected error condition occurs.
The IOAddress class represents an IP addresses (version agnostic)
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
bool isV4Zero() const
Convenience function to check if it is an IPv4 zero address.
std::string toText() const
Convert the address to a string.
static const IOAddress & IPV4_BCAST_ADDRESS()
Returns a "255.255.255.255" broadcast address.
uint32_t toUint32() const
Converts IPv4 address to uint32_t.
bool isV4() const
Convenience function to check for an IPv4 address.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
bool isV6Zero() const
Convenience function to check if it is an IPv4 zero address.
bool isV4Bcast() const
Convenience function to check if it is an IPv4 broadcast address.
bool isV6LinkLocal() const
checks whether and address is IPv6 and is link-local
The IOService class is a wrapper for the ASIO io_service class.
DHCPv4 and DHCPv6 allocation engine.
boost::shared_ptr< ClientContext4 > ClientContext4Ptr
Pointer to the ClientContext4.
Implementation of the mechanisms to control the use of the Configuration Backends by the DHCPv4 serve...
@ EARLY_GLOBAL_RESERVATIONS_LOOKUP
@ USE_ROUTING
Server uses routing to determine the right interface to send response.
@ SOCKET_UDP
Datagram socket, i.e. IP/UDP socket.
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
static SubnetSelector initSelector(const Pkt4Ptr &query)
Build selector from a client's message.
Container for storing client class names.
ClientClassContainer::const_iterator const_iterator
Type of iterators.
void insert(const ClientClass &class_name)
Insert an element.
bool empty() const
Check if classes is empty.
std::string toText(const std::string &separator=", ") const
Returns all class names as text.
const_iterator cbegin() const
Iterators to the first element.
const_iterator cend() const
Iterators to the past the end element.
Client race avoidance RAII handler.
bool tryLock(Pkt4Ptr query, ContinuationPtr cont=ContinuationPtr())
Tries to acquires a client.
Holds Client identifier or client IPv4 address.
ReplaceClientNameMode
Defines the client name replacement modes.
D2ClientMgr isolates Kea from the details of being a D2 client.
std::string generateFqdn(const asiolink::IOAddress &address, const DdnsParams &ddns_params, const bool trailing_dot=true) const
Builds a FQDN based on the configuration and given IP address.
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS is enabled.
void startSender(D2ClientErrorHandler error_handler, isc::asiolink::IOService &io_service)
Enables sending NameChangeRequests to kea-dhcp-ddns.
void getUpdateDirections(const T &fqdn_resp, bool &forward, bool &reverse)
Get directional update flags based on server FQDN flags.
void suspendUpdates()
Suspends sending requests.
void adjustDomainName(const T &fqdn, T &fqdn_resp, const DdnsParams &ddns_params)
Set server FQDN name based on configuration and a given FQDN.
void stopSender()
Disables sending NameChangeRequests to kea-dhcp-ddns.
void adjustFqdnFlags(const T &fqdn, T &fqdn_resp, const DdnsParams &ddns_params)
Set server FQDN flags based on configuration and a given FQDN.
std::string qualifyName(const std::string &partial_name, const DdnsParams &ddns_params, const bool trailing_dot) const
Adds a qualifying suffix to a given domain name.
Convenience container for conveying DDNS behavioral parameters It is intended to be created per Packe...
bool getUpdateOnRenew() const
Returns whether or not DNS should be updated when leases renew.
bool getEnableUpdates() const
Returns whether or not DHCP DDNS updating is enabled.
void close()
Close communication socket.
static Dhcp4to6Ipc & instance()
Returns pointer to the sole instance of Dhcp4to6Ipc.
AllocEngine::ClientContext4Ptr getContext() const
Returns the copy of the context for the Allocation engine.
void deleteResponse()
Removes the response message by resetting the pointer to NULL.
Pkt4Ptr getQuery() const
Returns the pointer to the query from the client.
static void setHostIdentifiers(AllocEngine::ClientContext4Ptr context)
Set host identifiers within a context.
Dhcpv4Exchange(const AllocEnginePtr &alloc_engine, const Pkt4Ptr &query, AllocEngine::ClientContext4Ptr &context, const Subnet4Ptr &subnet, bool &drop)
Constructor.
static void classifyByVendor(const Pkt4Ptr &pkt)
Assign class using vendor-class-identifier option.
void initResponse()
Initializes the instance of the response message.
void setReservedMessageFields()
Sets reserved values of siaddr, sname and file in the server's response.
CfgOptionList & getCfgOptionList()
Returns the configured option list (non-const version)
Pkt4Ptr getResponse() const
Returns the pointer to the server's response.
static void setReservedClientClasses(AllocEngine::ClientContext4Ptr context)
Assigns classes retrieved from host reservation database.
void initResponse4o6()
Initializes the DHCPv6 part of the response message.
static void evaluateClasses(const Pkt4Ptr &pkt, bool depend_on_known)
Evaluate classes.
static void classifyPacket(const Pkt4Ptr &pkt)
Assigns incoming packet to zero or more classes.
static void removeDependentEvaluatedClasses(const Pkt4Ptr &query)
Removed evaluated client classes.
void conditionallySetReservedClientClasses()
Assigns classes retrieved from host reservation database if they haven't been yet set.
int run()
Main server processing loop.
void declineLease(const Lease4Ptr &lease, const Pkt4Ptr &decline, AllocEngine::ClientContext4Ptr &context)
Marks lease as declined.
void classifyPacket(const Pkt4Ptr &pkt)
Assigns incoming packet to zero or more classes.
void appendRequestedVendorOptions(Dhcpv4Exchange &ex)
Appends requested vendor options as requested by client.
void adjustIfaceData(Dhcpv4Exchange &ex)
Set IP/UDP and interface parameters for the DHCPv4 response.
void run_one()
Main server processing step.
static uint16_t checkRelayPort(const Dhcpv4Exchange &ex)
Check if the relay port RAI sub-option was set in the query.
bool acceptDirectRequest(const Pkt4Ptr &query) const
Check if a message sent by directly connected client should be accepted or discarded.
virtual ~Dhcpv4Srv()
Destructor. Used during DHCPv4 service shutdown.
virtual Pkt4Ptr receivePacket(int timeout)
dummy wrapper around IfaceMgr::receive4
void processPacketAndSendResponseNoThrow(Pkt4Ptr &query)
Process a single incoming DHCPv4 packet and sends the response.
static void appendServerID(Dhcpv4Exchange &ex)
Adds server identifier option to the server's response.
void postAllocateNameUpdate(const AllocEngine::ClientContext4Ptr &ctx, const Lease4Ptr &lease, const Pkt4Ptr &query, const Pkt4Ptr &resp, bool client_name_changed)
Update client name and DNS flags in the lease and response.
void processDhcp4QueryAndSendResponse(Pkt4Ptr &query, Pkt4Ptr &rsp, bool allow_packet_park)
Process a single incoming DHCPv4 query.
void startD2()
Starts DHCP_DDNS client IO if DDNS updates are enabled.
bool accept(const Pkt4Ptr &query) const
Checks whether received message should be processed or discarded.
static int getHookIndexBuffer4Receive()
Returns the index for "buffer4_receive" hook point.
Pkt4Ptr processRequest(Pkt4Ptr &request, AllocEngine::ClientContext4Ptr &context)
Processes incoming REQUEST and returns REPLY response.
static void processStatsReceived(const Pkt4Ptr &query)
Class methods for DHCPv4-over-DHCPv6 handler.
static int getHookIndexPkt4Send()
Returns the index for "pkt4_send" hook point.
void processDecline(Pkt4Ptr &decline, AllocEngine::ClientContext4Ptr &context)
Process incoming DHCPDECLINE messages.
Dhcpv4Srv(uint16_t server_port=DHCP4_SERVER_PORT, uint16_t client_port=0, const bool use_bcast=true, const bool direct_response_desired=true)
Default constructor.
static int getHookIndexSubnet4Select()
Returns the index for "subnet4_select" hook point.
static void processStatsSent(const Pkt4Ptr &response)
Updates statistics for transmitted packets.
void shutdown() override
Instructs the server to shut down.
static int getHookIndexLease4Release()
Returns the index for "lease4_release" hook point.
void adjustRemoteAddr(Dhcpv4Exchange &ex)
Sets remote addresses for outgoing packet.
void processDhcp4Query(Pkt4Ptr &query, Pkt4Ptr &rsp, bool allow_packet_park)
Process a single incoming DHCPv4 query.
static int getHookIndexPkt4Receive()
Returns the index for "pkt4_receive" hook point.
void assignLease(Dhcpv4Exchange &ex)
Assigns a lease and appends corresponding options.
asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service used by the server.
void setFixedFields(Dhcpv4Exchange &ex)
Sets fixed fields of the outgoing packet.
void appendBasicOptions(Dhcpv4Exchange &ex)
Append basic options if they are not present.
void sendResponseNoThrow(hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &query, Pkt4Ptr &rsp)
Process an unparked DHCPv4 packet and sends the response.
void processClientName(Dhcpv4Exchange &ex)
Processes Client FQDN and Hostname Options sent by a client.
boost::shared_ptr< AllocEngine > alloc_engine_
Allocation Engine.
void requiredClassify(Dhcpv4Exchange &ex)
Assigns incoming packet to zero or more classes (required pass).
Pkt4Ptr processInform(Pkt4Ptr &inform, AllocEngine::ClientContext4Ptr &context)
Processes incoming DHCPINFORM messages.
uint16_t client_port_
UDP port number to which server sends all responses.
std::list< std::list< std::string > > jsonPathsToRedact() const final override
Return a list of all paths that contain passwords or secrets for kea-dhcp4.
static std::string srvidToString(const OptionPtr &opt)
converts server-id to text Converts content of server-id option to a text representation,...
bool acceptServerId(const Pkt4Ptr &pkt) const
Verifies if the server id belongs to our server.
static const std::string VENDOR_CLASS_PREFIX
this is a prefix added to the content of vendor-class option
void createNameChangeRequests(const Lease4Ptr &lease, const Lease4Ptr &old_lease, const DdnsParams &ddns_params)
Creates NameChangeRequests which correspond to the lease which has been acquired.
void appendRequestedOptions(Dhcpv4Exchange &ex)
Appends options requested by client.
void setPacketStatisticsDefaults()
This function sets statistics related to DHCPv4 packets processing to their initial values.
static std::string getVersion(bool extended)
returns Kea version on stdout and exit.
isc::dhcp::Subnet4Ptr selectSubnet4o6(const Pkt4Ptr &query, bool &drop, bool sanity_only=false) const
Selects a subnet for a given client's DHCP4o6 packet.
void buildCfgOptionList(Dhcpv4Exchange &ex)
Build the configured option list.
volatile bool shutdown_
Indicates if shutdown is in progress.
uint16_t server_port_
UDP port number on which server listens.
bool earlyGHRLookup(const Pkt4Ptr &query, AllocEngine::ClientContext4Ptr ctx)
Initialize client context and perform early global reservations lookup.
NetworkStatePtr network_state_
Holds information about disabled DHCP service and/or disabled subnet/network scopes.
void setTeeTimes(const Lease4Ptr &lease, const Subnet4Ptr &subnet, Pkt4Ptr resp)
Adds the T1 and T2 timers to the outbound response as appropriate.
bool getSendResponsesToSource() const
Returns value of the test_send_responses_to_source_ flag.
void processPacketAndSendResponse(Pkt4Ptr &query)
Process a single incoming DHCPv4 packet and sends the response.
isc::dhcp::Subnet4Ptr selectSubnet(const Pkt4Ptr &query, bool &drop, bool sanity_only=false) const
Selects a subnet for a given client's packet.
Pkt4Ptr processDiscover(Pkt4Ptr &discover, AllocEngine::ClientContext4Ptr &context)
Processes incoming DISCOVER and returns response.
virtual void d2ClientErrorHandler(const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)
Implements the error handler for DHCP_DDNS IO errors.
virtual void sendPacket(const Pkt4Ptr &pkt)
dummy wrapper around IfaceMgr::send()
static int getHookIndexBuffer4Send()
Returns the index for "buffer4_send" hook point.
void stopD2()
Stops DHCP_DDNS client IO if DDNS updates are enabled.
bool acceptMessageType(const Pkt4Ptr &query) const
Check if received message type is valid for the server to process.
static void sanityCheck(const Pkt4Ptr &query, RequirementLevel serverid)
Verifies if specified packet meets RFC requirements.
void processPacket(Pkt4Ptr &query, Pkt4Ptr &rsp, bool allow_packet_park=true)
Process a single incoming DHCPv4 packet.
void discardPackets()
Discards parked packets Clears the packet parking lots of all packets.
static int getHookIndexLease4Decline()
Returns the index for "lease4_decline" hook point.
void processRelease(Pkt4Ptr &release, AllocEngine::ClientContext4Ptr &context)
Processes incoming DHCPRELEASE messages.
void processPacketPktSend(hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &query, Pkt4Ptr &rsp)
Executes pkt4_send callout.
RequirementLevel
defines if certain option may, must or must not appear
void processPacketBufferSend(hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &rsp)
Executes buffer4_send callout and sends the response.
void deferredUnpack(Pkt4Ptr &query)
Perform deferred option unpacking.
IdentifierType
Type of the host identifier.
@ IDENT_FLEX
Flexible host identifier.
std::string getIdentifierAsText() const
Returns host identifier in a textual form.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
bool isDirectResponseSupported() const
Check if packet be sent directly to the client having no address.
bool send(const Pkt6Ptr &pkt)
Sends an IPv6 packet.
void closeSockets()
Closes all open sockets.
void setMatchingPacketFilter(const bool direct_response_desired=false)
Set Packet Filter object to handle send/receive packets.
uint16_t getSocket(const isc::dhcp::Pkt6Ptr &pkt)
Return most suitable socket for transmitting specified IPv6 packet.
static void destroy()
Destroy lease manager.
static LeaseMgr & instance()
Return current lease manager.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const =0
Returns an IPv4 lease for specified IPv4 address.
virtual bool deleteLease(const Lease4Ptr &lease)=0
Deletes an IPv4 lease.
static std::string getDBVersion()
Class method to return extended version info This class method must be redeclared and redefined in de...
virtual void updateLease4(const Lease4Ptr &lease4)=0
Updates IPv4 lease.
static OptionDefinitionPtr getOptionDef(const std::string &space, const uint16_t code)
Return the first option definition matching a particular option code.
static OptionDefinitionPtr getRuntimeOptionDef(const std::string &space, const uint16_t code)
Returns runtime (non-standard) option definition by space and option code.
static OptionDefinitionPtr getLastResortOptionDef(const std::string &space, const uint16_t code)
Returns last resort option definition by space and option code.
static std::string getDBVersion()
Local version of getDBVersion() class method.
Holds information about DHCP service enabling status.
DHCPv4 Option class for handling list of IPv4 addresses.
std::vector< isc::asiolink::IOAddress > AddressContainer
Defines a collection of IPv4 addresses.
Represents DHCPv4 Client FQDN Option (code 81).
static const uint8_t FLAG_N
Bit N.
bool getFlag(const uint8_t flag) const
Checks if the specified flag of the DHCPv4 Client FQDN Option is set.
static const uint8_t FLAG_S
Bit S.
void setDomainName(const std::string &domain_name, const DomainNameType domain_name_type)
Set new domain-name.
void setFlag(const uint8_t flag, const bool set)
Modifies the value of the specified DHCPv4 Client Fqdn Option flag.
static const uint8_t FLAG_E
Bit E.
virtual std::string toText(int indent=0) const
Returns string representation of the option.
Option with defined data fields represented as buffers that can be accessed using data field index.
static unsigned int getLabelCount(const std::string &text_name)
Return the number of labels in the Name.
OptionPtr option_
Option instance.
Forward declaration to OptionIntArray.
const std::vector< T > & getValues() const
Return collection of option values.
Forward declaration to OptionInt.
Class which represents an option carrying a single string value.
This class represents vendor-specific information option.
uint32_t getVendorId() const
Returns enterprise identifier.
static const size_t OPTION4_HDR_LEN
length of the usual DHCPv4 option header (there are exceptions)
static std::string getDBVersion()
Local version of getDBVersion() class method.
Represents DHCPv4 packet.
static const uint16_t FLAG_BROADCAST_MASK
Mask for the value of flags field in the DHCPv4 message to check whether client requested broadcast r...
Represents DHCPv4-over-DHCPv6 packet.
Represents a DHCPv6 packet.
An exception that is thrown if a DHCPv6 protocol violation occurs while processing a message (e....
RAII object enabling copying options retrieved from the packet.
Exception thrown when a call to select is interrupted by a signal.
Exception thrown during option unpacking This exception is thrown when an error has occurred,...
Result
Defines the outcome of an asynchronous NCR send.
Wrapper class around callout handle which automatically resets handle's state.
int getExitValue()
Fetches the exit value.
Statistics Manager class.
static StatsMgr & instance()
Statistics Manager accessor method.
RAII class creating a critical section.
Contains declarations for loggers used by the DHCPv4 server component.
Defines the Dhcp4o6Ipc class.
#define VENDOR_ID_CABLE_LABS
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< OptionUint8Array > OptionUint8ArrayPtr
OptionInt< uint32_t > OptionUint32
boost::shared_ptr< OptionUint32 > OptionUint32Ptr
void setValue(const std::string &name, const int64_t value)
Records absolute integer observation.
void addValue(const std::string &name, const int64_t value)
Records incremental integer observation.
An abstract API for lease database.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
IOAddress getNetmask4(uint8_t len)
Generates an IPv4 netmask of specified length.
boost::shared_ptr< const Element > ConstElementPtr
const char *const config_report[]
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
const isc::log::MessageID DHCP4_BUFFER_RECEIVE_FAIL
isc::log::Logger ddns4_logger(DHCP4_DDNS_LOGGER_NAME)
Logger for Hostname or FQDN processing.
const isc::log::MessageID DHCP4_PACKET_DROP_0004
const isc::log::MessageID DHCP4_SRV_DHCP4O6_ERROR
const isc::log::MessageID DHCP4_RELEASE_EXCEPTION
const isc::log::MessageID DHCP4_SUBNET_DATA
const isc::log::MessageID DHCP4_INIT_REBOOT
const isc::log::MessageID DHCP4_HOOK_PACKET_SEND_SKIP
const isc::log::MessageID DHCP4_FLEX_ID
const isc::log::MessageID DHCP4_PACKET_DROP_0003
const isc::log::MessageID DHCP4_DEFERRED_OPTION_UNPACK_FAIL
const isc::log::MessageID DHCP4_PACKET_DROP_0001
const isc::log::MessageID DHCP4_QUERY_DATA
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
const isc::log::MessageID DHCP4_NO_LEASE_INIT_REBOOT
const isc::log::MessageID DHCP4_INFORM_DIRECT_REPLY
boost::shared_ptr< Lease4Collection > Lease4CollectionPtr
A shared pointer to the collection of IPv4 leases.
void queueNCR(const NameChangeType &chg_type, const Lease4Ptr &lease)
Creates name change request from the DHCPv4 lease.
const isc::log::MessageID DHCP4_CLIENT_FQDN_PROCESS
const isc::log::MessageID DHCP4_DEFERRED_OPTION_MISSING
const isc::log::MessageID EVAL_RESULT
const isc::log::MessageID DHCP4_HOOK_SUBNET4_SELECT_DROP
@ DHO_DOMAIN_NAME_SERVERS
@ DHO_VENDOR_CLASS_IDENTIFIER
@ DHO_DHCP_REBINDING_TIME
@ DHO_DHCP_SERVER_IDENTIFIER
@ DHO_DHCP_CLIENT_IDENTIFIER
@ DHO_DHCP_REQUESTED_ADDRESS
@ DHO_DHCP_PARAMETER_REQUEST_LIST
const isc::log::MessageID DHCP4_PACKET_DROP_0008
const isc::log::MessageID DHCP4_HOOK_LEASES4_COMMITTED_DROP
const isc::log::MessageID DHCP4_RELEASE_FAIL_WRONG_CLIENT
const isc::log::MessageID DHCP4_LEASE_ADVERT
const isc::log::MessageID DHCP4_HOOK_BUFFER_RCVD_DROP
boost::shared_ptr< OptionCustom > OptionCustomPtr
A pointer to the OptionCustom object.
const isc::log::MessageID DHCP4_HOOK_PACKET_RCVD_SKIP
const int DBG_DHCP4_BASIC_DATA
Debug level used to log the traces with some basic data.
const isc::log::MessageID DHCP4_LEASE_ALLOC
const int DBG_DHCP4_DETAIL
Debug level used to trace detailed errors.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
isc::log::Logger lease4_logger(DHCP4_LEASE_LOGGER_NAME)
Logger for lease allocation logic.
const isc::log::MessageID DHCP4_NCR_CREATION_FAILED
isc::log::Logger options4_logger(DHCP4_OPTIONS_LOGGER_NAME)
Logger for options parser.
const isc::log::MessageID DHCP4_HOOK_SUBNET4_SELECT_SKIP
const int DBG_DHCP4_DETAIL_DATA
This level is used to log the contents of packets received and sent.
const isc::log::MessageID DHCP4_PACKET_PACK
boost::shared_ptr< AllocEngine > AllocEnginePtr
A pointer to the AllocEngine object.
ContinuationPtr makeContinuation(Continuation &&cont)
Continuation factory.
const isc::log::MessageID DHCP4_DECLINE_FAIL
const isc::log::MessageID DHCP4_LEASE_REUSE
boost::shared_ptr< const CfgHostOperations > ConstCfgHostOperationsPtr
Pointer to the const object.
boost::shared_ptr< CfgIface > CfgIfacePtr
A pointer to the CfgIface .
const isc::log::MessageID DHCP4_PACKET_PACK_FAIL
boost::shared_ptr< ClientClassDef > ClientClassDefPtr
a pointer to an ClientClassDef
const isc::log::MessageID DHCP4_DDNS_REQUEST_SEND_FAILED
const isc::log::MessageID DHCP4_GENERATE_FQDN
const isc::log::MessageID DHCP4_CLASS_ASSIGNED
const isc::log::MessageID DHCP4_PACKET_PROCESS_STD_EXCEPTION
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
const isc::log::MessageID DHCP4_RESPONSE_HOSTNAME_DATA
const isc::log::MessageID DHCP4_BUFFER_WAIT_SIGNAL
const isc::log::MessageID DHCP4_HOOK_LEASE4_RELEASE_SKIP
const isc::log::MessageID DHCP4_POST_ALLOCATION_NAME_UPDATE_FAIL
const isc::log::MessageID DHCP4_PACKET_NAK_0001
const isc::log::MessageID DHCP4_HOOK_DECLINE_SKIP
const isc::log::MessageID DHCP4_DECLINE_LEASE_MISMATCH
const isc::log::MessageID DHCP4_SRV_UNLOAD_LIBRARIES_ERROR
const isc::log::MessageID DHCP4_RESPONSE_HOSTNAME_GENERATE
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
const isc::log::MessageID DHCP4_PACKET_DROP_0013
const isc::log::MessageID DHCP4_PACKET_QUEUE_FULL
const isc::log::MessageID DHCP4_PACKET_DROP_0009
const isc::log::MessageID DHCP4_PACKET_RECEIVED
boost::shared_ptr< Pkt4o6 > Pkt4o6Ptr
A pointer to Pkt4o6 object.
const isc::log::MessageID DHCP4_BUFFER_UNPACK
const isc::log::MessageID DHCP4_CLIENT_HOSTNAME_DATA
const isc::log::MessageID DHCP4_PACKET_SEND_FAIL
std::pair< OptionContainerPersistIndex::const_iterator, OptionContainerPersistIndex::const_iterator > OptionContainerPersistRange
Pair of iterators to represent the range of options having the same persistency flag.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
boost::shared_ptr< Option4ClientFqdn > Option4ClientFqdnPtr
A pointer to the Option4ClientFqdn object.
const isc::log::MessageID DHCP4_CLIENTID_IGNORED_FOR_LEASES
const isc::log::MessageID DHCP4_CLIENT_NAME_PROC_FAIL
const isc::log::MessageID DHCP4_CLIENT_HOSTNAME_PROCESS
const isc::log::MessageID DHCP4_HOOK_DDNS_UPDATE
const isc::log::MessageID DHCP4_SRV_CONSTRUCT_ERROR
boost::shared_ptr< Expression > ExpressionPtr
const isc::log::MessageID DHCP4_RELEASE_FAIL
const isc::log::MessageID DHCP4_RELEASE_FAIL_NO_LEASE
const isc::log::MessageID DHCP4_CLIENT_HOSTNAME_MALFORMED
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
boost::shared_ptr< OptionString > OptionStringPtr
Pointer to the OptionString object.
isc::log::Logger bad_packet4_logger(DHCP4_BAD_PACKET_LOGGER_NAME)
Logger for rejected packets.
isc::hooks::CalloutHandlePtr getCalloutHandle(const T &pktptr)
CalloutHandle Store.
const isc::log::MessageID DHCP4_PACKET_DROP_0006
const int DBG_DHCP4_BASIC
Debug level used to trace basic operations within the code.
boost::shared_ptr< ClientClassDictionary > ClientClassDictionaryPtr
Defines a pointer to a ClientClassDictionary.
const isc::log::MessageID DHCP4_SRV_D2STOP_ERROR
const isc::log::MessageID DHCP4_RESPONSE_FQDN_DATA
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
boost::shared_ptr< Continuation > ContinuationPtr
Define the type of shared pointers to continuations.
const isc::log::MessageID DHCP4_DECLINE_LEASE_NOT_FOUND
boost::shared_ptr< OptionContainer > OptionContainerPtr
Pointer to the OptionContainer object.
const isc::log::MessageID DHCP4_CLASS_UNTESTABLE
boost::shared_ptr< ClientClassDefList > ClientClassDefListPtr
Defines a pointer to a ClientClassDefList.
const isc::log::MessageID DHCP4_PACKET_DROP_0005
const isc::log::MessageID DHCP4_SUBNET_DYNAMICALLY_CHANGED
const isc::log::MessageID DHCP4_SHUTDOWN_REQUEST
@ DHCP_NOTYPE
Message Type option missing.
const char *const * dhcp4_config_report
const isc::log::MessageID DHCP4_PACKET_NAK_0003
const isc::log::MessageID DHCP4_TESTING_MODE_SEND_TO_SOURCE_ENABLED
boost::shared_ptr< const CfgSubnets4 > ConstCfgSubnets4Ptr
Const pointer.
const isc::log::MessageID DHCP4_BUFFER_RECEIVED
bool evaluateBool(const Expression &expr, Pkt &pkt)
Evaluate a RPN expression for a v4 or v6 packet and return a true or false decision.
const isc::log::MessageID DHCP4_SUBNET_SELECTION_FAILED
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
const isc::log::MessageID DHCP4_RESPONSE_DATA
isc::log::Logger packet4_logger(DHCP4_PACKET_LOGGER_NAME)
Logger for processed packets.
OptionContainer::nth_index< 2 >::type OptionContainerPersistIndex
Type of the index #2 - option persistency flag.
const isc::log::MessageID DHCP4_DECLINE_LEASE
const isc::log::MessageID DHCP4_PACKET_SEND
const isc::log::MessageID DHCP4_RELEASE
const isc::log::MessageID DHCP4_HOOK_BUFFER_RCVD_SKIP
const isc::log::MessageID DHCP4_UNKNOWN_ADDRESS_REQUESTED
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
const isc::log::MessageID DHCP4_OPEN_SOCKET
const isc::log::MessageID DHCP4_PACKET_DROP_0007
boost::shared_ptr< CfgSharedNetworks4 > CfgSharedNetworks4Ptr
Pointer to the configuration of IPv4 shared networks.
const isc::log::MessageID DHCP4_HOOK_PACKET_SEND_DROP
const isc::log::MessageID DHCP4_RESERVED_HOSTNAME_ASSIGNED
isc::log::Logger dhcp4_logger(DHCP4_APP_LOGGER_NAME)
Base logger for DHCPv4 server.
bool isClientClassBuiltIn(const ClientClass &client_class)
Check if a client class name is builtin.
const isc::log::MessageID DHCP4_PACKET_NAK_0002
const int DBG_DHCP4_HOOKS
Debug level used to trace hook related operations.
boost::shared_ptr< SharedNetwork4 > SharedNetwork4Ptr
Pointer to SharedNetwork4 object.
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
const isc::log::MessageID DHCP4_HOOK_BUFFER_SEND_SKIP
const isc::log::MessageID DHCP4_PACKET_PROCESS_EXCEPTION
const isc::log::MessageID DHCP4_PACKET_OPTIONS_SKIPPED
const isc::log::MessageID DHCP4_EMPTY_HOSTNAME
const isc::log::MessageID DHCP4_SUBNET_SELECTED
const isc::log::MessageID DHCP4_PACKET_DROP_0010
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
const isc::log::MessageID DHCP4_CLASS_UNCONFIGURED
boost::shared_ptr< Option > OptionPtr
const int DBG_DHCP4_START
Debug level used to log information during server startup.
const isc::log::MessageID DHCP4_CLASS_UNDEFINED
const isc::log::MessageID DHCP4_HOOK_LEASES4_COMMITTED_PARK
const isc::log::MessageID DHCP4_HOOK_LEASES4_PARKING_LOT_FULL
const isc::log::MessageID DHCP4_PACKET_DROP_0014
std::list< ConstCfgOptionPtr > CfgOptionList
Const pointer list.
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
const isc::log::MessageID DHCP4_PACKET_NAK_0004
const isc::log::MessageID DHCP4_CLIENT_FQDN_DATA
const isc::log::MessageID DHCP4_PACKET_DROP_0002
isc::log::Logger hooks_logger("hooks")
Hooks Logger.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
const int DBGLVL_PKT_HANDLING
This debug level is reserved for logging the details of packet handling, such as dropping the packet ...
boost::shared_ptr< StringSanitizer > StringSanitizerPtr
Type representing the pointer to the StringSanitizer.
string trim(const string &instring)
Trim Leading and Trailing Spaces.
Defines the logger used by the top-level component of kea-lfc.
#define DHCP4_OPTION_SPACE
global std option spaces
Context information for the DHCPv4 lease allocation.
static std::string lifetimeToText(uint32_t lifetime)
Print lifetime.
structure that describes a single relay information
isc::asiolink::IOAddress linkaddr_
fixed field in relay-forw/relay-reply
Subnet selector used to specify parameters used to select a subnet.
asiolink::IOAddress local_address_
Address on which the message was received.
bool dhcp4o6_
Specifies if the packet is DHCP4o6.
asiolink::IOAddress option_select_
RAI link select or subnet select option.
std::string iface_name_
Name of the interface on which the message was received.
asiolink::IOAddress ciaddr_
ciaddr from the client's message.
ClientClasses client_classes_
Classes that the client belongs to.
asiolink::IOAddress remote_address_
Source address of the message.
OptionPtr interface_id_
Interface id option.
asiolink::IOAddress first_relay_linkaddr_
First relay link address.
asiolink::IOAddress giaddr_
giaddr from the client's message.