2009-09-26 11:10:01 +00:00
|
|
|
<%#
|
|
|
|
LuCI - Lua Configuration Interface
|
|
|
|
Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
-%>
|
|
|
|
|
|
|
|
<%-
|
|
|
|
|
|
|
|
local sys = require "luci.sys"
|
|
|
|
local utl = require "luci.util"
|
|
|
|
|
|
|
|
function guess_wifi_signal(info)
|
|
|
|
local scale = (100 / (info.quality_max or 100) * (info.quality or 0))
|
|
|
|
local icon
|
|
|
|
|
|
|
|
if not info.bssid or info.bssid == "00:00:00:00:00:00" then
|
|
|
|
icon = resource .. "/icons/signal-none.png"
|
|
|
|
elseif scale < 15 then
|
|
|
|
icon = resource .. "/icons/signal-0.png"
|
|
|
|
elseif scale < 35 then
|
|
|
|
icon = resource .. "/icons/signal-0-25.png"
|
|
|
|
elseif scale < 55 then
|
|
|
|
icon = resource .. "/icons/signal-25-50.png"
|
|
|
|
elseif scale < 75 then
|
|
|
|
icon = resource .. "/icons/signal-50-75.png"
|
|
|
|
else
|
|
|
|
icon = resource .. "/icons/signal-75-100.png"
|
|
|
|
end
|
|
|
|
|
|
|
|
return icon
|
|
|
|
end
|
|
|
|
|
|
|
|
function percent_wifi_signal(info)
|
|
|
|
local qc = info.quality or 0
|
|
|
|
local qm = info.quality_max or 0
|
|
|
|
|
|
|
|
if info.bssid and qc > 0 and qm > 0 then
|
|
|
|
return math.floor((100 / qm) * qc)
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function format_wifi_encryption(info)
|
|
|
|
if info.wep == true and not info.wpa_version then
|
|
|
|
return "WEP"
|
2009-09-26 14:00:23 +00:00
|
|
|
elseif info.wpa then
|
2009-09-26 11:10:01 +00:00
|
|
|
return "<abbr title='Pairwise: %s / Group: %s'>%s - %s</abbr>" % {
|
|
|
|
table.concat(info.pair_ciphers, ", "),
|
|
|
|
table.concat(info.group_ciphers, ", "),
|
2009-09-26 14:00:23 +00:00
|
|
|
(info.wpa == 3) and "mixed WPA/WPA2"
|
|
|
|
or (info.wpa == 2 and "WPA2" or "WPA"),
|
2009-09-26 11:10:01 +00:00
|
|
|
table.concat(info.auth_suites, ", ")
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return "<em>None</em>"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local dev = luci.http.formvalue("device")
|
|
|
|
local iw = luci.sys.wifi.getiwinfo(dev)
|
2010-11-16 00:04:28 +00:00
|
|
|
|
|
|
|
if not iw then
|
|
|
|
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
|
|
|
|
return
|
|
|
|
end
|
2009-09-26 11:10:01 +00:00
|
|
|
-%>
|
|
|
|
|
|
|
|
<%+header%>
|
|
|
|
|
2009-11-08 02:38:22 +00:00
|
|
|
<h2><a id="content" name="content"><%:Join Network: Wireless Scan%></a></h2>
|
2009-09-26 11:10:01 +00:00
|
|
|
|
|
|
|
<div class="cbi-map">
|
|
|
|
<fieldset class="cbi-section">
|
|
|
|
<table class="cbi-section-table" style="empty-cells:hide">
|
|
|
|
<!-- scan list -->
|
2010-11-15 14:41:30 +00:00
|
|
|
<% for i, net in ipairs(iw.scanlist) do net.encryption = net.encryption or { } %>
|
2009-09-26 11:10:01 +00:00
|
|
|
<tr class="cbi-section-table-row cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
|
|
|
|
<td class="cbi-value-field" style="width:16px; padding:3px">
|
|
|
|
<abbr title="Signal: <%=net.signal%> dB / Quality: <%=net.quality%>/<%=net.quality_max%>">
|
|
|
|
<img src="<%=guess_wifi_signal(net)%>" /><br />
|
|
|
|
<small><%=percent_wifi_signal(net)%>%</small>
|
|
|
|
</abbr>
|
|
|
|
</td>
|
|
|
|
<td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px">
|
|
|
|
<big><strong><%=net.ssid and utl.pcdata(net.ssid) or "<em>hidden</em>"%></strong></big><br />
|
|
|
|
<strong>Channel:</strong> <%=net.channel%> |
|
|
|
|
<strong>Mode:</strong> <%=net.mode%> |
|
|
|
|
<strong>BSSID:</strong> <%=net.bssid%> |
|
2010-11-15 14:41:30 +00:00
|
|
|
<strong>Encryption:</strong> <%=net.encryption.description or translate("Open")%>
|
2009-09-26 11:10:01 +00:00
|
|
|
</td>
|
|
|
|
<td class="cbi-value-field" style="width:40px">
|
|
|
|
<form action="<%=REQUEST_URI%>" method="post">
|
|
|
|
<input type="hidden" name="device" value="<%=utl.pcdata(dev)%>" />
|
|
|
|
<input type="hidden" name="join" value="<%=utl.pcdata(net.ssid)%>" />
|
|
|
|
<input type="hidden" name="mode" value="<%=net.mode%>" />
|
|
|
|
<input type="hidden" name="bssid" value="<%=net.bssid%>" />
|
|
|
|
<input type="hidden" name="channel" value="<%=net.channel%>" />
|
2010-11-15 14:41:30 +00:00
|
|
|
<input type="hidden" name="wep" value="<%=net.encryption.wep and 1 or 0%>" />
|
|
|
|
<% if net.encryption.wpa then %>
|
|
|
|
<input type="hidden" name="wpa_version" value="<%=net.encryption.wpa%>" />
|
|
|
|
<% for _, v in ipairs(net.encryption.auth_suites) do %><input type="hidden" name="wpa_suites" value="<%=v%>" />
|
|
|
|
<% end; for _, v in ipairs(net.encryption.group_ciphers) do %><input type="hidden" name="wpa_group" value="<%=v%>" />
|
|
|
|
<% end; for _, v in ipairs(net.encryption.pair_ciphers) do %><input type="hidden" name="wpa_pairwise" value="<%=v%>" />
|
2009-09-26 11:10:01 +00:00
|
|
|
<% end; end %>
|
|
|
|
|
2010-11-15 14:41:30 +00:00
|
|
|
<input type="hidden" name="clbridge" value="<%=iw.type == "wl" and 1 or 0%>" />
|
|
|
|
|
2011-01-20 23:29:00 +00:00
|
|
|
<input class="cbi-button-apply" type="submit" value="<%:Join Network%>" />
|
2009-09-26 11:10:01 +00:00
|
|
|
</form>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<% end %>
|
|
|
|
<!-- /scan list -->
|
|
|
|
</table>
|
|
|
|
</fieldset>
|
|
|
|
</div>
|
|
|
|
<div class="cbi-page-actions right">
|
|
|
|
<form class="inline" action="<%=luci.dispatcher.build_url("admin/network/wireless")%>" method="get">
|
2009-10-31 15:54:11 +00:00
|
|
|
<input class="cbi-button-reset" type="submit" value="<%:Back to overview%>" />
|
2009-09-26 11:10:01 +00:00
|
|
|
</form>
|
|
|
|
<form class="inline" action="<%=REQUEST_URI%>" method="get">
|
|
|
|
<input type="hidden" name="device" value="<%=utl.pcdata(dev)%>" />
|
2009-10-31 15:54:11 +00:00
|
|
|
<input class="cbi-input-find" type="submit" value="<%:Repeat scan%>" />
|
2009-09-26 11:10:01 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<%+footer%>
|