Kea 3.1.1
isc::radius::Attribute Class Referenceabstract

RADIUS attribute base class. More...

#include <client_attribute.h>

+ Inheritance diagram for isc::radius::Attribute:

Public Member Functions

virtual ~Attribute ()=default
 Virtual destructor.
 
uint8_t getType () const
 Get type.
 
virtual size_t getValueLen () const =0
 Generic get methods.
 
virtual AttrValueType getValueType () const =0
 Get value type.
 
virtual std::vector< uint8_t > toBinary () const
 To binary.
 
virtual std::vector< uint8_t > toBytes () const =0
 To bytes (wire format).
 
virtual uint32_t toInt () const
 To integer.
 
virtual asiolink::IOAddress toIpAddr () const
 To IPv4 address.
 
virtual asiolink::IOAddress toIpv6Addr () const
 To IPv6 address.
 
virtual asiolink::IOAddress toIpv6Prefix () const
 To IPv6 prefix.
 
virtual uint8_t toIpv6PrefixLen () const
 To IPv6 prefix length.
 
virtual std::string toString () const
 Specific get methods.
 
virtual std::string toText (size_t indent=0) const =0
 Returns text representation of the attribute.
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor.
 
virtual isc::data::ElementPtr toElement () const =0
 Unparse a configuration object.
 

Static Public Member Functions

static AttributePtr fromBinary (const uint8_t type, const std::vector< uint8_t > &value)
 From binary with type.
 
static AttributePtr fromBytes (const AttrDefPtr &def, const std::vector< uint8_t > &value)
 From bytes with definition.
 
static AttributePtr fromBytes (const std::vector< uint8_t > &bytes)
 From bytes (wire format).
 
static AttributePtr fromInt (const uint8_t type, const uint32_t value)
 From integer with type.
 
static AttributePtr fromIpAddr (const uint8_t type, const asiolink::IOAddress &value)
 From IPv4 address with type.
 
static AttributePtr fromIpv6Addr (const uint8_t type, const asiolink::IOAddress &value)
 From IPv6 address with type.
 
static AttributePtr fromIpv6Prefix (const uint8_t type, const uint8_t len, const asiolink::IOAddress &value)
 From IPv6 prefix with type.
 
static AttributePtr fromString (const uint8_t type, const std::string &value)
 From type specific factories.
 
static AttributePtr fromText (const AttrDefPtr &def, const std::string &value)
 From definition generic factories.
 
static AttributePtr fromText (const std::string &repr)
 Generic factories.
 

Public Attributes

const uint8_t type_
 Type.
 

Protected Member Functions

 Attribute (const uint8_t type)
 Constructor.
 

Detailed Description

RADIUS attribute base class.

Definition at line 40 of file client_attribute.h.

Constructor & Destructor Documentation

◆ Attribute()

isc::radius::Attribute::Attribute ( const uint8_t type)
inlineexplicitprotected

Constructor.

Called from derived classes.

Parameters
typeattribute type.

Definition at line 48 of file client_attribute.h.

References type_.

◆ ~Attribute()

virtual isc::radius::Attribute::~Attribute ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ fromBinary()

AttributePtr isc::radius::Attribute::fromBinary ( const uint8_t type,
const std::vector< uint8_t > & value )
static

From binary with type.

Note
Requires the type to be of a standard string attribute.
Parameters
typetype of attribute.
valuebinary value.

Definition at line 150 of file client_attribute.cc.

References isc_throw.

Referenced by isc::radius::Message::decodeUserPassword(), and isc::radius::Message::encodeUserPassword().

◆ fromBytes() [1/2]

AttributePtr isc::radius::Attribute::fromBytes ( const AttrDefPtr & def,
const std::vector< uint8_t > & value )
static

From bytes with definition.

Parameters
defpointer to attribute definition.
valuebinary value.
Returns
pointer to the attribute.
Exceptions
BadValueon errors.

Definition at line 116 of file client_attribute.cc.

References isc::radius::AttrInt::fromBytes(), isc::radius::AttrIpAddr::fromBytes(), isc::radius::AttrIpv6Addr::fromBytes(), isc::radius::AttrIpv6Prefix::fromBytes(), isc::radius::AttrString::fromBytes(), isc_throw, isc::radius::PW_TYPE_INTEGER, isc::radius::PW_TYPE_IPADDR, isc::radius::PW_TYPE_IPV6ADDR, isc::radius::PW_TYPE_IPV6PREFIX, and isc::radius::PW_TYPE_STRING.

+ Here is the call graph for this function:

◆ fromBytes() [2/2]

AttributePtr isc::radius::Attribute::fromBytes ( const std::vector< uint8_t > & bytes)
static

From bytes (wire format).

Parameters
bytesbinary attribute.
Returns
pointer to the attribute or null.
Exceptions
BadValueon errors other than the definition can't be found.

Definition at line 91 of file client_attribute.cc.

