22dfbea5ff729e9b5ab76904545ed5c5f0e113b8
[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(Flag, "halfduplex")
29
30 s:option(Value, "download", nil, "kb/s")
31
32 s:option(Value, "upload", nil, "kb/s")
33
34 s = m:section(TypedSection, "classify")
35 s.template = "cbi/tblsection"
36 s.anonymous = true
37 s.addremove = true
38
39 t = s:option(ListValue, "target")
40 t:value("Priority", translate("qos_priority"))
41 t:value("Express", translate("qos_express"))
42 t:value("Normal", translate("qos_normal"))
43 t:value("Bulk", translate("qos_bulk"))
44 t.default = "Normal"
45
46 srch = s:option(Value, "srchost")
47 srch.rmempty = true
48 srch:value("", translate("all"))
49 luci.tools.webadmin.cbi_add_knownips(srch)
50
51 dsth = s:option(Value, "dsthost")
52 dsth.rmempty = true
53 dsth:value("", translate("all"))
54 luci.tools.webadmin.cbi_add_knownips(dsth)
55
56 l7 = s:option(ListValue, "layer7", translate("service"))
57 l7.rmempty = true
58 l7:value("", translate("all"))
59 local pats = luci.fs.dir("/etc/l7-protocols")
60 if pats then
61         for i,f in ipairs(pats) do
62                 if f:sub(-4) == ".pat" then
63                         l7:value(f:sub(1, #f-4))
64                 end
65         end
66 end
67
68 p = s:option(Value, "proto", translate("protocol"))
69 p:value("", translate("all"))
70 p:value("tcp", "TCP")
71 p:value("udp", "UDP")
72 p:value("icmp", "ICMP")
73 p.rmempty = true
74
75 ports = s:option(Value, "ports", translate("ports"))
76 ports.rmempty = true
77 ports:value("", translate("allf", translate("all")))
78
79 bytes = s:option(Value, "connbytes", translate("qos_connbytes"))
80
81 return m