33#include <boost/scoped_ptr.hpp>
34#include <boost/algorithm/string.hpp>
92 if (txt ==
"address") {
94 }
else if (txt ==
"hw-address") {
96 }
else if (txt ==
"duid") {
98 }
else if (txt ==
"client-id") {
102 << txt <<
", the only supported values are: "
103 "address, hw-address, duid");
389 const int control_result,
390 const std::string& error_message)
const;
403 short family = AF_INET)
const;
465 if (!user_context || (user_context->getType() !=
Element::map)) {
472 return (
isc->get(
"relay-info"));
478 if (!lease->stateExpiredReclaimed()) {
481 "assigned-addresses"),
482 static_cast<int64_t
>(1));
492 "assigned-addresses")),
493 static_cast<int64_t
>(1));
497 if (lease->stateDeclined()) {
502 "declined-addresses"),
503 static_cast<int64_t
>(1));
509 "declined-addresses")),
510 static_cast<int64_t
>(1));
518 if (!lease->stateExpiredReclaimed()) {
522 "assigned-nas" :
"assigned-pds"),
523 static_cast<int64_t
>(1));
528 pool = subnet->getPool(lease->type_, lease->addr_,
false);
533 "pool" :
"pd-pool", pool->getID(),
535 "assigned-nas" :
"assigned-pds")),
536 static_cast<int64_t
>(1));
540 if (lease->stateDeclined()) {
545 "declined-addresses"),
546 static_cast<int64_t
>(1));
552 "declined-addresses")),
553 static_cast<int64_t
>(1));
562 if (!existing->stateExpiredReclaimed()) {
567 if (existing->subnet_id_ != lease->subnet_id_) {
570 "assigned-addresses"),
571 static_cast<int64_t
>(-1));
580 "assigned-addresses")),
581 static_cast<int64_t
>(-1));
586 if (existing->stateDeclined()) {
592 "declined-addresses"),
593 static_cast<int64_t
>(-1));
599 "declined-addresses")),
600 static_cast<int64_t
>(-1));
606 if (!lease->stateExpiredReclaimed()) {
608 if (existing->subnet_id_ != lease->subnet_id_) {
611 "assigned-addresses"),
612 static_cast<int64_t
>(1));
621 "assigned-addresses")),
622 static_cast<int64_t
>(1));
627 if (lease->stateDeclined()) {
633 "declined-addresses"),
634 static_cast<int64_t
>(1));
640 "declined-addresses")),
641 static_cast<int64_t
>(1));
647 if (!lease->stateExpiredReclaimed()) {
651 "assigned-addresses"),
652 static_cast<int64_t
>(1));
662 "assigned-addresses")),
663 static_cast<int64_t
>(1));
667 if (lease->stateDeclined()) {
673 "declined-addresses"),
674 static_cast<int64_t
>(1));
680 "declined-addresses")),
681 static_cast<int64_t
>(1));
691 if (!existing->stateExpiredReclaimed()) {
696 if (existing->subnet_id_ != lease->subnet_id_) {
700 "assigned-nas" :
"assigned-pds"),
701 static_cast<int64_t
>(-1));
705 pool = subnet->getPool(existing->type_, existing->addr_,
false);
710 "pool" :
"pd-pool", pool->getID(),
712 "assigned-nas" :
"assigned-pds")),
713 static_cast<int64_t
>(-1));
718 if (existing->stateDeclined()) {
724 "declined-addresses"),
725 static_cast<int64_t
>(-1));
731 "declined-addresses")),
732 static_cast<int64_t
>(-1));
738 if (!lease->stateExpiredReclaimed()) {
740 if (existing->subnet_id_ != lease->subnet_id_) {
744 "assigned-nas" :
"assigned-pds"),
745 static_cast<int64_t
>(1));
749 pool = subnet->getPool(lease->type_, lease->addr_,
false);
754 "pool" :
"pd-pool", pool->getID(),
756 "assigned-nas" :
"assigned-pds")),
757 static_cast<int64_t
>(1));
762 if (lease->stateDeclined()) {
768 "declined-addresses"),
769 static_cast<int64_t
>(1));
775 "declined-addresses")),
776 static_cast<int64_t
>(1));
782 if (!lease->stateExpiredReclaimed()) {
787 "assigned-nas" :
"assigned-pds"),
788 static_cast<int64_t
>(1));
793 pool = subnet->getPool(lease->type_, lease->addr_,
false);
798 "pool" :
"pd-pool", pool->getID(),
800 "assigned-nas" :
"assigned-pds")),
801 static_cast<int64_t
>(1));
805 if (lease->stateDeclined()) {
811 "declined-addresses"),
812 static_cast<int64_t
>(1));
818 "declined-addresses")),
819 static_cast<int64_t
>(1));
828 if (!lease->stateExpiredReclaimed()) {
831 "assigned-addresses"),
832 static_cast<int64_t
>(-1));
842 "assigned-addresses")),
843 static_cast<int64_t
>(-1));
847 if (lease->stateDeclined()) {
852 "declined-addresses"),
853 static_cast<int64_t
>(-1));
859 "declined-addresses")),
860 static_cast<int64_t
>(-1));
868 if (!lease->stateExpiredReclaimed()) {
872 "assigned-nas" :
"assigned-pds"),
873 static_cast<int64_t
>(-1));
878 pool = subnet->getPool(lease->type_, lease->addr_,
false);
883 "pool" :
"pd-pool", pool->getID(),
885 "assigned-nas" :
"assigned-pds")),
886 static_cast<int64_t
>(-1));
890 if (lease->stateDeclined()) {
895 "declined-addresses"),
896 static_cast<int64_t
>(-1));
902 "declined-addresses")),
903 static_cast<int64_t
>(-1));
912 if (force_create && !existing) {
916 "lost race between calls to get and add");
931 << lease->addr_ <<
" either because the lease has been "
932 "deleted or it has changed in the database, in both cases a "
933 "retry might succeed");
944 if (force_create && !existing) {
948 "lost race between calls to get and add");
962 if ((!old_extended_info && !extended_info) ||
963 (old_extended_info && extended_info &&
964 (*old_extended_info == *extended_info))) {
974 << lease->addr_ <<
" either because the lease has been "
975 "deleted or it has changed in the database, in both cases a "
976 "retry might succeed");
989 string lease_address =
"unknown";
1000 bool force_create =
false;
1007 lease_address = lease4->addr_.toText();
1015 if (resource_handler.
tryLock4(lease4->addr_)) {
1019 "ResourceBusy: IP address:" << lease4->addr_
1020 <<
" could not be added.");
1029 resp <<
"Lease for address " << lease4->addr_.toText()
1030 <<
", subnet-id " << lease4->subnet_id_ <<
" added.";
1036 lease_address = lease6->addr_.toText();
1044 if (resource_handler.
tryLock(lease6->type_, lease6->addr_)) {
1048 "ResourceBusy: IP address:" << lease6->addr_
1049 <<
" could not be added.");
1059 resp <<
"Lease for address " << lease6->addr_.toText()
1060 <<
", subnet-id " << lease6->subnet_id_ <<
" added.";
1062 resp <<
"Lease for prefix " << lease6->addr_.toText()
1063 <<
"/" <<
static_cast<int>(lease6->prefixlen_)
1064 <<
", subnet-id " << lease6->subnet_id_ <<
" added.";
1075 }
catch (
const std::exception& ex) {
1085 .arg(lease_address);
1098 if (params->contains(
"update-ddns")) {
1111 if (params->contains(
"type")) {
1112 string t = params->get(
"type")->stringValue();
1113 if (t ==
"IA_NA" || t ==
"0") {
1115 }
else if (t ==
"IA_TA" || t ==
"1") {
1117 }
else if (t ==
"IA_PD" || t ==
"2") {
1119 }
else if (t ==
"V4" || t ==
"3") {
1123 << t <<
", only supported values are: IA_NA, IA_TA,"
1124 <<
" IA_PD and V4");
1138 txt <<
"Invalid " << (v6 ?
"IPv6" :
"IPv4")
1139 <<
" address specified: " << tmp->stringValue();
1147 tmp = params->get(
"subnet-id");
1156 if (params->contains(
"iaid")) {
1157 x.
iaid = params->get(
"iaid")->intValue();
1168 " and 'identifier-type' is either missing or not a string.");
1172 " and 'identifier' is either missing or not a string.");
1201 " is not supported.");
1232 "requires hwaddr to be specified");
1245 "requires duid to be specified");
1259 "requires client-id to be specified");
1273 }
catch (
const std::exception& ex) {
1283 lease_json = lease4->toElement();
1285 "IPv4 lease found.", lease_json);
1287 }
else if (!v4 && lease6) {
1288 lease_json = lease6->toElement();
1290 "IPv6 lease found.", lease_json);
1320 const std::vector<ElementPtr>& subnet_ids = subnets->listValue();
1321 for (
auto const& subnet_id : subnet_ids) {
1329 for (
auto const& lease : leases) {
1331 leases_json->add(lease_json);
1336 for (
auto const& lease : leases) {
1338 leases_json->add(lease_json);
1347 for (
auto const& lease : leases) {
1349 leases_json->add(lease_json);
1353 for (
auto const& lease : leases) {
1355 leases_json->add(lease_json);
1360 std::ostringstream s;
1361 s << leases_json->size()
1362 <<
" IPv" << (v4 ?
"4" :
"6")
1363 <<
" lease(s) found.";
1365 args->set(
"leases", leases_json);
1373 }
catch (
const std::exception& ex) {
1407 boost::scoped_ptr<IOAddress> from_address;
1409 if (from->stringValue() ==
"start") {
1410 from_address.reset(
new IOAddress(v4 ?
"0.0.0.0" :
"::"));
1414 from_address.reset(
new IOAddress(from->stringValue()));
1419 "a valid IPv" << (v4 ?
"4" :
"6") <<
" address");
1424 if (v4 && (!from_address->isV4())) {
1426 <<
" is not an IPv4 address");
1428 }
else if (!v4 && from_address->isV4()) {
1430 <<
" is not an IPv6 address");
1445 size_t page_limit_value =
static_cast<size_t>(page_limit->intValue());
1456 for (
auto const& lease : leases) {
1458 leases_json->add(lease_json);
1467 for (
auto const& lease : leases) {
1469 leases_json->add(lease_json);
1474 std::ostringstream s;
1475 s << leases_json->size()
1476 <<
" IPv" << (v4 ?
"4" :
"6")
1477 <<
" lease(s) found.";
1481 args->set(
"leases", leases_json);
1482 args->set(
"count",
Element::create(
static_cast<int64_t
>(leases_json->size())));
1492 }
catch (
const std::exception& ex) {
1526 for (
auto const& lease : leases) {
1528 leases_json->add(lease_json);
1531 std::ostringstream s;
1532 s << leases_json->size() <<
" IPv4 lease(s) found.";
1534 args->set(
"leases", leases_json);
1542 }
catch (
const std::exception& ex) {
1576 for (
auto const& lease : leases) {
1578 leases_json->add(lease_json);
1581 std::ostringstream s;
1582 s << leases_json->size() <<
" IPv4 lease(s) found.";
1584 args->set(
"leases", leases_json);
1592 }
catch (
const std::exception& ex) {
1626 for (
auto const& lease : leases) {
1628 leases_json->add(lease_json);
1631 std::ostringstream s;
1632 s << leases_json->size() <<
" IPv6 lease(s) found.";
1634 args->set(
"leases", leases_json);
1642 }
catch (
const std::exception& ex) {
1655 v4 = (
cmd_name_ ==
"lease4-get-by-hostname");
1673 std::string hostname_ = hostname->stringValue();
1675 if (hostname_.empty()) {
1678 boost::algorithm::to_lower(hostname_);
1685 for (
auto const& lease : leases) {
1687 leases_json->add(lease_json);
1693 for (
auto const& lease : leases) {
1695 leases_json->add(lease_json);
1699 std::ostringstream s;
1700 s << leases_json->size()
1701 <<
" IPv" << (v4 ?
"4" :
"6")
1702 <<
" lease(s) found.";
1704 args->set(
"leases", leases_json);
1712 }
catch (
const std::exception& ex) {
1740 "requires hwaddr to be specified");
1754 "requires client-id to be specified");
1787 }
catch (
const std::exception& ex) {
1795 .arg(lease4->addr_.toText());
1810 auto deleted_leases =
cmd_args_->get(
"deleted-leases");
1813 if (!deleted_leases && !leases) {
1819 if (deleted_leases && (deleted_leases->getType() !=
Element::list)) {
1831 std::list<std::pair<Parameters, Lease6Ptr> > parsed_deleted_list;
1832 if (deleted_leases) {
1833 auto leases_list = deleted_leases->listValue();
1836 for (
auto const& lease_params : leases_list) {
1841 parsed_deleted_list.push_back(std::make_pair(p, lease));
1847 std::list<Lease6Ptr> parsed_leases_list;
1852 auto leases_list = leases->listValue();
1853 for (
auto const& lease_params : leases_list) {
1860 Lease6Ptr lease6 = parser.
parse(config, lease_params, force_update);
1861 parsed_leases_list.push_back(lease6);
1866 size_t success_count = 0;
1869 if (!parsed_deleted_list.empty()) {
1872 for (
auto const& lease_params_pair : parsed_deleted_list) {
1877 auto lease = lease_params_pair.second;
1890 if (!failed_deleted_list) {
1901 "lease not found"));
1905 }
catch (
const std::exception& ex) {
1907 if (!failed_deleted_list) {
1920 if (!parsed_leases_list.empty()) {
1924 for (
auto const& lease : parsed_leases_list) {
1927 std::ostringstream text;
1935 if (resource_handler.
tryLock(lease->type_, lease->addr_)) {
1939 "ResourceBusy: IP address:" << lease->addr_
1940 <<
" could not be updated.");
1949 }
catch (
const std::exception& ex) {
1956 if (!failed_leases_list) {
1971 if (failed_deleted_list || failed_leases_list) {
1976 if (failed_deleted_list) {
1977 args->set(
"failed-deleted-leases", failed_deleted_list);
1981 if (failed_leases_list) {
1982 args->set(
"failed-leases", failed_leases_list);
1987 std::ostringstream resp_text;
1988 resp_text <<
"Bulk apply of " << success_count <<
" IPv6 leases completed.";
1995 .arg(success_count);
1997 }
catch (
const std::exception& ex) {
2037 "requires duid to be specified");
2067 }
catch (
const std::exception& ex) {
2076 .arg(lease6->addr_.toText());
2094 bool force_create =
false;
2106 if (resource_handler.
tryLock4(lease4->addr_)) {
2110 "ResourceBusy: IP address:" << lease4->addr_
2111 <<
" could not be updated.");
2122 .arg(lease4->addr_.toText());
2131 }
catch (
const std::exception& ex) {
2156 bool force_create =
false;
2168 if (resource_handler.
tryLock(lease6->type_, lease6->addr_)) {
2172 "ResourceBusy: IP address:" << lease6->addr_
2173 <<
" could not be updated.");
2184 .arg(lease6->addr_.toText());
2193 }
catch (
const std::exception& ex) {
2228 int64_t previous_declined = 0;
2231 previous_declined = observation->getInteger().first;
2236 static_cast<int64_t
>(0));
2240 static_cast<int64_t
>(0));
2247 "assigned-addresses")));
2254 "declined-addresses")));
2269 for (
auto const& sub : *subs) {
2271 ids <<
" " << sub->getID();
2274 static_cast<int64_t
>(0));
2278 static_cast<int64_t
>(0));
2283 "assigned-addresses")));
2290 "declined-addresses")));
2301 tmp <<
"Deleted " << num <<
" IPv4 lease(s) from subnet(s)" << ids.str()
2302 <<
" WARNING: lease4-wipe is deprecated!";
2306 }
catch (
const std::exception& ex) {
2350 int64_t previous_declined = 0;
2353 previous_declined = observation->getInteger().first;
2358 static_cast<int64_t
>(0));
2362 static_cast<int64_t
>(0));
2366 static_cast<int64_t
>(0));
2380 "declined-addresses")));
2404 for (
auto const& sub : *subs) {
2406 ids <<
" " << sub->getID();
2409 static_cast<int64_t
>(0));
2413 static_cast<int64_t
>(0));
2417 static_cast<int64_t
>(0));
2429 "declined-addresses")));
2449 tmp <<
"Deleted " << num <<
" IPv6 lease(s) from subnet(s)" << ids.str()
2450 <<
" WARNING: lease6-wipe is deprecated!";
2454 }
catch (
const std::exception& ex) {
2481 lease6.reset(
new Lease6());
2482 lease6->addr_ = parameters.
addr;
2491 if (!parameters.
duid) {
2493 "requires duid to be specified");
2513 short family)
const {
2526 }
catch (
const std::exception& ex) {
2528 <<
"' is not a valid IP address.");
2533 << (family == AF_INET6 ?
"IPv6" :
"IPv4")
2534 <<
" address specified: " << param->stringValue());
2542 std::stringstream ss;
2552 ss <<
"DDNS updating is not enabled";
2558 ss <<
"No lease found for: " << addr.
toText();
2560 }
else if (lease->hostname_.empty()) {
2561 ss <<
"Lease for: " << addr.
toText()
2562 <<
", has no hostname, nothing to update";
2564 }
else if (!lease->fqdn_fwd_ && !lease->fqdn_rev_) {
2565 ss <<
"Neither forward nor reverse updates enabled for lease for: "
2572 ss <<
"NCR generated for: " << addr.
toText()
2573 <<
", hostname: " << lease->hostname_;
2579 }
catch (
const std::exception& ex) {
2590 std::stringstream ss;
2600 ss <<
"DDNS updating is not enabled";
2606 ss <<
"No lease found for: " << addr.
toText();
2608 }
else if (lease->hostname_.empty()) {
2609 ss <<
"Lease for: " << addr.
toText()
2610 <<
", has no hostname, nothing to update";
2612 }
else if (!lease->fqdn_fwd_ && !lease->fqdn_rev_) {
2613 ss <<
"Neither forward nor reverse updates enabled for lease for: "
2620 ss <<
"NCR generated for: " << addr.
toText()
2621 <<
", hostname: " << lease->hostname_;
2627 }
catch (
const std::exception& ex) {
2640 const int control_result,
2641 const std::string& error_message)
const {
2654 failed_lease_map->set(
"error-message",
Element::create(error_message));
2656 return (failed_lease_map);
2677 string filename = file->stringValue();
2678 if (filename.empty()) {
2688 s << (v4 ?
"IPv4" :
"IPv6")
2689 <<
" lease database into '"
2690 << filename <<
"'.";
2693 }
catch (
const std::exception& ex) {
2703 return (impl_->leaseAddHandler(handle));
2708 return (impl_->lease6BulkApplyHandler(handle));
2713 return (impl_->leaseGetHandler(handle));
2718 return (impl_->leaseGetAllHandler(handle));
2723 return (impl_->leaseGetPageHandler(handle));
2728 return (impl_->leaseGetByHwAddressHandler(handle));
2733 return (impl_->leaseGetByClientIdHandler(handle));
2738 return (impl_->leaseGetByDuidHandler(handle));
2743 return (impl_->leaseGetByHostnameHandler(handle));
2748 return (impl_->lease4DelHandler(handle));
2753 return (impl_->lease6DelHandler(handle));
2758 return (impl_->lease4UpdateHandler(handle));
2763 return (impl_->lease6UpdateHandler(handle));
2769 return (impl_->lease4WipeHandler(handle));
2775 return (impl_->lease6WipeHandler(handle));
2780 return (impl_->lease4ResendDdnsHandler(handle));
2785 return (impl_->lease6ResendDdnsHandler(handle));
2790 return (impl_->leaseWriteHandler(handle));
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...
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.
static ElementPtr create(const Position &pos=ZERO_POSITION())
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.
uint32_t getUint32(isc::data::ConstElementPtr scope, const std::string &name)
Returns a value converted to uint32_t.
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 DUID fromText(const std::string &text)
Create DUID from the textual format.
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.
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.
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.
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.
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 updateStatsOnUpdate(const Lease4Ptr &existing, const Lease4Ptr &lease)
Update stats when updating lease.
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.
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 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.
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
static void updateStatsOnAdd(const Lease4Ptr &lease)
Update stats when adding lease.
Parameters getParameters(bool v6, const ConstElementPtr &args)
Extracts parameters required for reservation-get and reservation-del.
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
static void updateStatsOnDelete(const Lease4Ptr &lease)
Update stats when deleting lease.
int lease4ResendDdnsHandler(hooks::CalloutHandle &handle)
lease4-resend-ddns command 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
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
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 command handler
int lease6UpdateHandler(hooks::CalloutHandle &handle)
lease6-update 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.
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_WIPE4_DEPRECATED
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_WIPE6_DEPRECATED
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_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< 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< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 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::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
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.
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")
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
Type
Type of lease or pool.
@ TYPE_TA
the lease contains temporary IPv6 address
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
@ TYPE_NA
the lease contains non-temporary IPv6 address
static void syncCurrentExpirationTime(const Lease &from, Lease &to)
Sync lease current expiration time with new value from another lease, so that additional operations c...
static std::string typeToText(Type type)
returns text representation of a lease type