cfg_host_operations.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright (C) 2016-2017 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. #ifndef CFG_HOST_OPERATIONS_H
  7. #define CFG_HOST_OPERATIONS_H
  8. #include <cc/cfg_to_element.h>
  9. #include <dhcpsrv/host.h>
  10. #include <boost/shared_ptr.hpp>
  11. #include <list>
  12. #include <string>
  13. namespace isc {
  14. namespace dhcp {
  15. /// @brief Forward declaration of the @ref CfgHostOperations.
  16. class CfgHostOperations;
  17. /// @name Pointers to the @ref CfgHostOperations objects.
  18. //@{
  19. /// @brief Pointer to the Non-const object.
  20. typedef boost::shared_ptr<CfgHostOperations> CfgHostOperationsPtr;
  21. /// @brief Pointer to the const object.
  22. typedef boost::shared_ptr<const CfgHostOperations>
  23. ConstCfgHostOperationsPtr;
  24. //@}
  25. /// @brief Represents global configuration for host reservations.
  26. ///
  27. /// This class represents server configuration pertaining to host
  28. /// reservations.
  29. ///
  30. /// Currently it only holds the ordered list of host identifiers
  31. /// to be used to search for reservations for a particular host.
  32. /// An administrator selects which identifiers the server should
  33. /// use and in which order to search for host reservations to
  34. /// optimize performance of the server.
  35. class CfgHostOperations : public isc::data::CfgToElement {
  36. public:
  37. /// @brief Type of the container holding ordered list of identifiers.
  38. typedef std::list<Host::IdentifierType> IdentifierTypes;
  39. /// @brief Constructor.
  40. ///
  41. /// The default confguration:
  42. /// - no identifiers selected for host reservations searches.
  43. CfgHostOperations();
  44. /// @name Factory functions for creating default configurations.
  45. //@{
  46. /// @brief Factory function for DHCPv4.
  47. static CfgHostOperationsPtr createConfig4();
  48. /// @brief Factory function for DHCPv6.
  49. static CfgHostOperationsPtr createConfig6();
  50. //@}
  51. /// @brief Adds new identifier type to a collection of identifiers
  52. /// to be used by the server to search for host reservations.
  53. ///
  54. /// @param identifier_name Name of the identifier to be added. It
  55. /// must be one of the names supported by the @ref Host::getIdentifierType
  56. /// function.
  57. void addIdentifierType(const std::string& identifier_name);
  58. /// @brief Returns const reference to ordered collection of identifiers
  59. /// to be used by the server to search for host reservations.
  60. const IdentifierTypes& getIdentifierTypes() const {
  61. return (identifier_types_);
  62. }
  63. /// @brief Removes existing identifier types.
  64. void clearIdentifierTypes();
  65. /// @brief Unparse a configuration objet
  66. ///
  67. /// @return a pointer to unparsed configuration
  68. virtual isc::data::ElementPtr toElement() const;
  69. private:
  70. /// @brief Holds ordered collection of identifiers to be used by the
  71. /// server to search for host reservations for a client.
  72. IdentifierTypes identifier_types_;
  73. };
  74. }
  75. }
  76. #endif // CFG_HOST_OPERATIONS_H