From 2ded2732710d0595ad7752ee1071dd35106fabd0 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 3 Dec 2016 14:49:22 +0100 Subject: [PATCH 1/2] Update poc.py Rewriting filter function so that both allow/deny-rule and filter-range will be evaluated. Suitable for e.g. signal-RIC --- includes/decoders/poc.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index b0d1fcd..df4e5ad 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -29,28 +29,37 @@ def isAllowed(poc_id): @requires: Configuration has to be set in the config.ini - @return: True if the Ric is allowed, other False + @return: Checks both allow/deny-rule and filter-range (suitable for signal-RIC) @exception: none """ - # 1.) If allowed RICs is set, only they will path, - # If RIC is the right one return True, else False + + allowed = 0 + + # 1.) Allow + # If RIC is allowed, return true; otherwise go on if globalVars.config.get("POC", "allow_ric"): if poc_id in globalVars.config.get("POC", "allow_ric"): logging.info("RIC %s is allowed", poc_id) return True else: logging.info("RIC %s is not in the allowed list", poc_id) - return False - # 2.) If denied RIC, return False - elif poc_id in globalVars.config.get("POC", "deny_ric"): + allowed = 0 + + # 2.) Deny + # If RIC is denied, mark as not allowed + if poc_id in globalVars.config.get("POC", "deny_ric"): logging.info("RIC %s is denied by config.ini", poc_id) - return False - # 3.) Check Range, return False if outside def. range - elif int(poc_id) < globalVars.config.getint("POC", "filter_range_start"): - logging.info("RIC %s out of filter range (start)", poc_id) - return False - elif int(poc_id) > globalVars.config.getint("POC", "filter_range_end"): - logging.info("RIC %s out of filter range (end)", poc_id) + allowed = 0 + + # 3.) Check Range, return true if in between + if globalVars.config.getint("POC", "filter_range_start") < int(poc_id) < globalVars.config.getint("POC", "filter_range_end"): + logging.info("RIC %s in between filter range", poc_id) + return True + else: + logging.info("RIC %s out of filter range", poc_id) + allowed = 0 + + if allowed == 0: return False return True From ae1c27b45fa045da38b14b0175902abf0245d032 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 3 Dec 2016 15:39:35 +0100 Subject: [PATCH 2/2] Update poc.py Including upper and lower boundary --- includes/decoders/poc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index df4e5ad..b686cf2 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -52,7 +52,7 @@ def isAllowed(poc_id): allowed = 0 # 3.) Check Range, return true if in between - if globalVars.config.getint("POC", "filter_range_start") < int(poc_id) < globalVars.config.getint("POC", "filter_range_end"): + if globalVars.config.getint("POC", "filter_range_start") <= int(poc_id) <= globalVars.config.getint("POC", "filter_range_end"): logging.info("RIC %s in between filter range", poc_id) return True else: