6171dfaa717931e0346bb52a34400c71c19d3971
[project/luci.git] / modules / niu / luasrc / model / cbi / niu / traffic / qos1.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15
16 local sys = require "luci.sys"
17 local fs = require "nixio.fs"
18
19 m = Map("qos", translate("Manage Prioritization (QoS)"), translate([[Different
20 kinds of network traffic usually have different transmission requirements.
21 For example the important factor for a large HTTP-download is bandwith whereas
22 VoIP has a large focus on low packet latency. Prioritization takes these quality
23 of service factors into account and optimizes priorities to allow reasonable 
24 performance for time critical services.]]))
25
26 s = m:section(NamedSection, "wan", "interface", translate("General Settings"),
27 translate([[For QoS to work correctly you need to provide the upload and
28 download speed of your internet connection. Values are in kilobits per second.
29 For comparison a standard consumer ADSL connection has between 1000 and 25000
30 kbps as donwload speed and between 128 and 1000 kbps upload speed.]]))
31 s.addremove = false
32
33 local en = s:option(ListValue, "enabled", translate("Prioritization"))
34 en:value("1", "Enable Quality of Service")
35 en:value("0", "Disable")
36
37 local dl = s:option(Value, "download", translate("Maximum Download Speed"), "kbps")
38 dl:depends("enabled", "1")
39
40 local ul = s:option(Value, "upload", translate("Maximum Upload Speed"), "kbps")
41 ul:depends("enabled", "1")
42
43 s = m:section(TypedSection, "classify", translate("Finetuning"), translate([[
44 The QoS application provides different useful default prioritization rules not
45 listed here that cover many common use-cases. You however can add custom rules
46 to finetune the prioritization process.]]))
47 s.template = "cbi/tblsection"
48
49 s.anonymous = true
50 s.addremove = true
51
52 n = s:option(Value, "_name", translate("Name"), translate("optional"))
53
54 srch = s:option(Value, "srchost", translate("Local IP-Address"))
55 srch.rmempty = true
56 srch:value("", translate("all"))
57 for i, dataset in ipairs(sys.net.arptable()) do
58         srch:value(dataset["IP address"])
59 end
60
61 p = s:option(ListValue, "proto", translate("Protocol"))
62 p:value("", translate("all"))
63 p:value("tcp", "TCP")
64 p:value("udp", "UDP")
65 p.rmempty = true
66
67 ports = s:option(Value, "ports", translate("Ports"))
68 ports.rmempty = true
69 ports:value("", translate("any"))
70
71 if fs.access("/etc/l7-protocols") then
72         l7 = s:option(ListValue, "layer7", translate("Service"))
73         l7.rmempty = true
74         l7:value("", translate("all"))
75         for f in fs.glob("/etc/l7-protocols/*.pat") do
76                 l7:value(f:sub(19, #f-4))
77         end
78 end
79
80 s:option(Value, "connbytes", translate("Bytes sent"), translate("from[-to]"))
81
82 t = s:option(ListValue, "target", translate("Priority"))
83 t:value("Priority", translate("Highest"))
84 t:value("Express", translate("High"))
85 t:value("Normal", translate("Normal"))
86 t:value("Bulk", translate("Low"))
87 t.default = "Normal"
88
89 return m