Globally reduce copyright headers
[project/luci.git] / applications / luci-app-qos / luasrc / model / cbi / qos / qos.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local wa = require "luci.tools.webadmin"
5 local fs = require "nixio.fs"
6
7 m = Map("qos", translate("Quality of Service"),
8         translate("With <abbr title=\"Quality of Service\">QoS</abbr> you " ..
9                 "can prioritize network traffic selected by addresses, " ..
10                 "ports or services."))
11
12 s = m:section(TypedSection, "interface", translate("Interfaces"))
13 s.addremove = true
14 s.anonymous = false
15
16 e = s:option(Flag, "enabled", translate("Enable"))
17 e.rmempty = false
18
19 c = s:option(ListValue, "classgroup", translate("Classification group"))
20 c:value("Default", translate("default"))
21 c.default = "Default"
22
23 s:option(Flag, "overhead", translate("Calculate overhead"))
24
25 s:option(Flag, "halfduplex", translate("Half-duplex"))
26
27 dl = s:option(Value, "download", translate("Download speed (kbit/s)"))
28 dl.datatype = "and(uinteger,min(1))"
29
30 ul = s:option(Value, "upload", translate("Upload speed (kbit/s)"))
31 ul.datatype = "and(uinteger,min(1))"
32
33 s = m:section(TypedSection, "classify", translate("Classification Rules"))
34 s.template = "cbi/tblsection"
35 s.anonymous = true
36 s.addremove = true
37 s.sortable  = true
38
39 t = s:option(ListValue, "target", translate("Target"))
40 t:value("Priority", translate("priority"))
41 t:value("Express", translate("express"))
42 t:value("Normal", translate("normal"))
43 t:value("Bulk", translate("low"))
44 t.default = "Normal"
45
46 srch = s:option(Value, "srchost", translate("Source host"))
47 srch.rmempty = true
48 srch:value("", translate("all"))
49 wa.cbi_add_knownips(srch)
50
51 dsth = s:option(Value, "dsthost", translate("Destination host"))
52 dsth.rmempty = true
53 dsth:value("", translate("all"))
54 wa.cbi_add_knownips(dsth)
55
56 l7 = s:option(ListValue, "layer7", translate("Service"))
57 l7.rmempty = true
58 l7:value("", translate("all"))
59
60 local pats = io.popen("find /etc/l7-protocols/ -type f -name '*.pat'")
61 if pats then
62         local l
63         while true do
64                 l = pats:read("*l")
65                 if not l then break end
66
67                 l = l:match("([^/]+)%.pat$")
68                 if l then
69                         l7:value(l)
70                 end
71         end
72         pats:close()
73 end
74
75 p = s:option(Value, "proto", translate("Protocol"))
76 p:value("", translate("all"))
77 p:value("tcp", "TCP")
78 p:value("udp", "UDP")
79 p:value("icmp", "ICMP")
80 p.rmempty = true
81
82 ports = s:option(Value, "ports", translate("Ports"))
83 ports.rmempty = true
84 ports:value("", translate("all"))
85
86 bytes = s:option(Value, "connbytes", translate("Number of bytes"))
87
88 comment = s:option(Value, "comment", translate("Comment"))
89
90 return m