Normalizing MAC address for database storage?
hjf at hjf.com.ar
Mon Sep 28 07:53:56 CEST 2015
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:
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
More information about the Freeradius-Users