Yep, there are the Net::Radius modules which incorporate methods for building packets for authentication and accounting against a Radius server - I have used these modules fairly extensively under their older namesake, RADIUS::Dictionary and RADIUS::Packet.
An example of usage of these Perl modules can be found in the System RADIUS Client Daemon project on Freshmeat here - From the code base for the next (and long overdue) release for this project ...
#!/usr/bin/perl
use Net::Radius::Dictionary;
use Net::Radius::Packet ();
use Socket;
.
.
.
sub build_radius_packet {
my (%attribute) = @_;
my $packet = Net::Radius::Packet->new($CONFIG->{'dictionary'});
if (defined $packet) {
$packet->set_code('Accounting-Request');
$packet->set_identifier(inet_ntoa(inet_aton($CONFIG->{'hostnam
+e'})));
$packet->set_authenticator(undef);
$packet->set_attr($_, $attribute{$_}) foreach sort keys %attri
+bute;
$packet->dump if $CONFIG->{'debug'};
}
return $packet;
}
sub send_radius_packet {
my ($packet) = @_;
my $response;
return undef unless socket(SOCK_UDP, PF_INET, SOCK_DGRAM, getproto
+byname('udp'));
my $data = Net::Radius::Packet::auth_resp($packet->pack, $CONFIG->
+{'secret'});
for (1..$CONFIG->{'retry'}) {
send(SOCK_UDP, $data, 0, $remote_addr);
sleep 1;
vec(my $rbit, fileno(SOCK_UDP), 1) = 1;
vec(my $wbit, fileno(SOCK_UDP), 1) = 1;
$response = select($rbit, $wbit, ($rbit | $wbit), $CONFIG->{'t
+imeout'});
last if $response > 1;
}
close(SOCK_UDP);
return $response;
}
| [reply] [d/l] |