AW: RAD_REQUEST: Calling-Station-Id = ARRAY(0x825a588)

Zenz, Thomas Thomas.Zenz at oenb.at
Thu Jan 8 15:08:06 CET 2015


Thank you Herwin for the improvement of my coding. My perl basics are quite old ;)
I agree with you about the readability, that's  why I use empty if leaves ;)
I changed the code below to the scalar function version.

Thank' s to Microsoft, we have to fix their bugs...

Thomas

-----Ursprüngliche Nachricht-----
Von: freeradius-users-bounces+thomas.zenz=oenb.at at lists.freeradius.org [mailto:freeradius-users-bounces+thomas.zenz=oenb.at at lists.freeradius.org] Im Auftrag von Herwin Weststrate
Gesendet: Donnerstag, 08. Jänner 2015 14:21
An: FreeRadius users mailing list
Betreff: Re: RAD_REQUEST: Calling-Station-Id = ARRAY(0x825a588)

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 (scalar(@array) == 1 ){
            # everyting OK, one Entry
            ;
         }
         elsif (scalar(@array) > 1){
            syslog('info', "More than one Calling-Station-Id");
            print "\n";
            print @array;
            print "\n";
         }
         elsif (scalar(@array) == 1){
            syslog('info', "No Calling-Station-Id");
         }

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
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


More information about the Freeradius-Users mailing list