Implemented terminal rules
authorSapan Bhatia <sapanb@cs.princeton.edu>
Wed, 16 Sep 2009 14:02:56 +0000 (14:02 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Wed, 16 Sep 2009 14:02:56 +0000 (14:02 +0000)
sfatables/runtime.py
sfatables/sfatables

index 0dab15d..dc9e7cb 100644 (file)
@@ -26,6 +26,8 @@ class SFATablesRules:
         intermediate_rspec = rspec
         for rule in self.sorted_rule_list:
             intermediate_rspec  = rule.apply_interpreted(intermediate_rspec)
+            if (rule.terminal):
+                break
 
         return intermediate_rspec
 
@@ -33,37 +35,8 @@ def main():
     incoming = SFATablesRules('INCOMING')
     outgoing = SFATablesRules('OUTGOING')
 
-    rspec = """
-<rspec>
-    <request-context>
-        <sfa><user><hrn>plc.princeton.sapan</hrn></user></sfa>
-    </request-context>
+    rspec = open(sys.argv[1]).read()
 
-    <sfatables-rule>
-            <argument>
-                <name>hrn</name>
-                <value>plc</value>
-            </argument>
-            <argument>
-                <name>whitelist</name>
-                <value>plc.princeton</value>
-            </argument>
-            <argument>
-                <name>blacklist</name>
-                <value>plc.tp</value>
-            </argument>
-    </sfatables-rule>
-    <request>
-        <nodespec>
-            <node name="plc.princeton.planetlab-01"/>
-            <node name="plc.princeton.planetlab-02"/>
-            <node name="plc.princeton.planetlab-03"/>
-            <node name="plc.princeton.planetlab-04"/>
-            <node name="plc.tp.planetlab3"/>
-        </nodespec>
-    </request>
-</rspec>
-    """
 
     
     print "%d rules loaded for INCOMING chain\n"%len(incoming.sorted_rule_list)
index 9abcf6c..7f61a3f 100755 (executable)
@@ -91,7 +91,7 @@ def main():
         match_parser = create_parser_xml_ext(match_dict)
         matches_str = ",".join(match_dict.keys())
         match_parser.add_option('-m','--match',dest='name',help='Match name (one of %s)'%matches_str, metavar = 'MATCH')
-        match_parser.add_option('-n','--negate',dest='negate',help='Negate result',action=store_true)
+        match_parser.add_option('-n','--negate',dest='negate',help='Negate result',action='store_true')
         (match_options, args) = match_parser.parse_args(pargs[1])
         try:
             name = match_options.name