Main Page | Namespace List | Alphabetical List | Class List | File List | Class Members | File Members

RadiusPacket Class Reference

#include <RadiusPacket.h>

List of all members.

Public Member Functions

 RadiusPacket (void)
 ~RadiusPacket (void)
 RadiusPacket (Octet code)
int addRadiusAttribute (RadiusAttribute *)
void dumpRadiusPacket (void)
void dumpShapedRadiusPacket (void)
int radiusSend (list< RadiusServer >::iterator)
int radiusReceive (list< RadiusServer > *)
int getRadiusAttribNumber (void)
char * getAuthenticator (void)
int getCode (void)
pair< multimap< Octet, RadiusAttribute
>::iterator, multimap< Octet,
RadiusAttribute >::iterator > 
findAttributes (int type)

Private Member Functions

void calcacctdigest (const char *secret)
void getRandom (int len, Octet *num)
int shapeRadiusPacket (const char *)
int unShapeRadiusPacket (void)

Private Attributes

multimap< Octet, RadiusAttributeattribs
int sock
Octet code
Octet identifier
unsigned short int length
Octet authenticator [RADIUS_PACKET_AUTHENTICATOR_LEN]
Octetsendbuffer
int sendbufferlen
Octetrecvbuffer
int recvbufferlen


Detailed Description

The class represents a radius packet with additional variables


Constructor & Destructor Documentation

RadiusPacket::RadiusPacket void   ) 
 

The constructur generates random numbers for the identifier. The socket, the code and the buffer length are set to 0, the pointer to the buffers is set to NULL. The length is set to 20 Bytes, this is the length without attributes.

RadiusPacket::~RadiusPacket void   ) 
 

The destructur frees the dynamic allocated memory of the buffers, closes the socket and clears the attribute multimap.

RadiusPacket::RadiusPacket Octet  code  ) 
 

The constructur sets the code and generate random numbers for the identifier. The socket and the buffer length are set to 0, the pointer to the buffers is set to NULL. The length is set to 20 Bytes, this is the length without attributes.

Parameters:
code The code of the packet.


Member Function Documentation

int RadiusPacket::addRadiusAttribute RadiusAttribute ra  ) 
 

Links a radiusAttrib structure to a radiusPacket.

Parameters:
ra The radius attribute to add.
Returns:
Returns 0 if everything is ok, NO_VALUE_IN_ATTRIBUTE if the attribut value length is 0. Return -1 if attribute value length is 0.

void RadiusPacket::calcacctdigest const char *  secret  )  [private]
 

Sets the authenticator field if the packet is a accounting request. It is a MD5 hash over the whole packet (the authenticator field itself is set to 0) and the shared secret.

Parameters:
secret The shared secret of the server in plaintext.

void RadiusPacket::dumpRadiusPacket void   ) 
 

Create a dump of the radius packet

void RadiusPacket::dumpShapedRadiusPacket void   ) 
 

Dumps a shaped RADIUS packet previously created with shapeRadiusPacket.

pair< multimap< Octet, RadiusAttribute >::iterator, multimap< Octet, RadiusAttribute >::iterator > RadiusPacket::findAttributes int  type  ) 
 

The method finds attributes with the given type in the packet and returns iterator pair. This can be looped for the attributes.

Parameters:
type The attribute type to find.
Returns:
A pair of the datatype pair<multimap<Octet,RadiusAttribute>::iterator,multimap<Octet,RadiusAttribute>::iterator>

char * RadiusPacket::getAuthenticator void   ) 
 

Returns a pointer to the authenticator field.

Returns:
A pointer to the authenticator field.

int RadiusPacket::getCode void   ) 
 

The getter method of the packet code.

Returns:
The code as an integer.

int RadiusPacket::getRadiusAttribNumber void   ) 
 

Returns the number of attributes in the given radiusPacket.

Returns:
An integer with the number of the attributes.

void RadiusPacket::getRandom int  len,
Octet num
[private]
 

Method to generate the hash for the authenticator in Accounting-Requests.

int RadiusPacket::radiusReceive list< RadiusServer > *  serverlist  ) 
 

Receives a packet from a radius server, and copies it into recvbuffer. If there is no response the packet is send again if the server->retry is bigger than 0. 1 means the packet is send one more time. If a packet is received the received data is write to the recvbuffer and the length is written to recvbufferlen. The attributes are cleared if a packet is received.

Parameters:
serverlist : A list of radius server.
Returns:
Returns 0 if everything is ok, else ALLOC_ERROR, UNKNOWN_HOST or NO_RESPONSE in case of error.

int RadiusPacket::radiusSend list< RadiusServer >::iterator  server  ) 
 

The method sends the packet to a radius server.

Parameters:
server A iterator to a server.
Returns:
Returns the number of bytes successfully sent, SOCKET_ERROR or UNKNOWN_HOST in case of error.

int RadiusPacket::shapeRadiusPacket const char *  sharedsecret  )  [private]
 

Formats a radiusPacket structure into a buffer that can be sent to a radius server via UDP. The destination buffer is put into sendbuffer while its length is put into sendbufferlen.

Parameters:
sharedsecret The sharedsecret in plaintext.
Returns:
Returns 0 if everything is ok, ALLOC_ERROR in case of error.

int RadiusPacket::unShapeRadiusPacket void   )  [private]
 

Formats a UDP-received buffer radiusPacket structure

Returns:
A error number. Returns 0 is everything is ok, NO_BUFFER_TO_UNSHAPE or ALLOC_ERROR or TO_BIG_ATTRIBUTE_LENGTH in case of error.


Member Data Documentation

multimap<Octet,RadiusAttribute> RadiusPacket::attribs [private]
 

Octet RadiusPacket::authenticator[RADIUS_PACKET_AUTHENTICATOR_LEN] [private]
 

Authenticator. In ACCEPT-Request packets it is a random number, in Accounting-Request it is a hash over whole packet and shared secret. The send-method generates it, when the code is an Accounting-Request

Octet RadiusPacket::code [private]
 

The code of the packet, see the Radius RFC or radius.h

Octet RadiusPacket::identifier [private]
 

The identifier of the packet, it is generated randomly.

unsigned short int RadiusPacket::length [private]
 

The length of the packet on the network in bytes.

Octet* RadiusPacket::recvbuffer [private]
 

Buffer for recveing the packet over the network.

int RadiusPacket::recvbufferlen [private]
 

Length of the buffer.

Octet* RadiusPacket::sendbuffer [private]
 

Buffer for sending the packet over the network.

int RadiusPacket::sendbufferlen [private]
 

Length of the buffer.

int RadiusPacket::sock [private]
 

The multimap for the radius attributes.The socket which is used.


The documentation for this class was generated from the following files:
Generated on Sun Nov 27 20:19:13 2005 for RadiusClass by  doxygen 1.4.2