Commit 79b7d8ee authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[master] Merge branch 'trac3084'

parents e66020fd 73fa8158
......@@ -36,7 +36,10 @@ CREATE TABLE lease4 (
client_id VARBINARY(128), # Client ID
valid_lifetime INT UNSIGNED, # Length of the lease (seconds)
expire TIMESTAMP, # Expiration time of the lease
subnet_id INT UNSIGNED # Subnet identification
subnet_id INT UNSIGNED, # Subnet identification
fqdn_fwd BOOL, # Has forward DNS update been performed by a server
fqdn_rev BOOL, # Has reverse DNS update been performed by a server
hostname VARCHAR(255) # The FQDN of the client
) ENGINE = INNODB;
......@@ -60,7 +63,11 @@ CREATE TABLE lease6 (
lease_type TINYINT, # Lease type (see lease6_types
# table for possible values)
iaid INT UNSIGNED, # See Section 10 of RFC 3315
prefix_len TINYINT UNSIGNED # For IA_PD only
prefix_len TINYINT UNSIGNED, # For IA_PD only
fqdn_fwd BOOL, # Has forward DNS update been performed by a server
fqdn_rev BOOL, # Has reverse DNS update been performed by a server
hostname VARCHAR(255) # The FQDN of the client
) ENGINE = INNODB;
# Create search indexes for lease4 table
......
......@@ -33,20 +33,21 @@ namespace isc {
namespace dhcp {
Lease::Lease(const isc::asiolink::IOAddress& addr, uint32_t t1, uint32_t t2,
uint32_t valid_lft, SubnetID subnet_id, time_t cltt)
uint32_t valid_lft, SubnetID subnet_id, time_t cltt,
const bool fqdn_fwd, const bool fqdn_rev,
const std::string& hostname)
:addr_(addr), t1_(t1), t2_(t2), valid_lft_(valid_lft), cltt_(cltt),
subnet_id_(subnet_id), fixed_(false), fqdn_fwd_(false), fqdn_rev_(false) {
subnet_id_(subnet_id), fixed_(false), hostname_(hostname),
fqdn_fwd_(fqdn_fwd), fqdn_rev_(fqdn_rev) {
}
Lease4::Lease4(const Lease4& other)
: Lease(other.addr_, other.t1_, other.t2_, other.valid_lft_,
other.subnet_id_, other.cltt_), ext_(other.ext_),
other.subnet_id_, other.cltt_, other.fqdn_fwd_,
other.fqdn_rev_, other.hostname_), ext_(other.ext_),
hwaddr_(other.hwaddr_) {
fixed_ = other.fixed_;
fqdn_fwd_ = other.fqdn_fwd_;
fqdn_rev_ = other.fqdn_rev_;
hostname_ = other.hostname_;
comments_ = other.comments_;
if (other.client_id_) {
......@@ -87,7 +88,23 @@ Lease4::operator=(const Lease4& other) {
Lease6::Lease6(LeaseType type, const isc::asiolink::IOAddress& addr,
DuidPtr duid, uint32_t iaid, uint32_t preferred, uint32_t valid,
uint32_t t1, uint32_t t2, SubnetID subnet_id, uint8_t prefixlen)
: Lease(addr, t1, t2, valid, subnet_id, 0/*cltt*/),
: Lease(addr, t1, t2, valid, subnet_id, 0/*cltt*/, false, false, ""),
type_(type), prefixlen_(prefixlen), iaid_(iaid), duid_(duid),
preferred_lft_(preferred) {
if (!duid) {
isc_throw(InvalidOperation, "DUID must be specified for a lease");
}
cltt_ = time(NULL);
}
Lease6::Lease6(LeaseType type, const isc::asiolink::IOAddress& addr,
DuidPtr duid, uint32_t iaid, uint32_t preferred, uint32_t valid,
uint32_t t1, uint32_t t2, SubnetID subnet_id,
const bool fqdn_fwd, const bool fqdn_rev,
const std::string& hostname, uint8_t prefixlen)
: Lease(addr, t1, t2, valid, subnet_id, 0/*cltt*/,
fqdn_fwd, fqdn_rev, hostname),
type_(type), prefixlen_(prefixlen), iaid_(iaid), duid_(duid),
preferred_lft_(preferred) {
if (!duid) {
......
......@@ -122,8 +122,13 @@ struct Lease {
/// @param valid_lft Lifetime of the lease
/// @param subnet_id Subnet identification
/// @param cltt Client last transmission time
/// @param fqdn_fwd If true, forward DNS update is performed for a lease.
/// @param fqdn_rev If true, reverse DNS update is performed for a lease.
/// @param hostname FQDN of the client which gets the lease.
Lease(const isc::asiolink::IOAddress& addr, uint32_t t1, uint32_t t2,
uint32_t valid_lft, SubnetID subnet_id, time_t cltt);
uint32_t valid_lft, SubnetID subnet_id, time_t cltt,
const bool fqdn_fwd, const bool fqdn_rev,
const std::string& hostname);
/// @brief Destructor
virtual ~Lease() {}
......@@ -243,10 +248,16 @@ struct Lease4 : public Lease {
/// @param t2 rebinding time
/// @param cltt Client last transmission time
/// @param subnet_id Subnet identification
/// @param fqdn_fwd If true, forward DNS update is performed for a lease.
/// @param fqdn_rev If true, reverse DNS update is performed for a lease.
/// @param hostname FQDN of the client which gets the lease.
Lease4(const isc::asiolink::IOAddress& addr, const uint8_t* hwaddr, size_t hwaddr_len,
const uint8_t* clientid, size_t clientid_len, uint32_t valid_lft,
uint32_t t1, uint32_t t2, time_t cltt, uint32_t subnet_id)
: Lease(addr, t1, t2, valid_lft, subnet_id, cltt),
uint32_t t1, uint32_t t2, time_t cltt, uint32_t subnet_id,
const bool fqdn_fwd = false, const bool fqdn_rev = false,
const std::string& hostname = "")
: Lease(addr, t1, t2, valid_lft, subnet_id, cltt, fqdn_fwd, fqdn_rev,
hostname),
ext_(0), hwaddr_(hwaddr, hwaddr + hwaddr_len) {
if (clientid_len) {
client_id_.reset(new ClientId(clientid, clientid_len));
......@@ -256,7 +267,7 @@ struct Lease4 : public Lease {
/// @brief Default constructor
///
/// Initialize fields that don't have a default constructor.
Lease4() : Lease(0, 0, 0, 0, 0, 0) {
Lease4() : Lease(0, 0, 0, 0, 0, 0, false, false, "") {
}
/// @brief Copy constructor
......@@ -341,14 +352,46 @@ struct Lease6 : public Lease {
/// @todo: Add DHCPv6 failover related fields here
/// @brief Constructor
/// @param type Lease type.
/// @param addr Assigned address.
/// @param duid A pointer to an object representing DUID.
/// @param iaid IAID.
/// @param preferred Preferred lifetime.
/// @param valid Valid lifetime.
/// @param t1 A value of the T1 timer.
/// @param t2 A value of the T2 timer.
/// @param subnet_id A Subnet identifier.
/// @param prefixlen An address prefix length.
Lease6(LeaseType type, const isc::asiolink::IOAddress& addr, DuidPtr duid,
uint32_t iaid, uint32_t preferred, uint32_t valid, uint32_t t1,
uint32_t t2, SubnetID subnet_id, uint8_t prefixlen_ = 0);
uint32_t t2, SubnetID subnet_id, uint8_t prefixlen = 0);
/// @brief Constructor, including FQDN data.
///
/// @param type Lease type.
/// @param addr Assigned address.
/// @param duid A pointer to an object representing DUID.
/// @param iaid IAID.
/// @param preferred Preferred lifetime.
/// @param valid Valid lifetime.
/// @param t1 A value of the T1 timer.
/// @param t2 A value of the T2 timer.
/// @param subnet_id A Subnet identifier.
/// @param fqdn_fwd If true, forward DNS update is performed for a lease.
/// @param fqdn_rev If true, reverse DNS update is performed for a lease.
/// @param hostname FQDN of the client which gets the lease.
/// @param prefixlen An address prefix length.
Lease6(LeaseType type, const isc::asiolink::IOAddress& addr, DuidPtr duid,
uint32_t iaid, uint32_t preferred, uint32_t valid, uint32_t t1,
uint32_t t2, SubnetID subnet_id, const bool fqdn_fwd,
const bool fqdn_rev, const std::string& hostname,
uint8_t prefixlen = 0);
/// @brief Constructor
///
/// Initialize fields that don't have a default constructor.
Lease6() : Lease(isc::asiolink::IOAddress("::"), 0, 0, 0, 0, 0),
Lease6() : Lease(isc::asiolink::IOAddress("::"), 0, 0, 0, 0, 0,
false, false, ""),
type_(LEASE_IA_NA) {
}
......
// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -104,6 +104,12 @@ const size_t ADDRESS6_TEXT_MAX_LEN = 39;
const my_bool MLM_FALSE = 0; ///< False value
const my_bool MLM_TRUE = 1; ///< True value
/// @brief Maximum length of the hostname stored in DNS.
///
/// This length is restricted by the length of the domain-name carried
/// in the Client FQDN %Option (see RFC4702 and RFC4704).
const size_t HOSTNAME_MAX_LEN = 255;
///@}
/// @brief MySQL Selection Statements
......@@ -123,68 +129,80 @@ TaggedStatement tagged_statements[] = {
"DELETE FROM lease6 WHERE address = ?"},
{MySqlLeaseMgr::GET_LEASE4_ADDR,
"SELECT address, hwaddr, client_id, "
"valid_lifetime, expire, subnet_id "
"valid_lifetime, expire, subnet_id, "
"fqdn_fwd, fqdn_rev, hostname "
"FROM lease4 "
"WHERE address = ?"},
{MySqlLeaseMgr::GET_LEASE4_CLIENTID,
"SELECT address, hwaddr, client_id, "
"valid_lifetime, expire, subnet_id "
"valid_lifetime, expire, subnet_id, "
"fqdn_fwd, fqdn_rev, hostname "
"FROM lease4 "
"WHERE client_id = ?"},
{MySqlLeaseMgr::GET_LEASE4_CLIENTID_SUBID,
"SELECT address, hwaddr, client_id, "
"valid_lifetime, expire, subnet_id "
"valid_lifetime, expire, subnet_id, "
"fqdn_fwd, fqdn_rev, hostname "
"FROM lease4 "
"WHERE client_id = ? AND subnet_id = ?"},
{MySqlLeaseMgr::GET_LEASE4_HWADDR,
"SELECT address, hwaddr, client_id, "
"valid_lifetime, expire, subnet_id "
"valid_lifetime, expire, subnet_id, "
"fqdn_fwd, fqdn_rev, hostname "
"FROM lease4 "
"WHERE hwaddr = ?"},
{MySqlLeaseMgr::GET_LEASE4_HWADDR_SUBID,
"SELECT address, hwaddr, client_id, "
"valid_lifetime, expire, subnet_id "
"valid_lifetime, expire, subnet_id, "
"fqdn_fwd, fqdn_rev, hostname "
"FROM lease4 "
"WHERE hwaddr = ? AND subnet_id = ?"},
{MySqlLeaseMgr::GET_LEASE6_ADDR,
"SELECT address, duid, valid_lifetime, "
"expire, subnet_id, pref_lifetime, "
"lease_type, iaid, prefix_len "
"lease_type, iaid, prefix_len, "
"fqdn_fwd, fqdn_rev, hostname "
"FROM lease6 "
"WHERE address = ?"},
{MySqlLeaseMgr::GET_LEASE6_DUID_IAID,
"SELECT address, duid, valid_lifetime, "
"expire, subnet_id, pref_lifetime, "
"lease_type, iaid, prefix_len "
"lease_type, iaid, prefix_len, "
"fqdn_fwd, fqdn_rev, hostname "
"FROM lease6 "
"WHERE duid = ? AND iaid = ?"},
{MySqlLeaseMgr::GET_LEASE6_DUID_IAID_SUBID,
"SELECT address, duid, valid_lifetime, "
"expire, subnet_id, pref_lifetime, "
"lease_type, iaid, prefix_len "
"lease_type, iaid, prefix_len, "
"fqdn_fwd, fqdn_rev, hostname "
"FROM lease6 "
"WHERE duid = ? AND iaid = ? AND subnet_id = ?"},
{MySqlLeaseMgr::GET_VERSION,
"SELECT version, minor FROM schema_version"},
{MySqlLeaseMgr::INSERT_LEASE4,
"INSERT INTO lease4(address, hwaddr, client_id, "
"valid_lifetime, expire, subnet_id) "
"VALUES (?, ?, ?, ?, ?, ?)"},
"valid_lifetime, expire, subnet_id, "
"fqdn_fwd, fqdn_rev, hostname) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"},
{MySqlLeaseMgr::INSERT_LEASE6,
"INSERT INTO lease6(address, duid, valid_lifetime, "
"expire, subnet_id, pref_lifetime, "
"lease_type, iaid, prefix_len) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"},
"lease_type, iaid, prefix_len, "
"fqdn_fwd, fqdn_rev, hostname) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"},
{MySqlLeaseMgr::UPDATE_LEASE4,
"UPDATE lease4 SET address = ?, hwaddr = ?, "
"client_id = ?, valid_lifetime = ?, expire = ?, "
"subnet_id = ? "
"subnet_id = ?, fqdn_fwd = ?, fqdn_rev = ?, "
"hostname = ? "
"WHERE address = ?"},
{MySqlLeaseMgr::UPDATE_LEASE6,
"UPDATE lease6 SET address = ?, duid = ?, "
"valid_lifetime = ?, expire = ?, subnet_id = ?, "
"pref_lifetime = ?, lease_type = ?, iaid = ?, "
"prefix_len = ? "
"prefix_len = ?, fqdn_fwd = ?, fqdn_rev = ?, "
"hostname = ? "
"WHERE address = ?"},
// End of list sentinel
{MySqlLeaseMgr::NUM_STATEMENTS, NULL}
......@@ -275,7 +293,7 @@ public:
class MySqlLease4Exchange : public MySqlLeaseExchange {
/// @brief Set number of database columns for this lease structure
static const size_t LEASE_COLUMNS = 6;
static const size_t LEASE_COLUMNS = 9;
public:
/// @brief Constructor
......@@ -294,7 +312,10 @@ public:
columns_[3] = "valid_lifetime";
columns_[4] = "expire";
columns_[5] = "subnet_id";
BOOST_STATIC_ASSERT(5 < LEASE_COLUMNS);
columns_[6] = "fqdn_fwd";
columns_[7] = "fqdn_rev";
columns_[8] = "hostname";
BOOST_STATIC_ASSERT(8 < LEASE_COLUMNS);
}
/// @brief Create MYSQL_BIND objects for Lease4 Pointer
......@@ -397,11 +418,32 @@ public:
// bind_[5].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// fqdn_fwd: boolean
bind_[6].buffer_type = MYSQL_TYPE_TINY;
bind_[6].buffer = reinterpret_cast<char*>(&lease_->fqdn_fwd_);
bind_[6].is_unsigned = MLM_TRUE;
// bind_[6].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// fqdn_rev: boolean
bind_[7].buffer_type = MYSQL_TYPE_TINY;
bind_[7].buffer = reinterpret_cast<char*>(&lease_->fqdn_rev_);
bind_[7].is_unsigned = MLM_TRUE;
// bind_[7].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// hostname: varchar(255)
bind_[8].buffer_type = MYSQL_TYPE_VARCHAR;
bind_[8].buffer = const_cast<char*>(lease_->hostname_.c_str());
bind_[8].buffer_length = lease_->hostname_.length();
// bind_[8].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// Add the error flags
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
// .. and check that we have the numbers correct at compile time.
BOOST_STATIC_ASSERT(5 < LEASE_COLUMNS);
BOOST_STATIC_ASSERT(8 < LEASE_COLUMNS);
// Add the data to the vector. Note the end element is one after the
// end of the array.
......@@ -470,11 +512,34 @@ public:
// bind_[5].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// fqdn_fwd: boolean
bind_[6].buffer_type = MYSQL_TYPE_TINY;
bind_[6].buffer = reinterpret_cast<char*>(&fqdn_fwd_);
bind_[6].is_unsigned = MLM_TRUE;
// bind_[6].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// fqdn_rev: boolean
bind_[7].buffer_type = MYSQL_TYPE_TINY;
bind_[7].buffer = reinterpret_cast<char*>(&fqdn_rev_);
bind_[7].is_unsigned = MLM_TRUE;
// bind_[7].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// hostname: varchar(255)
hostname_length_ = sizeof(hostname_buffer_);
bind_[8].buffer_type = MYSQL_TYPE_STRING;
bind_[8].buffer = reinterpret_cast<char*>(hostname_buffer_);
bind_[8].buffer_length = hostname_length_;
bind_[8].length = &hostname_length_;
// bind_[8].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// Add the error flags
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
// .. and check that we have the numbers correct at compile time.
BOOST_STATIC_ASSERT(5 < LEASE_COLUMNS);
BOOST_STATIC_ASSERT(8 < LEASE_COLUMNS);
// Add the data to the vector. Note the end element is one after the
// end of the array.
......@@ -500,10 +565,16 @@ public:
client_id_length_ = 0;
}
// Hostname is passed to Lease4 as a string object. We have to create
// it from the buffer holding hostname and the buffer length.
std::string hostname(hostname_buffer_,
hostname_buffer_ + hostname_length_);
// note that T1 and T2 are not stored
return (Lease4Ptr(new Lease4(addr4_, hwaddr_buffer_, hwaddr_length_,
client_id_buffer_, client_id_length_,
valid_lifetime_, 0, 0, cltt, subnet_id_)));
valid_lifetime_, 0, 0, cltt, subnet_id_,
fqdn_fwd_, fqdn_rev_, hostname)));
}
/// @brief Return columns in error
......@@ -543,6 +614,15 @@ private:
Lease4Ptr lease_; ///< Pointer to lease object
uint32_t subnet_id_; ///< Subnet identification
uint32_t valid_lifetime_; ///< Lease time
my_bool fqdn_fwd_; ///< Has forward DNS update been
///< performed
my_bool fqdn_rev_; ///< Has reverse DNS update been
///< performed
char hostname_buffer_[HOSTNAME_MAX_LEN];
///< Client hostname
unsigned long hostname_length_; ///< Client hostname length
};
......@@ -562,7 +642,7 @@ private:
class MySqlLease6Exchange : public MySqlLeaseExchange {
/// @brief Set number of database columns for this lease structure
static const size_t LEASE_COLUMNS = 9;
static const size_t LEASE_COLUMNS = 12;
public:
/// @brief Constructor
......@@ -575,15 +655,18 @@ public:
std::fill(&error_[0], &error_[LEASE_COLUMNS], MLM_FALSE);
// Set the column names (for error messages)
columns_[0] = "address";
columns_[1] = "duid";
columns_[2] = "valid_lifetime";
columns_[3] = "expire";
columns_[4] = "subnet_id";
columns_[5] = "pref_lifetime";
columns_[6] = "lease_type";
columns_[7] = "iaid";
columns_[8] = "prefix_len";
columns_[0] = "address";
columns_[1] = "duid";
columns_[2] = "valid_lifetime";
columns_[3] = "expire";
columns_[4] = "subnet_id";
columns_[5] = "pref_lifetime";
columns_[6] = "lease_type";
columns_[7] = "iaid";
columns_[8] = "prefix_len";
columns_[9] = "fqdn_fwd";
columns_[10] = "fqdn_rev";
columns_[11] = "hostname";
BOOST_STATIC_ASSERT(8 < LEASE_COLUMNS);
}
......@@ -707,11 +790,32 @@ public:
// bind_[8].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// fqdn_fwd: boolean
bind_[9].buffer_type = MYSQL_TYPE_TINY;
bind_[9].buffer = reinterpret_cast<char*>(&lease_->fqdn_fwd_);
bind_[9].is_unsigned = MLM_TRUE;
// bind_[7].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// fqdn_rev: boolean
bind_[10].buffer_type = MYSQL_TYPE_TINY;
bind_[10].buffer = reinterpret_cast<char*>(&lease_->fqdn_rev_);
bind_[10].is_unsigned = MLM_TRUE;
// bind_[10].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// hostname: varchar(255)
bind_[11].buffer_type = MYSQL_TYPE_VARCHAR;
bind_[11].buffer = const_cast<char*>(lease_->hostname_.c_str());
bind_[11].buffer_length = lease_->hostname_.length();
// bind_[11].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// Add the error flags
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
// .. and check that we have the numbers correct at compile time.
BOOST_STATIC_ASSERT(8 < LEASE_COLUMNS);
BOOST_STATIC_ASSERT(11 < LEASE_COLUMNS);
// Add the data to the vector. Note the end element is one after the
// end of the array.
......@@ -805,11 +909,34 @@ public:
// bind_[8].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// fqdn_fwd: boolean
bind_[9].buffer_type = MYSQL_TYPE_TINY;
bind_[9].buffer = reinterpret_cast<char*>(&fqdn_fwd_);
bind_[9].is_unsigned = MLM_TRUE;
// bind_[9].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// fqdn_rev: boolean
bind_[10].buffer_type = MYSQL_TYPE_TINY;
bind_[10].buffer = reinterpret_cast<char*>(&fqdn_rev_);
bind_[10].is_unsigned = MLM_TRUE;
// bind_[10].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// hostname: varchar(255)
hostname_length_ = sizeof(hostname_buffer_);
bind_[11].buffer_type = MYSQL_TYPE_STRING;
bind_[11].buffer = reinterpret_cast<char*>(hostname_buffer_);
bind_[11].buffer_length = hostname_length_;
bind_[11].length = &hostname_length_;
// bind_[11].is_null = &MLM_FALSE; // commented out for performance
// reasons, see memset() above
// Add the error flags
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
// .. and check that we have the numbers correct at compile time.
BOOST_STATIC_ASSERT(8 < LEASE_COLUMNS);
BOOST_STATIC_ASSERT(11 < LEASE_COLUMNS);
// Add the data to the vector. Note the end element is one after the
// end of the array.
......@@ -859,11 +986,17 @@ public:
// Set up DUID,
DuidPtr duid_ptr(new DUID(duid_buffer_, duid_length_));
// Hostname is passed to Lease6 as a string object, so we have to
// create it from the hostname buffer and length.
std::string hostname(hostname_buffer_,
hostname_buffer_ + hostname_length_);
// Create the lease and set the cltt (after converting from the
// expire time retrieved from the database).
Lease6Ptr result(new Lease6(type, addr, duid_ptr, iaid_,
pref_lifetime_, valid_lifetime_, 0, 0,
subnet_id_, prefixlen_));
subnet_id_, fqdn_fwd_, fqdn_rev_,
hostname, prefixlen_));
time_t cltt = 0;
MySqlLeaseMgr::convertFromDatabaseTime(expire_, valid_lifetime_, cltt);
result->cltt_ = cltt;
......@@ -907,6 +1040,14 @@ private:
uint32_t pref_lifetime_; ///< Preferred lifetime
uint32_t subnet_id_; ///< Subnet identification
uint32_t valid_lifetime_; ///< Lease time
my_bool fqdn_fwd_; ///< Has forward DNS update been
///< performed
my_bool fqdn_rev_; ///< Has reverse DNS update been
///< performed
char hostname_buffer_[HOSTNAME_MAX_LEN];
///< Client hostname
unsigned long hostname_length_; ///< Client hostname length
};
......
......@@ -272,8 +272,9 @@ TEST(Lease4, constructor) {
// Create the lease
Lease4 lease(ADDRESS[i], HWADDR, sizeof(HWADDR),
CLIENTID, sizeof(CLIENTID), VALID_LIFETIME, 0, 0, current_time,
SUBNET_ID);
CLIENTID, sizeof(CLIENTID), VALID_LIFETIME, 0, 0,
current_time, SUBNET_ID, true, true,
"hostname.example.com.");
EXPECT_EQ(ADDRESS[i], static_cast<uint32_t>(lease.addr_));
EXPECT_EQ(0, lease.ext_);
......@@ -285,9 +286,9 @@ TEST(Lease4, constructor) {
EXPECT_EQ(current_time, lease.cltt_);
EXPECT_EQ(SUBNET_ID, lease.subnet_id_);
EXPECT_FALSE(lease.fixed_);
EXPECT_TRUE(lease.hostname_.empty());
EXPECT_FALSE(lease.fqdn_fwd_);
EXPECT_FALSE(lease.fqdn_rev_);
EXPECT_EQ("hostname.example.com.", lease.hostname_);
EXPECT_TRUE(lease.fqdn_fwd_);
EXPECT_TRUE(lease.fqdn_rev_);
EXPECT_TRUE(lease.comments_.empty());
}
}
......@@ -494,7 +495,7 @@ TEST(Lease4, operatorEquals) {
// Lease6 is also defined in lease_mgr.h, so is tested in this file as well.
// This test checks if the Lease6 structure can be instantiated correctly
TEST(Lease6, Lease6Constructor) {
TEST(Lease6, Lease6ConstructorDefault) {
// check a variety of addresses with different bits set.
const char* ADDRESS[] = {
......@@ -525,6 +526,56 @@ TEST(Lease6, Lease6Constructor) {
EXPECT_TRUE(lease->valid_lft_ == 200);
EXPECT_TRUE(lease->t1_ == 50);
EXPECT_TRUE(lease->t2_ == 80);
EXPECT_FALSE(lease->fqdn_fwd_);
EXPECT_FALSE(lease->fqdn_rev_);
EXPECT_TRUE(lease->hostname_.empty());
}
// Lease6 must be instantiated with a DUID, not with NULL pointer
IOAddress addr(ADDRESS[0]);
Lease6Ptr lease2;
EXPECT_THROW(lease2.reset(new Lease6(Lease6::LEASE_IA_NA, addr,
DuidPtr(), iaid, 100, 200, 50, 80,
subnet_id)), InvalidOperation);
}
// This test verifies that the Lease6 constructor which accepts FQDN data,
// sets the data correctly for the lease.
TEST(Lease6, Lease6ConstructorWithFQDN) {
// check a variety of addresses with different bits set.
const char* ADDRESS[] = {
"::", "::1", "2001:db8:1::456",
"7fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
"8000::", "8000::1",
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
};
// Other values
uint8_t llt[] = {0, 1, 2, 3, 4, 5, 6, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
DuidPtr duid(new DUID(llt, sizeof(llt)));
uint32_t iaid = 7; // Just a number
SubnetID subnet_id = 8; // Just another number
for (int i = 0; i < sizeof(ADDRESS) / sizeof(ADDRESS[0]); ++i) {