* ffluci.sys.net.hexip4: Added option for big endian support
* ffluci.cbi.TypedSection.cfgsections: Check whether there are any configuration sections before iterating * ffluci.view.public_status.routes: Added "fix" for big endian systems
This commit is contained in:
parent
eb9a1093c2
commit
187bbe4bbe
3 changed files with 29 additions and 10 deletions
|
@ -367,7 +367,12 @@ end
|
||||||
-- Return all matching UCI sections for this TypedSection
|
-- Return all matching UCI sections for this TypedSection
|
||||||
function TypedSection.cfgsections(self)
|
function TypedSection.cfgsections(self)
|
||||||
local sections = {}
|
local sections = {}
|
||||||
|
|
||||||
local map = self.map:get()
|
local map = self.map:get()
|
||||||
|
if not map[".order"] then
|
||||||
|
return sections
|
||||||
|
end
|
||||||
|
|
||||||
for i, k in pairs(map[".order"]) do
|
for i, k in pairs(map[".order"]) do
|
||||||
if map[k][".type"] == self.sectiontype then
|
if map[k][".type"] == self.sectiontype then
|
||||||
if self:checkscope(k) then
|
if self:checkscope(k) then
|
||||||
|
|
|
@ -143,8 +143,8 @@ function net.routes()
|
||||||
return _parse_delimited_table(io.lines("/proc/net/route"))
|
return _parse_delimited_table(io.lines("/proc/net/route"))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the numeric IP to a given hexstring
|
-- Returns the numeric IP to a given hexstring (little endian)
|
||||||
function net.hexip4(hex)
|
function net.hexip4(hex, bigendian)
|
||||||
if #hex ~= 8 then
|
if #hex ~= 8 then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
@ -152,10 +152,17 @@ function net.hexip4(hex)
|
||||||
local hexdec = ffluci.bits.Hex2Dec
|
local hexdec = ffluci.bits.Hex2Dec
|
||||||
|
|
||||||
local ip = ""
|
local ip = ""
|
||||||
ip = ip .. tostring(hexdec(hex:sub(7,8))) .. "."
|
if bigendian then
|
||||||
ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "."
|
ip = ip .. tostring(hexdec(hex:sub(1,2))) .. "."
|
||||||
ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "."
|
ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "."
|
||||||
ip = ip .. tostring(hexdec(hex:sub(1,2)))
|
ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "."
|
||||||
|
ip = ip .. tostring(hexdec(hex:sub(7,8)))
|
||||||
|
else
|
||||||
|
ip = ip .. tostring(hexdec(hex:sub(7,8))) .. "."
|
||||||
|
ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "."
|
||||||
|
ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "."
|
||||||
|
ip = ip .. tostring(hexdec(hex:sub(1,2)))
|
||||||
|
end
|
||||||
|
|
||||||
return ip
|
return ip
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,11 +10,18 @@
|
||||||
<th><%:metric Metrik%></th>
|
<th><%:metric Metrik%></th>
|
||||||
<th><%:iface Schnittstelle%></th>
|
<th><%:iface Schnittstelle%></th>
|
||||||
</tr>
|
</tr>
|
||||||
<% for i, r in pairs(ffluci.sys.net.routes()) do %>
|
<%
|
||||||
|
local routes = ffluci.sys.net.routes()
|
||||||
|
|
||||||
|
-- UGLY hack is UGLY
|
||||||
|
local be = (routes[1] and routes[1].Mask:sub(-2) == "00")
|
||||||
|
|
||||||
|
for i, r in pairs(routes) do
|
||||||
|
%>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%=ffluci.sys.net.hexip4(r.Destination)%></td>
|
<td><%=ffluci.sys.net.hexip4(r.Destination, be)%></td>
|
||||||
<td><%=ffluci.sys.net.hexip4(r.Mask)%></td>
|
<td><%=ffluci.sys.net.hexip4(r.Mask, be)%></td>
|
||||||
<td><%=ffluci.sys.net.hexip4(r.Gateway)%></td>
|
<td><%=ffluci.sys.net.hexip4(r.Gateway, be)%></td>
|
||||||
<td><%=r.Metric%></td>
|
<td><%=r.Metric%></td>
|
||||||
<td><%=r.Iface%></td>
|
<td><%=r.Iface%></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in a new issue