| Kea 3.0.2-git

isc::radius::Message Class Reference

RADIUS Message. More...

`#include <client_message.h>`

## Public Member Functions
| Message (const Message &other)
| Copy constructor.
| Message (const std::vector< uint8_t > &buffer, const std::vector< uint8_t > &auth, const std::string &secret)
| Constructor.
| Message (const uint8_t code, uint16_t length, const std::vector< uint8_t > &auth, const std::string &secret, const AttributesPtr &attributes)
| Constructor.
virtual | ~Message ()
| Destructor.
void | decode ()
| Decode a message.
std::vector< uint8_t > | encode ()
| Encode a message.
AttributesPtr | getAttributes () const
| Get attributes.
std::vector< uint8_t > | getAuth () const
| Get authenticator.
std::vector< uint8_t > | getBuffer () const
| Get buffer.
uint8_t | getCode () const
| Get code.
uint8_t | getIdentifier () const
| Get identifier.
uint16_t | getLength () const
| Get length.
std::string | getSecret () const
| Get secret.
void | randomAuth ()
| Randomize authenticator.
void | randomIdentifier ()
| Randomize identifier.
void | setAttributes (const AttributesPtr &attributes)
| Set attributes.
void | setAuth (const std::vector< uint8_t > &auth)
| Set authenticator.
void | setBuffer (const std::vector< uint8_t > &buffer)
| Set buffer.
void | setCode (const uint8_t code)
| Set code.
void | setIdentifier (const uint8_t identifier)
| Set identifier.
void | setLength (const uint16_t length)
| Set length.
void | setSecret (const std::string &secret)
| Set secret.
void | zeroAuth ()
| Fill authenticator with 0.

## Static Public Member Functions
static const std::vector< uint8_t > | ZERO_AUTH ()
| Build a zero authenticator.

## Protected Member Functions
ConstAttributePtr | decodeUserPassword (const ConstAttributePtr &attr)
| Decode User-Password in an Access-Request.
ConstAttributePtr | encodeUserPassword (const ConstAttributePtr &attr)
| Encode User-Password in an Access-Request.

## Protected Attributes
AttributesPtr | attributes_
| Attributes: header[20]...
std::vector< uint8_t > | auth_
| Authenticator: header[4] (16 octets).
std::vector< uint8_t > | buffer_
| Buffer (message content).
uint8_t | code_
| Code (useful values in MsgCode): header[0].
uint8_t | identifier_
| Identifier (random): header[1].
uint16_t | length_
| Length: header[2] (16 bits, network order).
std::string | secret_
| Secret (not empty).

## Detailed Description

RADIUS Message.

Definition at line 55 of file client_message.h.

## Constructor & Destructor Documentation

## ◆ Message() [1/3]

isc::radius::Message::Message | ( | const uint8_t | code,
|  | uint16_t | length,
|  | const std::vector< uint8_t > & | auth,
|  | const std::string & | secret,
|  | const AttributesPtr & | attributes )

Constructor.

To be used to send a message.

code message code.

length message length (0 to be computed).

auth authenticator (16 octets).

secret associated secret (not empty).

attributes attributes.

Definition at line 63 of file client_message.cc.

References attributes_, auth_, buffer_, code_, length_, and secret_.

Referenced by Message(), and Message().

## ◆ Message() [2/3]

isc::radius::Message::Message | ( | const Message & | other | ) |

Copy constructor.

Copy attributes.

other message to copy.

Definition at line 70 of file client_message.cc.

References Message(), attributes_, auth_, buffer_, code_, length_, and secret_.

Here is the call graph for this function:

## ◆ Message() [3/3]

isc::radius::Message::Message | ( | const std::vector< uint8_t > & | buffer,
|  | const std::vector< uint8_t > & | auth,
|  | const std::string & | secret )

Constructor.

To be used on message reception.

Parameters

  buffer | buffer containing the message.
  auth | authenticator (16 octets).
  secret | associated secret (not empty).

Definition at line 86 of file client_message.cc.

References Message(), attributes_, auth_, buffer_, code_, length_, and secret_.

Here is the call graph for this function:

## ◆ ~Message()

isc::radius::Message::~Message | ( |  | ) |
| virtual

Destructor.

Destroy the secret.

Definition at line 93 of file client_message.cc.

References secret_.

## Member Function Documentation

## ◆ decode()

void isc::radius::Message::decode | ( |  | ) |

Decode a message.

Exceptions

  an | exception when something goes wrong.

Definition at line 197 of file client_message.cc.

References attributes_, auth_, buffer_, code_, decodeUserPassword(), isc::cryptolink::digest(), isc::radius::Attribute::fromBytes(), isc::cryptolink::CryptoLink::getCryptoLink(), identifier_, isc::radius::AttrDefs::instance(), isc_throw, length_, LOG_DEBUG, isc::cryptolink::MD5, isc::radius::msgCodeToText(), isc::radius::PW_ACCESS_REQUEST, isc::radius::PW_USER_PASSWORD, isc::radius::RADIUS_DBG_TRACE, isc::radius::RADIUS_DECODE_MESSAGE, isc::radius::radius_logger, and secret_.

Here is the call graph for this function:

## ◆ decodeUserPassword()

ConstAttributePtr isc::radius::Message::decodeUserPassword | ( | const ConstAttributePtr & | attr | ) |
| protected

Decode User-Password in an Access-Request.

Parameters

  attr | the User-Password attribute.

Returns
  decoded User-Password attribute.

Definition at line 341 of file client_message.cc.

References auth_, isc::cryptolink::digest(), isc::radius::Attribute::fromBinary(), isc::cryptolink::CryptoLink::getCryptoLink(), isc_throw, isc::cryptolink::MD5, isc::radius::PW_TYPE_STRING, isc::radius::PW_USER_PASSWORD, and secret_.

Referenced by decode().

Here is the call graph for this function:

## ◆ encode()

vector< uint8_t > isc::radius::Message::encode | ( |  | ) |

Encode a message.

Returns
  the buffer with the message.

Exceptions

  an | exception when something goes wrong.

Definition at line 140 of file client_message.cc.

References attributes_, auth_, buffer_, code_, encodeUserPassword(), isc::cryptolink::CryptoLink::getCryptoLink(), identifier_, isc_throw, length_, LOG_DEBUG, isc::cryptolink::MD5, isc::radius::msgCodeToText(), isc::radius::PW_ACCESS_REQUEST, isc::radius::PW_USER_PASSWORD, isc::radius::RADIUS_DBG_TRACE, isc::radius::RADIUS_ENCODE_MESSAGE, isc::radius::radius_logger, and secret_.

Here is the call graph for this function:

## ◆ encodeUserPassword()

ConstAttributePtr isc::radius::Message::encodeUserPassword | ( | const ConstAttributePtr & | attr | ) |
| protected

Encode User-Password in an Access-Request.

Parameters

  attr | the User-Password attribute.

Returns
  encoded User-Password attribute.

Definition at line 298 of file client_message.cc.

References auth_, isc::cryptolink::digest(), isc::radius::Attribute::fromBinary(), isc::cryptolink::CryptoLink::getCryptoLink(), isc_throw, isc::cryptolink::MD5, isc::radius::PW_TYPE_STRING, isc::radius::PW_USER_PASSWORD, and secret_.

Referenced by encode().

Here is the call graph for this function:

## ◆ getAttributes()

AttributesPtr isc::radius::Message::getAttributes | ( |  | ) | const
| inline

Get attributes.

Returns
  attributes.

Definition at line 179 of file client_message.h.

References attributes_.

## ◆ getAuth()

std::vector< uint8_t > isc::radius::Message::getAuth | ( |  | ) | const
| inline

Get authenticator.

Returns
  authenticator.

Definition at line 150 of file client_message.h.

References auth_.

## ◆ getBuffer()

std::vector< uint8_t > isc::radius::Message::getBuffer | ( |  | ) | const
| inline

Get buffer.

Returns
  message content.

Definition at line 193 of file client_message.h.

References buffer_.

## ◆ getCode()

uint8_t isc::radius::Message::getCode | ( |  | ) | const
| inline

Get code.

Returns
  code.

Definition at line 105 of file client_message.h.

References code_.

## ◆ getIdentifier()

uint8_t isc::radius::Message::getIdentifier | ( |  | ) | const
| inline

Get identifier.

Returns
  identifier.

Definition at line 119 of file client_message.h.

References identifier_.

## ◆ getLength()

uint16_t isc::radius::Message::getLength | ( |  | ) | const
| inline

Get length.

Returns
  length (field value).

Definition at line 136 of file client_message.h.

References length_.

## ◆ getSecret()

std::string isc::radius::Message::getSecret | ( |  | ) | const
| inline

Get secret.

Returns
  secret.

Definition at line 168 of file client_message.h.

References secret_.

## ◆ randomAuth()

void isc::radius::Message::randomAuth | ( |  | ) |

Randomize authenticator.

Definition at line 124 of file client_message.cc.

References auth_, isc_throw, and isc::cryptolink::random().

Here is the call graph for this function:

## ◆ randomIdentifier()

void isc::radius::Message::randomIdentifier | ( |  | ) |

Randomize identifier.

Definition at line 101 of file client_message.cc.

References identifier_, isc_throw, and isc::cryptolink::random().

Here is the call graph for this function:

## ◆ setAttributes()

void isc::radius::Message::setAttributes | ( | const AttributesPtr & | attributes | ) |
| inline

Set attributes.

Parameters

  attributes | new attributes.

Definition at line 186 of file client_message.h.

References attributes_.

## ◆ setAuth()

void isc::radius::Message::setAuth | ( | const std::vector< uint8_t > & | auth | ) |

Set authenticator.

Parameters

  auth | new authenticator (must have 16 octets).

Definition at line 110 of file client_message.cc.

References auth_, and isc_throw.

## ◆ setBuffer()

void isc::radius::Message::setBuffer | ( | const std::vector< uint8_t > & | buffer | ) |
| inline

Set buffer.

Parameters

  buffer | new message content.

Definition at line 200 of file client_message.h.

References buffer_.

## ◆ setCode()

void isc::radius::Message::setCode | ( | const uint8_t | code | ) |
| inline

Set code.

Parameters

  code | new code.

Definition at line 112 of file client_message.h.

References code_.

## ◆ setIdentifier()

void isc::radius::Message::setIdentifier | ( | const uint8_t | identifier | ) |
| inline

Set identifier.

Parameters

  identifier | new identifier.

Definition at line 126 of file client_message.h.

References identifier_.

## ◆ setLength()

void isc::radius::Message::setLength | ( | const uint16_t | length | ) |
| inline

Set length.

Parameters

  length | new length.

Definition at line 143 of file client_message.h.

References length_.

## ◆ setSecret()

void isc::radius::Message::setSecret | ( | const std::string & | secret | ) |

Set secret.

Parameters

  secret | new secret (not empty).

Definition at line 132 of file client_message.cc.

References isc_throw, and secret_.

## ◆ ZERO_AUTH()

const std::vector< uint8_t > isc::radius::Message::ZERO_AUTH | ( |  | ) |
| inline static

Build a zero authenticator.

Returns
  an authenticator filled with 0.

Definition at line 60 of file client_message.h.

## ◆ zeroAuth()

void isc::radius::Message::zeroAuth | ( |  | ) |

Fill authenticator with 0.

Definition at line 118 of file client_message.cc.

References auth_.

## Member Data Documentation

## ◆ attributes_

AttributesPtr isc::radius::Message::attributes_
| protected

Attributes: header[20]...

Definition at line 244 of file client_message.h.

Referenced by Message(), Message(), Message(), decode(), encode(), getAttributes(), and setAttributes().

## ◆ auth_

std::vector<uint8_t> isc::radius::Message::auth_
| protected

Authenticator: header[4] (16 octets).

Definition at line 238 of file client_message.h.

Referenced by Message(), Message(), Message(), decode(), decodeUserPassword(), encode(), encodeUserPassword(), getAuth(), randomAuth(), setAuth(), and zeroAuth().

## ◆ buffer_

std::vector<uint8_t> isc::radius::Message::buffer_
| protected

Buffer (message content).

Definition at line 247 of file client_message.h.

Referenced by Message(), Message(), Message(), decode(), encode(), getBuffer(), and setBuffer().

## ◆ code_

uint8_t isc::radius::Message::code_
| protected

Code (useful values in MsgCode): header[0].

Definition at line 229 of file client_message.h.

Referenced by Message(), Message(), Message(), decode(), encode(), getCode(), and setCode().

## ◆ identifier_

uint8_t isc::radius::Message::identifier_
| protected

Identifier (random): header[1].

Definition at line 232 of file client_message.h.

Referenced by decode(), encode(), getIdentifier(), randomIdentifier(), and setIdentifier().

## ◆ length_

uint16_t isc::radius::Message::length_
| protected

Length: header[2] (16 bits, network order).

Definition at line 235 of file client_message.h.

Referenced by Message(), Message(), Message(), decode(), encode(), getLength(), and setLength().

## ◆ secret_

std::string isc::radius::Message::secret_
| protected

Secret (not empty).

Definition at line 241 of file client_message.h.

Referenced by Message(), Message(), Message(), ~Message(), decode(), decodeUserPassword(), encode(), encodeUserPassword(), getSecret(), and setSecret().

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

- client_message.h
- client_message.cc