Kea: radius_service.cc Source File

| Kea 3.2.0-git

radius_service.cc
Go to the documentation of this file.
1// Copyright (C) 2023-2026 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <radius_service.h>
10#include <util/multi_threading_mgr.h>
11
12using namespace std;
13using namespace isc;
14using namespace isc::data;
15using namespace isc::util;
16
17namespace isc {
18namespace radius {
19
20std::mutex
21 RadiusService::idle_timer_mutex_;
22
23RadiusService::RadiusService(const std::string& name)
24 : name_(name), enabled_(false), peer_updates_(true),
25 max_pending_requests_(0), idle_timer_interval_(), idle_timer_() {
26}
27
28RadiusService::~RadiusService() {
29 MultiThreadingLock lock(idle_timer_mutex_);
30 cancelIdleTimer();
31}
32
33 ElementPtr
34RadiusService::toElement() const {
35 ElementPtr result = Element::createMap();
36
37 // enabled.
38 result->set("enabled", Element::create(enabled_));
39
40 // servers.
41 if (!servers_.empty()) {
42 ElementPtr servers = Element::createList();
43 for (auto const& server : servers_) {
44 if (server) {
45 servers->add(server->toElement());
46 }
47 }
48 result->set("servers", servers);
49 }
50
51 // attributes.
52 if (!attributes_.empty()) {
53 result->set("attributes", attributes_.toElement());
54 }
55
56 // idle-timer-interval.
57 result->set("idle-timer-interval", Element::create(idle_timer_interval_));
58
59 return (result);
60}
61
62void
63RadiusService::cancelIdleTimer() {
64 if (idle_timer_) {
65 idle_timer_->cancel();
66 idle_timer_.reset();
67 }
68}
69
70} // end of namespace isc::radius
71} // end of namespace isc
Element::create
static ElementPtr create(const Position &pos=ZERO_POSITION())
Create a NullElement.
Definition data.cc:299
Element::createMap
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:354
Element::createList
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition data.cc:349
isc::radius::RadiusService::peer_updates_
bool peer_updates_
Peer updates flag.
Definition radius_service.h:50
isc::radius::RadiusService::attributes_
CfgAttributes attributes_
Attribute configurations.
Definition radius_service.h:56
isc::radius::RadiusService::enabled_
bool enabled_
Enable flag.
Definition radius_service.h:47
isc::radius::RadiusService::RadiusService
RadiusService(const std::string &name)
Constructor.
Definition radius_service.cc:23
isc::radius::RadiusService::toElement
data::ElementPtr toElement() const override
Unparse service configuration.
Definition radius_service.cc:34
isc::radius::RadiusService::max_pending_requests_
size_t max_pending_requests_
Maximum number of pending requests.
Definition radius_service.h:59
isc::radius::RadiusService::idle_timer_
asiolink::IntervalTimerPtr idle_timer_
Idle timer.
Definition radius_service.h:65
isc::radius::RadiusService::idle_timer_interval_
long idle_timer_interval_
Idle timer interval in seconds.
Definition radius_service.h:62
isc::radius::RadiusService::servers_
Servers servers_
Server list.
Definition radius_service.h:53
isc::radius::RadiusService::cancelIdleTimer
void cancelIdleTimer()
Cancel idle timer.
Definition radius_service.cc:63
isc::radius::RadiusService::~RadiusService
virtual ~RadiusService()
Destructor.
Definition radius_service.cc:28
isc::radius::RadiusService::idle_timer_mutex_
static std::mutex idle_timer_mutex_
Idle timer mutex.
Definition radius_service.h:76
isc::radius::RadiusService::name_
std::string name_
Name (access or accounting).
Definition radius_service.h:44
multi_threading_mgr.h
isc::data
Definition base_stamped_element.cc:12
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
isc::radius
Definition cfg_attribute.cc:21
isc::util
Definition time_utils.cc:43
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
radius_service.h
isc::util::MultiThreadingLock
RAII lock object to protect the code in the same scope with a mutex.
Definition multi_threading_mgr.h:349