From e41e5cb8d9aa96de8a3ac1cdd656ce7821c35eda Mon Sep 17 00:00:00 2001
From: Christof Schulze <christof.schulze@gmx.net>
Date: Wed, 21 Dec 2016 20:25:21 +0100
Subject: [PATCH] gluon-core: add get_mesh_devices(uconn) to gluon.util which
 will return all devices being up and having proto = gluon_mesh

---
 package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
index 7afee87fb..f07f0ab1c 100644
--- a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
+++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
@@ -73,6 +73,16 @@ function node_id()
 	return string.gsub(sysconfig.primary_mac, ':', '')
 end
 
+function get_mesh_devices(uconn)
+	local dump = uconn:call("network.interface", "dump", {})
+	local devices = {}
+	for _, interface in ipairs(dump.interface) do
+	    if ( (interface.proto == "gluon_mesh") and interface.up ) then
+			table.insert(devices, interface.device)
+	    end
+	end
+	return devices
+end
 
 local function find_phy_by_path(path)
 	for phy in fs.glob('/sys/devices/' .. path .. '/ieee80211/phy*') do
-- 
GitLab