54 checkLeaseInternal(lease, sanity, subnets);
76 checkLeaseInternal(lease, sanity, subnets);
79template<
typename LeasePtrType,
typename SubnetsType>
81 const SubnetsType& subnets) {
83 auto subnet = subnets->getBySubnetId(lease->subnet_id_);
84 if (subnet && subnet->inRange(lease->addr_)) {
93 SubnetID id = findSubnetId(lease, subnets);
96 std::ostringstream msg;
98 msg <<
"the lease should have subnet-id " << id;
100 msg <<
"the lease IP address did not belong to a configured subnet";
103 switch (checks->getLeaseSanityCheck()) {
105 if (lease->subnet_id_ !=
id) {
108 .arg(lease->addr_.toText())
109 .arg(lease->subnet_id_)
115 if (lease->subnet_id_ !=
id) {
120 .arg(lease->addr_.toText())
121 .arg(lease->subnet_id_)
123 lease->subnet_id_ = id;
127 .arg(lease->addr_.toText())
128 .arg(lease->subnet_id_)
135 if (lease->subnet_id_ !=
id) {
140 .arg(lease->addr_.toText())
141 .arg(lease->subnet_id_)
143 lease->subnet_id_ = id;
148 .arg(lease->addr_.toText())
149 .arg(lease->subnet_id_)
158 if (lease->subnet_id_ !=
id) {
160 .arg(lease->addr_.toText())
161 .arg(lease->subnet_id_)
181template<
typename LeaseType,
typename SubnetsType>
182SubnetID SanityChecker::findSubnetId(
const LeaseType& lease,
const SubnetsType& subnets) {
183 auto subnet = subnets->selectSubnet(lease->addr_);
188 return (subnet->getID());
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
void checkLease(Lease4Ptr &lease, bool current=true)
Sanity checks and possibly corrects an IPv4 lease.
static bool leaseCheckingEnabled(bool current=true)
Indicates the specified configuration enables lease sanity checking.
static bool getCBRepairMode()
Get the CB repair mode flag.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
const isc::log::MessageID DHCPSRV_LEASE_SANITY_FAIL_DISCARD
const isc::log::MessageID DHCPSRV_LEASE_SANITY_FAIL
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
boost::shared_ptr< CfgSubnets6 > CfgSubnets6Ptr
Non-const pointer.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::shared_ptr< CfgSubnets4 > CfgSubnets4Ptr
Non-const pointer.
boost::shared_ptr< CfgConsistency > CfgConsistencyPtr
Type used to for pointing to CfgConsistency structure.
const isc::log::MessageID DHCPSRV_LEASE_SANITY_FIXED
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Defines the logger used by the top-level component of kea-lfc.
@ TYPE_NA
the lease contains non-temporary IPv6 address