mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-22 01:49:48 +00:00
[extend_host_struct] Fix review comments
This commit is contained in:
parent
3606c3ba9c
commit
2ff46b2dd5
1
AUTHORS
1
AUTHORS
@ -171,6 +171,7 @@ We have received the following contributions:
|
||||
|
||||
- Sunil Mayya
|
||||
2018-07: support for Authentication option in DHCPv6
|
||||
2018-07: support storage of Authentication keys in host structure
|
||||
|
||||
Kea uses log4cplus (http://sourceforge.net/projects/log4cplus/) for logging,
|
||||
Boost (http://www.boost.org/) library for almost everything, and can use Botan
|
||||
|
@ -1,3 +1,8 @@
|
||||
1434. [func] MayyaSunil
|
||||
Code added to support storage of Authentication key host reservation.
|
||||
There is no way to use the code yet.
|
||||
(Github #88, git tbd)
|
||||
|
||||
1433. [func] marcin
|
||||
Implemented state HA state machine pausing in the high
|
||||
availability hooks library.
|
||||
|
@ -165,7 +165,7 @@ EOF
|
||||
|
||||
# Second table: hosts
|
||||
mysql -u$db_user -p$db_password $db_name >/dev/null 2>&1 <<EOF
|
||||
SELECT host_id, dhcp_identifier, dhcp_identifier_type, dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, dhcp4_client_classes, dhcp6_client_classes, dhcp4_next_server, dhcp4_server_hostname, dhcp4_boot_file_name FROM hosts;
|
||||
SELECT host_id, dhcp_identifier, dhcp_identifier_type, dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, dhcp4_client_classes, dhcp6_client_classes, dhcp4_next_server, dhcp4_server_hostname, dhcp4_boot_file_name, auth_key FROM hosts;
|
||||
EOF
|
||||
ERRCODE=$?
|
||||
assert_eq 0 $ERRCODE "hosts table is missing or broken. (expected status code %d, returned %d)"
|
||||
@ -400,10 +400,10 @@ EOF
|
||||
|
||||
#table: DHCPv4 fixed field colums (upgrade 4.1 -> 5.0)
|
||||
# verify that hosts table has columns holding values for DHCPv4 fixed fields
|
||||
qry="select dhcp4_next_server, dhcp4_server_hostname, dhcp4_boot_file_name from hosts";
|
||||
qry="select dhcp4_next_server, dhcp4_server_hostname, dhcp4_boot_file_name, auth_key from hosts";
|
||||
count=`mysql_execute "${qry}"`
|
||||
ERRCODE=$?
|
||||
assert_eq 0 $ERRCODE "select dhcp4_next_server, dhcp4_server_hostname, dhcp4_boot_file_name failed. (expected status code %d, returned %d)"
|
||||
assert_eq 0 $ERRCODE "select dhcp4_next_server, dhcp4_server_hostname, dhcp4_boot_file_name, auth_key failed. (expected status code %d, returned %d)"
|
||||
|
||||
# verify that dhcp4_subnet_id is unsigned
|
||||
qry="show columns from hosts like 'dhcp4_subnet_id'"
|
||||
|
@ -165,7 +165,7 @@ pgsql_upgrade_2_0_to_3_0() {
|
||||
assert_eq 0 $ERRCODE "lease_hwaddr_source table is missing or broken. (expected status code %d, returned %d)"
|
||||
|
||||
# Added hosts table
|
||||
output=`pgsql_execute "select host_id, dhcp_identifier, dhcp_identifier_type, dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, dhcp4_client_classes, dhcp6_client_classes, dhcp4_next_server, dhcp4_server_hostname, dhcp4_boot_file_name from hosts;"`
|
||||
output=`pgsql_execute "select host_id, dhcp_identifier, dhcp_identifier_type, dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, dhcp4_client_classes, dhcp6_client_classes, dhcp4_next_server, dhcp4_server_hostname, dhcp4_boot_file_name, auth_key from hosts;"`
|
||||
ERRCODE=$?
|
||||
assert_eq 0 $ERRCODE "hosts table is missing or broken. (expected status code %d, returned %d)"
|
||||
|
||||
|
@ -497,6 +497,10 @@ of leases beginning with the specified address.
|
||||
A debug message issued when the server is attempting to obtain all IPv6
|
||||
leases from the memory file database.
|
||||
|
||||
% DHCPSRV_MEMFILE_GET6_DUID obtaining IPv6 leases for DUID %1
|
||||
A debug message issued when the server is attempting to obtain IPv6
|
||||
leases from the memory file database for the DUID.
|
||||
|
||||
% DHCPSRV_MEMFILE_GET_ADDR4 obtaining IPv4 lease for address %1
|
||||
A debug message issued when the server is attempting to obtain an IPv4
|
||||
lease from the memory file database for the specified address.
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <util/encode/hex.h>
|
||||
#include <util/strutil.h>
|
||||
#include <asiolink/io_address.h>
|
||||
#include <boost/random.hpp>
|
||||
#include <boost/random/uniform_int_distribution.hpp>
|
||||
#include <boost/random/mersenne_twister.hpp>
|
||||
#include <exceptions/exceptions.h>
|
||||
@ -47,9 +48,9 @@ AuthKey::getRandomKeyString() {
|
||||
|
||||
std::string
|
||||
AuthKey::ToText() const {
|
||||
std::ostringstream s;
|
||||
//s << authKey_;
|
||||
return (authKey_);
|
||||
//this will need enhancement if the stored container is not
|
||||
//string
|
||||
return authKey_;
|
||||
}
|
||||
|
||||
void
|
||||
@ -146,7 +147,7 @@ Host::Host(const uint8_t* identifier, const size_t identifier_len,
|
||||
server_host_name_(server_host_name), boot_file_name_(boot_file_name),
|
||||
host_id_(0), cfg_option4_(new CfgOption()),
|
||||
cfg_option6_(new CfgOption()), negative_(false),
|
||||
key_(auth_key){
|
||||
key_(auth_key) {
|
||||
|
||||
// Initialize host identifier.
|
||||
setIdentifier(identifier, identifier_len, identifier_type);
|
||||
@ -182,7 +183,7 @@ Host::Host(const std::string& identifier, const std::string& identifier_name,
|
||||
server_host_name_(server_host_name), boot_file_name_(boot_file_name),
|
||||
host_id_(0), cfg_option4_(new CfgOption()),
|
||||
cfg_option6_(new CfgOption()), negative_(false),
|
||||
key_(auth_key){
|
||||
key_(auth_key) {
|
||||
|
||||
// Initialize host identifier.
|
||||
setIdentifier(identifier, identifier_name);
|
||||
|
@ -35,13 +35,11 @@ class AuthKey {
|
||||
public:
|
||||
/// @brief Length of the key - 128 bits
|
||||
const static uint8_t KEY_LEN = 16;
|
||||
|
||||
|
||||
/// @brief Constructor
|
||||
///
|
||||
/// Constructor for assigning auth keys in host reservation
|
||||
/// Throws if the key length is greater than 16 bytes
|
||||
/// appends 0 to the the input if the key value is less
|
||||
/// than 16 bytes. Provide flexibility to store initialise the value as a string or a vector of bytes.
|
||||
/// Ensures the key length is not greater than 16 bytes
|
||||
/// @param string auth key to be stored
|
||||
AuthKey(const std::string key);
|
||||
|
||||
@ -50,20 +48,20 @@ public:
|
||||
/// Constructor for generating auth keys, with no argument
|
||||
/// shall use the internal function for generationg random keys
|
||||
AuthKey(void);
|
||||
|
||||
|
||||
// @brief get random string
|
||||
///
|
||||
/// Random string is generated by default will be used for
|
||||
/// Random string is generated by default will be used for
|
||||
/// the keys to be used for signing Reconfigure Message.
|
||||
/// @return auth keys
|
||||
/// @todo Move randomization function to cryptolink
|
||||
static std::string getRandomKeyString();
|
||||
static std::string getRandomKeyString();
|
||||
|
||||
/// @brief set auth key value
|
||||
///
|
||||
/// Set the key value. If the value is less than 16 bytes
|
||||
/// append 0. If the size is greater than 16 bytes, we shall
|
||||
/// throw an exception
|
||||
/// Set the key value.
|
||||
// If the size is greater than 16 bytes, we resize to 16 Bytes
|
||||
/// Doesnt throw an exception
|
||||
/// @param string key to be stored
|
||||
void setAuthKey(const std::string& key);
|
||||
|
||||
@ -73,13 +71,13 @@ public:
|
||||
std::string getAuthKey() {
|
||||
return authKey_;
|
||||
}
|
||||
|
||||
|
||||
/// @brief return text format for keys
|
||||
///
|
||||
/// Although returning member would have sufficed
|
||||
/// this is added incase in future authkey is no longer std::string
|
||||
std::string ToText() const;
|
||||
|
||||
|
||||
///
|
||||
/// @brief equality operator
|
||||
///
|
||||
@ -645,7 +643,6 @@ public:
|
||||
/// @brief sets key.
|
||||
///
|
||||
/// Keys are used for signing the Reconfigure Message.
|
||||
/// The accessor should ensure 128 characters
|
||||
void setKey(const AuthKey& key) {
|
||||
key_ = key;
|
||||
}
|
||||
@ -696,7 +693,7 @@ private:
|
||||
std::string server_host_name_;
|
||||
/// @brief Boot file name (a.k.a. file, carried in DHCPv4 message)
|
||||
std::string boot_file_name_;
|
||||
|
||||
|
||||
/// @brief HostID (a unique identifier assigned when the host is stored in
|
||||
/// MySQL, PostgreSQL or Cassandra)
|
||||
uint64_t host_id_;
|
||||
@ -719,7 +716,6 @@ private:
|
||||
// While sending reconfigure message authentication field
|
||||
/// shall contain MD5 hash computed using this key.
|
||||
AuthKey key_;
|
||||
|
||||
};
|
||||
|
||||
/// @brief Pointer to the @c Host object.
|
||||
|
@ -1015,6 +1015,20 @@ Memfile_LeaseMgr::getLeases6() const {
|
||||
return (collection);
|
||||
}
|
||||
|
||||
Lease6Collection
|
||||
Memfile_LeaseMgr::getLeases6(const DUID& duid) const {
|
||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET6_DUID)
|
||||
.arg(duid.toText());
|
||||
|
||||
Lease6Collection collection;
|
||||
for (auto lease = storage6_.begin(); lease != storage6_.end(); ++lease ) {
|
||||
if ( (**lease).duid_->getDuid() == duid.getDuid() )
|
||||
collection.push_back(Lease6Ptr(new Lease6(**lease)));
|
||||
}
|
||||
|
||||
return (collection);
|
||||
}
|
||||
|
||||
Lease6Collection
|
||||
Memfile_LeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
|
||||
const LeasePageSize& page_size) const {
|
||||
|
@ -145,7 +145,7 @@ public:
|
||||
dhcp4_next_server_null_(MLM_FALSE),
|
||||
dhcp4_server_hostname_null_(MLM_FALSE),
|
||||
dhcp4_boot_file_name_null_(MLM_FALSE),
|
||||
auth_key_null_(MLM_FALSE) {
|
||||
auth_key_null_(MLM_FALSE) {
|
||||
|
||||
// Fill arrays with 0 so as they don't include any garbage.
|
||||
memset(dhcp_identifier_buffer_, 0, sizeof(dhcp_identifier_buffer_));
|
||||
@ -1430,7 +1430,6 @@ public:
|
||||
|
||||
ipv6_address_buffer_[ipv6_address_buffer_len_] = '\0';
|
||||
std::string address = ipv6_address_buffer_;
|
||||
|
||||
IPv6Resrv r(type, IOAddress(address), prefix_len_);
|
||||
return (r);
|
||||
};
|
||||
|
@ -184,7 +184,7 @@ tagged_statements = { {
|
||||
"state, user_context "
|
||||
"FROM lease6 "
|
||||
"WHERE address = ? AND lease_type = ?"},
|
||||
{MySqlLeaseMgr::GET_LEASE6_DUID_IAID,
|
||||
{MySqlLeaseMgr::GET_LEASE6_DUID_IAID,
|
||||
"SELECT address, duid, valid_lifetime, "
|
||||
"expire, subnet_id, pref_lifetime, "
|
||||
"lease_type, iaid, prefix_len, "
|
||||
|
@ -1646,7 +1646,7 @@ TaggedStatementArray tagged_statements = { {
|
||||
//PgSqlHostDataSourceImpl::INSERT_V6_RESRV
|
||||
// Inserts a single IPv6 reservation into 'reservations' table.
|
||||
{5,
|
||||
{ OID_VARCHAR, OID_INT2, OID_INT4, OID_INT4, OID_INT4},
|
||||
{ OID_VARCHAR, OID_INT2, OID_INT4, OID_INT4, OID_INT4 },
|
||||
"insert_v6_resrv",
|
||||
"INSERT INTO ipv6_reservations(address, prefix_len, type, "
|
||||
" dhcp6_iaid, host_id) "
|
||||
|
@ -1590,7 +1590,7 @@ TEST_F(ExpirationAllocEngine6Test, reclaimDeclinedStats) {
|
||||
|
||||
// This test verifies that expired leases are reclaimed before they are
|
||||
// allocated to another client sending a Request message.
|
||||
/TEST_F(ExpirationAllocEngine6Test, reclaimReusedLeases) {
|
||||
TEST_F(ExpirationAllocEngine6Test, reclaimReusedLeases) {
|
||||
testReclaimReusedLeases(DHCPV6_REQUEST, false);
|
||||
}
|
||||
|
||||
|
@ -1277,10 +1277,12 @@ TEST(AuthKeyTest, basicTest) {
|
||||
defaultTestKey.setAuthKey(key16ByteStr);
|
||||
ASSERT_EQ(16, defaultTestKey.getAuthKey().size());
|
||||
ASSERT_EQ(key16ByteStr, defaultTestKey.getAuthKey());
|
||||
ASSERT_EQ(key16ByteStr, defaultTestKey.ToText());
|
||||
|
||||
defaultTestKey.setAuthKey(key18ByteStr);
|
||||
ASSERT_EQ(16, defaultTestKey.getAuthKey().size());
|
||||
ASSERT_EQ(key16ByteStr, defaultTestKey.getAuthKey());
|
||||
ASSERT_EQ(key16ByteStr, defaultTestKey.ToText());
|
||||
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ HostDataSourceUtils::initializeHost4(const std::string& address,
|
||||
}
|
||||
|
||||
HostPtr
|
||||
HostDataSourceUtils::initializeHost6(const std::string address,
|
||||
HostDataSourceUtils::initializeHost6(std::string address,
|
||||
Host::IdentifierType identifier,
|
||||
bool prefix,
|
||||
bool new_identifier,
|
||||
@ -107,13 +107,11 @@ HostDataSourceUtils::initializeHost6(const std::string address,
|
||||
++subnet4;
|
||||
++subnet6;
|
||||
|
||||
std::string default_string;
|
||||
HostPtr host(new Host(&ident[0], ident.size(), identifier, subnet4, subnet6,
|
||||
IOAddress("0.0.0.0"), default_string,
|
||||
default_string, default_string,
|
||||
asiolink:: IOAddress::IPV4_ZERO_ADDRESS(), default_string, default_string,
|
||||
AuthKey(auth_key)));
|
||||
|
||||
IOAddress("0.0.0.0")));
|
||||
|
||||
host->setKey(AuthKey(auth_key));
|
||||
|
||||
if (!prefix) {
|
||||
// Create IPv6 reservation (for an address)
|
||||
IPv6Resrv resv(IPv6Resrv::TYPE_NA, IOAddress(address), 128);
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
/// identifier should be generated or the same as previously.
|
||||
///
|
||||
/// @return generated Host object
|
||||
static HostPtr initializeHost6(const std::string address, Host::IdentifierType id,
|
||||
static HostPtr initializeHost6(std::string address, Host::IdentifierType id,
|
||||
bool prefix, bool new_identifier = true, const std::string key = "");
|
||||
|
||||
/// @brief Generates a hardware address in text version.
|
||||
|
Loading…
x
Reference in New Issue
Block a user