ipv6_subnet_id_(ipv6_subnet_id),
ipv4_reservation_(asiolink::IOAddress::IPV4_ZERO_ADDRESS()),
hostname_(hostname), dhcp4_client_classes_(dhcp4_client_classes),
- dhcp6_client_classes_(dhcp6_client_classes) {
+ dhcp6_client_classes_(dhcp6_client_classes), host_id_(0) {
// Initialize HWAddr or DUID
setIdentifier(identifier, identifier_len, identifier_type);
ipv6_subnet_id_(ipv6_subnet_id),
ipv4_reservation_(asiolink::IOAddress::IPV4_ZERO_ADDRESS()),
hostname_(hostname), dhcp4_client_classes_(dhcp4_client_classes),
- dhcp6_client_classes_(dhcp6_client_classes) {
+ dhcp6_client_classes_(dhcp6_client_classes), host_id_(0) {
// Initialize HWAddr or DUID
setIdentifier(identifier, identifier_name);
namespace isc {
namespace dhcp {
+/// @brief HostID (used only when storing in MySQL or Postgres)
+typedef uint64_t HostID;
+
/// @brief IPv6 reservation for a host.
///
/// This class represents a reservation for a host of a single IPv6
/// @brief Returns information about the host in the textual format.
std::string toText() const;
+ /// @brief Sets Host ID (primary key in MySQL and Postgres backends)
+ /// @param id HostId value
+ void setHostId(HostID id) {
+ host_id_ = id;
+ }
+
+ /// @brief Returns Host ID (primary key in MySQL and Postgres backends)
+ /// @return id HostId value (or 0 if not set)
+ HostID getHostId() const {
+ return (host_id_);
+ }
+
private:
/// @brief Adds new client class for DHCPv4 or DHCPv6.
ClientClasses dhcp4_client_classes_;
/// @brief Collection of classes associated with a DHCPv6 client.
ClientClasses dhcp6_client_classes_;
+
+ /// @brief HostID (a unique identifier assigned when the host is stored in
+ /// MySQL or Pgsql)
+ uint64_t host_id_;
};
/// @brief Pointer to the @c Host object.
host->toText());
}
+// Test verifies if the host can store HostId properly.
+TEST(HostTest, hostId) {
+ 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"),
+ "myhost.example.com")));
+ EXPECT_EQ(0, host->getHostId());
+
+ EXPECT_NO_THROW(host->setHostId(12345));
+
+ EXPECT_EQ(12345, host->getHostId());
+}
+
} // end of anonymous namespace