writable_host_data_source.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // Copyright (C) 2014-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. #ifndef WRITABLE_HOST_DATA_SOURCE_H
  7. #define WRITABLE_HOST_DATA_SOURCE_H
  8. namespace isc {
  9. namespace dhcp {
  10. /// @brief Interface for retrieving writable host reservations.
  11. ///
  12. /// This interface specifies the methods which return pointers to the
  13. /// @c Host objects, which can be modified. Deriving from this interface
  14. /// is needed if the class implementation must return the pointers to the
  15. /// objects which may be modified by the caller. Such classes usually
  16. /// also derive from the @c BaseHostDataSource to implement methods which
  17. /// return the const objects.
  18. class WritableHostDataSource {
  19. public:
  20. /// @brief Default destructor implementation.
  21. virtual ~WritableHostDataSource() { }
  22. /// @brief Non-const version of the @c getAll const method.
  23. ///
  24. /// Specifying both hardware address and DUID is allowed for this method
  25. /// and results in returning all objects that are associated with hardware
  26. /// address OR duid. For example: if one host is associated with the
  27. /// specified hardware address and another host is associated with the
  28. /// specified DUID, two hosts will be returned.
  29. ///
  30. /// @param hwaddr HW address of the client or NULL if no HW address
  31. /// available.
  32. /// @param duid client id or NULL if not available, e.g. DHCPv4 client case.
  33. ///
  34. /// @return Collection of non-const @c Host objects.
  35. virtual HostCollection
  36. getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid = DuidPtr()) = 0;
  37. /// @brief Non-const version of the @c getAll const method.
  38. ///
  39. /// This method returns all @c Host objects which represent reservations
  40. /// for a specified identifier. This method may return multiple hosts
  41. /// because a particular client may have reservations in multiple subnets.
  42. ///
  43. /// @param identifier_type Identifier type.
  44. /// @param identifier_begin Pointer to a begining of a buffer containing
  45. /// an identifier.
  46. /// @param identifier_len Identifier length.
  47. ///
  48. /// @return Collection of non-const @c Host objects.
  49. virtual HostCollection
  50. getAll(const Host::IdentifierType& identifier_type,
  51. const uint8_t* identifier_begin,
  52. const size_t identifier_len) = 0;
  53. /// @brief Returns a collection of hosts using the specified IPv4 address.
  54. ///
  55. /// This method may return multiple @c Host objects if they are connected
  56. /// to different subnets.
  57. ///
  58. /// @param address IPv4 address for which the @c Host object is searched.
  59. ///
  60. /// @return Collection of @c Host objects.
  61. virtual HostCollection
  62. getAll4(const asiolink::IOAddress& address) = 0;
  63. /// @brief Returns a host connected to the IPv4 subnet.
  64. ///
  65. /// Implementations of this method should guard against the case when
  66. /// mutliple instances of the @c Host are present, e.g. when two
  67. /// @c Host objects are found, one for the DUID, another one for the
  68. /// HW address. In such case, an implementation of this method
  69. /// should throw an exception.
  70. ///
  71. /// @param subnet_id Subnet identifier.
  72. /// @param hwaddr HW address of the client or NULL if no HW address
  73. /// available.
  74. /// @param duid client id or NULL if not available.
  75. ///
  76. /// @return Non-const @c Host object using a specified HW address or DUID.
  77. virtual HostPtr
  78. get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
  79. const DuidPtr& duid = DuidPtr()) = 0;
  80. /// @brief Returns a host connected to the IPv4 subnet.
  81. ///
  82. /// @param subnet_id Subnet identifier.
  83. /// @param identifier_type Identifier type.
  84. /// @param identifier_begin Pointer to a begining of a buffer containing
  85. /// an identifier.
  86. /// @param identifier_len Identifier length.
  87. ///
  88. /// @return Non-const @c Host object for which reservation has been made
  89. /// using the specified identifier.
  90. virtual HostPtr
  91. get4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
  92. const uint8_t* identifier_begin, const size_t identifier_len) = 0;
  93. /// @brief Returns a host connected to the IPv6 subnet.
  94. ///
  95. /// Implementations of this method should guard against the case when
  96. /// mutliple instances of the @c Host are present, e.g. when two
  97. /// @c Host objects are found, one for the DUID, another one for the
  98. /// HW address. In such case, an implementation of this method
  99. /// should throw an exception.
  100. ///
  101. /// @param subnet_id Subnet identifier.
  102. /// @param hwaddr HW address of the client or NULL if no HW address
  103. /// available.
  104. /// @param duid DUID or NULL if not available.
  105. ///
  106. /// @return Non-const @c Host object using a specified HW address or DUID.
  107. virtual HostPtr
  108. get6(const SubnetID& subnet_id, const DuidPtr& duid,
  109. const HWAddrPtr& hwaddr = HWAddrPtr()) = 0;
  110. /// @brief Returns a host connected to the IPv6 subnet.
  111. ///
  112. /// @param subnet_id Subnet identifier.
  113. /// @param identifier_type Identifier type.
  114. /// @param identifier_begin Pointer to a begining of a buffer containing
  115. /// an identifier.
  116. /// @param identifier_len Identifier length.
  117. ///
  118. /// @return Non-const @c Host object for which reservation has been made
  119. /// using the specified identifier.
  120. virtual HostPtr
  121. get6(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
  122. const uint8_t* identifier_begin, const size_t identifier_len) = 0;
  123. /// @brief Returns a host using the specified IPv6 prefix.
  124. ///
  125. /// @param prefix IPv6 prefix for which the @c Host object is searched.
  126. /// @param prefix_len IPv6 prefix length.
  127. ///
  128. /// @return Non-const @c Host object using a specified HW address or DUID.
  129. virtual HostPtr
  130. get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) = 0;
  131. };
  132. }
  133. }
  134. #endif // WRITABLE_HOST_DATA_SOURCE_H