dsp = require "luci.dispatcher"
-function interfaceWarnings(overview, count)
+function interfaceWarnings(overview, count, iface_max)
local warnings = ""
- if count <= 250 then
+ if count <= iface_max then
warnings = string.format("<strong>%s</strong><br />",
- translatef("There are currently %d of 250 supported interfaces configured", count)
+ translatef("There are currently %d of %d supported interfaces configured", count, iface_max)
)
else
warnings = string.format("<strong>%s</strong><br />",
- translatef("WARNING: %d interfaces are configured exceeding the maximum of 250!", count)
+ translatef("WARNING: %d interfaces are configured exceeding the maximum of %d!", count, iface_max)
)
end
end
end
)
- return overview, count
+
+ -- calculate iface_max usage from firewall mmx_mask
+ function bit(p)
+ return 2 ^ (p - 1)
+ end
+ function hasbit(x, p)
+ return x % (p + p) >= p
+ end
+ function setbit(x, p)
+ return hasbit(x, p) and x or x + p
+ end
+
+ local uci = require("uci").cursor(nil, "/var/state")
+ local mmx_mask = uci:get("mwan3", "globals", "mmx_mask") or "0x3F00"
+ local number = tonumber(mmx_mask, 16)
+ local bits = 0
+ local iface_max = 0
+ for i=1,16 do
+ if hasbit(number, bit(i)) then
+ bits = bits + 1
+ iface_max = setbit( iface_max, bit(bits))
+ end
+ end
+
+ -- subtract blackhole, unreachable and default table from iface_max
+ iface_max = iface_max - 3
+
+ return overview, count, iface_max
end
m5 = Map("mwan3", translate("MWAN - Interfaces"),
switch (status.interfaces[iface].status)
{
case 'online':
- state = '<%:Online (tracking active)%>';
+ state = '<%:Online%>';
css = 'success';
break;
case 'offline':
<fieldset id="interface_field" class="cbi-section">
<legend><%:MWAN Interfaces%></legend>
<div id="mwan_status_text">
- <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /><%:Collecting data...%>
+ <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
+ <%:Collecting data...%>
</div>
</fieldset>
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "detailed_status")%>', null,
function(x)
{
- var legend = document.getElementById('diag-rc-legend');
var output = document.getElementById('diag-rc-output');
- legend.style.display = 'none';
output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
}
);
<div><strong><%:INFO: MWAN not running%></strong></div>
<%end%>
<fieldset class="cbi-section">
- <legend id="diag-rc-legend"><%:Collecting data...%></legend>
<span id="diag-rc-output">
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align: middle;" />
+ <%:Collecting data...%>
</span>
</fieldset>
</div>
function update_status(iface, task)
{
- var legend = document.getElementById('diag-rc-legend');
var output = document.getElementById('diag-rc-output');
output.innerHTML =
stxhr.post('<%=url('admin/status/mwan')%>/diagnostics_display' + '/' + iface + '/' + task, { token: '<%=token%>' },
function(x)
{
- legend.style.display = 'none';
output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
}
);
</fieldset>
</div>
<fieldset class="cbi-section" style="display:none">
- <legend id="diag-rc-legend"><%:Collecting data...%></legend>
<span id="diag-rc-output"></span>
</fieldset>
</form>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
-<%+mwan/overview_status_interface%>
-
+<div class="cbi-map">
+ <%+mwan/overview_status_interface%>
+</div>
<%+footer%>
XHR.poll(15, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "troubleshooting_display")%>', null,
function(x)
{
- var legend = document.getElementById('diag-rc-legend');
var output = document.getElementById('diag-rc-output');
- legend.style.display = 'none';
output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
}
);
<div><strong><%:INFO: MWAN not running%></strong></div>
<%end%>
<fieldset class="cbi-section">
- <legend id="diag-rc-legend"><%:Collecting data...%></legend>
<span id="diag-rc-output">
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align: middle;" />
+ <%:Collecting data...%>
</span>
</fieldset>
</div>