luci-0.9: merge r6165
[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
15 local wa = require "luci.tools.webadmin"
16 local fs = require "nixio.fs"
17
18 m = Map("qos")
19
20 s = m:section(TypedSection, "interface", translate("interfaces"))
21 s.addremove = true
22 s.anonymous = true
23
24 e = s:option(Flag, "enabled", translate("enable"))
25 e.rmempty = false
26
27 c = s:option(ListValue, "classgroup")
28 c:value("Default", "standard")
29 c.default = "Default"
30
31 s:option(Flag, "overhead")
32
33 s:option(Flag, "halfduplex")
34
35 s:option(Value, "download", nil, "kb/s")
36
37 s:option(Value, "upload", nil, "kb/s")
38
39 s = m:section(TypedSection, "classify")
40 s.template = "cbi/tblsection"
41 s.anonymous = true
42 s.addremove = true
43
44 t = s:option(ListValue, "target")
45 t:value("Priority", translate("qos_priority"))
46 t:value("Express", translate("qos_express"))
47 t:value("Normal", translate("qos_normal"))
48 t:value("Bulk", translate("qos_bulk"))
49 t.default = "Normal"
50
51 srch = s:option(Value, "srchost")
52 srch.rmempty = true
53 srch:value("", translate("all"))
54 wa.cbi_add_knownips(srch)
55
56 dsth = s:option(Value, "dsthost")
57 dsth.rmempty = true
58 dsth:value("", translate("all"))
59 wa.cbi_add_knownips(dsth)
60
61 l7 = s:option(ListValue, "layer7", translate("service"))
62 l7.rmempty = true
63 l7:value("", translate("all"))
64 local pats = fs.dir("/etc/l7-protocols")
65 if pats then
66         for f in pats do
67                 if f:sub(-4) == ".pat" then
68                         l7:value(f:sub(1, #f-4))
69                 end
70         end
71 end
72
73 p = s:option(Value, "proto", translate("protocol"))
74 p:value("", translate("all"))
75 p:value("tcp", "TCP")
76 p:value("udp", "UDP")
77 p:value("icmp", "ICMP")
78 p.rmempty = true
79
80 ports = s:option(Value, "ports", translate("ports"))
81 ports.rmempty = true
82 ports:value("", translate("allf", translate("all")))
83
84 bytes = s:option(Value, "connbytes", translate("qos_connbytes"))
85
86 return m