lease_mgr.cc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2012-2013, 2015 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <config.h>
  15. #include <dhcpsrv/lease_mgr.h>
  16. #include <exceptions/exceptions.h>
  17. #include <boost/foreach.hpp>
  18. #include <boost/algorithm/string.hpp>
  19. #include <algorithm>
  20. #include <iostream>
  21. #include <iterator>
  22. #include <map>
  23. #include <sstream>
  24. #include <string>
  25. #include <time.h>
  26. using namespace std;
  27. namespace isc {
  28. namespace dhcp {
  29. const time_t LeaseMgr::MAX_DB_TIME = 2147483647;
  30. Lease6Ptr
  31. LeaseMgr::getLease6(Lease::Type type, const DUID& duid,
  32. uint32_t iaid, SubnetID subnet_id) const {
  33. Lease6Collection col = getLeases6(type, duid, iaid, subnet_id);
  34. if (col.size() > 1) {
  35. isc_throw(MultipleRecords, "More than one lease found for type "
  36. << static_cast<int>(type) << ", duid "
  37. << duid.toText() << ", iaid " << iaid
  38. << " and subnet-id " << subnet_id);
  39. }
  40. if (col.empty()) {
  41. return (Lease6Ptr());
  42. }
  43. return (*col.begin());
  44. }
  45. std::string
  46. LeaseMgr::getDBVersion() {
  47. isc_throw(NotImplemented, "LeaseMgr::getDBVersion() called");
  48. }
  49. } // namespace isc::dhcp
  50. } // namespace isc