1 -- Copyright 2017 Dirk Brenken (dev@brenken.org)
2 -- This is free software, licensed under the Apache License, Version 2.0
4 local nw = require("luci.model.network").init()
5 local fw = require("luci.model.firewall").init()
6 local util = require("luci.util")
7 local uci = require("luci.model.uci").cursor()
9 m = SimpleForm("network", translate("Interface Setup"),
10 translate("Automatically create a new wireless wan interface, configure it to use dhcp and " ..
11 "add it to the wan zone of the firewall. This step has only to be done once."))
14 iface = m:field(Value, "netname", translate("Name of the new wireless wan interface"),
15 translate("The allowed characters are: <code>A-Z</code>, <code>a-z</code>, " ..
16 "<code>0-9</code> and <code>_</code> (3-15 characters)."))
17 iface.default = "wwan"
18 iface.datatype = "and(uciname,minlength(3),maxlength(15))"
20 function iface.validate(self, value, section)
21 local value = iface:formvalue(section)
22 local name = uci.get("network", value)
24 iface:add_error(section, translate("The given network interface name already exist"))
26 iface.datatype = false
27 iface.default = iface.disabled
28 f = m:field(DummyValue, "textfield", " ", translatef("Direct Link: "
30 .. "Wireless Setup</a>", luci.dispatcher.build_url("admin/network/wireless")))
31 f.default = translatef("Network Interface '%s' created successfully." ..
32 " Feel free to scan & add new stations via standard wireless setup.", value)
38 function iface.write(self, section, value)
39 local name = iface:formvalue(section)
41 local net = nw:add_network(name, { proto = "dhcp" })
45 local zone = fw:get_zone_by_network("wan")
47 zone:add_network(name)