Because to pass multiple hashes, you need to pass references instead of the hashes themselves. Try something more like:
print_attrs(\%RAD_REQUEST, \%RAD_REPLY, \%RAD_CHECK);
sub print_attrs
{
my $req=shift;
my $reply=shift;
my $check=shift;Then, when you want to reference them, use something like:
${$req}{'key'}
i.e.:
${$req}{'key'}="value";
$foo=${$req}{'key'};etc.
Owen
--On Monday, June 23, 2003 7:15 PM +0600 [EMAIL PROTECTED] wrote:
I try to use perl.
I am confused
in sub authorize i write for debuging something like
sub authorize {
....... print_attrs(%RAD_REQUEST, %RAD_REPLY, %RAD_CHECK);
deb_print ("walk on hash RAD_REQUEST"); for $k (keys %RAD_REQUEST) { deb_print ("$k = $RAD_REQUEST{$k} "); } return $retval; }
deb_print is sub deb_print { print "radius.pl: ", @_,"\n"; }
i use arguments in print_attrs
sub print_attrs { my(%REQUEST, %REPLY, %CHECK) = @_;
logging("RAD_REQUEST: ==============="); for (keys %REQUEST) { deb_print("$_ = $REQUEST{$_} "); } logging("RAD_REPLY: ==============="); for (keys %REPLY) { deb_print("$_ = $REPLY{$_} "); } logging("RAD_CHECK: ==============="); for (keys %CHECK) { deb_print("$_ = $CHECK{$_} "); }
}
output is:
radius.pl: RAD_REQUEST: =============== radius.pl: Service-Type = Framed-User radius.pl: Auth-Type = MS-CHAP radius.pl: Calling-Station-Id = 192.168.0.2 radius.pl: MS-CHAP-Challenge = 0x71d56b9f34d89e3db8fba365beb64b08 radius.pl: Client-IP-Address = 192.168.0.12 radius.pl: Framed-Protocol = PPP radius.pl: User-Name = mmike radius.pl: User-Password = mike radius.pl: MS-CHAP2-Response = 0x0100e7814331bd36eafd3cfd1a646fbd3ac200000000000 00000769c73a6a9107f13152e660efc401eafeea5e6e3aec5c18f radius.pl: Connect-Info = 1524 radius.pl: NAS-Port = 0 radius.pl: NAS-IP-Address = 192.168.0.12 radius.pl: RAD_REPLY: =============== radius.pl: RAD_CHECK: ===============
radius.pl: walk on hash RAD_REQUEST radius.pl: Service-Type = Framed-User radius.pl: Calling-Station-Id = 192.168.0.2 radius.pl: MS-CHAP-Challenge = 0x71d56b9f34d89e3db8fba365beb64b08 radius.pl: Client-IP-Address = 192.168.0.12 radius.pl: Framed-Protocol = PPP radius.pl: User-Name = mmike radius.pl: MS-CHAP2-Response = 0x0100e7814331bd36eafd3cfd1a646fbd3ac200000000000 00000769c73a6a9107f13152e660efc401eafeea5e6e3aec5c18f radius.pl: Connect-Info = 1524 radius.pl: NAS-Port = 0 radius.pl: NAS-IP-Address = 192.168.0.12
output from print_attrs looks like no attributes in RAD_CHECK both User-Password and Auth-Type in RAD_REQUEST. but in really they in RAD_CHECK.
when i not use arguments in print_attrs
sub print_attrs { # my(%REQUEST, %REPLY, %CHECK) = @_; ..... }
then i have follow output
radius.pl: RAD_REQUEST: =============== radius.pl: Service-Type = Framed-User radius.pl: Calling-Station-Id = 192.168.0.2 radius.pl: MS-CHAP-Challenge = 0x71d56b9f34d89e3db8fba365beb64b08 radius.pl: Client-IP-Address = 192.168.0.12 radius.pl: Framed-Protocol = PPP radius.pl: User-Name = mmike radius.pl: MS-CHAP2-Response = 0x0100e7814331bd36eafd3cfd1a646fbd3ac200000000000 00000769c73a6a9107f13152e660efc401eafeea5e6e3aec5c18f radius.pl: Connect-Info = 1524 radius.pl: NAS-Port = 0 radius.pl: NAS-IP-Address = 192.168.0.12 radius.pl: RAD_REPLY: =============== radius.pl: RAD_CHECK: =============== radius.pl: User-Password = mike radius.pl: Auth-Type = MS-CHAP
radius.pl: walk on hash RAD_REQUEST radius.pl: Service-Type = Framed-User radius.pl: Calling-Station-Id = 192.168.0.2 radius.pl: MS-CHAP-Challenge = 0x71d56b9f34d89e3db8fba365beb64b08 radius.pl: Client-IP-Address = 192.168.0.12 radius.pl: Framed-Protocol = PPP radius.pl: User-Name = mmike radius.pl: MS-CHAP2-Response = 0x0100e7814331bd36eafd3cfd1a646fbd3ac200000000000 00000769c73a6a9107f13152e660efc401eafeea5e6e3aec5c18f radius.pl: Connect-Info = 1524 radius.pl: NAS-Port = 0 radius.pl: NAS-IP-Address = 192.168.0.12
Looks good - both User-Password and Auth-Type in RAD_CHECK in print_attrs and in walk on hash.
what is the reason of such different behaviour?
Mike
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
