1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 | // Copyright (C) 2018-2022 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 CFG_CONSISTENCY_H
#define CFG_CONSISTENCY_H
#include <cc/cfg_to_element.h>
#include <cc/user_context.h>
namespace isc {
namespace dhcp {
/// @brief Parameters for various consistency checks.
///
class CfgConsistency : public isc::data::UserContext, public isc::data::CfgToElement {
public:
/// @brief Values for subnet-id sanity checks done for leases.
enum LeaseSanity {
LEASE_CHECK_NONE, // Skip sanity checks
LEASE_CHECK_WARN, // Print a warning if subnet-id is incorrect.
LEASE_CHECK_FIX, // If subnet-id is incorrect, try to fix it (try to pick
// appropriate subnet, but if it fails, keep the lease,
// despite its broken subnet-id.
LEASE_CHECK_FIX_DEL, // If subnet-id is incorrect, try to fix it (try to pick
// appropriate subnet. If it fails, delete broken lease.
LEASE_CHECK_DEL // Delete leases with invalid subnet-id.
};
/// @brief Values for extended info sanity checks done for leases.
enum ExtendedInfoSanity {
EXTENDED_INFO_CHECK_NONE, // Skip sanity checks.
EXTENDED_INFO_CHECK_FIX, // Fix extended info common inconsistencies.
EXTENDED_INFO_CHECK_STRICT, // Fix extended info inconsistencies which
// have an impact for Bulk Lease Query.
EXTENDED_INFO_CHECK_PEDANTIC // Fix all extended info inconsistencies.
};
/// @brief Constructor
CfgConsistency()
: lease_sanity_check_(LEASE_CHECK_NONE),
extended_info_sanity_check_(EXTENDED_INFO_CHECK_FIX) {
}
/// @brief Returns JSON representation
///
/// @return Element pointer
virtual isc::data::ElementPtr toElement() const;<--- Function in derived class
/// @brief Sets specific sanity checks mode for leases.
///
/// @param l sanity checks mode
void setLeaseSanityCheck(LeaseSanity l) {
lease_sanity_check_ = l;
}
/// @brief Returns specific sanity checks mode for leases.
///
/// @return sanity checks mode
LeaseSanity getLeaseSanityCheck() const {
return (lease_sanity_check_);
}
/// @brief Converts lease sanity check value to printable text.
///
/// @param check_type sanity mode to be converted
static std::string sanityCheckToText(LeaseSanity check_type);
/// @brief Sets specific sanity checks mode for extended info.
///
/// @param l sanity checks mode
void setExtendedInfoSanityCheck(ExtendedInfoSanity l) {
extended_info_sanity_check_ = l;
}
/// @brief Returns specific sanity checks mode for extended info.
///
/// @return sanity checks mode
ExtendedInfoSanity getExtendedInfoSanityCheck() const {
return (extended_info_sanity_check_);
}
/// @brief Converts extended info sanity check value to printable text.
///
/// @param check_type sanity mode to be converted
static std::string sanityCheckToText(ExtendedInfoSanity check_type);
private:
/// @brief lease sanity checks mode.
LeaseSanity lease_sanity_check_;
/// @brief extended info sanity checks mode.
ExtendedInfoSanity extended_info_sanity_check_;
};
/// @brief Type used to for pointing to CfgConsistency structure
typedef boost::shared_ptr<CfgConsistency> CfgConsistencyPtr;
/// @brief Type used to for pointing to const CfgConsistency structure
typedef boost::shared_ptr<const CfgConsistency> ConstCfgConsistencyPtr;
} // namespace isc::dhcp
} // namespace isc
#endif /* CFG_CONSISTENCY_H */
|