Using unlang for Calling-Station-Id

Alexander Clouter alex at digriz.org.uk
Mon Sep 14 12:54:30 CEST 2009


Kanwar Ranbir Sandhu <m3freak at thesandhufamily.ca> wrote:
>
> On Sat, 2009-09-12 at 23:28 +0100, Alexander Clouter wrote:
>
>> If you also make this a policy, then you can make your 
>> configuration simpler.
> 
> I'm not sure what you mean here.  Please explain.
>
In a snippet from my configuration I have:
----
authorize {
                preprocess

                rewrite.called_station_id
                rewrite.calling_station_id

                suffix

		....
}
----

The 'rewrite.call(ing|ed)_station_id' bit lurks in 
/etc/freeradius/policy.conf and looks like:
----
        rewrite.calling_station_id {
                if("%{request:Calling-Station-Id}" =~ /^([0-9a-f]{2}).?([0-9a-f]{2}).?([0-9a-f]{2}).?([0-9a-f]{2}).?([0-9a-f]{2}).?([0-9a-f]{2})$/i){
                        update request {
                                Calling-Station-Id := "%{1}-%{2}-%{3}-%{4}-%{5}-%{6}"
                        }
                }
                else {  
                        noop
                }
        }
----

This means you do not need to clutter your virtual server chunks with 
huge bits of regex :)

>> As this is just for logging, you probably just want the amendment in 
>> post-auth only, just before you call 'sql' or whatever.  
> 
> So, I don't need it in preacct?  I mean, it's working as is.  Would it
> be better to put in post-auth versus preacct?
>
Well, depends, if you want the original to be around then I would leave 
Calling-Station-Id alone, I like to only amend the original attribute 
values if they are mangled in some strange manner and need fixing up to 
be more kosher (for example '-' in MAC addresses rather than ':').

If this is for just logging you might want to 'update control' and 
tinker with 'Tmp-String-0' and then when it comes to your SQL logging 
you can use that in place of Calling-Station-Id.

Of course it all depends on your needs, from your description my gut 
feeling would be to leave Calling-Station-Id alone and create your own 
and add some custom attibutes to /etc/freeradius/dictionary.

Cheers

-- 
Alexander Clouter
.sigmonster says: Being ugly isn't illegal.  Yet.




More information about the Freeradius-Users mailing list