<%# Opennet Firmware Copyright 2010 Rene Ejury 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: index.htm 5448 2009-10-31 15:54:11Z jow $ -%> <%+header%> <% local uci = require "luci.model.uci" local cursor = uci.cursor() local on_version = luci.sys.exec("opkg status on-core | awk '{if (/Version/) print $2;}'") local on_id = cursor:get("on-core", "settings", "on_id") require("luci.sys") function split(str) local t = { } str:gsub("%S+", function (w) table.insert(t, w) end) return t end local on_aps = "" if nixio.fs.access("/usr/sbin/on_portcalc.sh") then on_aps = split(luci.sys.exec("/usr/sbin/on_portcalc.sh"))[1] end function printZoneLine(zoneName) networks = cursor:get("firewall", "zone_"..zoneName, "network") if not networks then networks = cursor:get("firewall", "zone_"..zoneName, "name") end if networks and relevant(networks) then %> <% if zoneName == "local" then print(luci.i18n.translate([[LOCAL IP Address(es):]])) elseif zoneName == "opennet" then print(luci.i18n.translate([[OPENNET IP Address(es):]])) elseif zoneName == "wan" then print(luci.i18n.translate([[WAN IP Address(es):]])) elseif zoneName == "free" then print(luci.i18n.translate([[FREE IP Address(es):]])) end %> <% printInterfaces(networks) %> <% end end function relevant(networks) for network in networks:gmatch("%S+") do local devices = luci.sys.exec(". /etc/functions.sh; include /lib/network; scan_interfaces; ".. "[ -n \"$(config_get "..network.." ipaddr)\" ] && config_get "..network.." device") devices = devices.gsub(devices, "%c+", "") if devices ~= "" then for device in devices:gmatch("%S+") do if luci.sys.exec("ip link show "..device.." 2>/dev/null | grep UP") ~= "" then return true end end end end return false end function printInterfaces(networks) %> <% for network in networks:gmatch("%S+") do printValues(network) end %>
<%:Interface%> <%:IP%> <%:MAC%> <% print(luci.i18n.translate([[DHCP]])) %>
<% end function printValues(network) ifname = luci.sys.exec(". /etc/functions.sh; include /lib/network; scan_interfaces; config_get "..network.." ifname") ifname = ifname.gsub(ifname, "%c+", "") if not ifname then return end if luci.sys.exec("ip link show "..ifname.." 2>/dev/null | grep UP") == "" then return end output = luci.sys.exec([[ip address show label ]]..ifname..[[ | awk 'BEGIN{ mac="---";ip="---"; } { if ($1 ~ "link") mac=$2; if ($1 ~ "inet") ip=$2; } END{ print "]]..ifname..[["ip""mac""}']]) if output and output ~= "" then %> <%=output%> <% local dhcp = cursor:get_all("dhcp", network) if dhcp and dhcp.ignore ~= "1" then %> <%=dhcp.start.." / "..dhcp.limit.." / "..dhcp.leasetime%> <% else local dhcpfwd if (luci.sys.exec("pidof dhcp-fwd") ~= "") then -- check for dhcp-fwd dhcpfwd = luci.sys.exec([[ awk 'BEGIN{out=0} {if ($1 == "if" && $2 == "]]..ifname..[[" && $3 == "true") out=1; if (out == 1 && $1 == "server" && $2 == "ip") print $3}' /etc/dhcp-fwd.conf ]]) if dhcpfwd and dhcpfwd ~= "" then print("active, forwarded to "..dhcpfwd) end end if not dhcpfwd or dhcpfwd == "" then print("---") end end %> <% end end function printWireless() local header = 0; local wireless = cursor:get_all("wireless") if wireless then for k, v in pairs(wireless) do if v[".type"] == "wifi-iface" then if header == 0 then %> <%:WLAN-Status:%> <% header = 1 end ifname = v.ifname or "-" if not ifname or ifname == "-" then ifname = luci.sys.exec([[ find /var/run/ -name "hostapd*conf" -exec \ awk 'BEGIN{FS="=";iface="";found=0} {if ($1 == "ssid" && $2 == "]]..essid..[[") found=1; if ($1 == "interface") iface=$2;} END{if (found) print iface}' {} \; ]]) end ifname = ifname.gsub(ifname, "%c+", "") iwinfo = luci.sys.wifi.getiwinfo(ifname) device = v.device or "-"; mode802 = wireless[v.device].hwmode mode802 = mode802 and "802."..mode802 or "-" -- essid = luci.util.pcdata(v.ssid) or "-" -- channel = wireless[v.device].channel or "-" local signal = iwinfo and iwinfo.signal or "-" local noise = iwinfo and iwinfo.noise or "-" -- local q = iwinfo and iwinfo.quality or "0" local ssid = iwinfo and iwinfo.ssid or "N/A" local bssid = iwinfo and iwinfo.bssid or "N/A" local chan = iwinfo and iwinfo.channel or "N/A" local mode = iwinfo and iwinfo.mode or "N/A" local txpwr = iwinfo and iwinfo.txpower or "N/A" -- local bitrate = iwinfo and iwinfo.bitrate or "N/A" print( "".. "".. "") end end if header == 1 then %>
<%:Interface%> <%:SSID%>
"..ifname.."/"..device..""..ssid..""..mode.. " / Mode: "..mode802.. " / Channel: "..chan.. " / Cell: "..bssid.. " / S/N: "..signal.."/"..noise.. -- " / Bitrate: "..bitrate.. " / Power: "..txpwr.."
<% end end end %>

<% print(luci.i18n.translatef("Opennet Firmware (next generation) version %s", on_version)) if on_id then print(luci.i18n.translatef("-- AP %s", on_id)) end if on_aps and on_aps ~= "" then print(luci.i18n.translatef("-- CN %s", on_aps)) end %>

<%:This is an Access-Point with Opennet-Firmware, a modification of OpenWrt to the requirements of Opennet Rostock.%>