2 LuCI - Lua Configuration Interface
3 Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
17 local sys = require "luci.sys"
18 local utl = require "luci.util"
19 local uci = require "luci.model.uci".cursor_state()
22 uci:foreach("network", "interface", function(i)
23 if i.ifname ~= "lo" then
24 ifaces[#ifaces+1] = { i['.name'], i.ifname, i.ipaddr }
28 local dev = luci.http.formvalue("device")
29 local iw = luci.sys.wifi.getiwinfo(dev)
33 if iwinfo.type(dev) == "broadcom" and not nixio.fs.access("/usr/sbin/nas") then
34 requirement = luci.i18n.translatef("You need to install the <a href='%s'>Broadcom <em>nas</em> supplicant</a> to use WPA!"
35 % luci.dispatcher.build_url("admin/system/packages?url=nas&submit=1"))
36 elseif not nixio.fs.access("/usr/sbin/wpa_supplicant") then
37 requirement = luci.i18n.translatef("You need to install <a href='%s'><em>wpa-supplicant</em></a> to use WPA!"
38 % luci.dispatcher.build_url("admin/system/packages?url=wpa-supplicant&submit=1"))
45 <h2><a id="content" name="content"><%:Join Network%></a></h2>
47 <form method="post" action="<%=REQUEST_URI%>">
49 <div class="cbi-map-descr">
50 <%=luci.i18n.translatef("You are about to join the wireless network <em><strong>%s</strong></em>. " ..
51 "In order to complete the process, you need to provide some additional details.",
52 utl.pcdata(luci.http.formvalue("join") or "(hidden)")
56 <fieldset class="cbi-section">
57 <input type="hidden" name="confirm" value="1" />
58 <input type="hidden" name="join" value="<%=utl.pcdata(luci.http.formvalue("join"))%>" />
59 <input type="hidden" name="device" value="<%=utl.pcdata(luci.http.formvalue("device"))%>" />
60 <input type="hidden" name="mode" value="<%=luci.http.formvalue("mode")%>" />
61 <input type="hidden" name="bssid" value="<%=luci.http.formvalue("bssid")%>" />
62 <input type="hidden" name="channel" value="<%=luci.http.formvalue("channel")%>" />
63 <input type="hidden" name="wep" value="<%=luci.http.formvalue("wep")%>" />
64 <input type="hidden" name="wpa_version" value="<%=luci.http.formvalue("wpa_version")%>" />
66 <% if luci.http.formvalue("wep") == "1" then %>
67 <label for="pw_key">WEP passphrase</label><br />
68 <input class="cbi-input-password" type="password" name="key" id="pw_key" />
70 <% elseif tonumber(luci.http.formvalue("wpa_version") or 0) > 0 and luci.http.formvalue("wpa_suites") == "PSK" then %>
71 <label for="pw_key">WPA passphrase</label><br />
72 <input class="cbi-input-password" type="password" name="key" id="pw_key" />
74 <% if tonumber(luci.http.formvalue("wpa_version") or 0) == 3 then %>
75 <select name="wpa_suite">
76 <option value="psk">WPA-PSK</option>
77 <option value="psk2" selected="selected">WPA2-PSK</option>
78 <option value="psk+psk2">WPA/WPA2-PSK mixed mode</option>
81 <input type="hidden" name="wpa_suite" value="psk<%=tonumber(luci.http.formvalue("wpa_version") or 0) == 2 and 2%>" />
84 <% if requirement then %>
85 <strong class="error"> <%=requirement%></strong>
91 <label for="sel_attach_intf">Attach wireless to</label><br />
92 <select name="attach_intf" id="sel_attach_intf">
93 <% for _, i in ipairs(ifaces) do %>
94 <option<% if i[1] == "wan" then %> selected="selected"<% end %> value="<%=i[1]%>"><%=i[1]%> (<%=i[2]%><% if i[3] then %> - <%=i[3]%><% end %>)</option>
96 <option value="">-- no interface --</option>
102 <% if luci.http.formvalue("mode") == "Ad-Hoc" then %>
103 <input type="checkbox" name="fixed_bssid" value="1" id="cb_fixed_bssid" checked="checked" />
104 <label for="cb_fixed_bssid">Lock BSSID to <%=luci.http.formvalue("bssid")%></label>
108 <% if iw.mbssid_support then %>
109 <input type="checkbox" name="replace_net" value="1" id="cb_replace_net" checked="checked" />
110 <label for="cb_replace_net">Overwrite existing wireless configuration</label>
113 <input type="hidden" name="replace_net" value="1" />
116 <input type="checkbox" name="autoconnect" value="1" id="cb_autoconnect" checked="checked" />
117 <label for="cb_autoconnect">Automatically connect</label>
120 <div class="cbi-page-actions">
121 <input class="cbi-button-apply" type="submit" value="<%:Join Network%>" />
122 <input class="cbi-button-reset" type="submit" name="cancel" value="<%:Back to scan results%>" />