libs/sys: fix checking for empty table
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / conntrack.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15
16 f = SimpleForm("conntrack", translate("a_n_conntrack"), translate("a_n_conntrack_desc"))
17 f.reset = false
18 f.submit = false
19
20 t = f:section(Table, luci.sys.net.arptable(), "ARP")
21 t:option(DummyValue, "IP address", translate("ipaddress"))
22 t:option(DummyValue, "HW address", translate("macaddress"))
23 t:option(DummyValue, "Device", translate("interface"))
24
25 t = f:section(Table, luci.sys.net.conntrack() or {}, translate("a_n_conntrack"))
26 l3 = t:option(DummyValue, "layer3", translate("network"))
27 function l3.cfgvalue(self, ...)
28         return DummyValue.cfgvalue(self, ...):upper()
29 end
30
31
32 l4 = t:option(DummyValue, "layer4", translate("protocol"))
33 function l4.cfgvalue(self, ...)
34         return DummyValue.cfgvalue(self, ...):upper()
35 end
36
37 s = t:option(DummyValue, "src", translate("source"))
38 function s.cfgvalue(self, section)
39         return "%s:%s" % { self.map:get(section, "src"),
40                                          self.map:get(section, "sport") or "*" }
41 end
42
43 d = t:option(DummyValue, "dst", translate("destination"))
44 function d.cfgvalue(self, section)
45         return "%s:%s" % { self.map:get(section, "dst"),
46                                          self.map:get(section, "dport") or "*" }
47 end
48
49 return f