<%# Copyright 2008 Steven Barth Copyright 2008 Jo-Philipp Wich Copyright 2011 Manuel Munz Licensed to the public under the Apache License 2.0. -%> <% local i = 1 require("luci.model.uci") local uci = luci.model.uci.cursor_state() uci:foreach("olsrd", "olsrd", function(s) if s.SmartGateway and s.SmartGateway == "yes" then has_smartgw = true end end) if luci.http.formvalue("status") == "1" then local rv = {} for k, gw in ipairs(gws.ipv4, gws.ipv6) do gw.cost = tonumber(gw.cost)/1024 or 0 if gw.cost >= 100 then gw.cost = 0 end rv[#rv+1] = { proto = gw.IPv4 and '4' or '6', originator = gw.originator, selected = gw.selected and luci.i18n.translate('yes') or luci.i18n.translate('no'), cost = gw.cost > 0 and string.format("%.3f", gw.cost) or luci.i18n.translate('infinate'), hops = gw.hops, uplink = gw.uplink, downlink = gw.downlink, v4 = gw.IPv4 and luci.i18n.translate('yes') or luci.i18n.translate('no'), v6 = gw.IPv6 and luci.i18n.translate('yes') or luci.i18n.translate('no'), prefix = gw.prefix } end luci.http.prepare_content("application/json") luci.http.write_json(rv) return end %> <%+header%>

<%:SmartGW announcements%>

<% if has_smartgw then %>
<%:Overview of smart gateways in this network%>
<%:Gateway%>
<%:Selected%>
<%:ETX%>
<%:Hops%>
<%:Uplink%>
<%:Downlink%>
<%:IPv4%>
<%:IPv6%>
<%:Prefix%>
<% for k, gw in ipairs(gws.ipv4, gws.ipv6) do gw.cost = tonumber(gw.cost)/1024 or 0 if gw.cost >= 100 then gw.cost = 0 end %>
<% if gw.proto == '6' then %> <% else %> <% end %>
<%=gw.selected and luci.i18n.translate('yes') or luci.i18n.translate('no')%>
<%=gw.cost > 0 and string.format("%.3f", gw.cost) or luci.i18n.translate('infinate')%>
<%=gw.hops%>
<%=gw.uplink%>
<%=gw.downlink%>
<%=gw.IPv4 and luci.i18n.translate('yes') or luci.i18n.translate('no')%>
<%=gw.IPv6 and luci.i18n.translate('yes') or luci.i18n.translate('no')%>
<%=gw.prefix%>
<% i = ((i % 2) + 1) end %>
<% else %> <%:SmartGateway is not configured on this system.%> <% end %> <%+status-olsr/common_js%> <%+footer%>