PcapPlusPlus
pcpp::RadiusLayer Class Reference

#include <RadiusLayer.h>

Inheritance diagram for pcpp::RadiusLayer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 RadiusLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 RadiusLayer (uint8_t code, uint8_t id, const uint8_t *authenticator, uint8_t authenticatorArrSize)
 
 RadiusLayer (uint8_t code, uint8_t id, const std::string authenticator)
 
 ~RadiusLayer ()
 
radius_headergetRadiusHeader ()
 
std::string getAuthenticatorValue ()
 
void setAuthenticatorValue (const std::string &authValue)
 
RadiusAttribute getFirstAttribute ()
 
RadiusAttribute getNextAttribute (RadiusAttribute &attr)
 
RadiusAttribute getAttribute (uint8_t attrType)
 
size_t getAttributeCount ()
 
RadiusAttribute addAttribute (const RadiusAttributeBuilder &attrBuilder)
 
RadiusAttribute addAttributeAfter (const RadiusAttributeBuilder &attrBuilder, uint8_t prevAttrType)
 
bool removeAttribute (uint8_t attrType)
 
bool removeAllAttributes ()
 
size_t getHeaderLen ()
 
void parseNextLayer ()
 
void computeCalculateFields ()
 
std::string toString ()
 
OsiModelLayer getOsiModelLayer ()
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer ()
 
LayergetPrevLayer ()
 
ProtocolType getProtocol ()
 
uint8_t * getData ()
 
size_t getDataLen ()
 
uint8_t * getLayerPayload ()
 
size_t getLayerPayloadSize ()
 
bool isAllocatedToPacket ()
 
void copyData (uint8_t *toArr)
 
uint8_t * getDataPtr (size_t offset=0)
 

Static Public Member Functions

static std::string getRadiusMessageString (uint8_t radiusMessageCode)
 

Detailed Description

Represents a RADIUS (Remote Authentication Dial-In User Service) protocol layer

Constructor & Destructor Documentation

◆ RadiusLayer() [1/3]

pcpp::RadiusLayer::RadiusLayer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 
)
inline

A constructor that creates the layer from an existing packet raw data

Parameters
[in]dataA pointer to the raw data
[in]dataLenSize of the data in bytes
[in]prevLayerA pointer to the previous layer
[in]packetA pointer to the Packet instance where layer will be stored in

◆ RadiusLayer() [2/3]

pcpp::RadiusLayer::RadiusLayer ( uint8_t  code,
uint8_t  id,
const uint8_t *  authenticator,
uint8_t  authenticatorArrSize 
)

A constructor that creates a new layer from scratch

Parameters
[in]codeThe RADIUS message code
[in]idThe RADIUS message ID
[in]authenticatorA pointer to a byte array containing the authenticator value
[in]authenticatorArrSizeThe authenticator byte array size. A valid size of the authenticator field is 16 bytes. If the provided size is less than that then the byte array will be copied to the packet but the missing bytes will stay zero. If the size is more than 16 bytes, only the first 16 bytes will be copied to the packet

◆ RadiusLayer() [3/3]

pcpp::RadiusLayer::RadiusLayer ( uint8_t  code,
uint8_t  id,
const std::string  authenticator 
)

A constructor that creates a new layer from scratch

Parameters
[in]codeThe RADIUS message code
[in]idThe RADIUS message ID
[in]authenticatorA hex string representing the authenticator value. A valid size of the authenticator field is 16 bytes. If the hex string represents an array that is smaller than this then the missing bytes in the packet's authenticator field will stay zero. If the hex string represents an array that is larger than 16 bytes, only the first 16 bytes will be copied to the packet

◆ ~RadiusLayer()

pcpp::RadiusLayer::~RadiusLayer ( )
inline

A d'tor for this layer, currently does nothing

Member Function Documentation

◆ addAttribute()

RadiusAttribute pcpp::RadiusLayer::addAttribute ( const RadiusAttributeBuilder attrBuilder)

Add a new RADIUS attribute at the end of the layer

Parameters
[in]attrBuilderA RadiusAttributeBuilder object that contains the requested attribute data to add
Returns
A RadiusAttribute object containing the newly added RADIUS attribute data or logical NULL (RadiusAttribute::isNull() == true) if addition failed

◆ addAttributeAfter()

