X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=modules%2Fadmin-full%2Fluasrc%2Fmodel%2Fcbi%2Fadmin_network%2Fwifi_add.lua;h=5b646d9a31ba26b94309d6cc25ed4bc19526dbc6;hb=c9f7282d982f10e54fbc083c20e45e03052598fe;hp=3d0d7550eb882dc0a4123db7065c21aceda7c137;hpb=1aa676d501f806109d626665cd82390c175fd029;p=project%2Fluci.git diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua index 3d0d7550e..5b646d9a3 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua @@ -104,9 +104,6 @@ end function newnet.parse(self, section) local net, zone - local value = self:formvalue(section) - net = nw:add_network(value, { proto = "dhcp" }) - if has_firewall then local zval = fwzone:formvalue(section) zone = fw:get_zone(zval) @@ -119,41 +116,46 @@ function newnet.parse(self, section) end end - if not net then - self.error = { [section] = "missing" } - else - local wdev = nw:get_wifidev(m.hidden.device) + local wdev = nw:get_wifidev(m.hidden.device) - wdev:set("disabled", false) - wdev:set("channel", m.hidden.channel) + wdev:set("disabled", false) + wdev:set("channel", m.hidden.channel) - if replace:formvalue(section) then - local n - for _, n in ipairs(wdev:get_wifinets()) do - wdev:del_wifinet(n) - end + if replace:formvalue(section) then + local n + for _, n in ipairs(wdev:get_wifinets()) do + wdev:del_wifinet(n) end + end - local wconf = { - device = m.hidden.device, - ssid = m.hidden.join, - mode = (m.hidden.mode == "Ad-Hoc" and "adhoc" or "sta"), - network = net:name() - } - - if m.hidden.wep == "1" then - wconf.encryption = "wep" - wconf.key = key and key:formvalue(section) or "" - elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then - wconf.encryption = (tonumber(m.hidden.wpa_version) or 0) >= 2 and "psk2" or "psk" - wconf.key = key and key:formvalue(section) or "" - else - wconf.encryption = "none" - end + local wconf = { + device = m.hidden.device, + ssid = m.hidden.join, + mode = (m.hidden.mode == "Ad-Hoc" and "adhoc" or "sta") + } + + if m.hidden.wep == "1" then + wconf.encryption = "wep-open" + wconf.key = "1" + wconf.key1 = key and key:formvalue(section) or "" + elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then + wconf.encryption = (tonumber(m.hidden.wpa_version) or 0) >= 2 and "psk2" or "psk" + wconf.key = key and key:formvalue(section) or "" + else + wconf.encryption = "none" + end - if wconf.mode == "adhoc" then - wconf.bssid = m.hidden.bssid - end + if wconf.mode == "adhoc" or wconf.mode == "sta" then + wconf.bssid = m.hidden.bssid + end + + local value = self:formvalue(section) + net = nw:add_network(value, { proto = "dhcp" }) + + if not net then + self.error = { [section] = "missing" } + else + wconf.network = net:name() local wnet = wdev:add_wifinet(wconf) if wnet then @@ -166,9 +168,7 @@ function newnet.parse(self, section) uci:save("network") uci:save("firewall") - luci.http.redirect(luci.dispatcher.build_url( - "admin/network/wireless", wdev:name(), wnet:ifname() - )) + luci.http.redirect(wnet:adminlink()) end end end