summaryrefslogtreecommitdiffhomepage
path: root/core/src
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-04-22 16:07:02 +0000
committerSteven Barth <steven@midlink.org>2008-04-22 16:07:02 +0000
commit187bbe4bbec7cb22c33df9c805c829e939892016 (patch)
tree700a50697a81f8e07981ea5680764b96d87b4942 /core/src
parenteb9a1093c274bf33f9d7a798f0030821da637663 (diff)
* 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
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ffluci/cbi.lua5
-rw-r--r--core/src/ffluci/sys.lua19
2 files changed, 18 insertions, 6 deletions
diff --git a/core/src/ffluci/cbi.lua b/core/src/ffluci/cbi.lua
index f09d48ad7..5b38d1b50 100644
--- a/core/src/ffluci/cbi.lua
+++ b/core/src/ffluci/cbi.lua
@@ -367,7 +367,12 @@ end
-- Return all matching UCI sections for this TypedSection
function TypedSection.cfgsections(self)
local sections = {}
+
local map = self.map:get()
+ if not map[".order"] then
+ return sections
+ end
+
for i, k in pairs(map[".order"]) do
if map[k][".type"] == self.sectiontype then
if self:checkscope(k) then
diff --git a/core/src/ffluci/sys.lua b/core/src/ffluci/sys.lua
index c97017d8d..44855f8ef 100644
--- a/core/src/ffluci/sys.lua
+++ b/core/src/ffluci/sys.lua
@@ -143,8 +143,8 @@ function net.routes()
return _parse_delimited_table(io.lines("/proc/net/route"))
end
--- Returns the numeric IP to a given hexstring
-function net.hexip4(hex)
+-- Returns the numeric IP to a given hexstring (little endian)
+function net.hexip4(hex, bigendian)
if #hex ~= 8 then
return nil
end
@@ -152,10 +152,17 @@ function net.hexip4(hex)
local hexdec = ffluci.bits.Hex2Dec
local ip = ""
- 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)))
+ if bigendian then
+ ip = ip .. tostring(hexdec(hex:sub(1,2))) .. "."
+ ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "."
+ 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
end