+defaults = utl.class()
+function defaults.__init__(self)
+ uci_r:foreach("firewall", "defaults",
+ function(s)
+ self.sid = s['.name']
+ return false
+ end)
+
+ self.sid = self.sid or uci_r:section("firewall", "defaults", nil, { })
+end
+
+function defaults.get(self, opt)
+ return _get("firewall", self.sid, opt)
+end
+
+function defaults.set(self, opt, val)
+ return _set("firewall", self.sid, opt, val)
+end
+
+function defaults.syn_flood(self)
+ return (self:get("syn_flood") == "1")
+end
+
+function defaults.drop_invalid(self)
+ return (self:get("drop_invalid") == "1")
+end
+
+function defaults.input(self)
+ return self:get("input") or "DROP"
+end
+
+function defaults.forward(self)
+ return self:get("forward") or "DROP"
+end
+
+function defaults.output(self)
+ return self:get("output") or "DROP"
+end
+
+
+zone = utl.class()
+function zone.__init__(self, z)
+ if uci_r:get("firewall", z) == "zone" then
+ self.sid = z
+ self.data = uci_r:get_all("firewall", z)
+ else
+ uci_r:foreach("firewall", "zone",
+ function(s)
+ if s.name == z then
+ self.sid = s['.name']
+ self.data = s
+ return false
+ end
+ end)
+ end
+end
+
+function zone.get(self, opt)
+ return _get("firewall", self.sid, opt)
+end
+
+function zone.set(self, opt, val)
+ return _set("firewall", self.sid, opt, val)
+end
+
+function zone.masq(self)
+ return (self:get("masq") == "1")
+end