RAD_REQUEST: Calling-Station-Id = ARRAY(0x825a588)
Herwin Weststrate
herwin at quarantainenet.nl
Thu Jan 8 14:20:37 CET 2015
On 08-01-15 10:55, Thomas Zenz wrote:
> This session has as Calling-Station-Id an ARRAY. So my script failed,
> and the Port was set to the MAB VLAN where clients only get Updates or
> PXE Boot.
According to Section 5.44 of RFC2865, a request should contain at most 1
Calling-Station-Id, so this client doesn't behave like it should.
> if ($#array ==1 ){
> # everyting OK, one Entry
> ;
> }
> elsif ($#array > 1){
> syslog('info', "More than one Calling-Station-Id");
> print "\n";
> print @array;
> print "\n";
> }
> elsif ($#array == 0){
> syslog('info', "No Calling-Station-Id");
> print $array[0];
> }
The syntax $#array return the index of the last element of the array, or
-1 if the array is empty. So with "$#array == 0" you have exactly one
element in @array instead of none, "$#array == 1" means two elements.
You probably want to rewrite "$#array" to "scalar(@array)", which
returns the number of elements. You could even shortcut it to statements
like "if (@array == 0)", which converts the array to a scalar with the
size automatically, but I'm not a big fan of that syntax (it heavily
relies on perl internals and make it less understandable for readers who
know only other programming languages).
--
Herwin Weststrate
More information about the Freeradius-Users
mailing list