Kea 3.1.3
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.
 
virtual uint32_t toVendorId () const
 To vendor id.
 
virtual std::vector< uint8_t > toVsaData () const
 To vsa data.
 
- 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 (handle vendor).
 
static AttributePtr fromBytes (const std::vector< uint8_t > &bytes)
 Generic factories.
 
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 fromVsa (const uint8_t type, const uint32_t vendor, const std::string &value)
 From Vendor ID and string data with type.
 
static AttributePtr fromVsa (const uint8_t type, const uint32_t vendor, const std::vector< uint8_t > &value)
 From Vendor ID and binary data with type.
 

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 43 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 51 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 147 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 (handle vendor).

Handle Vendor-Specific encapsulation.

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

Definition at line 100 of file client_attribute.cc.

References fromVsa(), isc_throw, and isc::radius::PW_VENDOR_SPECIFIC.

+ Here is the call graph for this function:

◆ fromBytes() [2/2]

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

Generic factories.

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 75 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 155 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(), and isc::radius::Exchange::buildRequest().

◆ 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 160 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 165 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 170 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 139 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()

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

From definition generic factories.

From text with definition (handle vendor).

Handle Vendor-Specific encapsulation.

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

Definition at line 28 of file client_attribute.cc.

References fromVsa(), isc_throw, and isc::radius::PW_VENDOR_SPECIFIC.

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

+ Here is the call graph for this function:

◆ fromVsa() [1/2]

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

From Vendor ID and string data with type.

Note
Requires the type to be of a standard vsa attribute.
Used only in unit tests.
Parameters
typetype of attribute.
vendorvendor id.
valuevsa data.

Definition at line 176 of file client_attribute.cc.

Referenced by fromBytes(), and fromText().

◆ fromVsa() [2/2]

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

From Vendor ID and binary data with type.

Note
Requires the type to be of the Vendor Specific attribute (26).
Parameters
typetype of attribute.
vendorvendor id.
valuevsa data.

Definition at line 182 of file client_attribute.cc.

◆ getType()

◆ getValueLen()

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

◆ 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 194 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

◆ 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 200 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 206 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 212 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 218 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 224 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 188 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.

Note
Used for logs.
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, isc::radius::AttrString, and isc::radius::AttrVsa.

◆ toVendorId()

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

To vendor id.

Returns
the vendor id.
Exceptions
TypeErrorif the attribute is not a vsa one.

Reimplemented in isc::radius::AttrVsa.

Definition at line 230 of file client_attribute.cc.

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

+ Here is the call graph for this function:

◆ toVsaData()

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

To vsa data.

Returns
the vsa data.
Exceptions
TypeErrorif the attribute is not a vsa one.

Reimplemented in isc::radius::AttrVsa.

Definition at line 236 of file client_attribute.cc.

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

+ Here is the call graph for this function:

Member Data Documentation

◆ type_

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

Type.

Definition at line 264 of file client_attribute.h.

Referenced by Attribute(), and getType().


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