b29de61a0c51a82acb07031215dbf93712c08e99
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / wifi_join_settings.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
4
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
8
9         http://www.apache.org/licenses/LICENSE-2.0
10
11 $Id$
12
13 -%>
14
15 <%-
16
17         local sys = require "luci.sys"
18         local utl = require "luci.util"
19         local uci = require "luci.model.uci".cursor_state()
20
21         local ifaces = { }
22         uci:foreach("network", "interface", function(i)
23                 if i.ifname ~= "lo" then
24                         ifaces[#ifaces+1] = { i['.name'], i.ifname, i.ipaddr }
25                 end
26         end)
27
28         local dev = luci.http.formvalue("device")
29         local iw = luci.sys.wifi.getiwinfo(dev)
30
31         local requirement
32
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&amp;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&amp;submit=1"))
39         end
40
41 -%>
42
43 <%+header%>
44
45 <h2><a id="content" name="content"><%:Join Network%></a></h2>
46
47 <form method="post" action="<%=REQUEST_URI%>">
48         <div class="cbi-map">
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)")
53                         )%>
54                 </div>
55
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")%>" />
65
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" />
69                                 <br /><br />
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" />
73
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>
79                                         </select>
80                                 <% else %>
81                                         <input type="hidden" name="wpa_suite" value="psk<%=tonumber(luci.http.formvalue("wpa_version") or 0) == 2 and 2%>" />
82                                 <% end %>
83
84                                 <% if requirement then %>
85                                         <strong class="error">&nbsp; <%=requirement%></strong>
86                                 <% end %>
87
88                                 <br /><br />
89                         <% end %>
90
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>
95                                 <% end %>
96                                 <option value="">-- no interface --</option>
97                         </select>
98
99                         <br/><br />
100                         <hr /><br />
101
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>
105                         <br />
106                         <% end %>
107
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>
111                                 <br />
112                         <% else %>
113                                 <input type="hidden" name="replace_net" value="1" />
114                         <% end %>
115
116                         <input type="checkbox" name="autoconnect" value="1" id="cb_autoconnect" checked="checked" />
117                         <label for="cb_autoconnect">Automatically connect</label>
118                 </fieldset>
119         </div>
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%>" />
123         </div>
124 </form>
125
126 <%+footer%>