6965078edf631de85d50df3136ad70bb58c66649
[project/luci.git] / applications / luci-app-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 dl = s:option(Value, "download", translate("Download speed (kbit/s)"))
39 dl.datatype = "and(uinteger,min(1))"
40
41 ul = s:option(Value, "upload", translate("Upload speed (kbit/s)"))
42 ul.datatype = "and(uinteger,min(1))"
43
44 s = m:section(TypedSection, "classify", translate("Classification Rules"))
45 s.template = "cbi/tblsection"
46 s.anonymous = true
47 s.addremove = true
48 s.sortable  = true
49
50 t = s:option(ListValue, "target", translate("Target"))
51 t:value("Priority", translate("priority"))
52 t:value("Express", translate("express"))
53 t:value("Normal", translate("normal"))
54 t:value("Bulk", translate("low"))
55 t.default = "Normal"
56
57 srch = s:option(Value, "srchost", translate("Source host"))
58 srch.rmempty = true
59 srch:value("", translate("all"))
60 wa.cbi_add_knownips(srch)
61
62 dsth = s:option(Value, "dsthost", translate("Destination host"))
63 dsth.rmempty = true
64 dsth:value("", translate("all"))
65 wa.cbi_add_knownips(dsth)
66
67 l7 = s:option(ListValue, "layer7", translate("Service"))
68 l7.rmempty = true
69 l7:value("", translate("all"))
70
71 local pats = io.popen("find /etc/l7-protocols/ -type f -name '*.pat'")
72 if pats then
73         local l
74         while true do
75                 l = pats:read("*l")
76                 if not l then break end
77
78                 l = l:match("([^/]+)%.pat$")
79                 if l then
80                         l7:value(l)
81                 end
82         end
83         pats:close()
84 end
85
86 p = s:option(Value, "proto", translate("Protocol"))
87 p:value("", translate("all"))
88 p:value("tcp", "TCP")
89 p:value("udp", "UDP")
90 p:value("icmp", "ICMP")
91 p.rmempty = true
92
93 ports = s:option(Value, "ports", translate("Ports"))
94 ports.rmempty = true
95 ports:value("", translate("all"))
96
97 bytes = s:option(Value, "connbytes", translate("Number of bytes"))
98
99 comment = s:option(Value, "comment", translate("Comment"))
100
101 return m