Kea 2.7.6
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 unsigned evaluate (Pkt &pkt, ValueStack &values)=0
 This is a generic method for evaluating a packet.
 
virtual unsigned getLabel () const
 Return the label of this token.
 

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

Constructor & Destructor Documentation

◆ ~Token()

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

Virtual destructor.

Definition at line 89 of file token.h.

Member Function Documentation

◆ evaluate()

virtual unsigned 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
Returns
next label or 0 when means evaluate next token if any.

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

◆ getLabel()

virtual unsigned isc::dhcp::Token::getLabel ( ) const
inlinevirtual

Return the label of this token.

Returns
the label for a TokenLabel, 0 otherwise.

Reimplemented in isc::dhcp::TokenLabel.

Definition at line 94 of file token.h.

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

References isc_throw.

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


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