Kea 3.1.7
isc::radius::UdpExchange Class Reference

RADIUS/UDP Exchange. More...

#include <client_exchange.h>

Inheritance diagram for isc::radius::UdpExchange:

Public Member Functions

 UdpExchange (const asiolink::IOServicePtr io_service, const MessagePtr &request, unsigned maxretries, const Servers &servers, Handler handler)
 Constructor.
 UdpExchange (const MessagePtr &request, unsigned maxretries, const Servers &servers)
 Constructor.
virtual ~UdpExchange ()
 Destructor.
virtual void shutdown ()
 Shutdown.
virtual void start ()
 Start.
Public Member Functions inherited from isc::radius::Exchange
virtual ~Exchange ()=default
 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.
void processResponse ()
 Process response.

Protected Member Functions

void buildRequest ()
 Build request.
void cancelTimer ()
 Cancel timer.
void open ()
 Instance open.
void setTimer ()
 Set timer.
virtual void shutdownInternal ()
 Shutdown.
void terminate ()
 Terminate.
Protected Member Functions inherited from isc::radius::Exchange
 Exchange (const MessagePtr &request, unsigned maxretries, const Servers &servers)
 Constructor.
 Exchange (const MessagePtr &request, unsigned maxretries, const Servers &servers, Handler handler)
 Constructor.
void buildRequest (const ServerPtr &server, std::chrono::steady_clock::time_point start_time)
 Build request.
void createIdentifier ()
 Create identifier.

Static Protected Member Functions

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

Protected Attributes

std::vector< uint8_t > buffer_
 Buffer.
boost::scoped_ptr< asiolink::UDPEndpointep_
 UDP endpoint.
size_t idx_
 Current server index.
asiolink::IOServicePtr io_service_
 IO service (argument for async or internal for sync).
boost::scoped_ptr< std::mutex > mutex_
 State change mutex.
std::list< size_t > postponed_
 List of postponed server indexes.
unsigned retries_
 Retry counter.
ServerPtr server_
 Current server.
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 terminated_
 Terminated flag.
asiolink::IntervalTimerPtr timer_
 Interval timer.
Protected Attributes inherited from isc::radius::Exchange
Handler handler_
 Termination handler.
std::string identifier_
 The identifier (random value in hexadecimal).
unsigned maxretries_
 Maximum number of retries for a server.
int rc_
 Error/return code.
MessagePtr received_
 Received message.
MessagePtr request_
 Request message.
MessagePtr sent_
 Sent message.
Servers servers_
 Servers (a copy which is what we need).
bool sync_
 Sync / async flag.

Additional Inherited Members

Public Types inherited from isc::radius::Exchange
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.
Static Public Member Functions inherited from isc::radius::Exchange
static ExchangePtr create (const asiolink::IOServicePtr io_service, const MessagePtr &request, unsigned maxretries, const Servers &servers, Handler handler, RadiusProtocol protocol=PW_PROTO_UDP)
 Factory.
static ExchangePtr create (const MessagePtr &request, unsigned maxretries, const Servers &servers)
 Factory.
Static Public Attributes inherited from isc::radius::Exchange
static constexpr size_t BUF_LEN = 8192
 Receive buffer size.

Detailed Description

RADIUS/UDP Exchange.

Definition at line 215 of file client_exchange.h.

Constructor & Destructor Documentation

◆ UdpExchange() [1/2]

