Made distinction between INPUT and FORWARD rules less ambiguous
[project/luci.git] / applications / luci-fw / luasrc / model / cbi / luci_fw / trule.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 arg[1] = arg[1] or ""
15 m = Map("firewall", translate("firewall_rule"), translate("firewall_rule_desc"))
16
17 s = m:section(NamedSection, arg[1], "rule", "")
18 s.anonymous = true
19
20 back = s:option(DummyValue, "_overview", translate("overview"))
21 back.value = ""
22 back.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "traffic")
23
24
25 name = s:option(Value, "_name", translate("name")..translate("cbi_optional"))
26 name.rmempty = true
27
28 iface = s:option(ListValue, "src", translate("fw_src"))
29 iface.rmempty = true
30
31 oface = s:option(ListValue, "dest", translate("fw_dest"))
32 oface:value("", translate("device", "device"))
33 oface.rmempty = true
34
35 luci.model.uci.cursor():foreach("firewall", "zone",
36         function (section)
37                 iface:value(section.name)
38                 oface:value(section.name)
39         end)
40
41 proto = s:option(ListValue, "proto", translate("protocol"))
42 proto.optional = true
43 proto:value("")
44 proto:value("tcpudp", "TCP+UDP")
45 proto:value("tcp", "TCP")
46 proto:value("udp", "UDP")
47 proto:value("icmp", "ICMP")
48
49 s:option(Value, "src_ip", translate("firewall_rule_srcip")).optional = true
50 s:option(Value, "dest_ip", translate("firewall_rule_destip")).optional = true
51 s:option(Value, "src_mac", translate("firewall_rule_srcmac")).optional = true
52
53 sport = s:option(Value, "src_port", translate("firewall_rule_srcport"))
54 sport.optional = true
55 sport:depends("proto", "tcp")
56 sport:depends("proto", "udp")
57 sport:depends("proto", "tcpudp")
58
59 dport = s:option(Value, "dest_port", translate("firewall_rule_destport"))
60 dport.optional = true
61 dport:depends("proto", "tcp")
62 dport:depends("proto", "udp")
63 dport:depends("proto", "tcpudp")
64
65 jump = s:option(ListValue, "target", translate("firewall_rule_target"))
66 jump.rmempty = true
67 jump.default = "ACCEPT"
68 jump:value("DROP", translate("fw_drop"))
69 jump:value("ACCEPT", translate("fw_accept"))
70 jump:value("REJECT", translate("fw_reject"))
71
72
73 return m