Add connbytes support to QoS
[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 require("luci.tools.webadmin")
15 m = Map("qos")
16
17 s = m:section(TypedSection, "interface", translate("interfaces"))
18 s.addremove = true
19
20 s:option(Flag, "enabled", translate("enable"))
21
22 c = s:option(ListValue, "classgroup")
23 c:value("Default", "standard")
24 c.default = "Default"
25
26 s:option(Flag, "overhead")
27
28 s:option(Value, "download", nil, "kb/s")
29
30 s:option(Value, "upload", nil, "kb/s")
31
32 s = m:section(TypedSection, "classify")
33 s.template = "cbi/tblsection"
34 s.anonymous = true
35 s.addremove = true
36
37 t = s:option(ListValue, "target")
38 t:value("Priority", translate("qos_priority"))
39 t:value("Express", translate("qos_express"))
40 t:value("Normal", translate("qos_normal"))
41 t:value("Bulk", translate("qos_bulk"))
42 t.default = "Normal"
43
44 srch = s:option(Value, "srchost")
45 srch.rmempty = true
46 srch:value("", translate("all"))
47 luci.tools.webadmin.cbi_add_knownips(srch)
48
49 dsth = s:option(Value, "dsthost")
50 dsth.rmempty = true
51 dsth:value("", translate("all"))
52 luci.tools.webadmin.cbi_add_knownips(dsth)
53
54 l7 = s:option(ListValue, "layer7", translate("service"))
55 l7.rmempty = true
56 l7:value("", translate("all"))
57 local pats = luci.fs.dir("/etc/l7-protocols")
58 if pats then
59 for i,f in ipairs(pats) do
60 if f:sub(-4) == ".pat" then
61 l7:value(f:sub(1, #f-4))
62 end
63 end
64 end
65
66 p2p = s:option(ListValue, "ipp2p", "P2P")
67 p2p:value("", "-")
68 p2p:value("all", translate("all"))
69 p2p:value("bit", "BIT")
70 p2p:value("dc", "DC")
71 p2p:value("edk", "EDK")
72 p2p:value("gnu", "GNU")
73 p2p:value("kazaa", "KAZ")
74 p2p.rmempty = true
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("allf", translate("all")))
86
87 bytes = s:option(Value, "connbytes", translate("qos_connbytes"))
88
89 return m