#include <RadiusAttribute.h>
Public Member Functions | |
RadiusAttribute () | |
Constructor. | |
~RadiusAttribute () | |
Destructor. | |
void | dump () |
Dump attribute in readable text format to the STDOUT. | |
void | init (RadiusPacket *p_packet, uint16_t p_offset) |
Init attribute. | |
RadiusPacket * | getPacket (void) |
Get packet that this attribute belongs to. | |
uint16_t | getOffset (void) |
Get attribute's offset inside the packet. | |
unsigned char | getType (void) |
Get attribute type. | |
int | setType (unsigned char p_type) |
Set attribute type. | |
const char * | getTypeDescription (void) |
Get textual description of attribute type. | |
unsigned char | getLength (void) |
Get attribute length. | |
int | setLength (unsigned char p_length) |
Set attribute length. | |
int | isValid (void) |
Attribute is valid? | |
uint32_t | getNumber (void) |
Get value of the numeric attribute. | |
int | setNumber (uint32_t p_value) |
Set value of the numeric attribute. | |
in_addr | getIPAddress (void) |
Get value of the IP address attribute. | |
int | setIPAddress (struct in_addr p_value) |
Set value of the IP address attribute. | |
int | getString (const char *&p_data, uint16_t &p_length) |
Get value of the string attribute. | |
int | setString (const char *p_data, uint16_t p_length=0) |
Set value of the string attribute. | |
uint32_t | getVendorId (void) |
Get vendor ID of Vendor-Specific attribute. | |
int | setVendorId (uint32_t p_vendorId) |
Set vendor ID of Vendor-Specific attribute. | |
int | getVendorRawString (const char *&p_data, uint16_t &p_length) |
Get "raw" string data of Vendor-Specific attribute. | |
int | setVendorRawString (const char *p_data, uint16_t p_length=0) |
Set "raw" string data of Vendor-Specific attribute. | |
unsigned char | getVendorType () |
Get vendor type of Vendor-Specific attribute. | |
int | setVendorType (unsigned char p_value) |
Set vendor type of Vendor-Specific attribute. | |
unsigned char | getVendorLength () |
Get vendor length of Vendor-Specific attribute. | |
int | setVendorLength (unsigned char p_length) |
Set vendor length of Vendor-Specific attribute. | |
uint32_t | getVendorNumber () |
Get value of the numeric Vendor-Specific attribute. | |
int | setVendorNumber (uint32_t p_value) |
Set value of the numeric Vendor-Specific attribute. | |
in_addr | getVendorIPAddress () |
Get value of the IP address Vendor-Specific attribute. | |
int | setVendorIPAddress (struct in_addr p_address) |
Set value of the IP address Vendor-Specific attribute. | |
int | getVendorString (const char *&p_data, uint16_t &p_length) |
Get value of the string Vendor-Specific attribute. | |
int | setVendorString (const char *p_data, uint16_t p_length=0) |
Set value of the string Vendor-Specific attribute. | |
int | getUserPassword (char *p_data, uint16_t &p_length, RadiusSecret *p_secret=NULL) |
Get string data of User-Password attribute. | |
int | setUserPassword (const char *p_data, uint16_t p_length=0) |
Set string data of User-Password attribute. | |
int | getOldPassword (char *p_data, uint16_t &p_length, RadiusSecret *p_secret=NULL) |
Get string data of Old-Password attribute. | |
int | setOldPassword (const char *p_data, uint16_t p_length=0) |
Set string data of Old-Password attribute. | |
unsigned char | getChapIdentifier (void) |
Get CHAP identifier of CHAP-Password attribute. | |
int | setChapIdentifier (unsigned char p_chapId) |
Set vendor ID of CHAP-Password attribute. | |
int | getChapString (const char *&p_data, uint16_t &p_length) |
Get string data of CHAP-Password attribute. | |
int | setChapString (const char *p_data, uint16_t p_length=0) |
Set string data of CHAP-Password attribute. | |
Private Member Functions | |
void | dump (AttributeFormat_e p_format) |
This class does not keep any data - instead it provides methods to properly access and encode data at specific offset inside the RADIUS packet raw data buffer.
This implementation minimizes the footprint of RADIUS stack and does not require dynamic memory allocations. It's also very fast (at least in the typical RADIUS applications) since the data is immediately encoded inside the packet.
|
Init attribute. Set associated RADIUS packet and offset in it - this will effectively init the attribute. A special usage is to pass zero p_offset - this will mark attribute "invalid".
|
|
Get attribute type.
|
|
Set attribute type. Set attribute type
|
|
Get attribute length. Note that returned value is length of the attribute data block as encoded in raw RADIUS packet (in other words it's simply a value of Length octet in attribute data). You must take into account specific attribute type in order to calculate the "real data" length.
|
|
Set attribute length. Set attribute's length - refer to getLength() description for details.
|
|
Attribute is valid?
|
|
Get value of the numeric attribute.
|
|
Set value of the numeric attribute.
|
|
Get value of the IP address attribute.
|
|
Set value of the IP address attribute.
|
|
Get value of the string attribute. Note that string data may contain both readable characters and non-readable binary data. In any case string will not be null-terminated, hence you should use returned p_length value to properly operate on it.
|
|
Set value of the string attribute. Note that string data may contain both readable characters and non-readable binary data and in any case encoded string should not be null-terminated. You have two options:
|
|
Get vendor ID of Vendor-Specific attribute.
|
|
Set vendor ID of Vendor-Specific attribute.
|
|
Get "raw" string data of Vendor-Specific attribute. "Raw" string data of Vendor-Specific attribute typically contains Vendor Type, Vendor Length and Attribute-specific data. Therefore in most cases you should use getVendorType(), getVendorLength() and getVendorNumber() instead of this method. Note that string data may contain both readable characters and non-readable binary data. In any case string will not be null-terminated, hence yous should use returned p_length value to properly operate on it.
|
|
Set "raw" string data of Vendor-Specific attribute. "Raw" string data of Vendor-Specific attribute typically contains Vendor Type, Vendor Length and Attribute-specific data. Therefore in most cases you should use setVendorType(), setVendorLength() and setVendorNumber() instead of this method. Note that string data may contain both readable characters and non-readable binary data and in any case encoded string should not be null-terminated. You have two options:
|
|
Get vendor type of Vendor-Specific attribute.
|
|
Set vendor type of Vendor-Specific attribute.
|
|
Get vendor length of Vendor-Specific attribute.
|
|
Set vendor length of Vendor-Specific attribute.
|
|
Get value of the numeric Vendor-Specific attribute.
|
|
Set value of the numeric Vendor-Specific attribute.
|
|
Get value of the IP address Vendor-Specific attribute.
|
|
Set value of the IP address Vendor-Specific attribute.
|
|
Get value of the string Vendor-Specific attribute. Note that string data may contain both readable characters and non-readable binary data. In any case string will not be null-terminated, hence you should use returned p_length value to properly operate on it.
|
|
Set value of the string Vendor-Specific attribute. Note that string data may contain both readable characters and non-readable binary data. In any case string should not be null-terminated. Note that string data may contain both readable characters and non-readable binary data and in any case encoded string should not be null-terminated. You have two options:
|
|
Get string data of User-Password attribute. Password is decoded from the packet using secret key and presented in it's "original" form. Note that password may contain both readable characters and non-readable binary data. In any case string will not be null-terminated, hence you should use returned p_length value to properly operate on it.
|
|
Set string data of User-Password attribute. Password is encoded into the packet using secret key. The actual encoding is performed when packet is transmitted to the network (using the secret key of current connection) - therefore if you "dump" packet beforehand you won't see any data encoded. Note that the password may contain both readable characters and non-readable binary data. In any case encoded string should not be null-terminated. You have two options:
|
|
Get string data of Old-Password attribute. Password is decoded from the packet using secret key and presented in it's "original" form. Note that string data may contain both readable characters and non-readable binary data. In any case string will not be null-terminated, hence you should use returned p_length value to properly operate on it.
|
|
Set string data of Old-Password attribute. Password is encoded into the packet using secret key. The actual encoding is performed when packet is transmitted to the network (using the secret key of current connection) - therefore if you "dump" packet beforehand you won't see any data encoded. The application must add User-Password attribute prior to adding Old-Password, since encrypted User-Password data is used instead of shared authenticator for encoding Note that the password may contain both readable characters and non-readable binary data. In any case encoded string should not be null-terminated. You have two options:
|
|
Get CHAP identifier of CHAP-Password attribute.
|
|
Set vendor ID of CHAP-Password attribute.
|
|
Get string data of CHAP-Password attribute. Note that string data may contain both readable characters and non-readable binary data. In any case string will not be null-terminated, hence you should use returned p_length value to properly operate on it.
|
|
Set string data of CHAP-Password attribute. Note that string data may contain both readable characters and non-readable binary data. In any case string should not be null-terminated. You have two options:
|
|
|