Ejemplo n.º 1
0
 def rule_update(self, flow):
     infected_state = self.get_flowstate_map(flow, 'infected')
     exempt_state = self.get_flowstate_map(flow, 'exempt')
     if infected_state is None:
         infected_state = bool(infected_state)
     print "infected_state=%s" % infected_state
     exempt_state = self.get_flowstate_map(flow, 'exempt')
     if exempt_state is None:
         exempt_state = bool(exempt_state)
     print "exempt_state=%s" % exempt_state
     ### --- Add your logic here ---- ###
     # Forward to gardenwall if both True.
     # Else if infected is True, drop.
     # Else allow by default (check clear_block(flow))
     if (infected_state == 'True') and (exempt_state == 'True'):
         print "infected and exempt"
         msg = build_clear_rule(flow)
         self.eventSwitch.connection.send(msg)
         msg = build_rewrite_rule(flow)
         self.eventSwitch.connection.send(msg)
     else:
         if infected_state == 'True':
             print " only infected "
             self.install_block(flow)
         else:
             print "not_infected - clear"
             self.clear_block(flow)
Ejemplo n.º 2
0
    def rule_update(self, flow):
        infected_state = self.get_flowstate_map(flow, 'infected')
        exempt_state = self.get_flowstate_map(flow, 'exempt')
        
        ### --- Add your logic here ---- ###
        
        # Forward to gardenwall if both True.
        if (infected_state == 'True') and (exempt_state == 'True'):
            msg = build_clear_rule(flow)
            self.eventSwitch.connection.send(msg)
            msg = build_rewrite_rule(flow)
            self.eventSwitch.connection.send(msg)

        # Else if infected is True, drop.
        else:
            if infected_state == 'True':
                self.install_block(flow)

        # Else allow by default (check clear_block(flow))
            else:
                self.clear_block(flow)
 def clear_pass(self, flow):
     msg = build_clear_rule(flow)
     if self.eventSwitch is not None:
         print 'Send clear pass message.'
         self.eventSwitch.connection.send(msg)
Ejemplo n.º 4
0
 def clear_pass(self, flow):
     msg = build_clear_rule(flow)
     if self.eventSwitch is not None:
         print 'Send clear pass message.'
         self.eventSwitch.connection.send(msg)