From 28e3b328545529c19429ce88c7d1769e64e2de0f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 12 Mar 2018 16:12:18 +0100 Subject: 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 --- modules/luci-base/luasrc/cbi/datatypes.lua | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'modules/luci-base/luasrc/cbi') 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) -- cgit v1.2.3