def genFlowModFlush(): """ Genericly usable flush_flow command @return flow_mod with delete command """ flow_mod = message.flow_mod() flow_mod.match.wildcards = ofp.OFPFW_ALL flow_mod.command = ofp.OFPFC_DELETE flow_mod.priority = 0 flow_mod.buffer_id = 0xffffffff flow_mod.out_port = ofp.OFPP_NONE return flow_mod
def genFloModFromPkt(parent, pkt, ing_port=ofp.OFPP_NONE, action_list=None, wildcards=0, egr_port=None): """ Create a flow_mod message from a packet The created flow_mod will match on the given packet with given wildcards. @param parent parent must have logger (Logging object) @param pkt Parsed and used to construct a flow_mod @param ing_port ingress port @param action_list list of actions @param wildcards Used as a field on match structure @param egr_port Used for output action @return flow_mod """ logprefix = "FlowMsgCreate: " match = parse.packet_to_flow_match(pkt) parent.assertTrue(match is not None, "Flow match from pkt failed") match.wildcards = wildcards match.in_port = ing_port request = message.flow_mod() request.match = match request.buffer_id = 0xffffffff if action_list is not None: for act in action_list: parent.logger.debug(logprefix + "Adding action " + act.show()) rv = request.actions.add(act) parent.assertTrue(rv, "Could not add action" + act.show()) # Set up output/enqueue action if directed if egr_port is not None: act = action.action_output() act.port = egr_port rv = request.actions.add(act) parent.assertTrue(rv, "Could not add output action " + str(egr_port)) parent.logger.debug(logprefix + str(request.show())) return request