Kea 3.1.1
isc::radius::Exchange Class Reference

RADIUS Exchange. More...

#include <client_exchange.h>

+ Inheritance diagram for isc::radius::Exchange:

Public Types

typedef std::function< void(const ExchangePtr ex)> Handler
 Termination handler.
 
typedef asiolink::UDPSocket< const SocketCallbackRadiusSocket
 Type of RADIUS UDP sockets.
 
typedef std::function< void(const boost::system::error_code ec, const size_t size)> SocketCallback
 Type of UDP socket callback functions.
 

Public Member Functions

 Exchange (const asiolink::IOServicePtr io_service, const MessagePtr &request, unsigned maxretries, const Servers &servers, Handler handler)
 Constructor.
 
 Exchange (const MessagePtr &request, unsigned maxretries, const Servers &servers)
 Constructor.
 
virtual ~Exchange ()
 Destructor.
 
const std::string & getId () const
 Get identifier.
 
int getRC () const
 Get the error code.
 
MessagePtr getRequest () const
 Get the request.
 
MessagePtr getResponse () const
 Get the response.
 
void logReplyMessages () const
 Log reply messages.
 
virtual void shutdown ()
 Shutdown.
 
virtual void start ()
 Start.
 

Static Public Attributes

static constexpr size_t BUF_LEN = 8192
 Receive buffer size.
 

Protected Member Functions

void buildRequest ()
 Build request.
 
void cancelTimer ()
 Cancel timer.
 
void createIdentifier ()
 Create identifier.
 
void open ()
 Instance open.
 
void setTimer ()
 Set timer.
 
virtual void shutdownInternal ()
 Shutdown.
 
void terminate ()
 Terminate.
 

Static Protected Member Functions

static void openNext (ExchangePtr ex)
 Class open / open next.
 
static void receivedHandler (ExchangePtr ex, const boost::system::error_code ec, const size_t size)
 Received handler.
 
static void sentHandler (ExchangePtr ex, const boost::system::error_code ec, const size_t size)
 Sent handler.
 
static void timeoutHandler (ExchangePtr ex)
 Timeout handler.
 

Protected Attributes

std::vector< uint8_t > buffer_
 Buffer.
 
boost::scoped_ptr< asiolink::UDPEndpointep_
 UDP endpoint.
 
Handler handler_
 Termination handler.
 
std::string identifier_
 The identifier (random value in hexadecimal).
 
size_t idx_
 Current server index.
 
asiolink::IOServicePtr io_service_
 IO service (argument for async or internal for sync).
 
unsigned maxretries_
 Maximum number of retries for a server.
 
boost::scoped_ptr< std::mutex > mutex_
 State change mutex.
 
std::list< size_t > postponed_
 List of postponed server indexes.
 
int rc_
 Error/return code.
 
MessagePtr received_
 Received message.
 
MessagePtr request_
 Request message.
 
unsigned retries_
 Retry counter.
 
MessagePtr sent_
 Sent message.
 
ServerPtr server_
 Current server.
 
Servers servers_
 Servers (a copy which is what we need).
 
size_t size_
 Number of transmitted octests;.
 
boost::scoped_ptr< RadiusSocketsocket_
 Socket.
 
std::chrono::steady_clock::time_point start_time_
 Start time.
 
bool started_
 Started flag.
 
bool sync_
 Sync / async flag.
 
bool terminated_
 Terminated flag.
 
asiolink::IntervalTimerPtr timer_
 Interval timer.
 

Detailed Description

RADIUS Exchange.

Definition at line 58 of file client_exchange.h.

Member Typedef Documentation

◆ Handler

typedef std::function<void(const ExchangePtr ex)> isc::radius::Exchange::Handler

Termination handler.

Definition at line 71 of file client_exchange.h.

◆ RadiusSocket

Type of RADIUS UDP sockets.

Definition at line 68 of file client_exchange.h.

◆ SocketCallback

typedef std::function<void(const boost::system::error_code ec, const size_t size)> isc::radius::Exchange::SocketCallback

Type of UDP socket callback functions.

Definition at line 65 of file client_exchange.h.

Constructor & Destructor Documentation

◆ Exchange() [1/2]

isc::radius::Exchange::Exchange ( const asiolink::IOServicePtr io_service,
const MessagePtr & request,
unsigned maxretries,
const Servers & servers,
Handler handler )

