| Kea 3.0.2-git

isc::dhcp::TokenToHexString Class Reference

Token that converts to hexadecimal string. More...

`#include <token.h>`

Inheritance diagram for isc::dhcp::TokenToHexString:
[legend]

## Public Member Functions
| TokenToHexString ()
| Constructor (does nothing).
virtual unsigned | evaluate (Pkt &pkt, ValueStack &values)
| Convert a binary value to its hexadecimal string representation.
Public Member Functions inherited from isc::dhcp::Token
virtual | ~Token ()
| Virtual destructor.
virtual unsigned | getLabel () const
| Return the label of this token.

## 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.

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

## Constructor & Destructor Documentation

## ◆ TokenToHexString()

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

Constructor (does nothing).

Definition at line 976 of file token.h.

## Member Function Documentation

## ◆ evaluate()

unsigned 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

  EvalBadStack | if 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)

Returns
  0 which means evaluate next token if any.

Implements isc::dhcp::Token.

Definition at line 1028 of file token.cc.

References isc::dhcp::EVAL_DBG_STACK, isc::dhcp::EVAL_DEBUG_TOHEXSTRING, isc::dhcp::eval_logger, isc::dhcp::Pkt::getLabel(), isc_throw, LOG_DEBUG, and toHex().

Here is the call graph for this function:

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

- token.h
- token.cc