convert luci.fs users to nixio.fs api
[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")
19
20 s = m:section(TypedSection, "interface", translate("interfaces"))
21 s.addremove = true
22
23 s:option(Flag, "enabled", translate("enable"))
24
25 c = s:option(ListValue, "classgroup")
26 c:value("Default", "standard")
27 c.default = "Default"
28
29 s:option(Flag, "overhead")
30
31 s:option(Flag, "halfduplex")
32
33 s:option(Value, "download", nil, "kb/s")
34
35 s:option(Value, "upload", nil, "kb/s")
36
37 s = m:section(TypedSection, "classify")
38 s.template = "cbi/tblsection"
39 s.anonymous = true
40 s.addremove = true
41
42 t = s:option(ListValue, "target")
43 t:value("Priority", translate("qos_priority"))
44 t:value("Express", translate("qos_express"))
45 t:value("Normal", translate("qos_normal"))
46 t:value("Bulk", translate("qos_bulk"))
47 t.default = "Normal"
48
49 srch = s:option(Value, "srchost")
50 srch.rmempty = true
51 srch:value("", translate("all"))
52 wa.cbi_add_knownips(srch)
53
54 dsth = s:option(Value, "dsthost")
55 dsth.rmempty = true
56 dsth:value("", translate("all"))
57 wa.cbi_add_knownips(dsth)
58
59 l7 = s:option(ListValue, "layer7", translate("service"))
60 l7.rmempty = true
61 l7:value("", translate("all"))
62 local pats = fs.dir("/etc/l7-protocols")
63 if pats then
64         for f in pats do
65                 if f:sub(-4) == ".pat" then
66                         l7:value(f:sub(1, #f-4))
67                 end
68         end
69 end
70
71 p = s:option(Value, "proto", translate("protocol"))
72 p:value("", translate("all"))
73 p:value("tcp", "TCP")
74 p:value("udp", "UDP")
75 p:value("icmp", "ICMP")
76 p.rmempty = true
77
78 ports = s:option(Value, "ports", translate("ports"))
79 ports.rmempty = true
80 ports:value("", translate("allf", translate("all")))
81
82 bytes = s:option(Value, "connbytes", translate("qos_connbytes"))
83
84 return m