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
Sebastian Schrader
Kea
Commits
46918f31
Commit
46918f31
authored
Oct 13, 2014
by
Marcin Siodelski
Browse files
[3560] Added new accessors and modifiers to the Host class.
parent
a3530098
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/host.h
View file @
46918f31
...
...
@@ -113,7 +113,7 @@ typedef std::pair<IPv6ResrvIterator, IPv6ResrvIterator> IPv6ResrvRange;
/// @brief Represents a device with IPv4 and/or IPv6 reservations.
///
/// This class represents a
device in the
network which can be identified
/// This class represents a network
device
which can be identified
/// by the unique property, such as MAC address on the interface or
/// client identifier (DUID), and for which some resources are statically
/// assigned:
...
...
@@ -260,6 +260,20 @@ public:
return
(
duid_
);
}
/// @brief Sets new IPv4 subnet identifier.
///
/// @param ipv4_subnet_id New subnet identifier.
void
setIPv4SubnetID
(
const
SubnetID
ipv4_subnet_id
)
{
ipv4_subnet_id_
=
ipv4_subnet_id
;
}
/// @brief Sets new IPv6 subnet identifier.
///
/// @param ipv6_subnet_id New subnet identifier.
void
setIPv6SubnetID
(
const
SubnetID
ipv6_subnet_id
)
{
ipv6_subnet_id_
=
ipv6_subnet_id
;
}
/// @brief Returns subnet identifier for IPv4 reservation.
SubnetID
getIPv4SubnetID
()
const
{
return
(
ipv4_subnet_id_
);
...
...
@@ -270,6 +284,15 @@ public:
return
(
ipv6_subnet_id_
);
}
/// @brief Sets new IPv4 reservation.
///
/// The new reservation removes a previous reservation.
///
/// @param address Address to be reserved for the client.
void
setIPv4Reservation
(
const
asiolink
::
IOAddress
&
address
)
{
ipv4_reservation_
=
address
;
}
/// @brief Returns reserved IPv4 address.
///
/// @return IPv4 address or 0.0.0.0 if no IPv4 reservation specified.
...
...
@@ -290,6 +313,13 @@ public:
/// the specified type.
IPv6ResrvRange
getIPv6Reservations
(
const
IPv6Resrv
::
Type
&
type
)
const
;
/// @brief Sets new hostname.
///
/// @param hostname New hostname.
void
setHostname
(
const
std
::
string
&
hostname
)
{
hostname_
=
hostname
;
}
/// @brief Returns reserved hostname.
const
std
::
string
&
getHostname
()
const
{
return
(
hostname_
);
...
...
src/lib/dhcpsrv/tests/host_unittest.cc
View file @
46918f31
...
...
@@ -341,5 +341,25 @@ TEST(HostTest, addReservations) {
prefixes
));
}
// This test checks that various modifiers may be used to replace the current
// values of the Host class.
TEST
(
HostTest
,
setValues
)
{
boost
::
scoped_ptr
<
Host
>
host
;
ASSERT_NO_THROW
(
host
.
reset
(
new
Host
(
"01:02:03:04:05:06"
,
"hw-address"
,
SubnetID
(
1
),
SubnetID
(
2
),
IOAddress
(
"192.0.2.3"
))));
ASSERT_EQ
(
1
,
host
->
getIPv4SubnetID
());
ASSERT_EQ
(
2
,
host
->
getIPv6SubnetID
());
ASSERT_EQ
(
"192.0.2.3"
,
host
->
getIPv4Reservation
().
toText
());
host
->
setIPv4SubnetID
(
SubnetID
(
123
));
host
->
setIPv6SubnetID
(
SubnetID
(
234
));
host
->
setIPv4Reservation
(
IOAddress
(
"10.0.0.1"
));
EXPECT_EQ
(
123
,
host
->
getIPv4SubnetID
());
EXPECT_EQ
(
234
,
host
->
getIPv6SubnetID
());
EXPECT_EQ
(
"10.0.0.1"
,
host
->
getIPv4Reservation
().
toText
());
}
}
// end of anonymous namespace
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment