def install_garden(self, flow): msg = build_rewrite_rule(flow) if self.eventSwitch is not None: print 'Send garden message.' self.eventSwitch.connection.send(msg) msg.command = of.ofp_flow_mod_command_rev_map['OFPFC_ADD'] self.eventSwitch.connection.send(msg)
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)
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 and exempt_state: msg = build_rewrite_rule(flow) if self.eventSwitch is not None: print 'Send gardenwall message.' msg.command = of.ofp_flow_mod_command_rev_map['OFPFC_ADD'] self.eventSwitch.connection.send(msg) # Else if infected is True, drop. elif infected_state: self.install_block(flow) # Else allow by default (check clear_block(flow)) else: self.clear_block(flow)
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)