38 clocked_in_times_by_class_.clear();
39 clocked_in_times_by_subnet_id_.clear();
61 if (user_context_source) {
62 user_context =
copy(user_context_source, 0);
75 user_context->set(
"ISC", isc);
78 isc->set(
"client-classes", classes.
toElement());
81 lease->setContext(user_context);
87 address_limit_configuration_.parse(
config);
88 prefix_limit_configuration_.parse(
config);
89 rate_limit_configuration_.parse(
config);
98 for (
auto const& c : classes) {
104 auto const& limit_cfg = address_limit_configuration_.
parseUserContext(class_def->getContext());
106 int64_t
const limit_candidate(limit_cfg->intValue());
107 checkForLimitBoundaries<LeaseLimit>(limit_candidate);
114 result->add(element);
127 auto get_configuration = [&]() -> Configuration<LeaseLimit>& {
129 return (prefix_limit_configuration_);
131 return (address_limit_configuration_);
135 auto& config = get_configuration();
137 for (
auto const& c : classes) {
143 auto& limit_cfg = config.parseUserContext(class_def->getContext());
145 int64_t
const limit_candidate(limit_cfg->intValue());
146 checkForLimitBoundaries<LeaseLimit>(limit_candidate);
153 result->add(element);
162LimitManager::subnetLimitToElement<DHCPv4>(
SubnetID const subnet_id,
168 auto const& limit_cfg = address_limit_configuration_.parseUserContext(subnet_cfg->getContext());
170 int64_t
const limit_candidate(limit_cfg->intValue());
171 checkForLimitBoundaries<LeaseLimit>(limit_candidate);
185LimitManager::subnetLimitToElement<DHCPv6>(
SubnetID const subnet_id,
189 std::string limit_name;
190 auto get_configuration = [&]() -> Configuration<LeaseLimit>& {
192 limit_name = std::string(
"prefix-limit");
193 return (prefix_limit_configuration_);
195 limit_name = std::string(
"address-limit");
196 return (address_limit_configuration_);
200 auto& config = get_configuration();
204 auto const& limit_cfg = config.parseUserContext(subnet_cfg->getContext());
206 int64_t
const limit_candidate(limit_cfg->intValue());
207 checkForLimitBoundaries<LeaseLimit>(limit_candidate);
221LimitManager::subnetRateLimit<DHCPv4>(
SubnetID const subnet_id) {
226 limit = rate_limit_configuration_.parseUserContext(subnet_cfg->getContext());
234LimitManager::subnetRateLimit<DHCPv6>(
SubnetID const subnet_id) {
239 limit = rate_limit_configuration_.parseUserContext(subnet_cfg->getContext());
247LimitManager::checkLeaseLimits<DHCPv4>(
ConstElementPtr const& context)
const {
253LimitManager::checkLeaseLimits<DHCPv6>(
ConstElementPtr const& context)
const {
259LimitManager::recountClassLeases<DHCPv4>()
const {
267LimitManager::recountClassLeases<DHCPv6>()
const {
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Defines elements for storing the names of client classes.
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Container for storing client class names.
virtual isc::data::ElementPtr toElement() const
Returns all class names as an ElementPtr of type ListElement.
static TrackingLeaseMgr & instance()
Return current lease manager.
virtual void recountClassLeases4()=0
Recount the leases per class for V4 leases.
virtual void recountClassLeases6()=0
Recount the leases per class for V6 leases.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< SrvConfig > SrvConfigPtr
Non-const pointer to the SrvConfig.
boost::multi_index_container< SubClassRelation, boost::multi_index::indexed_by< boost::multi_index::sequenced< boost::multi_index::tag< TemplateClassSequenceTag > >, boost::multi_index::hashed_unique< boost::multi_index::tag< TemplateClassNameTag >, boost::multi_index::member< SubClassRelation, ClientClass, &SubClassRelation::class_def_ > > > > SubClassRelationContainer
the subclass multi-index.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
uint32_t LeaseLimit
a single lease-limiting entry configured as an integer
Defines the logger used by the top-level component of kea-lfc.
Type
Type of lease or pool.
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
isc::data::ConstElementPtr const parseUserContext(isc::data::ConstElementPtr const &user_context) const
Abstract method that takes a user context from any configuration element and returns the value of the...
Provides the capability to limit the number of leases or the response rate.
void parse(isc::dhcp::SrvConfigPtr const &config)
Fetches limits from the given Kea configuration.
void clear()
Clears the time series circular buffers in order to start over rate limiting.
void initialize(isc::dhcp::SrvConfigPtr const &config)
Reinitialize data structures required for limiting.
static LimitManager & instance()
singleton access function