policy-endpoint-device.lua: logic to connect endpoint to filter

While handling endpoints, first check to see if there is a filter
intending to connect to it.
Also prevent Endpoints connecting to filters unless otherwise
configured.
This commit is contained in:
Ashok Sidipotu
2023-11-22 06:49:10 +01:00
committed by George Kiagiadakis
parent 83e990bf2d
commit 9f6066ea0d
2 changed files with 26 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ function configProperties(node)
["priority.session"] = np["priority.session"],
["device.id"] = np["device.id"],
["card.profile.device"] = np["card.profile.device"],
["target.endpoint"] = np["target.endpoint"],
}
for k, v in pairs(np) do

View File

@@ -41,10 +41,26 @@ function scheduleRescan ()
end
end
function findFilterTarget (props)
for si_target in linkables_om:iterate {
-- exclude filter targets
Constraint { "node.link-group", "+" },
} do
local si_props = si_target.properties
if si_props["target.endpoint"] and si_props["target.endpoint"] == props["name"] then
return si_target
end
end
end
function findTargetByDefaultNode (target_media_class)
local def_id = default_nodes:call("get-default-node", target_media_class)
if def_id ~= Id.INVALID then
for si_target in linkables_om:iterate() do
for si_target in linkables_om:iterate {
-- exclude filter targets
Constraint { "node.link-group", "-" },
} do
local target_node = si_target:get_associated_proxy ("node")
if target_node["bound-id"] == def_id then
return si_target
@@ -55,7 +71,10 @@ function findTargetByDefaultNode (target_media_class)
end
function findTargetByFirstAvailable (target_media_class)
for si_target in linkables_om:iterate() do
for si_target in linkables_om:iterate {
-- exclude filter targets
Constraint { "node.link-group", "-" },
} do
local target_node = si_target:get_associated_proxy ("node")
if target_node.properties["media.class"] == target_media_class then
return si_target
@@ -76,7 +95,10 @@ function findUndefinedTarget (si_ep)
return nil
end
local si_target = findTargetByDefaultNode (target_media_class)
local si_target = findFilterTarget (si_ep.properties)
if not si_target then
si_target = findTargetByDefaultNode (target_media_class)
end
if not si_target then
si_target = findTargetByFirstAvailable (target_media_class)
end