1be6c22665d4e157a058fe5aa59a2d806b0f5999
[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("a_s_iw_require_nas",
35                         "You need to install the <a href='%s'>Broadcom <em>nas</em> supplicant</a> to use WPA!"
36                         % luci.dispatcher.build_url("admin/system/packages?url=nas&amp;submit=1"))
37         elseif not nixio.fs.access("/usr/sbin/wpa_supplicant") then
38                 requirement = luci.i18n.translatef("a_s_iw_require_wpasupplicant",
39                         "You need to install <a href='%s'><em>wpa-supplicant</em></a> to use WPA!"
40                         % luci.dispatcher.build_url("admin/system/packages?url=wpa-supplicant&amp;submit=1"))
41         end
42
43 -%>
44
45 <%+header%>
46
47 <h2><a id="content" name="content"><%:a_s_iw_join Join Network%></a></h2>
48
49 <form method="post" action="<%=REQUEST_URI%>">
50         <div class="cbi-map">
51                 <div class="cbi-map-descr">
52                         <%=luci.i18n.translatef("a_s_iw_join_desc", "You are about to join the wireless network <em><strong>%s</strong></em>. " ..
53                                 "In order to complete the process, you need to provide some additional details.",
54                                 utl.pcdata(luci.http.formvalue("join") or "(hidden)")
55                         )%>
56                 </div>
57
58                 <fieldset class="cbi-section">
59                         <input type="hidden" name="confirm" value="1" />
60                         <input type="hidden" name="join" value="<%=utl.pcdata(luci.http.formvalue("join"))%>" />
61                         <input type="hidden" name="device" value="<%=utl.pcdata(luci.http.formvalue("device"))%>" />
62                         <input type="hidden" name="mode" value="<%=luci.http.formvalue("mode")%>" />
63                         <input type="hidden" name="bssid" value="<%=luci.http.formvalue("bssid")%>" />
64                         <input type="hidden" name="channel" value="<%=luci.http.formvalue("channel")%>" />
65                         <input type="hidden" name="wep" value="<%=luci.http.formvalue("wep")%>" />
66                         <input type="hidden" name="wpa_version" value="<%=luci.http.formvalue("wpa_version")%>" />
67
68                         <% if luci.http.formvalue("wep") == "1" then %>
69                                 <label for="pw_key">WEP passphrase</label><br />
70                                 <input class="cbi-input-password" type="password" name="key" id="pw_key" />
71                                 <br /><br />
72                         <% elseif tonumber(luci.http.formvalue("wpa_version") or 0) > 0 and luci.http.formvalue("wpa_suites") == "PSK" then %>
73                                 <label for="pw_key">WPA passphrase</label><br />
74                                 <input class="cbi-input-password" type="password" name="key" id="pw_key" />
75
76                                 <% if tonumber(luci.http.formvalue("wpa_version") or 0) == 3 then %>
77                                         <select name="wpa_suite">
78                                                 <option value="psk">WPA-PSK</option>
79                                                 <option value="psk2" selected="selected">WPA2-PSK</option>
80                                                 <option value="psk+psk2">WPA/WPA2-PSK mixed mode</option>
81                                         </select>
82                                 <% else %>
83                                         <input type="hidden" name="wpa_suite" value="psk<%=tonumber(luci.http.formvalue("wpa_version") or 0) == 2 and 2%>" />
84                                 <% end %>
85
86                                 <% if requirement then %>
87                                         <strong class="error">&nbsp; <%=requirement%></strong>
88                                 <% end %>
89
90                                 <br /><br />
91                         <% end %>
92
93                         <label for="sel_attach_intf">Attach wireless to</label><br />
94                         <select name="attach_intf" id="sel_attach_intf">
95                                 <% for _, i in ipairs(ifaces) do %>
96                                         <option<% if i[1] == "wan" then %> selected="selected"<% end %> value="<%=i[1]%>"><%=i[1]%> (<%=i[2]%><% if i[3] then %> - <%=i[3]%><% end %>)</option>
97                                 <% end %>
98                                 <option value="">-- no interface --</option>
99                         </select>
100
101                         <br/><br />
102                         <hr /><br />
103
104                         <% if luci.http.formvalue("mode") == "Ad-Hoc" then %>
105                         <input type="checkbox" name="fixed_bssid" value="1" id="cb_fixed_bssid" checked="checked" />
106                         <label for="cb_fixed_bssid">Lock BSSID to <%=luci.http.formvalue("bssid")%></label>
107                         <br />
108                         <% end %>
109
110                         <% if iw.mbssid_support then %>
111                                 <input type="checkbox" name="replace_net" value="1" id="cb_replace_net" checked="checked" />
112                                 <label for="cb_replace_net">Overwrite existing wireless configuration</label>
113                                 <br />
114                         <% else %>
115                                 <input type="hidden" name="replace_net" value="1" />
116                         <% end %>
117
118                         <input type="checkbox" name="autoconnect" value="1" id="cb_autoconnect" checked="checked" />
119                         <label for="cb_autoconnect">Automatically connect</label>
120                 </fieldset>
121         </div>
122         <div class="cbi-page-actions">
123                 <input class="cbi-button-apply" type="submit" value="<%:a_s_iw_join_confirm Join network%>" />
124                 <input class="cbi-button-reset" type="submit" name="cancel" value="<%:a_s_iw_back_scan Back to scan results%>" />
125         </div>
126 </form>
127
128 <%+footer%>