Calling-Station-Id case sensitive

Alexander Clouter alex at digriz.org.uk
Wed Dec 17 11:01:46 CET 2008


lists at justinawilliams.com wrote:
>
> I am not really up  with perl... Is there any way that perl can rewrite
> the request and take out either the . or : or - between characters  as
> well as make everything lower case?
> 
> so that the calling-station-id request would be 00197da6ad06
> not 00:19:7d:a6:ad:06  or 00-19-7d-a6-ad-06  or 0019.7da6.ad06
> 
I have some unlang action for this that I use:

---------
if ( 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}"
  }
  update control {
    Tmp-String-0 := "%{1}%{2}%{3}%{4}%{5}%{6}"
  }
}

if ( Called-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 {
    Called-Station-Id := "%{1}-%{2}-%{3}-%{4}-%{5}-%{6}"
  }
}
-------

It seems to be RFCy if you keep with 00-11-22-33-44-55 as the style for 
MAC addresses, so outside FreeRADIUS it's stored in the RFC-manner[1] 
and for where I need to do 'fun' stuff[1] with it internally I use the 
Tmp-String-X family of internal variables.

Cheers

Alex

[1] LDAP lookups for example, such as cn=001122334455

-- 
Alexander Clouter
.sigmonster says: Do not use the blue keys on this terminal.




More information about the Freeradius-Users mailing list