Converting attributes from hex to ASCII
Aaron Paetznick
aaronp at critd.com
Wed Mar 31 05:27:34 CEST 2010
Thanks Arran, but I'm already pretty clear on how to update variables in
the request. I just don't know how to go about adding the logic to
convert hex/octal strings to ASCII values in unlang.
This is untested, but my current line of thinking is to modify the
queries in sql.conf with something like this:
...
IF('%{Some-Trigger-Attribute}'="TRIGGER-VALUE",
UNHEX('%{Called-Station-Id}'), '%{Called-Station-Id}'), \
...
A little bit of overhead to every query, but I suspect it will be
manageable on our network. Alternatively, I suppose I could do
something like this (untested):
...
if ("%{Some-Trigger-Attribute}" =~ /^TRIGGER-VALUE$/) {
update request {
Called-Station-Id := '%{sql:SELECT UNHEX(%{Called-Station-Id})}'
}
}
...
This somehow seems less desirable though.
--Aaron
On 3/30/2010 10:06 PM, Arran Cudbard-Bell wrote:
> update request {
> Tmp-String-1 := `printf etc...`
> }
>
> Then use variable expansion %{request:Tmp-String-1}. Variables in the
> backticks will also be expanded.
>
> -Arran
>
> On 3/30/10 4:59 PM, Aaron Paetznick wrote:
>> I'm receiving User-Name and various Cisco-AVPair attributes as hex.
>>
>> The situation is complicated. We have a Calix NAS doing something
>> called DHCP-triggered RADIUS accounting through a Cisco ASR. This
>> means neither vendor wants to accept responsibility, and here we are.
>>
>> I just thought it would be nice if FreeRADIUS supported a perl-like
>> regex system for manipulating strings. I think I'll have to try to fix
>> this by jiggering the SQL.
>>
>> I just wanted to see if anybody else has dealt with something like this.
>>
>>
>> --Aaron
>>
>>
>> Alan DeKok wrote:
>>> Aaron Paetznick wrote:
>>>> I am receiving certain accounting attributes as hex encoded strings,
>>>
>>> Why? Which attributes are they?
>>>
>>>> and
>>>> I would like to convert them back to cleartext ASCII before sending
>>>> them
>>>> to MySQL.
>>>>
>>>> I can't simply update the SQL with UNHEX() functions, as not all of the
>>>> requests are hex encoded this way.
>>>
>>> It sounds like the NAS is broken. Not that I'm surprised...
>>>
>>>> If I could use perl, I would do something like this:
>>>
>>> Why not use Perl? The server doesn't have generic string handling
>>> functions, and I don't see the need to invent yet another language.
>>>
>>> Alan DeKok.
>>> -
>>> List info/subscribe/unsubscribe? See
>>> http://www.freeradius.org/list/users.html
>> -
>> List info/subscribe/unsubscribe? See
>> http://www.freeradius.org/list/users.html
>
More information about the Freeradius-Users
mailing list