Hello Everyone -
Many of you have asked questions about how to deal with Cisco NAS-Port
attributes, so here is a hook I wrote recently that shows one way of dealing
with the encoded information.
regards
Hugh
--
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.
# cisco-nas-port.pl
# PreClientHook to extract NAS-Port information.
#
# Cisco encodes information in the NAS-Port attribute as follows:
#
# nl-rt-sh-vpn-aer11(config)#radius-server attribute nas-port format ?
#� a �Format is type, channel, port
#� b �Either interface(16) or isdn(16), async(16)
#� c �Data format(bits): shelf(2), slot(4), port(5), channel(5)
#� d �Data format(bits): slot(4), module(1), port(3), vpi(8), vci(16)
#
# This hook is written for Cisco format "d" above (ATM vpi/vci).
#
# The encoded information is extracted and the individual data elements
# are added to the request packet as pseudo-attributes.
#
# Hugh Irvine, Open System Consultants, 20010622
sub
{
my $p = ${$_[0]};
my $nasport = $p->get_attr('NAS-Port');
if (defined($nasport))
{
my ($slot, $module, $port, $vpi, $vci);
$vci = $nasport & 0xffff;
$nasport = $nasport >> 16;
$vpi = $nasport & 0xff;
$nasport = $nasport >> 8;
$port = $nasport & 0x7;
$nasport = $nasport >> 3;
$module = $nasport & 0x1;
$nasport = $nasport >> 1;
$slot = $nasport & 0xf;
$p->add_attr('Cisco-NAS-Port-Vci', $vci)
if defined $vci;
$p->add_attr('Cisco-NAS-Port-Vpi', $vpi)
if defined $vpi;
$p->add_attr('Cisco-NAS-Port-Port', $port)
if defined $port;
$p->add_attr('Cisco-NAS-Port-Module', $module)
if defined $module;
$p->add_attr('Cisco-NAS-Port-Slot', $slot)
if defined $slot;
}
}