37 "access",
"accounting",
"tls",
38 "bindaddr",
"canonical-mac-address",
"client-id-pop0",
39 "client-id-printable",
"deadtime",
"dictionary",
40 "extract-duid",
"identifier-type4",
"identifier-type6",
41 "nas-ports",
"protocol",
42 "reselect-subnet-address",
"reselect-subnet-pool",
43 "retries",
"session-history",
"thread-pool-size",
"timeout",
44 "use-message-authenticator",
115 }
catch (
const exception& ex) {
121 <<
"closed: vendor " << vendor <<
" is still open");
130 string proto = protocol->stringValue();
131 if (proto ==
"UDP") {
133 }
else if (proto ==
"TCP") {
135 }
else if (proto ==
"TLS") {
146 riref.
bindaddr_ = bindaddr->stringValue();
162 int64_t deadtime64 = deadtime->intValue();
163 if ((deadtime64 < 0) ||
164 (deadtime64 > numeric_limits<unsigned>::max())) {
167 << numeric_limits<unsigned>::max() <<
"]");
169 riref.
deadtime_ =
static_cast<unsigned>(deadtime64);
185 config->get(
"reselect-subnet-address");
190 config->get(
"reselect-subnet-pool");
195 int64_t retries64 = retries->intValue();
196 if ((retries64 < 0) ||
197 (retries64 > numeric_limits<unsigned>::max())) {
200 << numeric_limits<unsigned>::max() <<
"]");
202 riref.
retries_ =
static_cast<unsigned>(retries64);
214 int64_t timeout64 = timeout->intValue();
215 if ((timeout64 < 0) ||
216 (timeout64 > numeric_limits<long>::max() / 1000)) {
219 << (numeric_limits<long>::max() / 1000) <<
"]");
221 riref.
timeout_ =
static_cast<unsigned>(timeout64);
240 <<
"when protocol is not 'TLS'");
268 for (
auto const& entry : nas_ports->listValue()) {
279 riref.
remap_[
id->intValue()] = port->intValue();
288 getCfgSubnets4()->getByPrefix(prefix->stringValue());
293 riref.
remap_[subnet->getID()] = port->intValue();
297 getCfgSubnets6()->getByPrefix(prefix->stringValue());
302 riref.
remap_[subnet->getID()] = port->intValue();
312 getCfgSharedNetworks4()->getByName(name->stringValue());
317 for (
auto const& subnet : *network->getAllSubnets()) {
318 riref.
remap_[subnet->getID()] = port->intValue();
323 getCfgSharedNetworks6()->getByName(name->stringValue());
328 for (
auto const& subnet : *network->getAllSubnets()) {
329 riref.
remap_[subnet->getID()] = port->intValue();
336 if (entry->size() > 1) {
341 riref.
remap_[SUBNET_ID_DEFAULT] = port->intValue();
346 }
catch (
const std::exception& ex) {
354 "enabled",
"servers",
"attributes",
"peer-updates",
"max-pending-requests",
355 "idle-timer-interval"
373 for (
auto const& entry : srv_cfg->mapValue()) {
374 if (keywords.count(entry.first) == 0) {
392 if (service->name_ ==
"tls") {
395 service->enabled_ = enabled->boolValue();
398 (service->name_ !=
"tls")) {
399 service->enabled_ =
true;
407 (service->name_ !=
"tls")) {
409 << service->name_ <<
"' with TLS");
412 parser.
parse(service, servers);
413 if (!service->servers_.empty()) {
414 service->enabled_ =
true;
421 if (service->name_ ==
"tls") {
425 parser.
parse(service, attributes);
431 if (service->name_ !=
"accounting") {
433 << service->name_ <<
" service, but it is "
434 <<
"only supported for the accounting service");
442 service->peer_updates_ = peer_updates->boolValue();
447 srv_cfg->get(
"max-pending-requests");
448 if (max_pending_requests) {
449 if (service->name_ !=
"access") {
451 << service->name_ <<
" service, but it is only "
452 <<
"supported for the access service");
456 <<
"integer, but got "
460 if (max_pending_requests->intValue() < 0) {
462 <<
"positive, but got "
463 << max_pending_requests->intValue()
466 service->max_pending_requests_ = max_pending_requests->intValue();
471 srv_cfg->get(
"idle-timer-interval");
472 if (idle_timer_interval) {
474 (service->name_ !=
"tls")) {
476 << service->name_ <<
"' with TLS");
480 <<
"integer, but got "
484 if (idle_timer_interval->intValue() < 0) {
486 <<
"positive, but got "
487 << idle_timer_interval->intValue()
490 service->idle_timer_interval_ = idle_timer_interval->intValue();
492 }
catch (
const std::exception& ex) {
494 << service->name_ <<
")");
500 if (!service->enabled_) {
506 if (service->name_ ==
"access") {
508 }
else if (service->name_ ==
"accounting") {
510 if (cfg_attrs.
size() > attrs.
size()) {
512 "Expressions are not yet supported in accounting");
520 for (
auto const& srv : srv_list->listValue()) {
522 parser.
parse(service, srv);
536 const string& name =
getString(server,
"name");
547 msg <<
"peer-addr=" << peer_addr.
toText();
551 if (server->contains(
"port")) {
553 }
else if (service->name_ ==
"tls") {
555 }
else if (service->name_ ==
"access") {
560 msg <<
" port=" << port;
579 msg <<
" local_addr=" << local_addr;
583 if (!server->contains(
"secret") && (service->name_ ==
"tls")) {
593 msg <<
" secret=*****";
597 if (service->name_ ==
"tls") {
598 string trust_anchor =
getString(server,
"trust-anchor");
599 string cert_file =
getString(server,
"cert-file");
600 string key_file =
getString(server,
"key-file");
602 trust_anchor, cert_file, key_file);
608 service->servers_.push_back(srv);
611 <<
" server '" << msg.str() <<
"': " << ex.
what());
623 for (
auto const& attr : attr_list->listValue()) {
625 parser.
parse(service, attr);
647 const string& vendor_txt = vendor_elem->stringValue();
648 if (!vendor_txt.empty()) {
652 vendor = vendor_cst->value_;
655 int64_t val = boost::lexical_cast<int64_t>(vendor_txt);
656 if ((val < numeric_limits<int32_t>::min()) ||
657 (val > numeric_limits<uint32_t>::max())) {
660 vendor =
static_cast<uint32_t
>(val);
663 << vendor_txt <<
"'");
671 if (name->stringValue().empty()) {
677 msg <<
"attribute '" << name->stringValue() <<
"'";
679 msg <<
" in vendor '" << vendor_txt <<
"'";
681 msg <<
" is unknown";
689 if ((type->intValue() < 0) || (type->intValue() > 255)) {
691 << type->intValue());
693 uint8_t attrib =
static_cast<uint8_t
>(type->intValue());
694 if (def && (def->type_ != attrib)) {
696 msg <<
"'" << name->stringValue() <<
"' attribute";
698 msg <<
" in vendor '" << vendor_txt <<
"'";
700 msg <<
" has type " <<
static_cast<unsigned>(def->type_)
701 <<
", not " <<
static_cast<unsigned>(attrib);
709 msg <<
"attribute type " <<
static_cast<unsigned>(attrib);
711 msg <<
" in vendor '" << vendor_txt <<
"'";
713 msg <<
" is unknown";
724 const string& data_txt =
getString(attr,
"data");
727 const string& raw_txt =
getString(attr,
"raw");
730 const string& expr_txt =
getString(attr,
"expr");
735 if (!expr_txt.empty()) {
736 if (!data_txt.empty() || !raw_txt.empty()) {
750 }
catch (
const std::exception& ex) {
752 <<
"] error: " << ex.what() <<
" for "
753 << def->name_ <<
" attribute");
756 service->attributes_.add(def,
AttributePtr(), expression, expr_txt);
757 }
else if (!raw_txt.empty()) {
758 if (!data_txt.empty()) {
764 string padded = raw_txt;
765 if ((padded.size() % 2) != 0) {
766 padded = padded.insert(0,
"0");
768 vector<uint8_t> binary;
773 <<
"] for " << def->name_ <<
" attribute");
777 service->attributes_.add(def, attribute);
780 <<
" attribute from raw: [" << raw_txt <<
"]: "
786 service->attributes_.add(def, attribute);
789 <<
" 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.