writable_host_data_source.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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_begin Pointer to a begining of a buffer containing
  44. /// an identifier.
  45. /// @param identifier_len Identifier length.
  46. ///
  47. /// @return Collection of non-const @c Host objects.
  48. virtual HostCollection
  49. getAll(const Host::IdentifierType& identifier_type,
  50. const uint8_t* identifier_begin,
  51. const size_t identifier_len) = 0;
  52. /// @brief Returns a collection of hosts using the specified IPv4 address.
  53. ///
  54. /// This method may return multiple @c Host objects if they are connected
  55. /// to different subnets.
  56. ///
  57. /// @param address IPv4 address for which the @c Host object is searched.
  58. ///
  59. /// @return Collection of @c Host objects.
  60. virtual HostCollection
  61. getAll4(const asiolink::IOAddress& address) = 0;
  62. /// @brief Returns a host connected to the IPv4 subnet.
  63. ///
  64. /// Implementations of this method should guard against the case when
  65. /// mutliple instances of the @c Host are present, e.g. when two
  66. /// @c Host objects are found, one for the DUID, another one for the
  67. /// HW address. In such case, an implementation of this method
  68. /// should throw an exception.
  69. ///
  70. /// @param subnet_id Subnet identifier.
  71. /// @param hwaddr HW address of the client or NULL if no HW address
  72. /// available.
  73. /// @param duid client id or NULL if not available.
  74. ///
  75. /// @return Non-const @c Host object using a specified HW address or DUID.
  76. virtual HostPtr
  77. get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
  78. const DuidPtr& duid = DuidPtr()) = 0;
  79. /// @brief Returns a host connected to the IPv4 subnet.
  80. ///
  81. /// @param subnet_id Subnet identifier.
  82. /// @param identifier_type Identifier type.
  83. /// @param identifier_begin Pointer to a begining of a buffer containing
  84. /// an identifier.
  85. /// @param identifier_len Identifier length.
  86. ///
  87. /// @return Non-const @c Host object for which reservation has been made
  88. /// using the specified identifier.
  89. virtual HostPtr
  90. get4(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
  91. const uint8_t* identifier_begin, const size_t identifier_len) = 0;
  92. /// @brief Returns a host connected to the IPv6 subnet.
  93. ///
  94. /// Implementations of this method should guard against the case when
  95. /// mutliple instances of the @c Host are present, e.g. when two
  96. /// @c Host objects are found, one for the DUID, another one for the
  97. /// HW address. In such case, an implementation of this method
  98. /// should throw an exception.
  99. ///
  100. /// @param subnet_id Subnet identifier.
  101. /// @param hwaddr HW address of the client or NULL if no HW address
  102. /// available.
  103. /// @param duid DUID or NULL if not available.
  104. ///
  105. /// @return Non-const @c Host object using a specified HW address or DUID.
  106. virtual HostPtr
  107. get6(const SubnetID& subnet_id, const DuidPtr& duid,
  108. const HWAddrPtr& hwaddr = HWAddrPtr()) = 0;
  109. /// @brief Returns a host connected to the IPv6 subnet.
  110. ///
  111. /// @param subnet_id Subnet identifier.
  112. /// @param identifier_type Identifier type.
  113. /// @param identifier_begin Pointer to a begining of a buffer containing
  114. /// an identifier.
  115. /// @param identifier_len Identifier length.
  116. ///
  117. /// @return Non-const @c Host object for which reservation has been made
  118. /// using the specified identifier.
  119. virtual HostPtr
  120. get6(const SubnetID& subnet_id, const Host::IdentifierType& identifier_type,
  121. const uint8_t* identifier_begin, const size_t identifier_len) = 0;
  122. /// @brief Returns a host using the specified IPv6 prefix.
  123. ///
  124. /// @param prefix IPv6 prefix for which the @c Host object is searched.
  125. /// @param prefix_len IPv6 prefix length.
  126. ///
  127. /// @return Non-const @c Host object using a specified HW address or DUID.
  128. virtual HostPtr
  129. get6(const asiolink::IOAddress& prefix, const uint8_t prefix_len) = 0;
  130. };
  131. }
  132. }
  133. #endif // WRITABLE_HOST_DATA_SOURCE_H