References fromBytes(), isc::radius::AttrDefs::getByType(), isc::radius::AttrDefs::instance(), and isc_throw.

Referenced by isc::radius::Message::decode(), fromBytes(), isc::radius::Attributes::fromElement(), isc::radius::CfgAttributes::getEvalAll(), and isc::radius::RadiusAttributeParser::parse().

+ Here is the call graph for this function:

◆ fromInt()

AttributePtr isc::radius::Attribute::fromInt ( const uint8_t type,
const uint32_t value )
static

From integer with type.

Note
Requires the type to be of a standard integer attribute.
Parameters
typetype of attribute.
valueinteger value.

Definition at line 158 of file client_attribute.cc.

Referenced by isc::radius::RadiusRequest::RadiusRequest(), isc::radius::RadiusAccounting::buildAcct(), isc::radius::RadiusAccounting::buildAcct(), isc::radius::RadiusAccounting::buildAcct4(), isc::radius::RadiusAccounting::buildAcct6(), isc::radius::Exchange::buildRequest(), and fromText().

◆ fromIpAddr()

AttributePtr isc::radius::Attribute::fromIpAddr ( const uint8_t type,
const asiolink::IOAddress & value )
static

From IPv4 address with type.

Note
Requires the type to be of a standard ipaddr attribute.
Parameters
typetype of attribute.
valueIPv4 address.

Definition at line 163 of file client_attribute.cc.

Referenced by isc::radius::RadiusAccounting::buildAcct(), isc::radius::RadiusAccounting::buildAcct4(), and isc::radius::Exchange::buildRequest().

◆ fromIpv6Addr()

AttributePtr isc::radius::Attribute::fromIpv6Addr ( const uint8_t type,
const asiolink::IOAddress & value )
static

From IPv6 address with type.

Note
Requires the type to be of a standard ipv6addr attribute.
Parameters
typetype of attribute.
valueIPv6 address.

Definition at line 168 of file client_attribute.cc.

Referenced by isc::radius::RadiusAccounting::buildAcct(), isc::radius::RadiusAccounting::buildAcct6(), and isc::radius::Exchange::buildRequest().

◆ fromIpv6Prefix()

AttributePtr isc::radius::Attribute::fromIpv6Prefix ( const uint8_t type,
const uint8_t len,
const asiolink::IOAddress & value )
static

From IPv6 prefix with type.

Note
Requires the type to be of a standard ipv6prefix attribute.
Parameters
typetype of attribute.
lenprefix length.
valueIPv6 address.

Definition at line 173 of file client_attribute.cc.

Referenced by isc::radius::RadiusAccounting::buildAcct(), and isc::radius::RadiusAccounting::buildAcct6().

◆ fromString()

AttributePtr isc::radius::Attribute::fromString ( const uint8_t type,
const std::string & value )
static

From type specific factories.

Note
: should be used only for internal create of standard attributes.

From string with type.

Note
Requires the type to be of a standard string attribute.
Parameters
typetype of attribute.
valuestring value.

Definition at line 142 of file client_attribute.cc.

References isc_throw.

Referenced by isc::radius::RadiusAccounting::buildAcct(), isc::radius::RadiusAccounting::buildAcct(), isc::radius::RadiusAccounting::buildAcct4(), isc::radius::RadiusAccounting::buildAcct6(), isc::radius::RadiusAccess::buildAuth(), and isc::radius::RadiusAccess::buildAuth().

◆ fromText() [1/2]

AttributePtr isc::radius::Attribute::fromText ( const AttrDefPtr & def,
const std::string & value )
static

From definition generic factories.

From text with definition.

Parameters
defpointer to attribute definition.
valuetextual value.
Returns
pointer to the attribute.
Exceptions
BadValueon errors.

Definition at line 58 of file client_attribute.cc.

References fromInt(), isc::radius::AttrInt::fromText(), isc::radius::AttrIpAddr::fromText(), isc::radius::AttrIpv6Addr::fromText(), isc::radius::AttrIpv6Prefix::fromText(), isc::radius::AttrString::fromText(), isc::radius::AttrDefs::getByName(), isc::radius::AttrDefs::instance(), isc_throw, isc::radius::PW_TYPE_INTEGER, isc::radius::PW_TYPE_IPADDR, isc::radius::PW_TYPE_IPV6ADDR, isc::radius::PW_TYPE_IPV6PREFIX, and isc::radius::PW_TYPE_STRING.

+ Here is the call graph for this function:

◆ fromText() [2/2]

AttributePtr isc::radius::Attribute::fromText ( const std::string & repr)
static

Generic factories.

From text.

Parameters
reprname=value representation.
Returns
pointer to the attribute.
Exceptions
NotFoundif the definition can't be found.

Definition at line 28 of file client_attribute.cc.

References fromText(), isc::radius::AttrDefs::getByName(), isc::radius::AttrDefs::instance(), isc_throw, and isc::util::str::trim().

