![]() |
Kea 3.1.7
|
#include <client_exchange.h>
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::UDPEndpoint > | ep_ |
| 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< RadiusSocket > | socket_ |
| 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 SocketCallback > | RadiusSocket |
| 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. | |
RADIUS/UDP Exchange.
Definition at line 215 of file client_exchange.h.
| isc::radius::UdpExchange::UdpExchange | ( | const asiolink::IOServicePtr | io_service, |
| const MessagePtr & | request, | ||
| unsigned | maxretries, | ||
| const Servers & | servers, | ||
| Handler | handler ) |
Constructor.
Async version.
| io_service | Reference to the IO service. |
| request | request message to send. |
| maxretries | maximum number of retries for a server. |
| servers | Servers. |
| handler | Termination 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_.
| isc::radius::UdpExchange::UdpExchange | ( | const MessagePtr & | request, |
| unsigned | maxretries, | ||
| const Servers & | servers ) |
Constructor.
Sync version.
| request | request message to send. |
| maxretries | maximum number of retries for a server. |
| servers | Servers. |
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_.
|
virtual |
Destructor.
Definition at line 144 of file client_exchange.cc.
References io_service_, mutex_, shutdownInternal(), socket_, isc::radius::Exchange::sync_, and timer_.
|
protected |
Build request.
Definition at line 315 of file client_exchange.cc.
References isc::radius::Exchange::buildRequest(), server_, and start_time_.
Referenced by open().
|
protected |
Cancel timer.
Definition at line 793 of file client_exchange.cc.
References timer_.
Referenced by open(), setTimer(), shutdownInternal(), and terminate().
|
protected |
Instance open.
Definition at line 325 of file client_exchange.cc.
References buffer_, buildRequest(), cancelTimer(), ep_, isc::radius::ERROR_RC, isc::radius::Exchange::identifier_, idx_, io_service_, isc_throw, LOG_DEBUG, LOG_ERROR, isc::radius::Exchange::maxretries_, openNext(), postponed_, isc::radius::RADIUS_DBG_TRACE, isc::radius::radius_logger, isc::radius::RADIUS_UDP_EXCHANGE_OPEN_FAILED, isc::radius::RADIUS_UDP_EXCHANGE_SEND_NEW, isc::radius::RADIUS_UDP_EXCHANGE_SEND_RETRY, isc::radius::Exchange::rc_, retries_, isc::radius::Exchange::sent_, sentHandler(), server_, isc::radius::Exchange::servers_, setTimer(), isc::radius::RadiusImpl::shutdown_, shutdownInternal(), size_, socket_, start_time_, terminate(), terminated_, isc::radius::TIMEOUT_RC, and isc::Exception::what().
Referenced by start().
|
inlinestaticprotected |
Class open / open next.
| ex | the exchange. |
Definition at line 311 of file client_exchange.h.
Referenced by open(), receivedHandler(), and sentHandler().
|
staticprotected |
Received handler.
| ex | the exchange. |
| ec | Boost ASIO error code. |
| size | number 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().
|
staticprotected |
Sent handler.
| ex | the exchange. |
| ec | Boost ASIO error code. |
| size | number 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().
|
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().
|
virtual |
Shutdown.
Implements isc::radius::Exchange.
Definition at line 217 of file client_exchange.cc.
References mutex_, and 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().
|
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_.
|
protected |
Terminate.
Definition at line 734 of file client_exchange.cc.
References cancelTimer(), isc::radius::exchangeRCtoText(), isc::radius::Exchange::handler_, isc::radius::Exchange::identifier_, isc::util::MultiThreadingMgr::instance(), io_service_, LOG_DEBUG, LOG_ERROR, mutex_, isc::radius::OK_RC, isc::radius::RADIUS_DBG_TRACE, isc::radius::radius_logger, isc::radius::RADIUS_UDP_EXCHANGE_FAILED, isc::radius::RADIUS_UDP_EXCHANGE_TERMINATE, isc::radius::Exchange::rc_, isc::radius::REJECT_RC, socket_, isc::radius::Exchange::sync_, and terminated_.
Referenced by open(), and receivedHandler().
|
staticprotected |
Timeout handler.
| ex | the 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().
|
protected |
Buffer.
Definition at line 285 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), and open().
|
protected |
UDP endpoint.
Definition at line 270 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), and open().
|
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().
|
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().
|
protected |
State change mutex.
Definition at line 297 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), ~UdpExchange(), shutdown(), start(), and terminate().
|
protected |
List of postponed server indexes.
Definition at line 294 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), and open().
|
protected |
Retry counter.
Definition at line 291 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), and open().
|
protected |
Current server.
Definition at line 276 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), buildRequest(), open(), and setTimer().
|
protected |
Number of transmitted octests;.
Definition at line 288 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), and open().
|
protected |
Socket.
Definition at line 267 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), ~UdpExchange(), open(), shutdownInternal(), and terminate().
|
protected |
Start time.
Definition at line 264 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), buildRequest(), and open().
|
protected |
Started flag.
Definition at line 258 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), and start().
|
protected |
Terminated flag.
Definition at line 261 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), open(), shutdownInternal(), and terminate().
|
protected |
Interval timer.
Definition at line 273 of file client_exchange.h.
Referenced by UdpExchange(), UdpExchange(), ~UdpExchange(), cancelTimer(), and setTimer().