<%# 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 = split(luci.sys.exec("/usr/sbin/on_portcalc.sh"))[1] function printZoneLine(zoneName) networks = cursor:get("firewall", "zone_"..zoneName, "network") 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 if cursor:get("network", network, "type") == "bridge" then if luci.sys.exec("ip address show label br-"..network) ~= "" then return true end else ifaces = cursor:get("network", network, "ifname") if ifaces then for iface in ifaces:gmatch("%S+") do if iface and luci.sys.exec("ip address show label "..iface) ~= "" then return true end 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) if cursor:get("network", network, "type") == "bridge" then ifname = "br-"..network else ifname = cursor:get("network", network, "ifname") end if not ifname or ifname == "none" 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 %>

<% 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.%>