![]() |
Kea 3.0.0
|
Evaluation context, an interface to the expression evaluation. More...
#include <eval_context.h>
Public Types | |
| typedef std::function< bool(const ClientClass &)> | CheckDefined |
| Type of the check defined function. | |
| enum | ParserType { PARSER_BOOL , PARSER_STRING } |
| Specifies what type of expression the parser is expected to see. More... | |
Public Member Functions | |
| EvalContext (const Option::Universe &option_universe, CheckDefined check_defined=acceptAll) | |
| Default constructor. | |
| virtual | ~EvalContext () |
| destructor | |
| int8_t | convertNestLevelNumber (const std::string &nest_level, const isc::eval::location &loc) |
| Nest level conversion. | |
| uint16_t | convertOptionCode (const std::string &option_code, const isc::eval::location &loc) |
| Option code conversion. | |
| uint16_t | convertOptionName (const std::string &option_name, const isc::eval::location &loc) |
| Option name conversion. | |
| Option::Universe | getUniverse () |
| Returns the universe (v4 or v6) | |
| bool | isClientClassDefined (const ClientClass &client_class) |
| Check if a client class is already defined. | |
| bool | parseString (const std::string &str, ParserType type=PARSER_BOOL) |
| Run the parser on the string specified. | |
| void | scanStringBegin (ParserType type) |
| Method called before scanning starts on a string. | |
| void | scanStringEnd () |
| Method called after the last tokens are scanned from a string. | |
Static Public Member Functions | |
| static bool | acceptAll (const ClientClass &client_class) |
| Accept all client class names. | |
| static int16_t | convertInt16 (const std::string &number, const isc::eval::location &loc) |
| Attempts to convert string to signed 16bit integer. | |
| static int32_t | convertInt32 (const std::string &number, const isc::eval::location &loc) |
| Attempts to convert string to signed 32bit integer. | |
| static int8_t | convertInt8 (const std::string &number, const isc::eval::location &loc) |
| Attempts to convert string to signed 8bit integer. | |
| static uint16_t | convertUint16 (const std::string &number, const isc::eval::location &loc) |
| Attempts to convert string to unsigned 16bit integer. | |
| static uint32_t | convertUint32 (const std::string &number, const isc::eval::location &loc) |
| Attempts to convert string to unsigned 32bit integer. | |
| static uint8_t | convertUint8 (const std::string &number, const isc::eval::location &loc) |
| Attempts to convert string to unsigned 8bit integer. | |
| static void | error (const isc::eval::location &loc, const std::string &what) |
| Error handler. | |
| static void | error (const std::string &what) |
| Error handler. | |
| static void | fatal (const std::string &what) |
| Fatal error handler. | |
| static std::string | fromUint16 (const uint16_t integer) |
| Converts unsigned 16bit integer to string representation. | |
| static std::string | fromUint32 (const uint32_t integer) |
| Converts unsigned 32bit integer to string representation. | |
Public Attributes | |
| isc::dhcp::Expression | expression_ |
| Parsed expression (output tokens are stored here) | |
| std::string | file_ |
| The name of the file being parsed. | |
| unsigned | label_ |
| Label counter. | |
| std::vector< unsigned > | labels_ |
| Label stack. | |
| std::string | string_ |
| The string being parsed. | |
Evaluation context, an interface to the expression evaluation.
Definition at line 35 of file eval_context.h.
| typedef std::function<bool(const ClientClass&)> isc::eval::EvalContext::CheckDefined |
Type of the check defined function.
Definition at line 45 of file eval_context.h.
Specifies what type of expression the parser is expected to see.
| Enumerator | |
|---|---|
| PARSER_BOOL | expression is expected to evaluate to bool |
| PARSER_STRING | expression is expected to evaluate to string |
Definition at line 39 of file eval_context.h.
| EvalContext::EvalContext | ( | const Option::Universe & | option_universe, |
| CheckDefined | check_defined = acceptAll ) |
Default constructor.
| option_universe | Option universe: DHCPv4 or DHCPv6. This is used by the parser to determine which option definitions set should be used to map option names to option codes. |
| check_defined | A function called to check if a client class used for membership is already defined. If it is not the parser will fail: only backward or built-in references are accepted. |
Definition at line 21 of file eval_context.cc.
References label_.
|
virtual |
destructor
Definition at line 28 of file eval_context.cc.
|
static |
Accept all client class names.
| client_class | (unused) |
Definition at line 32 of file eval_context.cc.
Referenced by isc::dhcp::ClientClassDictionary::initMatchExpr(), and isc::dhcp::ClientClassDefParser::parse().
|
static |
Attempts to convert string to signed 16bit integer.
| number | string to be converted |
| loc | the location of the token |
| EvalParseError | if conversion fails or the value is out of range. |
Definition at line 180 of file eval_context.cc.
References isc::db::error.
|
static |
Attempts to convert string to signed 32bit integer.
| number | string to be converted |
| loc | the location of the token |
| EvalParseError | if conversion fails or the value is out of range. |
Definition at line 215 of file eval_context.cc.
References isc::db::error.
|
static |
Attempts to convert string to signed 8bit integer.
| number | string to be converted |
| loc | the location of the token |
| EvalParseError | if conversion fails or the value is out of range. |
Definition at line 145 of file eval_context.cc.
References isc::db::error.
Referenced by convertNestLevelNumber().
| int8_t EvalContext::convertNestLevelNumber | ( | const std::string & | nest_level, |
| const isc::eval::location & | loc ) |
Nest level conversion.
| nest_level | a string representing the integer nesting level |
| loc | the location of the token |
| calls | the syntax error function if the value is not in the range -32..31 |
Definition at line 112 of file eval_context.cc.
References convertInt8(), isc::db::error, HOP_COUNT_LIMIT, and isc::dhcp::Option::V6.
| uint16_t EvalContext::convertOptionCode | ( | const std::string & | option_code, |
| const isc::eval::location & | loc ) |
Option code conversion.
| option_code | a string representing the integer code |
| loc | the location of the token |
| calls | the syntax error function if the value is not in the range 0..255 or 0..65535 |
Definition at line 65 of file eval_context.cc.
References isc::db::error, and isc::dhcp::Option::V6.
| uint16_t EvalContext::convertOptionName | ( | const std::string & | option_name, |
| const isc::eval::location & | loc ) |
Option name conversion.
| option_name | the option name |
| loc | the location of the token |
| calls | the syntax error function if the name cannot be resolved |
Definition at line 89 of file eval_context.cc.
References DHCP4_OPTION_SPACE, DHCP6_OPTION_SPACE, isc::db::error, isc::dhcp::LibDHCP::getLastResortOptionDef(), isc::dhcp::LibDHCP::getOptionDef(), isc::dhcp::LibDHCP::getRuntimeOptionDef(), and isc::dhcp::Option::V4.
|
static |
Attempts to convert string to unsigned 16bit integer.
For reverse conversion, see fromUint16
| number | string to be converted |
| loc | the location of the token |
| EvalParseError | if conversion fails or the value is out of range. |
Definition at line 163 of file eval_context.cc.
References isc::db::error.
|
static |
Attempts to convert string to unsigned 32bit integer.
For reverse conversion, see fromUint32
| number | string to be converted |
| loc | the location of the token |
| EvalParseError | if conversion fails or the value is out of range. |
Definition at line 198 of file eval_context.cc.
References isc::db::error.
|
static |
Attempts to convert string to unsigned 8bit integer.
| number | string to be converted |
| loc | the location of the token |
| EvalParseError | if conversion fails or the value is out of range. |
Definition at line 128 of file eval_context.cc.
References isc::db::error.
|
static |
Error handler.
| loc | location within the parsed file where the problem was experienced. |
| what | string explaining the nature of the error. |
Definition at line 55 of file eval_context.cc.
References isc_throw.
|
static |
Error handler.
This is a simplified error reporting tool for possible future cases when the EvalParser is not able to handle the packet.
Definition at line 60 of file eval_context.cc.
References isc_throw.
|
static |
Fatal error handler.
This is for should not happen but fatal errors
Definition at line 258 of file eval_context.cc.
References isc_throw.
|
static |
Converts unsigned 16bit integer to string representation.
The integer is coded as a 2 byte long string in network order, e.g. 6 is represented as 0006. For reverse conversion, see convertUint16.
| integer | value to be converted |
Definition at line 244 of file eval_context.cc.
|
static |
Converts unsigned 32bit integer to string representation.
The integer is coded as a 4 byte long string in network order, e.g. 6 is represented as 00000006. For reverse conversion, see convertUint32.
| integer | value to be converted |
Definition at line 233 of file eval_context.cc.
Referenced by isc::dhcp::TokenPkt4::evaluate(), isc::dhcp::TokenPkt6::evaluate(), and isc::dhcp::TokenPkt::evaluate().
|
inline |
| bool EvalContext::isClientClassDefined | ( | const ClientClass & | client_class | ) |
Check if a client class is already defined.
| client_class | the client class name to check |
Definition at line 253 of file eval_context.cc.
| bool EvalContext::parseString | ( | const std::string & | str, |
| ParserType | type = PARSER_BOOL ) |
Run the parser on the string specified.
| str | string to be parsed |
| type | type of the expression expected/parser type to be created |
Definition at line 37 of file eval_context.cc.
References file_, isc::eval::EvalParser::parse(), scanStringBegin(), scanStringEnd(), and string_.
Referenced by isc::lease_cmds::BindingVariable::BindingVariable(), isc::dhcp::ExpressionParser::parse(), isc::radius::RadiusAttributeParser::parse(), isc::ddns_tuning::ExpressionCache::parseAndCacheExpression(), isc::flex_id::parseAndStoreExpression(), isc::ddns_tuning::DdnsTuningImpl::parseExpression(), isc::dhcp::LegalLogMgr::setRequestFormatExpression(), and isc::dhcp::LegalLogMgr::setResponseFormatExpression().
| void isc::eval::EvalContext::scanStringBegin | ( | ParserType | type | ) |
Method called before scanning starts on a string.
| type | specifies type of the expression to be parsed |
Referenced by parseString().
| void isc::eval::EvalContext::scanStringEnd | ( | ) |
Method called after the last tokens are scanned from a string.
References PARSER_BOOL.
Referenced by parseString().
| isc::dhcp::Expression isc::eval::EvalContext::expression_ |
Parsed expression (output tokens are stored here)
Definition at line 68 of file eval_context.h.
Referenced by isc::lease_cmds::BindingVariable::BindingVariable(), isc::dhcp::ExpressionParser::parse(), isc::radius::RadiusAttributeParser::parse(), isc::ddns_tuning::ExpressionCache::parseAndCacheExpression(), isc::flex_id::parseAndStoreExpression(), isc::ddns_tuning::DdnsTuningImpl::parseExpression(), isc::dhcp::LegalLogMgr::setRequestFormatExpression(), and isc::dhcp::LegalLogMgr::setResponseFormatExpression().
| std::string isc::eval::EvalContext::file_ |
The name of the file being parsed.
Used later to pass the file name to the location tracker.
Definition at line 93 of file eval_context.h.
Referenced by parseString().
| unsigned isc::eval::EvalContext::label_ |
| std::vector<unsigned> isc::eval::EvalContext::labels_ |
Label stack.
Definition at line 74 of file eval_context.h.
| std::string isc::eval::EvalContext::string_ |