2 LuCI - Lua Configuration Interface
3 Copyright 2008-2009 Steven Barth <steven@midlink.org>
4 Copyright 2008-2009 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
18 local sys = require "luci.sys"
19 local utl = require "luci.util"
20 local uci = require "luci.model.uci".cursor()
21 local wlm = require "luci.model.wireless"
25 function guess_wifi_hw(ifname)
26 local name, idx = ifname:match("^([a-z]+)(%d+)")
31 local name = "Broadcom 802.11 Wireless Controller"
34 local fd = nixio.open("/proc/bus/pci/devices", "r")
37 for ln in fd:linesource() do
38 if ln:match("wl$") then
40 local version = ln:match("^%S+%s+%S%S%S%S([0-9a-f]+)")
42 "Broadcom BCM%04x 802.11 Wireless Controller",
58 elseif name == "ath" or name == "wifi" then
59 return "Atheros 802.11 Wireless Controller"
62 elseif name == "ra" then
63 return "RaLink 802.11 Wireless Controller"
66 elseif name == "eth" then
67 return "Prism 802.11 Wireless Controller"
71 return "Generic 802.11 Wireless Controller"
75 function guess_wifi_signal(scale)
79 icon = resource .. "/icons/signal-none.png"
81 icon = resource .. "/icons/signal-0.png"
83 icon = resource .. "/icons/signal-0-25.png"
85 icon = resource .. "/icons/signal-25-50.png"
87 icon = resource .. "/icons/signal-50-75.png"
89 icon = resource .. "/icons/signal-75-100.png"
95 local devices = wlm:get_devices()
97 sys.net.arptable(function(e) arpcache[e["HW address"]] = e["IP address"] end)
102 <h2><a id="content" name="content"><%:Wireless Overview%></a></h2>
104 <div class="cbi-map">
106 <% for _, dev in ipairs(devices) do local nets = dev:get_networks() %>
107 <!-- device <%=dev:name()%> -->
108 <fieldset class="cbi-section">
109 <table class="cbi-section-table" style="margin:10px; empty-cells:hide">
110 <!-- physical device -->
112 <td style="width:34px"><img src="<%=resource%>/icons/wifi<%=dev:is_up() and "" or "_disabled"%>.png" style="float:left; margin-right:10px" /></td>
113 <td colspan="2" style="text-align:left">
114 <big><strong><%=guess_wifi_hw(dev:name())%> (<%=dev:name()%>)</strong></big><br />
115 <% if nets[1] then %>
116 <strong>Channel:</strong> <%=nets[1]:channel() or "?"%> (<%=nets[1]:frequency() or "?"%> GHz) |
117 <strong>Bitrate:</strong> <%=nets[1]:bitrate() or "?"%> Mb/s
120 <td style="width:40px">
121 <a href="<%=luci.dispatcher.build_url("admin/network/wireless_join?device="..dev:name())%>"><img style="border:none" src="<%=resource%>/cbi/find.gif" alt="Find and join network" title="Find and join network" /></a>
122 <a href="#"><img style="border:none" src="<%=resource%>/cbi/add.gif" alt="Provide new network" title="Provide new network" /></a>
125 <!-- /physical device -->
127 <!-- network list -->
128 <% if #nets > 0 then %>
129 <% for i, net in ipairs(nets) do %>
130 <tr class="cbi-section-table-row cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
132 <td class="cbi-value-field" style="width:16px; padding:3px">
133 <img src="<%=guess_wifi_signal(net:signal_level())%>" title="Signal: <%=net:signal()%> dBm / Noise: <%=net:noise()%> dBm" /><br />
134 <small><%=net:signal_percent()%>%</small>
136 <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px">
137 <strong>SSID:</strong> <%=utl.pcdata(net:active_ssid())%> |
138 <strong>Mode:</strong> <%=net:active_mode_i18n()%><br />
139 <strong>BSSID:</strong> <%=net:active_bssid()%> |
140 <strong>Encryption:</strong> <%=net:active_encryption()%>
142 <td class="cbi-value-field" style="width:40px">
143 <a href="<%=REQUEST_URI%>/<%=dev:name()%>/<%=net:name()%>"><img style="border:none" src="<%=resource%>/cbi/edit.gif" alt="Edit this network" title="Edit this network" /></a>
144 <a href="<%=luci.dispatcher.build_url("admin/network/wireless_delete", net:name())%>"><img style="border:none" src="<%=resource%>/cbi/remove.gif" alt="Delete this network" title="Delete this network" /></a>
149 <tr class="cbi-section-table-row cbi-rowstyle-2">
151 <td colspan="3" class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px">
152 <em>(No network configured on this device)</em>
156 <!-- /network list -->
159 <!-- /device <%=dev:name()%> -->
165 <h2><a id="content" name="content"><%:Associated Stations%></a></h2>
167 <fieldset class="cbi-section">
168 <table class="cbi-section-table" style="margin:10px; width:50%">
169 <tr class="cbi-section-table-titles">
170 <th class="cbi-section-table-cell"></th>
171 <th class="cbi-section-table-cell">SSID</th>
172 <th class="cbi-section-table-cell">MAC</th>
173 <th class="cbi-section-table-cell">Address</th>
174 <th class="cbi-section-table-cell">Signal</th>
175 <th class="cbi-section-table-cell">Noise</th>
178 <% local count = -1 %>
179 <% for _, dev in ipairs(devices) do local nets = dev:get_networks() %>
180 <% for _, net in ipairs(nets) do %>
181 <% for mac, info in utl.kspairs(net:assoclist()) do count = count + 1 %>
182 <tr class="cbi-section-table-row cbi-rowstyle-<%=1 + (count % 2)%>">
183 <td class="cbi-value-field"><img src="<%=guess_wifi_signal(net:signal_level(info.signal, info.noise))%>" title="Signal: <%=info.signal%> dBm / Noise: <%=info.noise%> dBm" /></td>
184 <td class="cbi-value-field"><%=net:active_ssid()%></td>
185 <td class="cbi-value-field"><%=mac%></td>
186 <td class="cbi-value-field"><%=arpcache[mac] or "n/a"%></td>
187 <td class="cbi-value-field"><%=info.signal%> dBm</td>
188 <td class="cbi-value-field"><%=info.noise%> dBm</td>
193 <% if count <= 0 then %>
194 <tr class="cbi-section-table-row cbi-rowstyle-2">
195 <td class="cbi-value-field" colspan="6">
196 <em>No information available</em>