+function cidr4(val)
+ local ip, mask = val:match("^([^/]+)/([^/]+)$")
+
+ return ip4addr(ip) and ip4prefix(mask)
+end
+
+function cidr6(val)
+ local ip, mask = val:match("^([^/]+)/([^/]+)$")
+
+ return ip6addr(ip) and ip6prefix(mask)
+end
+
+function ipnet4(val)
+ local ip, mask = val:match("^([^/]+)/([^/]+)$")
+
+ return ip4addr(ip) and ip4addr(mask)
+end
+
+function ipnet6(val)
+ local ip, mask = val:match("^([^/]+)/([^/]+)$")
+
+ return ip6addr(ip) and ip6addr(mask)
+end
+
+function ipmask(val)
+ return ipmask4(val) or ipmask6(val)
+end
+
+function ipmask4(val)
+ return cidr4(val) or ipnet4(val) or ip4addr(val)
+end
+
+function ipmask6(val)
+ return cidr6(val) or ipnet6(val) or ip6addr(val)
+end
+
+function ip6hostid(val)
+ if val == "eui64" or val == "random" then
+ return true
+ else
+ local addr = ip.IPv6(val)
+ if addr and addr:prefix() == 128 and addr:lower("::1:0:0:0:0") then
+ return true
+ end
+ end
+
+ return false
+end
+