Kea 2.5.8
isc::dhcp::Token Class Referenceabstract

Base class for all tokens. More...

#include <token.h>

+ Inheritance diagram for isc::dhcp::Token:

Public Member Functions

virtual ~Token ()
 Virtual destructor.
 
virtual void evaluate (Pkt &pkt, ValueStack &values)=0
 This is a generic method for evaluating a packet.
 

Static Public Member Functions

static bool toBool (std::string value)
 Coverts a (string) value to a boolean.
 

Detailed Description

Base class for all tokens.

It provides an interface for all tokens and storage for string representation (all tokens evaluate to string).

This class represents a single token. Examples of a token are:

  • "foo" (a constant string)
  • option[123].text (a token that extracts textual value of option 123)
  • == (an operator that compares two other tokens)
  • substring(a,b,c) (an operator that takes three arguments: a string, first character and length)

Definition at line 62 of file token.h.

Constructor & Destructor Documentation

◆ ~Token()

virtual isc::dhcp::Token::~Token ( )
inlinevirtual

Virtual destructor.

Definition at line 80 of file token.h.

Member Function Documentation

◆ evaluate()

virtual void isc::dhcp::Token::evaluate ( Pkt pkt,
ValueStack values 
)
pure virtual

This is a generic method for evaluating a packet.

We need to pass the packet being evaluated and possibly previously evaluated values. Specific implementations may ignore the packet altogether and just put their own value on the stack (constant tokens), look at the packet and put some data extracted from it on the stack (option tokens), or pop arguments from the stack and put back the result (operators).

The parameters passed will be:

Parameters
pkt- packet being classified
values- stack of values with previously evaluated tokens

Implemented in isc::dhcp::TokenString, isc::dhcp::TokenHexString, isc::dhcp::TokenLowerCase, isc::dhcp::TokenUpperCase, isc::dhcp::TokenIpAddress, isc::dhcp::TokenIpAddressToText, isc::dhcp::TokenInt8ToText, isc::dhcp::TokenInt16ToText, isc::dhcp::TokenInt32ToText, isc::dhcp::TokenUInt8ToText, isc::dhcp::TokenUInt16ToText, isc::dhcp::TokenUInt32ToText, isc::dhcp::TokenOption, isc::dhcp::TokenPkt, isc::dhcp::TokenPkt4, isc::dhcp::TokenPkt6, isc::dhcp::TokenRelay6Field, isc::dhcp::TokenEqual, isc::dhcp::TokenSubstring, isc::dhcp::TokenSplit, isc::dhcp::TokenConcat, isc::dhcp::TokenIfElse, isc::dhcp::TokenToHexString, isc::dhcp::TokenNot, isc::dhcp::TokenAnd, isc::dhcp::TokenOr, isc::dhcp::TokenMember, isc::dhcp::TokenVendor, isc::dhcp::TokenVendorClass, and isc::dhcp::TokenSubOption.

◆ toBool()

static bool isc::dhcp::Token::toBool ( std::string  value)
inlinestatic

Coverts a (string) value to a boolean.

Only "true" and "false" are expected.

Parameters
valuethe (string) value
Returns
the boolean represented by the value
Exceptions
EvalTypeErrorwhen the value is not either "true" or "false".

Definition at line 89 of file token.h.

References isc_throw.

Referenced by isc::dhcp::TokenIfElse::evaluate(), isc::dhcp::TokenNot::evaluate(), isc::dhcp::TokenAnd::evaluate(), isc::dhcp::TokenOr::evaluate(), and isc::dhcp::evaluateBool().


The documentation for this class was generated from the following file: