Kea: isc::radius::Message Class Reference

| Kea 3.2.0-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.
void | signMessageAuthenticator (size_t ptr)
| Encode Message-Authenticator in an Status-Server.
void | verifyMessageAuthenticator (size_t ptr)
| Decode Message-Authenticator in an Status-Server.

## 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 56 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 65 of file client_message.cc.

References attributes_, auth_, buffer_, code_, identifier_, 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 72 of file client_message.cc.

References Message(), attributes_, auth_, buffer_, code_, identifier_, 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 89 of file client_message.cc.

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

Here is the call graph for this function:

## ◆ ~Message()

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

Destructor.

Destroy the secret.

Definition at line 96 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 216 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_ACCOUNTING_REQUEST, isc::radius::PW_MESSAGE_AUTHENTICATOR, isc::radius::PW_STATUS_SERVER, isc::radius::PW_USER_PASSWORD, isc::radius::RADIUS_DBG_TRACE, isc::radius::RADIUS_DECODE_MESSAGE, isc::radius::radius_logger, secret_, and verifyMessageAuthenticator().

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 372 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 143 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_MESSAGE_AUTHENTICATOR, isc::radius::PW_STATUS_SERVER, isc::radius::PW_TYPE_STRING, isc::radius::PW_USER_PASSWORD, isc::radius::RADIUS_DBG_TRACE, isc::radius::RADIUS_ENCODE_MESSAGE, isc::radius::radius_logger, secret_, and signMessageAuthenticator().

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 329 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 180 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 151 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 194 of file client_message.h.

References buffer_.

## ◆ getCode()

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

Get code.

Returns
  code.

Definition at line 106 of file client_message.h.

References code_.

## ◆ getIdentifier()

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

Get identifier.

Returns
  identifier.

Definition at line 120 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 137 of file client_message.h.

References length_.

## ◆ getSecret()

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

Get secret.

Returns
  secret.

Definition at line 169 of file client_message.h.

References secret_.

## ◆ randomAuth()

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

Randomize authenticator.

Definition at line 127 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 104 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 187 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 113 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 201 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 113 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 127 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 144 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 135 of file client_message.cc.

References isc_throw, and secret_.

## ◆ signMessageAuthenticator()

void isc::radius::Message::signMessageAuthenticator | ( | size_t | ptr | ) |
| protected

Encode Message-Authenticator in an Status-Server.

Parameters

  ptr | the pointer to the attribute in the buffer.

Definition at line 429 of file client_message.cc.

References auth_, buffer_, isc::cryptolink::CryptoLink::getCryptoLink(), isc_throw, isc::cryptolink::MD5, and secret_.

Referenced by encode().

Here is the call graph for this function:

## ◆ verifyMessageAuthenticator()

void isc::radius::Message::verifyMessageAuthenticator | ( | size_t | ptr | ) |
| protected

Decode Message-Authenticator in an Status-Server.

Parameters

  ptr | the pointer to the attribute in the buffer.

Definition at line 449 of file client_message.cc.

References auth_, buffer_, isc::cryptolink::CryptoLink::getCryptoLink(), isc_throw, isc::cryptolink::MD5, and secret_.

Referenced by decode().

Here is the call graph for this function:

## ◆ ZERO_AUTH()

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

Build a zero authenticator.

Returns
  an authenticator filled with 0.

Definition at line 61 of file client_message.h.

## ◆ zeroAuth()

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

Fill authenticator with 0.

Definition at line 121 of file client_message.cc.

References auth_.

## Member Data Documentation

## ◆ attributes_

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

Attributes: header[20]...

Definition at line 255 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 249 of file client_message.h.

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

## ◆ buffer_

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

Buffer (message content).

Definition at line 258 of file client_message.h.

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

## ◆ code_

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

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

Definition at line 240 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 243 of file client_message.h.

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

## ◆ length_

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

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

Definition at line 246 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 252 of file client_message.h.

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

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

- client_message.h
- client_message.cc