isc::radius::UdpExchange::UdpExchange ( 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 116 of file client_exchange.cc.

References isc::radius::Exchange::Exchange(), buffer_, ep_, idx_, io_service_, isc_throw, mutex_, postponed_, retries_, server_, size_, socket_, start_time_, started_, terminated_, and timer_.

Here is the call graph for this function:

◆ UdpExchange() [2/2]

isc::radius::UdpExchange::UdpExchange ( 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 132 of file client_exchange.cc.

References isc::radius::Exchange::Exchange(), buffer_, ep_, idx_, io_service_, mutex_, postponed_, retries_, server_, size_, socket_, start_time_, started_, terminated_, and timer_.

Here is the call graph for this function:

◆ ~UdpExchange()

isc::radius::UdpExchange::~UdpExchange ( )
virtual

Destructor.

Definition at line 144 of file client_exchange.cc.

References io_service_, mutex_, shutdownInternal(), socket_, isc::radius::Exchange::sync_, and timer_.

Here is the call graph for this function:

Member Function Documentation

◆ buildRequest()

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

Build request.

Definition at line 315 of file client_exchange.cc.

References isc::radius::Exchange::buildRequest(), server_, and start_time_.

Referenced by open().

Here is the call graph for this function:

◆ cancelTimer()

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

Cancel timer.

Definition at line 793 of file client_exchange.cc.

References timer_.

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

◆ open()

◆ openNext()

void isc::radius::UdpExchange::openNext ( UdpExchangePtr ex)
inlinestaticprotected

Class open / open next.

Parameters
exthe exchange.

Definition at line 311 of file client_exchange.h.

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

◆ receivedHandler()

void isc::radius::UdpExchange::receivedHandler ( UdpExchangePtr ex,
const boost::system::error_code ec,
const size_t size )
staticprotected

Received handler.

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

Definition at line 673 of file client_exchange.cc.

References isc_throw, LOG_DEBUG, LOG_ERROR, isc::radius::OK_RC, openNext(), isc::radius::RADIUS_DBG_TRACE, isc::radius::radius_logger, isc::radius::RADIUS_UDP_EXCHANGE_RECEIVE_FAILED, isc::radius::RADIUS_UDP_EXCHANGE_RECEIVED, isc::radius::REJECT_RC, isc::radius::RadiusImpl::shutdown_, and terminate().

Referenced by sentHandler().

Here is the call graph for this function:

◆ sentHandler()

void isc::radius::UdpExchange::sentHandler ( UdpExchangePtr 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 538 of file client_exchange.cc.

References isc::radius::Exchange::BUF_LEN, isc_throw, LOG_DEBUG, LOG_ERROR, openNext(), isc::radius::RADIUS_DBG_TRACE, isc::radius::radius_logger, isc::radius::RADIUS_UDP_EXCHANGE_SEND_FAILED, isc::radius::RADIUS_UDP_EXCHANGE_SENT, receivedHandler(), and isc::radius::RadiusImpl::shutdown_.

Referenced by open().

Here is the call graph for this function:

◆ setTimer()

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

Set timer.

Definition at line 785 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::UdpExchange::shutdown ( )
virtual

Shutdown.

Implements isc::radius::Exchange.

Definition at line 217 of file client_exchange.cc.

References mutex_, and shutdownInternal().

Here is the call graph for this function:

◆ shutdownInternal()

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

Shutdown.

Definition at line 224 of file client_exchange.cc.

References cancelTimer(), isc::radius::Exchange::handler_, io_service_, socket_, isc::radius::Exchange::sync_, and terminated_.

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

Here is the call graph for this function:

◆ start()

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

Start.

Implements isc::radius::Exchange.

Definition at line 189 of file client_exchange.cc.

References isc::radius::Exchange::identifier_, io_service_, LOG_DEBUG, mutex_, open(), isc::radius::RADIUS_DBG_TRACE, isc::radius::radius_logger, isc::radius::RADIUS_UDP_EXCHANGE_START, isc::radius::RADIUS_UDP_EXCHANGE_SYNC_RETURN, isc::radius::Exchange::rc_, started_, and isc::radius::Exchange::sync_.

Here is the call graph for this function:

◆ terminate()

◆ timeoutHandler()

void isc::radius::UdpExchange::timeoutHandler ( UdpExchangePtr ex)
staticprotected

Timeout handler.

Parameters
exthe exchange.

Definition at line 801 of file client_exchange.cc.

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

Referenced by setTimer().

Member Data Documentation

◆ buffer_

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

Buffer.

Definition at line 285 of file client_exchange.h.

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

◆ ep_

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

UDP endpoint.

Definition at line 270 of file client_exchange.h.

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

◆ idx_

size_t isc::radius::UdpExchange::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 282 of file client_exchange.h.

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

◆ io_service_

asiolink::IOServicePtr isc::radius::UdpExchange::io_service_
protected

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

Definition at line 255 of file client_exchange.h.

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

◆ mutex_

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

State change mutex.

Definition at line 297 of file client_exchange.h.

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

◆ postponed_

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

List of postponed server indexes.

Definition at line 294 of file client_exchange.h.

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

◆ retries_

unsigned isc::radius::UdpExchange::retries_
protected

Retry counter.

Definition at line 291 of file client_exchange.h.

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

◆ server_

ServerPtr isc::radius::UdpExchange::server_
protected

Current server.

Definition at line 276 of file client_exchange.h.

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

◆ size_

size_t isc::radius::UdpExchange::size_
protected

Number of transmitted octests;.

Definition at line 288 of file client_exchange.h.

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

◆ socket_

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

Socket.

Definition at line 267 of file client_exchange.h.

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

◆ start_time_

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

Start time.

Definition at line 264 of file client_exchange.h.

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

◆ started_

bool isc::radius::UdpExchange::started_
protected

Started flag.

Definition at line 258 of file client_exchange.h.

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

◆ terminated_

bool isc::radius::UdpExchange::terminated_
protected

Terminated flag.

Definition at line 261 of file client_exchange.h.

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

◆ timer_

asiolink::IntervalTimerPtr isc::radius::UdpExchange::timer_
protected

Interval timer.

Definition at line 273 of file client_exchange.h.

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


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