49 checkLeaseInternal(lease, sanity, subnets);
71 checkLeaseInternal(lease, sanity, subnets);
74template<
typename LeasePtrType,
typename SubnetsType>
76 const SubnetsType& subnets) {
78 auto subnet = subnets->getBySubnetId(lease->subnet_id_);
79 if (subnet && subnet->inRange(lease->addr_)) {
88 SubnetID id = findSubnetId(lease, subnets);
91 std::ostringstream msg;
93 msg <<
"the lease should have subnet-id " << id;
95 msg <<
"the lease IP address did not belong to a configured subnet";
98 switch (checks->getLeaseSanityCheck()) {
100 if (lease->subnet_id_ !=
id) {
103 .arg(lease->addr_.toText())
104 .arg(lease->subnet_id_)
110 if (lease->subnet_id_ !=
id) {
115 .arg(lease->addr_.toText())
116 .arg(lease->subnet_id_)
118 lease->subnet_id_ = id;
122 .arg(lease->addr_.toText())
123 .arg(lease->subnet_id_)
130 if (lease->subnet_id_ !=
id) {
135 .arg(lease->addr_.toText())
136 .arg(lease->subnet_id_)
138 lease->subnet_id_ = id;
143 .arg(lease->addr_.toText())
144 .arg(lease->subnet_id_)
153 if (lease->subnet_id_ !=
id) {
155 .arg(lease->addr_.toText())
156 .arg(lease->subnet_id_)
176template<
typename LeaseType,
typename SubnetsType>
177SubnetID SanityChecker::findSubnetId(
const LeaseType& lease,
const SubnetsType& subnets) {
178 auto subnet = subnets->selectSubnet(lease->addr_);
183 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.
#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