Move mtu_fix to the right place (fixes #94)
[project/luci.git] / applications / luci-fw / luasrc / model / cbi / luci_fw / zones.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 nw = require "luci.model.network"
16 local fw = require "luci.model.firewall"
17
18 require("luci.tools.webadmin")
19 m = Map("firewall", translate("Firewall"), translate("The firewall creates zones over your network interfaces to control network traffic flow."))
20
21 fw.init(m.uci)
22 nw.init(m.uci)
23
24 s = m:section(TypedSection, "defaults")
25 s.anonymous = true
26 s.addremove = false
27
28 s:option(Flag, "syn_flood")
29
30 local di = s:option(Flag, "drop_invalid", translate("Drop invalid packets"))
31 di.rmempty = false
32 function di.cfgvalue(...)
33         return AbstractValue.cfgvalue(...) or "1"
34 end
35
36 p = {}
37 p[1] = s:option(ListValue, "input")
38 p[2] = s:option(ListValue, "output")
39 p[3] = s:option(ListValue, "forward")
40
41 for i, v in ipairs(p) do
42         v:value("REJECT", translate("reject"))
43         v:value("DROP", translate("drop"))
44         v:value("ACCEPT", translate("accept"))
45 end
46
47
48 s = m:section(TypedSection, "zone", translate("Zones"))
49 s.template = "cbi/tblsection"
50 s.anonymous = true
51 s.addremove = true
52
53 name = s:option(Value, "name", translate("Name"))
54 name.size = 8
55
56 p = {}
57 p[1] = s:option(ListValue, "input")
58 p[2] = s:option(ListValue, "output")
59 p[3] = s:option(ListValue, "forward")
60
61 for i, v in ipairs(p) do
62         v:value("REJECT", translate("reject"))
63         v:value("DROP", translate("drop"))
64         v:value("ACCEPT", translate("accept"))
65 end
66
67 s:option(Flag, "masq")
68 s:option(Flag, "mtu_fix", translate("MSS Clamping"))
69
70 net = s:option(MultiValue, "network")
71 net.template = "cbi/network_netlist"
72 net.widget = "checkbox"
73 net.rmempty = true
74 luci.tools.webadmin.cbi_add_networks(net)
75
76 function net.cfgvalue(self, section)
77         local value = MultiValue.cfgvalue(self, section)
78         return value or name:cfgvalue(section)
79 end
80
81 return m