![]() |
Kea 3.1.10
|
#include <client_exchange.h>
Public Types | |
| 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. | |
Public Member Functions | |
| 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. | |
| virtual void | shutdown ()=0 |
| Shutdown. | |
| virtual void | start ()=0 |
| Start. | |
Static Public Member Functions | |
| 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 | |
| static constexpr size_t | BUF_LEN = 8192 |
| Receive buffer size. | |
Protected Member Functions | |
| 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. | |
Protected Attributes | |
| 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. | |
RADIUS Base Exchange.
Definition at line 58 of file client_exchange.h.
| typedef std::function<void(const ExchangePtr ex)> isc::radius::Exchange::Handler |
Termination handler.
Definition at line 71 of file client_exchange.h.
| typedef asiolink::UDPSocket<const SocketCallback> isc::radius::Exchange::RadiusSocket |
Type of RADIUS UDP sockets.
Definition at line 68 of file client_exchange.h.
| 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.
|
virtualdefault |
Destructor.
|
protected |
Constructor.
Async version.
| request | request message to send. |
| maxretries | maximum number of retries for a server. |
| servers | Servers. |
| handler | Termination handler. |
Definition at line 59 of file client_exchange.cc.
References createIdentifier(), isc::radius::ERROR_RC, handler_, identifier_, if(), isc_throw, maxretries_, rc_, received_, request_, sent_, servers_, and sync_.
Referenced by isc::radius::TcpExchange::TcpExchange(), isc::radius::UdpExchange::UdpExchange(), and isc::radius::UdpExchange::UdpExchange().
|
protected |
Constructor.
Sync version.
| request | request message to send. |
| maxretries | maximum number of retries for a server. |
| servers | Servers. |
Definition at line 78 of file client_exchange.cc.
References createIdentifier(), isc::radius::ERROR_RC, handler_, identifier_, isc_throw, maxretries_, rc_, received_, request_, sent_, servers_, and sync_.
|
protected |
Build request.
| server | Server where to send the request. |
| start_time | Start time of the exchange. |
Definition at line 247 of file client_exchange.cc.
References isc::radius::Attribute::fromBinary(), isc::radius::Attribute::fromInt(), isc::radius::Attribute::fromIpAddr(), isc::radius::Attribute::fromIpv6Addr(), isc::asiolink::IOAddress::getFamily(), isc::radius::RadiusImpl::instance(), isc_throw, isc::radius::PW_ACCESS_REQUEST, isc::radius::PW_ACCOUNTING_REQUEST, isc::radius::PW_ACCT_DELAY_TIME, isc::radius::PW_MESSAGE_AUTHENTICATOR, isc::radius::PW_NAS_IP_ADDRESS, isc::radius::PW_NAS_IPV6_ADDRESS, isc::radius::PW_STATUS_SERVER, request_, and sent_.
Referenced by isc::radius::TcpExchange::buildRequest(), and isc::radius::UdpExchange::buildRequest().
|
static |
Factory.
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. |
| protocol | Protocol (default to UDP). |
Definition at line 94 of file client_exchange.cc.
References isc::radius::PW_PROTO_UDP.
Referenced by isc::radius::RadiusAcctStatus::RadiusAcctStatus(), isc::radius::RadiusAuthStatus::RadiusAuthStatus(), isc::radius::RadiusRequest::RadiusRequest(), and isc::radius::RadiusTlsStatus::RadiusTlsStatus().
|
static |
Factory.
Sync version (UDP only).
| request | request message to send. |
| maxretries | maximum number of retries for a server. |
| servers | Servers. |
Definition at line 110 of file client_exchange.cc.
|
protected |
Create identifier.
Definition at line 157 of file client_exchange.cc.
References identifier_, isc_throw, and isc::cryptolink::random().
Referenced by Exchange(), and Exchange().
|
inline |
Get identifier.
Definition at line 107 of file client_exchange.h.
References identifier_.
|
inline |
Get the error code.
Definition at line 114 of file client_exchange.h.
References rc_.
|
inline |
Get the request.
Definition at line 121 of file client_exchange.h.
References request_.
|
inline |
Get the response.
Definition at line 128 of file client_exchange.h.
References received_.
| void isc::radius::Exchange::logReplyMessages | ( | ) | const |
Log reply messages.
Definition at line 169 of file client_exchange.cc.
References identifier_, LOG_INFO, isc::radius::PW_REPLY_MESSAGE, isc::radius::radius_logger, isc::radius::RADIUS_REPLY_MESSAGE_ATTRIBUTE, and received_.
| void isc::radius::Exchange::processResponse | ( | ) |
Process response.
Definition at line 585 of file client_exchange.cc.
References isc::radius::BADRESP_RC, isc::radius::exchangeRCtoText(), identifier_, isc::radius::RadiusImpl::instance(), isc_throw, LOG_DEBUG, LOG_ERROR, isc::radius::msgCodeToText(), isc::radius::OK_RC, isc::radius::PW_ACCESS_ACCEPT, isc::radius::PW_ACCESS_REJECT, isc::radius::PW_ACCESS_REQUEST, isc::radius::PW_ACCOUNTING_REQUEST, isc::radius::PW_ACCOUNTING_RESPONSE, isc::radius::PW_MESSAGE_AUTHENTICATOR, isc::radius::PW_STATUS_SERVER, isc::radius::RADIUS_DBG_TRACE, isc::radius::RADIUS_EXCHANGE_RECEIVED_ACCESS_ACCEPT, isc::radius::RADIUS_EXCHANGE_RECEIVED_ACCESS_REJECT, isc::radius::RADIUS_EXCHANGE_RECEIVED_ACCOUNTING_RESPONSE, isc::radius::RADIUS_EXCHANGE_RECEIVED_BAD_RESPONSE, isc::radius::RADIUS_EXCHANGE_RECEIVED_MISMATCH, isc::radius::RADIUS_EXCHANGE_RECEIVED_RESPONSE, isc::radius::RADIUS_EXCHANGE_RECEIVED_UNEXPECTED, isc::radius::radius_logger, rc_, received_, isc::radius::REJECT_RC, request_, sent_, and isc::Exception::what().
|
pure virtual |
Shutdown.
Implemented in isc::radius::TcpExchange, and isc::radius::UdpExchange.
|
pure virtual |
Start.
Implemented in isc::radius::TcpExchange, and isc::radius::UdpExchange.
|
staticconstexpr |
Receive buffer size.
Definition at line 61 of file client_exchange.h.
Referenced by isc::radius::UdpExchange::sentHandler().
|
protected |
Termination handler.
Definition at line 195 of file client_exchange.h.
Referenced by Exchange(), Exchange(), isc::radius::TcpExchange::shutdown(), isc::radius::UdpExchange::shutdownInternal(), isc::radius::TcpExchange::start(), and isc::radius::UdpExchange::terminate().
|
protected |
The identifier (random value in hexadecimal).
Definition at line 170 of file client_exchange.h.
Referenced by Exchange(), Exchange(), createIdentifier(), getId(), logReplyMessages(), isc::radius::UdpExchange::open(), processResponse(), isc::radius::TcpExchange::start(), isc::radius::UdpExchange::start(), and isc::radius::UdpExchange::terminate().
|
protected |
Maximum number of retries for a server.
Definition at line 189 of file client_exchange.h.
Referenced by Exchange(), Exchange(), and isc::radius::UdpExchange::open().
|
protected |
Error/return code.
Definition at line 176 of file client_exchange.h.
Referenced by Exchange(), Exchange(), getRC(), isc::radius::UdpExchange::open(), processResponse(), isc::radius::TcpExchange::start(), isc::radius::UdpExchange::start(), and isc::radius::UdpExchange::terminate().
|
protected |
Received message.
Definition at line 185 of file client_exchange.h.
Referenced by Exchange(), Exchange(), getResponse(), logReplyMessages(), and processResponse().
|
protected |
Request message.
Definition at line 179 of file client_exchange.h.
Referenced by Exchange(), Exchange(), buildRequest(), getRequest(), and processResponse().
|
protected |
Sent message.
Definition at line 182 of file client_exchange.h.
Referenced by Exchange(), Exchange(), buildRequest(), isc::radius::UdpExchange::open(), processResponse(), and isc::radius::TcpExchange::start().
|
protected |
Servers (a copy which is what we need).
Definition at line 192 of file client_exchange.h.
Referenced by Exchange(), Exchange(), isc::radius::TcpExchange::TcpExchange(), and isc::radius::UdpExchange::open().
|
protected |
Sync / async flag.
Definition at line 173 of file client_exchange.h.
Referenced by Exchange(), Exchange(), isc::radius::UdpExchange::~UdpExchange(), isc::radius::UdpExchange::shutdownInternal(), isc::radius::UdpExchange::start(), and isc::radius::UdpExchange::terminate().