59 for (
auto const& name : names) {
60 if (keywords.count(name) == 0) {
83 uint32_t subnet_id = subnet->getID();
84 uint32_t host_subnet_id =
85 (subnet->getReservationsGlobal() ? SUBNET_ID_GLOBAL : subnet_id);
88 if (!
impl.auth_->getIdentifier(*query,
id, text)) {
99 if (host && host->getContext() &&
101 host->getContext()->contains(
"subnet-id")) {
104 subnet_id =
static_cast<uint32_t
>(reselected->intValue());
107 .arg(subnet->getID())
110 if (subnet_id == SUBNET_ID_UNUSED) {
116 uint32_t new_host_subnet_id = host_subnet_id;
117 if (subnet_id != subnet->getID()) {
120 getCfgSubnets4()->getSubnet(subnet_id);
123 "can't find subnet with id: " << subnet_id);
126 (new_subnet->getReservationsGlobal() ?
127 SUBNET_ID_GLOBAL : subnet_id);
131 if (new_host_subnet_id != host_subnet_id) {
136 }
catch (
const std::exception&) {
139 static_cast<void>(
impl.cache_->remove(bad));
146 if (host && host->getContext() &&
158 if (!host->getIPv4Reservation().isV4Zero()) {
163 if (framed_pool && (framed_pool->getValueType() ==
PW_TYPE_STRING)) {
164 query->addClass(framed_pool->toString());
179 impl.auth_->requests4_.get(
id);
182 if (pending_request) {
184 .arg(query->getLabel())
187 static_cast<int64_t
>(1));
189 static_cast<int64_t
>(1));
195 size_t max_requests =
impl.auth_->max_pending_requests_;
196 if (((max_requests > 0) &&
197 (
impl.auth_->requests4_.size() >= max_requests)) ||
198 !
impl.checkExchangeListRoom()) {
201 .arg(query->getLabel())
204 static_cast<int64_t
>(1));
206 static_cast<int64_t
>(1));
212 handler =
impl.auth_->buildAuth(*query, subnet_id,
id, text);
216 static_cast<int64_t
>(1));
218 static_cast<int64_t
>(1));
224 impl.auth_->requests4_.set(
id, query);
241 uint32_t subnet_id = subnet->getID();
242 uint32_t host_subnet_id =
243 (subnet->getReservationsGlobal() ? SUBNET_ID_GLOBAL : subnet_id);
246 if (!
impl.auth_->getIdentifier(*query,
id, text)) {
257 if (host && host->getContext() &&
259 host->getContext()->contains(
"subnet-id")) {
262 subnet_id =
static_cast<uint32_t
>(reselected->intValue());
265 .arg(subnet->getID())
268 if (subnet_id == SUBNET_ID_UNUSED) {
274 uint32_t new_host_subnet_id = host_subnet_id;
275 if (subnet_id != subnet->getID()) {
278 getCfgSubnets6()->getSubnet(subnet_id);
281 "can't find subnet with id: " << subnet_id);
284 (new_subnet->getReservationsGlobal() ?
285 SUBNET_ID_GLOBAL : subnet_id);
289 if (new_host_subnet_id != host_subnet_id) {
294 }
catch (
const std::exception&) {
297 static_cast<void>(
impl.cache_->remove(bad));
304 if (host && host->getContext() &&
317 if (host->hasIPv6Reservation()) {
322 if (framed_pool && (framed_pool->getValueType() ==
PW_TYPE_STRING)) {
323 query->addClass(framed_pool->toString());
338 impl.auth_->requests6_.get(
id);
341 if (pending_request) {
343 .arg(query->getLabel())
346 static_cast<int64_t
>(1));
348 static_cast<int64_t
>(1));
354 size_t max_requests =
impl.auth_->max_pending_requests_;
355 if (((max_requests > 0) &&
356 (
impl.auth_->requests6_.size() >= max_requests)) ||
357 !
impl.checkExchangeListRoom()) {
360 .arg(query->getLabel())
363 static_cast<int64_t
>(1));
365 static_cast<int64_t
>(1));
371 handler =
impl.auth_->buildAuth(*query, subnet_id,
id, text);
375 static_cast<int64_t
>(1));
377 static_cast<int64_t
>(1));
383 impl.auth_->requests6_.set(
id, query);
402 if (family == AF_INET) {
403 if (proc_name !=
"kea-dhcp4") {
405 <<
", expected kea-dhcp4");
408 if (proc_name !=
"kea-dhcp6") {
410 <<
", expected kea-dhcp6");
418 }
catch (
const std::exception& ex) {
486 if (!impl.serveAccess() || !impl.checkHostBackends()) {
493 if (!query || !subnet || (subnet->getID() == 0)) {
497 parking_lot->reference(query);
501 parking_lot->dereference(query);
507 parking_lot->dereference(query);
509 static_cast<int64_t
>(1));
511 static_cast<int64_t
>(1));
535 if (!impl.serveAccess() || !impl.checkHostBackends()) {
542 if (!query || !subnet || (subnet->getID() == 0)) {
546 parking_lot->reference(query);
550 parking_lot->dereference(query);
556 parking_lot->dereference(query);
558 static_cast<int64_t
>(1));
560 static_cast<int64_t
>(1));
583 if (!impl.serveAccounting() || !impl.getIOContext()) {
587 bool fake_allocation =
false;
588 handle.
getArgument(
"fake_allocation", fake_allocation);
589 if (fake_allocation) {
603 }
catch (
const std::exception& ex) {
605 .arg(
"lease4_select")
627 if (!impl.serveAccounting() || !impl.getIOContext()) {
633 if (!lease || (lease->reuseable_valid_lft_ > 0)) {
643 }
catch (
const std::exception& ex) {
667 if (!impl.serveAccounting() || !impl.getIOContext()) {
679 }
catch (
const std::exception& ex) {
681 .arg(
"lease4_release")
703 if (!impl.serveAccounting() || !impl.getIOContext()) {
715 }
catch (
const std::exception& ex) {
717 .arg(
"lease4_decline")
736 if (!impl.serveAccounting() || !impl.getIOContext()) {
747 }
catch (
const std::exception& ex) {
749 .arg(
"lease4_expire")
768 if (!impl.serveAccounting() || !impl.getIOContext()) {
771 bool fake_allocation;
772 handle.
getArgument(
"fake_allocation", fake_allocation);
773 if (fake_allocation) {
784 }
catch (
const std::exception& ex) {
786 .arg(
"lease6_select")
805 if (!impl.serveAccounting() || !impl.getIOContext()) {
811 if (!lease || (lease->reuseable_valid_lft_ > 0)) {
820 }
catch (
const std::exception& ex) {
841 if (!impl.serveAccounting() || !impl.getIOContext()) {
847 if (!lease || (lease->reuseable_valid_lft_ > 0)) {
856 }
catch (
const std::exception& ex) {
858 .arg(
"lease6_rebind")
877 if (!impl.serveAccounting() || !impl.getIOContext()) {
888 }
catch (
const std::exception& ex) {
890 .arg(
"lease6_release")
909 if (!impl.serveAccounting() || !impl.getIOContext()) {
920 }
catch (
const std::exception& ex) {
922 .arg(
"lease6_decline")
941 if (!impl.serveAccounting() || !impl.getIOContext()) {
952 }
catch (
const std::exception& ex) {
954 .arg(
"lease6_expire")
970 if (!impl.serveAccounting() || !impl.getIOContext()) {
980 if (!arguments || !response) {
1000 origin->stringValue() ==
"ha-partner");
1001 if (!impl.acct_->peer_updates_ && is_from_ha_partner) {
1007 if (name ==
"lease4-add") {
1008 handler = impl.acct_->buildAcct4(arguments,
EVENT_ADD);
1009 }
else if (name ==
"lease4-update") {
1010 handler = impl.acct_->buildAcct4(arguments,
EVENT_UPDATE);
1011 }
else if (name==
"lease4-del") {
1012 handler = impl.acct_->buildAcct4(arguments,
EVENT_DEL);
1013 }
else if (name ==
"lease6-add") {
1014 handler = impl.acct_->buildAcct6(arguments,
EVENT_ADD);
1015 }
else if (name ==
"lease6-update") {
1016 handler = impl.acct_->buildAcct6(arguments,
EVENT_UPDATE);
1017 }
else if (name==
"lease6-del") {
1018 handler = impl.acct_->buildAcct6(arguments,
EVENT_DEL);
1024 }
catch (
const std::exception& ex) {
1026 ss <<
"command_processed: " << name;
CalloutNextStep
Specifies allowed next steps.
@ NEXT_STEP_PARK
park the packet
@ NEXT_STEP_DROP
drop the packet
@ NEXT_STEP_SKIP
skip the next processing step
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown when an unexpected error condition occurs.
static IOServiceMgr & instance()
Access the IOServiceMgr singleton instance.
void registerIOService(IOServicePtr io_service)
Register IOService.
void unregisterIOService(IOServicePtr io_service)
Unregister IOService.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
uint16_t getFamily() const
Returns address family.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
ConstHostPtr get6Any(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len, const HostMgrOperationTarget target) const
Returns any host connected to the IPv6 subnet.
ConstHostPtr get4Any(const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len, const HostMgrOperationTarget target) const
Returns any host connected to the IPv4 subnet.
static HostMgr & instance()
Returns a sole instance of the HostMgr.
Represents a device with IPv4 and/or IPv6 reservations.
Per-packet callout handle.
ParkingLotHandlePtr getParkingLotHandlePtr() const
Returns pointer to the parking lot handle for this hook point.
CalloutNextStep getStatus() const
Returns the next processing step.
void setStatus(const CalloutNextStep next)
Sets the next processing step.
void getArgument(const std::string &name, T &value) const
Get argument.
void setArgument(const std::string &name, T value)
Set argument.
isc::data::ConstElementPtr getParameter(const std::string &name)
Returns configuration parameter for the library.
std::vector< std::string > getParameterNames()
Returns names of configuration parameters for the library.
static std::string getProcName()
returns the process name This value is used as when forming the default PID file name
Collection of attributes.
std::string toText(size_t indent=0) const
Returns text representation of the collection.
ConstAttributePtr get(const uint8_t type) const
Get instance of the attribute in the collection.
static Attributes fromElement(const data::ConstElementPtr &attr_list)
Parse collection.
InHook class (RAII style).
static void runAsync(RadiusAcctHandlerPtr handler)
Run asynchronously.
static const std::set< std::string > RADIUS_KEYWORDS
Keywords (aka global configuration entry names).
Radius hooks library implementation.
void reset()
Reset the state as it was just created.
void startServices()
Start the I/O mechanisms.
static RadiusImpl & instance()
RadiusImpl is a singleton class.
static StatsMgr & instance()
Statistics Manager accessor method.
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void addValue(const std::string &name, const int64_t value)
Records incremental integer observation.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
boost::shared_ptr< Host > HostPtr
Pointer to the Host object.
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
boost::shared_ptr< const Host > ConstHostPtr
Const pointer to the Host object.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
GssTsigImplPtr impl
The GSS-TSIG hook implementation object.
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
boost::shared_ptr< RadiusAcctHandler > RadiusAcctHandlerPtr
Type of pointers to Radius accounting communication handler.
const isc::log::MessageID RADIUS_ACCESS_CONFLICT
const isc::log::MessageID RADIUS_ACCESS_MAX_PENDING_REQUESTS
boost::shared_ptr< const Attribute > ConstAttributePtr
boost::shared_ptr< RadiusAuthPendingRequest< PktPtrType > > RadiusAuthPendingRequestPtr
Pointer to a pending Radius access request.
const isc::log::MessageID RADIUS_INIT_OK
const isc::log::MessageID RADIUS_DEINIT_OK
const int RADIUS_DBG_TRACE
Radius logging levels.
const isc::log::MessageID RADIUS_ACCESS_CACHE_GET
boost::shared_ptr< RadiusAuthHandler > RadiusAuthHandlerPtr
Type of pointers to Radius access communication handler.
isc::log::Logger radius_logger("radius-hooks")
Radius Logger.
const isc::log::MessageID RADIUS_ACCESS_SUBNET_RESELECT
const isc::log::MessageID RADIUS_CONFIGURATION_FAILED
const isc::log::MessageID RADIUS_HOOK_FAILED
Defines the logger used by the top-level component of kea-lfc.
int subnet4_select(CalloutHandle &handle)
This callout tries to retrieve host information from cache.
int lease4_release(CalloutHandle &handle)
This callout is called at the "lease4_release" hook.
int lease4_decline(CalloutHandle &handle)
This callout is called at the "lease4_decline" hook.
int dhcp6_srv_configured(CalloutHandle &)
This function is called by the DHCPv6 server when it is configured.
int dhcp4_srv_configured(CalloutHandle &)
This function is called by the DHCPv4 server when it is configured.
int lease6_release(CalloutHandle &handle)
This callout is called at the "lease6_release" hook.
int command_processed(CalloutHandle &handle)
This callout is called at the "command_processed" hook point.
int lease6_rebind(CalloutHandle &handle)
This callout is called at the "lease6_rebind" hook.
int multi_threading_compatible()
This function is called to retrieve the multi-threading compatibility.
int lease4_renew(CalloutHandle &handle)
This callout is called at the "lease4_renew" hook.
int subnet6_select(CalloutHandle &handle)
This callout tries to retrieve host information from cache.
int lease4_select(CalloutHandle &handle)
This callout is called at the "lease4_select" hook.
int unload()
This function is called when the library is unloaded.
int lease6_expire(CalloutHandle &handle)
This callout is called at the "lease6_expire" hook.
int lease4_expire(CalloutHandle &handle)
This callout is called at the "lease4_expire" 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 lease6_decline(CalloutHandle &handle)
This callout is called at the "lease6_decline" hook.
int lease6_renew(CalloutHandle &handle)
This callout is called at the "lease6_renew" hook.
RAII lock object to protect the code in the same scope with a mutex.