Data::Radius::Packet - module to encode/decode RADIUS messages
use Data::Radius::Constants qw(:all); use Data::Radius::Packet; my $dictionary = Data::Radius::Dictionary->load_file('./radius/dictionary'); my $packet = Data::Radius::Packet->new(secret => 'top-secret', dict => $dictionary); # build request packet: my ($request, $req_id, $authenticator) = $packet->build( type => ACCESS_REQUEST, av_list => [ { Name => 'User-Name', Value => 'JonSnow'}, { Name => 'Password', Value => 'Castle Black' }, { Name => 'Message-Authenticator', Value => '' }, ], ); # ... send $request and read $reply binary packets from RADIUS server # parse reply packet: my ($reply_type, $reply_id, $reply_authenticator, $av_list) = $packet->parse($reply, $authenticator);
The Data::Radius::Packet module provides a methods to encode/decode RADIUS messages. It can be used to implement both Radius client or Radius server.
Data::Radius::Packet
Create a new object. All arguments are optional. Dictionary is object of Data::Radius::Dictionary which allow to use attribute names instead of codes. Secret is global secret string, can be overrided when building a new packet.
Data::Radius::Dictionary
Build a binary-encoded RADIUS packet.
type identify type of RADIUS request. They are defined in Data::Radius::Constants.
type
av_list is ARRAY-REF of attributes, each defined as HASH-REF with keys {Name, Value} or {Id, [VendorId], Value}
av_list
authenticator is optional for request (by default the random value will be used), but required for replies.
authenticator
secret and dict can be used to override values from constructor (for example to use individual secrets for different Radius servers).
secret
dict
with_msg_auth can be passed to append Message-Authenticator attribute. It also can be archived by adding this attribyte to AV list with empty value
with_msg_auth
request_id - allow to define own it. By default internal sequence is used. Value must be in range 0-255 (1byte)
request_id
Parse binary-encoded RADIUS packet to list of attributes
Returns multiple values: RADIUS code, request id, authenticator, ARRAY-REF of attributes
Returns request id from packet without parsing it's attribues. Can be used to choose request authenticator before parsing the response packet in full.
Data::Radius::Constants, Data::Radius::Dictionary
Sergey Leschenko <sergle.ua at gmail.com>
PortaOne Development Team <perl-radius at portaone.com> is the current module's maintainer at CPAN.
To install Data::Radius, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Radius
CPAN shell
perl -MCPAN -e shell install Data::Radius
For more information on module installation, please visit the detailed CPAN module installation guide.