Redesigned firewall configuration
[project/luci.git] / applications / luci-fw / luasrc / model / cbi / luci_fw / rrule.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.sys")
15 arg[1] = arg[1] or ""
16
17 m = Map("firewall", translate("fw_redirect"), translate("fw_redirect_desc"))
18
19
20 s = m:section(NamedSection, arg[1], "redirect", "")
21 s.anonymous = true
22
23 name = s:option(Value, "_name", translate("name"))
24 name.rmempty = true
25 name.size = 10
26
27 iface = s:option(ListValue, "src", translate("fw_zone"))
28 iface.default = "wan"
29 luci.model.uci.cursor():foreach("firewall", "zone",
30         function (section)
31                 iface:value(section.name)
32         end)
33         
34 s:option(Value, "src_ip", translate("firewall_redirect_srcip")).optional = true
35 s:option(Value, "src_mac", translate("firewall_redirect_srcmac")).optional = true
36
37 sport = s:option(Value, "src_port", translate("firewall_redirect_srcport"))
38 sport.optional = true
39 sport:depends("proto", "tcp")
40 sport:depends("proto", "udp")
41 sport:depends("proto", "tcpudp")
42
43 proto = s:option(ListValue, "proto", translate("protocol"))
44 proto.optional = true
45 proto:value("")
46 proto:value("tcp", "TCP")
47 proto:value("udp", "UDP")
48 proto:value("tcpudp", "TCP+UDP")
49
50 dport = s:option(Value, "src_dport", translate("firewall_redirect_srcdport"))
51 dport.size = 5
52 dport.optional = true
53 dport:depends("proto", "tcp")
54 dport:depends("proto", "udp")
55 dport:depends("proto", "tcpudp")
56
57 to = s:option(Value, "dest_ip", translate("firewall_redirect_destip"))
58 for i, dataset in ipairs(luci.sys.net.arptable()) do
59         to:value(dataset["IP address"])
60 end
61
62 toport = s:option(Value, "dest_port", translate("firewall_redirect_destport"))
63 toport.optional = true
64 toport.size = 5
65
66 return m