Kea 3.1.1
radius_callout.cc File Reference
#include <config.h>
#include <asiolink/io_service_mgr.h>
#include <cc/command_interpreter.h>
#include <cc/simple_parser.h>
#include <hooks/hooks.h>
#include <dhcp/pkt4.h>
#include <dhcp/pkt6.h>
#include <dhcpsrv/lease.h>
#include <dhcpsrv/subnet.h>
#include <radius.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/host_mgr.h>
#include <process/daemon.h>
#include <radius_log.h>
#include <radius_parsers.h>
#include <radius_access.h>
#include <radius_accounting.h>
#include <util/multi_threading_mgr.h>
#include <string>
#include <sstream>
#include <vector>
+ Include dependency graph for radius_callout.cc:

Go to the source code of this file.

Functions

int command_processed (CalloutHandle &handle)
 This callout is called at the "command_processed" hook point.
 
int dhcp4_srv_configured (CalloutHandle &)
 This function is called by the DHCPv4 server when it is configured.
 
int dhcp6_srv_configured (CalloutHandle &)
 This function is called by the DHCPv6 server when it is configured.
 
int lease4_decline (CalloutHandle &handle)
 This callout is called at the "lease4_decline" hook.
 
int lease4_expire (CalloutHandle &handle)
 This callout is called at the "lease4_expire" hook.
 
int lease4_release (CalloutHandle &handle)
 This callout is called at the "lease4_release" hook.
 
int lease4_renew (CalloutHandle &handle)
 This callout is called at the "lease4_renew" hook.
 
int lease4_select (CalloutHandle &handle)
 This callout is called at the "lease4_select" hook.
 
int lease6_decline (CalloutHandle &handle)
 This callout is called at the "lease6_decline" hook.
 
int lease6_expire (CalloutHandle &handle)
 This callout is called at the "lease6_expire" hook.
 
int lease6_rebind (CalloutHandle &handle)
 This callout is called at the "lease6_rebind" hook.
 
int lease6_release (CalloutHandle &handle)
 This callout is called at the "lease6_release" hook.
 
int lease6_renew (CalloutHandle &handle)
 This callout is called at the "lease6_renew" hook.
 
int lease6_select (CalloutHandle &handle)
 This callout is called at the "lease6_select" hook.
 
int load (LibraryHandle &handle)
 This function is called when the library is loaded.
 
int multi_threading_compatible ()
 This function is called to retrieve the multi-threading compatibility.
 
int subnet4_select (CalloutHandle &handle)
 This callout tries to retrieve host information from cache.
 
int subnet6_select (CalloutHandle &handle)
 This callout tries to retrieve host information from cache.
 
int unload ()
 This function is called when the library is unloaded.
 

Function Documentation

◆ command_processed()

int command_processed ( CalloutHandle & handle)

This callout is called at the "command_processed" hook point.

If any lease{4,6}-add/update/del command is issued, this code sends appropriate Radius packets to the accounting server.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 884 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_ADD, isc::radius::EVENT_DEL, isc::radius::EVENT_UPDATE, isc::hooks::CalloutHandle::getArgument(), isc::data::SimpleParser::getInteger(), isc::radius::RadiusImpl::instance(), LOG_ERROR, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, isc::radius::RadiusAccounting::runAsync(), and Element::string.

+ Here is the call graph for this function:

◆ dhcp4_srv_configured()

int dhcp4_srv_configured ( CalloutHandle & )

This function is called by the DHCPv4 server when it is configured.

The only purpose of this callout is to retrieve io_service_ reference.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 421 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::asiolink::IOServiceMgr::instance(), isc::radius::RadiusImpl::instance(), isc::asiolink::IOServiceMgr::registerIOService(), and isc::radius::RadiusImpl::startServices().

+ Here is the call graph for this function:

◆ dhcp6_srv_configured()

int dhcp6_srv_configured ( CalloutHandle & )

This function is called by the DHCPv6 server when it is configured.

The only purpose of this callout is to retrieve io_service_ reference.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 433 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::asiolink::IOServiceMgr::instance(), isc::radius::RadiusImpl::instance(), isc::asiolink::IOServiceMgr::registerIOService(), and isc::radius::RadiusImpl::startServices().

+ Here is the call graph for this function:

◆ lease4_decline()

int lease4_decline ( CalloutHandle & handle)

This callout is called at the "lease4_decline" hook.

It does transmit Accounting-Request with Acct-Status-Type set to Stop.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 643 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_DECLINE, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ lease4_expire()

int lease4_expire ( CalloutHandle & handle)

