/// @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:
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_);
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.
/// 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_);
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