Kea  1.9.9-git
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. More...
virtual void evaluate (Pkt &pkt, ValueStack &values)=0
 This is a generic method for evaluating a packet. More...

Static Public Member Functions

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

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 63 of file token.h.

Constructor & Destructor Documentation

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

Virtual destructor.

Definition at line 81 of file token.h.

Member Function Documentation

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:

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

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

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

Coverts a (string) value to a boolean.

Only "true" and "false" are expected.

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

Definition at line 90 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: