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"
20 function guess_wifi_signal(info)
21 local scale = (
100 / (info.quality_max or
100) * (info.quality or
0))
24 if not info.bssid or info.bssid ==
"00:00:00:00:00:00" then
25 icon = resource ..
"/icons/signal-none.png"
26 elseif scale <
15 then
27 icon = resource ..
"/icons/signal-0.png"
28 elseif scale <
35 then
29 icon = resource ..
"/icons/signal-0-25.png"
30 elseif scale <
55 then
31 icon = resource ..
"/icons/signal-25-50.png"
32 elseif scale <
75 then
33 icon = resource ..
"/icons/signal-50-75.png"
35 icon = resource ..
"/icons/signal-75-100.png"
41 function percent_wifi_signal(info)
42 local qc = info.quality or
0
43 local qm = info.quality_max or
0
45 if info.bssid and qc
> 0 and qm
> 0 then
46 return math.floor((
100 / qm) * qc)
52 function format_wifi_encryption(info)
53 if info.wep == true then
55 elseif info.wpa
> 0 then
56 return translatef(
"<abbr title='Pairwise: %s / Group: %s'>%s - %s</abbr>",
57 table.concat(info.pair_ciphers,
", "),
58 table.concat(info.group_ciphers,
", "),
59 (info.wpa ==
3) and translate(
"mixed WPA/WPA2")
60 or (info.wpa ==
2 and
"WPA2" or
"WPA"),
61 table.concat(info.auth_suites,
", ")
63 elseif info.enabled then
64 return
"<em>%s</em>" % translate(
"unknown")
66 return
"<em>%s</em>" % translate(
"open")
70 local dev = luci.http.formvalue(
"device")
71 local iw = luci.sys.wifi.getiwinfo(dev)
74 luci.http.redirect(luci.dispatcher.build_url(
"admin/network/wireless"))
79 function scanlist(times)
85 for k, v in ipairs(iw.scanlist or { }) do
86 if not s[v.bssid] then
99 <h2><a id=
"content" name=
"content"><%:Join Network: Wireless Scan%
></a></h2>
101 <div class=
"cbi-map">
102 <fieldset class=
"cbi-section">
103 <table class=
"cbi-section-table" style=
"empty-cells:hide">
105 <% for i, net in ipairs(scanlist(
3)) do net.encryption = net.encryption or { } %
>
106 <tr class=
"cbi-section-table-row cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
107 <td class=
"cbi-value-field" style=
"width:16px; padding:3px">
108 <abbr title=
"<%:Signal%>: <%=net.signal%> <%:dB%> / <%:Quality%>: <%=net.quality%>/<%=net.quality_max%>">
109 <img src=
"<%=guess_wifi_signal(net)%>" /><br />
110 <small><%=percent_wifi_signal(net)%
>%
</small>
113 <td class=
"cbi-value-field" style=
"vertical-align:middle; text-align:left; padding:3px">
114 <big><strong><%=net.ssid and utl.pcdata(net.ssid) or
"<em>%s</em>" % translate(
"hidden")%
></strong></big><br />
115 <strong>Channel:
</strong> <%=net.channel%
> |
116 <strong>Mode:
</strong> <%=net.mode%
> |
117 <strong>BSSID:
</strong> <%=net.bssid%
> |
118 <strong>Encryption:
</strong> <%=format_wifi_encryption(net.encryption)%
>
120 <td class=
"cbi-value-field" style=
"width:40px">
121 <form action=
"<%=REQUEST_URI%>" method=
"post">
122 <input type=
"hidden" name=
"device" value=
"<%=utl.pcdata(dev)%>" />
123 <input type=
"hidden" name=
"join" value=
"<%=utl.pcdata(net.ssid)%>" />
124 <input type=
"hidden" name=
"mode" value=
"<%=net.mode%>" />
125 <input type=
"hidden" name=
"bssid" value=
"<%=net.bssid%>" />
126 <input type=
"hidden" name=
"channel" value=
"<%=net.channel%>" />
127 <input type=
"hidden" name=
"wep" value=
"<%=net.encryption.wep and 1 or 0%>" />
128 <% if net.encryption.wpa then %
>
129 <input type=
"hidden" name=
"wpa_version" value=
"<%=net.encryption.wpa%>" />
130 <% for _, v in ipairs(net.encryption.auth_suites) do %
><input type=
"hidden" name=
"wpa_suites" value=
"<%=v%>" />
131 <% end; for _, v in ipairs(net.encryption.group_ciphers) do %
><input type=
"hidden" name=
"wpa_group" value=
"<%=v%>" />
132 <% end; for _, v in ipairs(net.encryption.pair_ciphers) do %
><input type=
"hidden" name=
"wpa_pairwise" value=
"<%=v%>" />
135 <input type=
"hidden" name=
"clbridge" value=
"<%=iw.type == "wl
" and 1 or 0%>" />
137 <input class=
"cbi-button cbi-button-apply" type=
"submit" value=
"<%:Join Network%>" />
146 <div class=
"cbi-page-actions right">
147 <form class=
"inline" action=
"<%=luci.dispatcher.build_url("admin/network/wireless
")%>" method=
"get">
148 <input class=
"cbi-button cbi-button-reset" type=
"submit" value=
"<%:Back to overview%>" />
150 <form class=
"inline" action=
"<%=REQUEST_URI%>" method=
"get">
151 <input type=
"hidden" name=
"device" value=
"<%=utl.pcdata(dev)%>" />
152 <input class=
"cbi-button cbi-input-find" type=
"submit" value=
"<%:Repeat scan%>" />