Referenced by isc::radius::Attributes::fromElement(), fromText(), and isc::radius::RadiusAttributeParser::parse().

+ Here is the call graph for this function:

◆ getType()

◆ getValueLen()

virtual size_t isc::radius::Attribute::getValueLen ( ) const
pure virtual

Generic get methods.

Value length.

Returns
Value length.

Implemented in isc::radius::AttrInt, isc::radius::AttrIpAddr, isc::radius::AttrIpv6Addr, isc::radius::AttrIpv6Prefix, and isc::radius::AttrString.

◆ getValueType()

virtual AttrValueType isc::radius::Attribute::getValueType ( ) const
pure virtual

◆ toBinary()

vector< uint8_t > isc::radius::Attribute::toBinary ( ) const
virtual

To binary.

Returns
the string value as a binary.
Exceptions
TypeErrorif the attribute is not a string one.

Reimplemented in isc::radius::AttrString.

Definition at line 185 of file client_attribute.cc.

References isc::radius::attrValueTypeToText(), getValueType(), and isc_throw.

+ Here is the call graph for this function:

◆ toBytes()

virtual std::vector< uint8_t > isc::radius::Attribute::toBytes ( ) const
pure virtual

To bytes (wire format).

Returns
binary representation.

Implemented in isc::radius::AttrInt, isc::radius::AttrIpAddr, isc::radius::AttrIpv6Addr, isc::radius::AttrIpv6Prefix, and isc::radius::AttrString.

◆ toInt()

uint32_t isc::radius::Attribute::toInt ( ) const
virtual

To integer.

Returns
the integer value.
Exceptions
TypeErrorif the attribute is not an integer one.

Reimplemented in isc::radius::AttrInt.

Definition at line 191 of file client_attribute.cc.

References isc::radius::attrValueTypeToText(), getValueType(), and isc_throw.

+ Here is the call graph for this function:

◆ toIpAddr()

IOAddress isc::radius::Attribute::toIpAddr ( ) const
virtual

To IPv4 address.

Returns
the IPv4 address value.
Exceptions
TypeErrorif the attribute is not an ipaddr one.

Reimplemented in isc::radius::AttrIpAddr.

Definition at line 197 of file client_attribute.cc.

References isc::radius::attrValueTypeToText(), getValueType(), and isc_throw.

+ Here is the call graph for this function:

◆ toIpv6Addr()

IOAddress isc::radius::Attribute::toIpv6Addr ( ) const
virtual

To IPv6 address.

Returns
the IPv6 address value.
Exceptions
TypeErrorif the attribute is not an ipv6addr one.

Reimplemented in isc::radius::AttrIpv6Addr.

Definition at line 203 of file client_attribute.cc.

References isc::radius::attrValueTypeToText(), getValueType(), and isc_throw.

+ Here is the call graph for this function:

◆ toIpv6Prefix()

IOAddress isc::radius::Attribute::toIpv6Prefix ( ) const
virtual

To IPv6 prefix.

Returns
the IPv6 address value.
Exceptions
TypeErrorif the attribute is not an ipv6prefix one.

Reimplemented in isc::radius::AttrIpv6Prefix.

Definition at line 209 of file client_attribute.cc.

References isc::radius::attrValueTypeToText(), getValueType(), and isc_throw.

+ Here is the call graph for this function:

◆ toIpv6PrefixLen()

uint8_t isc::radius::Attribute::toIpv6PrefixLen ( ) const
virtual

To IPv6 prefix length.

Returns
the IPv6 prefix length.
Exceptions
TypeErrorif the attribute is not an ipv6prefix one.

Reimplemented in isc::radius::AttrIpv6Prefix.

Definition at line 215 of file client_attribute.cc.

References isc::radius::attrValueTypeToText(), getValueType(), and isc_throw.

+ Here is the call graph for this function:

◆ toString()

string isc::radius::Attribute::toString ( ) const
virtual

Specific get methods.

Note
: should be used only for standard or type checked attributes.

To string.

Returns
the string value.
Exceptions
TypeErrorif the attribute is not a string one.

Reimplemented in isc::radius::AttrString.

Definition at line 179 of file client_attribute.cc.

References isc::radius::attrValueTypeToText(), getValueType(), and isc_throw.

+ Here is the call graph for this function:

◆ toText()

virtual std::string isc::radius::Attribute::toText ( size_t indent = 0) const
pure virtual

Returns text representation of the attribute.

Parameters
indentnumber of spaces before printing text.
Returns
string with text representation.

Implemented in isc::radius::AttrInt, isc::radius::AttrIpAddr, isc::radius::AttrIpv6Addr, isc::radius::AttrIpv6Prefix, and isc::radius::AttrString.

Member Data Documentation

◆ type_

const uint8_t isc::radius::Attribute::type_

Type.

Definition at line 227 of file client_attribute.h.

Referenced by Attribute(), and getType().


The documentation for this class was generated from the following files: