89 static inline bool toBool(std::string value) {
90 if (value ==
"true") {
92 }
else if (value ==
"false") {
96 "\"false\" or \"true\", got \"" << value <<
"\"");
1119 uint16_t option_code = 0);
1220 uint16_t index = 0);
1289 const uint16_t sub_option_code,
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
EvalBadStack is thrown when more or less parameters are on the stack than expected.
EvalBadStack(const char *file, size_t line, const char *what)
EvalTypeError is thrown when a value on the stack has a content with an unexpected type.
EvalTypeError(const char *file, size_t line, const char *what)
Universe
defines option universe DHCPv4 or DHCPv6
Base class for classes representing DHCP messages.
Token that represents logical and operator.
void evaluate(Pkt &pkt, ValueStack &values)
Logical and.
TokenAnd()
Constructor (does nothing)
Token that represents concat operator (concatenates two other tokens)
void evaluate(Pkt &pkt, ValueStack &values)
Concatenate two values.
TokenConcat()
Constructor (does nothing)
Token that represents equality operator (compares two other tokens)
void evaluate(Pkt &pkt, ValueStack &values)
Compare two values.
TokenEqual()
Constructor (does nothing)
Token representing a constant string in hexadecimal format.
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the constant string on the stack after decoding or an empty string if...
std::string value_
Constant value.
Token that represents an alternative.
TokenIfElse()
Constructor (does nothing)
void evaluate(Pkt &pkt, ValueStack &values)
Alternative.
Token representing a 16 bit integer as a string.
TokenInt16ToText()
Constructor (does nothing)
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Token representing a 32 bit integer as a string.
TokenInt32ToText()
Constructor (does nothing)
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Token representing an 8 bit integer as a string.
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
TokenInt8ToText()
Constructor (does nothing)
Token representing an unsigned 32 bit integer.
uint32_t getInteger() const
Returns integer value.
uint32_t int_value_
value as integer (stored for testing only)
Token representing an IP address as a string.
TokenIpAddressToText()
Constructor (does nothing)
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Token representing an IP address as a constant string.
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the constant string on the stack after decoding)
std::string value_
< Constant value (empty string if the IP address cannot be converted)
Token representing a constant lower case string.
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the evaluated string expression converted to lower case on the stack)
TokenLowerCase()
Constructor (does nothing)
Token that represents client class membership.
const ClientClass & getClientClass() const
Returns client class name.
ClientClass client_class_
The client class name.
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (check if client_class_ was added to packet client classes)
TokenMember(const std::string &client_class)
Constructor.
Token that represents logical negation operator.
TokenNot()
Constructor (does nothing)
void evaluate(Pkt &pkt, ValueStack &values)
Logical negation.
Token that represents a value of an option.
uint16_t getCode() const
Returns option-code.
RepresentationType getRepresentation() const
Returns representation-type.
virtual OptionPtr getOption(Pkt &pkt)
Attempts to retrieve an option.
void evaluate(Pkt &pkt, ValueStack &values)
Evaluates the values of the option.
RepresentationType representation_type_
Representation type.
uint16_t option_code_
Code of the option to be extracted.
RepresentationType
Token representation type.
TokenOption(const uint16_t option_code, const RepresentationType &rep_type)
Constructor that takes an option code as a parameter.
virtual std::string pushFailure(ValueStack &values)
Auxiliary method that puts string representing a failure.
Token that represents logical or operator.
void evaluate(Pkt &pkt, ValueStack &values)
Logical or.
TokenOr()
Constructor (does nothing)
Token that represents fields of a DHCPv4 packet.
FieldType getType()
Returns field type.
FieldType
enum value that determines the field.
@ CIADDR
ciaddr (IPv4 address)
@ HLEN
hlen (hardware address length)
@ HTYPE
htype (hardware address type)
@ GIADDR
giaddr (IPv4 address)
@ CHADDR
chaddr field (up to 16 bytes link-layer address)
@ YIADDR
yiaddr (IPv4 address)
@ SIADDR
siaddr (IPv4 address)
@ TRANSID
transaction-id (xid)
@ MSGTYPE
message type (not really a field, content of option 53)
void evaluate(Pkt &pkt, ValueStack &values)
Gets a value from the specified packet.
TokenPkt4(const FieldType type)
Constructor (does nothing)
Token that represents fields of DHCPv6 packet.
TokenPkt6(const FieldType type)
Constructor (does nothing)
void evaluate(Pkt &pkt, ValueStack &values)
Gets a value of the specified packet.
FieldType getType()
Returns field type.
FieldType
enum value that determines the field.
@ TRANSID
transaction id (integer but manipulated as a string)
Token that represents meta data of a DHCP packet.
MetadataType
enum value that determines the field.
@ DST
destination (IP address)
@ IFACE
interface name (string)
MetadataType getType()
Returns metadata type.
void evaluate(Pkt &pkt, ValueStack &values)
Gets a value from the specified packet.
TokenPkt(const MetadataType type)
Constructor (does nothing)
Represents a sub-option inserted by the DHCPv4 relay.
virtual OptionPtr getOption(Pkt &pkt)
Attempts to obtain specified sub-option of option 82 from the packet.
Token that represents a value of a field within a DHCPv6 relay encapsulation.
FieldType type_
field to get
void evaluate(Pkt &pkt, ValueStack &values)
Extracts the specified field from the requested relay.
FieldType
enum value that determines the field.
@ LINKADDR
Link address field (IPv6 address)
@ PEERADDR
Peer address field (IPv6 address)
int8_t nest_level_
Specifies field of the DHCPv6 relay option to get.
FieldType getType()
Returns field type.
TokenRelay6Field(const int8_t nest_level, const FieldType type)
Constructor that takes a nesting level and field type as parameters.
int8_t getNest() const
Returns nest-level.
Token that represents a value of an option within a DHCPv6 relay encapsulation.
int8_t nest_level_
nesting level of the relay block to use
int8_t getNest() const
Returns nest-level.
virtual OptionPtr getOption(Pkt &pkt)
Attempts to obtain specified option from the specified relay block.
TokenRelay6Option(const int8_t nest_level, const uint16_t option_code, const RepresentationType &rep_type)
Constructor that takes a nesting level and an option code as parameters.
TokenSplit()
Constructor (does nothing)
void evaluate(Pkt &pkt, ValueStack &values)
Extract a field from a delimited string.
The order where Token subtypes are declared should be:
std::string value_
Constant value.
TokenString(const std::string &str)
Value is set during token construction.
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the constant string on the stack)
Token that represents sub-options in DHCPv4 and DHCPv6.
virtual void evaluate(Pkt &pkt, ValueStack &values)
This is a method for evaluating a packet.
uint16_t sub_option_code_
Code of the sub-option to be extracted.
uint16_t getSubCode() const
Returns sub-option-code.
TokenSubOption(const uint16_t option_code, const uint16_t sub_option_code, const RepresentationType &rep_type)
Constructor that takes an option and sub-option codes as parameter.
virtual OptionPtr getSubOption(const OptionPtr &parent)
Attempts to retrieve a sub-option.
Token that represents the substring operator (returns a portion of the supplied string)
void evaluate(Pkt &pkt, ValueStack &values)
Extract a substring from a string.
TokenSubstring()
Constructor (does nothing)
Token that converts to hexadecimal string.
TokenToHexString()
Constructor (does nothing)
void evaluate(Pkt &pkt, ValueStack &values)
Convert a binary value to its hexadecimal string representation.
Token representing a 16 bit unsigned integer as a string.
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
TokenUInt16ToText()
Constructor (does nothing)
Token representing a 32 bit unsigned integer as a string.
TokenUInt32ToText()
Constructor (does nothing)
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Token representing an 8 bit unsigned integer as a string.
TokenUInt8ToText()
Constructor (does nothing)
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the string on the stack after decoding)
Token representing a constant upper case string.
void evaluate(Pkt &pkt, ValueStack &values)
Token evaluation (puts value of the evaluated string expression converted to upper case on the stack)
TokenUpperCase()
Constructor (does nothing)
Token that represents vendor class options in DHCPv4 and DHCPv6.
uint16_t getDataIndex() const
Returns data index.
uint16_t index_
Data chunk index.
void evaluate(Pkt &pkt, ValueStack &values)
This is a method for evaluating a packet.
Token that represents vendor options in DHCPv4 and DHCPv6.
FieldType
Specifies a field of the vendor option.
@ DATA
data chunk, used in derived vendor-class only
@ EXISTS
vendor[123].exists
@ ENTERPRISE_ID
enterprise-id field (vendor-info, vendor-class)
@ SUBOPTION
If this token fetches a suboption, not a field.
Option::Universe universe_
Universe (V4 or V6)
uint32_t vendor_id_
Enterprise-id value.
FieldType field_
Specifies which field should be accessed.
uint32_t getVendorId() const
Returns enterprise-id.
virtual OptionPtr getOption(Pkt &pkt)
Attempts to get a suboption.
virtual void evaluate(Pkt &pkt, ValueStack &values)
This is a method for evaluating a packet.
FieldType getField() const
Returns field.
Base class for all tokens.
virtual void evaluate(Pkt &pkt, ValueStack &values)=0
This is a generic method for evaluating a packet.
virtual ~Token()
Virtual destructor.
static bool toBool(std::string value)
Coverts a (string) value to a boolean.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::string ClientClass
Defines a single class name.
boost::shared_ptr< Token > TokenPtr
Pointer to a single Token.
boost::shared_ptr< Expression > ExpressionPtr
std::vector< TokenPtr > Expression
This is a structure that holds an expression converted to RPN.
boost::shared_ptr< Option > OptionPtr
std::stack< std::string > ValueStack
Evaluated values are stored as a stack of strings.
Defines the logger used by the top-level component of kea-lfc.