Substring using Unlang?

Peter Lambrechtsen peter at crypt.co.nz
Wed Jul 10 05:20:51 CEST 2013


I've been looking at the options and it looks like the easiest will be
to use perl or similar external module as it can't be done easily in
FR 2.2.x

For our subscriber authentication we use in certain situations the
ADSL Remote ID as the Subscriber ID on the NAS.

The issue with this is the Subscriber ID is limited on our NAS to 32
chars, any longer than that and the subscriber doesn't come up.

With certain providers we connect up to they pass a ADSL Remote ID
value longer than 32 chars.

I was hoping there would be a way to trim / substring from the left
the string and return that.

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.

It's pretty simple in perl.  And I suspect that is the only way to do it.

This can't be done in Unlang or similar interpreted language within
freeradius itself?

Cheers

Peter


More information about the Freeradius-Users mailing list