cfg_host_reservations.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. #include <exceptions/exceptions.h>
  7. #include <dhcpsrv/cfg_host_reservations.h>
  8. #include <algorithm>
  9. namespace isc {
  10. namespace dhcp {
  11. CfgHostReservations::CfgHostReservations()
  12. : identifier_types_() {
  13. }
  14. CfgHostReservationsPtr
  15. CfgHostReservations::createConfig4() {
  16. CfgHostReservationsPtr cfg(new CfgHostReservations());
  17. cfg->addIdentifierType("hw-address");
  18. cfg->addIdentifierType("duid");
  19. cfg->addIdentifierType("circuit-id");
  20. return (cfg);
  21. }
  22. CfgHostReservationsPtr
  23. CfgHostReservations::createConfig6() {
  24. CfgHostReservationsPtr cfg(new CfgHostReservations());
  25. cfg->addIdentifierType("hw-address");
  26. cfg->addIdentifierType("duid");
  27. return (cfg);
  28. }
  29. void
  30. CfgHostReservations::addIdentifierType(const std::string& identifier_name) {
  31. Host::IdentifierType identifier_type = Host::getIdentifierType(identifier_name);
  32. if (std::find(identifier_types_.begin(), identifier_types_.end(),
  33. identifier_type) != identifier_types_.end()) {
  34. isc_throw(isc::BadValue, "duplicate host identifier '"
  35. << identifier_name << "'");
  36. }
  37. identifier_types_.push_back(identifier_type);
  38. }
  39. void
  40. CfgHostReservations::clear() {
  41. identifier_types_.clear();
  42. }
  43. }
  44. }