summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-olsr/luasrc/controller
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-olsr/luasrc/controller')
-rw-r--r--applications/luci-olsr/luasrc/controller/olsr.lua33
1 files changed, 16 insertions, 17 deletions
diff --git a/applications/luci-olsr/luasrc/controller/olsr.lua b/applications/luci-olsr/luasrc/controller/olsr.lua
index 6d6dc1ace2..a47496b31a 100644
--- a/applications/luci-olsr/luasrc/controller/olsr.lua
+++ b/applications/luci-olsr/luasrc/controller/olsr.lua
@@ -91,30 +91,29 @@ function index()
)
end
-function action_neigh()
- local data = fetch_txtinfo("links")
+local function compare_links(a, b)
+ local c = tonumber(a.Cost)
+ local d = tonumber(b.Cost)
- if not data or not data.Links then
- luci.template.render("status-olsr/error_olsr")
- return nil
+ if not c or c == 0 then
+ return false
end
- local function compare(a, b)
- local c = tonumber(a.Cost)
- local d = tonumber(b.Cost)
-
- if not c or c == 0 then
- return false
- end
+ if not d or d == 0 then
+ return true
+ end
+ return c < d
+end
- if not d or d == 0 then
- return true
- end
+function action_neigh(json)
+ local data = fetch_txtinfo("links")
- return c < d
+ if not data or not data.Links then
+ luci.template.render("status-olsr/error_olsr")
+ return nil
end
- table.sort(data.Links, compare)
+ table.sort(data.Links, compare_links)
luci.template.render("status-olsr/neighbors", {links=data.Links})
end