libkea_dhcpsrv_la_SOURCES += d2_client_cfg.cc d2_client_cfg.h
libkea_dhcpsrv_la_SOURCES += d2_client_mgr.cc d2_client_mgr.h
libkea_dhcpsrv_la_SOURCES += daemon.cc daemon.h
- libkea_dhcpsrv_la_SOURCES += dbaccess_parser.cc dbaccess_parser.h
libkea_dhcpsrv_la_SOURCES += dhcpsrv_log.cc dhcpsrv_log.h
- libkea_dhcpsrv_la_SOURCES += dhcp_config_parser.h
- libkea_dhcpsrv_la_SOURCES += dhcp_parsers.cc dhcp_parsers.h
libkea_dhcpsrv_la_SOURCES += host.cc host.h
libkea_dhcpsrv_la_SOURCES += host_container.h
- libkea_dhcpsrv_la_SOURCES += host_reservation_parser.cc host_reservation_parser.h
+libkea_dhcpsrv_la_SOURCES += host_mgr.cc host_mgr.h
libkea_dhcpsrv_la_SOURCES += key_from_key.h
libkea_dhcpsrv_la_SOURCES += lease.cc lease.h
libkea_dhcpsrv_la_SOURCES += lease_mgr.cc lease_mgr.h
libkea_dhcpsrv_la_SOURCES += subnet_selector.h
libkea_dhcpsrv_la_SOURCES += triplet.h
libkea_dhcpsrv_la_SOURCES += utils.h
+libkea_dhcpsrv_la_SOURCES += writable_host_data_source.h
+ # Configuration parsers
+ libkea_dhcpsrv_la_SOURCES += parsers/dhcp_config_parser.h
+ libkea_dhcpsrv_la_SOURCES += parsers/dbaccess_parser.cc
+ libkea_dhcpsrv_la_SOURCES += parsers/dbaccess_parser.h
+ libkea_dhcpsrv_la_SOURCES += parsers/dhcp_parsers.cc
+ libkea_dhcpsrv_la_SOURCES += parsers/dhcp_parsers.h
+ libkea_dhcpsrv_la_SOURCES += parsers/host_reservation_parser.cc
+ libkea_dhcpsrv_la_SOURCES += parsers/host_reservation_parser.h
+ libkea_dhcpsrv_la_SOURCES += parsers/host_reservations_list_parser.h
+
+
nodist_libkea_dhcpsrv_la_SOURCES = dhcpsrv_messages.h dhcpsrv_messages.cc
libkea_dhcpsrv_la_CXXFLAGS = $(AM_CXXFLAGS)
endif
# The message file should be in the distribution
- EXTRA_DIST = dhcpsrv_messages.mes
+ EXTRA_DIST += dhcpsrv_messages.mes
-# Distribute MySQL schema creation script and backend documentation
-EXTRA_DIST += dhcpdb_create.mysql dhcpdb_create.pgsql database_backends.dox libdhcpsrv.dox
-dist_pkgdata_DATA = dhcpdb_create.mysql dhcpdb_create.pgsql
+# Distribute backend documentation
+# Database schema creation script moved to src/bin/admin
+EXTRA_DIST += database_backends.dox libdhcpsrv.dox
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(dhcp_data_dir)
isc_throw(BadValue, "specified host object must not be NULL when it"
" is added to the configuration");
}
-
+ // At least one subnet ID must be non-zero
+ if (host->getIPv4SubnetID() == 0 && host->getIPv6SubnetID() == 0) {
+ isc_throw(BadValue, "must not use both IPv4 and IPv6 subnet ids of"
+ " 0 when adding new host reservation");
+ }
+ /// @todo This may need further sanity checks.
HWAddrPtr hwaddr = host->getHWAddress();
DuidPtr duid = host->getDuid();
+
+ // There should be at least one resource reserved: hostname, IPv4
+ // address, IPv6 address or prefix.
+ if (host->getHostname().empty() &&
+ (host->getIPv4Reservation() == IOAddress("0.0.0.0")) &&
+ (!host->hasIPv6Reservation())) {
+ std::ostringstream s;
+ if (hwaddr) {
+ s << "for DUID: " << hwaddr->toText();
+ } else if (duid) {
+ s << "for HW address: " << duid->toText();
+ }
+ isc_throw(BadValue, "specified reservation " << s
+ << " must include at least one resource, i.e. "
+ "hostname, IPv4 address or IPv6 address/prefix");
+ }
+
// Check for duplicates for the specified IPv4 subnet.
- if (get4(host->getIPv4SubnetID(), hwaddr, duid)) {
+ if ((host->getIPv4SubnetID() > 0) &&
+ get4(host->getIPv4SubnetID(), hwaddr, duid)) {
isc_throw(DuplicateHost, "failed to add new host using the HW"
" address '" << (hwaddr ? hwaddr->toText(false) : "(null)")
<< " and DUID '" << (duid ? duid->toText() : "(null)")
<< "' to the IPv4 subnet id '" << host->getIPv4SubnetID()
<< "' as this host has already been added");
- // Checek for duplicates for the specified IPv6 subnet.
+ // Check for duplicates for the specified IPv6 subnet.
- } else if (get6(host->getIPv6SubnetID(), duid, hwaddr)) {
+ } else if (host->getIPv6SubnetID() &&
+ get6(host->getIPv6SubnetID(), duid, hwaddr)) {
isc_throw(DuplicateHost, "failed to add new host using the HW"
" address '" << (hwaddr ? hwaddr->toText(false) : "(null)")
<< " and DUID '" << (duid ? duid->toText() : "(null)")
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/option_space_container.h>
#include <dhcpsrv/subnet.h>
+ #include <dhcpsrv/parsers/dhcp_config_parser.h>
#include <exceptions/exceptions.h>
+#include <util/optional_value.h>
#include <boost/shared_ptr.hpp>
libdhcpsrv_unittests_SOURCES += d2_udp_unittest.cc
libdhcpsrv_unittests_SOURCES += daemon_unittest.cc
libdhcpsrv_unittests_SOURCES += dbaccess_parser_unittest.cc
+libdhcpsrv_unittests_SOURCES += host_mgr_unittest.cc
libdhcpsrv_unittests_SOURCES += host_unittest.cc
libdhcpsrv_unittests_SOURCES += host_reservation_parser_unittest.cc
+ libdhcpsrv_unittests_SOURCES += host_reservations_list_parser_unittest.cc
libdhcpsrv_unittests_SOURCES += lease_file_io.cc lease_file_io.h
libdhcpsrv_unittests_SOURCES += lease_unittest.cc
libdhcpsrv_unittests_SOURCES += lease_mgr_factory_unittest.cc
// Add a host.
ASSERT_NO_THROW(cfg.add(HostPtr(new Host(hwaddrs_[0]->toText(false),
"hw-address",
- SubnetID(10), SubnetID(1),
+ SubnetID(0), SubnetID(1),
- IOAddress("0.0.0.0")))));
+ IOAddress("0.0.0.0"),
+ "foo.example.com"))));
// Try to add the host with the same HW address to the same subnet. The fact
// that the IP address is different here shouldn't really matter.
EXPECT_THROW(cfg.add(HostPtr(new Host(hwaddrs_[0]->toText(false),
"hw-address",
- SubnetID(11), SubnetID(1),
+ SubnetID(0), SubnetID(1),
- IOAddress("0.0.0.0")))),
+ IOAddress("0.0.0.0"),
+ "foo.example.com"))),
isc::dhcp::DuplicateHost);
// Now try to add it to a different subnet. It should go through.
EXPECT_NO_THROW(cfg.add(HostPtr(new Host(hwaddrs_[0]->toText(false),
"hw-address",
- SubnetID(11), SubnetID(2),
+ SubnetID(0), SubnetID(2),
- IOAddress("0.0.0.0")))));
+ IOAddress("0.0.0.0"),
+ "foo.example.com"))));
}
// This test verifies that it is not possible to add the same Host to the
// Add a host.
ASSERT_NO_THROW(cfg.add(HostPtr(new Host(duids_[0]->toText(),
"duid",
- SubnetID(10), SubnetID(1),
+ SubnetID(0), SubnetID(1),
- IOAddress("0.0.0.0")))));
+ IOAddress("0.0.0.0"),
+ "foo.example.com"))));
// Try to add the host with the same DUID to the same subnet. The fact
// that the IP address is different here shouldn't really matter.
EXPECT_THROW(cfg.add(HostPtr(new Host(duids_[0]->toText(),
"duid",
- SubnetID(11), SubnetID(1),
+ SubnetID(0), SubnetID(1),
- IOAddress("0.0.0.0")))),
+ IOAddress("0.0.0.0"),
+ "foo.example.com"))),
isc::dhcp::DuplicateHost);
// Now try to add it to a different subnet. It should go through.
EXPECT_NO_THROW(cfg.add(HostPtr(new Host(duids_[0]->toText(),
"duid",
- SubnetID(11), SubnetID(2),
+ SubnetID(0), SubnetID(2),
- IOAddress("0.0.0.0")))));
+ IOAddress("0.0.0.0"),
+ "foo.example.com"))));
}