Substring using Unlang?

Olivier Beytrison olivier at heliosnet.org
Wed Jul 10 07:48:17 CEST 2013


On 10.07.2013 05:20, Peter Lambrechtsen wrote:

> In pseudo code it would be something like:
> 
> if (length(ADSL-Agent-Remote-Id) > 31) {
> 
> update reply {
>     strncat(SubscriberID, ADSL-Agent-Remote-Id +
> (strlen(ADSL-Agent-Remote-Id) - 31), 31)
> }
> }
> else {
> update reply {
>     SubscriberID := ADSL-Agent-Remote-Id
> }
> }
> 
> Where in effect if the string is longer than 31 chars take the right
> most 31 chars and only return that.

if ( ADSL-Agent-Remote-Id =~ /(.{0,31})$/ ) {
   update reply {
      SubscriberID := "%{1}"
   }
}

that should do it.

Olivier
-- 

 Olivier Beytrison
 Network & Security Engineer, HES-SO Fribourg
 Mail: olivier at heliosnet.org


More information about the Freeradius-Users mailing list