This callout is called at the "lease4_expire" hook.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 673 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_EXPIRE, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ lease4_release()

int lease4_release ( CalloutHandle & handle)

This callout is called at the "lease4_release" hook.

It does transmit Accounting-Request with Acct-Status-Type set to Stop.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 610 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_RELEASE, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ lease4_renew()

int lease4_renew ( CalloutHandle & handle)

This callout is called at the "lease4_renew" hook.

It does transmit Accounting-Request with Acct-Status-Type set to Interim-Update.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 577 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_RENEW, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ lease4_select()

int lease4_select ( CalloutHandle & handle)

This callout is called at the "lease4_select" hook.

It does transmit Accounting-Request with Acct-Status-Type set to Start if a lease has been assigned.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 536 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_CREATE, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ lease6_decline()

int lease6_decline ( CalloutHandle & handle)

This callout is called at the "lease6_decline" hook.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 823 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_DECLINE, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ lease6_expire()

int lease6_expire ( CalloutHandle & handle)

This callout is called at the "lease6_expire" hook.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 852 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_EXPIRE, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ lease6_rebind()

int lease6_rebind ( CalloutHandle & handle)

This callout is called at the "lease6_rebind" hook.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 765 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_REBIND, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ lease6_release()

int lease6_release ( CalloutHandle & handle)

This callout is called at the "lease6_release" hook.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 794 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_RELEASE, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ lease6_renew()

int lease6_renew ( CalloutHandle & handle)

This callout is called at the "lease6_renew" hook.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 736 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_RENEW, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ lease6_select()

int lease6_select ( CalloutHandle & handle)

This callout is called at the "lease6_select" hook.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 702 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::radius::EVENT_CREATE, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), LOG_ERROR, CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_SKIP, isc::radius::RADIUS_HOOK_FAILED, isc::radius::radius_logger, and isc::radius::RadiusAccounting::runAsync().

+ Here is the call graph for this function:

◆ load()

int load ( LibraryHandle & handle)

This function is called when the library is loaded.

Parameters
handlelibrary handle
Returns
0 when initialization is successful, 1 otherwise

Definition at line 366 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::dhcp::CfgMgr::getFamily(), isc::process::Daemon::getProcName(), isc::dhcp::CfgMgr::instance(), isc::radius::RadiusImpl::instance(), isc_throw, LOG_ERROR, LOG_INFO, isc::radius::RADIUS_CONFIGURATION_FAILED, isc::radius::RADIUS_INIT_OK, and isc::radius::radius_logger.

+ Here is the call graph for this function:

◆ multi_threading_compatible()

int multi_threading_compatible ( )

This function is called to retrieve the multi-threading compatibility.

Returns
1 which means compatible with multi-threading,

Definition at line 411 of file radius_callout.cc.

◆ subnet4_select()

int subnet4_select ( CalloutHandle & handle)

This callout tries to retrieve host information from cache.

This function is called by the DHCPv4 server when a subnet is being selected. It uses input packet to extract identifier and then looks for host entry in the host cache.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 447 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getParkingLotHandlePtr(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_PARK, CalloutHandle::NEXT_STEP_SKIP, and isc::hooks::CalloutHandle::setStatus().

+ Here is the call graph for this function:

◆ subnet6_select()

int subnet6_select ( CalloutHandle & handle)

This callout tries to retrieve host information from cache.

This function is called by the DHCPv4 server when a subnet is being selected. It uses input packet to extract identifier and then looks for host entry in the host cache.

Parameters
handlecallout handle passed to the callout.
Returns
0 on success, 1 otherwise.

Definition at line 492 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getParkingLotHandlePtr(), isc::hooks::CalloutHandle::getStatus(), isc::radius::RadiusImpl::instance(), CalloutHandle::NEXT_STEP_DROP, CalloutHandle::NEXT_STEP_PARK, CalloutHandle::NEXT_STEP_SKIP, and isc::hooks::CalloutHandle::setStatus().

+ Here is the call graph for this function:

◆ unload()

int unload ( )

This function is called when the library is unloaded.

Returns
0 if deregistration was successful, 1 otherwise

Definition at line 401 of file radius_callout.cc.

References isc::config::CONTROL_RESULT_SUCCESS, isc::asiolink::IOServiceMgr::instance(), isc::radius::RadiusImpl::instance(), LOG_INFO, isc::radius::RADIUS_DEINIT_OK, isc::radius::radius_logger, isc::radius::RadiusImpl::reset(), and isc::asiolink::IOServiceMgr::unregisterIOService().

+ Here is the call graph for this function: