def create_flow_mod(dp, config): # matches_config = ConfigParser.get_matches(config) matches = Matches.create_matches(dp, matches_config) # instr_config = ConfigParser.get_instr_config(config) instructions = Instructions.create_instructions(dp, instr_config) # mod = dp.ofproto_parser.OFPFlowMod ( dp, cookie = 0, cookie_mask = 0, table_id = Utils.get_table(config["table"]), command = Utils.get_mod_command(dp, config["cmd"]), idle_timeout = 0, hard_timeout = 0, priority = 0, buffer_id = 0, out_port = Utils.get_mod_port(dp, config["port"]), out_group = Utils.get_mod_group(dp, config["group"]), flags=0, match=matches, instructions=instructions ) return mod
def create_flow_mod(dp, config): # matches_config = ConfigParser.get_matches(config) matches = Matches.create_matches(dp, matches_config) # instr_config = ConfigParser.get_instr_config(config) instructions = Instructions.create_instructions(dp, instr_config) # mod = dp.ofproto_parser.OFPFlowMod( dp, cookie=0, cookie_mask=0, table_id=Utils.get_table(config["table"]), command=Utils.get_mod_command(dp, config["cmd"]), idle_timeout=0, hard_timeout=0, priority=0, buffer_id=0, out_port=Utils.get_mod_port(dp, config["port"]), out_group=Utils.get_mod_group(dp, config["group"]), flags=0, match=matches, instructions=instructions) return mod
def switch_features_handler(self, ev): datapath = ev.msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser match = parser.OFPMatch() actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, ofproto.OFPCML_NO_BUFFER)] #FIXME: Sending packet-in message to controller is probably not by this way. # Based on the documenet about Source MAC Learning Feature, we need to use # client_srcmac_learn program or others to this. Indigo doesn't provide this. self.add_flow(datapath, 0, match, actions, Utils.get_table("TABLE_ACL"))
def delete_flow_mod(dp, config): # mod = dp.ofproto_parser.OFPFlowMod ( dp, cookie = 0, cookie_mask = 0, table_id = Utils.get_table(config["table"]), command = Utils.get_mod_command(dp, config["cmd"]), idle_timeout = 0, hard_timeout = 0, priority = 0, buffer_id = 0, out_port = Utils.get_mod_port(dp, config["port"]), out_group = Utils.get_mod_group(dp, config["group"]), flags=0 ) return mod
def process_goto(dp, config): table = Utils.get_table(config["table"]) return dp.ofproto_parser.OFPInstructionGotoTable(table)
def process_goto(dp,config): table = Utils.get_table(config["table"]) return dp.ofproto_parser.OFPInstructionGotoTable(table)
def add_ofdpa_flow(self, datapath, priority, vlan_vid, dst, out_port): #prerequisite ofproto = datapath.ofproto parser = datapath.ofproto_parser #the group id will be generated by increment group_id = generate_group_id() #vlan table match = parser.OFPMatch(in_port=in_port, vlan_vid=vlan_vid) type = ofproto.OFPIT_GOTO_TABLE inst = [parser.OFPInstructionGotoTable(type, Utils.get_table("TABLE_MAC"))] mod = parser.OFPFlowMod(datapath=datapath, cookie = 0, cookie_mask = 0, table_id=Utils.get_table("TABLE_VLAN"), command = Utils.get_mod_command(datapath, "add"), idle_timeout = 0, hard_timeout = 0, priority=priority, buffer_id = 0, match=match, out_port = Utils.get_mod_port(datapath, "any"), out_group = Utils.get_mod_group(datapath, "any"), flags=0, instructions=inst ) datapath.send_msg(mod) #bridging table match = parser.OFPMatch(eth_dst=dst, vlan_vid=vlan_vid) mask = mac.haddr_to_bin("ff:ff:ff:ff:ff:ff") match.set_dl_dst_masked(dst,mask) actions = [parser.OFPActionGroup(Utils.to_int(group_id))] type = ofproto.OFPIT_WRITE_ACTIONS inst = [parser.OFPInstructionActions(type, actions)] mod = parser.OFPFlowMod(datapath=datapath, cookie = 0, cookie_mask = 0, table_id=Utils.get_table("TABLE_BRIDGING"), command = Utils.get_mod_command(datapath, "add"), idle_timeout = 0, hard_timeout = 0, priority=priority, buffer_id = 0, match=match, out_port = Utils.get_mod_port(datapath, "any"), out_group = Utils.get_mod_group(datapath, "any"), flags=0, instructions=inst ) datapath.send_msg(mod) #L2 Group table actions = [parser.OFPActionOutput(out_port)] buckets = [] bucket = datapath.ofproto_parser.OFPBucket( weight = Utils.to_int("0"), watch_port = Utils.get_mod_port("any"), watch_group = Utils.get_mod_group("any"), actions = actions ) buckets.append(bucket) print "buckets: %s" % buckets mod = datapath.ofproto_parser.OFPGroupMod( datapath, Utils.get_mod_command(datapath, "add"), Utils.get_mod_type(datapath, "indirect"), Utils.get_mod_group(datapath, group_id), buckets ) datapath.send_msg(mod)