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> 82 namespace 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");
116 std::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();
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));
318 Dhcpv4Exchange::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());
360 Dhcpv4Exchange::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,
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) {
598 (*it)->test(pkt, expr_ptr);
605 const bool use_bcast,
const bool direct_response_desired)
606 : io_service_(new
IOService()), server_port_(server_port),
607 client_port_(client_port), shutdown_(true),
608 alloc_engine_(), use_bcast_(use_bcast),
611 test_send_responses_to_source_(false) {
613 const char* env = std::getenv(
"KEA_TEST_SEND_RESPONSES_TO_SOURCE");
616 test_send_responses_to_source_ =
true;
644 }
catch (
const std::exception &e) {
659 for (
auto it = dhcp4_statistics.begin(); it != dhcp4_statistics.end(); ++it) {
661 stats_mgr.
setValue((*it), static_cast<int64_t>(0));
671 }
catch (
const std::exception& ex) {
678 }
catch (
const std::exception& ex) {
690 HooksManager::prepareUnloadLibraries();
691 if (!HooksManager::unloadLibraries()) {
692 auto names = HooksManager::getLibraryNames();
694 if (!names.empty()) {
696 for (
size_t i = 1; i < names.size(); ++i) {
697 msg += std::string(
", ") + names[i];
712 bool sanity_only)
const {
715 if (query->isDhcp4o6()) {
724 subnet = cfgmgr.
getCurrentCfg()->getCfgSubnets4()->selectSubnet(selector);
729 HooksManager::calloutsPresent(Hooks.hook_index_subnet4_select_)) {
742 callout_handle->setArgument(
"query4", query);
743 callout_handle->setArgument(
"subnet4", subnet);
744 callout_handle->setArgument(
"subnet4collection",
746 getCfgSubnets4()->getAll());
749 HooksManager::callCallouts(Hooks.hook_index_subnet4_select_,
755 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
758 .arg(query->getLabel());
764 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
767 .arg(query->getLabel());
773 callout_handle->getArgument(
"subnet4", subnet);
779 .arg(query->getLabel())
780 .arg(subnet->getID());
784 .arg(query->getLabel())
785 .arg(subnet->toText());
790 .arg(query->getLabel());
798 bool sanity_only)
const {
802 selector.
ciaddr_ = query->getCiaddr();
803 selector.
giaddr_ = query->getGiaddr();
818 const Pkt6Ptr& query6 = query4o6->getPkt6();
821 if (query6 && !query6->relay_info_.empty()) {
844 subnet = cfgmgr.
getCurrentCfg()->getCfgSubnets4()->selectSubnet4o6(selector);
849 HooksManager::calloutsPresent(Hooks.hook_index_subnet4_select_)) {
859 callout_handle->setArgument(
"query4", query);
860 callout_handle->setArgument(
"subnet4", subnet);
861 callout_handle->setArgument(
"subnet4collection",
863 getCfgSubnets4()->getAll());
866 HooksManager::callCallouts(Hooks.hook_index_subnet4_select_,
872 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
875 .arg(query->getLabel());
881 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
884 .arg(query->getLabel());
890 callout_handle->getArgument(
"subnet4", subnet);
897 .arg(query->getLabel())
898 .arg(subnet->getID());
903 .arg(query->getLabel())
904 .arg(subnet->toText());
909 .arg(query->getLabel());
932 ctx->hwaddr_ = query->getHWAddr();
938 ctx->early_global_reservations_lookup_ = egrl->boolValue();
942 if (ctx->early_global_reservations_lookup_) {
946 ctx->clientid_.reset(
new ClientId(opt_clientid->getData()));
955 if (global_host && !global_host->getClientClasses4().empty()) {
960 const ClientClasses& classes = global_host->getClientClasses4();
962 cclass != classes.
cend(); ++cclass) {
963 query->addClass(*cclass);
972 query->addClass(
"KNOWN");
974 .arg(query->getLabel())
981 if (query->inClass(
"DROP")) {
984 .arg(query->toText());
986 static_cast<int64_t>(1));
991 ctx->hosts_[SUBNET_ID_GLOBAL] = global_host;
1006 while (__AFL_LOOP(fuzzer.maxLoopCount())) {
1012 #endif // ENABLE_AFL 1016 }
catch (
const std::exception& e) {
1033 MultiThreadingMgr::instance().apply(
false, 0, 0);
1047 uint32_t timeout = 1;
1058 .arg(query->getRemoteAddr().toText())
1059 .arg(query->getRemotePort())
1060 .arg(query->getLocalAddr().toText())
1061 .arg(query->getLocalPort())
1062 .arg(query->getIface());
1078 }
catch (
const std::exception& e) {
1093 .arg(query->getLabel());
1096 if (MultiThreadingMgr::instance().getMode()) {
1097 typedef function<void()> CallBack;
1098 boost::shared_ptr<CallBack> call_back =
1101 if (!MultiThreadingMgr::instance().getThreadPool().add(call_back)) {
1114 }
catch (
const std::exception& e) {
1137 query->addClass(
"ALL");
1144 static_cast<int64_t>(1));
1146 bool skip_unpack =
false;
1150 if (HooksManager::calloutsPresent(Hooks.hook_index_buffer4_receive_)) {
1163 callout_handle->setArgument(
"query4", query);
1166 HooksManager::callCallouts(Hooks.hook_index_buffer4_receive_,
1172 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
1175 .arg(query->getRemoteAddr().toText())
1176 .arg(query->getLocalAddr().toText())
1177 .arg(query->getIface());
1185 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
1188 .arg(query->getRemoteAddr().toText())
1189 .arg(query->getLocalAddr().toText())
1190 .arg(query->getIface());
1194 callout_handle->getArgument(
"query4", query);
1202 .arg(query->getRemoteAddr().toText())
1203 .arg(query->getLocalAddr().toText())
1204 .arg(query->getIface());
1212 }
catch (
const std::exception& e) {
1215 .arg(query->getRemoteAddr().toText())
1216 .arg(query->getLocalAddr().toText())
1217 .arg(query->getIface())
1222 static_cast<int64_t>(1));
1224 static_cast<int64_t>(1));
1245 static_cast<int64_t>(1));
1251 int type = query->getType();
1253 .arg(query->getLabel())
1254 .arg(query->getName())
1256 .arg(query->getRemoteAddr())
1257 .arg(query->getLocalAddr())
1258 .arg(query->getIface());
1260 .arg(query->getLabel())
1261 .arg(query->toText());
1264 if (HooksManager::calloutsPresent(Hooks.hook_index_pkt4_receive_)) {
1277 callout_handle->setArgument(
"query4", query);
1280 HooksManager::callCallouts(Hooks.hook_index_pkt4_receive_,
1286 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) ||
1287 (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP)) {
1290 .arg(query->getLabel());
1294 callout_handle->getArgument(
"query4", query);
1298 if (query->inClass(
"DROP")) {
1300 .arg(query->toText());
1302 static_cast<int64_t>(1));
1311 bool allow_packet_park) {
1320 }
catch (
const std::exception& e) {
1330 bool allow_packet_park) {
1335 if (MultiThreadingMgr::instance().getMode() &&
1342 this, query, rsp, allow_packet_park));
1343 if (!client_handler.
tryLock(query, cont)) {
1354 switch (query->getType()) {
1384 }
catch (
const std::exception& e) {
1394 .arg(query->getLabel())
1399 static_cast<int64_t>(1));
1403 if (ctx && HooksManager::calloutsPresent(Hooks.hook_index_leases4_committed_)) {
1427 std::shared_ptr<ScopedCalloutHandleState> callout_handle_state =
1428 std::make_shared<ScopedCalloutHandleState>(callout_handle);
1433 callout_handle->setArgument(
"query4", query);
1437 if (ctx->new_lease_ && (ctx->new_lease_->reuseable_valid_lft_ == 0)) {
1438 new_leases->push_back(ctx->new_lease_);
1440 callout_handle->setArgument(
"leases4", new_leases);
1443 if (ctx->old_lease_) {
1444 if ((!ctx->new_lease_) || (ctx->new_lease_->addr_ != ctx->old_lease_->addr_)) {
1445 deleted_leases->push_back(ctx->old_lease_);
1448 callout_handle->setArgument(
"deleted_leases4", deleted_leases);
1450 if (allow_packet_park) {
1452 uint32_t parked_packet_limit = 0;
1456 parked_packet_limit = ppl->intValue();
1459 if (parked_packet_limit) {
1460 const auto& parking_lot = ServerHooks::getServerHooks().
1461 getParkingLotPtr(
"leases4_committed");
1463 if (parking_lot && (parking_lot->size() >= parked_packet_limit)) {
1467 .arg(parked_packet_limit)
1468 .arg(query->getLabel());
1470 static_cast<int64_t>(1));
1480 HooksManager::park(
"leases4_committed", query,
1481 [
this, callout_handle, query, rsp, callout_handle_state]()
mutable {
1482 if (MultiThreadingMgr::instance().getMode()) {
1483 typedef function<void()> CallBack;
1484 boost::shared_ptr<CallBack> call_back =
1486 this, callout_handle, query, rsp));
1487 callout_handle_state->on_completion_ = [call_back]() {
1488 MultiThreadingMgr::instance().getThreadPool().add(call_back);
1499 HooksManager::callCallouts(Hooks.hook_index_leases4_committed_,
1503 if (allow_packet_park) {
1504 HooksManager::drop(
"leases4_committed", query);
1510 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_PARK)
1511 && allow_packet_park) {
1513 .arg(query->getLabel());
1521 HooksManager::drop(
"leases4_committed", query);
1522 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
1524 .arg(query->getLabel());
1542 }
catch (
const std::exception& e) {
1558 bool skip_pack =
false;
1561 if (HooksManager::calloutsPresent(Hooks.hook_index_pkt4_send_)) {
1574 callout_handle->setArgument(
"query4", query);
1577 callout_handle->setArgument(
"response4", rsp);
1580 HooksManager::callCallouts(Hooks.hook_index_pkt4_send_,
1588 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
1590 .arg(query->getLabel());
1595 if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
1597 .arg(rsp->getLabel());
1606 .arg(rsp->getLabel());
1608 }
catch (
const std::exception& e) {
1610 .arg(rsp->getLabel())
1628 if (HooksManager::calloutsPresent(Hooks.hook_index_buffer4_send_)) {
1640 callout_handle->setArgument(
"response4", rsp);
1643 HooksManager::callCallouts(Hooks.hook_index_buffer4_send_,
1649 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) ||
1650 (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP)) {
1653 .arg(rsp->getLabel());
1657 callout_handle->getArgument(
"response4", rsp);
1661 .arg(rsp->getLabel())
1662 .arg(rsp->getName())
1663 .arg(static_cast<int>(rsp->getType()))
1664 .arg(rsp->getLocalAddr().isV4Zero() ?
"*" : rsp->getLocalAddr().toText())
1665 .arg(rsp->getLocalPort())
1666 .arg(rsp->getRemoteAddr())
1667 .arg(rsp->getRemotePort())
1668 .arg(rsp->getIface().empty() ?
"to be determined from routing" :
1673 .arg(rsp->getLabel())
1674 .arg(rsp->getName())
1675 .arg(static_cast<int>(rsp->getType()))
1676 .arg(rsp->toText());
1682 }
catch (
const std::exception& e) {
1684 .arg(rsp->getLabel())
1694 boost::shared_ptr<Option4AddrLst> generated =
1701 if (addrs.size() != 1) {
1703 <<
"Expected to contain a single IPv4 address.");
1706 return (addrs[0].toText());
1724 if (local_addr.
isV4Bcast() || query->isDhcp4o6()) {
1747 if (host && !host->getCfgOption4()->empty()) {
1748 co_list.push_back(host->getCfgOption4());
1755 addr = resp->getYiaddr();
1759 if (pool && !pool->getCfgOption()->empty()) {
1760 co_list.push_back(pool->getCfgOption());
1765 if (!subnet->getCfgOption()->empty()) {
1766 co_list.push_back(subnet->getCfgOption());
1771 subnet->getSharedNetwork(network);
1772 if (network && !network->getCfgOption()->empty()) {
1773 co_list.push_back(network->getCfgOption());
1779 cclass != classes.
cend(); ++cclass) {
1782 getClientClassDictionary()->findClass(*cclass);
1794 if (ccdef->getCfgOption()->empty()) {
1799 co_list.push_back(ccdef->getCfgOption());
1823 if (co_list.empty()) {
1829 set<uint8_t> requested_opts;
1838 for (uint16_t code : option_prl->getValues()) {
1839 static_cast<void>(requested_opts.insert(code));
1844 for (
auto const& copts : co_list) {
1852 for (OptionContainerPersistIndex::const_iterator desc = range.first;
1853 desc != range.second; ++desc) {
1855 if (desc->option_) {
1856 static_cast<void>(requested_opts.insert(desc->option_->getType()));
1863 for (
auto const& opt : requested_opts) {
1869 if (!resp->getOption(opt)) {
1871 for (
auto const& copts : co_list) {
1875 resp->addOption(desc.
option_);
1883 set<uint32_t> vendor_ids;
1886 vendor_opts = boost::dynamic_pointer_cast<
OptionVendor>(opt.second);
1888 static_cast<void>(vendor_ids.insert(vendor_opts->getVendorId()));
1892 for (
auto const& copts : co_list) {
1895 if (!desc.option_) {
1899 boost::dynamic_pointer_cast<
OptionVendor>(desc.option_);
1905 if (vendor_ids.count(vendor_id) > 0) {
1909 resp->Pkt::addOption(desc.option_);
1910 static_cast<void>(vendor_ids.insert(vendor_id));
1929 if (!subnet || co_list.empty()) {
1935 set<uint32_t> vendor_ids;
1939 map<uint32_t, OptionVendorPtr> vendor_rsps;
1942 vendor_rsp = boost::dynamic_pointer_cast<
OptionVendor>(opt.second);
1945 vendor_rsps[vendor_id] = vendor_rsp;
1946 static_cast<void>(vendor_ids.insert(vendor_id));
1952 map<uint32_t, OptionVendorPtr> vendor_reqs;
1955 vendor_req = boost::dynamic_pointer_cast<
OptionVendor>(opt.second);
1958 vendor_reqs[vendor_id] = vendor_req;
1959 static_cast<void>(vendor_ids.insert(vendor_id));
1965 if (vendor_ids.empty()) {
1969 map<uint32_t, set<uint8_t> > requested_opts;
1986 set<uint8_t> oro_req_opts;
1987 for (uint8_t code : oro->getValues()) {
1988 static_cast<void>(oro_req_opts.insert(code));
1995 for (uint32_t vendor_id : vendor_ids) {
1996 for (
auto const& copts : co_list) {
2004 for (OptionContainerPersistIndex::const_iterator desc = range.first;
2005 desc != range.second; ++desc) {
2006 if (!desc->option_) {
2010 static_cast<void>(requested_opts[vendor_id].insert(desc->option_->getType()));
2019 if (requested_opts[vendor_id].empty()) {
2026 if (vendor_rsps.count(vendor_id) > 0) {
2027 vendor_rsp = vendor_rsps[vendor_id];
2035 for (uint8_t opt : requested_opts[vendor_id]) {
2036 if (!vendor_rsp->getOption(opt)) {
2037 for (
auto const& copts : co_list) {
2040 vendor_rsp->addOption(desc.
option_);
2050 if (added && (vendor_rsps.count(vendor_id) == 0)) {
2051 resp->Pkt::addOption(vendor_rsp);
2060 static const std::vector<uint16_t> required_options = {
2074 if (co_list.empty()) {
2082 for (
auto const& required : required_options) {
2083 OptionPtr opt = resp->getOption(required);
2086 for (
auto const& copts : co_list) {
2089 resp->addOption(desc.
option_);
2109 .arg(query->getLabel());
2110 processClientFqdnOption(ex);
2115 .arg(query->getLabel());
2116 processHostnameOption(ex);
2122 std::string hostname;
2123 bool fqdn_fwd =
false;
2124 bool fqdn_rev =
false;
2133 opt_hostname = boost::dynamic_pointer_cast<
OptionString>
2137 hostname = opt_hostname->
getValue();
2142 if (hostname ==
".") {
2148 if (ex.
getContext()->getDdnsParams()->getEnableUpdates()) {
2157 if (HooksManager::calloutsPresent(Hooks.hook_index_ddns4_update_)) {
2168 callout_handle->setArgument(
"query4", query);
2169 callout_handle->setArgument(
"response4", resp);
2170 callout_handle->setArgument(
"subnet4", subnet);
2171 callout_handle->setArgument(
"hostname", hostname);
2172 callout_handle->setArgument(
"fwd-update", fqdn_fwd);
2173 callout_handle->setArgument(
"rev-update", fqdn_rev);
2174 callout_handle->setArgument(
"ddns-params", ex.
getContext()->getDdnsParams());
2177 HooksManager::callCallouts(Hooks.hook_index_ddns4_update_, *callout_handle);
2180 string hook_hostname;
2181 bool hook_fqdn_fwd =
false;
2182 bool hook_fqdn_rev =
false;
2183 callout_handle->getArgument(
"hostname", hook_hostname);
2184 callout_handle->getArgument(
"fwd-update", hook_fqdn_fwd);
2185 callout_handle->getArgument(
"rev-update", hook_fqdn_rev);
2189 if ((hostname != hook_hostname) || (fqdn_fwd != hook_fqdn_fwd) ||
2190 (fqdn_rev != hook_fqdn_rev)) {
2192 .arg(hostname).arg(hook_hostname).arg(fqdn_fwd).arg(hook_fqdn_fwd)
2193 .arg(fqdn_rev).arg(hook_fqdn_rev);
2194 hostname = hook_hostname;
2195 fqdn_fwd = hook_fqdn_fwd;
2196 fqdn_rev = hook_fqdn_rev;
2203 hostname_opt->
setValue(hook_hostname);
2221 ctx->fwd_dns_update_ = fqdn_fwd;
2222 ctx->rev_dns_update_ = fqdn_rev;
2223 ctx->hostname_ = hostname;
2248 .arg(fqdn->toText());
2264 !ex.
getContext()->currentHost()->getHostname().empty()) {
2291 .arg(fqdn_resp->
toText());
2307 .arg(opt_hostname->getValue());
2315 if (ctx->currentHost() && !ctx->currentHost()->getHostname().empty()) {
2317 std::string hostname = d2_mgr.
qualifyName(ctx->currentHost()->getHostname(),
2320 boost::algorithm::to_lower(hostname);
2338 ex.
getContext()->getDdnsParams()->getReplaceClientNameMode();
2341 if (!opt_hostname) {
2361 .arg(opt_hostname->getValue());
2364 unsigned int label_count;
2370 }
catch (
const std::exception& exc) {
2381 if (label_count == 0) {
2399 || label_count < 2) {
2413 ex.
getContext()->getDdnsParams()->getHostnameSanitizer();
2416 hostname = sanitizer->scrub(hostname);
2420 boost::algorithm::to_lower(hostname);
2422 if (label_count == 2) {
2430 opt_hostname_resp.reset(
2441 .arg(opt_hostname_resp->getValue());
2451 "NULL lease specified when creating NameChangeRequest");
2459 if (!old_lease || ddns_params.
getUpdateOnRenew() || !lease->hasIdenticalFqdn(*old_lease)) {
2490 .arg(query->getLabel())
2491 .arg(query->getRemoteAddr().toText())
2492 .arg(query->getName());
2508 if (opt_requested_address) {
2509 hint = opt_requested_address->readAddress();
2511 }
else if (!query->getCiaddr().isV4Zero()) {
2512 hint = query->getCiaddr();
2524 bool fake_allocation = (query->getType() ==
DHCPDISCOVER);
2534 if (!fake_allocation && !opt_serverid && opt_requested_address) {
2537 .arg(query->getLabel())
2538 .arg(hint.toText());
2542 auto const& classes = query->getClasses();
2556 if (!leases_client_id.empty()) {
2562 for (
auto l = leases_client_id.begin(); l != leases_client_id.end(); ++l) {
2563 if ((*l)->subnet_id_ == s->getID()) {
2573 s = s->getNextSubnet(original_subnet, classes);
2581 if (!lease && hwaddr) {
2585 if (!leases_hwaddr.empty()) {
2590 for (
auto l = leases_hwaddr.begin(); l != leases_hwaddr.end(); ++l) {
2591 if ((*l)->subnet_id_ == s->getID()) {
2601 s = s->getNextSubnet(original_subnet, classes);
2610 bool authoritative = original_subnet->getAuthoritative();
2611 bool known_client = lease && lease->belongsToClient(hwaddr, client_id);
2612 if (!authoritative && !known_client) {
2615 .arg(query->getLabel())
2616 .arg(hint.toText());
2624 if ((known_client && (lease->addr_ != hint)) ||
2625 (!known_client && authoritative)) {
2628 .arg(query->getLabel())
2629 .arg(hint.toText());
2640 ctx->requested_address_ = hint;
2641 ctx->fake_allocation_ = fake_allocation;
2642 ctx->callout_handle_ = callout_handle;
2658 bool client_name_changed =
false;
2662 if (subnet && ctx->subnet_ && subnet->getID() != ctx->subnet_->getID()) {
2664 subnet->getSharedNetwork(network);
2666 .arg(query->getLabel())
2667 .arg(subnet->toText())
2668 .arg(ctx->subnet_->toText())
2669 .arg(network ? network->getName() :
"<no network?>");
2671 subnet = ctx->subnet_;
2686 ctx->hostname_ =
"";
2687 ctx->fwd_dns_update_ =
false;
2688 ctx->rev_dns_update_ =
false;
2695 if ((lease->hostname_ != ctx->hostname_) ||
2696 (lease->fqdn_fwd_ != ctx->fwd_dns_update_) ||
2697 (lease->fqdn_rev_ != ctx->rev_dns_update_)) {
2698 lease->hostname_ = ctx->hostname_;
2699 lease->fqdn_fwd_ = ctx->fwd_dns_update_;
2700 lease->fqdn_rev_ = ctx->rev_dns_update_;
2701 client_name_changed =
true;
2709 if (fake_allocation) {
2711 .arg(query->getLabel())
2712 .arg(lease->addr_.toText());
2715 .arg(query->getLabel())
2716 .arg(lease->addr_.toText())
2724 if (!ctx->subnet_->getMatchClientId()) {
2726 .arg(ctx->query_->getLabel())
2727 .arg(ctx->subnet_->getID());
2730 resp->setYiaddr(lease->addr_);
2736 if (!fake_allocation) {
2741 resp->setCiaddr(query->getCiaddr());
2750 if (lease->reuseable_valid_lft_ > 0) {
2751 lease->valid_lft_ = lease->reuseable_valid_lft_;
2753 .arg(query->getLabel())
2754 .arg(lease->addr_.toText())
2760 lease->valid_lft_));
2761 resp->addOption(opt);
2764 resp->addOption(getNetmaskOption(subnet));
2770 if (!fake_allocation) {
2776 .arg(query->getLabel())
2784 if (ctx->unknown_requested_addr_) {
2796 s = s->getNextSubnet(original_subnet);
2804 .arg(query->getLabel())
2805 .arg(query->getCiaddr().toText())
2806 .arg(opt_requested_address ?
2807 opt_requested_address->readAddress().toText() :
"(no address)");
2815 .arg(query->getLabel())
2816 .arg(query->getCiaddr().toText())
2817 .arg(opt_requested_address ?
2818 opt_requested_address->readAddress().toText() :
"(no address)");
2830 const Pkt4Ptr& query,
const Pkt4Ptr& resp,
bool client_name_changed) {
2840 if (!opt_hostname) {
2847 if (lease->hostname_.empty()) {
2854 .
generateFqdn(lease->addr_, *(ctx->getDdnsParams()), static_cast<bool>(fqdn));
2857 .arg(query->getLabel())
2858 .arg(lease->hostname_);
2860 client_name_changed =
true;
2863 if (client_name_changed) {
2868 if (!ctx->fake_allocation_) {
2870 lease->reuseable_valid_lft_ = 0;
2883 opt_hostname->setValue(lease->hostname_);
2887 .arg(query->getLabel())
2888 .arg(lease->hostname_)
2898 uint32_t t2_time = 0;
2900 if (!subnet->getT2().unspecified()) {
2901 t2_time = subnet->getT2();
2902 }
else if (subnet->getCalculateTeeTimes()) {
2904 t2_time =
static_cast<uint32_t
>(round(subnet->getT2Percent() * (lease->valid_lft_)));
2909 uint32_t timer_ceiling = lease->valid_lft_;
2910 if (t2_time > 0 && t2_time < timer_ceiling) {
2912 resp->addOption(t2);
2914 timer_ceiling = t2_time;
2917 uint32_t t1_time = 0;
2919 if (!subnet->getT1().unspecified()) {
2920 t1_time = subnet->getT1();
2921 }
else if (subnet->getCalculateTeeTimes()) {
2923 t1_time =
static_cast<uint32_t
>(round(subnet->getT1Percent() * (lease->valid_lft_)));
2928 if (t1_time > 0 && t1_time < timer_ceiling) {
2930 resp->addOption(t1);
2942 return (query->getRemotePort());
2970 }
else if (((query->getType() ==
DHCPINFORM) &&
2971 ((!query->getCiaddr().isV4Zero()) ||
2972 (!query->isRelayed() && !query->getRemoteAddr().isV4Zero()))) ||
2973 ((query->getType() !=
DHCPINFORM) && !query->isRelayed())) {
2974 response->setRemotePort(DHCP4_CLIENT_PORT);
2979 response->setRemotePort(relay_port ? relay_port : DHCP4_SERVER_PORT);
2983 if (query->isRelayed() &&
2989 response->resetIndex();
2991 response->setIface(query->getIface());
2995 IOAddress local_addr = query->getLocalAddr();
3004 if (local_addr.
isV4Bcast() || query->isDhcp4o6()) {
3015 response->setLocalAddr(local_addr);
3024 response->setIndex(query->getIndex());
3025 response->setIface(query->getIface());
3031 response->setLocalPort(DHCP4_SERVER_PORT);
3043 if (query->isDhcp4o6()) {
3044 response->setRemoteAddr(query->getRemoteAddr());
3056 if (!query->getCiaddr().isV4Zero()) {
3057 response->setRemoteAddr(query->getCiaddr());
3064 }
else if (query->isRelayed()) {
3065 response->setRemoteAddr(query->getGiaddr());
3066 response->setFlags(response->getFlags() | BOOTP_BROADCAST);
3071 response->setRemoteAddr(query->getRemoteAddr());
3078 if (query->isRelayed()) {
3087 query->getCiaddr().isV4Zero()) {
3088 response->setFlags(BOOTP_BROADCAST);
3090 response->setRemoteAddr(query->getGiaddr());
3094 }
else if (!query->getCiaddr().isV4Zero()) {
3095 response->setRemoteAddr(query->getCiaddr());
3100 }
else if (response->getType() ==
DHCPNAK) {
3104 }
else if (!response->getYiaddr().isV4Zero()) {
3119 response->setRemoteAddr(response ->getYiaddr());
3127 response->setRemoteAddr(query->getRemoteAddr());
3132 response->setRemoteAddr(query->getRemoteAddr());
3144 IOAddress subnet_next_server = subnet->getSiaddr();
3145 if (!subnet_next_server.
isV4Zero()) {
3146 response->setSiaddr(subnet_next_server);
3149 const string& sname = subnet->getSname();
3150 if (!sname.empty()) {
3156 response->setSname(reinterpret_cast<const uint8_t*>(sname.c_str()),
3160 const string& filename = subnet->getFilename();
3161 if (!filename.empty()) {
3167 response->setFile(reinterpret_cast<const uint8_t*>(filename.c_str()),
3175 if (!classes.
empty()) {
3188 size_t found_cnt = 0;
3190 name != classes.
cend() && found_cnt < 3; ++name) {
3202 next_server = cl->getNextServer();
3204 response->setSiaddr(next_server);
3209 if (sname.empty()) {
3210 sname = cl->getSname();
3211 if (!sname.empty()) {
3217 response->setSname(reinterpret_cast<const uint8_t*>(sname.c_str()),
3223 if (filename.empty()) {
3224 filename = cl->getFilename();
3225 if (!filename.empty()) {
3231 response->setFile(reinterpret_cast<const uint8_t*>(filename.c_str()),
3245 Dhcpv4Srv::getNetmaskOption(
const Subnet4Ptr& subnet) {
3246 uint32_t netmask =
getNetmask4(subnet->get().second).toUint32();
3274 if (MultiThreadingMgr::instance().getMode()) {
3348 if (MultiThreadingMgr::instance().getMode()) {
3361 }
else if (request->inClass(
"BOOTP")) {
3363 response->addClass(
"BOOTP");
3367 if (!response->getYiaddr().isV4Zero()) {
3430 .arg(release->getLabel())
3431 .arg(release->getCiaddr().toText());
3435 if (!lease->belongsToClient(release->getHWAddr(), client_id)) {
3437 .arg(release->getLabel())
3438 .arg(release->getCiaddr().toText());
3445 if (HooksManager::calloutsPresent(Hooks.hook_index_lease4_release_)) {
3458 callout_handle->setArgument(
"query4", release);
3461 callout_handle->setArgument(
"lease4", lease);
3464 HooksManager::callCallouts(Hooks.hook_index_lease4_release_,
3470 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) ||
3471 (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP)) {
3475 .arg(release->getLabel());
3483 bool success =
false;
3484 bool expired =
false;
3488 if (expiration_cfg->getFlushReclaimedTimerWaitTime() &&
3489 expiration_cfg->getHoldReclaimedTime() &&
3492 lease->valid_lft_ = 0;
3502 context->old_lease_ = lease;
3506 .arg(release->getLabel())
3507 .arg(lease->addr_.toText());
3511 .arg(release->getLabel())
3512 .arg(lease->addr_.toText());
3515 .arg(release->getLabel())
3516 .arg(lease->addr_.toText());
3519 StatsMgr::instance().addValue(
3520 StatsMgr::generateName(
"subnet", lease->subnet_id_,
"assigned-addresses"),
3521 static_cast<int64_t>(-1));
3529 .arg(release->getLabel())
3530 .arg(lease->addr_.toText());
3535 .arg(release->getLabel())
3536 .arg(release->getCiaddr())
3553 if (!opt_requested_address) {
3556 " in DHCPDECLINE sent from " << decline->getLabel());
3558 IOAddress addr(opt_requested_address->readAddress());
3576 .arg(addr.toText()).arg(decline->getLabel());
3584 client_id.reset(
new ClientId(opt_clientid->getData()));
3588 if (!lease->belongsToClient(decline->getHWAddr(), client_id)) {
3591 string client_hw = decline->getHWAddr() ?
3592 decline->getHWAddr()->toText(
false) :
"(none)";
3593 string lease_hw = lease->hwaddr_ ?
3594 lease->hwaddr_->toText(
false) :
"(none)";
3597 string client_id_txt = client_id ? client_id->toText() :
"(none)";
3598 string lease_id_txt = lease->client_id_ ?
3599 lease->client_id_->toText() :
"(none)";
3603 .arg(addr.toText()).arg(decline->getLabel())
3604 .arg(client_hw).arg(lease_hw).arg(client_id_txt).arg(lease_id_txt);
3621 if (HooksManager::calloutsPresent(Hooks.hook_index_lease4_decline_)) {
3634 callout_handle->setArgument(
"query4", decline);
3637 callout_handle->setArgument(
"lease4", lease);
3640 HooksManager::callCallouts(Hooks.hook_index_lease4_decline_,
3645 if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) ||
3646 (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP)) {
3648 .arg(decline->getLabel()).arg(lease->addr_.toText());
3653 Lease4Ptr old_values = boost::make_shared<Lease4>(*lease);
3667 .arg(decline->getLabel())
3668 .arg(lease->addr_.toText())
3680 StatsMgr::instance().addValue(
3681 StatsMgr::generateName(
"subnet", lease->subnet_id_,
"declined-addresses"),
3682 static_cast<int64_t>(1));
3685 StatsMgr::instance().addValue(
"declined-addresses", static_cast<int64_t>(1));
3697 context->new_lease_ = lease;
3700 .arg(decline->getLabel()).arg(lease->valid_lft_);
3747 if (ack->getRemoteAddr() != inform->getGiaddr()) {
3749 .arg(inform->getLabel())
3750 .arg(ack->getRemoteAddr())
3751 .arg(ack->getIface());
3774 .arg(query->getLabel())
3775 .arg(query->getIface());
3783 .arg(query->getLabel())
3784 .arg(query->getIface());
3794 if (pkt->isRelayed()) {
3799 if (pkt->isDhcp4o6()) {
3808 if (pkt->getRemoteAddr().isV4Zero() &&
3809 pkt->getCiaddr().isV4Zero()) {
3820 bool result = (!pkt->getLocalAddr().isV4Bcast() ||
3835 type = query->getType();
3839 .arg(query->getLabel())
3840 .arg(query->getIface());
3864 .arg(query->getLabel());
3871 .arg(query->getLabel())
3876 .arg(query->getLabel())
3906 if (!option_custom) {
3914 if (option_custom->getDataFieldsNum() != 1) {
3920 IOAddress server_id = option_custom->readAddress();
3921 if (!server_id.
isV4()) {
3930 if (rai_suboption && (server_id.
toBytes() == rai_suboption->toBinary())) {
3971 if (cfg_subnets->hasSubnetWithServerId(server_id)) {
3978 if (cfg_networks->hasNetworkWithServerId(server_id)) {
3985 cclass != classes.
cend(); ++cclass) {
3988 getClientClassDictionary()->findClass(*cclass);
3993 if (ccdef->getCfgOption()->empty()) {
4000 if (context_opt_server_id && (context_opt_server_id->readAddress() == server_id)) {
4011 return (opt_server_id && (opt_server_id->readAddress() == server_id));
4021 <<
" received in message " 4022 << query->getName());
4029 " received in message " 4030 << query->getName());
4040 if (query->getHWAddr() && !query->getHWAddr()->hwaddr_.empty()) {
4049 if (!client_id || client_id->len() == client_id->getHeaderLen()) {
4051 " provided in message " 4052 << query->getName());
4069 subnet->getSharedNetwork(network);
4071 const ClientClasses& to_add = network->getRequiredClasses();
4073 cclass != to_add.
cend(); ++cclass) {
4081 cclass != to_add.
cend(); ++cclass) {
4089 addr = resp->getYiaddr();
4096 cclass != to_add.
cend(); ++cclass) {
4110 cclass != classes.
cend(); ++cclass) {
4133 query->addClass(*cclass);
4146 .arg(
"get exception?");
4154 BOOST_FOREACH(
const uint16_t& code, query->getDeferredOptions()) {
4159 cclass != classes.
cend(); ++cclass) {
4163 getClientClassDictionary()->findClass(*cclass);
4169 if (!ccdef->getCfgOptionDef()) {
4207 opt = def->optionFactory(
Option::V4, code, buf);
4208 }
catch (
const std::exception& e) {
4216 while (query->delOption(code)) {
4220 query->addOption(opt);
4232 this, ph::_1, ph::_2));
4250 arg(result).arg((ncr ? ncr->toText() :
" NULL "));
4262 std::stringstream tmp;
4266 tmp << endl << EXTENDED_VERSION << endl;
4267 tmp <<
"linked with:" << endl;
4268 tmp << Logger::getVersion() << endl;
4269 tmp << CryptoLink::getVersion() << endl;
4270 tmp <<
"database:" << endl;
4289 string stat_name =
"pkt4-unknown-received";
4291 switch (query->getType()) {
4293 stat_name =
"pkt4-discover-received";
4297 stat_name =
"pkt4-offer-received";
4300 stat_name =
"pkt4-request-received";
4304 stat_name =
"pkt4-ack-received";
4308 stat_name =
"pkt4-nak-received";
4311 stat_name =
"pkt4-release-received";
4314 stat_name =
"pkt4-decline-received";
4317 stat_name =
"pkt4-inform-received";
4331 static_cast<int64_t>(1));
4337 static_cast<int64_t>(1));
4341 switch (response->getType()) {
4343 stat_name =
"pkt4-offer-sent";
4346 stat_name =
"pkt4-ack-sent";
4349 stat_name =
"pkt4-nak-sent";
4357 static_cast<int64_t>(1));
4361 return (Hooks.hook_index_buffer4_receive_);
4365 return (Hooks.hook_index_pkt4_receive_);
4369 return (Hooks.hook_index_subnet4_select_);
4373 return (Hooks.hook_index_lease4_release_);
4377 return (Hooks.hook_index_pkt4_send_);
4381 return (Hooks.hook_index_buffer4_send_);
4385 return (Hooks.hook_index_lease4_decline_);
4390 HooksManager::clearParkingLots();
4394 static std::list<std::list<std::string>>
const list({
4395 {
"config-control",
"config-databases",
"[]"},
4396 {
"hooks-libraries",
"[]",
"parameters",
"*"},
4398 {
"hosts-databases",
"[]"},
const isc::log::MessageID DHCP4_NCR_CREATION_FAILED
RAII class creating a critical section.
static std::string lifetimeToText(uint32_t lifetime)
Print lifetime.
void setPacketStatisticsDefaults()
This function sets statistics related to DHCPv4 packets processing to their initial values...
static const uint8_t FLAG_N
Bit N.
asiolink::IOAddress ciaddr_
ciaddr from the client's message.
const isc::log::MessageID DHCP4_DECLINE_FAIL
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
static OptionDefinitionPtr getRuntimeOptionDef(const std::string &space, const uint16_t code)
Returns runtime (non-standard) option definition by space and option code.
void run_one()
Main server processing step.
static int getHookIndexBuffer4Send()
Returns the index for "buffer4_send" hook point.
const isc::log::MessageID DHCP4_DHCP4O6_SUBNET_SELECTED
std::string toText(const std::string &separator=", ") const
Returns all class names as text.
virtual void updateLease4(const Lease4Ptr &lease4)=0
Updates IPv4 lease.
const isc::log::MessageID DHCP4_CLASS_UNDEFINED
uint32_t getVendorId() const
Returns enterprise identifier.
void appendRequestedVendorOptions(Dhcpv4Exchange &ex)
Appends requested vendor options as requested by client.
const isc::log::MessageID DHCP4_SUBNET_SELECTION_FAILED
virtual ~Dhcpv4Srv()
Destructor. Used during DHCPv4 service shutdown.
asiolink::IOAddress remote_address_
Source address of the message.
const isc::log::MessageID DHCP4_PACKET_NAK_0002
const isc::log::MessageID DHCP4_CLIENT_HOSTNAME_DATA
uint16_t server_port_
UDP port number on which server listens.
void processPacketPktSend(hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &query, Pkt4Ptr &rsp)
Executes pkt4_send callout.
Message Type option missing.
bool getFlag(const uint8_t flag) const
Checks if the specified flag of the DHCPv4 Client FQDN Option is set.
const isc::log::MessageID DHCP4_PACKET_SEND
void processPacketBufferSend(hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &rsp)
Executes buffer4_send callout and sends the response.
static std::string getDBVersion()
Local version of getDBVersion() class method.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
boost::shared_ptr< OptionCustom > OptionCustomPtr
A pointer to the OptionCustom object.
const isc::log::MessageID DHCP4_PACKET_SEND_FAIL
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
bool acceptMessageType(const Pkt4Ptr &query) const
Check if received message type is valid for the server to process.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
static void setHostIdentifiers(AllocEngine::ClientContext4Ptr context)
Set host identifiers within a context.
static int getHookIndexBuffer4Receive()
Returns the index for "buffer4_receive" hook point.
bool acceptDirectRequest(const Pkt4Ptr &query) const
Check if a message sent by directly connected client should be accepted or discarded.
Exception thrown during option unpacking This exception is thrown when an error has occurred...
DHCPv4 Option class for handling list of IPv4 addresses.
static SubnetSelector initSelector(const Pkt4Ptr &query)
Build selector from a client's message.
std::vector< isc::asiolink::IOAddress > AddressContainer
Defines a collection of IPv4 addresses.
const isc::log::MessageID DHCP4_PACKET_PACK
void adjustDomainName(const T &fqdn, T &fqdn_resp, const DdnsParams &ddns_params)
Set server FQDN name based on configuration and a given FQDN.
void buildCfgOptionList(Dhcpv4Exchange &ex)
Build the configured option list.
static void destroy()
Destroy lease manager.
const isc::log::MessageID DHCP4_LEASE_ADVERT
const isc::log::MessageID DHCP4_CLIENTID_IGNORED_FOR_LEASES
const isc::log::MessageID DHCP4_RESPONSE_DATA
const isc::log::MessageID DHCP4_PACKET_QUEUE_FULL
An abstract API for lease database.
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
const isc::log::MessageID DHCP4_CLIENT_FQDN_PROCESS
const isc::log::MessageID DHCP4_EMPTY_HOSTNAME
IOAddress getNetmask4(uint8_t len)
Generates an IPv4 netmask of specified length.
void sendResponseNoThrow(hooks::CalloutHandlePtr &callout_handle, Pkt4Ptr &query, Pkt4Ptr &rsp)
Process an unparked DHCPv4 packet and sends the response.
static CfgMgr & instance()
returns a single instance of Configuration Manager
asiolink::IOAddress option_select_
RAI link select or subnet select option.
const isc::log::MessageID DHCP4_PACKET_DROP_0006
void startSender(D2ClientErrorHandler error_handler, isc::asiolink::IOService &io_service)
Enables sending NameChangeRequests to kea-dhcp-ddns.
Result
Defines the outcome of an asynchronous NCR send.
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
const isc::log::MessageID DHCP4_INFORM_DIRECT_REPLY
OptionPtr interface_id_
Interface id option.
boost::shared_ptr< OptionUint8Array > OptionUint8ArrayPtr
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
boost::shared_ptr< Option > OptionPtr
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
void initResponse()
Initializes the instance of the response message.
static void classifyPacket(const Pkt4Ptr &pkt)
Assigns incoming packet to zero or more classes.
const isc::log::MessageID DHCP4_TESTING_MODE_SEND_TO_SOURCE_ENABLED
const isc::log::MessageID DHCP4_SHUTDOWN_REQUEST
void adjustRemoteAddr(Dhcpv4Exchange &ex)
Sets remote addresses for outgoing packet.
boost::shared_ptr< Option4ClientFqdn > Option4ClientFqdnPtr
A pointer to the Option4ClientFqdn object.
Represents a DHCPv6 packet.
boost::shared_ptr< OptionString > OptionStringPtr
Pointer to the OptionString object.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
void classifyPacket(const Pkt4Ptr &pkt)
Assigns incoming packet to zero or more classes.
const isc::log::MessageID DHCP4_INIT_REBOOT
isc::log::Logger bad_packet4_logger(DHCP4_BAD_PACKET_LOGGER_NAME)
Logger for rejected packets.
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Holds information about DHCP service enabling status.
const isc::log::MessageID DHCP4_RELEASE_FAIL_WRONG_CLIENT
virtual void sendPacket(const Pkt4Ptr &pkt)
dummy wrapper around IfaceMgr::send()
const isc::log::MessageID DHCP4_POST_ALLOCATION_NAME_UPDATE_FAIL
const isc::log::MessageID DHCP4_SRV_D2STOP_ERROR
boost::shared_ptr< CfgIface > CfgIfacePtr
A pointer to the CfgIface .
asiolink::IOAddress giaddr_
giaddr from the client's message.
const isc::log::MessageID DHCP4_DHCP4O6_SUBNET_SELECTION_FAILED
const isc::log::MessageID DHCP4_HOOK_DDNS_UPDATE
Represents DHCPv4 Client FQDN Option (code 81).
const isc::log::MessageID DHCP4_BUFFER_WAIT_SIGNAL
const isc::log::MessageID DHCP4_RELEASE_FAIL
Forward declaration to OptionInt.
const isc::log::MessageID DHCP4_HOOK_BUFFER_RCVD_SKIP
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
std::string getValue() const
Returns the string value held by the option.
static Dhcp4to6Ipc & instance()
Returns pointer to the sole instance of Dhcp4to6Ipc.
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
bool earlyGHRLookup(const Pkt4Ptr &query, AllocEngine::ClientContext4Ptr ctx)
Initialize client context and perform early global reservations lookup.
const int DBG_DHCP4_BASIC_DATA
Debug level used to log the traces with some basic data.
isc::log::Logger options4_logger(DHCP4_OPTIONS_LOGGER_NAME)
Logger for options parser.
const int DBG_DHCP4_START
Debug level used to log information during server startup.
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.
int getExitValue()
Fetches the exit value.
void discardPackets()
Discards parked packets Clears the packet parking lots of all packets.
void setDomainName(const std::string &domain_name, const DomainNameType domain_name_type)
Set new domain-name.
const int DBGLVL_PKT_HANDLING
This debug level is reserved for logging the details of packet handling, such as dropping the packet ...
const_iterator cbegin() const
Iterators to the first element.
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.
boost::shared_ptr< OptionUint32 > OptionUint32Ptr
RAII object enabling copying options retrieved from the packet.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
const isc::log::MessageID DHCP4_FLEX_ID
isc::log::Logger packet4_logger(DHCP4_PACKET_LOGGER_NAME)
Logger for processed packets.
void createNameChangeRequests(const Lease4Ptr &lease, const Lease4Ptr &old_lease, const DdnsParams &ddns_params)
Creates NameChangeRequests which correspond to the lease which has been acquired. ...
boost::shared_ptr< AllocEngine > AllocEnginePtr
A pointer to the AllocEngine object.
static int getHookIndexLease4Release()
Returns the index for "lease4_release" hook point.
const isc::log::MessageID DHCP4_CLIENT_HOSTNAME_MALFORMED
static StatsMgr & instance()
Statistics Manager accessor method.
const int DBG_DHCP4_BASIC
Debug level used to trace basic operations within the code.
const isc::log::MessageID DHCP4_DHCP4O6_SUBNET_DATA
boost::shared_ptr< const CfgSubnets4 > ConstCfgSubnets4Ptr
Const pointer.
bool isV6LinkLocal() const
checks whether and address is IPv6 and is link-local
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
void processRelease(Pkt4Ptr &release, AllocEngine::ClientContext4Ptr &context)
Processes incoming DHCPRELEASE messages.
Statistics Manager class.
ClientClasses client_classes_
Classes that the client belongs to.
static const size_t OPTION4_HDR_LEN
length of the usual DHCPv4 option header (there are exceptions)
The IOService class is a wrapper for the ASIO io_service class.
const isc::log::MessageID DHCP4_DECLINE_LEASE
const isc::log::MessageID DHCP4_HOOK_BUFFER_RCVD_DROP
Server uses routing to determine the right interface to send response.
Pkt6Ptr getPkt6() const
Returns encapsulating DHCPv6 message.
const isc::log::MessageID DHCP4_PACKET_DROP_0008
const isc::log::MessageID DHCP4_DECLINE_LEASE_MISMATCH
asiolink::IOAddress first_relay_linkaddr_
First relay link address.
const isc::log::MessageID DHCP4_PACKET_PACK_FAIL
void setFixedFields(Dhcpv4Exchange &ex)
Sets fixed fields of the outgoing packet.
bool send(const Pkt6Ptr &pkt)
Sends an IPv6 packet.
void setMatchingPacketFilter(const bool direct_response_desired=false)
Set Packet Filter object to handle send/receive packets.
Subnet selector used to specify parameters used to select a subnet.
OptionInt< uint32_t > OptionUint32
isc::log::Logger dhcp4_logger(DHCP4_APP_LOGGER_NAME)
Base logger for DHCPv4 server.
static std::string getDBVersion()
Class method to return extended version info This class method must be redeclared and redefined in de...
const isc::log::MessageID DHCP4_RELEASE_EXCEPTION
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
boost::shared_ptr< CfgSharedNetworks4 > CfgSharedNetworks4Ptr
Pointer to the configuration of IPv4 shared networks.
void queueNCR(const NameChangeType &chg_type, const Lease4Ptr &lease)
Creates name change request from the DHCPv4 lease.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
ClientClassContainer::const_iterator const_iterator
Type of iterators.
asiolink::IOServicePtr & getIOService()
Returns pointer to the IO service used by the server.
Pkt4Ptr processInform(Pkt4Ptr &inform, AllocEngine::ClientContext4Ptr &context)
Processes incoming DHCPINFORM messages.
const isc::log::MessageID DHCP4_CLASS_UNCONFIGURED
virtual void d2ClientErrorHandler(const dhcp_ddns::NameChangeSender::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)
Implements the error handler for DHCP_DDNS IO errors.
structure that describes a single relay information
const isc::log::MessageID DHCP4_SRV_UNLOAD_LIBRARIES_ERROR
Forward declaration to OptionIntArray.
void processDecline(Pkt4Ptr &decline, AllocEngine::ClientContext4Ptr &context)
Process incoming DHCPDECLINE messages.
void setTeeTimes(const Lease4Ptr &lease, const Subnet4Ptr &subnet, Pkt4Ptr resp)
Adds the T1 and T2 timers to the outbound response as appropriate.
const isc::log::MessageID DHCP4_BUFFER_RECEIVE_FAIL
bool acceptServerId(const Pkt4Ptr &pkt) const
Verifies if the server id belongs to our server.
std::list< ConstCfgOptionPtr > CfgOptionList
Const pointer list.
volatile bool shutdown_
Indicates if shutdown is in progress.
static const uint8_t FLAG_S
Bit S.
Implementation of the mechanisms to control the use of the Configuration Backends by the DHCPv4 serve...
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
static void sanityCheck(const Pkt4Ptr &query, RequirementLevel serverid)
Verifies if specified packet meets RFC requirements.
void processDhcp4QueryAndSendResponse(Pkt4Ptr &query, Pkt4Ptr &rsp, bool allow_packet_park)
Process a single incoming DHCPv4 query.
static void appendServerID(Dhcpv4Exchange &ex)
Adds server identifier option to the server's response.
const isc::log::MessageID DHCP4_PACKET_DROP_0010
bool getEnableUpdates() const
Returns whether or not DHCP DDNS updating is enabled.
std::string getIdentifierAsText() const
Returns host identifier in a textual form.
Pkt4Ptr processRequest(Pkt4Ptr &request, AllocEngine::ClientContext4Ptr &context)
Processes incoming REQUEST and returns REPLY response.
void processPacket(Pkt4Ptr &query, Pkt4Ptr &rsp, bool allow_packet_park=true)
Process a single incoming DHCPv4 packet.
bool isV4Bcast() const
Convenience function to check if it is an IPv4 broadcast address.
bool isV6Zero() const
Convenience function to check if it is an IPv4 zero address.
void appendRequestedOptions(Dhcpv4Exchange &ex)
Appends options requested by client.
boost::shared_ptr< Lease4Collection > Lease4CollectionPtr
A shared pointer to the collection of IPv4 leases.
boost::shared_ptr< ClientContext4 > ClientContext4Ptr
Pointer to the ClientContext4.
static int getHookIndexLease4Decline()
Returns the index for "lease4_decline" hook point.
virtual std::string toText(int indent=0) const
Returns string representation of the option.
static std::string getDBVersion()
Local version of getDBVersion() class method.
bool hasOpenSocket(const uint16_t family) const
Checks if there is at least one socket of the specified family open.
std::pair< OptionContainerPersistIndex::const_iterator, OptionContainerPersistIndex::const_iterator > OptionContainerPersistRange
Pair of iterators to represent the range of options having the same persistency flag.
static int getHookIndexSubnet4Select()
Returns the index for "subnet4_select" hook point.
static int getHookIndexPkt4Send()
Returns the index for "pkt4_send" hook point.
const isc::log::MessageID DHCP4_PACKET_DROP_0002
const int DBG_DHCP4_DETAIL_DATA
This level is used to log the contents of packets received and sent.
A generic exception that is thrown when an unexpected error condition occurs.
boost::shared_ptr< ClientClassDictionary > ClientClassDictionaryPtr
Defines a pointer to a ClientClassDictionary.
const isc::log::MessageID DHCP4_LEASE_REUSE
const isc::log::MessageID DHCP4_PACKET_DROP_0013
Wrapper class around callout handle which automatically resets handle's state.
void stopD2()
Stops DHCP_DDNS client IO if DDNS updates are enabled.
bool isV4Zero() const
Convenience function to check if it is an IPv4 zero address.
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
const isc::log::MessageID DHCP4_PACKET_DROP_0004
const isc::log::MessageID DHCP4_NO_LEASE_INIT_REBOOT
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
bool ddnsEnabled()
Convenience method for checking if DHCP-DDNS is enabled.
asiolink::IOAddress local_address_
Address on which the message was received.
const isc::log::MessageID DHCP4_PACKET_RECEIVED
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Flexible host identifier.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
std::string getDomainName() const
Returns the domain-name in the text format.
const isc::log::MessageID DHCP4_BUFFER_UNPACK
const char *const * dhcp4_config_report
const isc::log::MessageID DHCP4_HOOK_SUBNET4_SELECT_DROP
const isc::log::MessageID DHCP4_BUFFER_RECEIVED
void processDhcp4Query(Pkt4Ptr &query, Pkt4Ptr &rsp, bool allow_packet_park)
Process a single incoming DHCPv4 query.
const isc::log::MessageID DHCP4_HOOK_LEASES4_PARKING_LOT_FULL
const isc::log::MessageID DHCP4_CLASS_UNTESTABLE
static void classifyByVendor(const Pkt4Ptr &pkt)
Assign class using vendor-class-identifier option.
const isc::log::MessageID DHCP4_RELEASE_FAIL_NO_LEASE
static void removeDependentEvaluatedClasses(const Pkt4Ptr &query)
Removed evaluated client classes.
const int DBG_DHCP4_DETAIL
Debug level used to trace detailed errors.
const isc::log::MessageID DHCP4_RELEASE_DELETED
const isc::log::MessageID DHCP4_SRV_DHCP4O6_ERROR
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
const isc::log::MessageID DHCP4_PACKET_DROP_0005
const isc::log::MessageID DHCP4_HOOK_PACKET_SEND_DROP
const isc::log::MessageID DHCP4_PACKET_DROP_0001
bool isV4() const
Convenience function to check for an IPv4 address.
Convenience container for conveying DDNS behavioral parameters It is intended to be created per Packe...
const isc::log::MessageID DHCP4_HOOK_PACKET_SEND_SKIP
static OptionDefinitionPtr getOptionDef(const std::string &space, const uint16_t code)
Return the first option definition matching a particular option code.
bool empty() const
Check if classes is empty.
const int DBG_DHCP4_HOOKS
Debug level used to trace hook related operations.
const isc::log::MessageID DHCP4_CLIENT_FQDN_DATA
boost::shared_ptr< ClientClassDef > ClientClassDefPtr
a pointer to an ClientClassDef
OptionPtr option_
Option instance.
virtual Pkt4Ptr receivePacket(int timeout)
dummy wrapper around IfaceMgr::receive4
const isc::log::MessageID DHCP4_RESPONSE_HOSTNAME_DATA
boost::shared_ptr< SharedNetwork4 > SharedNetwork4Ptr
Pointer to SharedNetwork4 object.
const isc::log::MessageID DHCP4_GENERATE_FQDN
const isc::log::MessageID DHCP4_HOOK_PACKET_RCVD_SKIP
void processPacketAndSendResponse(Pkt4Ptr &query)
Process a single incoming DHCPv4 packet and sends the response.
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_OPEN_SOCKET
static void processStatsSent(const Pkt4Ptr &response)
Updates statistics for transmitted packets.
void addValue(const std::string &name, const int64_t value)
Records incremental integer observation.
const isc::log::MessageID DHCP4_HOOK_BUFFER_SEND_SKIP
boost::shared_ptr< AllocEngine > alloc_engine_
Allocation Engine.
Client race avoidance RAII handler.
const isc::log::MessageID DHCP4_PACKET_DROP_0009
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
NetworkStatePtr network_state_
Holds information about disabled DHCP service and/or disabled subnet/network scopes.
Datagram socket, i.e. IP/UDP socket.
void startD2()
Starts DHCP_DDNS client IO if DDNS updates are enabled.
const isc::log::MessageID DHCP4_SUBNET_DATA
void declineLease(const Lease4Ptr &lease, const Pkt4Ptr &decline, AllocEngine::ClientContext4Ptr &context)
Marks lease as declined.
const char *const config_report[]
Represents DHCPv4 packet.
const isc::log::MessageID DHCP4_RELEASE_EXPIRED
D2ClientMgr isolates Kea from the details of being a D2 client.
const isc::log::MessageID DHCP4_CLASS_ASSIGNED
void getUpdateDirections(const T &fqdn_resp, bool &forward, bool &reverse)
Get directional update flags based on server FQDN flags.
static const uint8_t FLAG_E
Bit E.
bool getSendResponsesToSource() const
Returns value of the test_send_responses_to_source_ flag.
RequirementLevel
defines if certain option may, must or must not appear
ReplaceClientNameMode
Defines the client name replacement modes.
const isc::log::MessageID DHCP4_CLIENT_HOSTNAME_PROCESS
boost::shared_ptr< ClientClassDefList > ClientClassDefListPtr
Defines a pointer to a ClientClassDefList.
const isc::log::MessageID DHCP4_RELEASE
isc::dhcp::Subnet4Ptr selectSubnet(const Pkt4Ptr &query, bool &drop, bool sanity_only=false) const
Selects a subnet for a given client's packet.
const isc::log::MessageID DHCP4_PACKET_PROCESS_EXCEPTION
Exception thrown when a call to select is interrupted by a signal.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
static std::string srvidToString(const OptionPtr &opt)
converts server-id to text Converts content of server-id option to a text representation, e.g.
isc::log::Logger hooks_logger("hooks")
Hooks Logger.
const isc::log::MessageID DHCP4_HOOK_LEASE4_RELEASE_SKIP
const isc::log::MessageID DHCP4_QUERY_DATA
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.
const isc::log::MessageID DHCP4_PACKET_DROP_0007
void requiredClassify(Dhcpv4Exchange &ex)
Assigns incoming packet to zero or more classes (required pass).
Pkt4Ptr getQuery() const
Returns the pointer to the query from the client.
static const uint32_t INFINITY_LFT
Infinity (means static, i.e. never expire)
const isc::log::MessageID DHCP4_SUBNET_SELECTED
boost::shared_ptr< Pkt4o6 > Pkt4o6Ptr
A pointer to Pkt4o6 object.
void assignLease(Dhcpv4Exchange &ex)
Assigns a lease and appends corresponding options.
static const IOAddress & IPV4_BCAST_ADDRESS()
Returns a "255.255.255.255" broadcast address.
static const std::string VENDOR_CLASS_PREFIX
this is a prefix added to the content of vendor-class option
Pkt4Ptr processDiscover(Pkt4Ptr &discover, AllocEngine::ClientContext4Ptr &context)
Processes incoming DISCOVER and returns response.
const isc::log::MessageID DHCP4_PACKET_PROCESS_STD_EXCEPTION
void closeSockets()
Closes all open sockets.
Holds Client identifier or client IPv4 address.
isc::dhcp::Subnet4Ptr selectSubnet4o6(const Pkt4Ptr &query, bool &drop, bool sanity_only=false) const
Selects a subnet for a given client's DHCP4o6 packet.
const isc::log::MessageID DHCP4_PACKET_OPTIONS_SKIPPED
bool accept(const Pkt4Ptr &query) const
Checks whether received message should be processed or discarded.
const isc::log::MessageID DHCP4_SRV_CONSTRUCT_ERROR
void initResponse4o6()
Initializes the DHCPv6 part of the response message.
static IfaceMgr & instance()
IfaceMgr is a singleton class.
An exception that is thrown if a DHCPv6 protocol violation occurs while processing a message (e...
#define DHCP4_OPTION_SPACE
global std option spaces
const isc::log::MessageID DHCP4_DHCP4O6_HOOK_SUBNET4_SELECT_SKIP
const isc::log::MessageID DHCP4_RESPONSE_FQDN_DATA
boost::shared_ptr< OptionContainer > OptionContainerPtr
Pointer to the OptionContainer object.
const isc::log::MessageID DHCP4_UNKNOWN_ADDRESS_REQUESTED
const_iterator cend() const
Iterators to the past the end element.
const isc::log::MessageID DHCP4_LEASE_ALLOC
bool tryLock(Pkt4Ptr query, ContinuationPtr cont=ContinuationPtr())
Tries to acquires a client.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
void deleteResponse()
Removes the response message by resetting the pointer to NULL.
const isc::log::MessageID DHCP4_HOOK_SUBNET4_SELECT_SKIP
void appendBasicOptions(Dhcpv4Exchange &ex)
Append basic options if they are not present.
std::string iface_name_
Name of the interface on which the message was received.
void processClientName(Dhcpv4Exchange &ex)
Processes Client FQDN and Hostname Options sent by a client.
int run()
Main server processing loop.
CfgOptionList & getCfgOptionList()
Returns the configured option list (non-const version)
static OptionDefinitionPtr getLastResortOptionDef(const std::string &space, const uint16_t code)
Returns last resort option definition by space and option code.
isc::log::Logger ddns4_logger(DHCP4_DDNS_LOGGER_NAME)
Logger for Hostname or FQDN processing.
void conditionallySetReservedClientClasses()
Assigns classes retrieved from host reservation database if they haven't been yet set...
static uint16_t checkRelayPort(const Dhcpv4Exchange &ex)
Check if the relay port RAI sub-option was set in the query.
const isc::log::MessageID DHCP4_PACKET_NAK_0004
uint16_t getSocket(const isc::dhcp::Pkt6Ptr &pkt)
Return most suitable socket for transmitting specified IPv6 packet.
bool getUpdateOnRenew() const
Returns whether or not DNS should be updated when leases renew.
boost::shared_ptr< const CfgHostOperations > ConstCfgHostOperationsPtr
Pointer to the const object.
const isc::log::MessageID DHCP4_DHCP4O6_HOOK_SUBNET4_SELECT_DROP
void close()
Close communication socket.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
const isc::log::MessageID DHCP4_DEFERRED_OPTION_MISSING
void suspendUpdates()
Suspends sending requests.
bool dhcp4o6_
Specifies if the packet is DHCP4o6.
Defines the Dhcp4o6Ipc class.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const =0
Returns an IPv4 lease for specified IPv4 address.
void setReservedMessageFields()
Sets reserved values of siaddr, sname and file in the server's response.
string trim(const string &instring)
Trim Leading and Trailing Spaces.
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
isc::asiolink::IOAddress linkaddr_
fixed field in relay-forw/relay-reply
virtual bool deleteLease(const Lease4Ptr &lease)=0
Deletes an IPv4 lease.
const isc::log::MessageID DHCP4_DEFERRED_OPTION_UNPACK_FAIL
const isc::log::MessageID DHCP4_PACKET_NAK_0001
bool isDirectResponseSupported() const
Check if packet be sent directly to the client having no address.
bool isClientClassBuiltIn(const ClientClass &client_class)
Check if a client class name is builtin.
isc::log::Logger lease4_logger(DHCP4_LEASE_LOGGER_NAME)
Logger for lease allocation logic.
void insert(const ClientClass &class_name)
Insert an element.
std::list< std::list< std::string > > jsonPathsToRedact() const final override
Return a list of all paths that contain passwords or secrets for kea-dhcp4.
boost::shared_ptr< StringSanitizer > StringSanitizerPtr
Type representing the pointer to the StringSanitizer.
void shutdown() override
Instructs the server to shut down.
IdentifierType
Type of the host identifier.
static unsigned int getLabelCount(const std::string &text_name)
Return the number of labels in the Name.
const isc::log::MessageID DHCP4_RESPONSE_HOSTNAME_GENERATE
The IOAddress class represents an IP addresses (version agnostic)
static LeaseMgr & instance()
Return current lease manager.
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.
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...
void deferredUnpack(Pkt4Ptr &query)
Perform deferred option unpacking.
isc::hooks::CalloutHandlePtr getCalloutHandle(const T &pktptr)
CalloutHandle Store.
const isc::log::MessageID DHCP4_CLIENT_NAME_PROC_FAIL
const isc::log::MessageID EVAL_RESULT
Option with defined data fields represented as buffers that can be accessed using data field index...
boost::shared_ptr< OptionVendor > OptionVendorPtr
Pointer to a vendor option.
const isc::log::MessageID DHCP4_DECLINE_LEASE_NOT_FOUND
const isc::log::MessageID DHCP4_SUBNET_DYNAMICALLY_CHANGED
const isc::log::MessageID DHCP4_PACKET_NAK_0003
static void evaluateClasses(const Pkt4Ptr &pkt, bool depend_on_known)
Evaluate classes.
static void setReservedClientClasses(AllocEngine::ClientContext4Ptr context)
Assigns classes retrieved from host reservation database.
static std::string getVersion(bool extended)
returns Kea version on stdout and exit.
uint16_t client_port_
UDP port number to which server sends all responses.
Context information for the DHCPv4 lease allocation.
void processPacketAndSendResponseNoThrow(Pkt4Ptr &query)
Process a single incoming DHCPv4 packet and sends the response.
void adjustIfaceData(Dhcpv4Exchange &ex)
Set IP/UDP and interface parameters for the DHCPv4 response.
const isc::log::MessageID DHCP4_HOOK_LEASES4_COMMITTED_PARK
DHCPv4 and DHCPv6 allocation engine.
static void processStatsReceived(const Pkt4Ptr &query)
Class methods for DHCPv4-over-DHCPv6 handler.
OptionContainer::nth_index< 2 >::type OptionContainerPersistIndex
Type of the index #2 - option persistency flag.
const isc::log::MessageID DHCP4_HOOK_LEASES4_COMMITTED_DROP
const isc::log::MessageID DHCP4_PACKET_DROP_0003
boost::shared_ptr< Continuation > ContinuationPtr
Define the type of shared pointers to continuations.
#define VENDOR_ID_CABLE_LABS
Class which represents an option carrying a single string value.
Pkt4Ptr getResponse() const
Returns the pointer to the server's response.
Container for storing client class names.
Represents DHCPv4-over-DHCPv6 packet.
const isc::log::MessageID DHCP4_HOOK_DECLINE_SKIP
boost::shared_ptr< Expression > ExpressionPtr
Contains declarations for loggers used by the DHCPv4 server component.
This class represents vendor-specific information option.
void setFlag(const uint8_t flag, const bool set)
Modifies the value of the specified DHCPv4 Client Fqdn Option flag.
void setValue(const std::string &name, const int64_t value)
Records absolute integer observation.
static int getHookIndexPkt4Receive()
Returns the index for "pkt4_receive" hook point.
void adjustFqdnFlags(const T &fqdn, T &fqdn_resp, const DdnsParams &ddns_params)
Set server FQDN flags based on configuration and a given FQDN.
AllocEngine::ClientContext4Ptr getContext() const
Returns the copy of the context for the Allocation engine.
void setValue(const std::string &value)
Sets the string value to be held by the option.
const isc::log::MessageID DHCP4_DDNS_REQUEST_SEND_FAILED
const isc::log::MessageID DHCP4_PACKET_DROP_0014
const isc::log::MessageID DHCP4_RESERVED_HOSTNAME_ASSIGNED
void stopSender()
Disables sending NameChangeRequests to kea-dhcp-ddns.
ContinuationPtr makeContinuation(Continuation &&cont)
Continuation factory.