36 "access",
"accounting",
"tls",
37 "bindaddr",
"canonical-mac-address",
"client-id-pop0",
38 "client-id-printable",
"deadtime",
"dictionary",
39 "extract-duid",
"identifier-type4",
"identifier-type6",
40 "nas-ports",
"protocol",
41 "reselect-subnet-address",
"reselect-subnet-pool",
42 "retries",
"session-history",
"thread-pool-size",
"timeout",
43 "use-message-authenticator",
114 }
catch (
const exception& ex) {
120 <<
"closed: vendor " << vendor <<
" is still open");
129 string proto = protocol->stringValue();
130 if (proto ==
"UDP") {
132 }
else if (proto ==
"TCP") {
134 }
else if (proto ==
"TLS") {
145 riref.
bindaddr_ = bindaddr->stringValue();
161 int64_t deadtime64 = deadtime->intValue();
162 if ((deadtime64 < 0) ||
163 (deadtime64 > numeric_limits<unsigned>::max())) {
166 << numeric_limits<unsigned>::max() <<
"]");
168 riref.
deadtime_ =
static_cast<unsigned>(deadtime64);
184 config->get(
"reselect-subnet-address");
189 config->get(
"reselect-subnet-pool");
194 int64_t retries64 = retries->intValue();
195 if ((retries64 < 0) ||
196 (retries64 > numeric_limits<unsigned>::max())) {
199 << numeric_limits<unsigned>::max() <<
"]");
201 riref.
retries_ =
static_cast<unsigned>(retries64);
213 int64_t timeout64 = timeout->intValue();
214 if ((timeout64 < 0) ||
215 (timeout64 > numeric_limits<long>::max() / 1000)) {
218 << (numeric_limits<long>::max() / 1000) <<
"]");
220 riref.
timeout_ =
static_cast<unsigned>(timeout64);
239 <<
"when protocol is not 'TLS'");
267 for (
auto const& entry : nas_ports->listValue()) {
278 riref.
remap_[
id->intValue()] = port->intValue();
287 getCfgSubnets4()->getByPrefix(prefix->stringValue());
292 riref.
remap_[subnet->getID()] = port->intValue();
296 getCfgSubnets6()->getByPrefix(prefix->stringValue());
301 riref.
remap_[subnet->getID()] = port->intValue();
311 getCfgSharedNetworks4()->getByName(name->stringValue());
316 for (
auto const& subnet : *network->getAllSubnets()) {
317 riref.
remap_[subnet->getID()] = port->intValue();
322 getCfgSharedNetworks6()->getByName(name->stringValue());
327 for (
auto const& subnet : *network->getAllSubnets()) {
328 riref.
remap_[subnet->getID()] = port->intValue();
335 if (entry->size() > 1) {
340 riref.
remap_[SUBNET_ID_DEFAULT] = port->intValue();
345 }
catch (
const std::exception& ex) {
353 "enabled",
"servers",
"attributes",
"peer-updates",
"max-pending-requests",
354 "idle-timer-interval"
372 for (
auto const& entry : srv_cfg->mapValue()) {
373 if (keywords.count(entry.first) == 0) {
391 if (service->name_ ==
"tls") {
394 service->enabled_ = enabled->boolValue();
397 (service->name_ !=
"tls")) {
398 service->enabled_ =
true;
406 (service->name_ !=
"tls")) {
408 << service->name_ <<
"' with TLS");
411 parser.
parse(service, servers);
412 if (!service->servers_.empty()) {
413 service->enabled_ =
true;
420 if (service->name_ ==
"tls") {
424 parser.
parse(service, attributes);
430 if (service->name_ !=
"accounting") {
432 << service->name_ <<
" service, but it is "
433 <<
"only supported for the accounting service");
441 service->peer_updates_ = peer_updates->boolValue();
446 srv_cfg->get(
"max-pending-requests");
447 if (max_pending_requests) {
448 if (service->name_ !=
"access") {
450 << service->name_ <<
" service, but it is only "
451 <<
"supported for the access service");
455 <<
"integer, but got "
459 if (max_pending_requests->intValue() < 0) {
461 <<
"positive, but got "
462 << max_pending_requests->intValue()
465 service->max_pending_requests_ = max_pending_requests->intValue();
470 srv_cfg->get(
"idle-timer-interval");
471 if (idle_timer_interval) {
473 (service->name_ !=
"tls")) {
475 << service->name_ <<
"' with TLS");
479 <<
"integer, but got "
483 if (idle_timer_interval->intValue() < 0) {
485 <<
"positive, but got "
486 << idle_timer_interval->intValue()
489 service->idle_timer_interval_ = idle_timer_interval->intValue();
491 }
catch (
const std::exception& ex) {
493 << service->name_ <<
")");
499 if (!service->enabled_) {
505 if (service->name_ ==
"access") {
507 }
else if (service->name_ ==
"accounting") {
509 if (cfg_attrs.
size() > attrs.
size()) {
511 "Expressions are not yet supported in accounting");
519 for (
auto const& srv : srv_list->listValue()) {
521 parser.
parse(service, srv);
535 const string& name =
getString(server,
"name");
546 msg <<
"peer-addr=" << peer_addr.
toText();
550 if (server->contains(
"port")) {
552 }
else if (service->name_ ==
"tls") {
554 }
else if (service->name_ ==
"access") {
559 msg <<
" port=" << port;
578 msg <<
" local_addr=" << local_addr;
582 if (!server->contains(
"secret") && (service->name_ ==
"tls")) {
592 msg <<
" secret=*****";
596 if (service->name_ ==
"tls") {
597 string trust_anchor =
getString(server,
"trust-anchor");
598 string cert_file =
getString(server,
"cert-file");
599 string key_file =
getString(server,
"key-file");
601 trust_anchor, cert_file, key_file);
607 service->servers_.push_back(srv);
610 <<
" server '" << msg.str() <<
"': " << ex.
what());
622 for (
auto const& attr : attr_list->listValue()) {
624 parser.
parse(service, attr);
646 const string& vendor_txt = vendor_elem->stringValue();
647 if (!vendor_txt.empty()) {
651 vendor = vendor_cst->value_;
654 int64_t val = boost::lexical_cast<int64_t>(vendor_txt);
655 if ((val < numeric_limits<int32_t>::min()) ||
656 (val > numeric_limits<uint32_t>::max())) {
659 vendor =
static_cast<uint32_t
>(val);
662 << vendor_txt <<
"'");
670 if (name->stringValue().empty()) {
676 msg <<
"attribute '" << name->stringValue() <<
"'";
678 msg <<
" in vendor '" << vendor_txt <<
"'";
680 msg <<
" is unknown";
688 if ((type->intValue() < 0) || (type->intValue() > 255)) {
690 << type->intValue());
692 uint8_t attrib =
static_cast<uint8_t
>(type->intValue());
693 if (def && (def->type_ != attrib)) {
695 msg <<
"'" << name->stringValue() <<
"' attribute";
697 msg <<
" in vendor '" << vendor_txt <<
"'";
699 msg <<
" has type " <<
static_cast<unsigned>(def->type_)
700 <<
", not " <<
static_cast<unsigned>(attrib);
708 msg <<
"attribute type " <<
static_cast<unsigned>(attrib);
710 msg <<
" in vendor '" << vendor_txt <<
"'";
712 msg <<
" is unknown";
723 const string& data_txt =
getString(attr,
"data");
726 const string& raw_txt =
getString(attr,
"raw");
729 const string& expr_txt =
getString(attr,
"expr");
734 if (!expr_txt.empty()) {
735 if (!data_txt.empty() || !raw_txt.empty()) {
749 }
catch (
const std::exception& ex) {
751 <<
"] error: " << ex.what() <<
" for "
752 << def->name_ <<
" attribute");
755 service->attributes_.add(def,
AttributePtr(), expression, expr_txt);
756 }
else if (!raw_txt.empty()) {
757 if (!data_txt.empty()) {
763 string padded = raw_txt;
764 if ((padded.size() % 2) != 0) {
765 padded = padded.insert(0,
"0");
767 vector<uint8_t> binary;
772 <<
"] for " << def->name_ <<
" attribute");
776 service->attributes_.add(def, attribute);
779 <<
" attribute from raw: [" << raw_txt <<
"]: "
785 service->attributes_.add(def, attribute);
788 <<
" attribute from [" << data_txt <<
"]: "
static std::string typeToName(Element::types type)
Returns the name of the given type as a string.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
An exception that is thrown if an error occurs while configuring any server.
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown when a function is not implemented.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
A generic exception that is thrown when an unexpected error condition occurs.
The IOAddress class represents an IP addresses (version agnostic)
std::string toText() const
Convert the address to a string.
Exception thrown on attempt to use a default credential.
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
uint16_t getUint16(isc::data::ConstElementPtr scope, const std::string &name)
Returns a value converted to uint16_t.
static size_t setDefaults(isc::data::ElementPtr scope, const SimpleDefaults &default_values)
Sets the default values.
A standard Data module exception that is thrown if a function is called for an Element that has a wro...
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
IdentifierType getIdentifierType() const
Returns the identifier type.
Universe
defines option universe DHCPv4 or DHCPv6
Evaluation context, an interface to the expression evaluation.
bool parseString(const std::string &str, ParserType type=PARSER_BOOL)
Run the parser on the string specified.
@ PARSER_STRING
expression is expected to evaluate to string
isc::dhcp::Expression expression_
Parsed expression (output tokens are stored here)
static AttrDefs & instance()
Returns a single instance.
void readDictionary(const std::string &path, uint32_t &vendor, unsigned int depth=0)
Read a dictionary from a file.
AttrDefPtr getByName(const std::string &name, const uint32_t vendor=0) const
Get attribute definition by name and vendor.
void checkStandardDefs(const AttrDefList &defs) const
Check if a list of standard attribute definitions are available and correct.
AttrDefPtr getByType(const uint8_t type, const uint32_t vendor=0) const
Get attribute definition by type and vendor.
static AttributePtr fromBytes(const std::vector< uint8_t > &bytes)
Generic factories.
static AttributePtr fromText(const AttrDefPtr &def, const std::string &value)
From definition generic factories.
Collection of attributes.
size_t size() const
Returns the number of elements.
Attribute data configuration.
Attributes getAll() const
Get all attributes in the configuration.
size_t size() const
Returns the number of elements.
Attribute list parser for Radius.
void parse(const RadiusServicePtr &service, const data::ConstElementPtr &attr_list)
Parses Radius list of attribute configurations.
Attribute configuration parser for Radius.
static const data::SimpleDefaults ATTRIBUTE_DEFAULTS
Defaults for Radius attribute configuration.
void parse(const RadiusServicePtr &service, const data::ElementPtr &attr)
Parses Radius attribute configuration.
static const std::set< std::string > RADIUS_KEYWORDS
Keywords (aka global configuration entry names).
void parse(data::ElementPtr &config)
Parses Radius configuration.
static const data::SimpleDefaults RADIUS_DEFAULTS
Defaults for Radius configuration.
static const AttrDefList USED_STANDARD_ATTR_DEFS
Needed standard attributes definitions.
Radius hooks library implementation.
unsigned thread_pool_size_
Thread pool size.
std::string dictionary_
Dictionary path.
boost::shared_ptr< RadiusTls > tls_
Pointer to tls (never null).
std::string bindaddr_
bindaddr.
bool clientid_pop0_
Client Id pop leading zero(s).
dhcp::Host::IdentifierType id_type4_
Identifier type for IPv4.
bool reselect_subnet_address_
Reselect subnet using address.
boost::shared_ptr< RadiusAccess > auth_
Pointer to access (never null).
bool extract_duid_
Extract Duid from Client Id.
unsigned timeout_
Timeout.
dhcp::Host::IdentifierType id_type6_
Identifier type for IPv6.
bool canonical_mac_address_
Canonical MAC address.
unsigned deadtime_
Deadtime.
boost::shared_ptr< RadiusAccounting > acct_
Pointer to accounting (never null).
unsigned retries_
Retries.
std::map< uint32_t, uint32_t > remap_
Subnet ID to NAS port map.
std::string session_history_filename_
Session history filename.
bool reselect_subnet_pool_
Reselect subnet using pool.
bool clientid_printable_
Client Id try printable.
RadiusProtocol proto_
Transport protocol.
static RadiusImpl & instance()
RadiusImpl is a singleton class.
bool use_message_authenticator_
Use Message-Authenticator attribute.
Server list parser for Radius.
void parse(const RadiusServicePtr &service, const data::ConstElementPtr &srv_list)
Parses Radius server list.
Server parser for Radius.
void parse(const RadiusServicePtr &service, const data::ElementPtr &server)
Parses Radius server.
Service parser for Radius.
static const std::set< std::string > SERVICE_KEYWORDS
Keywords (aka service configuration entry names).
void checkAttributes(const RadiusServicePtr &service)
Check Radius attributes.
void parse(const RadiusServicePtr &service, const data::ConstElementPtr &srv_cfg)
Parses Radius service.
static asiolink::IOAddress getSrcAddress(const asiolink::IOAddress &dest)
Get the source address from a destination address.
static asiolink::IOAddress getAddress(const std::string &name)
Get an address from a name.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
boost::shared_ptr< const Element > ConstElementPtr
std::vector< SimpleDefault > SimpleDefaults
This specifies all default values in a given scope (e.g. a subnet).
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< Expression > ExpressionPtr
std::vector< TokenPtr > Expression
This is a structure that holds an expression converted to RPN.
boost::shared_ptr< IntCstDef > IntCstDefPtr
Shared pointers to Integer constant definition.
const isc::log::MessageID RADIUS_SERVER_CONFIGURED
@ PW_DELEGATED_IPV6_PREFIX
ipv6prefix.
@ PW_SERVICE_TYPE
integer.
@ PW_FRAMED_IP_ADDRESS
ipaddr.
@ PW_CALLING_STATION_ID
string.
@ PW_ACCT_DELAY_TIME
integer.
@ PW_ACCT_STATUS_TYPE
integer.
@ PW_NAS_IPV6_ADDRESS
ipv6addr.
@ PW_NAS_IP_ADDRESS
ipaddr.
@ PW_USER_PASSWORD
string.
@ PW_REPLY_MESSAGE
string.
@ PW_VENDOR_SPECIFIC
string.
@ PW_ACCT_SESSION_ID
string.
@ PW_MESSAGE_AUTHENTICATOR
string.
@ PW_FRAMED_IPV6_ADDRESS
ipv6addr.
std::list< AttrDef > AttrDefList
List of Attribute definitions.
boost::shared_ptr< AttrDef > AttrDefPtr
Shared pointers to Attribute definition.
boost::shared_ptr< Server > ServerPtr
Type of shared pointers to a RADIUS server object.
boost::shared_ptr< RadiusService > RadiusServicePtr
Type of pointers to Radius service.
boost::shared_ptr< Attribute > AttributePtr
isc::log::Logger radius_logger("radius-hooks")
Radius Logger.
vector< uint8_t > pop0(const ClientIdPtr &client_id)
Pop leading zero in a DHCPv4 client-id.
void decodeHex(const string &encoded_str, vector< uint8_t > &output)
Decode a base16 encoded string into binary data.
Defines the logger used by the top-level component of kea-lfc.
static void check(const std::string &value)
Check if the value is a default credential.