Constructor.

Async version.

Parameters
io_serviceReference to the IO service.
requestrequest message to send.
maxretriesmaximum number of retries for a server.
serversServers.
handlerTermination handler.

Definition at line 58 of file client_exchange.cc.

References buffer_, createIdentifier(), ep_, isc::radius::ERROR_RC, handler_, identifier_, idx_, if(), io_service_, isc_throw, maxretries_, mutex_, postponed_, rc_, received_, request_, retries_, sent_, server_, servers_, size_, socket_, start_time_, started_, sync_, terminated_, and timer_.

+ Here is the call graph for this function:

◆ Exchange() [2/2]

isc::radius::Exchange::Exchange ( const MessagePtr & request,
unsigned maxretries,
const Servers & servers )

Constructor.

Sync version.

Parameters
requestrequest message to send.
maxretriesmaximum number of retries for a server.
serversServers.

Definition at line 85 of file client_exchange.cc.

References buffer_, createIdentifier(), ep_, isc::radius::ERROR_RC, handler_, identifier_, idx_, io_service_, isc_throw, maxretries_, mutex_, postponed_, rc_, received_, request_, retries_, sent_, server_, servers_, size_, socket_, start_time_, started_, sync_, terminated_, and timer_.

+ Here is the call graph for this function:

◆ ~Exchange()

isc::radius::Exchange::~Exchange ( )
virtual

Destructor.

Definition at line 105 of file client_exchange.cc.

References io_service_, mutex_, shutdownInternal(), socket_, sync_, and timer_.

+ Here is the call graph for this function:

Member Function Documentation

◆ buildRequest()

void isc::radius::Exchange::buildRequest ( )
protected

Build request.

Definition at line 208 of file client_exchange.cc.

References isc::radius::Attribute::fromInt(), isc::radius::Attribute::fromIpAddr(), isc::radius::Attribute::fromIpv6Addr(), isc::asiolink::IOAddress::getFamily(), isc_throw, isc::radius::PW_ACCESS_REQUEST, isc::radius::PW_ACCOUNTING_REQUEST, isc::radius::PW_ACCT_DELAY_TIME, isc::radius::PW_NAS_IP_ADDRESS, isc::radius::PW_NAS_IPV6_ADDRESS, request_, sent_, server_, and start_time_.

Referenced by open().

+ Here is the call graph for this function:

◆ cancelTimer()

void isc::radius::Exchange::cancelTimer ( )
protected

Cancel timer.

Definition at line 697 of file client_exchange.cc.

References timer_.

Referenced by open(), setTimer(), shutdownInternal(), and terminate().

◆ createIdentifier()

void isc::radius::Exchange::createIdentifier ( )
protected

Create identifier.

Definition at line 118 of file client_exchange.cc.

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

Referenced by Exchange(), and Exchange().

+ Here is the call graph for this function:

◆ getId()

const std::string & isc::radius::Exchange::getId ( ) const
inline

Get identifier.

Returns
the identifier.

Definition at line 105 of file client_exchange.h.

References identifier_.

◆ getRC()

int isc::radius::Exchange::getRC ( ) const
inline

Get the error code.

Returns
the error code.

Definition at line 112 of file client_exchange.h.

References rc_.

◆ getRequest()

MessagePtr isc::radius::Exchange::getRequest ( ) const
inline

Get the request.

Returns
the request.

Definition at line 119 of file client_exchange.h.

References request_.

◆ getResponse()

MessagePtr isc::radius::Exchange::getResponse ( ) const
inline

Get the response.

Returns
the response.

Definition at line 126 of file client_exchange.h.

References received_.

◆ logReplyMessages()

void isc::radius::Exchange::logReplyMessages ( ) const

◆ open()

◆ openNext()

static void isc::radius::Exchange::openNext ( ExchangePtr ex)
inlinestaticprotected

Class open / open next.

Parameters
exthe exchange.

Definition at line 228 of file client_exchange.h.

Referenced by open(), receivedHandler(), and sentHandler().

◆ receivedHandler()

◆ sentHandler()

void isc::radius::Exchange::sentHandler ( ExchangePtr ex,
const boost::system::error_code ec,
const size_t size )
staticprotected

Sent handler.

Parameters
exthe exchange.
ecBoost ASIO error code.
sizenumber of sent octets.

Definition at line 476 of file client_exchange.cc.