RadiusAttribute pcpp::RadiusLayer::addAttributeAfter ( const RadiusAttributeBuilder attrBuilder,
uint8_t  prevAttrType 
)

Add a new RADIUS attribute after an existing one

Parameters
[in]attrBuilderA RadiusAttributeBuilder object that contains the requested attribute data to add
[in]prevAttrTypeThe RADIUS attribute which the newly added attribute will come after
Returns
A RadiusAttribute object containing the newly added RADIUS attribute data or logical NULL (RadiusAttribute::isNull() == true) if addition failed

◆ computeCalculateFields()

void pcpp::RadiusLayer::computeCalculateFields ( )
virtual

Calculate and store the value of radius_header::length according to the layer size

Implements pcpp::Layer.

◆ getAttribute()

RadiusAttribute pcpp::RadiusLayer::getAttribute ( uint8_t  attrType)

Get a RADIUS attribute by attribute type

Parameters
[in]attrTypeRADIUS attribute type
Returns
A RadiusAttribute object containing the first attribute data that matches this type, or logical NULL (RadiusAttribute::isNull() == true) if no such attribute found

◆ getAttributeCount()

size_t pcpp::RadiusLayer::getAttributeCount ( )
Returns
The number of RADIUS attributes in the packet

◆ getAuthenticatorValue()

std::string pcpp::RadiusLayer::getAuthenticatorValue ( )
Returns
A hex string representation of the radius_header::authenticator byte array value

◆ getFirstAttribute()

RadiusAttribute pcpp::RadiusLayer::getFirstAttribute ( )
Returns
The first RADIUS attribute in the packet. If there are no attributes the returned value will contain a logical NULL (RadiusAttribute::isNull() == true)

◆ getHeaderLen()

size_t pcpp::RadiusLayer::getHeaderLen ( )
virtual
Returns
The size written in radius_header::length

Implements pcpp::Layer.

◆ getNextAttribute()

RadiusAttribute pcpp::RadiusLayer::getNextAttribute ( RadiusAttribute attr)

Get the RADIUS attribute that comes after a given attribute. If the given attribute was the last one, the returned value will contain a logical NULL (RadiusAttribute::isNull() == true)

Parameters
[in]attrA given attribute
Returns
A RadiusAttribute object containing the attribute data that comes next, or logical NULL if the given attribute: (1) was the last one; (2) contains a logical NULL or (3) doesn't belong to this packet

◆ getOsiModelLayer()

OsiModelLayer pcpp::RadiusLayer::getOsiModelLayer ( )
inlinevirtual
Returns
The OSI Model layer this protocol belongs to

Implements pcpp::Layer.

◆ getRadiusHeader()

radius_header* pcpp::RadiusLayer::getRadiusHeader ( )
inline

Get a pointer to the RADIUS header. Notice this points directly to the data, so every change will change the actual packet data

Returns
A pointer to the radius_header object

◆ getRadiusMessageString()

static std::string pcpp::RadiusLayer::getRadiusMessageString ( uint8_t  radiusMessageCode)
static

A static method that returns the RADIUS message string for a give message code. For example: the string "Access-Request" will be returned for code 1

Parameters
[in]radiusMessageCodeRADIUS message code
Returns
RADIUS message string

◆ parseNextLayer()

void pcpp::RadiusLayer::parseNextLayer ( )
inlinevirtual

Does nothing for this layer, RADIUS is always last

Implements pcpp::Layer.

◆ removeAllAttributes()

bool pcpp::RadiusLayer::removeAllAttributes ( )

Remove all RADIUS attributes in this layer

Returns
True if all attributes were successfully removed or false if removal failed for some reason

◆ removeAttribute()

bool pcpp::RadiusLayer::removeAttribute ( uint8_t  attrType)

Remove an existing RADIUS attribute from the layer

Parameters
[in]attrTypeThe RADIUS attribute type to remove
Returns
True if the RADIUS attribute was successfully removed or false if type wasn't found or if removal failed

◆ setAuthenticatorValue()

void pcpp::RadiusLayer::setAuthenticatorValue ( const std::string &  authValue)

Setter for radius_header::authenticator

Parameters
[in]authValueA hex string representing the requested authenticator value

◆ toString()

std::string pcpp::RadiusLayer::toString ( )
virtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.