Hello Martin -
I think from the code below you are referring to the session database? In any case, my answer holds true for an AuthBy SQL as well.
You should have a look at the example code in "goodies/hooks.txt", the reply hook that does dynamic address allocation.
This is how to find a specific AuthBy clause:
# Find the AuthBy clause with the same Identifier
my $authby = Radius::AuthGeneric::find($identifier);
&main::log($main::LOG_DEBUG, "Found AuthBy with Identifier $identifier");
Similarily you could use something like this for a session database:
# Find the session database with the same Identifier
my $sessdb = Radius::SessGeneric::find($identifier);
&main::log($main::LOG_DEBUG, "Found SessionDatabase with Identifier $identifier");
Once you have the handle to a specific clause, you can use it to call any of the routines supported by that module to reference the object that the module refers to.
You should also have a look at the code in Radius/SessSQL.pm.
regards
Hugh
On Tuesday, October 29, 2002, at 11:33 AM, Martin Edge wrote:
Hey Guys,NB: I am travelling this week, so there may be delays in our correspondence.
Little curious, I need to perform an Extra SQL query while processing RADIUS
requests, and set the value to an internal Radiator variable, it comes from
the same database, so I was wondering how one would utilise the existing DB
connection easily, without having to spawn an additional one using DBI.
Below is the code I'm using..
# find the POP id
sub
{
my $p = ${$_[0]};
my $nasip;
my $db;
$nasip = $p->get_attr('NAS-IP-Address');
# If there is a NAS at all..
if ($nasip) {
use DBI;
my $user = "xxxxxx";
my $password = "xxxxxxxxx";
my $database = "xxxxxxxxxx";
my $dsn = "DBI:mysql:database=$database;host=192.168.3.21";
$db = DBI->connect($dsn, $user, $password);
if (!$db) {
&main::log($main::LOG_DEBUG,"Failed Bringin Up
Second DB\n".DBI::errstr);
return;
}
# get the popid
my $popidquery = "select popid from nascache where
nasidentifier = '$nasip'";
my $sth = $db->prepare($popidquery);
$sth->execute;
my $popid = ($sth->fetchrow())[0];
if ($popid) {
&main::setVariable("popid", $popid);
&main::log($main::LOG_DEBUG,"Resolved Packet to
POPid $popid");
} else {
&main::log($main::LOG_DEBUG,"No POPid for NASIP
$nasip");
&main::setVariable("popid", "0");
}
}
Regards,
Martin Edge
Software/Network Engineer
KBS Internet
Phone: 1300 727 205
Web: http://www.kbs.net.au/
Extranet: http://xray.kbs.net.au/
eMail: [EMAIL PROTECTED]
-------------=-=-=-----------------
===
Archive at http://www.open.com.au/archives/radiator/
Announcements on [EMAIL PROTECTED]
To unsubscribe, email '[EMAIL PROTECTED]' with
'unsubscribe radiator' in the body of the message.
--
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. Available on *NIX, *BSD, Windows 95/98/2000, NT, MacOS X.
-
Nets: internetwork inventory and management - graphical, extensible,
flexible with hardware, software, platform and database independence.
===
Archive at http://www.open.com.au/archives/radiator/
Announcements on [EMAIL PROTECTED]
To unsubscribe, email '[EMAIL PROTECTED]' with
'unsubscribe radiator' in the body of the message.
