X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfatables%2Fruntime.py;h=235c67f2590e61e962c0d12e232a442e0418fba1;hb=b66306b1358def8542a702b711f58542e9a14c31;hp=0dab15d3869423ef16103f09d28879a459451db3;hpb=f7866302ad749a87e91516e1e37dbaec6f83c61c;p=sfa.git diff --git a/sfatables/runtime.py b/sfatables/runtime.py index 0dab15d3..235c67f2 100644 --- a/sfatables/runtime.py +++ b/sfatables/runtime.py @@ -6,69 +6,43 @@ import pdb import libxml2 from optparse import OptionParser -from sfatables import commands, matches, targets -from sfatables.xmlextension import Xmlextension +from sfatables import commands from sfatables.globals import * from sfatables.commands.List import * from sfatables.xmlrule import * class SFATablesRules: def __init__(self, chain_name): + self.contexts = None # placeholder for rspec_manger self.sorted_rule_list = [] - chain_dir_path = "%s/%s"%(sfatables_config,chain_name) + chain_dir_path = os.path.join(sfatables_config,chain_name) rule_list = List().get_rule_list(chain_dir_path) for rule_number in rule_list: self.sorted_rule_list.append(XMLRule(chain_name, rule_number)) return + def set_context(self, request_context): + return + def apply(self, rspec): intermediate_rspec = rspec for rule in self.sorted_rule_list: intermediate_rspec = rule.apply_interpreted(intermediate_rspec) + if (rule.terminal): + break - return intermediate_rspec + final_rspec = XMLRule().wrap_up(intermediate_rspec) + return final_rspec def main(): incoming = SFATablesRules('INCOMING') outgoing = SFATablesRules('OUTGOING') - rspec = """ - - - plc.princeton.sapan - - - - - hrn - plc - - - whitelist - plc.princeton - - - blacklist - plc.tp - - - - - - - - - - - - - """ - - - print "%d rules loaded for INCOMING chain\n"%len(incoming.sorted_rule_list) - print "%d rules loaded for OUTGOING chain\n"%len(outgoing.sorted_rule_list) + print "%d rules loaded for INCOMING chain"%len(incoming.sorted_rule_list) + print "%d rules loaded for OUTGOING chain"%len(outgoing.sorted_rule_list) + rspec = open(sys.argv[1]).read() newrspec = incoming.apply(rspec) print newrspec return