diff options
author | Tomek Mrugalski <tomasz@isc.org> | 2018-07-24 20:41:07 +0200 |
---|---|---|
committer | Tomek Mrugalski <tomasz@isc.org> | 2018-07-30 19:03:18 +0200 |
commit | 5bf6881bbf1013fecaee446066433ec10e8d2b9b (patch) | |
tree | ec084766a55843af4ff4380424d5d1406e5e7f85 /src/lib/dhcpsrv/sanity_checker.h | |
parent | [master] ChangeLog updated after 5680 merge. (diff) | |
download | kea-5bf6881bbf1013fecaee446066433ec10e8d2b9b.tar.xz kea-5bf6881bbf1013fecaee446066433ec10e8d2b9b.zip |
[5682] Consistency checks implemented in libdhcpsrv
Diffstat (limited to 'src/lib/dhcpsrv/sanity_checker.h')
-rw-r--r-- | src/lib/dhcpsrv/sanity_checker.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/lib/dhcpsrv/sanity_checker.h b/src/lib/dhcpsrv/sanity_checker.h new file mode 100644 index 0000000000..6cc46bc59d --- /dev/null +++ b/src/lib/dhcpsrv/sanity_checker.h @@ -0,0 +1,73 @@ +// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef SANITY_CHECKER_H +#define SANITY_CHECKER_H + +#include <dhcpsrv/lease.h> +#include <dhcpsrv/cfg_consistency.h> + +namespace isc { +namespace dhcp { + +/// @brief Code used to conduct various sanity checks. Currently used for leases. +/// +/// This class is expected to be used as a simple interface sanity checker for +/// various run-time and configuration elements. Currently is provides sanity +/// checking and correction for subnet-id parameter in leases. +class SanityChecker { + public: + + /// @brief Sanity checks and possibly corrects an IPv4 lease + /// + /// Depending on the sanity-checks/lease-checks parameter value (see + /// @ref CfgConsistency for details), this code may print a warning, + /// correct subnet-id or discard the lease. + /// + /// @param lease Lease to be sanity-checked + void checkLease(Lease4Ptr& lease); + + /// @brief Sanity checks and possibly corrects an IPv4 lease + /// + /// Depending on the sanity-checks/lease-checks parameter value (see + /// @ref CfgConsistency for details), this code may print a warning, + /// correct subnet-id or discard the lease. + /// + /// @param lease Lease to be sanity-checked + void checkLease(Lease6Ptr& lease); + + private: + + /// @brief Internal implementation for checkLease command + /// + /// @tparam LeaseType type of the lease (Lease4Ptr or Lease6Ptr) + /// @tparam SubnetsType type of the subnets container (CfgSubnets4Ptr or + /// CfgSubnets6Ptr) + /// @param lease a lease to be checked/corrected + /// @param checks a pointer to CfgConsistency structure (type of checks + /// specified here) + /// @param subnets configuration structure with subnets + template<typename LeaseType, typename SubnetsType> + void checkLeaseInternal(LeaseType lease, const CfgConsistencyPtr& checks, + const SubnetsType& subnets); + + /// @brief Internal method for finding appropriate subnet-id + /// + /// @tparam LeaseType type of the lease (Lease4Ptr or Lease6Ptr) + /// @tparam SubnetsType type of the subnets container (CfgSubnets4Ptr or + /// CfgSubnets6Ptr) + /// @param lease a lease to be checked/corrected + /// @param subnets configuration structure with subnets + template<typename LeaseType, typename SubnetsType> + SubnetID findSubnetId(const LeaseType& lease, const SubnetsType& subnets); +}; + + +}; +}; + + +#endif /* SANITY_CHECKER_H */ |