const ClientIdPtr& clientid,
const HWAddrPtr& hwaddr,
const IOAddress& hint,
+ const bool fwd_dns_update,
+ const bool rev_dns_update,
+ const std::string& hostname,
bool fake_allocation,
const isc::hooks::CalloutHandlePtr& callout_handle,
Lease4Ptr& old_lease) {
old_lease.reset(new Lease4(*existing));
// We have a lease already. This is a returning client, probably after
// its reboot.
- existing = renewLease4(subnet, clientid, hwaddr, existing, fake_allocation);
+ existing = renewLease4(subnet, clientid, hwaddr,
+ fwd_dns_update, rev_dns_update, hostname,
+ existing, fake_allocation);
if (existing) {
return (existing);
}
old_lease.reset(new Lease4(*existing));
// we have a lease already. This is a returning client, probably after
// its reboot.
- existing = renewLease4(subnet, clientid, hwaddr, existing, fake_allocation);
+ existing = renewLease4(subnet, clientid, hwaddr,
+ fwd_dns_update, rev_dns_update,
+ hostname, existing, fake_allocation);
// @todo: produce a warning. We haven't found him using MAC address, but
// we found him using client-id
if (existing) {
// The hint is valid and not currently used, let's create a lease for it
Lease4Ptr lease = createLease4(subnet, clientid, hwaddr, hint,
- callout_handle, fake_allocation);
+ fwd_dns_update, rev_dns_update,
+ hostname, callout_handle,
+ fake_allocation);
// It can happen that the lease allocation failed (we could have lost
// the race condition. That means that the hint is lo longer usable and
// Save the old lease, before reusing it.
old_lease.reset(new Lease4(*existing));
return (reuseExpiredLease(existing, subnet, clientid, hwaddr,
- callout_handle, fake_allocation));
+ fwd_dns_update, rev_dns_update,
+ hostname, callout_handle,
+ fake_allocation));
}
}
if (!existing) {
// there's no existing lease for selected candidate, so it is
// free. Let's allocate it.
- Lease4Ptr lease = createLease4(subnet, clientid, hwaddr, candidate,
+ Lease4Ptr lease = createLease4(subnet, clientid, hwaddr,
+ candidate, fwd_dns_update,
+ rev_dns_update, hostname,
callout_handle, fake_allocation);
if (lease) {
return (lease);
// Save old lease before reusing it.
old_lease.reset(new Lease4(*existing));
return (reuseExpiredLease(existing, subnet, clientid, hwaddr,
- callout_handle, fake_allocation));
+ fwd_dns_update, rev_dns_update,
+ hostname, callout_handle,
+ fake_allocation));
}
}
Lease4Ptr AllocEngine::renewLease4(const SubnetPtr& subnet,
const ClientIdPtr& clientid,
const HWAddrPtr& hwaddr,
+ const bool fwd_dns_update,
+ const bool rev_dns_update,
+ const std::string& hostname,
const Lease4Ptr& lease,
bool fake_allocation /* = false */) {
lease->t1_ = subnet->getT1();
lease->t2_ = subnet->getT2();
lease->valid_lft_ = subnet->getValid();
+ lease->fqdn_fwd_ = fwd_dns_update;
+ lease->fqdn_rev_ = rev_dns_update;
+ lease->hostname_ = hostname;
if (!fake_allocation) {
// for REQUEST we do update the lease
const SubnetPtr& subnet,
const ClientIdPtr& clientid,
const HWAddrPtr& hwaddr,
+ const bool fwd_dns_update,
+ const bool rev_dns_update,
+ const std::string& hostname,
const isc::hooks::CalloutHandlePtr& callout_handle,
bool fake_allocation /*= false */ ) {
expired->cltt_ = time(NULL);
expired->subnet_id_ = subnet->getID();
expired->fixed_ = false;
- expired->hostname_ = std::string("");
- expired->fqdn_fwd_ = false;
- expired->fqdn_rev_ = false;
+ expired->hostname_ = hostname;
+ expired->fqdn_fwd_ = fwd_dns_update;
+ expired->fqdn_rev_ = rev_dns_update;
/// @todo: log here that the lease was reused (there's ticket #2524 for
/// logging in libdhcpsrv)
const DuidPtr& clientid,
const HWAddrPtr& hwaddr,
const IOAddress& addr,
+ const bool fwd_dns_update,
+ const bool rev_dns_update,
+ const std::string& hostname,
const isc::hooks::CalloutHandlePtr& callout_handle,
bool fake_allocation /*= false */ ) {
if (!hwaddr) {
subnet->getT1(), subnet->getT2(), now,
subnet->getID()));
+ // Set FQDN specific lease parameters.
+ lease->fqdn_fwd_ = fwd_dns_update;
+ lease->fqdn_rev_ = rev_dns_update;
+ lease->hostname_ = hostname;
+
// Let's execute all callouts registered for lease4_select
if (callout_handle &&
HooksManager::getHooksManager().calloutsPresent(hook_index_lease4_select_)) {
///
/// @param subnet subnet the allocation should come from
/// @param clientid Client identifier
- /// @param hwaddr client's hardware address info
- /// @param hint a hint that the client provided
- /// @param fake_allocation is this real i.e. REQUEST (false) or just picking
+ /// @param hwaddr Client's hardware address info
+ /// @param hint A hint that the client provided
+ /// @param fwd_dns_update Indicates whether forward DNS update will be
+ /// performed for the client (true) or not (false).
+ /// @param rev_dns_update Indicates whether reverse DNS update will be
+ /// performed for the client (true) or not (false).
+ /// @param hostname A string carrying hostname to be used for DNS updates.
+ /// @param fake_allocation Is this real i.e. REQUEST (false) or just picking
/// an address for DISCOVER that is not really allocated (true)
- /// @param callout_handle a callout handle (used in hooks). A lease callouts
+ /// @param callout_handle A callout handle (used in hooks). A lease callouts
/// will be executed if this parameter is passed.
/// @param [out] old_lease Holds the pointer to a previous instance of a
/// lease. The NULL pointer indicates that lease didn't exist prior
const ClientIdPtr& clientid,
const HWAddrPtr& hwaddr,
const isc::asiolink::IOAddress& hint,
+ const bool fwd_dns_update,
+ const bool rev_dns_update,
+ const std::string& hostname,
bool fake_allocation,
const isc::hooks::CalloutHandlePtr& callout_handle,
Lease4Ptr& old_lease);
/// to get a new lease. It thinks that it gets a new lease, but in fact
/// we are only renewing the still valid lease for that client.
///
- /// @param subnet subnet the client is attached to
- /// @param clientid client identifier
- /// @param hwaddr client's hardware address
- /// @param lease lease to be renewed
- /// @param fake_allocation is this real i.e. REQUEST (false) or just picking
+ /// @param subnet A subnet the client is attached to
+ /// @param clientid Client identifier
+ /// @param hwaddr Client's hardware address
+ /// @param fwd_dns_update Indicates whether forward DNS update will be
+ /// performed for the client (true) or not (false).
+ /// @param rev_dns_update Indicates whether reverse DNS update will be
+ /// performed for the client (true) or not (false).
+ /// @param hostname A string carrying hostname to be used for DNS updates.
+ /// @param lease A lease to be renewed
+ /// @param fake_allocation Is this real i.e. REQUEST (false) or just picking
/// an address for DISCOVER that is not really allocated (true)
Lease4Ptr
renewLease4(const SubnetPtr& subnet,
const ClientIdPtr& clientid,
const HWAddrPtr& hwaddr,
+ const bool fwd_dns_update,
+ const bool rev_dns_update,
+ const std::string& hostname,
const Lease4Ptr& lease,
bool fake_allocation /* = false */);
/// into the database. That may fail in some cases, e.g. when there is another
/// allocation process and we lost a race to a specific lease.
///
- /// @param subnet subnet the lease is allocated from
- /// @param clientid client identifier
- /// @param hwaddr client's hardware address
- /// @param addr an address that was selected and is confirmed to be available
+ /// @param subnet Subnet the lease is allocated from
+ /// @param clientid Client identifier
+ /// @param hwaddr Client's hardware address
+ /// @param addr An address that was selected and is confirmed to be available
+ /// @param fwd_dns_update Indicates whether forward DNS update will be
+ /// performed for the client (true) or not (false).
+ /// @param rev_dns_update Indicates whether reverse DNS update will be
+ /// performed for the client (true) or not (false).
+ /// @param hostname A string carrying hostname to be used for DNS updates.
/// @param callout_handle a callout handle (used in hooks). A lease callouts
/// will be executed if this parameter is passed (and there are callouts
/// registered)
- /// @param fake_allocation is this real i.e. REQUEST (false) or just picking
+ /// @param fake_allocation Is this real i.e. REQUEST (false) or just picking
/// an address for DISCOVER that is not really allocated (true)
/// @return allocated lease (or NULL in the unlikely case of the lease just
/// becomed unavailable)
Lease4Ptr createLease4(const SubnetPtr& subnet, const DuidPtr& clientid,
const HWAddrPtr& hwaddr,
const isc::asiolink::IOAddress& addr,
+ const bool fwd_dns_update,
+ const bool rev_dns_update,
+ const std::string& hostname,
const isc::hooks::CalloutHandlePtr& callout_handle,
bool fake_allocation = false);
/// is updated if this is real (i.e. REQUEST, fake_allocation = false), not
/// dummy allocation request (i.e. DISCOVER, fake_allocation = true).
///
- /// @param expired old, expired lease
- /// @param subnet subnet the lease is allocated from
- /// @param clientid client identifier
- /// @param hwaddr client's hardware address
- /// @param callout_handle a callout handle (used in hooks). A lease callouts
+ /// @param expired Old, expired lease
+ /// @param subnet Subnet the lease is allocated from
+ /// @param clientid Client identifier
+ /// @param hwaddr Client's hardware address
+ /// @param fwd_dns_update Indicates whether forward DNS update will be
+ /// performed for the client (true) or not (false).
+ /// @param rev_dns_update Indicates whether reverse DNS update will be
+ /// performed for the client (true) or not (false).
+ /// @param hostname A string carrying hostname to be used for DNS updates.
+ /// @param callout_handle A callout handle (used in hooks). A lease callouts
/// will be executed if this parameter is passed.
- /// @param fake_allocation is this real i.e. REQUEST (false) or just picking
+ /// @param fake_allocation Is this real i.e. REQUEST (false) or just picking
/// an address for DISCOVER that is not really allocated (true)
/// @return refreshed lease
/// @throw BadValue if trying to recycle lease that is still valid
const SubnetPtr& subnet,
const ClientIdPtr& clientid,
const HWAddrPtr& hwaddr,
+ const bool fwd_dns_update,
+ const bool rev_dns_update,
+ const std::string& hostname,
const isc::hooks::CalloutHandlePtr& callout_handle,
bool fake_allocation = false);
ASSERT_TRUE(engine);
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
- IOAddress("0.0.0.0"), false,
- CalloutHandlePtr(),
+ IOAddress("0.0.0.0"),
+ false, false, "",
+ false, CalloutHandlePtr(),
old_lease_);
// The new lease has been allocated, so the old lease should not exist.
EXPECT_FALSE(old_lease_);
ASSERT_TRUE(engine);
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
- IOAddress("0.0.0.0"), true,
- CalloutHandlePtr(),
+ IOAddress("0.0.0.0"),
+ false, false, "",
+ true, CalloutHandlePtr(),
old_lease_);
// The new lease has been allocated, so the old lease should not exist.
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
IOAddress("192.0.2.105"),
+ false, false, "",
false, CalloutHandlePtr(),
old_lease_);
// Check that we got a lease
// twice.
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
IOAddress("192.0.2.106"),
+ false, false, "",
false, CalloutHandlePtr(),
old_lease_);
// with the normal allocation
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
IOAddress("10.1.1.1"),
+ false, false, "",
false, CalloutHandlePtr(),
old_lease_);
// Check that we got a lease
// Allocations without subnet are not allowed
Lease4Ptr lease = engine->allocateAddress4(SubnetPtr(), clientid_, hwaddr_,
- IOAddress("0.0.0.0"), false,
- CalloutHandlePtr(), old_lease_);
+ IOAddress("0.0.0.0"),
+ false, false, "",
+ false, CalloutHandlePtr(),
+ old_lease_);
EXPECT_FALSE(lease);
// Allocations without HW address are not allowed
lease = engine->allocateAddress4(subnet_, clientid_, HWAddrPtr(),
- IOAddress("0.0.0.0"), false,
- CalloutHandlePtr(),
+ IOAddress("0.0.0.0"),
+ false, false, "",
+ false, CalloutHandlePtr(),
old_lease_);
EXPECT_FALSE(lease);
EXPECT_FALSE(old_lease_);
// Allocations without client-id are allowed
clientid_ = ClientIdPtr();
lease = engine->allocateAddress4(subnet_, ClientIdPtr(), hwaddr_,
- IOAddress("0.0.0.0"), false,
- CalloutHandlePtr(),
+ IOAddress("0.0.0.0"),
+ false, false, "",
+ false, CalloutHandlePtr(),
old_lease_);
// Check that we got a lease
ASSERT_TRUE(lease);
subnet_->addPool(pool_);
cfg_mgr.addSubnet4(subnet_);
- Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"),
+ Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ IOAddress("0.0.0.0"),
+ false, false, "",
false, CalloutHandlePtr(),
old_lease_);
uint8_t hwaddr2[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
uint8_t clientid2[] = { 8, 7, 6, 5, 4, 3, 2, 1 };
time_t now = time(NULL);
- Lease4Ptr lease(new Lease4(addr, hwaddr2, sizeof(hwaddr2), clientid2, sizeof(clientid2),
- 501, 502, 503, now, subnet_->getID()));
+ Lease4Ptr lease(new Lease4(addr, hwaddr2, sizeof(hwaddr2), clientid2,
+ sizeof(clientid2), 501, 502, 503, now,
+ subnet_->getID()));
lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// else, so the allocation should fail
Lease4Ptr lease2 = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
- IOAddress("0.0.0.0"), false,
- CalloutHandlePtr(),
+ IOAddress("0.0.0.0"),
+ false, false, "",
+ false, CalloutHandlePtr(),
old_lease_);
EXPECT_FALSE(lease2);
EXPECT_FALSE(old_lease_);
// CASE 1: Asking for any address
lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
IOAddress("0.0.0.0"),
+ false, false, "",
true, CalloutHandlePtr(),
old_lease_);
// Check that we got that single lease
checkLease4(lease);
// CASE 2: Asking specifically for this address
- lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_, IOAddress(addr.toText()),
+ lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ IOAddress(addr.toText()),
+ false, false, "",
true, CalloutHandlePtr(),
old_lease_);
// Check that we got that single lease
// A client comes along, asking specifically for this address
lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
- IOAddress(addr.toText()), false,
- CalloutHandlePtr(),
+ IOAddress(addr.toText()),
+ false, false, "",
+ false, CalloutHandlePtr(),
old_lease_);
// Check that he got that single lease
// Lease was assigned 45 seconds ago and is valid for 100 seconds. Let's
// renew it.
ASSERT_FALSE(lease->expired());
- lease = engine->renewLease4(subnet_, clientid_, hwaddr_, lease, false);
+ lease = engine->renewLease4(subnet_, clientid_, hwaddr_, false,
+ false, "", lease, false);
// Check that he got that single lease
ASSERT_TRUE(lease);
EXPECT_EQ(addr.toText(), lease->addr_.toText());
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
IOAddress("0.0.0.0"),
+ false, false, "",
false, callout_handle,
old_lease_);
// Check that we got a lease
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
// Call allocateAddress4. Callouts should be triggered here.
- Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"),
+ Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ IOAddress("0.0.0.0"),
+ false, false, "",
false, callout_handle,
old_lease_);
// Check that we got a lease