af481fd3aa8410bfa41fe6266f69a3841b21281d
[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", translate("Quality of Service"),
19         translate("With <abbr title=\"Quality of Service\">QoS</abbr> you " ..
20                 "can prioritize network traffic selected by addresses, " ..
21                 "ports or services."))
22
23 s = m:section(TypedSection, "interface", translate("Interfaces"))
24 s.addremove = true
25 s.anonymous = false
26
27 e = s:option(Flag, "enabled", translate("Enable"))
28 e.rmempty = false
29
30 c = s:option(ListValue, "classgroup", translate("Classification group"))
31 c:value("Default", translate("default"))
32 c.default = "Default"
33
34 s:option(Flag, "overhead", translate("Calculate overhead"))
35
36 s:option(Flag, "halfduplex", translate("Half-duplex"))
37
38 s:option(Value, "download", translate("Download speed (kb/s)"))
39
40 s:option(Value, "upload", translate("Upload speed (kb/s)"))
41
42 s = m:section(TypedSection, "classify", translate("Classification Rules"))
43 s.template = "cbi/tblsection"
44 s.anonymous = true
45 s.addremove = true
46
47 t = s:option(ListValue, "target", translate("Target"))
48 t:value("Priority", translate("priority"))
49 t:value("Express", translate("express"))
50 t:value("Normal", translate("normal"))
51 t:value("Bulk", translate("low"))
52 t.default = "Normal"
53
54 srch = s:option(Value, "srchost", translate("Source host"))
55 srch.rmempty = true
56 srch:value("", translate("all"))
57 wa.cbi_add_knownips(srch)
58
59 dsth = s:option(Value, "dsthost", translate("Destination host"))
60 dsth.rmempty = true
61 dsth:value("", translate("all"))
62 wa.cbi_add_knownips(dsth)
63
64 l7 = s:option(ListValue, "layer7", translate("Service"))
65 l7.rmempty = true
66 l7:value("", translate("all"))
67 local pats = fs.dir("/etc/l7-protocols")
68 if pats then
69         for f in pats do
70                 if f:sub(-4) == ".pat" then
71                         l7:value(f:sub(1, #f-4))
72                 end
73         end
74 end
75
76 p = s:option(Value, "proto", translate("Protocol"))
77 p:value("", translate("all"))
78 p:value("tcp", "TCP")
79 p:value("udp", "UDP")
80 p:value("icmp", "ICMP")
81 p.rmempty = true
82
83 ports = s:option(Value, "ports", translate("Ports"))
84 ports.rmempty = true
85 ports:value("", translate("all"))
86
87 bytes = s:option(Value, "connbytes", translate("Number of bytes"))
88
89 return m