References BUF_LEN, isc_throw, LOG_DEBUG, LOG_ERROR, openNext(), isc::radius::RADIUS_DBG_TRACE, isc::radius::RADIUS_EXCHANGE_SEND_FAILED, isc::radius::RADIUS_EXCHANGE_SENT, isc::radius::radius_logger, receivedHandler(), and isc::radius::RadiusImpl::shutdown_.

Referenced by open().

+ Here is the call graph for this function:

◆ setTimer()

void isc::radius::Exchange::setTimer ( )
protected

Set timer.

Definition at line 689 of file client_exchange.cc.

References cancelTimer(), io_service_, isc::asiolink::IntervalTimer::ONE_SHOT, server_, timeoutHandler(), and timer_.

Referenced by open().

+ Here is the call graph for this function:

◆ shutdown()

void isc::radius::Exchange::shutdown ( )
virtual

Shutdown.

Definition at line 178 of file client_exchange.cc.

References mutex_, and shutdownInternal().

+ Here is the call graph for this function:

◆ shutdownInternal()

void isc::radius::Exchange::shutdownInternal ( )
protectedvirtual

Shutdown.

Definition at line 185 of file client_exchange.cc.

References cancelTimer(), handler_, io_service_, socket_, sync_, and terminated_.

Referenced by ~Exchange(), open(), and shutdown().

+ Here is the call graph for this function:

◆ start()

void isc::radius::Exchange::start ( )
virtual

Start.

Definition at line 151 of file client_exchange.cc.

References identifier_, io_service_, LOG_DEBUG, mutex_, open(), isc::radius::RADIUS_DBG_TRACE, isc::radius::RADIUS_EXCHANGE_START, isc::radius::RADIUS_EXCHANGE_SYNC_RETURN, isc::radius::radius_logger, rc_, started_, and sync_.

+ Here is the call graph for this function:

◆ terminate()

void isc::radius::Exchange::terminate ( )
protected

Terminate.

Definition at line 639 of file client_exchange.cc.

References cancelTimer(), isc::radius::exchangeRCtoText(), handler_, identifier_, isc::util::MultiThreadingMgr::instance(), io_service_, LOG_DEBUG, LOG_ERROR, mutex_, isc::radius::OK_RC, isc::radius::RADIUS_DBG_TRACE, isc::radius::RADIUS_EXCHANGE_FAILED, isc::radius::RADIUS_EXCHANGE_TERMINATE, isc::radius::radius_logger, rc_, isc::radius::REJECT_RC, socket_, sync_, and terminated_.

Referenced by open(), and receivedHandler().

+ Here is the call graph for this function:

◆ timeoutHandler()

void isc::radius::Exchange::timeoutHandler ( ExchangePtr ex)
staticprotected

Timeout handler.

Parameters
exthe exchange.

Definition at line 705 of file client_exchange.cc.

References LOG_ERROR, isc::radius::RADIUS_EXCHANGE_TIMEOUT, isc::radius::radius_logger, and isc::radius::TIMEOUT_RC.

Referenced by setTimer().

Member Data Documentation

◆ BUF_LEN

size_t isc::radius::Exchange::BUF_LEN = 8192
staticconstexpr

Receive buffer size.

Definition at line 61 of file client_exchange.h.

Referenced by sentHandler().

◆ buffer_

std::vector<uint8_t> isc::radius::Exchange::buffer_
protected

Buffer.

Definition at line 189 of file client_exchange.h.

Referenced by Exchange(), Exchange(), and open().

◆ ep_

boost::scoped_ptr<asiolink::UDPEndpoint> isc::radius::Exchange::ep_
protected

UDP endpoint.

Definition at line 165 of file client_exchange.h.

Referenced by Exchange(), Exchange(), and open().

◆ handler_

Handler isc::radius::Exchange::handler_
protected

Termination handler.

Definition at line 208 of file client_exchange.h.

Referenced by Exchange(), Exchange(), shutdownInternal(), and terminate().

◆ identifier_

std::string isc::radius::Exchange::identifier_
protected

The identifier (random value in hexadecimal).

Definition at line 141 of file client_exchange.h.

Referenced by Exchange(), Exchange(), createIdentifier(), getId(), logReplyMessages(), open(), start(), and terminate().

◆ idx_

size_t isc::radius::Exchange::idx_
protected

Current server index.

