unlang substring with nas-port-id

Kris kgrobelak at airspeed.ie
Thu Mar 21 02:37:46 CET 2013


Hi,

Not sure about it but I think you might be able to use regex to do that.
It may be something like:

if("%{NAS-Port-Id}" =~ / \b[1-4][0-9]{3}/) { #this to extract the vlan

         switch "%{1}" { #this to refer to the matched vlan tag substring

                 case 1000 {
                         ....
                 }

                 case 1001 {
                         ....
                 }
                 ....
         }
}

But you might need to double check the syntax in man unlang. Hopefully 
someone will correct me on this.

Regards,
Krzysztof

On 20/03/13 09:57, Łukasz Kopiszka wrote:
> Hi,
>
> I'm receiving from SE100:
> NAS-Port-Id = "2/2 vlan-id 1001 clips 132019"
>
> How to extract number 1001 which will be used in code:
>
> switch "extracted vlan-id" {
>         case 1000 {
>                 ...
>     }
>         case 1001 {
>                 ...
>     }
>         case 1002 {
>                 ...
>     }
> ...
> }
>




Airspeed Telecom


More information about the Freeradius-Users mailing list