Kea  2.1.7-git
isc::dhcp::TokenToHexString Class Reference

Token that converts to hexadecimal string. More...

#include <token.h>

+ Inheritance diagram for isc::dhcp::TokenToHexString:

Public Member Functions

 TokenToHexString ()
 Constructor (does nothing) More...
 
void evaluate (Pkt &pkt, ValueStack &values)
 Convert a binary value to its hexadecimal string representation. More...
 
- Public Member Functions inherited from isc::dhcp::Token
virtual ~Token ()
 Virtual destructor. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from isc::dhcp::Token
static bool toBool (std::string value)
 Coverts a (string) value to a boolean. More...
 

Detailed Description

Token that converts to hexadecimal string.

For example in the sub-expression "hexstring(pkt4.mac, ':')" the binary MAC address is converted to its usual hexadecimal representation as a list of (6) pairs of hexadecimal digits separated by colons (':'). Please note the token is named TokenToHexString when the syntax use the hexstring name without a leading "to".

Definition at line 905 of file token.h.

Constructor & Destructor Documentation

◆ TokenToHexString()

isc::dhcp::TokenToHexString::TokenToHexString ( )
inline

Constructor (does nothing)

Definition at line 908 of file token.h.

Member Function Documentation

◆ evaluate()

void TokenToHexString::evaluate ( Pkt pkt,
ValueStack values 
)
virtual

Convert a binary value to its hexadecimal string representation.

Evaluation does not use packet information. It requires at least two values to be present on the stack. It will consume the top two values on the stack as parameters and push the resulting hexadecimal string onto the stack. From the top it expects the values on the stack as:

  • separator
  • binary

binary is the binary value (note it can be any value, i.e. it is not checked to really be not printable). separator is literal for instance '-' or ':'. The empty separator means no separator.

The following example use a binary MAC address 06:ce:8f:55:b3:33:

  • mac, '-' => "06-ce-8f-55-b3-33"
Exceptions
EvalBadStackif there are less than 2 values on stack
Parameters
pkt(unused)
values- stack of values (2 arguments will be popped, 1 result will be pushed)

Implements isc::dhcp::Token.

Definition at line 922 of file token.cc.

References isc::dhcp::EVAL_DBG_STACK, isc::dhcp::EVAL_DEBUG_TOHEXSTRING, isc::dhcp::eval_logger, isc_throw, LOG_DEBUG, and isc::util::encode::toHex().

+ Here is the call graph for this function:

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