53 std::string expression_str = json->stringValue();
54 if (!expression_str.empty()) {
60 }
catch (
const std::exception& ex) {
75 static_cast<void>(
subnet_exprs_.findExpression(subnet_id, expression));
99 if (subnet->getModificationTime() >
subnet_exprs_.getLastFlushTime()) {
103 found =
subnet_exprs_.findExpression(subnet->getID(), expression);
116 .arg(subnet->toText());
129 auto ctx = subnet->getContext();
136 json = json->get(
"hostname-expr");
143 .arg(json->stringValue())
144 .arg(subnet->toText());
146 }
catch (
const std::exception& ex) {
150 <<
" parsing failed: " << ex.what());
167 if (expression_str.empty()) {
174 }
catch (
const std::exception& ex) {
176 << expression_str <<
"] : " << ex.what());
189 if (!hostname_expr || (hostname_expr->empty())) {
190 return (std::string(
""));
200 if (preserve_global) {
215boost::posix_time::ptime
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown when an unexpected error condition occurs.
void configure(isc::data::ConstElementPtr params)
Configure the Ddns Tuning implementation.
dhcp::ExpressionPtr fetchScopedHostnameExpression(dhcp::ConstSubnetPtr subnet)
Fetches the expression that is in scope for the given subnet.
void flushCache(bool preserve_global=true)
Flushes the cache contents.
~DdnsTuningImpl()
Destructor.
ExpressionCache subnet_exprs_
Per subnet expression cache.
dhcp::ExpressionPtr getHostnameExpression(const dhcp::SubnetID &subnet_id)
Fetches the hostname for a given subnet_id.
void setHostnameExpression(const dhcp::SubnetID &subnet_id, dhcp::ExpressionPtr &expression)
Set the hostname expression for a given subnet.
dhcp::ExpressionPtr parseExpression(const std::string &expression_str) const
Parses an expression string into an Expression.
boost::posix_time::ptime getLastFlushTime()
Fetches the time (in seconds) of when the cache was last flushed.
void setGlobalHostnameExpression(dhcp::ExpressionPtr &expression)
Set the global hostname expression.
dhcp::ExpressionPtr getGlobalHostnameExpression()
Get the global hostname expression.
std::string calculateHostname(dhcp::PktPtr query, dhcp::ConstSubnetPtr subnet)
Calculate the hostname for a packet given a subnet.
dhcp::ExpressionPtr cacheExpression(dhcp::ConstSubnetPtr subnet)
Caches an expression entry for a given subnet.
size_t getCacheSize()
Fetches the number of entries in the cache.
Evaluation context, an interface to the expression evaluation.
bool parseString(const std::string &str, ParserType type=PARSER_BOOL)
Run the parser on the string specified.
@ PARSER_STRING
expression is expected to evaluate to string
isc::dhcp::Expression expression_
Parsed expression (output tokens are stored here)
const isc::log::MessageID DDNS_TUNING_GLOBAL_EXPR_SET
const isc::log::MessageID DDNS_TUNING_SUBNET_EXPRESSION_PARSE
const isc::log::MessageID DDNS_TUNING_SUBNET_EXPR_CACHED
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< const Element > ConstElementPtr
isc::log::Logger ddns_tuning_logger("ddns-tuning-hooks")
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
std::string evaluateString(const Expression &expr, Pkt &pkt)
Evaluate a RPN expression for a v4 or v6 packet and return a string value.
boost::shared_ptr< Expression > ExpressionPtr
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::shared_ptr< const Subnet > ConstSubnetPtr
A generic pointer to either const Subnet4 or const Subnet6 object.
std::vector< TokenPtr > Expression
This is a structure that holds an expression converted to RPN.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
Defines the logger used by the top-level component of kea-lfc.