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