19namespace ph = std::placeholders;
26 auto const by_id = remap.find(subnet_id);
27 if (by_id != remap.end()) {
28 return (by_id->second);
30 auto const by_id0 = remap.find(SUBNET_ID_DEFAULT);
31 if (by_id0 != remap.end()) {
32 return (by_id0->second);
65 request, maxretries, servers, handler,
75 send_attrs = request->getAttributes();
79 .arg(send_attrs ? send_attrs->toText() :
"no attributes");
85 if (result ==
OK_RC) {
88 .arg(recv_attrs ? recv_attrs->toText() :
"no attributes");
93 .arg(recv_attrs ? recv_attrs->toText() :
"no attributes");
124 send_attrs = request->getAttributes();
128 .arg(send_attrs ? send_attrs->toText() :
"no attributes");
140 int result = exchange->getRC();
142 MessagePtr response = exchange->getResponse();
144 recv_attrs = response->getAttributes();
146 if (result ==
OK_RC) {
149 .arg(recv_attrs ? recv_attrs->toText() :
"no attributes");
154 .arg(recv_attrs ? recv_attrs->toText() :
"no attributes");
165 callback(result, recv_attrs);
169 exchange->shutdown();
178 send_attrs = request->getAttributes();
182 .arg(send_attrs ? send_attrs->toText() :
"no attributes");
186 int result =
getRC();
187 if (result ==
OK_RC) {
220 send_attrs = request->getAttributes();
224 .arg(send_attrs ? send_attrs->toText() :
"no attributes");
236 int result = exchange->getRC();
237 if (result ==
OK_RC) {
254 exchange->shutdown();
static AttributePtr fromInt(const uint8_t type, const uint32_t value)
From integer with type.
Collection of attributes.
std::function< void(const ExchangePtr ex)> Handler
Termination handler.
static ExchangePtr create(const asiolink::IOServicePtr io_service, const MessagePtr &request, unsigned maxretries, const Servers &servers, Handler handler, RadiusProtocol protocol=PW_PROTO_UDP)
Factory.
RadiusAcct(uint32_t subnet_id, const AttributesPtr &send_attrs, bool sync, const Exchange::Handler &handler)
Constructor.
static void invokeCallback(const CallbackAcct &callback, const ExchangePtr exchange)
Invoke accounting communication callback.
virtual void start() override
Start communication.
RadiusAsyncAcct(uint32_t subnet_id, const AttributesPtr &send_attrs, const CallbackAcct &callback)
Constructor.
static void invokeCallback(const CallbackAuth &callback, const ExchangePtr exchange)
Invoke authentication communication callback.
virtual void start() override
Start communication.
RadiusAsyncAuth(uint32_t subnet_id, const AttributesPtr &send_attrs, const CallbackAuth &callback)
Constructor.
RadiusAuth(uint32_t subnet_id, const AttributesPtr &send_attrs, bool sync, const Exchange::Handler &handler)
Constructor.
void setAccountingIdleTimer()
Set the accounting idle timer.
const Servers & getAccessServers() const
Get servers for access.
void unregisterExchange(ExchangePtr exchange)
Unregister Exchange.
unsigned retries_
Retries.
std::map< uint32_t, uint32_t > remap_
Subnet ID to NAS port map.
const Servers & getAccountingServers() const
Get servers for accounting.
void setAccessIdleTimer()
Set the access idle timer.
static RadiusImpl & instance()
RadiusImpl is a singleton class.
int getRC() const
Get the error code.
RadiusRequest(const MsgCode code, uint32_t subnet_id, const AttributesPtr &send_attrs, bool sync, const Exchange::Handler &handler)
Constructor.
AttributesPtr getRespAttrs() const
Get response attributes.
virtual void start()
Start communication.
uint32_t nas_port_
Client/NAS port (from Subnet Id).
ExchangePtr exchange_
Exchange.
virtual void start() override
Start communication.
CallbackAcct callback_
Accounting termination callback.
CallbackAuth callback_
Authentication termination callback.
virtual void start() override
Start communication.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
const isc::log::MessageID RADIUS_AUTHENTICATION_SYNC_FAILED
const isc::log::MessageID RADIUS_AUTHENTICATION_ASYNC_FAILED
const isc::log::MessageID RADIUS_ACCOUNTING_ASYNC_SUCCEED
const isc::log::MessageID RADIUS_ACCOUNTING_SYNC_SUCCEED
const isc::log::MessageID RADIUS_AUTHENTICATION_ASYNC
const isc::log::MessageID RADIUS_AUTHENTICATION_SYNC
boost::shared_ptr< Attributes > AttributesPtr
Shared pointers to attribute collection.
std::function< void(int)> CallbackAcct
Type of callback for accounting termination.
const isc::log::MessageID RADIUS_ACCOUNTING_SYNC
string exchangeRCtoText(const int rc)
ExchangeRC value -> name function.
const isc::log::MessageID RADIUS_AUTHENTICATION_SYNC_REJECTED
std::vector< ServerPtr > Servers
Type of RADIUS server collection.
boost::shared_ptr< Exchange > ExchangePtr
Type of shared pointers to RADIUS exchange object.
const isc::log::MessageID RADIUS_ACCOUNTING_SYNC_FAILED
const int RADIUS_DBG_TRACE
Radius logging levels.
const isc::log::MessageID RADIUS_ACCOUNTING_ASYNC_FAILED
const isc::log::MessageID RADIUS_ACCOUNTING_ASYNC
const isc::log::MessageID RADIUS_AUTHENTICATION_SYNC_ACCEPTED
std::function< void(int, AttributesPtr)> CallbackAuth
Type of callback for authentication termination.
isc::log::Logger radius_logger("radius-hooks")
Radius Logger.
boost::shared_ptr< Message > MessagePtr
Shared pointers to message.
MsgCode
Standard RADIUS message code.
uint32_t getNASPort(uint32_t subnet_id)
Remap a subnet ID to a NAS port.
const isc::log::MessageID RADIUS_AUTHENTICATION_ASYNC_ACCEPTED
const isc::log::MessageID RADIUS_AUTHENTICATION_ASYNC_REJECTED
Defines the logger used by the top-level component of kea-lfc.