blob: 559020dfbbdf36ad3c07d5ba7a74265813cbd2e2 [file] [log] [blame]
# -- validate_mac
#
# mac address validator to be used with the form broker
proc validate_mac {_mac_address_d} {
upvar $_mac_address_d mac_address_d
dict with mac_address_d {
set var [string trim $var]
if {[regexp {^[[:xdigit:]]{2}([:-][[:xdigit:]]{2}){5}$} $var]} {
set var [string tolower $var]
# we normalize the mac address to the Unix form.
# The dash '-' characters in the windows representation
# are replaced by columns ':'
set var [regsub -all -- {-} $var :]
# the 'constrain' field is bidirectional:
# it tells the validator to curb/change the value
# within the bonds/forms/representation suitable.
# By setting it the validator tells the FormBroker
# to copy the value back in the response array
set constrain 1
return FB_OK
} else {
return FB_WRONG_MAC
}
}
}