37 "access",
"accounting",
38 "bindaddr",
"canonical-mac-address",
"client-id-pop0",
39 "client-id-printable",
"deadtime",
"dictionary",
40 "extract-duid",
"identifier-type4",
"identifier-type6",
42 "reselect-subnet-address",
"reselect-subnet-pool",
43 "retries",
"session-history",
"thread-pool-size",
"timeout",
110 }
catch (
const exception& ex) {
121 riref.
bindaddr_ = bindaddr->stringValue();
137 int64_t deadtime64 = deadtime->intValue();
138 if ((deadtime64 < 0) ||
139 (deadtime64 > numeric_limits<unsigned>::max())) {
142 << numeric_limits<unsigned>::max() <<
"]");
144 riref.
deadtime_ =
static_cast<unsigned>(deadtime64);
162 config->get(
"reselect-subnet-address");
167 config->get(
"reselect-subnet-pool");
172 int64_t retries64 = retries->intValue();
173 if ((retries64 < 0) ||
174 (retries64 > numeric_limits<unsigned>::max())) {
177 << numeric_limits<unsigned>::max() <<
"]");
179 riref.
retries_ =
static_cast<unsigned>(retries64);
191 int64_t timeout64 = timeout->intValue();
192 if ((timeout64 < 0) ||
193 (timeout64 > numeric_limits<long>::max() / 1000)) {
196 << (numeric_limits<long>::max() / 1000) <<
"]");
198 riref.
timeout_ =
static_cast<unsigned>(timeout64);
221 for (
auto const& entry : nas_ports->listValue()) {
232 riref.
remap_[
id->intValue()] = port->intValue();
241 getCfgSubnets4()->getByPrefix(prefix->stringValue());
246 riref.
remap_[subnet->getID()] = port->intValue();
250 getCfgSubnets6()->getByPrefix(prefix->stringValue());
255 riref.
remap_[subnet->getID()] = port->intValue();
265 getCfgSharedNetworks4()->getByName(name->stringValue());
270 for (
auto const& subnet : *network->getAllSubnets()) {
271 riref.
remap_[subnet->getID()] = port->intValue();
276 getCfgSharedNetworks6()->getByName(name->stringValue());
281 for (
auto const& subnet : *network->getAllSubnets()) {
282 riref.
remap_[subnet->getID()] = port->intValue();
289 if (entry->size() > 1) {
294 riref.
remap_[SUBNET_ID_DEFAULT] = port->intValue();
299 }
catch (
const std::exception& ex) {
307 "servers",
"attributes",
"peer-updates",
"max-pending-requests"
323 for (
auto const& entry : srv_cfg->mapValue()) {
324 if (keywords.count(entry.first) == 0) {
334 parser.
parse(service, servers);
335 if (!service->servers_.empty()) {
336 service->enabled_ =
true;
344 parser.
parse(service, attributes);
350 if (service->name_ ==
"access") {
352 "only supported for the accounting service");
359 service->peer_updates_ = peer_updates->boolValue();
364 srv_cfg->get(
"max-pending-requests");
365 if (max_pending_requests) {
366 if (service->name_ ==
"accounting") {
368 <<
"accounting service, but it is only supported "
369 <<
"for the access service");
373 <<
"integer, but got "
377 if (max_pending_requests->intValue() < 0) {
379 <<
"positive, but got "
380 << max_pending_requests->intValue()
383 service->max_pending_requests_ = max_pending_requests->intValue();
385 }
catch (
const std::exception& ex) {
387 << service->name_ <<
")");
393 if (!service->enabled_) {
399 if (service->name_ ==
"access") {
401 }
else if (service->name_ ==
"accounting") {
403 if (cfg_attrs.
size() > attrs.
size()) {
405 "Expressions are not yet supported in accounting");
413 for (
auto const& srv : srv_list->listValue()) {
415 parser.
parse(service, srv);
429 const string& name =
getString(server,
"name");
440 msg <<
"peer-addr=" << peer_addr.
toText();
444 if (server->contains(
"port")) {
446 }
else if (service->name_ ==
"access") {
447 port = PW_AUTH_UDP_PORT;
449 port = PW_ACCT_UDP_PORT;
451 msg <<
" port=" << port;
470 msg <<
" local_addr=" << local_addr;
473 const string& secret =
getString(server,
"secret");
479 msg <<
" secret=*****";
484 service->servers_.push_back(srv);
487 <<
" server '" << msg.str() <<
"': " << ex.
what());
499 for (
auto const& attr : attr_list->listValue()) {
501 parser.
parse(service, attr);
516 if (name->stringValue().empty()) {
522 << name->stringValue() <<
"' is unknown");
529 if ((type->intValue() < 0) || (type->intValue() > 255)) {
531 << type->intValue());
533 uint8_t attrib =
static_cast<uint8_t
>(type->intValue());
534 if (def && (def->type_ != attrib)) {
536 <<
"type " <<
static_cast<unsigned>(def->type_)
537 <<
", not " <<
static_cast<unsigned>(attrib));
544 <<
static_cast<unsigned>(attrib) <<
" is unknown");
554 const string& data_txt =
getString(attr,
"data");
557 const string& raw_txt =
getString(attr,
"raw");
560 const string& expr_txt =
getString(attr,
"expr");
565 if (!expr_txt.empty()) {
566 if (!data_txt.empty() || !raw_txt.empty()) {
580 }
catch (
const std::exception& ex) {
582 <<
"] error: " << ex.what() <<
" for "
583 << def->name_ <<
" attribute");
586 service->attributes_.add(def,
AttributePtr(), expression, expr_txt);
587 }
else if (!raw_txt.empty()) {
588 if (!data_txt.empty()) {
594 string padded = raw_txt;
595 if ((padded.size() % 2) != 0) {
596 padded = padded.insert(0,
"0");
598 vector<uint8_t> binary;
603 <<
"] for " << def->name_ <<
" attribute");
607 service->attributes_.add(def, attribute);
610 <<
" attribute from raw: [" << raw_txt <<
"]: "
616 service->attributes_.add(def, attribute);
619 <<
" 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 if a parameter given to a method would refer to or modify out-of-r...
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.
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)
Read a dictionary from a file.
AttrDefPtr getByName(const std::string &name) const
Get attribute definition by name.
AttrDefPtr getByType(const uint8_t type) const
Get attribute definition by type.
void checkStandardDefs(const AttrDefList &defs) const
Check if a list of standard attribute definitions are available and correct.
static AttributePtr fromBytes(const std::vector< uint8_t > &bytes)
From bytes (wire format).
static AttributePtr fromText(const std::string &repr)
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.
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_
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.
static RadiusImpl & instance()
RadiusImpl is a singleton class.
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< 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.
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_ACCT_SESSION_ID
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.