Normalizing MAC address for database storage?
I'm trying to use EAP and DHCP together: EAP authenticates the client, the MAC address is stored to database along with username, and then the DHCP module looks up the MAC and uses it as a key to retrieve the username, which will be used to find the user group, which will be the ip pool for the address. Anyway, the problem I've found is that the device I'm using sends the Calling-Station-Id as uppercase separated with hyphen: AA-BB-CC-DD-EE-FF, while DHCP uses the lowercase-colon format: aa:bb:cc:dd:ee:ff. How can I normalize the formats before writing to database? I've found the "tolower" case function which solves half the problem. But I can't find a way to convert "-" into ":". I could do it on SQL but I'd rather do it on Freeradius before it's stored. Maybe even a more minimalistic format would be better for MAC address: all lowercase, no separators: aabbccddeeff. A simple regex could discard anything that's not 0123456789abcdef, and then convert to lowercase. Thanks, Hernan
Maybe even a more minimalistic format would be better for MAC address: all lowercase, no separators: aabbccddeeff. A simple regex could discard anything that's not 0123456789abcdef, and then convert to lowercase.
I'd do this but of course you need tolower first before the regex... Kev/.
On Mon, Sep 28, 2015 at 2:23 PM, Kev Pearce <email.me@kevp.com> wrote:
Maybe even a more minimalistic format would be better for MAC address: all lowercase, no separators: aabbccddeeff. A simple regex could discard anything that's not 0123456789abcdef, and then convert to lowercase.
I'd do this but of course you need tolower first before the regex...
BEFORE regex? Not really. Just add "i". http://wiki.freeradius.org/guide/mac-auth -- Fajar
It'd be great if there were some prewritten function that could do that for you just waiting to be used in the profiles directory..... ;) alan
On Sep 28, 2015, at 1:53 AM, Hernán Freschi <hjf@hjf.com.ar> wrote:
Maybe even a more minimalistic format would be better for MAC address: all lowercase, no separators: aabbccddeeff. A simple regex could discard anything that's not 0123456789abcdef, and then convert to lowercase.
In v3, read raddb/policy.d/canonicalization Alan DeKok.
participants (5)
-
Alan Buxey -
Alan DeKok -
Fajar A. Nugraha -
Hernán Freschi -
Kev Pearce