#include <RadiusPacket.h>
Public Member Functions | |
RadiusPacket (unsigned char p_code, RadiusClientStack &p_stack) | |
Constructor. | |
RadiusPacket (unsigned char p_code, RadiusPacket &p_request) | |
Constructor. | |
RadiusPacket (unsigned char p_code) | |
Constructor. | |
RadiusPacket (const RadiusPacket &p_packet) | |
Copy constructor. | |
~RadiusPacket () | |
Destructor. | |
unsigned char | getCode (void) |
Get packet code. | |
const char * | getCodeDescription (void) |
Get packet code description. | |
uint16_t | getLength (void) |
Get packet length. | |
unsigned char | getID (void) |
Get packet identifier. | |
void | setID (unsigned char p_id) |
Set packet identifier. | |
void | randomID () |
Set random packet identifier. | |
RadiusSecret * | getSecret (void) |
Get secret key used for packet encoding. | |
void | setSecret (RadiusSecret *p_secret) |
Set secret key used for packet encoding. | |
const unsigned char * | getAuthenticator (void) |
Get packet authenticator. | |
void | setAuthenticator (const unsigned char *p_auth) |
Set packet authenticator. | |
void | dump () |
Dump radius packet in readable text format to the STDOUT. | |
int | getFirstAttribute (RadiusAttribute &p_attr) |
Get first attribute in the packet. | |
int | getNextAttribute (RadiusAttribute &p_attr) |
Get next attribute in the packet. | |
int | findAttribute (unsigned char p_attrType, RadiusAttribute &p_attr) |
Find specific attribute in the packet. | |
int | addAttribute (unsigned char p_attrType, RadiusAttribute &p_attr) |
Add new attribute to the packet. | |
unsigned char * | getRawData (void) |
Get raw packet data. | |
int | adjustLength (uint16_t p_length) |
Adjust packet's length. | |
void | responseAuthenticator (RadiusSecret *p_secret=NULL) |
Generate authenticator for response packet. | |
void | accountingRequestAuthenticator (RadiusSecret *p_secret=NULL) |
Generate authenticator for accounting request packet. | |
bool | verifyResponse (RadiusPacket &p_packet) |
Verify RADIUS response. | |
Private Member Functions | |
void | init (unsigned char p_code) |
Init packet. | |
void | randomAuthenticator (void) |
Generate pseudo-random authenticator. | |
void | setCode (unsigned char p_code) |
Set packet's code. | |
void | setLength (uint16_t p_length) |
Set packet's length. | |
Private Attributes | |
unsigned char | m_data [D_RAW_DATA_LENGTH] |
Raw packet data. | |
RadiusSecret * | m_secret |
RADIUS secret associated with this packet. |
RadiusPacket class is responsible for holding data transferred to/from the network and providing simple interface to build new outgoing RADIUS packet and to parse incoming packet.
|
Constructor. This constructor should be used for constructing RADIUS requests (i.e. by RADIUS client application). It automatically generates random Authenticator, however application may override this later on by calling setAuthenticator() method.
|
|
Constructor. This constructor should be used for constructing RADIUS responses (i.e. by RADIUS server application). Original RADIUS request should be passed as parameter to it.
|
|
Constructor. This constructor should be used for constructing RADIUS requests. It automatically generates random Authenticator, however application may override this later on by calling setAuthenticator() method. Most applications should use the former constructors instead of this one. If for any reason you decide to use this constructor, make sure to update packet's identifier (by default packet will have zero ID).
|
|
Get packet code.
|
|
Get packet length.
|
|
Get packet identifier.
|
|
Set packet identifier.
|
|
Get secret key used for packet encoding.
|
|
Set secret key used for packet encoding.
|
|
Get first attribute in the packet. Updates p_attr to point at the first attribute in the packet. If packet has no attributes "invalid" attribute is returned. Typical code that goes over all attributes in the packet looks as follows: RadiusAttribute l_attr; for (packet->getFirstAttribute(l_attr); l_attr.isValid(); packet->getNextAttribute(l_attr)) { // do something with the attribute }
|
|
Get next attribute in the packet. Updates p_attr to point at the next attribute in the packet after the one that it was pointing at prior to calling this function. If no more attributes are found "invalid" attribute is returned. Application can analyze return code or use isValid() method of RadiusAttribute to verify validity of the returned attribute.
|
|
Find specific attribute in the packet. Updates p_attr to point at the first attribute of specified type in the packet. If attribute is not found "invalid" attribute is returned. If more than one instance of the same attribute exist in the packet, application should use getNextAttribute() interface to retrieve them. Application can analyze return code or use isValid() method of RadiusAttribute to verify validity of the returned attribute.
|
|
Add new attribute to the packet. Updates p_attr to point at the free space in the packet. Returns RadiusAttribute structure should be used by application in order to set attribute's value. If packet is full, "invalid" attribute is returned. Actual attribute's data is not encoded into the packet until proper attribute's set() method is called. So if application calls addAttribute() and then suddenly changes it's mind, it's perfectly OK to simply call addAttribute() again or send the packet "as is". Application can analyze return code or use isValid() method of RadiusAttribute to verify validity of the returned attribute.
|
|
Adjust packet's length. Adjust (increase) packet's length by specified number of bytes. If packet has not enough space to accomodate requested data, RC_FAIL is returned.
|
|
Generate authenticator for response packet. Packet's authenticator should be initially set to the request's authenticator. This method should be called once only - prior to sending the packet over the network. Usually RadiusServer does the job, so user application doesn't have to bother.
|
|
Generate authenticator for accounting request packet. Packet's attributes should be ready before calling This method should be called once only - prior to sending the packet over the network. Usually RadiusClientStack does the job, so user application doesn't have to bother.
|
|
Set packet's code. Set packet's code. This method is intentionally put into the private section, since application should pass packet's code to RadiusPacket constructor.
|
|
Set packet's length. Set packet's length
|