diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-03-12 16:12:18 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-03-12 16:12:18 +0100 |
commit | 28e3b328545529c19429ce88c7d1769e64e2de0f (patch) | |
tree | 3d7d85d7d4d1202199bad98df125f2af88b73c86 /modules/luci-base/luasrc/cbi | |
parent | dfba318140e1a84359e221b7a9154337595dbded (diff) |
treewide: unify mac address handling
Use the new luci.ip MAC address facilities to parse and verify MAC addresses
in a common way, instead of relying on various ad-hoc solutions.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/luasrc/cbi')
-rw-r--r-- | modules/luci-base/luasrc/cbi/datatypes.lua | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/modules/luci-base/luasrc/cbi/datatypes.lua b/modules/luci-base/luasrc/cbi/datatypes.lua index a7e02f350a..55cdf8a74b 100644 --- a/modules/luci-base/luasrc/cbi/datatypes.lua +++ b/modules/luci-base/luasrc/cbi/datatypes.lua @@ -196,23 +196,7 @@ function portrange(val) end function macaddr(val) - if val and val:match( - "^[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+:" .. - "[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+$" - ) then - local parts = util.split( val, ":" ) - - for i = 1,6 do - parts[i] = tonumber( parts[i], 16 ) - if parts[i] < 0 or parts[i] > 255 then - return false - end - end - - return true - end - - return false + return ip.checkmac(val) and true or false end function hostname(val) |