60 for (
auto const& name : names) {
61 if (keywords.count(name) == 0) {
84 uint32_t subnet_id = subnet->getID();
85 uint32_t host_subnet_id =
86 (subnet->getReservationsGlobal() ? SUBNET_ID_GLOBAL : subnet_id);
89 if (!
impl.auth_->getIdentifier(*query,
id, text)) {
100 if (host && host->getContext() &&
102 host->getContext()->contains(
"subnet-id")) {
105 subnet_id =
static_cast<uint32_t
>(reselected->intValue());
108 .arg(subnet->getID())
111 if (subnet_id == SUBNET_ID_UNUSED) {
117 uint32_t new_host_subnet_id = host_subnet_id;
118 if (subnet_id != subnet->getID()) {
121 getCfgSubnets4()->getSubnet(subnet_id);
124 "can't find subnet with id: " << subnet_id);
127 (new_subnet->getReservationsGlobal() ?
128 SUBNET_ID_GLOBAL : subnet_id);
132 if (new_host_subnet_id != host_subnet_id) {
137 }
catch (
const std::exception&) {
140 static_cast<void>(
impl.cache_->remove(bad));
147 if (host && host->getContext() &&
159 if (!host->getIPv4Reservation().isV4Zero()) {
164 if (framed_pool && (framed_pool->getValueType() ==
PW_TYPE_STRING)) {
165 query->addClass(framed_pool->toString());
180 impl.auth_->requests4_.get(
id);
183 if (pending_request) {
185 .arg(query->getLabel())
188 static_cast<int64_t
>(1));
190 static_cast<int64_t
>(1));
196 size_t max_requests =
impl.auth_->max_pending_requests_;
197 if (((max_requests > 0) &&
198 (
impl.auth_->requests4_.size() >= max_requests)) ||
199 !
impl.checkExchangeListRoom()) {
202 .arg(query->getLabel())
205 static_cast<int64_t
>(1));
207 static_cast<int64_t
>(1));
213 handler =
impl.auth_->buildAuth(*query, subnet_id,
id, text);
217 static_cast<int64_t
>(1));
219 static_cast<int64_t
>(1));
225 impl.auth_->requests4_.set(
id, query);
242 uint32_t subnet_id = subnet->getID();
243 uint32_t host_subnet_id =
244 (subnet->getReservationsGlobal() ? SUBNET_ID_GLOBAL : subnet_id);
247 if (!
impl.auth_->getIdentifier(*query,
id, text)) {
258 if (host && host->getContext() &&
260 host->getContext()->contains(
"subnet-id")) {
263 subnet_id =
static_cast<uint32_t
>(reselected->intValue());
266 .arg(subnet->getID())
269 if (subnet_id == SUBNET_ID_UNUSED) {
275 uint32_t new_host_subnet_id = host_subnet_id;
276 if (subnet_id != subnet->getID()) {
279 getCfgSubnets6()->getSubnet(subnet_id);
282 "can't find subnet with id: " << subnet_id);
285 (new_subnet->getReservationsGlobal() ?
286 SUBNET_ID_GLOBAL : subnet_id);
290 if (new_host_subnet_id != host_subnet_id) {
295 }
catch (
const std::exception&) {
298 static_cast<void>(
impl.cache_->remove(bad));
305 if (host && host->getContext() &&
318 if (host->hasIPv6Reservation()) {
323 if (framed_pool && (framed_pool->getValueType() ==
PW_TYPE_STRING)) {
324 query->addClass(framed_pool->toString());
339 impl.auth_->requests6_.get(
id);
342 if (pending_request) {
344 .arg(query->getLabel())
347 static_cast<int64_t
>(1));
349 static_cast<int64_t
>(1));
355 size_t max_requests =
impl.auth_->max_pending_requests_;
356 if (((max_requests > 0) &&
357 (
impl.auth_->requests6_.size() >= max_requests)) ||
358 !
impl.checkExchangeListRoom()) {
361 .arg(query->getLabel())
364 static_cast<int64_t
>(1));
366 static_cast<int64_t
>(1));
372 handler =
impl.auth_->buildAuth(*query, subnet_id,
id, text);
376 static_cast<int64_t
>(1));
378 static_cast<int64_t
>(1));
384 impl.auth_->requests6_.set(
id, query);
403 if (family == AF_INET) {
404 if (proc_name !=
"kea-dhcp4") {
406 <<
", expected kea-dhcp4");
409 if (proc_name !=
"kea-dhcp6") {
411 <<
", expected kea-dhcp6");
419 }
catch (
const std::exception& ex) {
487 if (!impl.serveAccess() || !impl.checkHostBackends()) {
494 if (!query || !subnet || (subnet->getID() == 0)) {
498 parking_lot->reference(query);
502 parking_lot->dereference(query);
508 parking_lot->dereference(query);
510 static_cast<int64_t
>(1));
512 static_cast<int64_t
>(1));
536 if (!impl.serveAccess() || !impl.checkHostBackends()) {
543 if (!query || !subnet || (subnet->getID() == 0)) {
547 parking_lot->reference(query);
551 parking_lot->dereference(query);
557 parking_lot->dereference(query);
559 static_cast<int64_t
>(1));
561 static_cast<int64_t
>(1));
584 if (!impl.serveAccounting() || !impl.getIOContext()) {
588 bool fake_allocation =
false;
589 handle.
getArgument(
"fake_allocation", fake_allocation);
590 if (fake_allocation) {
604 }
catch (
const std::exception& ex) {
606 .arg(
"lease4_select")
628 if (!impl.serveAccounting() || !impl.getIOContext()) {
634 if (!lease || (lease->reuseable_valid_lft_ > 0)) {
644 }
catch (
const std::exception& ex) {
668 if (!impl.serveAccounting() || !impl.getIOContext()) {
680 }
catch (
const std::exception& ex) {
682 .arg(
"lease4_release")
704 if (!impl.serveAccounting() || !impl.getIOContext()) {
716 }
catch (
const std::exception& ex) {
718 .arg(
"lease4_decline")
737 if (!impl.serveAccounting() || !impl.getIOContext()) {
748 }
catch (
const std::exception& ex) {
750 .arg(
"lease4_expire")
769 if (!impl.serveAccounting() || !impl.getIOContext()) {
772 bool fake_allocation;
773 handle.
getArgument(
"fake_allocation", fake_allocation);
774 if (fake_allocation) {
785 }
catch (
const std::exception& ex) {
787 .arg(
"lease6_select")
806 if (!impl.serveAccounting() || !impl.getIOContext()) {
812 if (!lease || (lease->reuseable_valid_lft_ > 0)) {
821 }
catch (
const std::exception& ex) {
842 if (!impl.serveAccounting() || !impl.getIOContext()) {
848 if (!lease || (lease->reuseable_valid_lft_ > 0)) {
857 }
catch (
const std::exception& ex) {
859 .arg(
"lease6_rebind")
878 if (!impl.serveAccounting() || !impl.getIOContext()) {
889 }
catch (
const std::exception& ex) {
891 .arg(
"lease6_release")
910 if (!impl.serveAccounting() || !impl.getIOContext()) {
921 }
catch (
const std::exception& ex) {
923 .arg(
"lease6_decline")
942 if (!impl.serveAccounting() || !impl.getIOContext()) {
953 }
catch (
const std::exception& ex) {
955 .arg(
"lease6_expire")
971 if (!impl.serveAccounting() || !impl.getIOContext()) {
981 if (!arguments || !response) {
1001 origin->stringValue() ==
"ha-partner");
1002 if (!impl.acct_->peer_updates_ && is_from_ha_partner) {
1008 if (name ==
"lease4-add") {
1009 handler = impl.acct_->buildAcct4(arguments,
EVENT_ADD);
1010 }
else if (name ==
"lease4-update") {
1011 handler = impl.acct_->buildAcct4(arguments,
EVENT_UPDATE);
1012 }
else if (name==
"lease4-del") {
1013 handler = impl.acct_->buildAcct4(arguments,
EVENT_DEL);
1014 }
else if (name ==
"lease6-add") {
1015 handler = impl.acct_->buildAcct6(arguments,
EVENT_ADD);
1016 }
else if (name ==
"lease6-update") {
1017 handler = impl.acct_->buildAcct6(arguments,
EVENT_UPDATE);
1018 }
else if (name==
"lease6-del") {
1019 handler = impl.acct_->buildAcct6(arguments,
EVENT_DEL);
1025 }
catch (
const std::exception& ex) {
1027 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.