namespace isc {
namespace radius {
+string
+protocolToText(const int proto) {
+ ostringstream result;
+ switch (proto) {
+ case PW_PROTO_UDP:
+ return ("UDP");
+ case PW_PROTO_TCP:
+ return ("TCP");
+ case PW_PROTO_TLS:
+ return ("TLS");
+ default:
+ result << "unknown transport protocol " << proto;
+ return (result.str());
+ }
+}
+
IOAddress
Server::getAddress(const string& name) {
AddrInfo res(name);
namespace radius {
/// @brief Default RADIUS access/authentication port.
-static constexpr uint16_t PW_AUTH_UDP_PORT = 1812;
+static constexpr uint16_t PW_AUTH_PORT = 1812;
/// @brief Default RADIUS accounting port.
-static constexpr uint16_t PW_ACCT_UDP_PORT = 1813;
+static constexpr uint16_t PW_ACCT_PORT = 1813;
+
+/// @brief Default RADIUS/TLS port.
+static constexpr uint16_t PW_TLS_PORT = 2083;
+
+/// @brief Transport protocols.
+enum RadiusProtocol {
+ PW_PROTO_UDP,
+ PW_PROTO_TCP,
+ PW_PROTO_TLS
+};
+
+/// @brief Transport protocol to text.
+std::string protocolToText(const int proto);
/// @brief RADIUS server class.
class Server : public data::CfgToElement {
'radius_request.cc',
'radius_service.cc',
'radius_status.cc',
+ 'radius_tls.cc',
'radius_utils.cc',
'version.cc',
cpp_args: [f'-DDICTIONARY="@SYSCONFDIR_INSTALLED@/kea/radius/dictionary"'],
#include <radius_accounting.h>
#include <radius_log.h>
#include <radius_parsers.h>
+#include <radius_tls.h>
#include <exception>
}
RadiusImpl::RadiusImpl()
- : auth_(new RadiusAccess()), acct_(new RadiusAccounting()),
+ : proto_(PW_PROTO_UDP), common_(new RadiusTls()),
+ auth_(new RadiusAccess()), acct_(new RadiusAccounting()),
bindaddr_("*"), canonical_mac_address_(false),
clientid_pop0_(false), clientid_printable_(false),
deadtime_(0), extract_duid_(true),
backend_.reset();
}
+ common_.reset(new RadiusTls());
auth_.reset(new RadiusAccess());
acct_.reset(new RadiusAccounting());
}
void RadiusImpl::init(ElementPtr&config) {
+ common_.reset(new RadiusTls());
auth_.reset(new RadiusAccess());
acct_.reset(new RadiusAccounting());
RadiusConfigParser parser;
/// Moved from radius_request.h file for better visibility.
static const uint32_t SUBNET_ID_DEFAULT = 0;
+/// @brief Forward declaration of RadiusTls.
+class RadiusTls;
+
/// @brief Forward declaration of RadiusAccess.
class RadiusAccess;
/// @brief Dictionary path.
std::string dictionary_;
+ /// @brief Transport protocol.
+ RadiusProtocol proto_;
+
/// @brief Subnet ID to NAS port map.
std::map<uint32_t, uint32_t> remap_;
- // @brief Pointer to access (never null).
+ /// @brief Pointer to common tls (never null).
+ boost::shared_ptr<RadiusTls> common_;
+
+ /// @brief Pointer to access (never null).
boost::shared_ptr<RadiusAccess> auth_;
/// @brief Pointer to accounting (never null).
/// @brief Idle timer callback.
static void IdleTimerCallback();
-
};
} // end of namespace isc::radius
if (server->contains("port")) {
port = getUint16(server, "port");
} else if (service->name_ == "access") {
- port = PW_AUTH_UDP_PORT;
+ port = PW_AUTH_PORT;
} else {
- port = PW_ACCT_UDP_PORT;
+ port = PW_ACCT_PORT;
}
msg << " port=" << port;
--- /dev/null
+// Copyright (C) 2020-2025 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+
+#include <radius_status.h>
+#include <radius_tls.h>
+#include <util/multi_threading_mgr.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::asiolink;
+using namespace isc::util;
+
+namespace isc {
+namespace radius {
+
+RadiusTls::RadiusTls() : RadiusService("common-tls") {
+}
+
+void
+RadiusTls::setIdleTimer() {
+ MultiThreadingLock lock(idle_timer_mutex_);
+ cancelIdleTimer();
+ if (idle_timer_interval_ <= 0) {
+ return;
+ }
+ // Cope to one day.
+ long secs = idle_timer_interval_;
+ if (secs > 24*60*60) {
+ secs = 24*60*60;
+ }
+ idle_timer_.reset(new IntervalTimer(RadiusImpl::instance().getIOContext()));
+ idle_timer_->setup(RadiusTls::IdleTimerCallback,
+ secs * 1000, IntervalTimer::REPEATING);
+}
+
+void
+RadiusTls::IdleTimerCallback() {
+ AttributesPtr send_attrs;
+ RadiusAuthStatusPtr handler(new RadiusAuthStatus(send_attrs, 0));
+ RadiusImpl::instance().registerExchange(handler->getExchange());
+ handler->start();
+}
+
+} // end of namespace isc::radius
+} // end of namespace isc
--- /dev/null
+// Copyright (C) 2023-2025 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef RADIUS_TLS_H
+#define RADIUS_TLS_H
+
+#include <radius_service.h>
+
+namespace isc {
+namespace radius {
+
+/// @brief Radius common service for TLS transport.
+class RadiusTls : public RadiusService {
+public:
+
+ /// @brief Constructor.
+ RadiusTls();
+
+ /// @brief Destructor.
+ virtual ~RadiusTls() = default;
+
+ /// @brief Set idle timer.
+ ///
+ /// @note: The caller must hold the idle timer mutex.
+ void setIdleTimer();
+
+ /// @brief Idle timer callback.
+ static void IdleTimerCallback();
+};
+
+} // end of namespace isc::radius
+} // end of namespace isc
+
+#endif
namespace {
+/// Verify protocolToText.
+TEST(ServerClassTest, protocolToText) {
+ EXPECT_EQ("UDP", protocolToText(PW_PROTO_UDP));
+ EXPECT_EQ("TCP", protocolToText(PW_PROTO_TCP));
+ EXPECT_EQ("TLS", protocolToText(PW_PROTO_TLS));
+ EXPECT_EQ("unknown transport protocol 6", protocolToText(6));
+}
+
/// Verify Server::getAddress.
TEST(ServerClassTest, getAddress) {
boost::scoped_ptr<IOAddress> addr;