20 : server_type_(server_type), config_(config), subnet_ids_() {
27 for (
auto const& subnet : *
CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll()) {
28 conditionallyApplySubnetFilter(subnet);
31 for (
auto const& subnet : *
CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll()) {
32 conditionallyApplySubnetFilter(subnet);
39 return (subnet_ids_.empty() || subnet_ids_.count(lease->subnet_id_));
43LeaseSyncFilter::conditionallyApplySubnetFilter(
const SubnetPtr& subnet) {
46 if (!server_name.empty()) {
47 for (
auto const& peer : config_->getAllServersConfig()) {
48 if (peer.first == server_name) {
49 subnet_ids_.insert(subnet->getID());
static CfgMgr & instance()
returns a single instance of Configuration Manager
static std::string getSubnetServerName(const dhcp::SubnetPtr &subnet)
Convenience function extracting a value of the ha-server-name parameter from a subnet context.
void apply()
Applies filtering rules based on the current server configuration.
LeaseSyncFilter(const HAServerType &server_type, const HAConfigPtr &config)
Constructor.
bool shouldSync(const dhcp::LeasePtr &lease) const
Checks if the lease should be accepted or discarded.
boost::shared_ptr< Subnet > SubnetPtr
A generic pointer to either Subnet4 or Subnet6 object.
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
boost::shared_ptr< HAConfig > HAConfigPtr
Pointer to the High Availability configuration structure.
HAServerType
Lists possible server types for which HA service is created.
Defines the logger used by the top-level component of kea-lfc.