Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
f30ca446
Commit
f30ca446
authored
Jul 15, 2018
by
mayya
Committed by
Tomek Mrugalski
Jul 23, 2018
Browse files
review comments 2
review comments 2 test1 fixed unit tests fixed cassandra fixed cassandra2
parent
beeadf3d
Changes
17
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/cql_host_data_source.cc
View file @
f30ca446
...
...
@@ -116,7 +116,6 @@ static constexpr char NULL_USER_CONTEXT[] = "";
static
constexpr
char
NULL_RESERVED_IPV6_PREFIX_ADDRESS
[]
=
"::"
;
static
constexpr
cass_int32_t
NULL_RESERVED_IPV6_PREFIX_LENGTH
=
0
;
static
constexpr
cass_int32_t
NULL_RESERVED_IPV6_PREFIX_ADDRESS_TYPE
=
-
1
;
static
constexpr
char
NULL_RESERVED_KEY
[]
=
""
;
static
constexpr
cass_int32_t
NULL_IAID
=
-
1
;
static
constexpr
cass_int32_t
NULL_OPTION_UNIVERSE
=
-
1
;
static
constexpr
cass_int32_t
NULL_OPTION_CODE
=
-
1
;
...
...
@@ -351,6 +350,9 @@ private:
/// @brief Boot file name (file).
std
::
string
host_ipv4_boot_file_name_
;
/// @brief Key for authentication
std
::
string
auth_key_
;
/// @brief Name reserved for the host
std
::
string
hostname_
;
...
...
@@ -373,9 +375,6 @@ private:
/// This value corresponds to the @ref Host::IdentifierType value.
cass_int32_t
reserved_ipv6_prefix_address_type_
;
/// @brief Key for authentication
std
::
string
key_
;
/// @brief The reservation's IAID
cass_int32_t
iaid_
;
...
...
@@ -435,6 +434,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"host_ipv4_next_server, "
"host_ipv4_server_hostname, "
"host_ipv4_boot_file_name, "
"auth_key, "
"hostname, "
"user_context, "
"host_ipv4_client_classes, "
...
...
@@ -442,7 +442,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"reserved_ipv6_prefix_address, "
"reserved_ipv6_prefix_length, "
"reserved_ipv6_prefix_address_type, "
"reserved_key, "
"iaid, "
"option_universe, "
"option_code, "
...
...
@@ -477,6 +476,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"host_ipv4_next_server, "
"host_ipv4_server_hostname, "
"host_ipv4_boot_file_name, "
"auth_key, "
"hostname, "
"user_context, "
"host_ipv4_client_classes, "
...
...
@@ -484,7 +484,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"reserved_ipv6_prefix_address, "
"reserved_ipv6_prefix_length, "
"reserved_ipv6_prefix_address_type, "
"reserved_key, "
"iaid, "
"option_universe, "
"option_code, "
...
...
@@ -511,6 +510,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"host_ipv4_next_server, "
"host_ipv4_server_hostname, "
"host_ipv4_boot_file_name, "
"auth_key, "
"hostname, "
"user_context, "
"host_ipv4_client_classes, "
...
...
@@ -518,7 +518,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"reserved_ipv6_prefix_address, "
"reserved_ipv6_prefix_length, "
"reserved_ipv6_prefix_address_type, "
"reserved_key, "
"iaid, "
"option_universe, "
"option_code, "
...
...
@@ -548,6 +547,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"host_ipv4_next_server, "
"host_ipv4_server_hostname, "
"host_ipv4_boot_file_name, "
"auth_key, "
"hostname, "
"user_context, "
"host_ipv4_client_classes, "
...
...
@@ -555,7 +555,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"reserved_ipv6_prefix_address, "
"reserved_ipv6_prefix_length, "
"reserved_ipv6_prefix_address_type, "
"reserved_key, "
"iaid, "
"option_universe, "
"option_code, "
...
...
@@ -584,6 +583,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"host_ipv4_next_server, "
"host_ipv4_server_hostname, "
"host_ipv4_boot_file_name, "
"auth_key, "
"hostname, "
"user_context, "
"host_ipv4_client_classes, "
...
...
@@ -591,7 +591,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"reserved_ipv6_prefix_address, "
"reserved_ipv6_prefix_length, "
"reserved_ipv6_prefix_address_type, "
"reserved_key, "
"iaid, "
"option_universe, "
"option_code, "
...
...
@@ -622,6 +621,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"host_ipv4_next_server, "
"host_ipv4_server_hostname, "
"host_ipv4_boot_file_name, "
"auth_key, "
"hostname, "
"user_context, "
"host_ipv4_client_classes, "
...
...
@@ -629,7 +629,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"reserved_ipv6_prefix_address, "
"reserved_ipv6_prefix_length, "
"reserved_ipv6_prefix_address_type, "
"reserved_key, "
"iaid, "
"option_universe, "
"option_code, "
...
...
@@ -660,6 +659,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"host_ipv4_next_server, "
"host_ipv4_server_hostname, "
"host_ipv4_boot_file_name, "
"auth_key, "
"hostname, "
"user_context, "
"host_ipv4_client_classes, "
...
...
@@ -667,7 +667,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"reserved_ipv6_prefix_address, "
"reserved_ipv6_prefix_length, "
"reserved_ipv6_prefix_address_type, "
"reserved_key, "
"iaid, "
"option_universe, "
"option_code, "
...
...
@@ -697,6 +696,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"host_ipv4_next_server, "
"host_ipv4_server_hostname, "
"host_ipv4_boot_file_name, "
"auth_key, "
"hostname, "
"user_context, "
"host_ipv4_client_classes, "
...
...
@@ -704,7 +704,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"reserved_ipv6_prefix_address, "
"reserved_ipv6_prefix_length, "
"reserved_ipv6_prefix_address_type, "
"reserved_key, "
"iaid, "
"option_universe, "
"option_code, "
...
...
@@ -734,6 +733,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"host_ipv4_next_server, "
"host_ipv4_server_hostname, "
"host_ipv4_boot_file_name, "
"auth_key, "
"hostname, "
"user_context, "
"host_ipv4_client_classes, "
...
...
@@ -741,7 +741,6 @@ StatementMap CqlHostExchange::tagged_statements_ = {
"reserved_ipv6_prefix_address, "
"reserved_ipv6_prefix_length, "
"reserved_ipv6_prefix_address_type, "
"reserved_key, "
"iaid, "
"option_universe, "
"option_code, "
...
...
@@ -771,6 +770,7 @@ CqlHostExchange::CqlHostExchange()
host_ipv6_subnet_id_
(
0
),
host_ipv4_address_
(
0
),
host_ipv4_next_server_
(
0
),
host_ipv4_server_hostname_
(
NULL_DHCP4_SERVER_HOSTNAME
),
host_ipv4_boot_file_name_
(
NULL_DHCP4_BOOT_FILE_NAME
),
auth_key_
(
""
),
user_context_
(
NULL_USER_CONTEXT
),
reserved_ipv6_prefix_length_
(
NULL_RESERVED_IPV6_PREFIX_LENGTH
),
reserved_ipv6_prefix_address_type_
(
NULL_RESERVED_IPV6_PREFIX_ADDRESS_TYPE
),
...
...
@@ -808,6 +808,8 @@ CqlHostExchange::createBindForSelect(AnyArray& data, StatementTag /* not used */
data
.
add
(
&
host_ipv4_server_hostname_
);
// host_ipv4_boot_file_name: text
data
.
add
(
&
host_ipv4_boot_file_name_
);
// auth_key: text
data
.
add
(
&
auth_key_
);
// hostname: text
data
.
add
(
&
hostname_
);
// user_context: text
...
...
@@ -824,8 +826,6 @@ CqlHostExchange::createBindForSelect(AnyArray& data, StatementTag /* not used */
data
.
add
(
&
reserved_ipv6_prefix_length_
);
// reserved_ipv6_prefix_address_type: int
data
.
add
(
&
reserved_ipv6_prefix_address_type_
);
// reserved_key: text
data
.
add
(
&
key_
);
// iaid: int
data
.
add
(
&
iaid_
);
/// @}
...
...
@@ -903,6 +903,9 @@ CqlHostExchange::prepareExchange(const HostPtr& host,
// host_ipv4_boot_file_name: text
host_ipv4_boot_file_name_
=
host
->
getBootFileName
();
// auth_key: varchar
auth_key_
=
host
->
getKey
().
ToText
();
// hostname: text
hostname_
=
host
->
getHostname
();
if
(
hostname_
.
size
()
>
HOSTNAME_MAX_LENGTH
)
{
...
...
@@ -944,8 +947,6 @@ CqlHostExchange::prepareExchange(const HostPtr& host,
reserved_ipv6_prefix_length_
=
NULL_RESERVED_IPV6_PREFIX_LENGTH
;
// reserved_ipv6_prefix_address_type: int
reserved_ipv6_prefix_address_type_
=
NULL_RESERVED_IPV6_PREFIX_ADDRESS_TYPE
;
// reserved_key: text
key_
=
NULL_RESERVED_KEY
;
iaid_
=
NULL_IAID
;
}
else
{
// reserved_ipv6_prefix_address: text
...
...
@@ -958,9 +959,6 @@ CqlHostExchange::prepareExchange(const HostPtr& host,
reserved_ipv6_prefix_address_type_
=
reservation
->
getType
()
==
IPv6Resrv
::
TYPE_NA
?
0
:
2
;
// reserved_key: text
key_
=
reservation
->
getKey
().
getAuthKey
();
// iaid: int
/// @todo: We don't support iaid in the IPv6Resrv yet.
iaid_
=
0
;
...
...
@@ -1070,6 +1068,7 @@ CqlHostExchange::createBindForMutation(const HostPtr& host,
data
.
add
(
&
host_ipv4_next_server_
);
data
.
add
(
&
host_ipv4_server_hostname_
);
data
.
add
(
&
host_ipv4_boot_file_name_
);
data
.
add
(
&
auth_key_
);
data
.
add
(
&
hostname_
);
data
.
add
(
&
user_context_
);
data
.
add
(
&
host_ipv4_client_classes_
);
...
...
@@ -1080,7 +1079,6 @@ CqlHostExchange::createBindForMutation(const HostPtr& host,
data
.
add
(
&
reserved_ipv6_prefix_address_
);
data
.
add
(
&
reserved_ipv6_prefix_length_
);
data
.
add
(
&
reserved_ipv6_prefix_address_type_
);
data
.
add
(
&
key_
);
data
.
add
(
&
iaid_
);
// Option
...
...
@@ -1189,7 +1187,8 @@ CqlHostExchange::retrieve() {
ipv4_reservation
,
hostname_
,
host_ipv4_client_classes_
,
host_ipv6_client_classes_
,
static_cast
<
uint32_t
>
(
host_ipv4_next_server_
),
host_ipv4_server_hostname_
,
host_ipv4_boot_file_name_
);
host_ipv4_server_hostname_
,
host_ipv4_boot_file_name_
,
AuthKey
(
auth_key_
));
// Set the user context if there is one.
if
(
!
user_context_
.
empty
())
{
...
...
@@ -1248,7 +1247,7 @@ CqlHostExchange::retrieveReservation() const {
}
return
(
IPv6Resrv
(
type
,
IOAddress
(
reserved_ipv6_prefix_address_
),
reserved_ipv6_prefix_length_
,
key_
));
reserved_ipv6_prefix_length_
));
}
const
OptionWrapper
...
...
src/lib/dhcpsrv/cql_lease_mgr.cc
View file @
f30ca446
...
...
@@ -942,6 +942,7 @@ constexpr StatementTag CqlLease6Exchange::UPDATE_LEASE6;
constexpr
StatementTag
CqlLease6Exchange
::
DELETE_LEASE6
;
constexpr
StatementTag
CqlLease6Exchange
::
GET_LEASE6_EXPIRE
;
constexpr
StatementTag
CqlLease6Exchange
::
GET_LEASE6_ADDR
;
constexpr
StatementTag
CqlLease6Exchange
::
GET_LEASE6_DUID
;
constexpr
StatementTag
CqlLease6Exchange
::
GET_LEASE6_DUID_IAID
;
constexpr
StatementTag
CqlLease6Exchange
::
GET_LEASE6_DUID_IAID_SUBID
;
constexpr
StatementTag
CqlLease6Exchange
::
GET_LEASE6_LIMIT
;
...
...
@@ -2292,11 +2293,8 @@ CqlLeaseMgr::getLease6(Lease::Type lease_type, const IOAddress &addr) const {
return
(
result
);
}
Lease6Ptr
CqlLeaseMgr
::
getLease6
(
const
DUID
&
duid
)
const
{
std
::
string
duid_data
=
duid
.
toText
();
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_CQL_GET_DUID
)
.
arg
(
duid_data
);
Lease6Collection
CqlLeaseMgr
::
getLeases6
(
const
DUID
&
duid
)
const
{
// Set up the WHERE clause value
AnyArray
data
;
...
...
@@ -2311,6 +2309,7 @@ CqlLeaseMgr::getLease6(const DUID& duid) const {
exchange6
->
getLeaseCollection
(
CqlLease6Exchange
::
GET_LEASE6_DUID
,
data
,
result
);
return
(
result
);
}
Lease6Collection
...
...
src/lib/dhcpsrv/host.cc
View file @
f30ca446
...
...
@@ -13,6 +13,7 @@
#include
<boost/random/uniform_int_distribution.hpp>
#include
<boost/random/mersenne_twister.hpp>
#include
<exceptions/exceptions.h>
#include
<random>
#include
<sstream>
using
namespace
isc
::
data
;
...
...
@@ -44,6 +45,13 @@ AuthKey::getRandomKeyString() {
return
std
::
string
(
randomString
.
begin
(),
randomString
.
end
());
}
std
::
string
AuthKey
::
ToText
()
const
{
std
::
ostringstream
s
;
//s << authKey_;
return
(
authKey_
);
}
void
AuthKey
::
setAuthKey
(
const
std
::
string
&
key
)
{
authKey_
=
key
;
...
...
@@ -66,24 +74,14 @@ IPv6Resrv::IPv6Resrv(const Type& type,
const
asiolink
::
IOAddress
&
prefix
,
const
uint8_t
prefix_len
)
:
type_
(
type
),
prefix_
(
asiolink
::
IOAddress
(
"::"
)),
prefix_len_
(
128
)
,
key_
(
""
)
{
prefix_len_
(
128
){
// Validate and set the actual values.
set
(
type
,
prefix
,
prefix_len
);
}
IPv6Resrv
::
IPv6Resrv
(
const
Type
&
type
,
const
asiolink
::
IOAddress
&
prefix
,
const
AuthKey
&
key
,
const
uint8_t
prefix_len
)
:
type_
(
type
),
prefix_
(
asiolink
::
IOAddress
(
"::"
)),
prefix_len_
(
128
),
key_
(
""
)
{
// Validate and set the actual values.
set
(
type
,
prefix
,
prefix_len
,
key
);
}
void
IPv6Resrv
::
set
(
const
Type
&
type
,
const
asiolink
::
IOAddress
&
prefix
,
const
uint8_t
prefix_len
,
const
AuthKey
&
key
)
{
const
uint8_t
prefix_len
)
{
if
(
!
prefix
.
isV6
()
||
prefix
.
isV6Multicast
())
{
isc_throw
(
isc
::
BadValue
,
"invalid prefix '"
<<
prefix
<<
"' for new IPv6 reservation"
);
...
...
@@ -99,9 +97,6 @@ IPv6Resrv::set(const Type& type, const asiolink::IOAddress& prefix,
<<
"' for reserved IPv6 address, expected 128"
);
}
if
(
key
.
getAuthKey
().
size
()
!=
0
)
{
key_
=
key
;
}
type_
=
type
;
prefix_
=
prefix
;
prefix_len_
=
prefix_len
;
...
...
@@ -112,7 +107,6 @@ IPv6Resrv::toText() const {
std
::
ostringstream
s
;
s
<<
prefix_
;
// For PD, append prefix length.
// @todo: add to text for key
if
(
getType
()
==
TYPE_PD
)
{
s
<<
"/"
<<
static_cast
<
int
>
(
prefix_len_
);
}
...
...
@@ -123,8 +117,7 @@ bool
IPv6Resrv
::
operator
==
(
const
IPv6Resrv
&
other
)
const
{
return
(
type_
==
other
.
type_
&&
prefix_
==
other
.
prefix_
&&
prefix_len_
==
other
.
prefix_len_
&&
key_
==
other
.
key_
);
prefix_len_
==
other
.
prefix_len_
);
}
bool
...
...
@@ -141,7 +134,8 @@ Host::Host(const uint8_t* identifier, const size_t identifier_len,
const
std
::
string
&
dhcp6_client_classes
,
const
asiolink
::
IOAddress
&
next_server
,
const
std
::
string
&
server_host_name
,
const
std
::
string
&
boot_file_name
)
const
std
::
string
&
boot_file_name
,
const
AuthKey
&
auth_key
)
:
identifier_type_
(
identifier_type
),
identifier_value_
(),
ipv4_subnet_id_
(
ipv4_subnet_id
),
...
...
@@ -152,7 +146,8 @@ Host::Host(const uint8_t* identifier, const size_t identifier_len,
next_server_
(
asiolink
::
IOAddress
::
IPV4_ZERO_ADDRESS
()),
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
)
{
cfg_option6_
(
new
CfgOption
()),
negative_
(
false
),
key_
(
auth_key
){
// Initialize host identifier.
setIdentifier
(
identifier
,
identifier_len
,
identifier_type
);
...
...
@@ -176,7 +171,8 @@ Host::Host(const std::string& identifier, const std::string& identifier_name,
const
std
::
string
&
dhcp6_client_classes
,
const
asiolink
::
IOAddress
&
next_server
,
const
std
::
string
&
server_host_name
,
const
std
::
string
&
boot_file_name
)
const
std
::
string
&
boot_file_name
,
const
AuthKey
&
auth_key
)
:
identifier_type_
(
IDENT_HWADDR
),
identifier_value_
(),
ipv4_subnet_id_
(
ipv4_subnet_id
),
ipv6_subnet_id_
(
ipv6_subnet_id
),
...
...
@@ -186,7 +182,8 @@ Host::Host(const std::string& identifier, const std::string& identifier_name,
next_server_
(
asiolink
::
IOAddress
::
IPV4_ZERO_ADDRESS
()),
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
)
{
cfg_option6_
(
new
CfgOption
()),
negative_
(
false
),
key_
(
auth_key
){
// Initialize host identifier.
setIdentifier
(
identifier
,
identifier_name
);
...
...
@@ -584,6 +581,10 @@ Host::toElement6() const {
ConstCfgOptionPtr
opts
=
getCfgOption6
();
map
->
set
(
"option-data"
,
opts
->
toElement
());
// Set auth key
//@todo: uncomment once storing in configuration file is enabled
//map->set("auth-key", Element::create(getKey().ToText()));
return
(
map
);
}
...
...
@@ -621,6 +622,8 @@ Host::toText() const {
// Add boot file name.
s
<<
" file="
<<
(
boot_file_name_
.
empty
()
?
"(empty)"
:
boot_file_name_
);
s
<<
" key="
<<
(
key_
.
ToText
().
empty
()
?
"(empty)"
:
key_
.
ToText
());
if
(
ipv6_reservations_
.
empty
())
{
s
<<
" ipv6_reservations=(none)"
;
...
...
src/lib/dhcpsrv/host.h
View file @
f30ca446
...
...
@@ -59,14 +59,6 @@ public:
/// @todo Move randomization function to cryptolink
static
std
::
string
getRandomKeyString
();
/// @brief get auth key value
///
/// Returns 16 Byte long key
std
::
string
getAuthKey
()
const
{
return
authKey_
;
}
/// @brief set auth key value
///
/// Set the key value. If the value is less than 16 bytes
...
...
@@ -75,6 +67,20 @@ public:
/// @param string key to be stored
void
setAuthKey
(
const
std
::
string
&
key
);
/// @brief return auth key
///
/// @return auth key
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
///
/// equality operator to compare two AuthKey classes
...
...
@@ -127,25 +133,6 @@ public:
const
asiolink
::
IOAddress
&
prefix
,
const
uint8_t
prefix_len
=
128
);
/// @brief Constructor.
///
/// Creates a reservation from the IPv6 address ,prefix length and
/// key value. If the prefix length is not specified, the default value
/// of 128 is used. This value indicates that the reservation is made
/// for an IPv6 address for a client which supports reconfiguration.
///
/// @param type Reservation type: NA or PD.
/// @param prefix Address or prefix to be reserved.
/// @param keys to be reserved.
/// @param prefix_len Prefix length.
///
/// @throw isc::BadValue if prefix is not IPv6 prefix, is a
/// multicast address or the prefix length is greater than 128.
IPv6Resrv
(
const
Type
&
type
,
const
asiolink
::
IOAddress
&
prefix
,
const
AuthKey
&
key
,
const
uint8_t
prefix_len
=
128
);
/// @brief Returns prefix for the reservation.
const
asiolink
::
IOAddress
&
getPrefix
()
const
{
return
(
prefix_
);
...
...
@@ -165,21 +152,6 @@ public:
return
(
type_
);
}
/// @brief Returns the key.
///
/// Keys are used for signing the Reconfigure Message.
AuthKey
getKey
()
const
{
return
(
key_
);
}
/// @brief sets key.
///
/// Keys are used for signing the Reconfigure Message.
/// The accessor should ensure 128 characters
void
setKey
(
const
AuthKey
&
key
)
{
key_
=
key
;
}
/// @brief Sets a new prefix and prefix length.
///
/// @param type Reservation type: NA or PD.
...
...
@@ -189,7 +161,7 @@ public:
/// @throw isc::BadValue if prefix is not IPv6 prefix, is a
/// multicast address or the prefix length is greater than 128.
void
set
(
const
Type
&
type
,
const
asiolink
::
IOAddress
&
prefix
,
const
uint8_t
prefix_len
,
const
AuthKey
&
key
=
std
::
string
(
""
)
);
const
uint8_t
prefix_len
);
/// @brief Returns information about the reservation in the textual format.
std
::
string
toText
()
const
;
...
...
@@ -209,7 +181,6 @@ private:
Type
type_
;
///< Reservation type.
asiolink
::
IOAddress
prefix_
;
///< Prefix
uint8_t
prefix_len_
;
///< Prefix length.
AuthKey
key_
;
///< keys for authentication.
};
/// @brief Collection of IPv6 reservations for the host.
...
...
@@ -330,7 +301,8 @@ public:
const
std
::
string
&
dhcp6_client_classes
=
""
,
const
asiolink
::
IOAddress
&
next_server
=
asiolink
::
IOAddress
::
IPV4_ZERO_ADDRESS
(),
const
std
::
string
&
server_host_name
=
""
,
const
std
::
string
&
boot_file_name
=
""
);
const
std
::
string
&
boot_file_name
=
""
,
const
AuthKey
&
auth_key
=
std
::
string
(
""
));
/// @brief Constructor.
///
...
...
@@ -379,7 +351,8 @@ public:
const
std
::
string
&
dhcp6_client_classes
=
""
,
const
asiolink
::
IOAddress
&
next_server
=
asiolink
::
IOAddress
::
IPV4_ZERO_ADDRESS
(),
const
std
::
string
&
server_host_name
=
""
,
const
std
::
string
&
boot_file_name
=
""
);
const
std
::
string
&
boot_file_name
=
""
,
const
AuthKey
&
auth_key
=
std
::
string
(
""
));
/// @brief Replaces currently used identifier with a new identifier.
///
...
...
@@ -664,10 +637,25 @@ public:
/// @return Element representation of the host
isc
::
data
::
ElementPtr
toElement4
()
const
;
/// @brief Unparses (converts to Element representation) IPv
4
host
/// @brief Unparses (converts to Element representation) IPv
6
host
///
/// @return Element representation of the host
isc
::
data
::
ElementPtr
toElement6
()
const
;
/// @brief sets key.
///
/// Keys are used for signing the Reconfigure Message.
/// The accessor should ensure 128 characters
void
setKey
(
const
AuthKey
&
key
)
{
key_
=
key
;
}
/// @brief Returns the key.
///
/// Keys are used for signing the Reconfigure Message.
AuthKey
getKey
()
const
{
return
(
key_
);
}
private:
...
...
@@ -708,8 +696,6 @@ 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_
;
...
...
@@ -724,6 +710,15 @@ private:
/// we queried other backends for specific host and there was no
/// entry for it.
bool
negative_
;
/// @brief keys for authentication .
///
/// This key is a 16 byte value to be used in the authentication field
/// During server replies specified in the RFC 3315bis authentication field will
/// contain the below key. While sending reconfigure message authentication field
/// shall contain MD5 hash computed using this key.
AuthKey
key_
;
/// @brief HostID (a unique identifier assigned when the host is stored in
};
/// @brief Pointer to the @c Host object.
...
...
src/lib/dhcpsrv/mysql_host_data_source.cc
View file @
f30ca446
...
...
@@ -115,7 +115,7 @@ class MySqlHostExchange {
private:
/// @brief Number of columns returned for SELECT queries send by this class.
static
const
size_t
HOST_COLUMNS
=
1
3
;
static
const
size_t
HOST_COLUMNS
=
1
4
;
public:
...
...
@@ -145,7 +145,8 @@ public:
user_context_null_
(
MLM_FALSE
),
dhcp4_next_server_null_
(
MLM_FALSE
),
dhcp4_server_hostname_null_
(
MLM_FALSE
),
dhcp4_boot_file_name_null_
(
MLM_FALSE
)
{
dhcp4_boot_file_name_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_
));
...
...
@@ -172,8 +173,9 @@ public:
columns_
[
10
]
=
"dhcp4_next_server"
;
columns_
[
11
]
=
"dhcp4_server_hostname"
;
columns_
[
12
]
=
"dhcp4_boot_file_name"
;
columns_
[
13
]
=
"auth_key"
;
BOOST_STATIC_ASSERT
(
1
2
<
HOST_COLUMNS
);
BOOST_STATIC_ASSERT
(
1
3
<
HOST_COLUMNS
);
};
/// @brief Virtual destructor.
...
...
@@ -398,6 +400,14 @@ public:
bind_
[
12
].
buffer
=
dhcp4_boot_file_name_
;
bind_
[
12
].
buffer_length
=
boot_file_name
.
length
();
// auth key
bind_
[
13
].
buffer_type
=
MYSQL_TYPE_STRING
;
std
::
string
auth_key
=
host
->
getKey
().
ToText
();
std
::
strncpy
(
auth_key_
,
auth_key
.
c_str
(),
KEY_LEN
);
auth_key_null_
=
auth_key
.
empty
()
?
MLM_TRUE
:
MLM_FALSE
;
bind_
[
13
].
buffer
=
auth_key_
;
bind_
[
13
].
buffer_length
=
auth_key
.
length
();
}
catch
(
const
std
::
exception
&
ex
)
{
isc_throw
(
DbOperationError
,
"Could not create bind array from Host: "
...
...
@@ -524,6 +534,15 @@ public:
bind_
[
12
].
length
=
&
dhcp4_boot_file_name_length_
;
bind_
[
12
].
is_null
=
&
dhcp4_boot_file_name_null_
;
// auth_key_
auth_key_null_
=
MLM_FALSE
;
auth_key_length_
=
sizeof
(
auth_key_
);
bind_
[
13
].
buffer_type
=
MYSQL_TYPE_STRING
;
bind_
[
13
].
buffer
=
reinterpret_cast
<
char
*>
(
auth_key_
);
bind_
[
13
].
buffer_length
=
auth_key_length_
;
bind_
[
13
].
length
=
&
auth_key_length_
;
bind_
[
13
].
is_null
=
&
auth_key_null_
;
// Add the error flags
setErrorIndicators
(