34#include <boost/scoped_ptr.hpp>
35#include <boost/algorithm/string.hpp>
57const int128_t uint32_min = numeric_limits<uint32_t>::min();
58const int128_t uint32_max = numeric_limits<uint32_t>::max();
103 if (txt ==
"hw-address") {
105 }
else if (txt ==
"duid") {
107 }
else if (txt ==
"client-id") {
111 << txt <<
", the only supported values are: "
112 "hw-address, duid, client-id");
410 const int control_result,
411 const std::string& error_message)
const;
424 short family = AF_INET)
const;
451 if (!user_context || (user_context->getType() !=
Element::map)) {
458 return (
isc->get(
"relay-info"));
508 if (lease->stateRegistered()) {
513 if (force_create && !existing) {
517 "lost race between calls to get and add");
532 << lease->addr_ <<
" either because the lease has been "
533 "deleted or it has changed in the database, in both cases a "
534 "retry might succeed");
545 if (force_create && !existing) {
549 "lost race between calls to get and add");
556 if (existing->stateRegistered() && !lease->stateRegistered()) {
559 }
else if (!existing->stateRegistered() && lease->stateRegistered()) {
561 <<
" can't be registered");
572 if ((!old_extended_info && !extended_info) ||
573 (old_extended_info && extended_info &&
574 (*old_extended_info == *extended_info))) {
584 << lease->addr_ <<
" either because the lease has been "
585 "deleted or it has changed in the database, in both cases a "
586 "retry might succeed");
599 string lease_address =
"unknown";
610 bool force_create =
false;
617 lease_address = lease4->addr_.toText();
625 if (resource_handler.
tryLock4(lease4->addr_)) {
629 "ResourceBusy: IP address:" << lease4->addr_
630 <<
" could not be added.");
639 resp <<
"Lease for address " << lease4->addr_.toText()
640 <<
", subnet-id " << lease4->subnet_id_ <<
" added.";
646 lease_address = lease6->addr_.toText();
654 if (resource_handler.
tryLock(lease6->type_, lease6->addr_)) {
658 "ResourceBusy: IP address:" << lease6->addr_
659 <<
" could not be added.");
669 resp <<
"Lease for address " << lease6->addr_.toText()
670 <<
", subnet-id " << lease6->subnet_id_ <<
" added.";
672 resp <<
"Lease for prefix " << lease6->addr_.toText()
673 <<
"/" <<
static_cast<int>(lease6->prefixlen_)
674 <<
", subnet-id " << lease6->subnet_id_ <<
" added.";
685 }
catch (
const std::exception& ex) {
708 if (params->contains(
"update-ddns")) {
721 if (params->contains(
"type")) {
722 string t = params->get(
"type")->stringValue();
723 if (t ==
"IA_NA" || t ==
"0") {
725 }
else if (t ==
"IA_PD" || t ==
"2") {
727 }
else if (t ==
"V4" || t ==
"3") {
731 <<
", only supported values are: IA_NA, IA_PD and V4");
745 txt <<
"Invalid " << (v6 ?
"IPv6" :
"IPv4")
746 <<
" address specified: " << tmp->stringValue();
754 tmp = params->get(
"subnet-id");
762 if ((tmp128 < uint32_min) || (tmp128 > uint32_max)) {
767 tmp = params->get(
"iaid");
775 tmp128 = tmp->intValue();
776 if ((tmp128 < uint32_min) || (tmp128 > uint32_max)) {
779 x.
iaid =
static_cast<uint32_t
>(tmp128);
790 " and 'identifier-type' is either missing or not a string.");
794 " and 'identifier' is either missing or not a string.");
806 }
catch (
const std::exception& ex) {
813 }
catch (
const std::exception& ex) {
821 }
catch (
const std::exception& ex) {
827 " is not supported.");
857 "requires hwaddr to be specified");
870 "requires duid to be specified");
884 "requires client-id to be specified");
898 }
catch (
const std::exception& ex) {
908 lease_json = lease4->toElement();
910 "IPv4 lease found.", lease_json);
912 }
else if (!v4 && lease6) {
913 lease_json = lease6->toElement();
915 "IPv6 lease found.", lease_json);
945 const std::vector<ElementPtr>& subnet_ids = subnets->listValue();
946 for (
auto const& subnet_id : subnet_ids) {
950 auto subnet_id_ = subnet_id->intValue();
951 if ((subnet_id_ < uint32_min) || (subnet_id_ > uint32_max)) {
959 for (
auto const& lease : leases) {
961 leases_json->add(lease_json);
966 for (
auto const& lease : leases) {
968 leases_json->add(lease_json);
977 for (
auto const& lease : leases) {
979 leases_json->add(lease_json);
983 for (
auto const& lease : leases) {
985 leases_json->add(lease_json);
990 std::ostringstream s;
991 s << leases_json->size()
992 <<
" IPv" << (v4 ?
"4" :
"6")
993 <<
" lease(s) found.";
995 args->set(
"leases", leases_json);
1003 }
catch (
const std::exception& ex) {
1037 boost::scoped_ptr<IOAddress> from_address;
1039 if (from->stringValue() ==
"start") {
1040 from_address.reset(
new IOAddress(v4 ?
"0.0.0.0" :
"::"));
1044 from_address.reset(
new IOAddress(from->stringValue()));
1049 "a valid IPv" << (v4 ?
"4" :
"6") <<
" address");
1054 if (v4 && (!from_address->isV4())) {
1056 <<
" is not an IPv4 address");
1058 }
else if (!v4 && from_address->isV4()) {
1060 <<
" is not an IPv6 address");
1074 auto tmp128 = page_limit->intValue();
1075 if ((tmp128 < uint32_min) || (tmp128 > uint32_max)) {
1084 size_t page_limit_value =
static_cast<size_t>(tmp128);
1095 for (
auto const& lease : leases) {
1097 leases_json->add(lease_json);
1106 for (
auto const& lease : leases) {
1108 leases_json->add(lease_json);
1113 std::ostringstream s;
1114 s << leases_json->size()
1115 <<
" IPv" << (v4 ?
"4" :
"6")
1116 <<
" lease(s) found.";
1120 args->set(
"leases", leases_json);
1121 args->set(
"count",
Element::create(
static_cast<int64_t
>(leases_json->size())));
1131 }
catch (
const std::exception& ex) {
1144 v4 = (
cmd_name_ ==
"lease4-get-by-hw-address");
1162 if (hw_address->stringValue().empty()) {
1169 }
catch (
const std::exception& ex) {
1177 for (
auto const& lease : leases) {
1179 leases_json->add(lease_json);
1184 for (
auto const& lease : leases) {
1186 leases_json->add(lease_json);
1190 std::ostringstream s;
1191 s << leases_json->size()
1192 <<
" IPv" << (v4 ?
"4" :
"6")
1193 <<
" lease(s) found.";
1195 args->set(
"leases", leases_json);
1203 }
catch (
const std::exception& ex) {
1235 }
catch (
const std::exception& ex) {
1242 for (
auto const& lease : leases) {
1244 leases_json->add(lease_json);
1247 std::ostringstream s;
1248 s << leases_json->size() <<
" IPv4 lease(s) found.";
1250 args->set(
"leases", leases_json);
1258 }
catch (
const std::exception& ex) {
1290 }
catch (
const std::exception& ex) {
1297 for (
auto const& lease : leases) {
1299 leases_json->add(lease_json);
1302 std::ostringstream s;
1303 s << leases_json->size() <<
" IPv6 lease(s) found.";
1305 args->set(
"leases", leases_json);
1313 }
catch (
const std::exception& ex) {
1326 v4 = (
cmd_name_ ==
"lease4-get-by-state");
1339 uint32_t state_ = 0;
1342 std::string state_str = state->stringValue();
1343 if (state_str.empty()) {
1345 }
else if ((state_str ==
"default") || (state_str ==
"assigned")) {
1347 }
else if (state_str ==
"declined") {
1349 }
else if (state_str ==
"expired-reclaimed") {
1351 }
else if (state_str ==
"released") {
1353 }
else if (state_str ==
"registered") {
1357 <<
") is not recognized");
1360 state_ = state->intValue();
1371 auto id128 = subnet->intValue();
1372 if ((id128 < uint32_min) || (id128 > uint32_max)) {
1375 subnet_id_ =
static_cast<SubnetID>(id128);
1383 for (
auto const& lease : leases) {
1385 leases_json->add(lease_json);
1391 for (
auto const& lease : leases) {
1393 leases_json->add(lease_json);
1397 std::ostringstream s;
1398 s << leases_json->size()
1399 <<
" IPv" << (v4 ?
"4" :
"6")
1400 <<
" lease(s) found with state ";
1406 if (subnet_id_ != 0) {
1407 s <<
" in subnet " << subnet_id_;
1411 args->set(
"leases", leases_json);
1419 }
catch (
const std::exception& ex) {
1432 v4 = (
cmd_name_ ==
"lease4-get-by-hostname");
1450 std::string hostname_ = hostname->stringValue();
1452 if (hostname_.empty()) {
1455 boost::algorithm::to_lower(hostname_);
1462 for (
auto const& lease : leases) {
1464 leases_json->add(lease_json);
1470 for (
auto const& lease : leases) {
1472 leases_json->add(lease_json);
1476 std::ostringstream s;
1477 s << leases_json->size()
1478 <<
" IPv" << (v4 ?
"4" :
"6")
1479 <<
" lease(s) found.";
1481 args->set(
"leases", leases_json);
1489 }
catch (
const std::exception& ex) {
1517 "requires hwaddr to be specified");
1531 "requires client-id to be specified");
1564 }
catch (
const std::exception& ex) {
1572 .arg(lease4->addr_.toText());
1587 auto deleted_leases =
cmd_args_->get(
"deleted-leases");
1590 if (!deleted_leases && !leases) {
1596 if (deleted_leases && (deleted_leases->getType() !=
Element::list)) {
1608 std::list<std::pair<Parameters, Lease6Ptr> > parsed_deleted_list;
1609 if (deleted_leases) {
1610 auto leases_list = deleted_leases->listValue();
1613 for (
auto const& lease_params : leases_list) {
1618 parsed_deleted_list.push_back(std::make_pair(p, lease));
1624 std::list<Lease6Ptr> parsed_leases_list;
1629 auto leases_list = leases->listValue();
1630 for (
auto const& lease_params : leases_list) {
1638 parsed_leases_list.push_back(lease6);
1643 size_t success_count = 0;
1646 if (!parsed_deleted_list.empty()) {
1649 for (
auto const& lease_params_pair : parsed_deleted_list) {
1654 auto lease = lease_params_pair.second;
1667 if (!failed_deleted_list) {
1678 "lease not found"));
1682 }
catch (
const std::exception& ex) {
1684 if (!failed_deleted_list) {
1697 if (!parsed_leases_list.empty()) {
1701 for (
auto const& lease : parsed_leases_list) {
1704 std::ostringstream text;
1712 if (resource_handler.
tryLock(lease->type_, lease->addr_)) {
1716 "ResourceBusy: IP address:" << lease->addr_
1717 <<
" could not be updated.");
1726 }
catch (
const std::exception& ex) {
1733 if (!failed_leases_list) {
1748 if (failed_deleted_list || failed_leases_list) {
1753 if (failed_deleted_list) {
1754 args->set(
"failed-deleted-leases", failed_deleted_list);
1758 if (failed_leases_list) {
1759 args->set(
"failed-leases", failed_leases_list);
1764 std::ostringstream resp_text;
1765 resp_text <<
"Bulk apply of " << success_count <<
" IPv6 leases completed.";
1772 .arg(success_count);
1774 }
catch (
const std::exception& ex) {
1814 "requires duid to be specified");
1844 }
catch (
const std::exception& ex) {
1853 .arg(lease6->addr_.toText());
1871 bool force_create =
false;
1883 if (resource_handler.
tryLock4(lease4->addr_)) {
1887 "ResourceBusy: IP address:" << lease4->addr_
1888 <<
" could not be updated.");
1899 .arg(lease4->addr_.toText());
1908 }
catch (
const std::exception& ex) {
1933 bool force_create =
false;
1945 if (resource_handler.
tryLock(lease6->type_, lease6->addr_)) {
1949 "ResourceBusy: IP address:" << lease6->addr_
1950 <<
" could not be updated.");
1961 .arg(lease6->addr_.toText());
1970 }
catch (
const std::exception& ex) {
2005 int64_t previous_assigned = 0;
2007 if (assigned_observation) {
2008 previous_assigned = assigned_observation->getInteger().first;
2014 int64_t previous_declined = 0;
2016 if (declined_observation) {
2017 previous_declined = declined_observation->getInteger().first;
2022 static_cast<int64_t
>(0));
2026 static_cast<int64_t
>(0));
2033 "assigned-addresses")));
2040 "declined-addresses")));
2057 for (
auto const& sub : *subs) {
2059 ids <<
" " << sub->getID();
2062 static_cast<int64_t
>(0));
2066 static_cast<int64_t
>(0));
2071 "assigned-addresses")));
2078 "declined-addresses")));
2091 tmp <<
"Deleted " << num <<
" IPv4 lease(s) from subnet(s)" << ids.str();
2095 }
catch (
const std::exception& ex) {
2137 int64_t previous_assigned_na = 0;
2139 if (assigned_na_observation) {
2140 previous_assigned_na = assigned_na_observation->getInteger().first;
2146 int64_t previous_assigned_pd = 0;
2148 if (assigned_pd_observation) {
2149 previous_assigned_pd = assigned_pd_observation->getInteger().first;
2155 int64_t previous_declined = 0;
2157 if (declined_observation) {
2158 previous_declined = declined_observation->getInteger().first;
2163 static_cast<int64_t
>(0));
2167 static_cast<int64_t
>(0));
2171 static_cast<int64_t
>(0));
2175 static_cast<int64_t
>(0));
2189 "declined-addresses")));
2217 for (
auto const& sub : *subs) {
2219 ids <<
" " << sub->getID();
2222 static_cast<int64_t
>(0));
2226 static_cast<int64_t
>(0));
2230 static_cast<int64_t
>(0));
2234 static_cast<int64_t
>(0));
2246 "declined-addresses")));
2270 tmp <<
"Deleted " << num <<
" IPv6 lease(s) from subnet(s)" << ids.str();
2274 }
catch (
const std::exception& ex) {
2299 lease6.reset(
new Lease6());
2300 lease6->addr_ = parameters.
addr;
2309 if (!parameters.
duid) {
2311 "requires duid to be specified");
2331 short family)
const {
2344 }
catch (
const std::exception& ex) {
2346 <<
"' is not a valid IP address.");
2351 << (family == AF_INET6 ?
"IPv6" :
"IPv4")
2352 <<
" address specified: " << param->stringValue());
2360 std::stringstream ss;
2370 ss <<
"DDNS updating is not enabled";
2376 ss <<
"No lease found for: " << addr.
toText();
2378 }
else if (lease->hostname_.empty()) {
2379 ss <<
"Lease for: " << addr.
toText()
2380 <<
", has no hostname, nothing to update";
2382 }
else if (!lease->fqdn_fwd_ && !lease->fqdn_rev_) {
2383 ss <<
"Neither forward nor reverse updates enabled for lease for: "
2390 ss <<
"NCR generated for: " << addr.
toText()
2391 <<
", hostname: " << lease->hostname_;
2397 }
catch (
const std::exception& ex) {
2408 std::stringstream ss;
2418 ss <<
"DDNS updating is not enabled";
2424 ss <<
"No lease found for: " << addr.
toText();
2426 }
else if (lease->hostname_.empty()) {
2427 ss <<
"Lease for: " << addr.
toText()
2428 <<
", has no hostname, nothing to update";
2430 }
else if (!lease->fqdn_fwd_ && !lease->fqdn_rev_) {
2431 ss <<
"Neither forward nor reverse updates enabled for lease for: "
2438 ss <<
"NCR generated for: " << addr.
toText()
2439 <<
", hostname: " << lease->hostname_;
2445 }
catch (
const std::exception& ex) {
2458 const int control_result,
2459 const std::string& error_message)
const {
2472 failed_lease_map->set(
"error-message",
Element::create(error_message));
2474 return (failed_lease_map);
2496 std::string filename;
2502 filename =
file->stringValue();
2503 }
catch (
const std::exception& ex) {
2514 s << (v4 ?
"IPv4" :
"IPv6")
2515 <<
" lease database into '"
2516 << filename <<
"'.";
2519 }
catch (
const std::exception& ex) {
2530 uint32_t offer_lifetime;
2531 callout_handle.
getArgument(
"offer_lifetime", offer_lifetime);
2532 if (!offer_lifetime) {
2543 callout_handle.
getArgument(
"response4", response);
2546 if (!leases || leases->empty() || !((*leases)[0])) {
2552 if (mgr->evaluateVariables(query, response, lease)) {
2557 " the lease with address " << lease->addr_ <<
2558 " either because the lease has been"
2559 " deleted or it has changed in the database");
2560 }
catch (
const std::exception& ex) {
2562 << query->getLabel() <<
", :" << ex.what());
2575 callout_handle.
getArgument(
"response4", response);
2584 if (leases->empty() || !response || (response->getType() !=
DHCPACK)) {
2594 if (mgr->evaluateVariables(query, response, lease)) {
2599 " the lease with address " << lease->addr_ <<
2600 " either because the lease has been"
2601 " deleted or it has changed in the database");
2602 }
catch (
const std::exception& ex) {
2604 << query->getLabel() <<
", :" << ex.what());
2617 callout_handle.
getArgument(
"response6", response);
2625 if (leases->empty() || !response) {
2631 for (
auto lease : *leases) {
2643 if (lease->valid_lft_) {
2645 if (mgr->evaluateVariables(query, response, lease)) {
2652 .arg(lease->addr_.toText())
2653 .arg(query->getLabel());
2654 }
catch (
const std::exception& ex) {
2657 .arg(query->getLabel())
2658 .arg(lease->addr_.toText())
2665 <<
" leases failed to update for "
2666 << query->getLabel());
2672 return (impl_->leaseAddHandler(handle));
2677 return (impl_->lease6BulkApplyHandler(handle));
2682 return (impl_->leaseGetHandler(handle));
2687 return (impl_->leaseGetAllHandler(handle));
2692 return (impl_->leaseGetPageHandler(handle));
2697 return (impl_->leaseGetByHwAddressHandler(handle));
2702 return (impl_->leaseGetByClientIdHandler(handle));
2707 return (impl_->leaseGetByDuidHandler(handle));
2712 return (impl_->leaseGetByStateHandler(handle));
2717 return (impl_->leaseGetByHostnameHandler(handle));
2722 return (impl_->lease4DelHandler(handle));
2727 return (impl_->lease6DelHandler(handle));
2732 return (impl_->lease4UpdateHandler(handle));
2737 return (impl_->lease6UpdateHandler(handle));
2743 return (impl_->lease4WipeHandler(handle));
2749 return (impl_->lease6WipeHandler(handle));
2754 return (impl_->lease4ResendDdnsHandler(handle));
2759 return (impl_->lease6ResendDdnsHandler(handle));
2764 return (impl_->leaseWriteHandler(handle));
2774 impl_->lease4Offer(callout_handle, mgr);
2780 impl_->leases4Committed(callout_handle, mgr);
2786 impl_->leases6Committed(callout_handle, mgr);
static DUID fromText(const std::string &text)
Create DUID from the textual format.
static const DUID & EMPTY()
Defines the constant "empty" DUID.
static ElementPtr create(const Position &pos=ZERO_POSITION())
Create a NullElement.
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Exception thrown when a command failed due to a conflict.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown if a function is called in a prohibited way.
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
A generic exception that is thrown when an unexpected error condition occurs.
The IOAddress class represents an IP addresses (version agnostic).
std::string toText() const
Convert the address to a string.
bool isV6() const
Convenience function to check for an IPv6 address.
bool isV4() const
Convenience function to check for an IPv4 address.
bool isV6Zero() const
Convenience function to check if it is an IPv4 zero address.
short getFamily() const
Returns the address family.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
Base class that command handler implementers may use for common tasks.
std::string cmd_name_
Stores the command name extracted by a call to extractCommand.
void setErrorResponse(hooks::CalloutHandle &handle, const std::string &text, int status=CONTROL_RESULT_ERROR)
Set the callout argument "response" to indicate an error.
data::ConstElementPtr cmd_args_
Stores the command arguments extracted by a call to extractCommand.
void extractCommand(hooks::CalloutHandle &handle)
Extracts the command name and arguments from a Callout handle.
void setSuccessResponse(hooks::CalloutHandle &handle, const std::string &text)
Set the callout argument "response" to indicate success.
void setResponse(hooks::CalloutHandle &handle, data::ConstElementPtr &response)
Set the callout argument "response" to the given response.
uint32_t getUint32(isc::data::ConstElementPtr scope, const std::string &name)
Returns a value converted to uint32_t.
std::string validatePath(const std::string data_path) const
Validates a file path against the supported directory for DHCP data.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
static ClientIdPtr fromText(const std::string &text)
Create client identifier from the textual format.
Holds DUID (DHCPv6 Unique Identifier).
static TrackingLeaseMgr & instance()
Return current lease manager.
virtual Lease6Collection getLeases6(Lease::Type type, const DUID &duid, uint32_t iaid) const =0
Returns existing IPv6 leases for a given DUID+IA combination.
virtual size_t wipeLeases6(const SubnetID &subnet_id)=0
Virtual method which removes specified leases.
static void updateStatsOnAdd(const Lease4Ptr &lease)
Update in-memory stats when adding a v4 lease.
virtual Lease4Collection getLeases4(SubnetID subnet_id) const =0
Returns all IPv4 leases for the particular subnet identifier.
virtual void writeLeases6(const std::string &filename)=0
Write V6 leases to a file.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const =0
Returns an IPv4 lease for specified IPv4 address.
static void updateStatsOnUpdate(const Lease4Ptr &existing, const Lease4Ptr &lease)
Update in-memory stats when updating a v4 lease.
virtual bool addLease(const Lease4Ptr &lease)=0
Adds an IPv4 lease.
virtual size_t wipeLeases4(const SubnetID &subnet_id)=0
Virtual method which removes specified leases.
virtual void updateLease4(const Lease4Ptr &lease4)=0
Updates IPv4 lease.
virtual void writeLeases4(const std::string &filename)=0
Write V4 leases to a file.
static void updateStatsOnDelete(const Lease4Ptr &lease)
Update in-memory stats when deleting a v4 lease.
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const =0
Returns existing IPv6 lease for a given IPv6 address.
virtual void updateLease6(const Lease6Ptr &lease6)=0
Updates IPv6 lease.
Wraps value holding size of the page with leases.
Attempt to update lease that was not there.
Resource race avoidance RAII handler for DHCPv4.
bool tryLock4(const asiolink::IOAddress &addr)
Tries to acquires a resource.
Resource race avoidance RAII handler.
bool tryLock(Lease::Type type, const asiolink::IOAddress &addr)
Tries to acquires a resource.
Per-packet callout handle.
void getArgument(const std::string &name, T &value) const
Get argument.
Parser for Lease4 structure.
virtual isc::dhcp::Lease4Ptr parse(isc::dhcp::ConstSrvConfigPtr &cfg, const isc::data::ConstElementPtr &lease_info, bool &force_create)
Parses Element tree and tries to convert to Lease4.
Parser for Lease6 structure.
virtual isc::dhcp::Lease6Ptr parse(isc::dhcp::ConstSrvConfigPtr &cfg, const isc::data::ConstElementPtr &lease_info, bool &force_create)
Parses Element tree and tries to convert to Lease4.
Parameters specified for lease commands.
uint32_t iaid
IAID identifier used for v6 leases.
HWAddrPtr hwaddr
Specifies hardware address (used when query_type is TYPE_HWADDR).
Lease::Type lease_type
Lease type (NA,TA or PD) used for v6 leases.
Type query_type
specifies parameter types
Type
specifies type of query (by IP addr, by hwaddr, by DUID)
@ TYPE_DUID
query by DUID (v6 only)
@ TYPE_CLIENT_ID
query by client identifier (v4 only).
@ TYPE_HWADDR
query by hardware address (v4 only)
@ TYPE_ADDR
query by IP address (either v4 or v6)
isc::dhcp::ClientIdPtr client_id
Specifies identifier value (used when query_type is TYPE_CLIENT_ID).
static Type txtToType(const std::string &txt)
Attempts to covert text to one of specified types.
Parameters()
Default constructor.
bool updateDDNS
Indicates whether or not DNS should be updated.
IOAddress addr
Specifies IPv4/v6 address (used when query_type is TYPE_ADDR).
SubnetID subnet_id
Specifies subnet-id (always used).
isc::dhcp::DuidPtr duid
Specifies identifier value (used when query_type is TYPE_DUID).
Wrapper class around reservation command handlers.
int lease4DelHandler(CalloutHandle &handle)
lease4-del command handler
IOAddress getAddressParam(ConstElementPtr params, const std::string name, short family=AF_INET) const
static void lease4Offer(CalloutHandle &callout_handle, BindingVariableMgrPtr mgr)
lease4_offer hookpoint handler.
ElementPtr createFailedLeaseMap(const Lease::Type &lease_type, const IOAddress &lease_address, const DuidPtr &duid, const int control_result, const std::string &error_message) const
Returns a map holding brief information about a lease which failed to be deleted, updated or added.
int leaseGetByStateHandler(hooks::CalloutHandle &handle)
lease4-get-by-state and lease6-get-by-state commands handler
static bool addOrUpdate6(Lease6Ptr lease, bool force_create)
Add or update lease.
int lease6BulkApplyHandler(CalloutHandle &handle)
lease6-bulk-apply command handler
int leaseGetByDuidHandler(hooks::CalloutHandle &handle)
lease6-get-by-duid command handler
int lease6UpdateHandler(CalloutHandle &handle)
lease6-update handler
int leaseGetPageHandler(hooks::CalloutHandle &handle)
lease4-get-page, lease6-get-page commands handler
Lease6Ptr getIPv6LeaseForDelete(const Parameters ¶meters) const
Convenience function fetching IPv6 address to be used to delete a lease.
int leaseGetByHostnameHandler(hooks::CalloutHandle &handle)
lease4-get-by-hostname and lease6-get-by-hostname commands handler
int lease6DelHandler(CalloutHandle &handle)
lease6-del command handler
int leaseGetByHwAddressHandler(hooks::CalloutHandle &handle)
lease4-get-by-hw-address, lease6-get-by-hw-address command handler
static ConstElementPtr getExtendedInfo6(const Lease6Ptr &lease)
Get DHCPv6 extended info.
int leaseGetHandler(CalloutHandle &handle)
lease4-get, lease6-get command handler
static bool addOrUpdate4(Lease4Ptr lease, bool force_create)
Add or update lease.
static void leases4Committed(CalloutHandle &callout_handle, BindingVariableMgrPtr mgr)
leases4_committed hookpoint handler.
int lease6WipeHandler(CalloutHandle &handle)
lease6-wipe handler
int leaseGetByClientIdHandler(hooks::CalloutHandle &handle)
lease4-get-by-client-id command handler
int lease6ResendDdnsHandler(CalloutHandle &handle)
lease6-resend-ddns handler
int leaseAddHandler(CalloutHandle &handle)
lease4-add, lease6-add command handler
int lease4ResendDdnsHandler(CalloutHandle &handle)
lease4-resend-ddns handler
Parameters getParameters(bool v6, const ConstElementPtr &args)
Extracts parameters required for reservation-get and reservation-del.
static void leases6Committed(CalloutHandle &callout_handle, BindingVariableMgrPtr mgr)
leases6_committed hookpoint handler.
int lease4UpdateHandler(CalloutHandle &handle)
lease4-update handler
int lease4WipeHandler(CalloutHandle &handle)
lease4-wipe handler
int leaseGetAllHandler(CalloutHandle &handle)
lease4-get-all, lease6-get-all commands handler
int leaseWriteHandler(CalloutHandle &handle)
lease4-write handler, lease6-write handler
int lease4ResendDdnsHandler(hooks::CalloutHandle &handle)
lease4-resend-ddns command handler
int leaseGetByStateHandler(hooks::CalloutHandle &handle)
lease4-get-by-state and lease6-get-by-state commands handler
int lease6WipeHandler(hooks::CalloutHandle &handle)
lease6-wipe handler
int leaseGetPageHandler(hooks::CalloutHandle &handle)
lease4-get-page, lease6-get-page commands handler
int lease6DelHandler(hooks::CalloutHandle &handle)
lease6-del command handler
int leaseGetAllHandler(hooks::CalloutHandle &handle)
lease4-get-all, lease6-get-all commands handler
int leaseGetByHostnameHandler(hooks::CalloutHandle &handle)
lease4-get-by-hostname and lease6-get-by-hostname commands handler
void leases4Committed(hooks::CalloutHandle &callout_handle, BindingVariableMgrPtr mgr)
leases4_committed hookpoint handler.
int lease4DelHandler(hooks::CalloutHandle &handle)
lease4-del command handler
int leaseWriteHandler(hooks::CalloutHandle &handle)
lease4-write handler, lease6-write handler
int leaseAddHandler(hooks::CalloutHandle &handle)
lease4-add, lease6-add command handler
int leaseGetByClientIdHandler(hooks::CalloutHandle &handle)
lease4-get-by-client-id command handler
void lease4Offer(hooks::CalloutHandle &callout_handle, BindingVariableMgrPtr mgr)
lease4_offer hookpoint handler.
int lease4UpdateHandler(hooks::CalloutHandle &handle)
lease4-update handler
int leaseGetHandler(hooks::CalloutHandle &handle)
lease4-get, lease6-get command handler
int leaseGetByHwAddressHandler(hooks::CalloutHandle &handle)
lease4-get-by-hw-address, lease6-get-by-hw-address command handler
int lease6UpdateHandler(hooks::CalloutHandle &handle)
lease6-update handler
void leases6Committed(hooks::CalloutHandle &callout_handle, BindingVariableMgrPtr mgr)
leases6_committed hookpoint handler.
int leaseGetByDuidHandler(hooks::CalloutHandle &handle)
lease6-get-by-duid command handler
int lease6BulkApplyHandler(hooks::CalloutHandle &handle)
lease6-bulk-apply command handler
int lease4WipeHandler(hooks::CalloutHandle &handle)
lease4-wipe handler
int lease6ResendDdnsHandler(hooks::CalloutHandle &handle)
lease6-resend-ddns command handler
ObservationPtr getObservation(const std::string &name) const
Returns an observation.
static StatsMgr & instance()
Statistics Manager accessor method.
static std::string generateName(const std::string &context, Type index, const std::string &stat_name)
Generates statistic name in a given context.
RAII class creating a critical section.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
A generic exception that is thrown if a parameter given violates security check but enforcement is la...
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
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.
const isc::log::MessageID LEASE_CMDS_DEL4
const isc::log::MessageID LEASE_CMDS_WIPE4_FAILED
const isc::log::MessageID LEASE_CMDS_UPDATE6_FAILED
const isc::log::MessageID LEASE_CMDS_UPDATE4_FAILED
const isc::log::MessageID LEASE_CMDS_WIPE6_FAILED
const isc::log::MessageID LEASE_CMDS_UPDATE6_CONFLICT
const isc::log::MessageID LEASE_CMDS_UPDATE4_CONFLICT
const isc::log::MessageID LEASE_CMDS_RESEND_DDNS4_FAILED
const isc::log::MessageID LEASE_CMDS_DEL6
const isc::log::MessageID LEASE_CMDS_ADD4_FAILED
const isc::log::MessageID LEASE_CMDS_LEASES6_COMMITTED_LEASE_ERROR
const isc::log::MessageID LEASE_CMDS_PATH_SECURITY_WARNING
const isc::log::MessageID LEASE_CMDS_ADD6
const isc::log::MessageID LEASE_CMDS_ADD4
const isc::log::MessageID LEASE_CMDS_WIPE6
const isc::log::MessageID LEASE_CMDS_ADD6_CONFLICT
const isc::log::MessageID LEASE_CMDS_BULK_APPLY6_FAILED
const isc::log::MessageID LEASE_CMDS_UPDATE6
const isc::log::MessageID LEASE_CMDS_RESEND_DDNS4
const isc::log::MessageID LEASE_CMDS_GET6_FAILED
const isc::log::MessageID LEASE_CMDS_WIPE4
const isc::log::MessageID LEASE_CMDS_BULK_APPLY6
const isc::log::MessageID LEASE_CMDS_RESEND_DDNS6_FAILED
const isc::log::MessageID LEASE_CMDS_RESEND_DDNS6
const isc::log::MessageID LEASE_CMDS_GET4_FAILED
const isc::log::MessageID LEASE_CMDS_ADD4_CONFLICT
const isc::log::MessageID LEASE_CMDS_LEASES6_COMMITTED_CONFLICT
const isc::log::MessageID LEASE_CMDS_DEL4_FAILED
const isc::log::MessageID LEASE_CMDS_ADD6_FAILED
const isc::log::MessageID LEASE_CMDS_UPDATE4
const isc::log::MessageID LEASE_CMDS_DEL6_FAILED
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.
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
const int CONTROL_RESULT_CONFLICT
Status code indicating that the command was unsuccessful due to a conflict between the command argume...
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< Lease4Collection > Lease4CollectionPtr
A shared pointer to the collection of IPv4 leases.
boost::shared_ptr< const SrvConfig > ConstSrvConfigPtr
Const pointer to the SrvConfig.
void queueNCR(const NameChangeType &chg_type, const Lease4Ptr &lease)
Creates name change request from the DHCPv4 lease.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
boost::shared_ptr< DUID > DuidPtr
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
boost::multi_index_container< Subnet6Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > Subnet6Collection
A collection of Subnet6 objects.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > Subnet4Collection
A collection of Subnet4 objects.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
boost::shared_ptr< const CfgSubnets4 > ConstCfgSubnets4Ptr
Const pointer.
boost::shared_ptr< const CfgSubnets6 > ConstCfgSubnets6Ptr
Const pointer.
boost::shared_ptr< Lease6Collection > Lease6CollectionPtr
A shared pointer to the collection of IPv6 leases.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
const int LEASE_CMDS_DBG_COMMAND_DATA
Logging level used to log successful commands.
isc::log::Logger lease_cmds_logger("lease-cmds-hooks")
boost::shared_ptr< BindingVariableMgr > BindingVariableMgrPtr
Defines a shared pointer to a BindingVariableMgr.
boost::multiprecision::checked_int128_t int128_t
Defines the logger used by the top-level component of kea-lfc.
Hardware type that represents information from DHCPv4 packet.
static HWAddr fromText(const std::string &text, const uint16_t htype=HTYPE_ETHER)
Creates instance of the hardware address from textual format.
Structure that holds a lease for IPv6 address and/or prefix.
@ ACTION_UPDATE
update extended info tables.
a common structure for IPv4 and IPv6 leases
static constexpr uint32_t STATE_DEFAULT
A lease in the default state.
static constexpr uint32_t STATE_EXPIRED_RECLAIMED
Expired and reclaimed lease.
static constexpr uint32_t STATE_DECLINED
Declined lease.
static constexpr uint32_t STATE_REGISTERED
Registered self-generated lease.
static std::string basicStatesToText(const uint32_t state)
Returns name(s) of the basic lease state(s).
static constexpr uint32_t STATE_RELEASED
Released lease held in the database for lease affinity.
static void syncCurrentExpirationTime(const Lease &from, Lease &to)
Sync lease current expiration time with new value from another lease, so that additional operations c...
Type
Type of lease or pool.
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
@ TYPE_NA
the lease contains non-temporary IPv6 address
static std::string typeToText(Type type)
returns text representation of a lease type