3d0cd9e5bd1fa50f2c0b51bd5c8be0b40d8d8dcc
[project/luci.git] / applications / luci-fw / luasrc / model / cbi / luci_fw / firewall.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 m = Map("firewall", translate("fw_rules"), translate("fw_rules1"))
15
16 s = m:section(TypedSection, "rule", "")
17 s.addremove = true
18 s.anonymous = true
19
20 iface = s:option(ListValue, "src")
21 iface:value("")
22 iface.rmempty = true
23
24 oface = s:option(ListValue, "dest")
25 oface.optional = true
26
27 luci.model.uci.cursor():foreach("firewall", "zone",
28 function (section)
29 iface:value(section.name)
30 oface:value(section.name)
31 end)
32
33 proto = s:option(ListValue, "proto", translate("protocol"))
34 proto.optional = true
35 proto:value("")
36 proto:value("tcpudp", "TCP+UDP")
37 proto:value("tcp", "TCP")
38 proto:value("udp", "UDP")
39 proto:value("icmp", "ICMP")
40
41 s:option(Value, "src_ip").optional = true
42 s:option(Value, "dest_ip").optional = true
43 s:option(Value, "src_mac").optional = true
44
45 sport = s:option(Value, "src_port")
46 sport.optional = true
47 sport:depends("proto", "tcp")
48 sport:depends("proto", "udp")
49
50 dport = s:option(Value, "dest_port")
51 dport.optional = true
52 dport:depends("proto", "tcp")
53 dport:depends("proto", "udp")
54
55 jump = s:option(ListValue, "target")
56 jump.rmempty = true
57 jump:value("DROP", translate("fw_drop"))
58 jump:value("ACCEPT", translate("fw_accept"))
59 jump:value("REJECT", translate("fw_reject"))
60
61
62 return m