The current server is either the server indexed by this in the table or when greater than the table size the first postponed server.

Definition at line 177 of file client_exchange.h.

Referenced by Exchange(), Exchange(), and open().

◆ io_service_

asiolink::IOServicePtr isc::radius::Exchange::io_service_
protected

IO service (argument for async or internal for sync).

Definition at line 144 of file client_exchange.h.

Referenced by Exchange(), Exchange(), ~Exchange(), open(), setTimer(), shutdownInternal(), start(), and terminate().

◆ maxretries_

unsigned isc::radius::Exchange::maxretries_
protected

Maximum number of retries for a server.

Note
0 is a valid value which means no retry.

Definition at line 199 of file client_exchange.h.

Referenced by Exchange(), Exchange(), and open().

◆ mutex_

boost::scoped_ptr<std::mutex> isc::radius::Exchange::mutex_
protected

State change mutex.

Definition at line 211 of file client_exchange.h.

Referenced by Exchange(), Exchange(), ~Exchange(), shutdown(), start(), and terminate().

◆ postponed_

std::list<size_t> isc::radius::Exchange::postponed_
protected

List of postponed server indexes.

Definition at line 205 of file client_exchange.h.

Referenced by Exchange(), Exchange(), and open().

◆ rc_

int isc::radius::Exchange::rc_
protected

Error/return code.

Definition at line 156 of file client_exchange.h.

Referenced by Exchange(), Exchange(), getRC(), open(), start(), and terminate().

◆ received_

MessagePtr isc::radius::Exchange::received_
protected

Received message.

Definition at line 186 of file client_exchange.h.

Referenced by Exchange(), Exchange(), getResponse(), and logReplyMessages().

◆ request_

MessagePtr isc::radius::Exchange::request_
protected

Request message.

Definition at line 180 of file client_exchange.h.

Referenced by Exchange(), Exchange(), buildRequest(), and getRequest().

◆ retries_

unsigned isc::radius::Exchange::retries_
protected

Retry counter.

Definition at line 195 of file client_exchange.h.

Referenced by Exchange(), Exchange(), and open().

◆ sent_

MessagePtr isc::radius::Exchange::sent_
protected

Sent message.

Definition at line 183 of file client_exchange.h.

Referenced by Exchange(), Exchange(), buildRequest(), and open().

◆ server_

ServerPtr isc::radius::Exchange::server_
protected

Current server.

Definition at line 171 of file client_exchange.h.

Referenced by Exchange(), Exchange(), buildRequest(), open(), and setTimer().

◆ servers_

Servers isc::radius::Exchange::servers_
protected

Servers (a copy which is what we need).

Definition at line 202 of file client_exchange.h.

Referenced by Exchange(), Exchange(), and open().

◆ size_

size_t isc::radius::Exchange::size_
protected

Number of transmitted octests;.

Definition at line 192 of file client_exchange.h.

Referenced by Exchange(), Exchange(), and open().

◆ socket_

boost::scoped_ptr<RadiusSocket> isc::radius::Exchange::socket_
protected

Socket.

Definition at line 162 of file client_exchange.h.

Referenced by Exchange(), Exchange(), ~Exchange(), open(), shutdownInternal(), and terminate().

◆ start_time_

std::chrono::steady_clock::time_point isc::radius::Exchange::start_time_
protected

Start time.

Definition at line 159 of file client_exchange.h.

Referenced by Exchange(), Exchange(), buildRequest(), and open().

◆ started_

bool isc::radius::Exchange::started_
protected

Started flag.

Definition at line 150 of file client_exchange.h.

Referenced by Exchange(), Exchange(), and start().

◆ sync_

bool isc::radius::Exchange::sync_
protected

Sync / async flag.

Definition at line 147 of file client_exchange.h.

Referenced by Exchange(), Exchange(), ~Exchange(), shutdownInternal(), start(), and terminate().

◆ terminated_

bool isc::radius::Exchange::terminated_
protected

Terminated flag.

Definition at line 153 of file client_exchange.h.

Referenced by Exchange(), Exchange(), open(), shutdownInternal(), and terminate().

◆ timer_

asiolink::IntervalTimerPtr isc::radius::Exchange::timer_
protected

Interval timer.

Definition at line 168 of file client_exchange.h.

Referenced by Exchange(), Exchange(), ~Exchange(), cancelTimer(), and setTimer().


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