29 char const* pkt_per(
" packets per ");
30 size_t index(text.find(pkt_per));
31 if (index == text.npos) {
32 pkt_per =
" packet per ";
33 index = text.find(pkt_per);
34 if (index == text.npos) {
36 "expected rate limit of format <n> packet[s] per <time-unit>, got: " << text);
41 int64_t
const allowed_packets(stoll(text.substr(0, index)));
42 checkForLimitBoundaries<decltype(allowed_packets_)>(allowed_packets);
46 string const time_period(text.substr(index + strlen(pkt_per)));
47 if (time_period ==
"second") {
49 }
else if (time_period ==
"minute") {
51 }
else if (time_period ==
"hour") {
53 }
else if (time_period ==
"day") {
55 }
else if (time_period ==
"week") {
57 }
else if (time_period ==
"month") {
59 }
else if (time_period ==
"year") {
73 static std::string limit_str(
"address-limit");
84 int64_t
const limit_candidate(limit->intValue());
85 checkForLimitBoundaries<LeaseLimit>(limit_candidate);
99 int64_t
const limit_candidate(limit->intValue());
100 checkForLimitBoundaries<LeaseLimit>(limit_candidate);
103 .arg(limit_candidate)
111 static std::string limit_str (
"prefix-limit");
122 int64_t
const limit_candidate(limit->intValue());
123 checkForLimitBoundaries<LeaseLimit>(limit_candidate);
126 .arg(limit_candidate)
137 int64_t
const limit_candidate(limit->intValue());
138 checkForLimitBoundaries<LeaseLimit>(limit_candidate);
141 .arg(limit_candidate)
149 static std::string limit_str(
"rate-limit");
160 string const& limit_candidate = limit->stringValue();
164 .arg(limit_candidate)
175 string const& limit_candidate = limit->stringValue();
179 .arg(limit_candidate)
An exception that is thrown if an error occurs while configuring any server.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< const Element > ConstElementPtr
std::string ClientClass
Defines a single class name.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
const isc::log::MessageID LIMITS_CONFIGURED_PREFIX_LIMIT_BY_SUBNET
const isc::log::MessageID LIMITS_CONFIGURED_ADDRESS_LIMIT_BY_SUBNET
const isc::log::MessageID LIMITS_CONFIGURED_RATE_LIMIT_BY_SUBNET
const isc::log::MessageID LIMITS_CONFIGURED_RATE_LIMIT_BY_CLIENT_CLASS
const isc::log::MessageID LIMITS_CONFIGURED_ADDRESS_LIMIT_BY_CLIENT_CLASS
const isc::log::MessageID LIMITS_CONFIGURED_PREFIX_LIMIT_BY_CLIENT_CLASS
isc::log::Logger limits_logger("limits-hooks")
const int DBGLVL_TRACE_BASIC
Trace basic operations.
Defines the logger used by the top-level component of kea-lfc.
virtual void logClientClassLimit(isc::dhcp::ClientClass const &client_class, isc::data::ConstElementPtr const &user_context) override
Method that checks and logs limit which is to be applied to a client class.
virtual void logSubnetLimit(isc::dhcp::SubnetID const subnet_id, isc::data::ConstElementPtr const &user_context) override
Method that checks and logs limit which is to be applied to a client class.
const std::string & key() const override
Returns the key required to configure the limit in the user context.
virtual void logClientClassLimit(isc::dhcp::ClientClass const &client_class, isc::data::ConstElementPtr const &user_context) override
Method that checks and logs limit which is to be applied to a client class.
virtual void logSubnetLimit(isc::dhcp::SubnetID const subnet_id, isc::data::ConstElementPtr const &user_context) override
Method that checks and logs limit which is to be applied to a client class.
const std::string & key() const override
Returns the key required to configure the limit in the user context.
virtual void logClientClassLimit(isc::dhcp::ClientClass const &client_class, isc::data::ConstElementPtr const &user_context) override
Method that checks and logs limit which is to be applied to a client class.
const std::string & key() const override
Returns the key required to configure the limit in the user context.
virtual void logSubnetLimit(isc::dhcp::SubnetID const subnet_id, isc::data::ConstElementPtr const &user_context) override
Method that checks and logs limit which is to be applied to a client class.
a single rate-limiting entry configured as "rate-limit": "<n> packet[s] per <time-unit>"
std::string text_
a string representation of the rate limit as specified in the configuration used for logging purposes
std::chrono::seconds time_unit_
Seconds of one time unit's worth.
uint32_t allowed_packets_
the configured limit