summaryrefslogtreecommitdiffhomepage
path: root/libs/uvl/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-09-04 23:39:55 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-09-04 23:39:55 +0000
commit35a529a5c56df3dbcd105f691d164f4f85283611 (patch)
treec54370257557c67f9327944bb06a122a34a5d6a8 /libs/uvl/luasrc
parent76145b3e254047aab2a526aa26120025289157c8 (diff)
* luci/libs/uvl:
- implement port and portrange datatypes - fix datatype of port ranges in firewall scheme
Diffstat (limited to 'libs/uvl/luasrc')
-rw-r--r--libs/uvl/luasrc/uvl/datatypes.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/libs/uvl/luasrc/uvl/datatypes.lua b/libs/uvl/luasrc/uvl/datatypes.lua
index 60377e289..e6a4c1688 100644
--- a/libs/uvl/luasrc/uvl/datatypes.lua
+++ b/libs/uvl/luasrc/uvl/datatypes.lua
@@ -83,6 +83,20 @@ function ip6prefix( val )
return ( val and val >= 0 and val <= 128 )
end
+function port( val )
+ val = tonumber(val)
+ return ( val and val >= 1 and val <= 65535 )
+end
+
+function portrange( val )
+ local p1, p2 = val:match("^(%d+)%-(%d+)$")
+ if p1 and p2 and port(p1) and port(p2) then
+ return true
+ else
+ return port(val)
+ end
+end
+
function macaddr( val )
if val and val:match(
"^[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+:" ..