(RADIATOR) hook to update the radpool table when using AddressAllocator SQL
Kwang Moon
kwang.moon at O2.com
Fri Feb 6 08:20:58 CST 2004
Hi,
I'm trying to implement a hook to deal with accounting alive packets - ie
when an alive packet is received, then update the expiry value in the
RADPOOL table for a further 24 hours.
This is the hook that I wrote. It works, but I'm sure there's a better way
to do it by accessing the database handle that was opened by the
AddressAllocator clause rather than opening up and closing down a new sql
connection each time the hook is fired.
sub {
my $request = ${$_[0]};
# If the packet is an Accounting Alive packet reset the expiry value
in the RADIUS DB for a further 24 hours.
return unless ($request->code() eq 'Accounting-Request');
my $statustype = $request->get_attr('Acct-Status-Type');
return unless ($statustype eq 'Alive');
my $query = undef;
my $expiry = time + 86400;
my $framedipaddress = $request->get_attr('Framed-IP-Address');
my $sth = undef;
my $rv = undef;
my $sess_handle = DBI->connect("dbi:Oracle:radius", "xxx",
"xxx", { RaiseError => 1, AutoCommit => 0 });
$query = "update radpool set expiry=? where yiaddr=?";
$sth = $sess_handle->prepare($query);
$rv = $sth->execute($expiry, $framedipaddress);
$sth->finish;
$sess_handle->disconnect;
}
Any suggestions for improvement would be most welcomed. Thanks in advance.
Cheers,
Kwang
===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.
More information about the radiator
mailing list