42be400c4e6dfce5d606070361260abd88fd135b
[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.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
41 proto = s:option(ListValue, "proto", translate("protocol"))
42 proto.optional = true
43 proto:value("")
44 proto:value("tcp", "TCP")
45 proto:value("udp", "UDP")
46
47 dport = s:option(Value, "src_dport")
48 dport.size = 5
49 dport.optional = true
50 dport:depends("proto", "tcp")
51 dport:depends("proto", "udp")
52
53 to = s:option(Value, "dest_ip")
54 for i, dataset in ipairs(luci.sys.net.arptable()) do
55         to:value(dataset["IP address"])
56 end
57
58 toport = s:option(Value, "dest_port")
59 toport.optional = true
60 toport.size = 5
61
62 return m