Sync with OpenWrt
[project/luci.git] / applications / luci-qos / luasrc / model / cbi / qos / qos.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14 require("luci.tools.webadmin")
15 m = Map("qos")
16
17 s = m:section(TypedSection, "interface", translate("interfaces"))
18 s.addremove = true
19
20 s:option(Flag, "enabled", translate("enable"))
21
22 c = s:option(ListValue, "classgroup")
23 c:value("Default", "standard")
24 c.default = "Default"
25
26 s:option(Flag, "overhead")
27
28 s:option(Value, "download", nil, "kb/s")
29
30 s:option(Value, "upload", nil, "kb/s")
31
32 s = m:section(TypedSection, "classify")
33 s.template = "cbi/tblsection"
34 s.anonymous = true
35 s.addremove = true
36
37 t = s:option(ListValue, "target")
38 t:value("Priority", translate("qos_priority"))
39 t:value("Express", translate("qos_express"))
40 t:value("Normal", translate("qos_normal"))
41 t:value("Bulk", translate("qos_bulk"))
42 t.default = "Normal"
43
44 srch = s:option(Value, "srchost")
45 srch.rmempty = true
46 srch:value("", translate("all"))
47 luci.tools.webadmin.cbi_add_knownips(srch)
48
49 dsth = s:option(Value, "dsthost")
50 dsth.rmempty = true
51 dsth:value("", translate("all"))
52 luci.tools.webadmin.cbi_add_knownips(dsth)
53
54 l7 = s:option(ListValue, "layer7", translate("service"))
55 l7.rmempty = true
56 l7:value("", translate("all"))
57 local pats = luci.fs.dir("/etc/l7-protocols")
58 if pats then
59         for i,f in ipairs(pats) do
60                 if f:sub(-4) == ".pat" then
61                         l7:value(f:sub(1, #f-4))
62                 end
63         end
64 end
65
66 p = s:option(Value, "proto", translate("protocol"))
67 p:value("", translate("all"))
68 p:value("tcp", "TCP")
69 p:value("udp", "UDP")
70 p:value("icmp", "ICMP")
71 p.rmempty = true
72
73 ports = s:option(Value, "ports", translate("ports"))
74 ports.rmempty = true
75 ports:value("", translate("allf", translate("all")))
76
77 bytes = s:option(Value, "connbytes", translate("qos_connbytes"))
78
79 return m